Mercurial > emacs
comparison lisp/term/w32-win.el @ 59704:a53730244ba3
Simplify code.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 23 Jan 2005 16:56:11 +0000 |
parents | 9b8f178a62da |
children | 5d9760bd65eb befae6bafecb |
comparison
equal
deleted
inserted
replaced
59703:51a8532d9066 | 59704:a53730244ba3 |
---|---|
1 ;;; w32-win.el --- parse switches controlling interface with W32 window system | 1 ;;; w32-win.el --- parse switches controlling interface with W32 window system |
2 | 2 |
3 ;; Copyright (C) 1993, 1994, 2003, 2004 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 1994, 2003, 2004, 2005 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Kevin Gallo | 5 ;; Author: Kevin Gallo |
6 ;; Keywords: terminals | 6 ;; Keywords: terminals |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
137 | 137 |
138 (defun x-handle-switch (switch) | 138 (defun x-handle-switch (switch) |
139 "Handle SWITCH of the form \"-switch value\" or \"-switch\"." | 139 "Handle SWITCH of the form \"-switch value\" or \"-switch\"." |
140 (let ((aelt (assoc switch command-line-x-option-alist))) | 140 (let ((aelt (assoc switch command-line-x-option-alist))) |
141 (if aelt | 141 (if aelt |
142 (let ((param (nth 3 aelt)) | 142 (push (cons (nth 3 aelt) (or (nth 4 aelt) (pop x-invocation-args))) |
143 (value (nth 4 aelt))) | 143 default-frame-alist)))) |
144 (if value | |
145 (setq default-frame-alist | |
146 (cons (cons param value) | |
147 default-frame-alist)) | |
148 (setq default-frame-alist | |
149 (cons (cons param | |
150 (car x-invocation-args)) | |
151 default-frame-alist) | |
152 x-invocation-args (cdr x-invocation-args))))))) | |
153 | 144 |
154 (defun x-handle-numeric-switch (switch) | 145 (defun x-handle-numeric-switch (switch) |
155 "Handle SWITCH of the form \"-switch n\"." | 146 "Handle SWITCH of the form \"-switch n\"." |
156 (let ((aelt (assoc switch command-line-x-option-alist))) | 147 (let ((aelt (assoc switch command-line-x-option-alist))) |
157 (if aelt | 148 (if aelt |
158 (let ((param (nth 3 aelt))) | 149 (push (cons (nth 3 aelt) (string-to-int (pop x-invocation-args))) |
159 (setq default-frame-alist | 150 default-frame-alist)))) |
160 (cons (cons param | |
161 (string-to-int (car x-invocation-args))) | |
162 default-frame-alist) | |
163 x-invocation-args | |
164 (cdr x-invocation-args)))))) | |
165 | 151 |
166 ;; Handle options that apply to initial frame only | 152 ;; Handle options that apply to initial frame only |
167 (defun x-handle-initial-switch (switch) | 153 (defun x-handle-initial-switch (switch) |
168 (let ((aelt (assoc switch command-line-x-option-alist))) | 154 (let ((aelt (assoc switch command-line-x-option-alist))) |
169 (if aelt | 155 (if aelt |
170 (let ((param (nth 3 aelt)) | 156 (push (cons (nth 3 aelt) (or (nth 4 aelt) (pop x-invocation-args))) |
171 (value (nth 4 aelt))) | 157 initial-frame-alist)))) |
172 (if value | |
173 (setq initial-frame-alist | |
174 (cons (cons param value) | |
175 initial-frame-alist)) | |
176 (setq initial-frame-alist | |
177 (cons (cons param | |
178 (car x-invocation-args)) | |
179 initial-frame-alist) | |
180 x-invocation-args (cdr x-invocation-args))))))) | |
181 | 158 |
182 (defun x-handle-iconic (switch) | 159 (defun x-handle-iconic (switch) |
183 "Make \"-iconic\" SWITCH apply only to the initial frame." | 160 "Make \"-iconic\" SWITCH apply only to the initial frame." |
184 (setq initial-frame-alist | 161 (push '(visibility . icon) initial-frame-alist)) |
185 (cons '(visibility . icon) initial-frame-alist))) | |
186 | 162 |
187 (defun x-handle-xrm-switch (switch) | 163 (defun x-handle-xrm-switch (switch) |
188 "Handle the \"-xrm\" SWITCH." | 164 "Handle the \"-xrm\" SWITCH." |
189 (or (consp x-invocation-args) | 165 (or (consp x-invocation-args) |
190 (error "%s: missing argument to `%s' option" (invocation-name) switch)) | 166 (error "%s: missing argument to `%s' option" (invocation-name) switch)) |
224 "Handle a \"-name\" SWITCH." | 200 "Handle a \"-name\" SWITCH." |
225 ;; Handle the -name option. Set the variable x-resource-name | 201 ;; Handle the -name option. Set the variable x-resource-name |
226 ;; to the option's operand; set the name of the initial frame, too. | 202 ;; to the option's operand; set the name of the initial frame, too. |
227 (or (consp x-invocation-args) | 203 (or (consp x-invocation-args) |
228 (error "%s: missing argument to `%s' option" (invocation-name) switch)) | 204 (error "%s: missing argument to `%s' option" (invocation-name) switch)) |
229 (setq x-resource-name (car x-invocation-args) | 205 (setq x-resource-name (pop x-invocation-args)) |
230 x-invocation-args (cdr x-invocation-args)) | 206 (push (cons 'name x-resource-name) initial-frame-alist)) |
231 (setq initial-frame-alist (cons (cons 'name x-resource-name) | |
232 initial-frame-alist))) | |
233 | 207 |
234 (defvar x-display-name nil | 208 (defvar x-display-name nil |
235 "The display name specifying server and frame.") | 209 "The display name specifying server and frame.") |
236 | 210 |
237 (defun x-handle-display (switch) | 211 (defun x-handle-display (switch) |
238 "Handle the \"-display\" SWITCH." | 212 "Handle the \"-display\" SWITCH." |
239 (setq x-display-name (car x-invocation-args) | 213 (setq x-display-name (pop x-invocation-args))) |
240 x-invocation-args (cdr x-invocation-args))) | |
241 | 214 |
242 (defun x-handle-args (args) | 215 (defun x-handle-args (args) |
243 "Process the X-related command line options in ARGS. | 216 "Process the X-related command line options in ARGS. |
244 This is done before the user's startup file is loaded. They are copied to | 217 This is done before the user's startup file is loaded. They are copied to |
245 `x-invocation args' from which the X-related things are extracted, first | 218 `x-invocation args' from which the X-related things are extracted, first |
279 (if argval | 252 (if argval |
280 (let ((x-invocation-args | 253 (let ((x-invocation-args |
281 (cons argval x-invocation-args))) | 254 (cons argval x-invocation-args))) |
282 (funcall handler this-switch)) | 255 (funcall handler this-switch)) |
283 (funcall handler this-switch)) | 256 (funcall handler this-switch)) |
284 (setq args (cons orig-this-switch args))))) | 257 (push orig-this-switch args)))) |
285 (nconc (nreverse args) x-invocation-args)) | 258 (nconc (nreverse args) x-invocation-args)) |
286 | 259 |
287 ;; | 260 ;; |
288 ;; Available colors | 261 ;; Available colors |
289 ;; | 262 ;; |
1044 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp") | 1017 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp") |
1045 | 1018 |
1046 (defun xw-defined-colors (&optional frame) | 1019 (defun xw-defined-colors (&optional frame) |
1047 "Internal function called by `defined-colors', which see." | 1020 "Internal function called by `defined-colors', which see." |
1048 (or frame (setq frame (selected-frame))) | 1021 (or frame (setq frame (selected-frame))) |
1049 (let* ((color-map-colors (mapcar (lambda (clr) (car clr)) w32-color-map)) | 1022 (let ((defined-colors nil)) |
1050 (all-colors (or color-map-colors x-colors)) | 1023 (dolist (this-color (or (mapcar 'car w32-color-map) x-colors)) |
1051 (this-color nil) | |
1052 (defined-colors nil)) | |
1053 (while all-colors | |
1054 (setq this-color (car all-colors) | |
1055 all-colors (cdr all-colors)) | |
1056 (and (color-supported-p this-color frame t) | 1024 (and (color-supported-p this-color frame t) |
1057 (setq defined-colors (cons this-color defined-colors)))) | 1025 (push this-color defined-colors))) |
1058 defined-colors)) | 1026 defined-colors)) |
1059 | 1027 |
1060 | 1028 |
1061 ;;;; Function keys | 1029 ;;;; Function keys |
1062 | 1030 |
1074 | 1042 |
1075 (setq command-line-args (x-handle-args command-line-args)) | 1043 (setq command-line-args (x-handle-args command-line-args)) |
1076 | 1044 |
1077 ;;; Make sure we have a valid resource name. | 1045 ;;; Make sure we have a valid resource name. |
1078 (or (stringp x-resource-name) | 1046 (or (stringp x-resource-name) |
1079 (let (i) | 1047 (setq x-resource-name |
1080 (setq x-resource-name (invocation-name)) | 1048 ;; Change any . or * characters in x-resource-name to hyphens, |
1081 | 1049 ;; so as not to choke when we use it in X resource queries. |
1082 ;; Change any . or * characters in x-resource-name to hyphens, | 1050 (replace-regexp-in-string "[.*]" "-" (invocation-name)))) |
1083 ;; so as not to choke when we use it in X resource queries. | |
1084 (while (setq i (string-match "[.*]" x-resource-name)) | |
1085 (aset x-resource-name i ?-)))) | |
1086 | 1051 |
1087 ;; For the benefit of older Emacses (19.27 and earlier) that are sharing | 1052 ;; For the benefit of older Emacses (19.27 and earlier) that are sharing |
1088 ;; the same lisp directory, don't pass the third argument unless we seem | 1053 ;; the same lisp directory, don't pass the third argument unless we seem |
1089 ;; to have the multi-display support. | 1054 ;; to have the multi-display support. |
1090 (if (fboundp 'x-close-connection) | 1055 (if (fboundp 'x-close-connection) |
1164 (cons '(user-size . t) parsed)))) | 1129 (cons '(user-size . t) parsed)))) |
1165 ;; All geometry parms apply to the initial frame. | 1130 ;; All geometry parms apply to the initial frame. |
1166 (setq initial-frame-alist (append initial-frame-alist parsed)) | 1131 (setq initial-frame-alist (append initial-frame-alist parsed)) |
1167 ;; The size parms apply to all frames. | 1132 ;; The size parms apply to all frames. |
1168 (if (assq 'height parsed) | 1133 (if (assq 'height parsed) |
1169 (setq default-frame-alist | 1134 (push (cons 'height (cdr (assq 'height parsed))) |
1170 (cons (cons 'height (cdr (assq 'height parsed))) | 1135 default-frame-alist)) |
1171 default-frame-alist))) | |
1172 (if (assq 'width parsed) | 1136 (if (assq 'width parsed) |
1173 (setq default-frame-alist | 1137 (push (cons 'width (cdr (assq 'width parsed))) |
1174 (cons (cons 'width (cdr (assq 'width parsed))) | 1138 default-frame-alist))))) |
1175 default-frame-alist)))))) | |
1176 | 1139 |
1177 ;; Check the reverseVideo resource. | 1140 ;; Check the reverseVideo resource. |
1178 (let ((case-fold-search t)) | 1141 (let ((case-fold-search t)) |
1179 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo"))) | 1142 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo"))) |
1180 (if (and rv | 1143 (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv)) |
1181 (string-match "^\\(true\\|yes\\|on\\)$" rv)) | 1144 (push '(reverse . t) default-frame-alist)))) |
1182 (setq default-frame-alist | |
1183 (cons '(reverse . t) default-frame-alist))))) | |
1184 | 1145 |
1185 (defun x-win-suspend-error () | 1146 (defun x-win-suspend-error () |
1186 "Report an error when a suspend is attempted." | 1147 "Report an error when a suspend is attempted." |
1187 (error "Suspending an Emacs running under W32 makes no sense")) | 1148 (error "Suspending an Emacs running under W32 makes no sense")) |
1188 (add-hook 'suspend-hook 'x-win-suspend-error) | 1149 (add-hook 'suspend-hook 'x-win-suspend-error) |
1242 (let ((chosen-font (w32-select-font (selected-frame) | 1203 (let ((chosen-font (w32-select-font (selected-frame) |
1243 w32-list-proportional-fonts))) | 1204 w32-list-proportional-fonts))) |
1244 (and chosen-font (list chosen-font))) | 1205 (and chosen-font (list chosen-font))) |
1245 (x-popup-menu | 1206 (x-popup-menu |
1246 last-nonmenu-event | 1207 last-nonmenu-event |
1247 ;; Append list of fontsets currently defined. | 1208 ;; Append list of fontsets currently defined. |
1248 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles | 1209 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles |
1249 (if (fboundp 'new-fontset) | 1210 (if (fboundp 'new-fontset) |
1250 (append w32-fixed-font-alist (list (generate-fontset-menu))))))) | 1211 (append w32-fixed-font-alist (list (generate-fontset-menu))))))) |
1251 (if fonts | 1212 (if fonts |
1252 (let (font) | 1213 (let (font) |
1266 (png "libpng13d.dll" "libpng13.dll" "libpng12d.dll" "libpng12.dll" "libpng.dll") | 1227 (png "libpng13d.dll" "libpng13.dll" "libpng12d.dll" "libpng12.dll" "libpng.dll") |
1267 (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") | 1228 (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") |
1268 (tiff "libtiff3.dll" "libtiff.dll") | 1229 (tiff "libtiff3.dll" "libtiff.dll") |
1269 (gif "libungif.dll"))) | 1230 (gif "libungif.dll"))) |
1270 | 1231 |
1271 ;;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166 | 1232 ;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166 |
1272 ;;; w32-win.el ends here | 1233 ;;; w32-win.el ends here |