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