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