Reduce duplicate definitions of x-select-enable-clipboard from 3 to 2.
[bpt/emacs.git] / lisp / term / common-win.el
CommitLineData
d5e4dda5
DN
1;;; common-win.el --- common part of handling window systems
2
3;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
114f9c96 4;; 2008, 2009, 2010 Free Software Foundation, Inc.
d5e4dda5
DN
5
6;; Maintainer: FSF
7;; Keywords: terminals
8
9;; This file is part of GNU Emacs.
10
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.
15
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.
20
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/>.
23
24;;; Commentary:
25
26;;; Code:
27
8aa0f263
GM
28(defcustom x-select-enable-clipboard t
29 "Non-nil means cutting and pasting uses the clipboard.
30This is in addition to, but in preference to, the primary selection.
31
32Note that MS-Windows does not support selection types other than the
33clipboard. \(The primary selection that is set by Emacs is not
34accessible to other programs on MS-Windows.\)"
35 :type 'boolean
36 :group 'killing
37 ;; The GNU/Linux version changed in 24.1, the MS-Windows version did not.
38 :version "24.1")
d5e4dda5
DN
39
40(defvar x-invocation-args)
41
42(defvar x-command-line-resources nil)
43
44;; Handler for switches of the form "-switch value" or "-switch".
45(defun x-handle-switch (switch)
46 (let ((aelt (assoc switch command-line-x-option-alist)))
47 (if aelt
48 (let ((param (nth 3 aelt))
49 (value (nth 4 aelt)))
50 (if value
51 (setq default-frame-alist
52 (cons (cons param value)
53 default-frame-alist))
54 (setq default-frame-alist
55 (cons (cons param
56 (car x-invocation-args))
57 default-frame-alist)
58 x-invocation-args (cdr x-invocation-args)))))))
59
60;; Handler for switches of the form "-switch n"
61(defun x-handle-numeric-switch (switch)
62 (let ((aelt (assoc switch command-line-x-option-alist)))
63 (if aelt
64 (let ((param (nth 3 aelt)))
65 (setq default-frame-alist
66 (cons (cons param
67 (string-to-number (car x-invocation-args)))
68 default-frame-alist)
69 x-invocation-args
70 (cdr x-invocation-args))))))
71
72;; Handle options that apply to initial frame only
73(defun x-handle-initial-switch (switch)
74 (let ((aelt (assoc switch command-line-x-option-alist)))
75 (if aelt
76 (let ((param (nth 3 aelt))
77 (value (nth 4 aelt)))
78 (if value
79 (setq initial-frame-alist
80 (cons (cons param value)
81 initial-frame-alist))
82 (setq initial-frame-alist
83 (cons (cons param
84 (car x-invocation-args))
85 initial-frame-alist)
86 x-invocation-args (cdr x-invocation-args)))))))
87
88;; Make -iconic apply only to the initial frame!
89(defun x-handle-iconic (switch)
90 (setq initial-frame-alist
91 (cons '(visibility . icon) initial-frame-alist)))
92
93;; Handle the -xrm option.
94(defun x-handle-xrm-switch (switch)
95 (unless (consp x-invocation-args)
96 (error "%s: missing argument to `%s' option" (invocation-name) switch))
97 (setq x-command-line-resources
98 (if (null x-command-line-resources)
99 (car x-invocation-args)
100 (concat x-command-line-resources "\n" (car x-invocation-args))))
101 (setq x-invocation-args (cdr x-invocation-args)))
102
103(declare-function x-parse-geometry "frame.c" (string))
104
105;; Handle the geometry option
106(defun x-handle-geometry (switch)
107 (let* ((geo (x-parse-geometry (car x-invocation-args)))
108 (left (assq 'left geo))
109 (top (assq 'top geo))
110 (height (assq 'height geo))
111 (width (assq 'width geo)))
112 (if (or height width)
113 (setq default-frame-alist
114 (append default-frame-alist
115 '((user-size . t))
116 (if height (list height))
117 (if width (list width)))
118 initial-frame-alist
119 (append initial-frame-alist
120 '((user-size . t))
121 (if height (list height))
122 (if width (list width)))))
123 (if (or left top)
124 (setq initial-frame-alist
125 (append initial-frame-alist
126 '((user-position . t))
127 (if left (list left))
128 (if top (list top)))))
129 (setq x-invocation-args (cdr x-invocation-args))))
130
131(defvar x-resource-name)
132
133;; Handle the -name option. Set the variable x-resource-name
134;; to the option's operand; set the name of
135;; the initial frame, too.
136(defun x-handle-name-switch (switch)
137 (or (consp x-invocation-args)
138 (error "%s: missing argument to `%s' option" (invocation-name) switch))
139 (setq x-resource-name (car x-invocation-args)
140 x-invocation-args (cdr x-invocation-args))
141 (setq initial-frame-alist (cons (cons 'name x-resource-name)
142 initial-frame-alist)))
143
144(defvar x-display-name nil
3077d1f6
EZ
145 "The name of the window display on which Emacs was started.
146On X, the display name of individual X frames is recorded in the
147`display' frame parameter.")
d5e4dda5 148
d5e4dda5
DN
149(defun x-handle-display (switch)
150 "Handle -display DISPLAY option."
151 (setq x-display-name (car x-invocation-args)
152 x-invocation-args (cdr x-invocation-args))
153 ;; Make subshell programs see the same DISPLAY value Emacs really uses.
154 ;; Note that this isn't completely correct, since Emacs can use
155 ;; multiple displays. However, there is no way to tell an already
156 ;; running subshell which display the user is currently typing on.
157 (setenv "DISPLAY" x-display-name))
158
159(defun x-handle-args (args)
160 "Process the X-related command line options in ARGS.
161This is done before the user's startup file is loaded. They are copied to
162`x-invocation-args', from which the X-related things are extracted, first
163the switch (e.g., \"-fg\") in the following code, and possible values
164\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
165This function returns ARGS minus the arguments that have been processed."
166 ;; We use ARGS to accumulate the args that we don't handle here, to return.
167 (setq x-invocation-args args
168 args nil)
169 (while (and x-invocation-args
170 (not (equal (car x-invocation-args) "--")))
171 (let* ((this-switch (car x-invocation-args))
172 (orig-this-switch this-switch)
173 completion argval aelt handler)
174 (setq x-invocation-args (cdr x-invocation-args))
175 ;; Check for long options with attached arguments
176 ;; and separate out the attached option argument into argval.
177 (if (string-match "^--[^=]*=" this-switch)
178 (setq argval (substring this-switch (match-end 0))
179 this-switch (substring this-switch 0 (1- (match-end 0)))))
180 ;; Complete names of long options.
181 (if (string-match "^--" this-switch)
182 (progn
183 (setq completion (try-completion this-switch command-line-x-option-alist))
184 (if (eq completion t)
185 ;; Exact match for long option.
186 nil
187 (if (stringp completion)
188 (let ((elt (assoc completion command-line-x-option-alist)))
189 ;; Check for abbreviated long option.
190 (or elt
191 (error "Option `%s' is ambiguous" this-switch))
192 (setq this-switch completion))))))
193 (setq aelt (assoc this-switch command-line-x-option-alist))
194 (if aelt (setq handler (nth 2 aelt)))
195 (if handler
196 (if argval
197 (let ((x-invocation-args
198 (cons argval x-invocation-args)))
199 (funcall handler this-switch))
200 (funcall handler this-switch))
201 (setq args (cons orig-this-switch args)))))
202 (nconc (nreverse args) x-invocation-args))
203
204\f
205;;
206;; Available colors
207;;
208;; The ordering of the colors is chosen for the user's convenience in
209;; `list-colors-display', which displays the reverse of this list.
210;; Roughly speaking, `list-colors-display' orders by (i) named shades
211;; of grey with hue 0.0, sorted by value (ii) named colors with
212;; saturation 1.0, sorted by hue, (iii) named non-white colors with
213;; saturation less than 1.0, sorted by hue, (iv) other named shades of
214;; white, (v) numbered colors sorted by hue, and (vi) numbered shades
215;; of grey.
216
217(defvar x-colors
89877f5f
CY
218 (purecopy
219 '("gray100" "grey100" "gray99" "grey99" "gray98" "grey98" "gray97"
220 "grey97" "gray96" "grey96" "gray95" "grey95" "gray94" "grey94"
221 "gray93" "grey93" "gray92" "grey92" "gray91" "grey91" "gray90"
222 "grey90" "gray89" "grey89" "gray88" "grey88" "gray87" "grey87"
223 "gray86" "grey86" "gray85" "grey85" "gray84" "grey84" "gray83"
224 "grey83" "gray82" "grey82" "gray81" "grey81" "gray80" "grey80"
225 "gray79" "grey79" "gray78" "grey78" "gray77" "grey77" "gray76"
226 "grey76" "gray75" "grey75" "gray74" "grey74" "gray73" "grey73"
227 "gray72" "grey72" "gray71" "grey71" "gray70" "grey70" "gray69"
228 "grey69" "gray68" "grey68" "gray67" "grey67" "gray66" "grey66"
229 "gray65" "grey65" "gray64" "grey64" "gray63" "grey63" "gray62"
230 "grey62" "gray61" "grey61" "gray60" "grey60" "gray59" "grey59"
231 "gray58" "grey58" "gray57" "grey57" "gray56" "grey56" "gray55"
232 "grey55" "gray54" "grey54" "gray53" "grey53" "gray52" "grey52"
233 "gray51" "grey51" "gray50" "grey50" "gray49" "grey49" "gray48"
234 "grey48" "gray47" "grey47" "gray46" "grey46" "gray45" "grey45"
235 "gray44" "grey44" "gray43" "grey43" "gray42" "grey42" "gray41"
236 "grey41" "gray40" "grey40" "gray39" "grey39" "gray38" "grey38"
237 "gray37" "grey37" "gray36" "grey36" "gray35" "grey35" "gray34"
238 "grey34" "gray33" "grey33" "gray32" "grey32" "gray31" "grey31"
239 "gray30" "grey30" "gray29" "grey29" "gray28" "grey28" "gray27"
240 "grey27" "gray26" "grey26" "gray25" "grey25" "gray24" "grey24"
241 "gray23" "grey23" "gray22" "grey22" "gray21" "grey21" "gray20"
242 "grey20" "gray19" "grey19" "gray18" "grey18" "gray17" "grey17"
243 "gray16" "grey16" "gray15" "grey15" "gray14" "grey14" "gray13"
244 "grey13" "gray12" "grey12" "gray11" "grey11" "gray10" "grey10"
245 "gray9" "grey9" "gray8" "grey8" "gray7" "grey7" "gray6" "grey6"
246 "gray5" "grey5" "gray4" "grey4" "gray3" "grey3" "gray2" "grey2"
247 "gray1" "grey1" "gray0" "grey0"
248 "LightPink1" "LightPink2" "LightPink3" "LightPink4"
249 "pink1" "pink2" "pink3" "pink4"
250 "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4"
251 "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4"
252 "VioletRed1" "VioletRed2" "VioletRed3" "VioletRed4"
253 "HotPink1" "HotPink2" "HotPink3" "HotPink4"
254 "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4"
255 "maroon1" "maroon2" "maroon3" "maroon4"
256 "orchid1" "orchid2" "orchid3" "orchid4"
257 "plum1" "plum2" "plum3" "plum4"
258 "thistle1" "thistle2" "thistle3" "thistle4"
259 "MediumOrchid1" "MediumOrchid2" "MediumOrchid3" "MediumOrchid4"
260 "DarkOrchid1" "DarkOrchid2" "DarkOrchid3" "DarkOrchid4"
261 "purple1" "purple2" "purple3" "purple4"
262 "MediumPurple1" "MediumPurple2" "MediumPurple3" "MediumPurple4"
263 "SlateBlue1" "SlateBlue2" "SlateBlue3" "SlateBlue4"
264 "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4"
265 "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4"
266 "SlateGray1" "SlateGray2" "SlateGray3" "SlateGray4"
267 "DodgerBlue1" "DodgerBlue2" "DodgerBlue3" "DodgerBlue4"
268 "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4"
269 "SkyBlue1" "SkyBlue2" "SkyBlue3" "SkyBlue4"
270 "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3" "LightSkyBlue4"
271 "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4"
272 "CadetBlue1" "CadetBlue2" "CadetBlue3" "CadetBlue4"
273 "azure1" "azure2" "azure3" "azure4"
274 "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4"
275 "PaleTurquoise1" "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4"
276 "DarkSlateGray1" "DarkSlateGray2" "DarkSlateGray3" "DarkSlateGray4"
277 "aquamarine1" "aquamarine2" "aquamarine3" "aquamarine4"
278 "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4"
279 "honeydew1" "honeydew2" "honeydew3" "honeydew4"
280 "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3" "DarkSeaGreen4"
281 "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4"
282 "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4"
283 "OliveDrab1" "OliveDrab2" "OliveDrab3" "OliveDrab4"
284 "ivory1" "ivory2" "ivory3" "ivory4"
285 "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4"
286 "khaki1" "khaki2" "khaki3" "khaki4"
287 "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4"
288 "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4"
289 "cornsilk1" "cornsilk2" "cornsilk3" "cornsilk4"
290 "goldenrod1" "goldenrod2" "goldenrod3" "goldenrod4"
291 "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4"
292 "wheat1" "wheat2" "wheat3" "wheat4"
293 "NavajoWhite1" "NavajoWhite2" "NavajoWhite3" "NavajoWhite4"
294 "burlywood1" "burlywood2" "burlywood3" "burlywood4"
295 "AntiqueWhite1" "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4"
296 "bisque1" "bisque2" "bisque3" "bisque4"
297 "tan1" "tan2" "tan3" "tan4"
298 "PeachPuff1" "PeachPuff2" "PeachPuff3" "PeachPuff4"
299 "seashell1" "seashell2" "seashell3" "seashell4"
300 "chocolate1" "chocolate2" "chocolate3" "chocolate4"
301 "sienna1" "sienna2" "sienna3" "sienna4"
302 "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4"
303 "salmon1" "salmon2" "salmon3" "salmon4"
304 "coral1" "coral2" "coral3" "coral4"
305 "tomato1" "tomato2" "tomato3" "tomato4"
306 "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4"
307 "snow1" "snow2" "snow3" "snow4"
308 "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4"
309 "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4"
310 "firebrick1" "firebrick2" "firebrick3" "firebrick4"
311 "brown1" "brown2" "brown3" "brown4"
312 "magenta1" "magenta2" "magenta3" "magenta4"
313 "blue1" "blue2" "blue3" "blue4"
314 "DeepSkyBlue1" "DeepSkyBlue2" "DeepSkyBlue3" "DeepSkyBlue4"
315 "turquoise1" "turquoise2" "turquoise3" "turquoise4"
316 "cyan1" "cyan2" "cyan3" "cyan4"
317 "SpringGreen1" "SpringGreen2" "SpringGreen3" "SpringGreen4"
318 "green1" "green2" "green3" "green4"
319 "chartreuse1" "chartreuse2" "chartreuse3" "chartreuse4"
320 "yellow1" "yellow2" "yellow3" "yellow4"
321 "gold1" "gold2" "gold3" "gold4"
322 "orange1" "orange2" "orange3" "orange4"
323 "DarkOrange1" "DarkOrange2" "DarkOrange3" "DarkOrange4"
324 "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4"
325 "red1" "red2" "red3" "red4"
326 "lavender blush" "LavenderBlush" "ghost white" "GhostWhite"
327 "lavender" "alice blue" "AliceBlue" "azure" "light cyan"
328 "LightCyan" "mint cream" "MintCream" "honeydew" "ivory"
329 "light goldenrod yellow" "LightGoldenrodYellow" "light yellow"
330 "LightYellow" "beige" "floral white" "FloralWhite" "old lace"
331 "OldLace" "blanched almond" "BlanchedAlmond" "moccasin"
332 "papaya whip" "PapayaWhip" "bisque" "antique white"
333 "AntiqueWhite" "linen" "peach puff" "PeachPuff" "seashell"
334 "misty rose" "MistyRose" "snow" "light pink" "LightPink" "pink"
335 "hot pink" "HotPink" "deep pink" "DeepPink" "maroon"
336 "pale violet red" "PaleVioletRed" "violet red" "VioletRed"
337 "medium violet red" "MediumVioletRed" "violet" "plum" "thistle"
338 "orchid" "medium orchid" "MediumOrchid" "dark orchid"
339 "DarkOrchid" "purple" "blue violet" "BlueViolet" "medium purple"
340 "MediumPurple" "light slate blue" "LightSlateBlue"
341 "medium slate blue" "MediumSlateBlue" "slate blue" "SlateBlue"
342 "dark slate blue" "DarkSlateBlue" "midnight blue" "MidnightBlue"
343 "navy" "navy blue" "NavyBlue" "dark blue" "DarkBlue"
344 "light steel blue" "LightSteelBlue" "cornflower blue"
345 "CornflowerBlue" "dodger blue" "DodgerBlue" "royal blue"
346 "RoyalBlue" "light slate gray" "light slate grey"
347 "LightSlateGray" "LightSlateGrey" "slate gray" "slate grey"
348 "SlateGray" "SlateGrey" "dark slate gray" "dark slate grey"
349 "DarkSlateGray" "DarkSlateGrey" "steel blue" "SteelBlue"
350 "cadet blue" "CadetBlue" "light sky blue" "LightSkyBlue"
351 "sky blue" "SkyBlue" "light blue" "LightBlue" "powder blue"
352 "PowderBlue" "pale turquoise" "PaleTurquoise" "turquoise"
353 "medium turquoise" "MediumTurquoise" "dark turquoise"
354 "DarkTurquoise" "dark cyan" "DarkCyan" "aquamarine"
355 "medium aquamarine" "MediumAquamarine" "light sea green"
356 "LightSeaGreen" "medium sea green" "MediumSeaGreen" "sea green"
357 "SeaGreen" "dark sea green" "DarkSeaGreen" "pale green"
358 "PaleGreen" "lime green" "LimeGreen" "dark green" "DarkGreen"
359 "forest green" "ForestGreen" "light green" "LightGreen"
360 "green yellow" "GreenYellow" "yellow green" "YellowGreen"
361 "olive drab" "OliveDrab" "dark olive green" "DarkOliveGreen"
362 "lemon chiffon" "LemonChiffon" "khaki" "dark khaki" "DarkKhaki"
363 "cornsilk" "pale goldenrod" "PaleGoldenrod" "light goldenrod"
364 "LightGoldenrod" "goldenrod" "dark goldenrod" "DarkGoldenrod"
365 "wheat" "navajo white" "NavajoWhite" "tan" "burlywood"
366 "sandy brown" "SandyBrown" "peru" "chocolate" "saddle brown"
367 "SaddleBrown" "sienna" "rosy brown" "RosyBrown" "dark salmon"
368 "DarkSalmon" "coral" "tomato" "light salmon" "LightSalmon"
369 "salmon" "light coral" "LightCoral" "indian red" "IndianRed"
370 "firebrick" "brown" "dark red" "DarkRed" "magenta"
371 "dark magenta" "DarkMagenta" "dark violet" "DarkViolet"
372 "medium blue" "MediumBlue" "blue" "deep sky blue" "DeepSkyBlue"
373 "cyan" "medium spring green" "MediumSpringGreen" "spring green"
374 "SpringGreen" "green" "lawn green" "LawnGreen" "chartreuse"
375 "yellow" "gold" "orange" "dark orange" "DarkOrange" "orange red"
376 "OrangeRed" "red" "white" "white smoke" "WhiteSmoke" "gainsboro"
377 "light gray" "light grey" "LightGray" "LightGrey" "gray" "grey"
378 "dark gray" "dark grey" "DarkGray" "DarkGrey" "dim gray"
379 "dim grey" "DimGray" "DimGrey" "black"))
3077d1f6
EZ
380 "List of basic colors available on color displays.
381For X, the list comes from the `rgb.txt' file,v 10.41 94/02/20.
382For Nextstep, this is a list of non-PANTONE colors returned by
383the operating system.")
d5e4dda5
DN
384
385;;; common-win.el ends here