Doc fixes.
[emacs.git] / lisp / term / common-win.el
blobc3c5f8e302c3cda2126d0f2f97f3fa2d68e8d40b
1 ;;; common-win.el --- common part of handling window systems
3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: terminals
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;;; Code:
29 (defvar x-invocation-args)
31 (defvar x-command-line-resources nil)
33 ;; Handler for switches of the form "-switch value" or "-switch".
34 (defun x-handle-switch (switch)
35 (let ((aelt (assoc switch command-line-x-option-alist)))
36 (if aelt
37 (let ((param (nth 3 aelt))
38 (value (nth 4 aelt)))
39 (if value
40 (setq default-frame-alist
41 (cons (cons param value)
42 default-frame-alist))
43 (setq default-frame-alist
44 (cons (cons param
45 (car x-invocation-args))
46 default-frame-alist)
47 x-invocation-args (cdr x-invocation-args)))))))
49 ;; Handler for switches of the form "-switch n"
50 (defun x-handle-numeric-switch (switch)
51 (let ((aelt (assoc switch command-line-x-option-alist)))
52 (if aelt
53 (let ((param (nth 3 aelt)))
54 (setq default-frame-alist
55 (cons (cons param
56 (string-to-number (car x-invocation-args)))
57 default-frame-alist)
58 x-invocation-args
59 (cdr x-invocation-args))))))
61 ;; Handle options that apply to initial frame only
62 (defun x-handle-initial-switch (switch)
63 (let ((aelt (assoc switch command-line-x-option-alist)))
64 (if aelt
65 (let ((param (nth 3 aelt))
66 (value (nth 4 aelt)))
67 (if value
68 (setq initial-frame-alist
69 (cons (cons param value)
70 initial-frame-alist))
71 (setq initial-frame-alist
72 (cons (cons param
73 (car x-invocation-args))
74 initial-frame-alist)
75 x-invocation-args (cdr x-invocation-args)))))))
77 ;; Make -iconic apply only to the initial frame!
78 (defun x-handle-iconic (switch)
79 (setq initial-frame-alist
80 (cons '(visibility . icon) initial-frame-alist)))
82 ;; Handle the -xrm option.
83 (defun x-handle-xrm-switch (switch)
84 (unless (consp x-invocation-args)
85 (error "%s: missing argument to `%s' option" (invocation-name) switch))
86 (setq x-command-line-resources
87 (if (null x-command-line-resources)
88 (car x-invocation-args)
89 (concat x-command-line-resources "\n" (car x-invocation-args))))
90 (setq x-invocation-args (cdr x-invocation-args)))
92 (declare-function x-parse-geometry "frame.c" (string))
94 ;; Handle the geometry option
95 (defun x-handle-geometry (switch)
96 (let* ((geo (x-parse-geometry (car x-invocation-args)))
97 (left (assq 'left geo))
98 (top (assq 'top geo))
99 (height (assq 'height geo))
100 (width (assq 'width geo)))
101 (if (or height width)
102 (setq default-frame-alist
103 (append default-frame-alist
104 '((user-size . t))
105 (if height (list height))
106 (if width (list width)))
107 initial-frame-alist
108 (append initial-frame-alist
109 '((user-size . t))
110 (if height (list height))
111 (if width (list width)))))
112 (if (or left top)
113 (setq initial-frame-alist
114 (append initial-frame-alist
115 '((user-position . t))
116 (if left (list left))
117 (if top (list top)))))
118 (setq x-invocation-args (cdr x-invocation-args))))
120 (defvar x-resource-name)
122 ;; Handle the -name option. Set the variable x-resource-name
123 ;; to the option's operand; set the name of
124 ;; the initial frame, too.
125 (defun x-handle-name-switch (switch)
126 (or (consp x-invocation-args)
127 (error "%s: missing argument to `%s' option" (invocation-name) switch))
128 (setq x-resource-name (car x-invocation-args)
129 x-invocation-args (cdr x-invocation-args))
130 (setq initial-frame-alist (cons (cons 'name x-resource-name)
131 initial-frame-alist)))
133 (defvar x-display-name nil
134 "The name of the window display on which Emacs was started.
135 On X, the display name of individual X frames is recorded in the
136 `display' frame parameter.")
138 (defun x-handle-display (switch)
139 "Handle -display DISPLAY option."
140 (setq x-display-name (car x-invocation-args)
141 x-invocation-args (cdr x-invocation-args))
142 ;; Make subshell programs see the same DISPLAY value Emacs really uses.
143 ;; Note that this isn't completely correct, since Emacs can use
144 ;; multiple displays. However, there is no way to tell an already
145 ;; running subshell which display the user is currently typing on.
146 (setenv "DISPLAY" x-display-name))
148 (defun x-handle-args (args)
149 "Process the X-related command line options in ARGS.
150 This is done before the user's startup file is loaded. They are copied to
151 `x-invocation-args', from which the X-related things are extracted, first
152 the switch (e.g., \"-fg\") in the following code, and possible values
153 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
154 This function returns ARGS minus the arguments that have been processed."
155 ;; We use ARGS to accumulate the args that we don't handle here, to return.
156 (setq x-invocation-args args
157 args nil)
158 (while (and x-invocation-args
159 (not (equal (car x-invocation-args) "--")))
160 (let* ((this-switch (car x-invocation-args))
161 (orig-this-switch this-switch)
162 completion argval aelt handler)
163 (setq x-invocation-args (cdr x-invocation-args))
164 ;; Check for long options with attached arguments
165 ;; and separate out the attached option argument into argval.
166 (if (string-match "^--[^=]*=" this-switch)
167 (setq argval (substring this-switch (match-end 0))
168 this-switch (substring this-switch 0 (1- (match-end 0)))))
169 ;; Complete names of long options.
170 (if (string-match "^--" this-switch)
171 (progn
172 (setq completion (try-completion this-switch command-line-x-option-alist))
173 (if (eq completion t)
174 ;; Exact match for long option.
176 (if (stringp completion)
177 (let ((elt (assoc completion command-line-x-option-alist)))
178 ;; Check for abbreviated long option.
179 (or elt
180 (error "Option `%s' is ambiguous" this-switch))
181 (setq this-switch completion))))))
182 (setq aelt (assoc this-switch command-line-x-option-alist))
183 (if aelt (setq handler (nth 2 aelt)))
184 (if handler
185 (if argval
186 (let ((x-invocation-args
187 (cons argval x-invocation-args)))
188 (funcall handler this-switch))
189 (funcall handler this-switch))
190 (setq args (cons orig-this-switch args)))))
191 (nconc (nreverse args) x-invocation-args))
195 ;; Available colors
197 ;; The ordering of the colors is chosen for the user's convenience in
198 ;; `list-colors-display', which displays the reverse of this list.
199 ;; Roughly speaking, `list-colors-display' orders by (i) named shades
200 ;; of grey with hue 0.0, sorted by value (ii) named colors with
201 ;; saturation 1.0, sorted by hue, (iii) named non-white colors with
202 ;; saturation less than 1.0, sorted by hue, (iv) other named shades of
203 ;; white, (v) numbered colors sorted by hue, and (vi) numbered shades
204 ;; of grey.
206 (defvar x-colors
207 (purecopy
208 '("gray100" "gray99" "gray98" "gray97" "gray96" "gray95" "gray94" "gray93" "gray92"
209 "gray91" "gray90" "gray89" "gray88" "gray87" "gray86" "gray85" "gray84" "gray83"
210 "gray82" "gray81" "gray80" "gray79" "gray78" "gray77" "gray76" "gray75" "gray74"
211 "gray73" "gray72" "gray71" "gray70" "gray69" "gray68" "gray67" "gray66" "gray65"
212 "gray64" "gray63" "gray62" "gray61" "gray60" "gray59" "gray58" "gray57" "gray56"
213 "gray55" "gray54" "gray53" "gray52" "gray51" "gray50" "gray49" "gray48" "gray47"
214 "gray46" "gray45" "gray44" "gray43" "gray42" "gray41" "gray40" "gray39" "gray38"
215 "gray37" "gray36" "gray35" "gray34" "gray33" "gray32" "gray31" "gray30" "gray29"
216 "gray28" "gray27" "gray26" "gray25" "gray24" "gray23" "gray22" "gray21" "gray20"
217 "gray19" "gray18" "gray17" "gray16" "gray15" "gray14" "gray13" "gray12" "gray11"
218 "gray10" "gray9" "gray8" "gray7" "gray6" "gray5" "gray4" "gray3" "gray2" "gray1"
219 "gray0" "LightPink1" "LightPink2" "LightPink3" "LightPink4" "pink1" "pink2" "pink3"
220 "pink4" "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4"
221 "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4" "VioletRed1"
222 "VioletRed2" "VioletRed3" "VioletRed4" "HotPink1" "HotPink2" "HotPink3" "HotPink4"
223 "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4" "maroon1" "maroon2" "maroon3"
224 "maroon4" "orchid1" "orchid2" "orchid3" "orchid4" "plum1" "plum2" "plum3" "plum4"
225 "thistle1" "thistle2" "thistle3" "thistle4" "MediumOrchid1" "MediumOrchid2"
226 "MediumOrchid3" "MediumOrchid4" "DarkOrchid1" "DarkOrchid2" "DarkOrchid3"
227 "DarkOrchid4" "purple1" "purple2" "purple3" "purple4" "MediumPurple1"
228 "MediumPurple2" "MediumPurple3" "MediumPurple4" "SlateBlue1" "SlateBlue2"
229 "SlateBlue3" "SlateBlue4" "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4"
230 "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4" "SlateGray1"
231 "SlateGray2" "SlateGray3" "SlateGray4" "DodgerBlue1" "DodgerBlue2" "DodgerBlue3"
232 "DodgerBlue4" "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4" "SkyBlue1"
233 "SkyBlue2" "SkyBlue3" "SkyBlue4" "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3"
234 "LightSkyBlue4" "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4" "CadetBlue1"
235 "CadetBlue2" "CadetBlue3" "CadetBlue4" "azure1" "azure2" "azure3" "azure4"
236 "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4" "PaleTurquoise1"
237 "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4" "DarkSlateGray1" "DarkSlateGray2"
238 "DarkSlateGray3" "DarkSlateGray4" "aquamarine1" "aquamarine2" "aquamarine3"
239 "aquamarine4" "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4" "honeydew1"
240 "honeydew2" "honeydew3" "honeydew4" "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3"
241 "DarkSeaGreen4" "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4"
242 "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4" "OliveDrab1"
243 "OliveDrab2" "OliveDrab3" "OliveDrab4" "ivory1" "ivory2" "ivory3" "ivory4"
244 "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4" "khaki1" "khaki2"
245 "khaki3" "khaki4" "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4"
246 "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4" "cornsilk1"
247 "cornsilk2" "cornsilk3" "cornsilk4" "goldenrod1" "goldenrod2" "goldenrod3"
248 "goldenrod4" "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4"
249 "wheat1" "wheat2" "wheat3" "wheat4" "NavajoWhite1" "NavajoWhite2" "NavajoWhite3"
250 "NavajoWhite4" "burlywood1" "burlywood2" "burlywood3" "burlywood4" "AntiqueWhite1"
251 "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4" "bisque1" "bisque2" "bisque3"
252 "bisque4" "tan1" "tan2" "tan3" "tan4" "PeachPuff1" "PeachPuff2" "PeachPuff3"
253 "PeachPuff4" "seashell1" "seashell2" "seashell3" "seashell4" "chocolate1"
254 "chocolate2" "chocolate3" "chocolate4" "sienna1" "sienna2" "sienna3" "sienna4"
255 "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4" "salmon1" "salmon2"
256 "salmon3" "salmon4" "coral1" "coral2" "coral3" "coral4" "tomato1" "tomato2"
257 "tomato3" "tomato4" "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4" "snow1"
258 "snow2" "snow3" "snow4" "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4"
259 "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4" "firebrick1" "firebrick2"
260 "firebrick3" "firebrick4" "brown1" "brown2" "brown3" "brown4" "magenta1" "magenta2"
261 "magenta3" "magenta4" "blue1" "blue2" "blue3" "blue4" "DeepSkyBlue1" "DeepSkyBlue2"
262 "DeepSkyBlue3" "DeepSkyBlue4" "turquoise1" "turquoise2" "turquoise3" "turquoise4"
263 "cyan1" "cyan2" "cyan3" "cyan4" "SpringGreen1" "SpringGreen2" "SpringGreen3"
264 "SpringGreen4" "green1" "green2" "green3" "green4" "chartreuse1" "chartreuse2"
265 "chartreuse3" "chartreuse4" "yellow1" "yellow2" "yellow3" "yellow4" "gold1" "gold2"
266 "gold3" "gold4" "orange1" "orange2" "orange3" "orange4" "DarkOrange1" "DarkOrange2"
267 "DarkOrange3" "DarkOrange4" "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4"
268 "red1" "red2" "red3" "red4" "lavender blush" "ghost white" "lavender" "alice blue"
269 "azure" "light cyan" "mint cream" "honeydew" "ivory" "light goldenrod yellow"
270 "light yellow" "beige" "floral white" "old lace" "blanched almond" "moccasin"
271 "papaya whip" "bisque" "antique white" "linen" "peach puff" "seashell" "misty rose"
272 "snow" "light pink" "pink" "hot pink" "deep pink" "maroon" "pale violet red"
273 "violet red" "medium violet red" "violet" "plum" "thistle" "orchid" "medium orchid"
274 "dark orchid" "purple" "blue violet" "medium purple" "light slate blue"
275 "medium slate blue" "slate blue" "dark slate blue" "midnight blue" "navy"
276 "dark blue" "light steel blue" "cornflower blue" "dodger blue" "royal blue"
277 "light slate gray" "slate gray" "dark slate gray" "steel blue" "cadet blue"
278 "light sky blue" "sky blue" "light blue" "powder blue" "pale turquoise" "turquoise"
279 "medium turquoise" "dark cyan" "aquamarine" "medium aquamarine" "light sea green"
280 "medium sea green" "sea green" "dark sea green" "pale green" "lime green"
281 "forest green" "light green" "green yellow" "yellow green" "olive drab"
282 "dark olive green" "lemon chiffon" "khaki" "dark khaki" "cornsilk"
283 "pale goldenrod" "light goldenrod" "goldenrod" "dark goldenrod" "wheat"
284 "navajo white" "tan" "burlywood" "sandy brown" "peru" "chocolate" "saddle brown"
285 "sienna" "rosy brown" "dark salmon" "coral" "tomato" "light salmon" "salmon"
286 "light coral" "indian red" "firebrick" "brown" "dark red" "magenta"
287 "dark magenta" "dark violet" "medium blue" "blue" "deep sky blue"
288 "cyan" "medium spring green" "spring green" "green" "lawn green" "chartreuse"
289 "yellow" "gold" "orange" "dark orange" "orange red" "red" "white" "white smoke"
290 "gainsboro" "light grey" "gray" "dark grey" "dim gray" "black" ))
291 "List of basic colors available on color displays.
292 For X, the list comes from the `rgb.txt' file,v 10.41 94/02/20.
293 For Nextstep, this is a list of non-PANTONE colors returned by
294 the operating system.")
296 ;; arch-tag: 2a128601-99cc-401e-9dff-0ee6a36102ef
297 ;;; common-win.el ends here