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