(image-library-alist): New variable to map image types to external
[bpt/emacs.git] / lisp / term / w32-win.el
CommitLineData
6a05d05f 1;;; w32-win.el --- parse switches controlling interface with W32 window system
2fe590dc 2
25d887f0 3;; Copyright (C) 1993, 1994, 2003 Free Software Foundation, Inc.
ee78dc32
GV
4
5;; Author: Kevin Gallo
6;; Keywords: terminals
7
2fe590dc
EN
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.
ee78dc32
GV
24
25;;; Commentary:
26
b63f9ba1
GV
27;; w32-win.el: this file is loaded from ../lisp/startup.el when it recognizes
28;; that W32 windows are to be used. Command line switches are parsed and those
29;; pertaining to W32 are processed and removed from the command line. The
30;; W32 display is opened and hooks are set for popping up the initial window.
ee78dc32
GV
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
38;; These are the standard X switches from the Xt Initialize.c file of
39;; Release 4.
40
41;; Command line Resource Manager string
42
43;; +rv *reverseVideo
44;; +synchronous *synchronous
45;; -background *background
46;; -bd *borderColor
47;; -bg *background
48;; -bordercolor *borderColor
49;; -borderwidth .borderWidth
50;; -bw .borderWidth
51;; -display .display
52;; -fg *foreground
53;; -fn *font
54;; -font *font
55;; -foreground *foreground
56;; -geometry .geometry
57;; -i .iconType
58;; -itype .iconType
59;; -iconic .iconic
60;; -name .name
61;; -reverse *reverseVideo
62;; -rv *reverseVideo
63;; -selectionTimeout .selectionTimeout
64;; -synchronous *synchronous
65;; -xrm
66
67;; An alist of X options and the function which handles them. See
68;; ../startup.el.
69
b63f9ba1
GV
70(if (not (eq window-system 'w32))
71 (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
db95369b 72
ee78dc32
GV
73(require 'frame)
74(require 'mouse)
75(require 'scroll-bar)
76(require 'faces)
77(require 'select)
78(require 'menu-bar)
1e8b532f 79(require 'x-dnd)
b0efcd2e
JR
80(require 'code-pages)
81
b05f815e 82;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
64f41d64
JR
83(if (fboundp 'new-fontset)
84 (require 'fontset))
ee78dc32 85
15f18b89 86;; The following definition is used for debugging scroll bar events.
fbd6baed 87;(defun w32-handle-scroll-bar-event (event) (interactive "e") (princ event))
af99aa46 88
e596f2a2 89;; Handle mouse-wheel events with mwheel.
230c8ad7 90(mouse-wheel-mode 1)
d66be571 91
de0c7b5d
JR
92(defun w32-drag-n-drop-debug (event)
93 "Print the drag-n-drop EVENT in a readable form."
94 (interactive "e")
33b307f8
RS
95 (princ event))
96
97(defun w32-drag-n-drop (event)
de0c7b5d 98 "Edit the files listed in the drag-n-drop EVENT.
33b307f8
RS
99Switch to a buffer editing the last file dropped."
100 (interactive "e")
c8316112 101 (save-excursion
35a8911d
GM
102 ;; Make sure the drop target has positive co-ords
103 ;; before setting the selected frame - otherwise it
104 ;; won't work. <skx@tardis.ed.ac.uk>
105 (let* ((window (posn-window (event-start event)))
106 (coords (posn-x-y (event-start event)))
107 (x (car coords))
108 (y (cdr coords)))
109 (if (and (> x 0) (> y 0))
110 (set-frame-selected-window nil window))
1e8b532f
JR
111 (mapcar (lambda (file-name)
112 (x-dnd-handle-one-url window 'private
113 (concat "file:" file-name)))
114 (car (cdr (cdr event)))))
35a8911d 115 (raise-frame)))
33b307f8
RS
116
117(defun w32-drag-n-drop-other-frame (event)
de0c7b5d 118 "Edit the files listed in the drag-n-drop EVENT, in other frames.
33b307f8
RS
119May create new frames, or reuse existing ones. The frame editing
120the last file dropped is selected."
121 (interactive "e")
122 (mapcar 'find-file-other-frame (car (cdr (cdr event)))))
123
124;; Bind the drag-n-drop event.
125(global-set-key [drag-n-drop] 'w32-drag-n-drop)
126(global-set-key [C-drag-n-drop] 'w32-drag-n-drop-other-frame)
127
a73c80a3
GV
128;; Keyboard layout/language change events
129;; For now ignore language-change events; in the future
130;; we should switch the Emacs Input Method to match the
131;; new layout/language selected by the user.
132(global-set-key [language-change] 'ignore)
133
ee78dc32
GV
134(defvar x-invocation-args)
135
136(defvar x-command-line-resources nil)
137
ee78dc32 138(defun x-handle-switch (switch)
de0c7b5d 139 "Handle SWITCH of the form \"-switch value\" or \"-switch\"."
3d27abc4 140 (let ((aelt (assoc switch command-line-x-option-alist)))
ee78dc32 141 (if aelt
3d27abc4
JR
142 (let ((param (nth 3 aelt))
143 (value (nth 4 aelt)))
144 (if value
145 (setq default-frame-alist
146 (cons (cons param value)
147 default-frame-alist))
ee78dc32 148 (setq default-frame-alist
3d27abc4
JR
149 (cons (cons param
150 (car x-invocation-args))
1823c9d2
JB
151 default-frame-alist)
152 x-invocation-args (cdr x-invocation-args)))))))
de0c7b5d 153
ee78dc32 154(defun x-handle-numeric-switch (switch)
de0c7b5d 155 "Handle SWITCH of the form \"-switch n\"."
3d27abc4 156 (let ((aelt (assoc switch command-line-x-option-alist)))
ee78dc32 157 (if aelt
3d27abc4 158 (let ((param (nth 3 aelt)))
ee78dc32 159 (setq default-frame-alist
3d27abc4 160 (cons (cons param
ee78dc32
GV
161 (string-to-int (car x-invocation-args)))
162 default-frame-alist)
163 x-invocation-args
3d27abc4
JR
164 (cdr x-invocation-args))))))
165
166;; Handle options that apply to initial frame only
167(defun x-handle-initial-switch (switch)
168 (let ((aelt (assoc switch command-line-x-option-alist)))
169 (if aelt
170 (let ((param (nth 3 aelt))
171 (value (nth 4 aelt)))
172 (if value
173 (setq initial-frame-alist
174 (cons (cons param value)
175 initial-frame-alist))
176 (setq initial-frame-alist
177 (cons (cons param
178 (car x-invocation-args))
179 initial-frame-alist)
180 x-invocation-args (cdr x-invocation-args)))))))
181
182(defun x-handle-iconic (switch)
183 "Make \"-iconic\" SWITCH apply only to the initial frame."
184 (setq initial-frame-alist
185 (cons '(visibility . icon) initial-frame-alist)))
ee78dc32 186
ee78dc32 187(defun x-handle-xrm-switch (switch)
de0c7b5d 188 "Handle the \"-xrm\" SWITCH."
ee78dc32
GV
189 (or (consp x-invocation-args)
190 (error "%s: missing argument to `%s' option" (invocation-name) switch))
3d27abc4
JR
191 (setq x-command-line-resources
192 (if (null x-command-line-resources)
193 (car x-invocation-args)
194 (concat x-command-line-resources "\n" (car x-invocation-args))))
ee78dc32
GV
195 (setq x-invocation-args (cdr x-invocation-args)))
196
ee78dc32 197(defun x-handle-geometry (switch)
de0c7b5d 198 "Handle the \"-geometry\" SWITCH."
ea8d3061
RS
199 (let* ((geo (x-parse-geometry (car x-invocation-args)))
200 (left (assq 'left geo))
201 (top (assq 'top geo))
202 (height (assq 'height geo))
203 (width (assq 'width geo)))
204 (if (or height width)
205 (setq default-frame-alist
206 (append default-frame-alist
0ebcabe7
JB
207 '((user-size . t))
208 (if height (list height))
209 (if width (list width)))
210 initial-frame-alist
211 (append initial-frame-alist
ea8d3061
RS
212 '((user-size . t))
213 (if height (list height))
214 (if width (list width)))))
215 (if (or left top)
216 (setq initial-frame-alist
217 (append initial-frame-alist
218 '((user-position . t))
219 (if left (list left))
220 (if top (list top)))))
221 (setq x-invocation-args (cdr x-invocation-args))))
ee78dc32 222
3d27abc4
JR
223(defun x-handle-name-switch (switch)
224 "Handle a \"-name\" SWITCH."
225;; Handle the -name option. Set the variable x-resource-name
226;; to the option's operand; set the name of the initial frame, too.
ee78dc32
GV
227 (or (consp x-invocation-args)
228 (error "%s: missing argument to `%s' option" (invocation-name) switch))
229 (setq x-resource-name (car x-invocation-args)
230 x-invocation-args (cdr x-invocation-args))
3d27abc4
JR
231 (setq initial-frame-alist (cons (cons 'name x-resource-name)
232 initial-frame-alist)))
ee78dc32
GV
233
234(defvar x-display-name nil
235 "The display name specifying server and frame.")
236
237(defun x-handle-display (switch)
de0c7b5d 238 "Handle the \"-display\" SWITCH."
ee78dc32
GV
239 (setq x-display-name (car x-invocation-args)
240 x-invocation-args (cdr x-invocation-args)))
241
ee78dc32
GV
242(defun x-handle-args (args)
243 "Process the X-related command line options in ARGS.
244This is done before the user's startup file is loaded. They are copied to
3d27abc4 245`x-invocation args' from which the X-related things are extracted, first
ee78dc32
GV
246the switch (e.g., \"-fg\") in the following code, and possible values
247\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
248This returns ARGS with the arguments that have been processed removed."
3d27abc4 249 ;; We use ARGS to accumulate the args that we don't handle here, to return.
ee78dc32
GV
250 (setq x-invocation-args args
251 args nil)
3d27abc4
JR
252 (while (and x-invocation-args
253 (not (equal (car x-invocation-args) "--")))
ee78dc32
GV
254 (let* ((this-switch (car x-invocation-args))
255 (orig-this-switch this-switch)
3d27abc4 256 completion argval aelt handler)
ee78dc32
GV
257 (setq x-invocation-args (cdr x-invocation-args))
258 ;; Check for long options with attached arguments
259 ;; and separate out the attached option argument into argval.
260 (if (string-match "^--[^=]*=" this-switch)
261 (setq argval (substring this-switch (match-end 0))
262 this-switch (substring this-switch 0 (1- (match-end 0)))))
3d27abc4
JR
263 ;; Complete names of long options.
264 (if (string-match "^--" this-switch)
265 (progn
266 (setq completion (try-completion this-switch command-line-x-option-alist))
267 (if (eq completion t)
268 ;; Exact match for long option.
269 nil
270 (if (stringp completion)
271 (let ((elt (assoc completion command-line-x-option-alist)))
272 ;; Check for abbreviated long option.
273 (or elt
274 (error "Option `%s' is ambiguous" this-switch))
275 (setq this-switch completion))))))
276 (setq aelt (assoc this-switch command-line-x-option-alist))
277 (if aelt (setq handler (nth 2 aelt)))
278 (if handler
ee78dc32
GV
279 (if argval
280 (let ((x-invocation-args
281 (cons argval x-invocation-args)))
3d27abc4
JR
282 (funcall handler this-switch))
283 (funcall handler this-switch))
284 (setq args (cons orig-this-switch args)))))
285 (nconc (nreverse args) x-invocation-args))
ee78dc32
GV
286\f
287;;
288;; Available colors
289;;
290
027a15c1
EZ
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"
ee78dc32 855 "coral"
027a15c1
EZ
856 "DarkOrange"
857 "dark orange"
858 "orange"
859 "LightSalmon"
860 "light salmon"
861 "salmon"
862 "DarkSalmon"
863 "dark salmon"
ee78dc32 864 "brown"
027a15c1
EZ
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"
ee78dc32 883 "goldenrod"
027a15c1
EZ
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"
ee78dc32 899 "ForestGreen"
027a15c1
EZ
900 "forest green"
901 "YellowGreen"
902 "yellow green"
ee78dc32 903 "LimeGreen"
027a15c1
EZ
904 "lime green"
905 "GreenYellow"
906 "green yellow"
ee78dc32 907 "MediumSpringGreen"
027a15c1
EZ
908 "medium spring green"
909 "chartreuse"
910 "green"
911 "LawnGreen"
912 "lawn green"
913 "SpringGreen"
914 "spring green"
ee78dc32 915 "PaleGreen"
027a15c1
EZ
916 "pale green"
917 "LightSeaGreen"
918 "light sea green"
919 "MediumSeaGreen"
920 "medium sea green"
ee78dc32 921 "SeaGreen"
027a15c1
EZ
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"
ee78dc32 937 "turquoise"
ee78dc32 938 "MediumTurquoise"
027a15c1
EZ
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"
ee78dc32 1003 "white"
027a15c1
EZ
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.
1044XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
ee78dc32 1045
f795f633
EZ
1046(defun xw-defined-colors (&optional frame)
1047 "Internal function called by `defined-colors', which see."
ee78dc32 1048 (or frame (setq frame (selected-frame)))
e5e0a3c9
GV
1049 (let* ((color-map-colors (mapcar (lambda (clr) (car clr)) w32-color-map))
1050 (all-colors (or color-map-colors x-colors))
1051 (this-color nil)
1052 (defined-colors nil))
1053 (message "Defining colors...")
ee78dc32
GV
1054 (while all-colors
1055 (setq this-color (car all-colors)
1056 all-colors (cdr all-colors))
79b24da3 1057 (and (color-supported-p this-color frame t)
ee78dc32
GV
1058 (setq defined-colors (cons this-color defined-colors))))
1059 defined-colors))
1060\f
d66be571 1061\f
ee78dc32
GV
1062;;;; Function keys
1063
d66be571
GV
1064;;; make f10 activate the real menubar rather than the mini-buffer menu
1065;;; navigation feature.
1066(global-set-key [f10] (lambda ()
1067 (interactive) (w32-send-sys-command ?\xf100)))
1068
ee78dc32
GV
1069(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1070 global-map)
1071
ee78dc32 1072\f
ee78dc32
GV
1073;;; Do the actual Windows setup here; the above code just defines
1074;;; functions and variables that we use now.
1075
1076(setq command-line-args (x-handle-args command-line-args))
1077
1078;;; Make sure we have a valid resource name.
1079(or (stringp x-resource-name)
1080 (let (i)
1081 (setq x-resource-name (invocation-name))
1082
1083 ;; Change any . or * characters in x-resource-name to hyphens,
1084 ;; so as not to choke when we use it in X resource queries.
1085 (while (setq i (string-match "[.*]" x-resource-name))
1086 (aset x-resource-name i ?-))))
1087
1088;; For the benefit of older Emacses (19.27 and earlier) that are sharing
1089;; the same lisp directory, don't pass the third argument unless we seem
1090;; to have the multi-display support.
1091(if (fboundp 'x-close-connection)
1092 (x-open-connection ""
1093 x-command-line-resources
1094 ;; Exit Emacs with fatal error if this fails.
1095 t)
1096 (x-open-connection ""
1097 x-command-line-resources))
1098
1099(setq frame-creation-function 'x-create-frame-with-faces)
1100
1101(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
1102 x-cut-buffer-max))
1103
fbd6baed 1104;; W32 expects the menu bar cut and paste commands to use the clipboard.
ee78dc32
GV
1105;; This has ,? to match both on Sunos and on Solaris.
1106(menu-bar-enable-clipboard)
1107
4664455c
GV
1108;; W32 systems have different fonts than commonly found on X, so
1109;; we define our own standard fontset here.
1110(defvar w32-standard-fontset-spec
e7a8ad1f 1111 "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-standard"
de0c7b5d
JR
1112 "String of fontset spec of the standard fontset.
1113This defines a fontset consisting of the Courier New variations for
1114European languages which are distributed with Windows as
1115\"Multilanguage Support\".
4664455c
GV
1116
1117See the documentation of `create-fontset-from-fontset-spec for the format.")
1118
b05f815e 1119;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
de0c7b5d
JR
1120(if (fboundp 'new-fontset)
1121 (progn
7f75eaa8
KH
1122 ;; Setup the default fontset.
1123 (setup-default-fontset)
de0c7b5d
JR
1124 ;; Create the standard fontset.
1125 (create-fontset-from-fontset-spec w32-standard-fontset-spec t)
1126 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1,...).
1127 (create-fontset-from-x-resource)
1128 ;; Try to create a fontset from a font specification which comes
1129 ;; from initial-frame-alist, default-frame-alist, or X resource.
1130 ;; A font specification in command line argument (i.e. -fn XXXX)
1131 ;; should be already in default-frame-alist as a `font'
1132 ;; parameter. However, any font specifications in site-start
1133 ;; library, user's init file (.emacs), and default.el are not
1134 ;; yet handled here.
1135
1136 (let ((font (or (cdr (assq 'font initial-frame-alist))
1137 (cdr (assq 'font default-frame-alist))
1138 (x-get-resource "font" "Font")))
1139 xlfd-fields resolved-name)
1140 (if (and font
1141 (not (query-fontset font))
1142 (setq resolved-name (x-resolve-font-name font))
1143 (setq xlfd-fields (x-decompose-font-name font)))
1144 (if (string= "fontset"
1145 (aref xlfd-fields xlfd-regexp-registry-subnum))
1146 (new-fontset font
1147 (x-complement-fontset-spec xlfd-fields nil))
1148 ;; Create a fontset from FONT. The fontset name is
1149 ;; generated from FONT.
1150 (create-fontset-from-ascii-font font
1151 resolved-name "startup"))))))
4664455c 1152
ee78dc32
GV
1153;; Apply a geometry resource to the initial frame. Put it at the end
1154;; of the alist, so that anything specified on the command line takes
1155;; precedence.
1156(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1157 parsed)
1158 (if res-geometry
1159 (progn
1160 (setq parsed (x-parse-geometry res-geometry))
1161 ;; If the resource specifies a position,
1162 ;; call the position and size "user-specified".
1163 (if (or (assq 'top parsed) (assq 'left parsed))
1164 (setq parsed (cons '(user-position . t)
1165 (cons '(user-size . t) parsed))))
1166 ;; All geometry parms apply to the initial frame.
1167 (setq initial-frame-alist (append initial-frame-alist parsed))
1168 ;; The size parms apply to all frames.
1169 (if (assq 'height parsed)
1170 (setq default-frame-alist
1171 (cons (cons 'height (cdr (assq 'height parsed)))
1172 default-frame-alist)))
1173 (if (assq 'width parsed)
1174 (setq default-frame-alist
1175 (cons (cons 'width (cdr (assq 'width parsed)))
1176 default-frame-alist))))))
1177
1178;; Check the reverseVideo resource.
1179(let ((case-fold-search t))
1180 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
1181 (if (and rv
1182 (string-match "^\\(true\\|yes\\|on\\)$" rv))
1183 (setq default-frame-alist
1184 (cons '(reverse . t) default-frame-alist)))))
1185
ee78dc32 1186(defun x-win-suspend-error ()
de0c7b5d
JR
1187 "Report an error when a suspend is attempted."
1188 (error "Suspending an Emacs running under W32 makes no sense"))
ee78dc32
GV
1189(add-hook 'suspend-hook 'x-win-suspend-error)
1190
fbd6baed 1191;;; Turn off window-splitting optimization; w32 is usually fast enough
ee78dc32
GV
1192;;; that this is only annoying.
1193(setq split-window-keep-point t)
1194
1195;; Don't show the frame name; that's redundant.
f182c531 1196(setq-default mode-line-frame-identification " ")
ee78dc32
GV
1197
1198;;; Set to a system sound if you want a fancy bell.
1199(set-message-beep 'ok)
1200
fbd6baed 1201;; Remap some functions to call w32 common dialogs
ee78dc32
GV
1202
1203(defun internal-face-interactive (what &optional bool)
1204 (let* ((fn (intern (concat "face-" what)))
3247de96
DL
1205 (prompt (concat "Set " what " of face "))
1206 (face (read-face-name prompt))
ee78dc32
GV
1207 (default (if (fboundp fn)
1208 (or (funcall fn face (selected-frame))
1209 (funcall fn 'default (selected-frame)))))
1210 (fn-win (intern (concat (symbol-name window-system) "-select-" what)))
3ce36200
AI
1211 value)
1212 (setq value
1213 (cond ((fboundp fn-win)
1214 (funcall fn-win))
1215 ((eq bool 'color)
1216 (completing-read (concat prompt " " (symbol-name face) " to: ")
1217 (mapcar (function (lambda (color)
1218 (cons color color)))
1219 x-colors)
1220 nil nil nil nil default))
1221 (bool
1222 (y-or-n-p (concat "Should face " (symbol-name face)
1223 " be " bool "? ")))
1224 (t
1225 (read-string (concat prompt " " (symbol-name face) " to: ")
1226 nil nil default))))
1227 (list face (if (equal value "") nil value))))
ee78dc32 1228
d76d2456 1229;;; Enable Japanese fonts on Windows to be used by default.
41cba4d0
KH
1230(set-fontset-font nil (make-char 'katakana-jisx0201) '("*" . "JISX0208-SJIS"))
1231(set-fontset-font nil (make-char 'latin-jisx0201) '("*" . "JISX0208-SJIS"))
1232(set-fontset-font nil (make-char 'japanese-jisx0208) '("*" . "JISX0208-SJIS"))
1233(set-fontset-font nil (make-char 'japanese-jisx0208-1978) '("*" . "JISX0208-SJIS"))
d76d2456 1234
ee78dc32 1235(defun mouse-set-font (&rest fonts)
de0c7b5d
JR
1236 "Select a font.
1237If `w32-use-w32-font-dialog' is non-nil (the default), use the Windows
1238font dialog to get the matching FONTS. Otherwise use a pop-up menu
2991b258 1239\(like Emacs on other platforms) initialized with the fonts in
f9de6f69 1240`w32-fixed-font-alist'."
cf14c2b4
GV
1241 (interactive
1242 (if w32-use-w32-font-dialog
78887b5a
JR
1243 (let ((chosen-font (w32-select-font (selected-frame)
1244 w32-list-proportional-fonts)))
efaec94e 1245 (and chosen-font (list chosen-font)))
cf14c2b4
GV
1246 (x-popup-menu
1247 last-nonmenu-event
1248 ;; Append list of fontsets currently defined.
b05f815e 1249 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
4664455c
GV
1250 (if (fboundp 'new-fontset)
1251 (append w32-fixed-font-alist (list (generate-fontset-menu)))))))
cf14c2b4 1252 (if fonts
f9de6f69 1253 (let (font)
cf14c2b4
GV
1254 (while fonts
1255 (condition-case nil
1256 (progn
e7a8ad1f 1257 (setq font (car fonts))
f9de6f69 1258 (set-default-font font)
e7a8ad1f
GV
1259 (setq fonts nil))
1260 (error (setq fonts (cdr fonts)))))
cf14c2b4
GV
1261 (if (null font)
1262 (error "Font not found")))))
ee78dc32 1263
ab5796a9 1264;;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
b63f9ba1 1265;;; w32-win.el ends here