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