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