]> code.delx.au - gnu-emacs/blob - lisp/term/x-win.el
Only require fontset when new-fontset is bound.
[gnu-emacs] / lisp / term / x-win.el
1 ;;; x-win.el --- parse switches controlling interface with X window system
2
3 ;; Copyright (C) 1993, 1994, 2001 Free Software Foundation, Inc.
4
5 ;; Author: FSF
6 ;; Keywords: terminals
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; X-win.el: this file is loaded from ../lisp/startup.el when it recognizes
28 ;; that X windows are to be used. Command line switches are parsed and those
29 ;; pertaining to X are processed and removed from the command line. The
30 ;; X display is opened and hooks are set for popping up the initial window.
31
32 ;; startup.el will then examine startup files, and eventually call the hooks
33 ;; which create the first window (s).
34
35 ;;; Code:
36 \f
37 ;; These are the standard X switches from the Xt Initialize.c file of
38 ;; Release 4.
39
40 ;; Command line Resource Manager string
41
42 ;; +rv *reverseVideo
43 ;; +synchronous *synchronous
44 ;; -background *background
45 ;; -bd *borderColor
46 ;; -bg *background
47 ;; -bordercolor *borderColor
48 ;; -borderwidth .borderWidth
49 ;; -bw .borderWidth
50 ;; -display .display
51 ;; -fg *foreground
52 ;; -fn *font
53 ;; -font *font
54 ;; -foreground *foreground
55 ;; -geometry .geometry
56 ;; -i .iconType
57 ;; -itype .iconType
58 ;; -iconic .iconic
59 ;; -name .name
60 ;; -reverse *reverseVideo
61 ;; -rv *reverseVideo
62 ;; -selectionTimeout .selectionTimeout
63 ;; -synchronous *synchronous
64 ;; -xrm
65
66 ;; An alist of X options and the function which handles them. See
67 ;; ../startup.el.
68
69 (if (not (eq window-system 'x))
70 (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
71
72 (require 'frame)
73 (require 'mouse)
74 (require 'scroll-bar)
75 (require 'faces)
76 (require 'select)
77 (require 'menu-bar)
78 (if (fboundp 'new-fontset)
79 (require 'fontset))
80
81 (defvar x-invocation-args)
82
83 (defvar x-command-line-resources nil)
84
85 ;; Handler for switches of the form "-switch value" or "-switch".
86 (defun x-handle-switch (switch)
87 (let ((aelt (assoc switch command-line-x-option-alist)))
88 (if aelt
89 (let ((param (nth 3 aelt))
90 (value (nth 4 aelt)))
91 (if value
92 (setq default-frame-alist
93 (cons (cons param value)
94 default-frame-alist))
95 (setq default-frame-alist
96 (cons (cons param
97 (car x-invocation-args))
98 default-frame-alist)
99 x-invocation-args (cdr x-invocation-args)))))))
100
101 ;; Handler for switches of the form "-switch n"
102 (defun x-handle-numeric-switch (switch)
103 (let ((aelt (assoc switch command-line-x-option-alist)))
104 (if aelt
105 (let ((param (nth 3 aelt)))
106 (setq default-frame-alist
107 (cons (cons param
108 (string-to-int (car x-invocation-args)))
109 default-frame-alist)
110 x-invocation-args
111 (cdr x-invocation-args))))))
112
113 ;; Handle options that apply to initial frame only
114 (defun x-handle-initial-switch (switch)
115 (let ((aelt (assoc switch command-line-x-option-alist)))
116 (if aelt
117 (let ((param (nth 3 aelt))
118 (value (nth 4 aelt)))
119 (if value
120 (setq initial-frame-alist
121 (cons (cons param value)
122 initial-frame-alist))
123 (setq initial-frame-alist
124 (cons (cons param
125 (car x-invocation-args))
126 initial-frame-alist)
127 x-invocation-args (cdr x-invocation-args)))))))
128
129 ;; Make -iconic apply only to the initial frame!
130 (defun x-handle-iconic (switch)
131 (setq initial-frame-alist
132 (cons '(visibility . icon) initial-frame-alist)))
133
134 ;; Handle the -xrm option.
135 (defun x-handle-xrm-switch (switch)
136 (unless (consp x-invocation-args)
137 (error "%s: missing argument to `%s' option" (invocation-name) switch))
138 (setq x-command-line-resources
139 (if (null x-command-line-resources)
140 (car x-invocation-args)
141 (concat x-command-line-resources "\n" (car x-invocation-args))))
142 (setq x-invocation-args (cdr x-invocation-args)))
143
144 ;; Handle the geometry option
145 (defun x-handle-geometry (switch)
146 (let* ((geo (x-parse-geometry (car x-invocation-args)))
147 (left (assq 'left geo))
148 (top (assq 'top geo))
149 (height (assq 'height geo))
150 (width (assq 'width geo)))
151 (if (or height width)
152 (setq default-frame-alist
153 (append default-frame-alist
154 '((user-size . t))
155 (if height (list height))
156 (if width (list width)))))
157 (if (or left top)
158 (setq initial-frame-alist
159 (append initial-frame-alist
160 '((user-position . t))
161 (if left (list left))
162 (if top (list top)))))
163 (setq x-invocation-args (cdr x-invocation-args))))
164
165 ;; Handle the -name option. Set the variable x-resource-name
166 ;; to the option's operand; set the name of
167 ;; the initial frame, too.
168 (defun x-handle-name-switch (switch)
169 (or (consp x-invocation-args)
170 (error "%s: missing argument to `%s' option" (invocation-name) switch))
171 (setq x-resource-name (car x-invocation-args)
172 x-invocation-args (cdr x-invocation-args))
173 (setq initial-frame-alist (cons (cons 'name x-resource-name)
174 initial-frame-alist)))
175
176 (defvar x-display-name nil
177 "The X display name specifying server and X frame.")
178
179 (defun x-handle-display (switch)
180 (setq x-display-name (car x-invocation-args)
181 x-invocation-args (cdr x-invocation-args))
182 ;; Make subshell programs see the same DISPLAY value Emacs really uses.
183 ;; Note that this isn't completely correct, since Emacs can use
184 ;; multiple displays. However, there is no way to tell an already
185 ;; running subshell which display the user is currently typing on.
186 (setenv "DISPLAY" x-display-name))
187
188 (defun x-handle-args (args)
189 "Process the X-related command line options in ARGS.
190 This is done before the user's startup file is loaded. They are copied to
191 `x-invocation-args', from which the X-related things are extracted, first
192 the switch (e.g., \"-fg\") in the following code, and possible values
193 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
194 This function returns ARGS minus the arguments that have been processed."
195 ;; We use ARGS to accumulate the args that we don't handle here, to return.
196 (setq x-invocation-args args
197 args nil)
198 (while (and x-invocation-args
199 (not (equal (car x-invocation-args) "--")))
200 (let* ((this-switch (car x-invocation-args))
201 (orig-this-switch this-switch)
202 completion argval aelt handler)
203 (setq x-invocation-args (cdr x-invocation-args))
204 ;; Check for long options with attached arguments
205 ;; and separate out the attached option argument into argval.
206 (if (string-match "^--[^=]*=" this-switch)
207 (setq argval (substring this-switch (match-end 0))
208 this-switch (substring this-switch 0 (1- (match-end 0)))))
209 ;; Complete names of long options.
210 (if (string-match "^--" this-switch)
211 (progn
212 (setq completion (try-completion this-switch command-line-x-option-alist))
213 (if (eq completion t)
214 ;; Exact match for long option.
215 nil
216 (if (stringp completion)
217 (let ((elt (assoc completion command-line-x-option-alist)))
218 ;; Check for abbreviated long option.
219 (or elt
220 (error "Option `%s' is ambiguous" this-switch))
221 (setq this-switch completion))))))
222 (setq aelt (assoc this-switch command-line-x-option-alist))
223 (if aelt (setq handler (nth 2 aelt)))
224 (if handler
225 (if argval
226 (let ((x-invocation-args
227 (cons argval x-invocation-args)))
228 (funcall handler this-switch))
229 (funcall handler this-switch))
230 (setq args (cons orig-this-switch args)))))
231 (nconc (nreverse args) x-invocation-args))
232 \f
233 ;;
234 ;; Standard X cursor shapes, courtesy of Mr. Fox, who wanted ALL of them.
235 ;;
236
237 (defconst x-pointer-X-cursor 0)
238 (defconst x-pointer-arrow 2)
239 (defconst x-pointer-based-arrow-down 4)
240 (defconst x-pointer-based-arrow-up 6)
241 (defconst x-pointer-boat 8)
242 (defconst x-pointer-bogosity 10)
243 (defconst x-pointer-bottom-left-corner 12)
244 (defconst x-pointer-bottom-right-corner 14)
245 (defconst x-pointer-bottom-side 16)
246 (defconst x-pointer-bottom-tee 18)
247 (defconst x-pointer-box-spiral 20)
248 (defconst x-pointer-center-ptr 22)
249 (defconst x-pointer-circle 24)
250 (defconst x-pointer-clock 26)
251 (defconst x-pointer-coffee-mug 28)
252 (defconst x-pointer-cross 30)
253 (defconst x-pointer-cross-reverse 32)
254 (defconst x-pointer-crosshair 34)
255 (defconst x-pointer-diamond-cross 36)
256 (defconst x-pointer-dot 38)
257 (defconst x-pointer-dotbox 40)
258 (defconst x-pointer-double-arrow 42)
259 (defconst x-pointer-draft-large 44)
260 (defconst x-pointer-draft-small 46)
261 (defconst x-pointer-draped-box 48)
262 (defconst x-pointer-exchange 50)
263 (defconst x-pointer-fleur 52)
264 (defconst x-pointer-gobbler 54)
265 (defconst x-pointer-gumby 56)
266 (defconst x-pointer-hand1 58)
267 (defconst x-pointer-hand2 60)
268 (defconst x-pointer-heart 62)
269 (defconst x-pointer-icon 64)
270 (defconst x-pointer-iron-cross 66)
271 (defconst x-pointer-left-ptr 68)
272 (defconst x-pointer-left-side 70)
273 (defconst x-pointer-left-tee 72)
274 (defconst x-pointer-leftbutton 74)
275 (defconst x-pointer-ll-angle 76)
276 (defconst x-pointer-lr-angle 78)
277 (defconst x-pointer-man 80)
278 (defconst x-pointer-middlebutton 82)
279 (defconst x-pointer-mouse 84)
280 (defconst x-pointer-pencil 86)
281 (defconst x-pointer-pirate 88)
282 (defconst x-pointer-plus 90)
283 (defconst x-pointer-question-arrow 92)
284 (defconst x-pointer-right-ptr 94)
285 (defconst x-pointer-right-side 96)
286 (defconst x-pointer-right-tee 98)
287 (defconst x-pointer-rightbutton 100)
288 (defconst x-pointer-rtl-logo 102)
289 (defconst x-pointer-sailboat 104)
290 (defconst x-pointer-sb-down-arrow 106)
291 (defconst x-pointer-sb-h-double-arrow 108)
292 (defconst x-pointer-sb-left-arrow 110)
293 (defconst x-pointer-sb-right-arrow 112)
294 (defconst x-pointer-sb-up-arrow 114)
295 (defconst x-pointer-sb-v-double-arrow 116)
296 (defconst x-pointer-shuttle 118)
297 (defconst x-pointer-sizing 120)
298 (defconst x-pointer-spider 122)
299 (defconst x-pointer-spraycan 124)
300 (defconst x-pointer-star 126)
301 (defconst x-pointer-target 128)
302 (defconst x-pointer-tcross 130)
303 (defconst x-pointer-top-left-arrow 132)
304 (defconst x-pointer-top-left-corner 134)
305 (defconst x-pointer-top-right-corner 136)
306 (defconst x-pointer-top-side 138)
307 (defconst x-pointer-top-tee 140)
308 (defconst x-pointer-trek 142)
309 (defconst x-pointer-ul-angle 144)
310 (defconst x-pointer-umbrella 146)
311 (defconst x-pointer-ur-angle 148)
312 (defconst x-pointer-watch 150)
313 (defconst x-pointer-xterm 152)
314 \f
315 ;;
316 ;; Available colors
317 ;;
318
319 (defvar x-colors '("LightGreen"
320 "light green"
321 "DarkRed"
322 "dark red"
323 "DarkMagenta"
324 "dark magenta"
325 "DarkCyan"
326 "dark cyan"
327 "DarkBlue"
328 "dark blue"
329 "DarkGray"
330 "dark gray"
331 "DarkGrey"
332 "dark grey"
333 "grey100"
334 "gray100"
335 "grey99"
336 "gray99"
337 "grey98"
338 "gray98"
339 "grey97"
340 "gray97"
341 "grey96"
342 "gray96"
343 "grey95"
344 "gray95"
345 "grey94"
346 "gray94"
347 "grey93"
348 "gray93"
349 "grey92"
350 "gray92"
351 "grey91"
352 "gray91"
353 "grey90"
354 "gray90"
355 "grey89"
356 "gray89"
357 "grey88"
358 "gray88"
359 "grey87"
360 "gray87"
361 "grey86"
362 "gray86"
363 "grey85"
364 "gray85"
365 "grey84"
366 "gray84"
367 "grey83"
368 "gray83"
369 "grey82"
370 "gray82"
371 "grey81"
372 "gray81"
373 "grey80"
374 "gray80"
375 "grey79"
376 "gray79"
377 "grey78"
378 "gray78"
379 "grey77"
380 "gray77"
381 "grey76"
382 "gray76"
383 "grey75"
384 "gray75"
385 "grey74"
386 "gray74"
387 "grey73"
388 "gray73"
389 "grey72"
390 "gray72"
391 "grey71"
392 "gray71"
393 "grey70"
394 "gray70"
395 "grey69"
396 "gray69"
397 "grey68"
398 "gray68"
399 "grey67"
400 "gray67"
401 "grey66"
402 "gray66"
403 "grey65"
404 "gray65"
405 "grey64"
406 "gray64"
407 "grey63"
408 "gray63"
409 "grey62"
410 "gray62"
411 "grey61"
412 "gray61"
413 "grey60"
414 "gray60"
415 "grey59"
416 "gray59"
417 "grey58"
418 "gray58"
419 "grey57"
420 "gray57"
421 "grey56"
422 "gray56"
423 "grey55"
424 "gray55"
425 "grey54"
426 "gray54"
427 "grey53"
428 "gray53"
429 "grey52"
430 "gray52"
431 "grey51"
432 "gray51"
433 "grey50"
434 "gray50"
435 "grey49"
436 "gray49"
437 "grey48"
438 "gray48"
439 "grey47"
440 "gray47"
441 "grey46"
442 "gray46"
443 "grey45"
444 "gray45"
445 "grey44"
446 "gray44"
447 "grey43"
448 "gray43"
449 "grey42"
450 "gray42"
451 "grey41"
452 "gray41"
453 "grey40"
454 "gray40"
455 "grey39"
456 "gray39"
457 "grey38"
458 "gray38"
459 "grey37"
460 "gray37"
461 "grey36"
462 "gray36"
463 "grey35"
464 "gray35"
465 "grey34"
466 "gray34"
467 "grey33"
468 "gray33"
469 "grey32"
470 "gray32"
471 "grey31"
472 "gray31"
473 "grey30"
474 "gray30"
475 "grey29"
476 "gray29"
477 "grey28"
478 "gray28"
479 "grey27"
480 "gray27"
481 "grey26"
482 "gray26"
483 "grey25"
484 "gray25"
485 "grey24"
486 "gray24"
487 "grey23"
488 "gray23"
489 "grey22"
490 "gray22"
491 "grey21"
492 "gray21"
493 "grey20"
494 "gray20"
495 "grey19"
496 "gray19"
497 "grey18"
498 "gray18"
499 "grey17"
500 "gray17"
501 "grey16"
502 "gray16"
503 "grey15"
504 "gray15"
505 "grey14"
506 "gray14"
507 "grey13"
508 "gray13"
509 "grey12"
510 "gray12"
511 "grey11"
512 "gray11"
513 "grey10"
514 "gray10"
515 "grey9"
516 "gray9"
517 "grey8"
518 "gray8"
519 "grey7"
520 "gray7"
521 "grey6"
522 "gray6"
523 "grey5"
524 "gray5"
525 "grey4"
526 "gray4"
527 "grey3"
528 "gray3"
529 "grey2"
530 "gray2"
531 "grey1"
532 "gray1"
533 "grey0"
534 "gray0"
535 "thistle4"
536 "thistle3"
537 "thistle2"
538 "thistle1"
539 "MediumPurple4"
540 "MediumPurple3"
541 "MediumPurple2"
542 "MediumPurple1"
543 "purple4"
544 "purple3"
545 "purple2"
546 "purple1"
547 "DarkOrchid4"
548 "DarkOrchid3"
549 "DarkOrchid2"
550 "DarkOrchid1"
551 "MediumOrchid4"
552 "MediumOrchid3"
553 "MediumOrchid2"
554 "MediumOrchid1"
555 "plum4"
556 "plum3"
557 "plum2"
558 "plum1"
559 "orchid4"
560 "orchid3"
561 "orchid2"
562 "orchid1"
563 "magenta4"
564 "magenta3"
565 "magenta2"
566 "magenta1"
567 "VioletRed4"
568 "VioletRed3"
569 "VioletRed2"
570 "VioletRed1"
571 "maroon4"
572 "maroon3"
573 "maroon2"
574 "maroon1"
575 "PaleVioletRed4"
576 "PaleVioletRed3"
577 "PaleVioletRed2"
578 "PaleVioletRed1"
579 "LightPink4"
580 "LightPink3"
581 "LightPink2"
582 "LightPink1"
583 "pink4"
584 "pink3"
585 "pink2"
586 "pink1"
587 "HotPink4"
588 "HotPink3"
589 "HotPink2"
590 "HotPink1"
591 "DeepPink4"
592 "DeepPink3"
593 "DeepPink2"
594 "DeepPink1"
595 "red4"
596 "red3"
597 "red2"
598 "red1"
599 "OrangeRed4"
600 "OrangeRed3"
601 "OrangeRed2"
602 "OrangeRed1"
603 "tomato4"
604 "tomato3"
605 "tomato2"
606 "tomato1"
607 "coral4"
608 "coral3"
609 "coral2"
610 "coral1"
611 "DarkOrange4"
612 "DarkOrange3"
613 "DarkOrange2"
614 "DarkOrange1"
615 "orange4"
616 "orange3"
617 "orange2"
618 "orange1"
619 "LightSalmon4"
620 "LightSalmon3"
621 "LightSalmon2"
622 "LightSalmon1"
623 "salmon4"
624 "salmon3"
625 "salmon2"
626 "salmon1"
627 "brown4"
628 "brown3"
629 "brown2"
630 "brown1"
631 "firebrick4"
632 "firebrick3"
633 "firebrick2"
634 "firebrick1"
635 "chocolate4"
636 "chocolate3"
637 "chocolate2"
638 "chocolate1"
639 "tan4"
640 "tan3"
641 "tan2"
642 "tan1"
643 "wheat4"
644 "wheat3"
645 "wheat2"
646 "wheat1"
647 "burlywood4"
648 "burlywood3"
649 "burlywood2"
650 "burlywood1"
651 "sienna4"
652 "sienna3"
653 "sienna2"
654 "sienna1"
655 "IndianRed4"
656 "IndianRed3"
657 "IndianRed2"
658 "IndianRed1"
659 "RosyBrown4"
660 "RosyBrown3"
661 "RosyBrown2"
662 "RosyBrown1"
663 "DarkGoldenrod4"
664 "DarkGoldenrod3"
665 "DarkGoldenrod2"
666 "DarkGoldenrod1"
667 "goldenrod4"
668 "goldenrod3"
669 "goldenrod2"
670 "goldenrod1"
671 "gold4"
672 "gold3"
673 "gold2"
674 "gold1"
675 "yellow4"
676 "yellow3"
677 "yellow2"
678 "yellow1"
679 "LightYellow4"
680 "LightYellow3"
681 "LightYellow2"
682 "LightYellow1"
683 "LightGoldenrod4"
684 "LightGoldenrod3"
685 "LightGoldenrod2"
686 "LightGoldenrod1"
687 "khaki4"
688 "khaki3"
689 "khaki2"
690 "khaki1"
691 "DarkOliveGreen4"
692 "DarkOliveGreen3"
693 "DarkOliveGreen2"
694 "DarkOliveGreen1"
695 "OliveDrab4"
696 "OliveDrab3"
697 "OliveDrab2"
698 "OliveDrab1"
699 "chartreuse4"
700 "chartreuse3"
701 "chartreuse2"
702 "chartreuse1"
703 "green4"
704 "green3"
705 "green2"
706 "green1"
707 "SpringGreen4"
708 "SpringGreen3"
709 "SpringGreen2"
710 "SpringGreen1"
711 "PaleGreen4"
712 "PaleGreen3"
713 "PaleGreen2"
714 "PaleGreen1"
715 "SeaGreen4"
716 "SeaGreen3"
717 "SeaGreen2"
718 "SeaGreen1"
719 "DarkSeaGreen4"
720 "DarkSeaGreen3"
721 "DarkSeaGreen2"
722 "DarkSeaGreen1"
723 "aquamarine4"
724 "aquamarine3"
725 "aquamarine2"
726 "aquamarine1"
727 "DarkSlateGray4"
728 "DarkSlateGray3"
729 "DarkSlateGray2"
730 "DarkSlateGray1"
731 "cyan4"
732 "cyan3"
733 "cyan2"
734 "cyan1"
735 "turquoise4"
736 "turquoise3"
737 "turquoise2"
738 "turquoise1"
739 "CadetBlue4"
740 "CadetBlue3"
741 "CadetBlue2"
742 "CadetBlue1"
743 "PaleTurquoise4"
744 "PaleTurquoise3"
745 "PaleTurquoise2"
746 "PaleTurquoise1"
747 "LightCyan4"
748 "LightCyan3"
749 "LightCyan2"
750 "LightCyan1"
751 "LightBlue4"
752 "LightBlue3"
753 "LightBlue2"
754 "LightBlue1"
755 "LightSteelBlue4"
756 "LightSteelBlue3"
757 "LightSteelBlue2"
758 "LightSteelBlue1"
759 "SlateGray4"
760 "SlateGray3"
761 "SlateGray2"
762 "SlateGray1"
763 "LightSkyBlue4"
764 "LightSkyBlue3"
765 "LightSkyBlue2"
766 "LightSkyBlue1"
767 "SkyBlue4"
768 "SkyBlue3"
769 "SkyBlue2"
770 "SkyBlue1"
771 "DeepSkyBlue4"
772 "DeepSkyBlue3"
773 "DeepSkyBlue2"
774 "DeepSkyBlue1"
775 "SteelBlue4"
776 "SteelBlue3"
777 "SteelBlue2"
778 "SteelBlue1"
779 "DodgerBlue4"
780 "DodgerBlue3"
781 "DodgerBlue2"
782 "DodgerBlue1"
783 "blue4"
784 "blue3"
785 "blue2"
786 "blue1"
787 "RoyalBlue4"
788 "RoyalBlue3"
789 "RoyalBlue2"
790 "RoyalBlue1"
791 "SlateBlue4"
792 "SlateBlue3"
793 "SlateBlue2"
794 "SlateBlue1"
795 "azure4"
796 "azure3"
797 "azure2"
798 "azure1"
799 "MistyRose4"
800 "MistyRose3"
801 "MistyRose2"
802 "MistyRose1"
803 "LavenderBlush4"
804 "LavenderBlush3"
805 "LavenderBlush2"
806 "LavenderBlush1"
807 "honeydew4"
808 "honeydew3"
809 "honeydew2"
810 "honeydew1"
811 "ivory4"
812 "ivory3"
813 "ivory2"
814 "ivory1"
815 "cornsilk4"
816 "cornsilk3"
817 "cornsilk2"
818 "cornsilk1"
819 "LemonChiffon4"
820 "LemonChiffon3"
821 "LemonChiffon2"
822 "LemonChiffon1"
823 "NavajoWhite4"
824 "NavajoWhite3"
825 "NavajoWhite2"
826 "NavajoWhite1"
827 "PeachPuff4"
828 "PeachPuff3"
829 "PeachPuff2"
830 "PeachPuff1"
831 "bisque4"
832 "bisque3"
833 "bisque2"
834 "bisque1"
835 "AntiqueWhite4"
836 "AntiqueWhite3"
837 "AntiqueWhite2"
838 "AntiqueWhite1"
839 "seashell4"
840 "seashell3"
841 "seashell2"
842 "seashell1"
843 "snow4"
844 "snow3"
845 "snow2"
846 "snow1"
847 "thistle"
848 "MediumPurple"
849 "medium purple"
850 "purple"
851 "BlueViolet"
852 "blue violet"
853 "DarkViolet"
854 "dark violet"
855 "DarkOrchid"
856 "dark orchid"
857 "MediumOrchid"
858 "medium orchid"
859 "orchid"
860 "plum"
861 "violet"
862 "magenta"
863 "VioletRed"
864 "violet red"
865 "MediumVioletRed"
866 "medium violet red"
867 "maroon"
868 "PaleVioletRed"
869 "pale violet red"
870 "LightPink"
871 "light pink"
872 "pink"
873 "DeepPink"
874 "deep pink"
875 "HotPink"
876 "hot pink"
877 "red"
878 "OrangeRed"
879 "orange red"
880 "tomato"
881 "LightCoral"
882 "light coral"
883 "coral"
884 "DarkOrange"
885 "dark orange"
886 "orange"
887 "LightSalmon"
888 "light salmon"
889 "salmon"
890 "DarkSalmon"
891 "dark salmon"
892 "brown"
893 "firebrick"
894 "chocolate"
895 "tan"
896 "SandyBrown"
897 "sandy brown"
898 "wheat"
899 "beige"
900 "burlywood"
901 "peru"
902 "sienna"
903 "SaddleBrown"
904 "saddle brown"
905 "IndianRed"
906 "indian red"
907 "RosyBrown"
908 "rosy brown"
909 "DarkGoldenrod"
910 "dark goldenrod"
911 "goldenrod"
912 "LightGoldenrod"
913 "light goldenrod"
914 "gold"
915 "yellow"
916 "LightYellow"
917 "light yellow"
918 "LightGoldenrodYellow"
919 "light goldenrod yellow"
920 "PaleGoldenrod"
921 "pale goldenrod"
922 "khaki"
923 "DarkKhaki"
924 "dark khaki"
925 "OliveDrab"
926 "olive drab"
927 "ForestGreen"
928 "forest green"
929 "YellowGreen"
930 "yellow green"
931 "LimeGreen"
932 "lime green"
933 "GreenYellow"
934 "green yellow"
935 "MediumSpringGreen"
936 "medium spring green"
937 "chartreuse"
938 "green"
939 "LawnGreen"
940 "lawn green"
941 "SpringGreen"
942 "spring green"
943 "PaleGreen"
944 "pale green"
945 "LightSeaGreen"
946 "light sea green"
947 "MediumSeaGreen"
948 "medium sea green"
949 "SeaGreen"
950 "sea green"
951 "DarkSeaGreen"
952 "dark sea green"
953 "DarkOliveGreen"
954 "dark olive green"
955 "DarkGreen"
956 "dark green"
957 "aquamarine"
958 "MediumAquamarine"
959 "medium aquamarine"
960 "CadetBlue"
961 "cadet blue"
962 "LightCyan"
963 "light cyan"
964 "cyan"
965 "turquoise"
966 "MediumTurquoise"
967 "medium turquoise"
968 "DarkTurquoise"
969 "dark turquoise"
970 "PaleTurquoise"
971 "pale turquoise"
972 "PowderBlue"
973 "powder blue"
974 "LightBlue"
975 "light blue"
976 "LightSteelBlue"
977 "light steel blue"
978 "SteelBlue"
979 "steel blue"
980 "LightSkyBlue"
981 "light sky blue"
982 "SkyBlue"
983 "sky blue"
984 "DeepSkyBlue"
985 "deep sky blue"
986 "DodgerBlue"
987 "dodger blue"
988 "blue"
989 "RoyalBlue"
990 "royal blue"
991 "MediumBlue"
992 "medium blue"
993 "LightSlateBlue"
994 "light slate blue"
995 "MediumSlateBlue"
996 "medium slate blue"
997 "SlateBlue"
998 "slate blue"
999 "DarkSlateBlue"
1000 "dark slate blue"
1001 "CornflowerBlue"
1002 "cornflower blue"
1003 "NavyBlue"
1004 "navy blue"
1005 "navy"
1006 "MidnightBlue"
1007 "midnight blue"
1008 "LightGray"
1009 "light gray"
1010 "LightGrey"
1011 "light grey"
1012 "grey"
1013 "gray"
1014 "LightSlateGrey"
1015 "light slate grey"
1016 "LightSlateGray"
1017 "light slate gray"
1018 "SlateGrey"
1019 "slate grey"
1020 "SlateGray"
1021 "slate gray"
1022 "DimGrey"
1023 "dim grey"
1024 "DimGray"
1025 "dim gray"
1026 "DarkSlateGrey"
1027 "dark slate grey"
1028 "DarkSlateGray"
1029 "dark slate gray"
1030 "black"
1031 "white"
1032 "MistyRose"
1033 "misty rose"
1034 "LavenderBlush"
1035 "lavender blush"
1036 "lavender"
1037 "AliceBlue"
1038 "alice blue"
1039 "azure"
1040 "MintCream"
1041 "mint cream"
1042 "honeydew"
1043 "seashell"
1044 "LemonChiffon"
1045 "lemon chiffon"
1046 "ivory"
1047 "cornsilk"
1048 "moccasin"
1049 "NavajoWhite"
1050 "navajo white"
1051 "PeachPuff"
1052 "peach puff"
1053 "bisque"
1054 "BlanchedAlmond"
1055 "blanched almond"
1056 "PapayaWhip"
1057 "papaya whip"
1058 "AntiqueWhite"
1059 "antique white"
1060 "linen"
1061 "OldLace"
1062 "old lace"
1063 "FloralWhite"
1064 "floral white"
1065 "gainsboro"
1066 "WhiteSmoke"
1067 "white smoke"
1068 "GhostWhite"
1069 "ghost white"
1070 "snow")
1071 "The list of X colors from the `rgb.txt' file.
1072 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
1073
1074 (defun xw-defined-colors (&optional frame)
1075 "Internal function called by `defined-colors', which see."
1076 (or frame (setq frame (selected-frame)))
1077 (let ((all-colors x-colors)
1078 (this-color nil)
1079 (defined-colors nil))
1080 (while all-colors
1081 (setq this-color (car all-colors)
1082 all-colors (cdr all-colors))
1083 (and (color-supported-p this-color frame t)
1084 (setq defined-colors (cons this-color defined-colors))))
1085 defined-colors))
1086 \f
1087 ;;;; Function keys
1088
1089 (defun iconify-or-deiconify-frame ()
1090 "Iconify the selected frame, or deiconify if it's currently an icon."
1091 (interactive)
1092 (if (eq (cdr (assq 'visibility (frame-parameters))) t)
1093 (iconify-frame)
1094 (make-frame-visible)))
1095
1096 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1097 global-map)
1098
1099 ;; Map certain keypad keys into ASCII characters
1100 ;; that people usually expect.
1101 (define-key function-key-map [backspace] [127])
1102 (define-key function-key-map [delete] [127])
1103 (define-key function-key-map [tab] [?\t])
1104 (define-key function-key-map [linefeed] [?\n])
1105 (define-key function-key-map [clear] [?\C-l])
1106 (define-key function-key-map [return] [?\C-m])
1107 (define-key function-key-map [escape] [?\e])
1108 (define-key function-key-map [M-backspace] [?\M-\d])
1109 (define-key function-key-map [M-delete] [?\M-\d])
1110 (define-key function-key-map [M-tab] [?\M-\t])
1111 (define-key function-key-map [M-linefeed] [?\M-\n])
1112 (define-key function-key-map [M-clear] [?\M-\C-l])
1113 (define-key function-key-map [M-return] [?\M-\C-m])
1114 (define-key function-key-map [M-escape] [?\M-\e])
1115 (define-key function-key-map [iso-lefttab] [backtab])
1116
1117 ;; These tell read-char how to convert
1118 ;; these special chars to ASCII.
1119 (put 'backspace 'ascii-character 127)
1120 (put 'delete 'ascii-character 127)
1121 (put 'tab 'ascii-character ?\t)
1122 (put 'linefeed 'ascii-character ?\n)
1123 (put 'clear 'ascii-character 12)
1124 (put 'return 'ascii-character 13)
1125 (put 'escape 'ascii-character ?\e)
1126
1127 (defun vendor-specific-keysyms (vendor)
1128 "Return the appropriate value of system-key-alist for VENDOR.
1129 VENDOR is a string containing the name of the X Server's vendor,
1130 as returned by (x-server-vendor)."
1131 (cond ((string-equal vendor "Apollo Computer Inc.")
1132 '((65280 . linedel)
1133 (65281 . chardel)
1134 (65282 . copy)
1135 (65283 . cut)
1136 (65284 . paste)
1137 (65285 . move)
1138 (65286 . grow)
1139 (65287 . cmd)
1140 (65288 . shell)
1141 (65289 . leftbar)
1142 (65290 . rightbar)
1143 (65291 . leftbox)
1144 (65292 . rightbox)
1145 (65293 . upbox)
1146 (65294 . downbox)
1147 (65295 . pop)
1148 (65296 . read)
1149 (65297 . edit)
1150 (65298 . save)
1151 (65299 . exit)
1152 (65300 . repeat)))
1153 ((or (string-equal vendor "Hewlett-Packard Incorporated")
1154 (string-equal vendor "Hewlett-Packard Company"))
1155 '(( 168 . mute-acute)
1156 ( 169 . mute-grave)
1157 ( 170 . mute-asciicircum)
1158 ( 171 . mute-diaeresis)
1159 ( 172 . mute-asciitilde)
1160 ( 175 . lira)
1161 ( 190 . guilder)
1162 ( 252 . block)
1163 ( 256 . longminus)
1164 (65388 . reset)
1165 (65389 . system)
1166 (65390 . user)
1167 (65391 . clearline)
1168 (65392 . insertline)
1169 (65393 . deleteline)
1170 (65394 . insertchar)
1171 (65395 . deletechar)
1172 (65396 . backtab)
1173 (65397 . kp-backtab)))
1174 ((or (string-equal vendor "X11/NeWS - Sun Microsystems Inc.")
1175 (string-equal vendor "X Consortium"))
1176 '((392976 . f36)
1177 (392977 . f37)
1178 (393056 . req)
1179 ;; These are for Sun under X11R6
1180 (393072 . props)
1181 (393073 . front)
1182 (393074 . copy)
1183 (393075 . open)
1184 (393076 . paste)
1185 (393077 . cut)))
1186 (t
1187 ;; This is used by DEC's X server.
1188 '((65280 . remove)))))
1189
1190 \f
1191 ;;;; Selections and cut buffers
1192
1193 ;;; We keep track of the last text selected here, so we can check the
1194 ;;; current selection against it, and avoid passing back our own text
1195 ;;; from x-cut-buffer-or-selection-value.
1196 (defvar x-last-selected-text nil)
1197
1198 ;;; It is said that overlarge strings are slow to put into the cut buffer.
1199 ;;; Note this value is overridden below.
1200 (defvar x-cut-buffer-max 20000
1201 "Max number of characters to put in the cut buffer.")
1202
1203 (defcustom x-select-enable-clipboard nil
1204 "Non-nil means cutting and pasting uses the clipboard.
1205 This is in addition to, but in preference to, the primary selection."
1206 :type 'boolean
1207 :group 'killing)
1208
1209 ;;; Make TEXT, a string, the primary X selection.
1210 ;;; Also, set the value of X cut buffer 0, for backward compatibility
1211 ;;; with older X applications.
1212 ;;; gildea@stop.mail-abuse.org says it's not desirable to put kills
1213 ;;; in the clipboard.
1214 (defun x-select-text (text &optional push)
1215 ;; Don't send the cut buffer too much text.
1216 ;; It becomes slow, and if really big it causes errors.
1217 (if (< (length text) x-cut-buffer-max)
1218 (x-set-cut-buffer text push)
1219 (x-set-cut-buffer "" push))
1220 (x-set-selection 'PRIMARY text)
1221 (if x-select-enable-clipboard
1222 (x-set-selection 'CLIPBOARD text))
1223 (setq x-last-selected-text text))
1224
1225 ;;; Return the value of the current X selection.
1226 ;;; Consult the selection, then the cut buffer. Treat empty strings
1227 ;;; as if they were unset.
1228 ;;; If this function is called twice and finds the same text,
1229 ;;; it returns nil the second time. This is so that a single
1230 ;;; selection won't be added to the kill ring over and over.
1231 (defun x-cut-buffer-or-selection-value ()
1232 (let (text)
1233 (when x-select-enable-clipboard
1234 (if (null text)
1235 (condition-case c
1236 (setq text (x-get-selection 'CLIPBOARD 'COMPOUND_TEXT))
1237 (error nil)))
1238 (if (null text)
1239 (condition-case c
1240 (setq text (x-get-selection 'CLIPBOARD 'STRING))
1241 (error nil)))
1242 (if (string= text "") (setq text nil)))
1243
1244 ;; Don't die if x-get-selection signals an error.
1245 (if (null text)
1246 (condition-case c
1247 (setq text (x-get-selection 'PRIMARY 'COMPOUND_TEXT))
1248 (error nil)))
1249 (if (null text)
1250 (condition-case c
1251 (setq text (x-get-selection 'PRIMARY 'STRING))
1252 (error nil)))
1253 (if (string= text "") (setq text nil))
1254
1255 (or text (setq text (x-get-cut-buffer 0)))
1256 (if (string= text "") (setq text nil))
1257
1258 (cond
1259 ((not text) nil)
1260 ((eq text x-last-selected-text) nil)
1261 ((string= text x-last-selected-text)
1262 ;; Record the newer string, so subsequent calls can use the `eq' test.
1263 (setq x-last-selected-text text)
1264 nil)
1265 (t
1266 (setq x-last-selected-text text)))))
1267
1268 \f
1269 ;;; Do the actual X Windows setup here; the above code just defines
1270 ;;; functions and variables that we use now.
1271
1272 (setq command-line-args (x-handle-args command-line-args))
1273
1274 ;;; Make sure we have a valid resource name.
1275 (or (stringp x-resource-name)
1276 (let (i)
1277 (setq x-resource-name (invocation-name))
1278
1279 ;; Change any . or * characters in x-resource-name to hyphens,
1280 ;; so as not to choke when we use it in X resource queries.
1281 (while (setq i (string-match "[.*]" x-resource-name))
1282 (aset x-resource-name i ?-))))
1283
1284 ;; For the benefit of older Emacses (19.27 and earlier) that are sharing
1285 ;; the same lisp directory, don't pass the third argument unless we seem
1286 ;; to have the multi-display support.
1287 (if (fboundp 'x-close-connection)
1288 (x-open-connection (or x-display-name
1289 (setq x-display-name (getenv "DISPLAY")))
1290 x-command-line-resources
1291 ;; Exit Emacs with fatal error if this fails.
1292 t)
1293 (x-open-connection (or x-display-name
1294 (setq x-display-name (getenv "DISPLAY")))
1295 x-command-line-resources))
1296
1297 (setq frame-creation-function 'x-create-frame-with-faces)
1298
1299 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
1300 x-cut-buffer-max))
1301
1302 (if (fboundp 'new-fontset)
1303 (progn
1304 ;; Create the standard fontset.
1305 (create-fontset-from-fontset-spec standard-fontset-spec t)
1306
1307 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
1308 (create-fontset-from-x-resource)
1309
1310 ;; Try to create a fontset from a font specification which comes
1311 ;; from initial-frame-alist, default-frame-alist, or X resource.
1312 ;; A font specification in command line argument (i.e. -fn XXXX)
1313 ;; should be already in default-frame-alist as a `font'
1314 ;; parameter. However, any font specifications in site-start
1315 ;; library, user's init file (.emacs), and default.el are not
1316 ;; yet handled here.
1317
1318 (let ((font (or (cdr (assq 'font initial-frame-alist))
1319 (cdr (assq 'font default-frame-alist))
1320 (x-get-resource "font" "Font")))
1321 xlfd-fields resolved-name)
1322 (if (and font
1323 (not (query-fontset font))
1324 (setq resolved-name (x-resolve-font-name font))
1325 (setq xlfd-fields (x-decompose-font-name font)))
1326 (if (string= "fontset"
1327 (aref xlfd-fields xlfd-regexp-registry-subnum))
1328 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
1329 ;; Create a fontset from FONT. The fontset name is
1330 ;; generated from FONT.
1331 (create-fontset-from-ascii-font font
1332 resolved-name "startup"))))))
1333
1334 ;; Sun expects the menu bar cut and paste commands to use the clipboard.
1335 ;; This has ,? to match both on Sunos and on Solaris.
1336 (if (string-match "Sun Microsystems,? Inc\\."
1337 (x-server-vendor))
1338 (menu-bar-enable-clipboard))
1339
1340 ;; Apply a geometry resource to the initial frame. Put it at the end
1341 ;; of the alist, so that anything specified on the command line takes
1342 ;; precedence.
1343 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1344 parsed)
1345 (if res-geometry
1346 (progn
1347 (setq parsed (x-parse-geometry res-geometry))
1348 ;; If the resource specifies a position,
1349 ;; call the position and size "user-specified".
1350 (if (or (assq 'top parsed) (assq 'left parsed))
1351 (setq parsed (cons '(user-position . t)
1352 (cons '(user-size . t) parsed))))
1353 ;; All geometry parms apply to the initial frame.
1354 (setq initial-frame-alist (append initial-frame-alist parsed))
1355 ;; The size parms apply to all frames.
1356 (if (assq 'height parsed)
1357 (setq default-frame-alist
1358 (cons (cons 'height (cdr (assq 'height parsed)))
1359 default-frame-alist)))
1360 (if (assq 'width parsed)
1361 (setq default-frame-alist
1362 (cons (cons 'width (cdr (assq 'width parsed)))
1363 default-frame-alist))))))
1364
1365 ;; Check the reverseVideo resource.
1366 (let ((case-fold-search t))
1367 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
1368 (if (and rv
1369 (string-match "^\\(true\\|yes\\|on\\)$" rv))
1370 (setq default-frame-alist
1371 (cons '(reverse . t) default-frame-alist)))))
1372
1373 ;; Set x-selection-timeout, measured in milliseconds.
1374 (let ((res-selection-timeout
1375 (x-get-resource "selectionTimeout" "SelectionTimeout")))
1376 (setq x-selection-timeout 20000)
1377 (if res-selection-timeout
1378 (setq x-selection-timeout (string-to-number res-selection-timeout))))
1379
1380 (defun x-win-suspend-error ()
1381 (error "Suspending an emacs running under X makes no sense"))
1382 (add-hook 'suspend-hook 'x-win-suspend-error)
1383
1384 ;;; Arrange for the kill and yank functions to set and check the clipboard.
1385 (setq interprogram-cut-function 'x-select-text)
1386 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
1387
1388 ;;; Turn off window-splitting optimization; X is usually fast enough
1389 ;;; that this is only annoying.
1390 (setq split-window-keep-point t)
1391
1392 ;; Don't show the frame name; that's redundant with X.
1393 (setq-default mode-line-frame-identification " ")
1394
1395 ;;; Motif direct handling of f10 wasn't working right,
1396 ;;; So temporarily we've turned it off in lwlib-Xm.c
1397 ;;; and turned the Emacs f10 back on.
1398 ;;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
1399 ;;; (if (featurep 'motif)
1400 ;;; (global-set-key [f10] 'ignore))
1401
1402 ;;; x-win.el ends here