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