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