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