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