(mac-ae-open-documents): Escape file name on conversion to URL.
[bpt/emacs.git] / lisp / term / w32-win.el
CommitLineData
6a05d05f 1;;; w32-win.el --- parse switches controlling interface with W32 window system
2fe590dc 2
5fd6d89f 3;; Copyright (C) 1993, 1994, 2002, 2003, 2004,
253d8b7a 4;; 2005, 2006 Free Software Foundation, Inc.
ee78dc32
GV
5
6;; Author: Kevin Gallo
7;; Keywords: terminals
8
2fe590dc
EN
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 2, or (at your option)
14;; 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; see the file COPYING. If not, write to the
4fc5845f
LK
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
ee78dc32
GV
25
26;;; Commentary:
27
b63f9ba1
GV
28;; w32-win.el: this file is loaded from ../lisp/startup.el when it recognizes
29;; that W32 windows are to be used. Command line switches are parsed and those
30;; pertaining to W32 are processed and removed from the command line. The
31;; W32 display is opened and hooks are set for popping up the initial window.
ee78dc32
GV
32
33;; startup.el will then examine startup files, and eventually call the hooks
34;; which create the first window (s).
35
36;;; Code:
37\f
38
39;; These are the standard X switches from the Xt Initialize.c file of
40;; Release 4.
41
42;; Command line Resource Manager string
43
44;; +rv *reverseVideo
45;; +synchronous *synchronous
46;; -background *background
47;; -bd *borderColor
48;; -bg *background
49;; -bordercolor *borderColor
50;; -borderwidth .borderWidth
51;; -bw .borderWidth
52;; -display .display
53;; -fg *foreground
54;; -fn *font
55;; -font *font
56;; -foreground *foreground
57;; -geometry .geometry
58;; -i .iconType
59;; -itype .iconType
60;; -iconic .iconic
61;; -name .name
62;; -reverse *reverseVideo
63;; -rv *reverseVideo
64;; -selectionTimeout .selectionTimeout
65;; -synchronous *synchronous
66;; -xrm
67
68;; An alist of X options and the function which handles them. See
69;; ../startup.el.
70
b63f9ba1
GV
71(if (not (eq window-system 'w32))
72 (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
db95369b 73
ee78dc32
GV
74(require 'frame)
75(require 'mouse)
76(require 'scroll-bar)
77(require 'faces)
78(require 'select)
79(require 'menu-bar)
6bc52abc 80(require 'dnd)
b0efcd2e
JR
81(require 'code-pages)
82
b01f27a3
JB
83(defvar xlfd-regexp-registry-subnum)
84
b05f815e 85;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
64f41d64
JR
86(if (fboundp 'new-fontset)
87 (require 'fontset))
ee78dc32 88
15f18b89 89;; The following definition is used for debugging scroll bar events.
fbd6baed 90;(defun w32-handle-scroll-bar-event (event) (interactive "e") (princ event))
af99aa46 91
e596f2a2 92;; Handle mouse-wheel events with mwheel.
230c8ad7 93(mouse-wheel-mode 1)
d66be571 94
de0c7b5d
JR
95(defun w32-drag-n-drop-debug (event)
96 "Print the drag-n-drop EVENT in a readable form."
97 (interactive "e")
33b307f8
RS
98 (princ event))
99
100(defun w32-drag-n-drop (event)
de0c7b5d 101 "Edit the files listed in the drag-n-drop EVENT.
33b307f8
RS
102Switch to a buffer editing the last file dropped."
103 (interactive "e")
c8316112 104 (save-excursion
35a8911d
GM
105 ;; Make sure the drop target has positive co-ords
106 ;; before setting the selected frame - otherwise it
107 ;; won't work. <skx@tardis.ed.ac.uk>
108 (let* ((window (posn-window (event-start event)))
109 (coords (posn-x-y (event-start event)))
110 (x (car coords))
111 (y (cdr coords)))
112 (if (and (> x 0) (> y 0))
113 (set-frame-selected-window nil window))
5fd6d89f
TTN
114 (mapcar (lambda (file-name)
115 (dnd-handle-one-url window 'private
6bc52abc 116 (concat "file:" file-name)))
1e8b532f 117 (car (cdr (cdr event)))))
35a8911d 118 (raise-frame)))
33b307f8
RS
119
120(defun w32-drag-n-drop-other-frame (event)
de0c7b5d 121 "Edit the files listed in the drag-n-drop EVENT, in other frames.
33b307f8
RS
122May create new frames, or reuse existing ones. The frame editing
123the last file dropped is selected."
124 (interactive "e")
125 (mapcar 'find-file-other-frame (car (cdr (cdr event)))))
126
127;; Bind the drag-n-drop event.
128(global-set-key [drag-n-drop] 'w32-drag-n-drop)
129(global-set-key [C-drag-n-drop] 'w32-drag-n-drop-other-frame)
130
a73c80a3
GV
131;; Keyboard layout/language change events
132;; For now ignore language-change events; in the future
133;; we should switch the Emacs Input Method to match the
134;; new layout/language selected by the user.
135(global-set-key [language-change] 'ignore)
136
ee78dc32
GV
137(defvar x-invocation-args)
138
139(defvar x-command-line-resources nil)
140
ee78dc32 141(defun x-handle-switch (switch)
de0c7b5d 142 "Handle SWITCH of the form \"-switch value\" or \"-switch\"."
3d27abc4 143 (let ((aelt (assoc switch command-line-x-option-alist)))
ee78dc32 144 (if aelt
bd6a8278
SM
145 (push (cons (nth 3 aelt) (or (nth 4 aelt) (pop x-invocation-args)))
146 default-frame-alist))))
de0c7b5d 147
ee78dc32 148(defun x-handle-numeric-switch (switch)
de0c7b5d 149 "Handle SWITCH of the form \"-switch n\"."
3d27abc4 150 (let ((aelt (assoc switch command-line-x-option-alist)))
ee78dc32 151 (if aelt
027a4b6b 152 (push (cons (nth 3 aelt) (string-to-number (pop x-invocation-args)))
bd6a8278 153 default-frame-alist))))
3d27abc4
JR
154
155;; Handle options that apply to initial frame only
156(defun x-handle-initial-switch (switch)
157 (let ((aelt (assoc switch command-line-x-option-alist)))
158 (if aelt
bd6a8278
SM
159 (push (cons (nth 3 aelt) (or (nth 4 aelt) (pop x-invocation-args)))
160 initial-frame-alist))))
3d27abc4
JR
161
162(defun x-handle-iconic (switch)
163 "Make \"-iconic\" SWITCH apply only to the initial frame."
bd6a8278 164 (push '(visibility . icon) initial-frame-alist))
ee78dc32 165
ee78dc32 166(defun x-handle-xrm-switch (switch)
de0c7b5d 167 "Handle the \"-xrm\" SWITCH."
ee78dc32
GV
168 (or (consp x-invocation-args)
169 (error "%s: missing argument to `%s' option" (invocation-name) switch))
3d27abc4
JR
170 (setq x-command-line-resources
171 (if (null x-command-line-resources)
172 (car x-invocation-args)
173 (concat x-command-line-resources "\n" (car x-invocation-args))))
ee78dc32
GV
174 (setq x-invocation-args (cdr x-invocation-args)))
175
ee78dc32 176(defun x-handle-geometry (switch)
de0c7b5d 177 "Handle the \"-geometry\" SWITCH."
ea8d3061
RS
178 (let* ((geo (x-parse-geometry (car x-invocation-args)))
179 (left (assq 'left geo))
180 (top (assq 'top geo))
181 (height (assq 'height geo))
182 (width (assq 'width geo)))
183 (if (or height width)
184 (setq default-frame-alist
185 (append default-frame-alist
0ebcabe7
JB
186 '((user-size . t))
187 (if height (list height))
188 (if width (list width)))
189 initial-frame-alist
190 (append initial-frame-alist
ea8d3061
RS
191 '((user-size . t))
192 (if height (list height))
193 (if width (list width)))))
194 (if (or left top)
195 (setq initial-frame-alist
196 (append initial-frame-alist
197 '((user-position . t))
198 (if left (list left))
199 (if top (list top)))))
200 (setq x-invocation-args (cdr x-invocation-args))))
ee78dc32 201
3d27abc4
JR
202(defun x-handle-name-switch (switch)
203 "Handle a \"-name\" SWITCH."
204;; Handle the -name option. Set the variable x-resource-name
205;; to the option's operand; set the name of the initial frame, too.
ee78dc32
GV
206 (or (consp x-invocation-args)
207 (error "%s: missing argument to `%s' option" (invocation-name) switch))
bd6a8278
SM
208 (setq x-resource-name (pop x-invocation-args))
209 (push (cons 'name x-resource-name) initial-frame-alist))
ee78dc32
GV
210
211(defvar x-display-name nil
212 "The display name specifying server and frame.")
213
214(defun x-handle-display (switch)
de0c7b5d 215 "Handle the \"-display\" SWITCH."
bd6a8278 216 (setq x-display-name (pop x-invocation-args)))
ee78dc32 217
ee78dc32
GV
218(defun x-handle-args (args)
219 "Process the X-related command line options in ARGS.
220This is done before the user's startup file is loaded. They are copied to
3d27abc4 221`x-invocation args' from which the X-related things are extracted, first
ee78dc32
GV
222the switch (e.g., \"-fg\") in the following code, and possible values
223\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
224This returns ARGS with the arguments that have been processed removed."
3d27abc4 225 ;; We use ARGS to accumulate the args that we don't handle here, to return.
ee78dc32
GV
226 (setq x-invocation-args args
227 args nil)
3d27abc4
JR
228 (while (and x-invocation-args
229 (not (equal (car x-invocation-args) "--")))
ee78dc32
GV
230 (let* ((this-switch (car x-invocation-args))
231 (orig-this-switch this-switch)
3d27abc4 232 completion argval aelt handler)
ee78dc32
GV
233 (setq x-invocation-args (cdr x-invocation-args))
234 ;; Check for long options with attached arguments
235 ;; and separate out the attached option argument into argval.
236 (if (string-match "^--[^=]*=" this-switch)
237 (setq argval (substring this-switch (match-end 0))
238 this-switch (substring this-switch 0 (1- (match-end 0)))))
3d27abc4
JR
239 ;; Complete names of long options.
240 (if (string-match "^--" this-switch)
241 (progn
242 (setq completion (try-completion this-switch command-line-x-option-alist))
243 (if (eq completion t)
244 ;; Exact match for long option.
245 nil
246 (if (stringp completion)
247 (let ((elt (assoc completion command-line-x-option-alist)))
248 ;; Check for abbreviated long option.
249 (or elt
250 (error "Option `%s' is ambiguous" this-switch))
251 (setq this-switch completion))))))
252 (setq aelt (assoc this-switch command-line-x-option-alist))
253 (if aelt (setq handler (nth 2 aelt)))
254 (if handler
ee78dc32
GV
255 (if argval
256 (let ((x-invocation-args
257 (cons argval x-invocation-args)))
3d27abc4
JR
258 (funcall handler this-switch))
259 (funcall handler this-switch))
bd6a8278 260 (push orig-this-switch args))))
3d27abc4 261 (nconc (nreverse args) x-invocation-args))
ee78dc32
GV
262\f
263;;
264;; Available colors
265;;
266
027a15c1
EZ
267(defvar x-colors '("LightGreen"
268 "light green"
269 "DarkRed"
270 "dark red"
271 "DarkMagenta"
272 "dark magenta"
273 "DarkCyan"
274 "dark cyan"
275 "DarkBlue"
276 "dark blue"
277 "DarkGray"
278 "dark gray"
279 "DarkGrey"
280 "dark grey"
281 "grey100"
282 "gray100"
283 "grey99"
284 "gray99"
285 "grey98"
286 "gray98"
287 "grey97"
288 "gray97"
289 "grey96"
290 "gray96"
291 "grey95"
292 "gray95"
293 "grey94"
294 "gray94"
295 "grey93"
296 "gray93"
297 "grey92"
298 "gray92"
299 "grey91"
300 "gray91"
301 "grey90"
302 "gray90"
303 "grey89"
304 "gray89"
305 "grey88"
306 "gray88"
307 "grey87"
308 "gray87"
309 "grey86"
310 "gray86"
311 "grey85"
312 "gray85"
313 "grey84"
314 "gray84"
315 "grey83"
316 "gray83"
317 "grey82"
318 "gray82"
319 "grey81"
320 "gray81"
321 "grey80"
322 "gray80"
323 "grey79"
324 "gray79"
325 "grey78"
326 "gray78"
327 "grey77"
328 "gray77"
329 "grey76"
330 "gray76"
331 "grey75"
332 "gray75"
333 "grey74"
334 "gray74"
335 "grey73"
336 "gray73"
337 "grey72"
338 "gray72"
339 "grey71"
340 "gray71"
341 "grey70"
342 "gray70"
343 "grey69"
344 "gray69"
345 "grey68"
346 "gray68"
347 "grey67"
348 "gray67"
349 "grey66"
350 "gray66"
351 "grey65"
352 "gray65"
353 "grey64"
354 "gray64"
355 "grey63"
356 "gray63"
357 "grey62"
358 "gray62"
359 "grey61"
360 "gray61"
361 "grey60"
362 "gray60"
363 "grey59"
364 "gray59"
365 "grey58"
366 "gray58"
367 "grey57"
368 "gray57"
369 "grey56"
370 "gray56"
371 "grey55"
372 "gray55"
373 "grey54"
374 "gray54"
375 "grey53"
376 "gray53"
377 "grey52"
378 "gray52"
379 "grey51"
380 "gray51"
381 "grey50"
382 "gray50"
383 "grey49"
384 "gray49"
385 "grey48"
386 "gray48"
387 "grey47"
388 "gray47"
389 "grey46"
390 "gray46"
391 "grey45"
392 "gray45"
393 "grey44"
394 "gray44"
395 "grey43"
396 "gray43"
397 "grey42"
398 "gray42"
399 "grey41"
400 "gray41"
401 "grey40"
402 "gray40"
403 "grey39"
404 "gray39"
405 "grey38"
406 "gray38"
407 "grey37"
408 "gray37"
409 "grey36"
410 "gray36"
411 "grey35"
412 "gray35"
413 "grey34"
414 "gray34"
415 "grey33"
416 "gray33"
417 "grey32"
418 "gray32"
419 "grey31"
420 "gray31"
421 "grey30"
422 "gray30"
423 "grey29"
424 "gray29"
425 "grey28"
426 "gray28"
427 "grey27"
428 "gray27"
429 "grey26"
430 "gray26"
431 "grey25"
432 "gray25"
433 "grey24"
434 "gray24"
435 "grey23"
436 "gray23"
437 "grey22"
438 "gray22"
439 "grey21"
440 "gray21"
441 "grey20"
442 "gray20"
443 "grey19"
444 "gray19"
445 "grey18"
446 "gray18"
447 "grey17"
448 "gray17"
449 "grey16"
450 "gray16"
451 "grey15"
452 "gray15"
453 "grey14"
454 "gray14"
455 "grey13"
456 "gray13"
457 "grey12"
458 "gray12"
459 "grey11"
460 "gray11"
461 "grey10"
462 "gray10"
463 "grey9"
464 "gray9"
465 "grey8"
466 "gray8"
467 "grey7"
468 "gray7"
469 "grey6"
470 "gray6"
471 "grey5"
472 "gray5"
473 "grey4"
474 "gray4"
475 "grey3"
476 "gray3"
477 "grey2"
478 "gray2"
479 "grey1"
480 "gray1"
481 "grey0"
482 "gray0"
483 "thistle4"
484 "thistle3"
485 "thistle2"
486 "thistle1"
487 "MediumPurple4"
488 "MediumPurple3"
489 "MediumPurple2"
490 "MediumPurple1"
491 "purple4"
492 "purple3"
493 "purple2"
494 "purple1"
495 "DarkOrchid4"
496 "DarkOrchid3"
497 "DarkOrchid2"
498 "DarkOrchid1"
499 "MediumOrchid4"
500 "MediumOrchid3"
501 "MediumOrchid2"
502 "MediumOrchid1"
503 "plum4"
504 "plum3"
505 "plum2"
506 "plum1"
507 "orchid4"
508 "orchid3"
509 "orchid2"
510 "orchid1"
511 "magenta4"
512 "magenta3"
513 "magenta2"
514 "magenta1"
515 "VioletRed4"
516 "VioletRed3"
517 "VioletRed2"
518 "VioletRed1"
519 "maroon4"
520 "maroon3"
521 "maroon2"
522 "maroon1"
523 "PaleVioletRed4"
524 "PaleVioletRed3"
525 "PaleVioletRed2"
526 "PaleVioletRed1"
527 "LightPink4"
528 "LightPink3"
529 "LightPink2"
530 "LightPink1"
531 "pink4"
532 "pink3"
533 "pink2"
534 "pink1"
535 "HotPink4"
536 "HotPink3"
537 "HotPink2"
538 "HotPink1"
539 "DeepPink4"
540 "DeepPink3"
541 "DeepPink2"
542 "DeepPink1"
543 "red4"
544 "red3"
545 "red2"
546 "red1"
547 "OrangeRed4"
548 "OrangeRed3"
549 "OrangeRed2"
550 "OrangeRed1"
551 "tomato4"
552 "tomato3"
553 "tomato2"
554 "tomato1"
555 "coral4"
556 "coral3"
557 "coral2"
558 "coral1"
559 "DarkOrange4"
560 "DarkOrange3"
561 "DarkOrange2"
562 "DarkOrange1"
563 "orange4"
564 "orange3"
565 "orange2"
566 "orange1"
567 "LightSalmon4"
568 "LightSalmon3"
569 "LightSalmon2"
570 "LightSalmon1"
571 "salmon4"
572 "salmon3"
573 "salmon2"
574 "salmon1"
575 "brown4"
576 "brown3"
577 "brown2"
578 "brown1"
579 "firebrick4"
580 "firebrick3"
581 "firebrick2"
582 "firebrick1"
583 "chocolate4"
584 "chocolate3"
585 "chocolate2"
586 "chocolate1"
587 "tan4"
588 "tan3"
589 "tan2"
590 "tan1"
591 "wheat4"
592 "wheat3"
593 "wheat2"
594 "wheat1"
595 "burlywood4"
596 "burlywood3"
597 "burlywood2"
598 "burlywood1"
599 "sienna4"
600 "sienna3"
601 "sienna2"
602 "sienna1"
603 "IndianRed4"
604 "IndianRed3"
605 "IndianRed2"
606 "IndianRed1"
607 "RosyBrown4"
608 "RosyBrown3"
609 "RosyBrown2"
610 "RosyBrown1"
611 "DarkGoldenrod4"
612 "DarkGoldenrod3"
613 "DarkGoldenrod2"
614 "DarkGoldenrod1"
615 "goldenrod4"
616 "goldenrod3"
617 "goldenrod2"
618 "goldenrod1"
619 "gold4"
620 "gold3"
621 "gold2"
622 "gold1"
623 "yellow4"
624 "yellow3"
625 "yellow2"
626 "yellow1"
627 "LightYellow4"
628 "LightYellow3"
629 "LightYellow2"
630 "LightYellow1"
631 "LightGoldenrod4"
632 "LightGoldenrod3"
633 "LightGoldenrod2"
634 "LightGoldenrod1"
635 "khaki4"
636 "khaki3"
637 "khaki2"
638 "khaki1"
639 "DarkOliveGreen4"
640 "DarkOliveGreen3"
641 "DarkOliveGreen2"
642 "DarkOliveGreen1"
643 "OliveDrab4"
644 "OliveDrab3"
645 "OliveDrab2"
646 "OliveDrab1"
647 "chartreuse4"
648 "chartreuse3"
649 "chartreuse2"
650 "chartreuse1"
651 "green4"
652 "green3"
653 "green2"
654 "green1"
655 "SpringGreen4"
656 "SpringGreen3"
657 "SpringGreen2"
658 "SpringGreen1"
659 "PaleGreen4"
660 "PaleGreen3"
661 "PaleGreen2"
662 "PaleGreen1"
663 "SeaGreen4"
664 "SeaGreen3"
665 "SeaGreen2"
666 "SeaGreen1"
667 "DarkSeaGreen4"
668 "DarkSeaGreen3"
669 "DarkSeaGreen2"
670 "DarkSeaGreen1"
671 "aquamarine4"
672 "aquamarine3"
673 "aquamarine2"
674 "aquamarine1"
675 "DarkSlateGray4"
676 "DarkSlateGray3"
677 "DarkSlateGray2"
678 "DarkSlateGray1"
679 "cyan4"
680 "cyan3"
681 "cyan2"
682 "cyan1"
683 "turquoise4"
684 "turquoise3"
685 "turquoise2"
686 "turquoise1"
687 "CadetBlue4"
688 "CadetBlue3"
689 "CadetBlue2"
690 "CadetBlue1"
691 "PaleTurquoise4"
692 "PaleTurquoise3"
693 "PaleTurquoise2"
694 "PaleTurquoise1"
695 "LightCyan4"
696 "LightCyan3"
697 "LightCyan2"
698 "LightCyan1"
699 "LightBlue4"
700 "LightBlue3"
701 "LightBlue2"
702 "LightBlue1"
703 "LightSteelBlue4"
704 "LightSteelBlue3"
705 "LightSteelBlue2"
706 "LightSteelBlue1"
707 "SlateGray4"
708 "SlateGray3"
709 "SlateGray2"
710 "SlateGray1"
711 "LightSkyBlue4"
712 "LightSkyBlue3"
713 "LightSkyBlue2"
714 "LightSkyBlue1"
715 "SkyBlue4"
716 "SkyBlue3"
717 "SkyBlue2"
718 "SkyBlue1"
719 "DeepSkyBlue4"
720 "DeepSkyBlue3"
721 "DeepSkyBlue2"
722 "DeepSkyBlue1"
723 "SteelBlue4"
724 "SteelBlue3"
725 "SteelBlue2"
726 "SteelBlue1"
727 "DodgerBlue4"
728 "DodgerBlue3"
729 "DodgerBlue2"
730 "DodgerBlue1"
731 "blue4"
732 "blue3"
733 "blue2"
734 "blue1"
735 "RoyalBlue4"
736 "RoyalBlue3"
737 "RoyalBlue2"
738 "RoyalBlue1"
739 "SlateBlue4"
740 "SlateBlue3"
741 "SlateBlue2"
742 "SlateBlue1"
743 "azure4"
744 "azure3"
745 "azure2"
746 "azure1"
747 "MistyRose4"
748 "MistyRose3"
749 "MistyRose2"
750 "MistyRose1"
751 "LavenderBlush4"
752 "LavenderBlush3"
753 "LavenderBlush2"
754 "LavenderBlush1"
755 "honeydew4"
756 "honeydew3"
757 "honeydew2"
758 "honeydew1"
759 "ivory4"
760 "ivory3"
761 "ivory2"
762 "ivory1"
763 "cornsilk4"
764 "cornsilk3"
765 "cornsilk2"
766 "cornsilk1"
767 "LemonChiffon4"
768 "LemonChiffon3"
769 "LemonChiffon2"
770 "LemonChiffon1"
771 "NavajoWhite4"
772 "NavajoWhite3"
773 "NavajoWhite2"
774 "NavajoWhite1"
775 "PeachPuff4"
776 "PeachPuff3"
777 "PeachPuff2"
778 "PeachPuff1"
779 "bisque4"
780 "bisque3"
781 "bisque2"
782 "bisque1"
783 "AntiqueWhite4"
784 "AntiqueWhite3"
785 "AntiqueWhite2"
786 "AntiqueWhite1"
787 "seashell4"
788 "seashell3"
789 "seashell2"
790 "seashell1"
791 "snow4"
792 "snow3"
793 "snow2"
794 "snow1"
795 "thistle"
796 "MediumPurple"
797 "medium purple"
798 "purple"
799 "BlueViolet"
800 "blue violet"
801 "DarkViolet"
802 "dark violet"
803 "DarkOrchid"
804 "dark orchid"
805 "MediumOrchid"
806 "medium orchid"
807 "orchid"
808 "plum"
809 "violet"
810 "magenta"
811 "VioletRed"
812 "violet red"
813 "MediumVioletRed"
814 "medium violet red"
815 "maroon"
816 "PaleVioletRed"
817 "pale violet red"
818 "LightPink"
819 "light pink"
820 "pink"
821 "DeepPink"
822 "deep pink"
823 "HotPink"
824 "hot pink"
825 "red"
826 "OrangeRed"
827 "orange red"
828 "tomato"
829 "LightCoral"
830 "light coral"
ee78dc32 831 "coral"
027a15c1
EZ
832 "DarkOrange"
833 "dark orange"
834 "orange"
835 "LightSalmon"
836 "light salmon"
837 "salmon"
838 "DarkSalmon"
839 "dark salmon"
ee78dc32 840 "brown"
027a15c1
EZ
841 "firebrick"
842 "chocolate"
843 "tan"
844 "SandyBrown"
845 "sandy brown"
846 "wheat"
847 "beige"
848 "burlywood"
849 "peru"
850 "sienna"
851 "SaddleBrown"
852 "saddle brown"
853 "IndianRed"
854 "indian red"
855 "RosyBrown"
856 "rosy brown"
857 "DarkGoldenrod"
858 "dark goldenrod"
ee78dc32 859 "goldenrod"
027a15c1
EZ
860 "LightGoldenrod"
861 "light goldenrod"
862 "gold"
863 "yellow"
864 "LightYellow"
865 "light yellow"
866 "LightGoldenrodYellow"
867 "light goldenrod yellow"
868 "PaleGoldenrod"
869 "pale goldenrod"
870 "khaki"
871 "DarkKhaki"
872 "dark khaki"
873 "OliveDrab"
874 "olive drab"
ee78dc32 875 "ForestGreen"
027a15c1
EZ
876 "forest green"
877 "YellowGreen"
878 "yellow green"
ee78dc32 879 "LimeGreen"
027a15c1
EZ
880 "lime green"
881 "GreenYellow"
882 "green yellow"
ee78dc32 883 "MediumSpringGreen"
027a15c1
EZ
884 "medium spring green"
885 "chartreuse"
886 "green"
887 "LawnGreen"
888 "lawn green"
889 "SpringGreen"
890 "spring green"
ee78dc32 891 "PaleGreen"
027a15c1
EZ
892 "pale green"
893 "LightSeaGreen"
894 "light sea green"
895 "MediumSeaGreen"
896 "medium sea green"
ee78dc32 897 "SeaGreen"
027a15c1
EZ
898 "sea green"
899 "DarkSeaGreen"
900 "dark sea green"
901 "DarkOliveGreen"
902 "dark olive green"
903 "DarkGreen"
904 "dark green"
905 "aquamarine"
906 "MediumAquamarine"
907 "medium aquamarine"
908 "CadetBlue"
909 "cadet blue"
910 "LightCyan"
911 "light cyan"
912 "cyan"
ee78dc32 913 "turquoise"
ee78dc32 914 "MediumTurquoise"
027a15c1
EZ
915 "medium turquoise"
916 "DarkTurquoise"
917 "dark turquoise"
918 "PaleTurquoise"
919 "pale turquoise"
920 "PowderBlue"
921 "powder blue"
922 "LightBlue"
923 "light blue"
924 "LightSteelBlue"
925 "light steel blue"
926 "SteelBlue"
927 "steel blue"
928 "LightSkyBlue"
929 "light sky blue"
930 "SkyBlue"
931 "sky blue"
932 "DeepSkyBlue"
933 "deep sky blue"
934 "DodgerBlue"
935 "dodger blue"
936 "blue"
937 "RoyalBlue"
938 "royal blue"
939 "MediumBlue"
940 "medium blue"
941 "LightSlateBlue"
942 "light slate blue"
943 "MediumSlateBlue"
944 "medium slate blue"
945 "SlateBlue"
946 "slate blue"
947 "DarkSlateBlue"
948 "dark slate blue"
949 "CornflowerBlue"
950 "cornflower blue"
951 "NavyBlue"
952 "navy blue"
953 "navy"
954 "MidnightBlue"
955 "midnight blue"
956 "LightGray"
957 "light gray"
958 "LightGrey"
959 "light grey"
960 "grey"
961 "gray"
962 "LightSlateGrey"
963 "light slate grey"
964 "LightSlateGray"
965 "light slate gray"
966 "SlateGrey"
967 "slate grey"
968 "SlateGray"
969 "slate gray"
970 "DimGrey"
971 "dim grey"
972 "DimGray"
973 "dim gray"
974 "DarkSlateGrey"
975 "dark slate grey"
976 "DarkSlateGray"
977 "dark slate gray"
978 "black"
ee78dc32 979 "white"
027a15c1
EZ
980 "MistyRose"
981 "misty rose"
982 "LavenderBlush"
983 "lavender blush"
984 "lavender"
985 "AliceBlue"
986 "alice blue"
987 "azure"
988 "MintCream"
989 "mint cream"
990 "honeydew"
991 "seashell"
992 "LemonChiffon"
993 "lemon chiffon"
994 "ivory"
995 "cornsilk"
996 "moccasin"
997 "NavajoWhite"
998 "navajo white"
999 "PeachPuff"
1000 "peach puff"
1001 "bisque"
1002 "BlanchedAlmond"
1003 "blanched almond"
1004 "PapayaWhip"
1005 "papaya whip"
1006 "AntiqueWhite"
1007 "antique white"
1008 "linen"
1009 "OldLace"
1010 "old lace"
1011 "FloralWhite"
1012 "floral white"
1013 "gainsboro"
1014 "WhiteSmoke"
1015 "white smoke"
1016 "GhostWhite"
1017 "ghost white"
1018 "snow")
1019 "The list of X colors from the `rgb.txt' file.
1020XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
ee78dc32 1021
f795f633
EZ
1022(defun xw-defined-colors (&optional frame)
1023 "Internal function called by `defined-colors', which see."
ee78dc32 1024 (or frame (setq frame (selected-frame)))
bd6a8278
SM
1025 (let ((defined-colors nil))
1026 (dolist (this-color (or (mapcar 'car w32-color-map) x-colors))
79b24da3 1027 (and (color-supported-p this-color frame t)
bd6a8278 1028 (push this-color defined-colors)))
ee78dc32
GV
1029 defined-colors))
1030\f
d66be571 1031\f
ee78dc32
GV
1032;;;; Function keys
1033
d66be571
GV
1034;;; make f10 activate the real menubar rather than the mini-buffer menu
1035;;; navigation feature.
1036(global-set-key [f10] (lambda ()
1037 (interactive) (w32-send-sys-command ?\xf100)))
1038
ee78dc32
GV
1039(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1040 global-map)
1041
756bfad5
JL
1042(define-key function-key-map [S-tab] [backtab])
1043
ee78dc32 1044\f
ee78dc32
GV
1045;;; Do the actual Windows setup here; the above code just defines
1046;;; functions and variables that we use now.
1047
1048(setq command-line-args (x-handle-args command-line-args))
1049
1050;;; Make sure we have a valid resource name.
1051(or (stringp x-resource-name)
bd6a8278
SM
1052 (setq x-resource-name
1053 ;; Change any . or * characters in x-resource-name to hyphens,
1054 ;; so as not to choke when we use it in X resource queries.
1055 (replace-regexp-in-string "[.*]" "-" (invocation-name))))
ee78dc32
GV
1056
1057;; For the benefit of older Emacses (19.27 and earlier) that are sharing
1058;; the same lisp directory, don't pass the third argument unless we seem
1059;; to have the multi-display support.
1060(if (fboundp 'x-close-connection)
1061 (x-open-connection ""
1062 x-command-line-resources
1063 ;; Exit Emacs with fatal error if this fails.
1064 t)
1065 (x-open-connection ""
1066 x-command-line-resources))
1067
1068(setq frame-creation-function 'x-create-frame-with-faces)
1069
1070(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
1071 x-cut-buffer-max))
1072
fbd6baed 1073;; W32 expects the menu bar cut and paste commands to use the clipboard.
ee78dc32
GV
1074;; This has ,? to match both on Sunos and on Solaris.
1075(menu-bar-enable-clipboard)
1076
4664455c
GV
1077;; W32 systems have different fonts than commonly found on X, so
1078;; we define our own standard fontset here.
1079(defvar w32-standard-fontset-spec
e7a8ad1f 1080 "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-standard"
de0c7b5d
JR
1081 "String of fontset spec of the standard fontset.
1082This defines a fontset consisting of the Courier New variations for
1083European languages which are distributed with Windows as
1084\"Multilanguage Support\".
4664455c
GV
1085
1086See the documentation of `create-fontset-from-fontset-spec for the format.")
1087
b05f815e 1088;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
de0c7b5d
JR
1089(if (fboundp 'new-fontset)
1090 (progn
7f75eaa8
KH
1091 ;; Setup the default fontset.
1092 (setup-default-fontset)
de0c7b5d
JR
1093 ;; Create the standard fontset.
1094 (create-fontset-from-fontset-spec w32-standard-fontset-spec t)
1095 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1,...).
1096 (create-fontset-from-x-resource)
1097 ;; Try to create a fontset from a font specification which comes
1098 ;; from initial-frame-alist, default-frame-alist, or X resource.
1099 ;; A font specification in command line argument (i.e. -fn XXXX)
1100 ;; should be already in default-frame-alist as a `font'
1101 ;; parameter. However, any font specifications in site-start
1102 ;; library, user's init file (.emacs), and default.el are not
1103 ;; yet handled here.
1104
1105 (let ((font (or (cdr (assq 'font initial-frame-alist))
1106 (cdr (assq 'font default-frame-alist))
1107 (x-get-resource "font" "Font")))
1108 xlfd-fields resolved-name)
1109 (if (and font
1110 (not (query-fontset font))
1111 (setq resolved-name (x-resolve-font-name font))
1112 (setq xlfd-fields (x-decompose-font-name font)))
1113 (if (string= "fontset"
1114 (aref xlfd-fields xlfd-regexp-registry-subnum))
1115 (new-fontset font
1116 (x-complement-fontset-spec xlfd-fields nil))
1117 ;; Create a fontset from FONT. The fontset name is
1118 ;; generated from FONT.
1119 (create-fontset-from-ascii-font font
1120 resolved-name "startup"))))))
4664455c 1121
ee78dc32
GV
1122;; Apply a geometry resource to the initial frame. Put it at the end
1123;; of the alist, so that anything specified on the command line takes
1124;; precedence.
1125(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1126 parsed)
1127 (if res-geometry
1128 (progn
1129 (setq parsed (x-parse-geometry res-geometry))
1130 ;; If the resource specifies a position,
1131 ;; call the position and size "user-specified".
1132 (if (or (assq 'top parsed) (assq 'left parsed))
1133 (setq parsed (cons '(user-position . t)
1134 (cons '(user-size . t) parsed))))
1135 ;; All geometry parms apply to the initial frame.
1136 (setq initial-frame-alist (append initial-frame-alist parsed))
1137 ;; The size parms apply to all frames.
1138 (if (assq 'height parsed)
bd6a8278
SM
1139 (push (cons 'height (cdr (assq 'height parsed)))
1140 default-frame-alist))
ee78dc32 1141 (if (assq 'width parsed)
bd6a8278
SM
1142 (push (cons 'width (cdr (assq 'width parsed)))
1143 default-frame-alist)))))
ee78dc32
GV
1144
1145;; Check the reverseVideo resource.
1146(let ((case-fold-search t))
1147 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
bd6a8278
SM
1148 (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv))
1149 (push '(reverse . t) default-frame-alist))))
ee78dc32 1150
ee78dc32 1151(defun x-win-suspend-error ()
de0c7b5d
JR
1152 "Report an error when a suspend is attempted."
1153 (error "Suspending an Emacs running under W32 makes no sense"))
ee78dc32
GV
1154(add-hook 'suspend-hook 'x-win-suspend-error)
1155
fbd6baed 1156;;; Turn off window-splitting optimization; w32 is usually fast enough
ee78dc32
GV
1157;;; that this is only annoying.
1158(setq split-window-keep-point t)
1159
1160;; Don't show the frame name; that's redundant.
f182c531 1161(setq-default mode-line-frame-identification " ")
ee78dc32
GV
1162
1163;;; Set to a system sound if you want a fancy bell.
1164(set-message-beep 'ok)
1165
fbd6baed 1166;; Remap some functions to call w32 common dialogs
ee78dc32
GV
1167
1168(defun internal-face-interactive (what &optional bool)
1169 (let* ((fn (intern (concat "face-" what)))
3247de96
DL
1170 (prompt (concat "Set " what " of face "))
1171 (face (read-face-name prompt))
ee78dc32
GV
1172 (default (if (fboundp fn)
1173 (or (funcall fn face (selected-frame))
1174 (funcall fn 'default (selected-frame)))))
1175 (fn-win (intern (concat (symbol-name window-system) "-select-" what)))
3ce36200
AI
1176 value)
1177 (setq value
1178 (cond ((fboundp fn-win)
1179 (funcall fn-win))
1180 ((eq bool 'color)
1181 (completing-read (concat prompt " " (symbol-name face) " to: ")
1182 (mapcar (function (lambda (color)
1183 (cons color color)))
1184 x-colors)
1185 nil nil nil nil default))
1186 (bool
1187 (y-or-n-p (concat "Should face " (symbol-name face)
1188 " be " bool "? ")))
1189 (t
1190 (read-string (concat prompt " " (symbol-name face) " to: ")
1191 nil nil default))))
1192 (list face (if (equal value "") nil value))))
ee78dc32 1193
d76d2456 1194;;; Enable Japanese fonts on Windows to be used by default.
41cba4d0
KH
1195(set-fontset-font nil (make-char 'katakana-jisx0201) '("*" . "JISX0208-SJIS"))
1196(set-fontset-font nil (make-char 'latin-jisx0201) '("*" . "JISX0208-SJIS"))
1197(set-fontset-font nil (make-char 'japanese-jisx0208) '("*" . "JISX0208-SJIS"))
1198(set-fontset-font nil (make-char 'japanese-jisx0208-1978) '("*" . "JISX0208-SJIS"))
d76d2456 1199
ee78dc32 1200(defun mouse-set-font (&rest fonts)
52f9306b
EZ
1201 "Select an Emacs font from a list of known good fonts and fontsets.
1202
de0c7b5d 1203If `w32-use-w32-font-dialog' is non-nil (the default), use the Windows
ff04436d 1204font dialog to display the list of possible fonts. Otherwise use a
52f9306b
EZ
1205pop-up menu (like Emacs does on other platforms) initialized with
1206the fonts in `w32-fixed-font-alist'.
1207If `w32-list-proportional-fonts' is non-nil, add proportional fonts
1208to the list in the font selection dialog (the fonts listed by the
1209pop-up menu are unaffected by `w32-list-proportional-fonts')."
cf14c2b4
GV
1210 (interactive
1211 (if w32-use-w32-font-dialog
78887b5a
JR
1212 (let ((chosen-font (w32-select-font (selected-frame)
1213 w32-list-proportional-fonts)))
efaec94e 1214 (and chosen-font (list chosen-font)))
cf14c2b4
GV
1215 (x-popup-menu
1216 last-nonmenu-event
bd6a8278 1217 ;; Append list of fontsets currently defined.
b05f815e 1218 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
4664455c
GV
1219 (if (fboundp 'new-fontset)
1220 (append w32-fixed-font-alist (list (generate-fontset-menu)))))))
cf14c2b4 1221 (if fonts
f9de6f69 1222 (let (font)
cf14c2b4
GV
1223 (while fonts
1224 (condition-case nil
1225 (progn
e7a8ad1f 1226 (setq font (car fonts))
f9de6f69 1227 (set-default-font font)
e7a8ad1f
GV
1228 (setq fonts nil))
1229 (error (setq fonts (cdr fonts)))))
cf14c2b4
GV
1230 (if (null font)
1231 (error "Font not found")))))
ee78dc32 1232
fe347034
JB
1233;;; Set default known names for image libraries
1234(setq image-library-alist
dc75b163 1235 '((xpm "xpm4.dll" "libXpm-nox4.dll" "libxpm.dll")
fe347034
JB
1236 (png "libpng13d.dll" "libpng13.dll" "libpng12d.dll" "libpng12.dll" "libpng.dll")
1237 (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
1238 (tiff "libtiff3.dll" "libtiff.dll")
253d8b7a 1239 (gif "giflib4.dll" "libungif4.dll" "libungif.dll")))
fe347034 1240
bd6a8278 1241;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
b63f9ba1 1242;;; w32-win.el ends here