Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; pc-win.el --- setup support for `PC windows' (whatever that is) |
ef88bd2d | 2 | |
1bd62036 | 3 | ;; Copyright (C) 1994, 1996, 1997, 1999, 2001 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 | ||
55535639 PJ |
25 | ;;; Commentary: |
26 | ||
2fe590dc EN |
27 | ;;; Code: |
28 | ||
ef88bd2d MW |
29 | (load "term/internal" nil t) |
30 | ||
c4d64969 | 31 | ;;; This is copied from etc/rgb.txt, except that some values were changed |
f795f633 EZ |
32 | ;;; a bit to make them consistent with DOS console colors, and the RGB |
33 | ;;; values were scaled up to 16 bits, as `tty-define-color' requires. | |
34 | ;;; | |
35 | ;;; The mapping between the 16 standard EGA/VGA colors and X color names | |
36 | ;;; was done by running a Unix version of Emacs inside an X client and a | |
37 | ;;; DJGPP-compiled Emacs on the same PC. The names of X colors used to | |
38 | ;;; define the pixel values are shown as comments to each color below. | |
c4d64969 EZ |
39 | ;;; |
40 | ;;; If you want to change the RGB values, keep in mind that various pieces | |
41 | ;;; of Emacs think that a color whose RGB values add up to less than 0.6 of | |
f795f633 | 42 | ;;; the values for WHITE (i.e. less than 117963) are ``dark'', otherwise the |
c4d64969 EZ |
43 | ;;; color is ``light''; see `frame-set-background-mode' in lisp/faces.el for |
44 | ;;; an example. | |
45 | (defvar msdos-color-values | |
f795f633 EZ |
46 | '(("white" 15 65535 65535 65535) |
47 | ("yellow" 14 65535 65535 0) ; Yellow | |
48 | ("lightmagenta" 13 65535 0 65535) ; Magenta | |
49 | ("lightred" 12 65535 0 0) ; Red | |
50 | ("lightcyan" 11 0 65535 65535) ; Cyan | |
51 | ("lightgreen" 10 0 65535 0) ; Green | |
52 | ("lightblue" 9 0 0 65535) ; Blue | |
53 | ("darkgray" 8 26112 26112 26112) ; Gray40 | |
54 | ("lightgray" 7 48640 48640 48640) ; Gray | |
55 | ("brown" 6 40960 20992 11520) ; Sienna | |
56 | ("magenta" 5 35584 0 35584) ; DarkMagenta | |
57 | ("red" 4 45568 8704 8704) ; FireBrick | |
58 | ("cyan" 3 0 52736 53504) ; DarkTurquoise | |
59 | ("green" 2 8704 35584 8704) ; ForestGreen | |
60 | ("blue" 1 0 0 52480) ; MediumBlue | |
61 | ("black" 0 0 0 0)) | |
62 | "A list of MS-DOS console colors, their indices and 16-bit RGB values.") | |
a13b5fad | 63 | |
ef88bd2d MW |
64 | ;; --------------------------------------------------------------------------- |
65 | ;; We want to delay setting frame parameters until the faces are setup | |
66 | (defvar default-frame-alist nil) | |
9000684d | 67 | (modify-frame-parameters terminal-frame default-frame-alist) |
f795f633 | 68 | (tty-color-clear) |
ef88bd2d MW |
69 | |
70 | (defun msdos-face-setup () | |
9000684d RS |
71 | (set-face-foreground 'bold "yellow" terminal-frame) |
72 | (set-face-foreground 'italic "red" terminal-frame) | |
73 | (set-face-foreground 'bold-italic "lightred" terminal-frame) | |
74 | (set-face-foreground 'underline "white" terminal-frame) | |
ef88bd2d MW |
75 | |
76 | (make-face 'msdos-menu-active-face) | |
77 | (make-face 'msdos-menu-passive-face) | |
78 | (make-face 'msdos-menu-select-face) | |
9000684d RS |
79 | (set-face-foreground 'msdos-menu-active-face "white" terminal-frame) |
80 | (set-face-foreground 'msdos-menu-passive-face "lightgray" terminal-frame) | |
81 | (set-face-background 'msdos-menu-active-face "blue" terminal-frame) | |
82 | (set-face-background 'msdos-menu-passive-face "blue" terminal-frame) | |
c13c88d7 | 83 | (set-face-background 'msdos-menu-select-face "red" terminal-frame)) |
ef88bd2d | 84 | |
ef88bd2d | 85 | (add-hook 'before-init-hook 'msdos-face-setup) |
9000684d | 86 | |
f795f633 EZ |
87 | (defun msdos-handle-reverse-video (frame parameters) |
88 | "Handle the reverse-video frame parameter on MS-DOS frames." | |
c88c89a0 EZ |
89 | (when (cdr (or (assq 'reverse parameters) |
90 | (assq 'reverse default-frame-alist))) | |
f795f633 | 91 | (let* ((params (frame-parameters frame)) |
8fcacf13 EZ |
92 | (fg (cdr (assq 'foreground-color params))) |
93 | (bg (cdr (assq 'background-color params)))) | |
94 | (if (equal fg (cdr (assq 'mouse-color params))) | |
f795f633 | 95 | (modify-frame-parameters frame |
8fcacf13 EZ |
96 | (list (cons 'mouse-color bg)))) |
97 | (if (equal fg (cdr (assq 'cursor-color params))) | |
f795f633 | 98 | (modify-frame-parameters frame |
8fcacf13 | 99 | (list (cons 'cursor-color bg))))))) |
f795f633 EZ |
100 | |
101 | ;; This must run after all the default colors are inserted into | |
102 | ;; tty-color-alist, since msdos-handle-reverse-video needs to know the | |
103 | ;; actual frame colors. tty-color-alist is set up by startup.el, but | |
104 | ;; only after it runs before-init-hook and after-init-hook. | |
105 | (defun msdos-setup-initial-frame () | |
106 | (modify-frame-parameters terminal-frame default-frame-alist) | |
107 | ;; This remembers the screen colors after applying default-frame-alist, | |
108 | ;; so that all subsequent frames could begin with those colors. | |
109 | (msdos-remember-default-colors terminal-frame) | |
110 | (modify-frame-parameters terminal-frame initial-frame-alist) | |
111 | (msdos-handle-reverse-video terminal-frame | |
112 | (frame-parameters terminal-frame)) | |
113 | ||
114 | (frame-set-background-mode terminal-frame) | |
115 | (face-set-after-frame-default terminal-frame)) | |
116 | ||
117 | (add-hook 'term-setup-hook 'msdos-setup-initial-frame) | |
118 | ||
9000684d RS |
119 | ;; We create frames as if we were a terminal, but with a twist. |
120 | (defun make-msdos-frame (&optional parameters) | |
f795f633 EZ |
121 | (let ((frame (make-terminal-frame parameters)) |
122 | success) | |
68a89a25 EZ |
123 | (unwind-protect |
124 | (progn | |
f795f633 | 125 | (msdos-handle-reverse-video frame (frame-parameters frame)) |
68a89a25 EZ |
126 | (frame-set-background-mode frame) |
127 | (face-set-after-frame-default frame) | |
128 | (setq success t)) | |
129 | (unless success (delete-frame frame))) | |
e2f35ede | 130 | frame)) |
9000684d RS |
131 | |
132 | (setq frame-creation-function 'make-msdos-frame) | |
133 | ||
ef88bd2d | 134 | ;; --------------------------------------------------------------------------- |
a7acbbe4 | 135 | ;; More or less useful imitations of certain X-functions. A lot of the |
ef88bd2d MW |
136 | ;; values returned are questionable, but usually only the form of the |
137 | ;; returned value matters. Also, by the way, recall that `ignore' is | |
138 | ;; a useful function for returning 'nil regardless of argument. | |
139 | ||
140 | ;; From src/xfns.c | |
cee30b8f | 141 | (defun x-list-fonts (pattern &optional face frame maximum width) |
c0e2e77f EZ |
142 | (if (or (null width) (and (numberp width) (= width 1))) |
143 | (list "ms-dos") | |
cee30b8f | 144 | (list "no-such-font"))) |
a259d337 RS |
145 | (defun x-display-pixel-width (&optional frame) (frame-width frame)) |
146 | (defun x-display-pixel-height (&optional frame) (frame-height frame)) | |
c0e2e77f EZ |
147 | (defun x-display-planes (&optional frame) 4) ;bg switched to 16 colors as well |
148 | (defun x-display-color-cells (&optional frame) 16) | |
ef88bd2d MW |
149 | (defun x-server-max-request-size (&optional frame) 1000000) ; ??? |
150 | (defun x-server-vendor (&optional frame) t "GNU") | |
151 | (defun x-server-version (&optional frame) '(1 0 0)) | |
152 | (defun x-display-screens (&optional frame) 1) | |
c0e2e77f EZ |
153 | (defun x-display-mm-height (&optional frame) 245) ; Guess the size of my |
154 | (defun x-display-mm-width (&optional frame) 322) ; monitor, EZ... | |
ef88bd2d MW |
155 | (defun x-display-backing-store (&optional frame) 'not-useful) |
156 | (defun x-display-visual-class (&optional frame) 'static-color) | |
157 | (fset 'x-display-save-under 'ignore) | |
158 | (fset 'x-get-resource 'ignore) | |
a0c712ae | 159 | |
ef88bd2d | 160 | ;; From lisp/term/x-win.el |
f795f633 EZ |
161 | (defvar x-display-name "pc" |
162 | "The display name specifying the MS-DOS display and frame type.") | |
ef88bd2d | 163 | (setq split-window-keep-point t) |
c0e2e77f | 164 | (defvar x-colors (mapcar 'car msdos-color-values) |
bb3a4574 | 165 | "The list of colors available on a PC display under MS-DOS.") |
c4d64969 | 166 | |
8254b6b4 | 167 | ;; From lisp/term/w32-win.el |
c432c362 EZ |
168 | ; |
169 | ;;;; Selections and cut buffers | |
bb3a4574 | 170 | ; |
c432c362 EZ |
171 | ;;; We keep track of the last text selected here, so we can check the |
172 | ;;; current selection against it, and avoid passing back our own text | |
173 | ;;; from x-cut-buffer-or-selection-value. | |
174 | (defvar x-last-selected-text nil) | |
175 | ||
8c717810 EZ |
176 | (defcustom x-select-enable-clipboard t |
177 | "Non-nil means cutting and pasting uses the clipboard. | |
178 | This is the default on this system, since MS-Windows does not | |
179 | support other types of selections." | |
180 | :type 'boolean | |
181 | :group 'killing) | |
c432c362 EZ |
182 | |
183 | (defun x-select-text (text &optional push) | |
184 | (if x-select-enable-clipboard | |
8254b6b4 | 185 | (w16-set-clipboard-data text)) |
c432c362 EZ |
186 | (setq x-last-selected-text text)) |
187 | ||
188 | ;;; Return the value of the current selection. | |
189 | ;;; Consult the selection, then the cut buffer. Treat empty strings | |
190 | ;;; as if they were unset. | |
191 | (defun x-get-selection-value () | |
192 | (if x-select-enable-clipboard | |
193 | (let (text) | |
194 | ;; Don't die if x-get-selection signals an error. | |
195 | (condition-case c | |
8254b6b4 EZ |
196 | (setq text (w16-get-clipboard-data)) |
197 | (error (message "w16-get-clipboard-data:%s" c))) | |
c432c362 EZ |
198 | (if (string= text "") (setq text nil)) |
199 | (cond | |
200 | ((not text) nil) | |
201 | ((eq text x-last-selected-text) nil) | |
202 | ((string= text x-last-selected-text) | |
203 | ;; Record the newer string, so subsequent calls can use the 'eq' test. | |
204 | (setq x-last-selected-text text) | |
205 | nil) | |
206 | (t | |
207 | (setq x-last-selected-text text)))))) | |
208 | ||
209 | ;;; Arrange for the kill and yank functions to set and check the clipboard. | |
210 | (setq interprogram-cut-function 'x-select-text) | |
211 | (setq interprogram-paste-function 'x-get-selection-value) | |
ef88bd2d | 212 | |
ea6401d7 RS |
213 | ;; From lisp/faces.el: we only have one font, so always return |
214 | ;; it, no matter which variety they've asked for. | |
215 | (defun x-frob-font-slant (font which) | |
216 | font) | |
c0e2e77f EZ |
217 | (defun x-frob-font-weight (font which) |
218 | font) | |
219 | (defun x-font-family-list () | |
220 | "Return a list of available font families on FRAME.\n\ | |
221 | If FRAME is omitted or nil, use the selected frame.\n\ | |
222 | Value is a list of conses (FAMILY . FIXED-P) where FAMILY\n\ | |
223 | is a font family, and FIXED-P is non-nil if fonts of that family\n\ | |
224 | are fixed-pitch." | |
225 | '(("default" . t))) | |
ea6401d7 | 226 | |
cee30b8f RS |
227 | ;; From src/fontset.c: |
228 | (fset 'query-fontset 'ignore) | |
229 | ||
e1ddc4b4 RS |
230 | ;; From lisp/term/x-win.el: make iconify-or-deiconify-frame a no-op. |
231 | (fset 'iconify-or-deiconify-frame 'ignore) | |
232 | ||
ef88bd2d MW |
233 | ;; From lisp/frame.el |
234 | (fset 'set-default-font 'ignore) | |
235 | (fset 'set-mouse-color 'ignore) ; We cannot, I think. | |
236 | (fset 'set-cursor-color 'ignore) ; Hardware determined by char under. | |
237 | (fset 'set-border-color 'ignore) ; Not useful. | |
c8a6e3b9 | 238 | |
ef88bd2d | 239 | ;; --------------------------------------------------------------------------- |
092af6d8 RS |
240 | |
241 | ;;; pc-win.el ends here |