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