Mercurial > emacs
comparison lisp/term/x-win.el @ 96830:a8aac59d9c7a
* term/x-win.el (x-handle-switch, x-handle-numeric-switch)
(x-handle-initial-switch, x-handle-iconic, x-handle-xrm-switch)
(x-handle-geometry, x-handle-name-switch, x-display-name)
(x-handle-display, x-handle-args, x-colors): Move ...
* term/common-win.el: ... here. New file.
* term/w32-win.el (x-handle-switch, x-handle-numeric-switch)
(x-handle-initial-switch, x-handle-iconic, x-handle-xrm-switch)
(x-handle-geometry, x-handle-name-switch, x-display-name)
(x-handle-display, x-handle-args, x-colors): Remove.
* loadup.el: Load term/common-win before term/x-win and term/w32-win.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 20 Jul 2008 00:37:45 +0000 |
parents | b4e36ff621b3 |
children | 6e551caf98f6 |
comparison
equal
deleted
inserted
replaced
96829:57e1550dd32a | 96830:a8aac59d9c7a |
---|---|
85 (defvar x-keysym-table) | 85 (defvar x-keysym-table) |
86 (defvar x-selection-timeout) | 86 (defvar x-selection-timeout) |
87 (defvar x-session-id) | 87 (defvar x-session-id) |
88 (defvar x-session-previous-id) | 88 (defvar x-session-previous-id) |
89 | 89 |
90 (defvar x-command-line-resources nil) | |
91 | |
92 ;; Handler for switches of the form "-switch value" or "-switch". | |
93 (defun x-handle-switch (switch) | |
94 (let ((aelt (assoc switch command-line-x-option-alist))) | |
95 (if aelt | |
96 (let ((param (nth 3 aelt)) | |
97 (value (nth 4 aelt))) | |
98 (if value | |
99 (setq default-frame-alist | |
100 (cons (cons param value) | |
101 default-frame-alist)) | |
102 (setq default-frame-alist | |
103 (cons (cons param | |
104 (car x-invocation-args)) | |
105 default-frame-alist) | |
106 x-invocation-args (cdr x-invocation-args))))))) | |
107 | |
108 ;; Handler for switches of the form "-switch n" | |
109 (defun x-handle-numeric-switch (switch) | |
110 (let ((aelt (assoc switch command-line-x-option-alist))) | |
111 (if aelt | |
112 (let ((param (nth 3 aelt))) | |
113 (setq default-frame-alist | |
114 (cons (cons param | |
115 (string-to-number (car x-invocation-args))) | |
116 default-frame-alist) | |
117 x-invocation-args | |
118 (cdr x-invocation-args)))))) | |
119 | |
120 ;; Handle options that apply to initial frame only | |
121 (defun x-handle-initial-switch (switch) | |
122 (let ((aelt (assoc switch command-line-x-option-alist))) | |
123 (if aelt | |
124 (let ((param (nth 3 aelt)) | |
125 (value (nth 4 aelt))) | |
126 (if value | |
127 (setq initial-frame-alist | |
128 (cons (cons param value) | |
129 initial-frame-alist)) | |
130 (setq initial-frame-alist | |
131 (cons (cons param | |
132 (car x-invocation-args)) | |
133 initial-frame-alist) | |
134 x-invocation-args (cdr x-invocation-args))))))) | |
135 | |
136 (defun x-handle-no-bitmap-icon (switch) | 90 (defun x-handle-no-bitmap-icon (switch) |
137 (setq default-frame-alist (cons '(icon-type) default-frame-alist))) | 91 (setq default-frame-alist (cons '(icon-type) default-frame-alist))) |
138 | |
139 ;; Make -iconic apply only to the initial frame! | |
140 (defun x-handle-iconic (switch) | |
141 (setq initial-frame-alist | |
142 (cons '(visibility . icon) initial-frame-alist))) | |
143 | |
144 ;; Handle the -xrm option. | |
145 (defun x-handle-xrm-switch (switch) | |
146 (unless (consp x-invocation-args) | |
147 (error "%s: missing argument to `%s' option" (invocation-name) switch)) | |
148 (setq x-command-line-resources | |
149 (if (null x-command-line-resources) | |
150 (car x-invocation-args) | |
151 (concat x-command-line-resources "\n" (car x-invocation-args)))) | |
152 (setq x-invocation-args (cdr x-invocation-args))) | |
153 | |
154 (declare-function x-parse-geometry "frame.c" (string)) | |
155 | |
156 ;; Handle the geometry option | |
157 (defun x-handle-geometry (switch) | |
158 (let* ((geo (x-parse-geometry (car x-invocation-args))) | |
159 (left (assq 'left geo)) | |
160 (top (assq 'top geo)) | |
161 (height (assq 'height geo)) | |
162 (width (assq 'width geo))) | |
163 (if (or height width) | |
164 (setq default-frame-alist | |
165 (append default-frame-alist | |
166 '((user-size . t)) | |
167 (if height (list height)) | |
168 (if width (list width))) | |
169 initial-frame-alist | |
170 (append initial-frame-alist | |
171 '((user-size . t)) | |
172 (if height (list height)) | |
173 (if width (list width))))) | |
174 (if (or left top) | |
175 (setq initial-frame-alist | |
176 (append initial-frame-alist | |
177 '((user-position . t)) | |
178 (if left (list left)) | |
179 (if top (list top))))) | |
180 (setq x-invocation-args (cdr x-invocation-args)))) | |
181 | |
182 (defvar x-resource-name) | |
183 | |
184 ;; Handle the -name option. Set the variable x-resource-name | |
185 ;; to the option's operand; set the name of | |
186 ;; the initial frame, too. | |
187 (defun x-handle-name-switch (switch) | |
188 (or (consp x-invocation-args) | |
189 (error "%s: missing argument to `%s' option" (invocation-name) switch)) | |
190 (setq x-resource-name (car x-invocation-args) | |
191 x-invocation-args (cdr x-invocation-args)) | |
192 (setq initial-frame-alist (cons (cons 'name x-resource-name) | |
193 initial-frame-alist))) | |
194 | 92 |
195 ;; Handle the --parent-id option. | 93 ;; Handle the --parent-id option. |
196 (defun x-handle-parent-id (switch) | 94 (defun x-handle-parent-id (switch) |
197 (or (consp x-invocation-args) | 95 (or (consp x-invocation-args) |
198 (error "%s: missing argument to `%s' option" (invocation-name) switch)) | 96 (error "%s: missing argument to `%s' option" (invocation-name) switch)) |
199 (setq initial-frame-alist (cons | 97 (setq initial-frame-alist (cons |
200 (cons 'parent-id | 98 (cons 'parent-id |
201 (string-to-number (car x-invocation-args))) | 99 (string-to-number (car x-invocation-args))) |
202 initial-frame-alist) | 100 initial-frame-alist) |
203 x-invocation-args (cdr x-invocation-args))) | 101 x-invocation-args (cdr x-invocation-args))) |
204 | |
205 (defvar x-display-name nil | |
206 "The name of the X display on which Emacs was started. | |
207 | |
208 For the X display name of individual frames, see the `display' | |
209 frame parameter.") | |
210 | |
211 (defun x-handle-display (switch) | |
212 "Handle -display DISPLAY option." | |
213 (setq x-display-name (car x-invocation-args) | |
214 x-invocation-args (cdr x-invocation-args)) | |
215 ;; Make subshell programs see the same DISPLAY value Emacs really uses. | |
216 ;; Note that this isn't completely correct, since Emacs can use | |
217 ;; multiple displays. However, there is no way to tell an already | |
218 ;; running subshell which display the user is currently typing on. | |
219 (setenv "DISPLAY" x-display-name)) | |
220 | |
221 (defun x-handle-args (args) | |
222 "Process the X-related command line options in ARGS. | |
223 This is done before the user's startup file is loaded. They are copied to | |
224 `x-invocation-args', from which the X-related things are extracted, first | |
225 the switch (e.g., \"-fg\") in the following code, and possible values | |
226 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch). | |
227 This function returns ARGS minus the arguments that have been processed." | |
228 ;; We use ARGS to accumulate the args that we don't handle here, to return. | |
229 (setq x-invocation-args args | |
230 args nil) | |
231 (while (and x-invocation-args | |
232 (not (equal (car x-invocation-args) "--"))) | |
233 (let* ((this-switch (car x-invocation-args)) | |
234 (orig-this-switch this-switch) | |
235 completion argval aelt handler) | |
236 (setq x-invocation-args (cdr x-invocation-args)) | |
237 ;; Check for long options with attached arguments | |
238 ;; and separate out the attached option argument into argval. | |
239 (if (string-match "^--[^=]*=" this-switch) | |
240 (setq argval (substring this-switch (match-end 0)) | |
241 this-switch (substring this-switch 0 (1- (match-end 0))))) | |
242 ;; Complete names of long options. | |
243 (if (string-match "^--" this-switch) | |
244 (progn | |
245 (setq completion (try-completion this-switch command-line-x-option-alist)) | |
246 (if (eq completion t) | |
247 ;; Exact match for long option. | |
248 nil | |
249 (if (stringp completion) | |
250 (let ((elt (assoc completion command-line-x-option-alist))) | |
251 ;; Check for abbreviated long option. | |
252 (or elt | |
253 (error "Option `%s' is ambiguous" this-switch)) | |
254 (setq this-switch completion)))))) | |
255 (setq aelt (assoc this-switch command-line-x-option-alist)) | |
256 (if aelt (setq handler (nth 2 aelt))) | |
257 (if handler | |
258 (if argval | |
259 (let ((x-invocation-args | |
260 (cons argval x-invocation-args))) | |
261 (funcall handler this-switch)) | |
262 (funcall handler this-switch)) | |
263 (setq args (cons orig-this-switch args))))) | |
264 (nconc (nreverse args) x-invocation-args)) | |
265 | 102 |
266 ;; Handle the --smid switch. This is used by the session manager | 103 ;; Handle the --smid switch. This is used by the session manager |
267 ;; to give us back our session id we had on the previous run. | 104 ;; to give us back our session id we had on the previous run. |
268 (defun x-handle-smid (switch) | 105 (defun x-handle-smid (switch) |
269 (or (consp x-invocation-args) | 106 (or (consp x-invocation-args) |
412 (defconst x-pointer-umbrella 146) | 249 (defconst x-pointer-umbrella 146) |
413 (defconst x-pointer-ur-angle 148) | 250 (defconst x-pointer-ur-angle 148) |
414 (defconst x-pointer-watch 150) | 251 (defconst x-pointer-watch 150) |
415 (defconst x-pointer-xterm 152) | 252 (defconst x-pointer-xterm 152) |
416 (defconst x-pointer-invisible 255) | 253 (defconst x-pointer-invisible 255) |
254 | |
417 | 255 |
418 ;; | |
419 ;; Available colors | |
420 ;; | |
421 ;; The ordering of the colors is chosen for the user's convenience in | |
422 ;; `list-colors-display', which displays the reverse of this list. | |
423 ;; Roughly speaking, `list-colors-display' orders by (i) named shades | |
424 ;; of grey with hue 0.0, sorted by value (ii) named colors with | |
425 ;; saturation 1.0, sorted by hue, (iii) named non-white colors with | |
426 ;; saturation less than 1.0, sorted by hue, (iv) other named shades of | |
427 ;; white, (v) numbered colors sorted by hue, and (vi) numbered shades | |
428 ;; of grey. | |
429 | |
430 (defvar x-colors | |
431 '("gray100" "gray99" "gray98" "gray97" "gray96" "gray95" "gray94" "gray93" "gray92" | |
432 "gray91" "gray90" "gray89" "gray88" "gray87" "gray86" "gray85" "gray84" "gray83" | |
433 "gray82" "gray81" "gray80" "gray79" "gray78" "gray77" "gray76" "gray75" "gray74" | |
434 "gray73" "gray72" "gray71" "gray70" "gray69" "gray68" "gray67" "gray66" "gray65" | |
435 "gray64" "gray63" "gray62" "gray61" "gray60" "gray59" "gray58" "gray57" "gray56" | |
436 "gray55" "gray54" "gray53" "gray52" "gray51" "gray50" "gray49" "gray48" "gray47" | |
437 "gray46" "gray45" "gray44" "gray43" "gray42" "gray41" "gray40" "gray39" "gray38" | |
438 "gray37" "gray36" "gray35" "gray34" "gray33" "gray32" "gray31" "gray30" "gray29" | |
439 "gray28" "gray27" "gray26" "gray25" "gray24" "gray23" "gray22" "gray21" "gray20" | |
440 "gray19" "gray18" "gray17" "gray16" "gray15" "gray14" "gray13" "gray12" "gray11" | |
441 "gray10" "gray9" "gray8" "gray7" "gray6" "gray5" "gray4" "gray3" "gray2" "gray1" | |
442 "gray0" "LightPink1" "LightPink2" "LightPink3" "LightPink4" "pink1" "pink2" "pink3" | |
443 "pink4" "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4" | |
444 "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4" "VioletRed1" | |
445 "VioletRed2" "VioletRed3" "VioletRed4" "HotPink1" "HotPink2" "HotPink3" "HotPink4" | |
446 "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4" "maroon1" "maroon2" "maroon3" | |
447 "maroon4" "orchid1" "orchid2" "orchid3" "orchid4" "plum1" "plum2" "plum3" "plum4" | |
448 "thistle1" "thistle2" "thistle3" "thistle4" "MediumOrchid1" "MediumOrchid2" | |
449 "MediumOrchid3" "MediumOrchid4" "DarkOrchid1" "DarkOrchid2" "DarkOrchid3" | |
450 "DarkOrchid4" "purple1" "purple2" "purple3" "purple4" "MediumPurple1" | |
451 "MediumPurple2" "MediumPurple3" "MediumPurple4" "SlateBlue1" "SlateBlue2" | |
452 "SlateBlue3" "SlateBlue4" "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4" | |
453 "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4" "SlateGray1" | |
454 "SlateGray2" "SlateGray3" "SlateGray4" "DodgerBlue1" "DodgerBlue2" "DodgerBlue3" | |
455 "DodgerBlue4" "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4" "SkyBlue1" | |
456 "SkyBlue2" "SkyBlue3" "SkyBlue4" "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3" | |
457 "LightSkyBlue4" "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4" "CadetBlue1" | |
458 "CadetBlue2" "CadetBlue3" "CadetBlue4" "azure1" "azure2" "azure3" "azure4" | |
459 "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4" "PaleTurquoise1" | |
460 "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4" "DarkSlateGray1" "DarkSlateGray2" | |
461 "DarkSlateGray3" "DarkSlateGray4" "aquamarine1" "aquamarine2" "aquamarine3" | |
462 "aquamarine4" "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4" "honeydew1" | |
463 "honeydew2" "honeydew3" "honeydew4" "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3" | |
464 "DarkSeaGreen4" "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4" | |
465 "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4" "OliveDrab1" | |
466 "OliveDrab2" "OliveDrab3" "OliveDrab4" "ivory1" "ivory2" "ivory3" "ivory4" | |
467 "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4" "khaki1" "khaki2" | |
468 "khaki3" "khaki4" "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4" | |
469 "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4" "cornsilk1" | |
470 "cornsilk2" "cornsilk3" "cornsilk4" "goldenrod1" "goldenrod2" "goldenrod3" | |
471 "goldenrod4" "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4" | |
472 "wheat1" "wheat2" "wheat3" "wheat4" "NavajoWhite1" "NavajoWhite2" "NavajoWhite3" | |
473 "NavajoWhite4" "burlywood1" "burlywood2" "burlywood3" "burlywood4" "AntiqueWhite1" | |
474 "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4" "bisque1" "bisque2" "bisque3" | |
475 "bisque4" "tan1" "tan2" "tan3" "tan4" "PeachPuff1" "PeachPuff2" "PeachPuff3" | |
476 "PeachPuff4" "seashell1" "seashell2" "seashell3" "seashell4" "chocolate1" | |
477 "chocolate2" "chocolate3" "chocolate4" "sienna1" "sienna2" "sienna3" "sienna4" | |
478 "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4" "salmon1" "salmon2" | |
479 "salmon3" "salmon4" "coral1" "coral2" "coral3" "coral4" "tomato1" "tomato2" | |
480 "tomato3" "tomato4" "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4" "snow1" | |
481 "snow2" "snow3" "snow4" "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4" | |
482 "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4" "firebrick1" "firebrick2" | |
483 "firebrick3" "firebrick4" "brown1" "brown2" "brown3" "brown4" "magenta1" "magenta2" | |
484 "magenta3" "magenta4" "blue1" "blue2" "blue3" "blue4" "DeepSkyBlue1" "DeepSkyBlue2" | |
485 "DeepSkyBlue3" "DeepSkyBlue4" "turquoise1" "turquoise2" "turquoise3" "turquoise4" | |
486 "cyan1" "cyan2" "cyan3" "cyan4" "SpringGreen1" "SpringGreen2" "SpringGreen3" | |
487 "SpringGreen4" "green1" "green2" "green3" "green4" "chartreuse1" "chartreuse2" | |
488 "chartreuse3" "chartreuse4" "yellow1" "yellow2" "yellow3" "yellow4" "gold1" "gold2" | |
489 "gold3" "gold4" "orange1" "orange2" "orange3" "orange4" "DarkOrange1" "DarkOrange2" | |
490 "DarkOrange3" "DarkOrange4" "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4" | |
491 "red1" "red2" "red3" "red4" "lavender blush" "ghost white" "lavender" "alice blue" | |
492 "azure" "light cyan" "mint cream" "honeydew" "ivory" "light goldenrod yellow" | |
493 "light yellow" "beige" "floral white" "old lace" "blanched almond" "moccasin" | |
494 "papaya whip" "bisque" "antique white" "linen" "peach puff" "seashell" "misty rose" | |
495 "snow" "light pink" "pink" "hot pink" "deep pink" "maroon" "pale violet red" | |
496 "violet red" "medium violet red" "violet" "plum" "thistle" "orchid" "medium orchid" | |
497 "dark orchid" "purple" "blue violet" "medium purple" "light slate blue" | |
498 "medium slate blue" "slate blue" "dark slate blue" "midnight blue" "navy" | |
499 "dark blue" "light steel blue" "cornflower blue" "dodger blue" "royal blue" | |
500 "light slate gray" "slate gray" "dark slate gray" "steel blue" "cadet blue" | |
501 "light sky blue" "sky blue" "light blue" "powder blue" "pale turquoise" "turquoise" | |
502 "medium turquoise" "dark cyan" "aquamarine" "medium aquamarine" "light sea green" | |
503 "medium sea green" "sea green" "dark sea green" "pale green" "lime green" | |
504 "forest green" "light green" "green yellow" "yellow green" "olive drab" | |
505 "dark olive green" "lemon chiffon" "khaki" "dark khaki" "cornsilk" | |
506 "pale goldenrod" "light goldenrod" "goldenrod" "dark goldenrod" "wheat" | |
507 "navajo white" "tan" "burlywood" "sandy brown" "peru" "chocolate" "saddle brown" | |
508 "sienna" "rosy brown" "dark salmon" "coral" "tomato" "light salmon" "salmon" | |
509 "light coral" "indian red" "firebrick" "brown" "dark red" "magenta" | |
510 "dark magenta" "dark violet" "medium blue" "blue" "deep sky blue" | |
511 "cyan" "medium spring green" "spring green" "green" "lawn green" "chartreuse" | |
512 "yellow" "gold" "orange" "dark orange" "orange red" "red" "white" "white smoke" | |
513 "gainsboro" "light grey" "gray" "dark grey" "dim gray" "black" ) | |
514 "The list of X colors from the `rgb.txt' file. | |
515 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp") | |
516 | |
517 (defun xw-defined-colors (&optional frame) | 256 (defun xw-defined-colors (&optional frame) |
518 "Internal function called by `defined-colors', which see." | 257 "Internal function called by `defined-colors', which see." |
519 (or frame (setq frame (selected-frame))) | 258 (or frame (setq frame (selected-frame))) |
520 (let ((all-colors x-colors) | 259 (let ((all-colors x-colors) |
521 (this-color nil) | 260 (this-color nil) |