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