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