Commit | Line | Data |
---|---|---|
092af6d8 | 1 | ;;; pc-win.el --- setup support for `PC windows' (whatever that is). |
ef88bd2d | 2 | |
e2f35ede | 3 | ;; Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. |
ef88bd2d MW |
4 | |
5 | ;; Author: Morten Welinder <terra@diku.dk> | |
9596811a | 6 | ;; Maintainer: FSF |
ef88bd2d MW |
7 | |
8 | ;; This file is part of GNU Emacs. | |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
2fe590dc EN |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
24 | ||
25 | ;;; Code: | |
26 | ||
ef88bd2d MW |
27 | (load "term/internal" nil t) |
28 | ||
ec46c6e8 RS |
29 | ;; Color translation -- doesn't really need to be fast. |
30 | ;; Colors listed here do not include the "light-", | |
31 | ;; "medium-" and "dark-" prefixes that are accounted for | |
32 | ;; by `msdos-color-translate', which see below). | |
ef88bd2d MW |
33 | |
34 | (defvar msdos-color-aliases | |
ec46c6e8 RS |
35 | '(("snow" . "white") |
36 | ("ghost white" . "white") | |
37 | ("ghostwhite" . "white") | |
38 | ("white smoke" . "white") | |
39 | ("whitesmoke" . "white") | |
40 | ("gainsboro" . "white") | |
41 | ("floral white" . "white") | |
42 | ("floralwhite" . "white") | |
43 | ("old lace" . "white") | |
44 | ("oldlace" . "white") | |
45 | ("linen" . "white") | |
46 | ("antique white" . "white") | |
47 | ("antiquewhite" . "white") | |
48 | ("papaya whip" . "white") | |
49 | ("papayawhip" . "white") | |
50 | ("blanched almond" . "white") | |
51 | ("blanchedalmond" . "white") | |
52 | ("bisque" . "white") | |
53 | ("peach puff" . "lightred") | |
54 | ("peachpuff" . "lightred") | |
55 | ("navajo white" . "lightred") | |
56 | ("navajowhite" . "lightred") | |
57 | ("moccasin" . "lightred") | |
58 | ("cornsilk" . "white") | |
59 | ("ivory" . "white") | |
60 | ("lemon chiffon" . "yellow") | |
61 | ("lemonchiffon" . "yellow") | |
62 | ("seashell" . "white") | |
63 | ("honeydew" . "white") | |
64 | ("mint cream" . "white") | |
65 | ("mintcream" . "white") | |
66 | ("azure" . "lightcyan") | |
67 | ("alice blue" . "lightcyan") | |
68 | ("aliceblue" . "lightcyan") | |
69 | ("lavender" . "lightcyan") | |
70 | ("lavender blush" . "lightcyan") | |
71 | ("lavenderblush" . "lightcyan") | |
72 | ("misty rose" . "lightred") | |
73 | ("mistyrose" . "lightred") | |
74 | ("aquamarine" . "blue") | |
75 | ("cadet blue" . "blue") | |
76 | ("cadetblue" . "blue") | |
77 | ("cornflower blue" . "lightblue") | |
78 | ("cornflowerblue" . "lightblue") | |
79 | ("midnight blue" . "blue") | |
80 | ("midnightblue" . "blue") | |
81 | ("navy blue" . "cyan") | |
82 | ("navyblue" . "cyan") | |
83 | ("navy" . "cyan") | |
84 | ("sky blue" . "lightblue") | |
85 | ("skyblue" . "lightblue") | |
86 | ("dodger blue" . "blue") | |
87 | ("dodgerblue" . "blue") | |
88 | ("powder blue" . "lightblue") | |
89 | ("powderblue" . "lightblue") | |
90 | ("slate blue" . "cyan") | |
91 | ("slateblue" . "cyan") | |
92 | ("steel blue" . "blue") | |
93 | ("steelblue" . "blue") | |
94 | ("coral" . "lightred") | |
95 | ("firebrick" . "red") | |
96 | ("gold" . "yellow") | |
97 | ("goldenrod" . "yellow") | |
98 | ("pale goldenrod" . "yellow") | |
99 | ("palegoldenrod" . "yellow") | |
100 | ("olive green" . "lightgreen") | |
101 | ("olivegreen" . "lightgreen") | |
102 | ("olive drab" . "green") | |
103 | ("olivedrab" . "green") | |
104 | ("forest green" . "green") | |
105 | ("forestgreen" . "green") | |
106 | ("lime green" . "lightgreen") | |
107 | ("limegreen" . "lightgreen") | |
108 | ("sea green" . "lightcyan") | |
109 | ("seagreen" . "lightcyan") | |
110 | ("spring green" . "green") | |
111 | ("springgreen" . "green") | |
112 | ("pale green" . "lightgreen") | |
113 | ("palegreen" . "lightgreen") | |
114 | ("lawn green" . "lightgreen") | |
115 | ("lawngreen" . "lightgreen") | |
116 | ("chartreuse" . "yellow") | |
117 | ("yellow green" . "lightgreen") | |
118 | ("yellowgreen" . "lightgreen") | |
119 | ("green yellow" . "lightgreen") | |
120 | ("greenyellow" . "lightgreen") | |
121 | ("slate grey" . "lightgray") | |
122 | ("slategrey" . "lightgray") | |
123 | ("slate gray" . "lightgray") | |
124 | ("slategray" . "lightgray") | |
125 | ("dim grey" . "darkgray") | |
126 | ("dimgrey" . "darkgray") | |
127 | ("dim gray" . "darkgray") | |
128 | ("dimgray" . "darkgray") | |
129 | ("light grey" . "lightgray") | |
130 | ("lightgrey" . "lightgray") | |
131 | ("light gray" . "lightgray") | |
132 | ("gray" . "darkgray") | |
133 | ("grey" . "darkgray") | |
134 | ("gray80" . "darkgray") | |
135 | ("gray50" . "black") | |
136 | ("gray90" . "darkgray") | |
137 | ("khaki" . "green") | |
138 | ("maroon" . "red") | |
139 | ("orange" . "brown") | |
140 | ("orchid" . "brown") | |
141 | ("saddle brown" . "red") | |
142 | ("saddlebrown" . "red") | |
143 | ("sienna" . "red") | |
144 | ("peru" . "red") | |
145 | ("pink" . "lightred") | |
146 | ("plum" . "magenta") | |
147 | ("indian red" . "red") | |
148 | ("indianred" . "red") | |
149 | ("violet red" . "magenta") | |
150 | ("violetred" . "magenta") | |
151 | ("orange red" . "red") | |
152 | ("orangered" . "red") | |
153 | ("salmon" . "lightred") | |
154 | ("sienna" . "lightred") | |
155 | ("tan" . "lightred") | |
156 | ("thistle" . "magenta") | |
157 | ("turquoise" . "lightgreen") | |
158 | ("pale turquoise" . "cyan") | |
159 | ("paleturquoise" . "cyan") | |
160 | ("violet" . "magenta") | |
161 | ("blue violet" . "lightmagenta") | |
162 | ("blueviolet" . "lightmagenta") | |
163 | ("wheat" . "white") | |
164 | ("green yellow" . "yellow") | |
165 | ("greenyellow" . "yellow") | |
166 | ("purple" . "magenta") | |
167 | ("royalblue" . "blue") | |
168 | ("grey40" . "darkgray") | |
169 | ("rosybrown" . "brown") | |
170 | ("rosy brown" . "brown") | |
171 | ("beige" . "brown")) | |
ef88bd2d MW |
172 | "List of alternate names for colors.") |
173 | ||
174 | (defun msdos-color-translate (name) | |
175 | (setq name (downcase name)) | |
176 | (let* ((len (length name)) | |
bb3a4574 RS |
177 | (val (- (length x-colors) |
178 | (length (member name x-colors)))) | |
ef88bd2d | 179 | (try)) |
bb3a4574 | 180 | (if (or (< val 0) (>= val (length x-colors))) (setq val nil)) |
ef88bd2d MW |
181 | (or val |
182 | (and (setq try (cdr (assoc name msdos-color-aliases))) | |
183 | (msdos-color-translate try)) | |
184 | (and (> len 5) | |
ec46c6e8 | 185 | (string= "light" (substring name 0 5)) |
ef88bd2d MW |
186 | (setq try (msdos-color-translate (substring name 5))) |
187 | (logior try 8)) | |
188 | (and (> len 6) | |
ec46c6e8 | 189 | (string= "light " (substring name 0 6)) |
ef88bd2d MW |
190 | (setq try (msdos-color-translate (substring name 6))) |
191 | (logior try 8)) | |
ec46c6e8 RS |
192 | (and (> len 6) |
193 | (string= "medium" (substring name 0 6)) | |
194 | (msdos-color-translate (substring name 6))) | |
195 | (and (> len 7) | |
196 | (string= "medium " (substring name 0 7)) | |
197 | (msdos-color-translate (substring name 7))) | |
ef88bd2d | 198 | (and (> len 4) |
ec46c6e8 | 199 | (string= "dark" (substring name 0 4)) |
ef88bd2d MW |
200 | (msdos-color-translate (substring name 4))) |
201 | (and (> len 5) | |
ec46c6e8 | 202 | (string= "dark " (substring name 0 5)) |
ef88bd2d MW |
203 | (msdos-color-translate (substring name 5)))))) |
204 | ;; --------------------------------------------------------------------------- | |
205 | ;; We want to delay setting frame parameters until the faces are setup | |
206 | (defvar default-frame-alist nil) | |
9000684d | 207 | (modify-frame-parameters terminal-frame default-frame-alist) |
ef88bd2d | 208 | |
e2f35ede RS |
209 | (defun msdos-bg-mode (&optional frame) |
210 | (let* ((frame (or frame (selected-frame))) | |
211 | (params (frame-parameters frame)) | |
212 | (bg (cdr (assq 'background-color params)))) | |
213 | (if (member bg '("black" "blue" "darkgray" "green")) | |
214 | 'dark | |
215 | 'light))) | |
216 | ||
ef88bd2d | 217 | (defun msdos-face-setup () |
9000684d | 218 | (modify-frame-parameters terminal-frame default-frame-alist) |
ef88bd2d | 219 | |
9000684d RS |
220 | (set-face-foreground 'bold "yellow" terminal-frame) |
221 | (set-face-foreground 'italic "red" terminal-frame) | |
222 | (set-face-foreground 'bold-italic "lightred" terminal-frame) | |
223 | (set-face-foreground 'underline "white" terminal-frame) | |
224 | (set-face-background 'region "green" terminal-frame) | |
ef88bd2d MW |
225 | |
226 | (make-face 'msdos-menu-active-face) | |
227 | (make-face 'msdos-menu-passive-face) | |
228 | (make-face 'msdos-menu-select-face) | |
9000684d RS |
229 | (set-face-foreground 'msdos-menu-active-face "white" terminal-frame) |
230 | (set-face-foreground 'msdos-menu-passive-face "lightgray" terminal-frame) | |
231 | (set-face-background 'msdos-menu-active-face "blue" terminal-frame) | |
232 | (set-face-background 'msdos-menu-passive-face "blue" terminal-frame) | |
e2f35ede RS |
233 | (set-face-background 'msdos-menu-select-face "red" terminal-frame) |
234 | (modify-frame-parameters terminal-frame | |
235 | (list (cons 'background-mode | |
236 | (msdos-bg-mode terminal-frame)) | |
237 | (cons 'display-type 'color)))) | |
ef88bd2d MW |
238 | |
239 | ;; We have only one font, so... | |
240 | (add-hook 'before-init-hook 'msdos-face-setup) | |
9000684d RS |
241 | |
242 | ;; We create frames as if we were a terminal, but with a twist. | |
243 | (defun make-msdos-frame (&optional parameters) | |
e2f35ede RS |
244 | (let* ((parms |
245 | (append initial-frame-alist default-frame-alist parameters nil)) | |
246 | (frame (make-terminal-frame parms))) | |
247 | (modify-frame-parameters frame | |
248 | (list (cons 'background-mode | |
249 | (msdos-bg-mode frame)) | |
250 | (cons 'display-type 'color))) | |
251 | frame)) | |
9000684d RS |
252 | |
253 | (setq frame-creation-function 'make-msdos-frame) | |
254 | ||
ef88bd2d | 255 | ;; --------------------------------------------------------------------------- |
a7acbbe4 | 256 | ;; More or less useful imitations of certain X-functions. A lot of the |
ef88bd2d MW |
257 | ;; values returned are questionable, but usually only the form of the |
258 | ;; returned value matters. Also, by the way, recall that `ignore' is | |
259 | ;; a useful function for returning 'nil regardless of argument. | |
260 | ||
261 | ;; From src/xfns.c | |
beb4ba68 | 262 | (defun x-display-color-p (&optional display) 't) |
ef88bd2d MW |
263 | (defun x-list-fonts (pattern &optional face frame) (list "default")) |
264 | (defun x-color-defined-p (color) (numberp (msdos-color-translate color))) | |
a259d337 RS |
265 | (defun x-display-pixel-width (&optional frame) (frame-width frame)) |
266 | (defun x-display-pixel-height (&optional frame) (frame-height frame)) | |
ef88bd2d MW |
267 | (defun x-display-planes (&optional frame) 4) ; 3 for background, actually |
268 | (defun x-display-color-cells (&optional frame) 16) ; ??? | |
269 | (defun x-server-max-request-size (&optional frame) 1000000) ; ??? | |
270 | (defun x-server-vendor (&optional frame) t "GNU") | |
271 | (defun x-server-version (&optional frame) '(1 0 0)) | |
272 | (defun x-display-screens (&optional frame) 1) | |
273 | (defun x-display-mm-height (&optional frame) 200) ; Guess the size of my | |
274 | (defun x-display-mm-width (&optional frame) 253) ; monitor, MW... | |
275 | (defun x-display-backing-store (&optional frame) 'not-useful) | |
276 | (defun x-display-visual-class (&optional frame) 'static-color) | |
277 | (fset 'x-display-save-under 'ignore) | |
278 | (fset 'x-get-resource 'ignore) | |
279 | ||
280 | ;; From lisp/term/x-win.el | |
281 | (setq x-display-name "pc") | |
282 | (setq split-window-keep-point t) | |
bb3a4574 RS |
283 | (defvar x-colors '("black" |
284 | "blue" | |
285 | "green" | |
286 | "cyan" | |
287 | "red" | |
288 | "magenta" | |
289 | "brown" | |
290 | "lightgray" | |
291 | "darkgray" | |
292 | "lightblue" | |
293 | "lightgreen" | |
294 | "lightcyan" | |
295 | "lightred" | |
296 | "lightmagenta" | |
297 | "yellow" | |
298 | "white") | |
299 | "The list of colors available on a PC display under MS-DOS.") | |
300 | (defun x-defined-colors (&optional frame) | |
301 | "Return a list of colors supported for a particular frame. | |
302 | The argument FRAME specifies which frame to try. | |
303 | The value may be different for frames on different X displays." | |
304 | x-colors) | |
c432c362 EZ |
305 | |
306 | ;; From lisp/term/win32-win.el | |
307 | ; | |
308 | ;;;; Selections and cut buffers | |
bb3a4574 | 309 | ; |
c432c362 EZ |
310 | ;;; We keep track of the last text selected here, so we can check the |
311 | ;;; current selection against it, and avoid passing back our own text | |
312 | ;;; from x-cut-buffer-or-selection-value. | |
313 | (defvar x-last-selected-text nil) | |
314 | ||
315 | (defvar x-select-enable-clipboard t | |
316 | "Non-nil means cutting and pasting uses the clipboard. | |
317 | This is in addition to the primary selection.") | |
318 | ||
319 | (defun x-select-text (text &optional push) | |
320 | (if x-select-enable-clipboard | |
321 | (win16-set-clipboard-data text)) | |
322 | (setq x-last-selected-text text)) | |
323 | ||
324 | ;;; Return the value of the current selection. | |
325 | ;;; Consult the selection, then the cut buffer. Treat empty strings | |
326 | ;;; as if they were unset. | |
327 | (defun x-get-selection-value () | |
328 | (if x-select-enable-clipboard | |
329 | (let (text) | |
330 | ;; Don't die if x-get-selection signals an error. | |
331 | (condition-case c | |
332 | (setq text (win16-get-clipboard-data)) | |
333 | (error (message "win16-get-clipboard-data:%s" c))) | |
334 | (if (string= text "") (setq text nil)) | |
335 | (cond | |
336 | ((not text) nil) | |
337 | ((eq text x-last-selected-text) nil) | |
338 | ((string= text x-last-selected-text) | |
339 | ;; Record the newer string, so subsequent calls can use the 'eq' test. | |
340 | (setq x-last-selected-text text) | |
341 | nil) | |
342 | (t | |
343 | (setq x-last-selected-text text)))))) | |
344 | ||
345 | ;;; Arrange for the kill and yank functions to set and check the clipboard. | |
346 | (setq interprogram-cut-function 'x-select-text) | |
347 | (setq interprogram-paste-function 'x-get-selection-value) | |
ef88bd2d | 348 | |
ea6401d7 RS |
349 | ;; From lisp/faces.el: we only have one font, so always return |
350 | ;; it, no matter which variety they've asked for. | |
351 | (defun x-frob-font-slant (font which) | |
352 | font) | |
353 | ||
e1ddc4b4 RS |
354 | ;; From lisp/term/x-win.el: make iconify-or-deiconify-frame a no-op. |
355 | (fset 'iconify-or-deiconify-frame 'ignore) | |
356 | ||
ef88bd2d MW |
357 | ;; From lisp/frame.el |
358 | (fset 'set-default-font 'ignore) | |
359 | (fset 'set-mouse-color 'ignore) ; We cannot, I think. | |
360 | (fset 'set-cursor-color 'ignore) ; Hardware determined by char under. | |
361 | (fset 'set-border-color 'ignore) ; Not useful. | |
ef88bd2d MW |
362 | ;; --------------------------------------------------------------------------- |
363 | ;; Handle the X-like command line parameters "-fg" and "-bg" | |
364 | (defun msdos-handle-args (args) | |
365 | (let ((rest nil)) | |
366 | (while args | |
367 | (let ((this (car args))) | |
368 | (setq args (cdr args)) | |
369 | (cond ((or (string= this "-fg") (string= this "-foreground")) | |
370 | (if args | |
371 | (setq default-frame-alist | |
372 | (cons (cons 'foreground-color (car args)) | |
373 | default-frame-alist) | |
374 | args (cdr args)))) | |
375 | ((or (string= this "-bg") (string= this "-background")) | |
376 | (if args | |
377 | (setq default-frame-alist | |
378 | (cons (cons 'background-color (car args)) | |
379 | default-frame-alist) | |
380 | args (cdr args)))) | |
381 | (t (setq rest (cons this rest)))))) | |
382 | (nreverse rest))) | |
383 | ||
384 | (setq command-line-args (msdos-handle-args command-line-args)) | |
385 | ;; --------------------------------------------------------------------------- | |
092af6d8 RS |
386 | |
387 | ;;; pc-win.el ends here |