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