* international/titdic-cnv.el (dos-8+3-filename):
[bpt/emacs.git] / lisp / term / w32-win.el
1 ;;; w32-win.el --- parse switches controlling interface with W32 window system
2
3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
5
6 ;; Author: Kevin Gallo
7 ;; Keywords: terminals
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; w32-win.el: this file is loaded from ../lisp/startup.el when it recognizes
29 ;; that W32 windows are to be used. Command line switches are parsed and those
30 ;; pertaining to W32 are processed and removed from the command line. The
31 ;; W32 display is opened and hooks are set for popping up the initial window.
32
33 ;; startup.el will then examine startup files, and eventually call the hooks
34 ;; which create the first window (s).
35
36 ;;; Code:
37 \f
38
39 ;; These are the standard X switches from the Xt Initialize.c file of
40 ;; Release 4.
41
42 ;; Command line Resource Manager string
43
44 ;; +rv *reverseVideo
45 ;; +synchronous *synchronous
46 ;; -background *background
47 ;; -bd *borderColor
48 ;; -bg *background
49 ;; -bordercolor *borderColor
50 ;; -borderwidth .borderWidth
51 ;; -bw .borderWidth
52 ;; -display .display
53 ;; -fg *foreground
54 ;; -fn *font
55 ;; -font *font
56 ;; -foreground *foreground
57 ;; -geometry .geometry
58 ;; -i .iconType
59 ;; -itype .iconType
60 ;; -iconic .iconic
61 ;; -name .name
62 ;; -reverse *reverseVideo
63 ;; -rv *reverseVideo
64 ;; -selectionTimeout .selectionTimeout
65 ;; -synchronous *synchronous
66 ;; -xrm
67
68 ;; An alist of X options and the function which handles them. See
69 ;; ../startup.el.
70
71 ;; (if (not (eq window-system 'w32))
72 ;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
73
74 (require 'frame)
75 (require 'mouse)
76 (require 'scroll-bar)
77 (require 'faces)
78 (require 'select)
79 (require 'menu-bar)
80 (require 'dnd)
81 (require 'code-pages)
82 (require 'w32-vars)
83
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")
87
88 (defvar xlfd-regexp-registry-subnum)
89 (defvar w32-color-map) ;; defined in w32fns.c
90
91 (declare-function w32-send-sys-command "w32fns.c")
92 (declare-function w32-select-font "w32fns.c")
93 (declare-function set-message-beep "w32console.c")
94
95 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
96 (if (fboundp 'new-fontset)
97 (require 'fontset))
98
99 ;; The following definition is used for debugging scroll bar events.
100 ;(defun w32-handle-scroll-bar-event (event) (interactive "e") (princ event))
101
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))
106
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)))
134
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)))))
141
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)
145
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)
151
152 (defvar x-invocation-args)
153
154 (defvar x-command-line-resources nil)
155
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))))
162
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))))
169
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))))
176
177 (defun x-handle-iconic (switch)
178 "Make \"-iconic\" SWITCH apply only to the initial frame."
179 (push '(visibility . icon) initial-frame-alist))
180
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)))
190
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))))
216
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))
225
226 (defvar x-display-name nil
227 "The display name specifying server and frame.")
228
229 (defun x-handle-display (switch)
230 "Handle the \"-display\" SWITCH."
231 (setq x-display-name (pop x-invocation-args)))
232
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.
260 nil
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))
277 \f
278 ;;
279 ;; Available colors
280 ;;
281
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")
1036
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))
1045 \f
1046 \f
1047 ;;;; Function keys
1048
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.
1053
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.
1057
1058 If FRAME is nil or not given, use the selected frame."
1059 (interactive "i")
1060 (w32-send-sys-command ?\xf100 frame))
1061 \f
1062
1063 ;; W32 systems have different fonts than commonly found on X, so
1064 ;; we define our own standard fontset here.
1065 (defvar w32-standard-fontset-spec
1066 "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-standard"
1067 "String of fontset spec of the standard fontset.
1068 This defines a fontset consisting of the Courier New variations for
1069 European languages which are distributed with Windows as
1070 \"Multilanguage Support\".
1071
1072 See the documentation of `create-fontset-from-fontset-spec' for the format.")
1073
1074 (defun x-win-suspend-error ()
1075 "Report an error when a suspend is attempted."
1076 (error "Suspending an Emacs running under W32 makes no sense"))
1077
1078
1079 (defun mouse-set-font (&rest fonts)
1080 "Select an Emacs font from a list of known good fonts and fontsets.
1081
1082 If `w32-use-w32-font-dialog' is non-nil (the default), use the Windows
1083 font dialog to display the list of possible fonts. Otherwise use a
1084 pop-up menu (like Emacs does on other platforms) initialized with
1085 the fonts in `w32-fixed-font-alist'.
1086 If `w32-list-proportional-fonts' is non-nil, add proportional fonts
1087 to the list in the font selection dialog (the fonts listed by the
1088 pop-up menu are unaffected by `w32-list-proportional-fonts')."
1089 (interactive
1090 (if w32-use-w32-font-dialog
1091 (let ((chosen-font (w32-select-font (selected-frame)
1092 w32-list-proportional-fonts)))
1093 (and chosen-font (list chosen-font)))
1094 (x-popup-menu
1095 last-nonmenu-event
1096 ;; Append list of fontsets currently defined.
1097 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
1098 (if (fboundp 'new-fontset)
1099 (append w32-fixed-font-alist (list (generate-fontset-menu)))))))
1100 (if fonts
1101 (let (font)
1102 (while fonts
1103 (condition-case nil
1104 (progn
1105 (setq font (car fonts))
1106 (set-default-font font)
1107 (setq fonts nil))
1108 (error (setq fonts (cdr fonts)))))
1109 (if (null font)
1110 (error "Font not found")))))
1111
1112 ;;; Set default known names for image libraries
1113 (setq image-library-alist
1114 '((xpm "xpm4.dll" "libXpm-nox4.dll" "libxpm.dll")
1115 (png "libpng13d.dll" "libpng13.dll" "libpng12d.dll" "libpng12.dll" "libpng.dll")
1116 (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
1117 (tiff "libtiff3.dll" "libtiff.dll")
1118 (gif "giflib4.dll" "libungif4.dll" "libungif.dll")
1119 (svg "librsvg-2-2.dll")
1120 (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
1121 (glib "libglib-2.0-0.dll")))
1122
1123 ;;; multi-tty support
1124 (defvar w32-initialized nil
1125 "Non-nil if the w32 window system has been initialized.")
1126
1127 (defun w32-initialize-window-system ()
1128 "Initialize Emacs for W32 GUI frames."
1129
1130 ;; Do the actual Windows setup here; the above code just defines
1131 ;; functions and variables that we use now.
1132
1133 (setq command-line-args (x-handle-args command-line-args))
1134
1135 ;; Make sure we have a valid resource name.
1136 (or (stringp x-resource-name)
1137 (setq x-resource-name
1138 ;; Change any . or * characters in x-resource-name to hyphens,
1139 ;; so as not to choke when we use it in X resource queries.
1140 (replace-regexp-in-string "[.*]" "-" (invocation-name))))
1141
1142 (x-open-connection "" x-command-line-resources
1143 ;; Exit with a fatal error if this fails and we
1144 ;; are the initial display
1145 (eq initial-window-system 'w32))
1146
1147 ;; Setup the default fontset.
1148 (setup-default-fontset)
1149
1150 ;; Enable Japanese fonts on Windows to be used by default.
1151 (set-fontset-font nil (make-char 'katakana-jisx0201)
1152 '("*" . "JISX0208-SJIS"))
1153 (set-fontset-font nil (make-char 'latin-jisx0201)
1154 '("*" . "JISX0208-SJIS"))
1155 (set-fontset-font nil (make-char 'japanese-jisx0208)
1156 '("*" . "JISX0208-SJIS"))
1157 (set-fontset-font nil (make-char 'japanese-jisx0208-1978)
1158 '("*" . "JISX0208-SJIS"))
1159
1160 ;; Create the standard fontset.
1161 (create-fontset-from-fontset-spec w32-standard-fontset-spec t)
1162 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1,...).
1163 (create-fontset-from-x-resource)
1164 ;; Try to create a fontset from a font specification which comes
1165 ;; from initial-frame-alist, default-frame-alist, or X resource.
1166 ;; A font specification in command line argument (i.e. -fn XXXX)
1167 ;; should be already in default-frame-alist as a `font'
1168 ;; parameter. However, any font specifications in site-start
1169 ;; library, user's init file (.emacs), and default.el are not
1170 ;; yet handled here.
1171
1172 (let ((font (or (cdr (assq 'font initial-frame-alist))
1173 (cdr (assq 'font default-frame-alist))
1174 (x-get-resource "font" "Font")))
1175 xlfd-fields resolved-name)
1176 (if (and font
1177 (not (query-fontset font))
1178 (setq resolved-name (x-resolve-font-name font))
1179 (setq xlfd-fields (x-decompose-font-name font)))
1180 (if (string= "fontset"
1181 (aref xlfd-fields xlfd-regexp-registry-subnum))
1182 (new-fontset font
1183 (x-complement-fontset-spec xlfd-fields nil))
1184 ;; Create a fontset from FONT. The fontset name is
1185 ;; generated from FONT.
1186 (create-fontset-from-ascii-font font
1187 resolved-name "startup"))))
1188
1189 ;; Apply a geometry resource to the initial frame. Put it at the end
1190 ;; of the alist, so that anything specified on the command line takes
1191 ;; precedence.
1192 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1193 parsed)
1194 (if res-geometry
1195 (progn
1196 (setq parsed (x-parse-geometry res-geometry))
1197 ;; If the resource specifies a position,
1198 ;; call the position and size "user-specified".
1199 (if (or (assq 'top parsed) (assq 'left parsed))
1200 (setq parsed (cons '(user-position . t)
1201 (cons '(user-size . t) parsed))))
1202 ;; All geometry parms apply to the initial frame.
1203 (setq initial-frame-alist (append initial-frame-alist parsed))
1204 ;; The size parms apply to all frames.
1205 (if (assq 'height parsed)
1206 (push (cons 'height (cdr (assq 'height parsed)))
1207 default-frame-alist))
1208 (if (assq 'width parsed)
1209 (push (cons 'width (cdr (assq 'width parsed)))
1210 default-frame-alist)))))
1211
1212 ;; Check the reverseVideo resource.
1213 (let ((case-fold-search t))
1214 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
1215 (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv))
1216 (push '(reverse . t) default-frame-alist))))
1217
1218 ;; Don't let Emacs suspend under w32 gui
1219 (add-hook 'suspend-hook 'x-win-suspend-error)
1220
1221 ;; Turn off window-splitting optimization; w32 is usually fast enough
1222 ;; that this is only annoying.
1223 (setq split-window-keep-point t)
1224
1225 ;; Turn on support for mouse wheels
1226 (mouse-wheel-mode 1)
1227
1228 ;; W32 expects the menu bar cut and paste commands to use the clipboard.
1229 (menu-bar-enable-clipboard)
1230
1231 ;; Don't show the frame name; that's redundant.
1232 (setq-default mode-line-frame-identification " ")
1233
1234 ;; Set to a system sound if you want a fancy bell.
1235 (set-message-beep 'ok)
1236 (setq w32-initialized t))
1237
1238 (add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
1239 (add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces))
1240 (add-to-list 'window-system-initialization-alist '(w32 . w32-initialize-window-system))
1241
1242 (provide 'w32-win)
1243
1244 ;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
1245 ;;; w32-win.el ends here