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