Commit | Line | Data |
---|---|---|
dc6d9681 | 1 | ;;; frame.el --- multi-frame management independent of window systems. |
c88ab9ce | 2 | |
c0f86408 | 3 | ;;;; Copyright (C) 1993 Free Software Foundation, Inc. |
3a801d0c | 4 | |
fc68affa | 5 | ;; Maintainer: FSF |
fd7fa35a | 6 | ;; Keywords: internal |
fc68affa | 7 | |
64c669bc JB |
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 | |
de49a6d3 | 12 | ;;; the Free Software Foundation; either version 2, or (at your option) |
64c669bc JB |
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 | |
22 | ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | ||
fc68affa ER |
24 | ;;; Code: |
25 | ||
dc6d9681 JB |
26 | (defvar frame-creation-function nil |
27 | "Window-system dependent function to call to create a new frame. | |
28 | The window system startup file should set this to its frame creation | |
64c669bc JB |
29 | function, which should take an alist of parameters as its argument.") |
30 | ||
7eadab74 JB |
31 | ;;; The initial value given here for this must ask for a minibuffer. |
32 | ;;; There must always exist a frame with a minibuffer, and after we | |
33 | ;;; delete the terminal frame, this will be the only frame. | |
9e2b097b | 34 | (defvar initial-frame-alist '((minibuffer . t)) |
eaa974e1 JB |
35 | "Alist of frame parameters for creating the initial X window frame. |
36 | You can set this in your `.emacs' file; for example, | |
dc6d9681 | 37 | (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55))) |
eaa974e1 JB |
38 | If the value calls for a frame without a minibuffer, and you do not create a |
39 | minibuffer frame on your own, one is created according to | |
7eadab74 | 40 | `minibuffer-frame-alist'. |
eaa974e1 JB |
41 | Parameters specified here supersede the values given in |
42 | `default-frame-alist'.") | |
64c669bc | 43 | |
7eadab74 | 44 | (defvar minibuffer-frame-alist '((width . 80) (height . 2)) |
eaa974e1 JB |
45 | "Alist of frame parameters for initially creating a minibuffer frame. |
46 | You can set this in your `.emacs' file; for example, | |
dc6d9681 | 47 | (setq minibuffer-frame-alist |
7eadab74 | 48 | '((top . 1) (left . 1) (width . 80) (height . 2))) |
eaa974e1 JB |
49 | Parameters specified here supersede the values given in |
50 | `default-frame-alist'.") | |
64c669bc | 51 | |
dc6d9681 | 52 | (defvar pop-up-frame-alist nil |
eaa974e1 | 53 | "Alist of frame parameters used when creating pop-up frames. |
dc6d9681 | 54 | Pop-up frames are used for completions, help, and the like. |
64c669bc | 55 | This variable can be set in your init file, like this: |
dc6d9681 | 56 | (setq pop-up-frame-alist '((width . 80) (height . 20))) |
eb8c3be9 | 57 | These supersede the values given in `default-frame-alist'.") |
64c669bc | 58 | |
dc6d9681 | 59 | (setq pop-up-frame-function |
64c669bc | 60 | (function (lambda () |
dc6d9681 | 61 | (new-frame pop-up-frame-alist)))) |
64c669bc JB |
62 | |
63 | \f | |
dc6d9681 | 64 | ;;;; Arrangement of frames at startup |
64c669bc JB |
65 | |
66 | ;;; 1) Load the window system startup file from the lisp library and read the | |
67 | ;;; high-priority arguments (-q and the like). The window system startup | |
dc6d9681 | 68 | ;;; file should create any frames specified in the window system defaults. |
64c669bc | 69 | ;;; |
dc6d9681 | 70 | ;;; 2) If no frames have been opened, we open an initial text frame. |
64c669bc JB |
71 | ;;; |
72 | ;;; 3) Once the init file is done, we apply any newly set parameters | |
dc6d9681 | 73 | ;;; in initial-frame-alist to the frame. |
64c669bc | 74 | |
fc4d4afb RS |
75 | ;; These are now called explicitly at the proper times, |
76 | ;; since that is easier to understand. | |
77 | ;; Actually using hooks within Emacs is bad for future maintenance. --rms. | |
78 | ;; (add-hook 'before-init-hook 'frame-initialize) | |
79 | ;; (add-hook 'window-setup-hook 'frame-notice-user-settings) | |
64c669bc | 80 | |
dc6d9681 JB |
81 | ;;; If we create the initial frame, this is it. |
82 | (defvar frame-initial-frame nil) | |
64c669bc | 83 | |
3f2f8c83 RS |
84 | ;; Record the parameters used in frame-initialize to make the initial frame. |
85 | (defvar frame-initial-frame-alist) | |
86 | ||
64c669bc | 87 | ;;; startup.el calls this function before loading the user's init |
dc6d9681 | 88 | ;;; file - if there is no frame with a minibuffer open now, create |
64c669bc | 89 | ;;; one to display messages while loading the init file. |
dc6d9681 | 90 | (defun frame-initialize () |
64c669bc JB |
91 | |
92 | ;; Are we actually running under a window system at all? | |
93 | (if (and window-system (not noninteractive)) | |
7eadab74 JB |
94 | (progn |
95 | ;; If there is no frame with a minibuffer besides the terminal | |
96 | ;; frame, then we need to create the opening frame. Make sure | |
97 | ;; it has a minibuffer, but let initial-frame-alist omit the | |
98 | ;; minibuffer spec. | |
99 | (or (delq terminal-frame (minibuffer-frame-list)) | |
36fc9c9f | 100 | (progn |
3f2f8c83 RS |
101 | (setq frame-initial-frame-alist |
102 | (append initial-frame-alist default-frame-alist)) | |
36fc9c9f RS |
103 | (setq default-minibuffer-frame |
104 | (setq frame-initial-frame | |
105 | (new-frame initial-frame-alist))) | |
11281034 RS |
106 | ;; Delete any specifications for window geometry parameters |
107 | ;; so that we won't reapply them in frame-notice-user-settings. | |
108 | ;; It would be wrong to reapply them then, | |
109 | ;; because that would override explicit user resizing. | |
58bf6042 JB |
110 | (setq initial-frame-alist |
111 | (frame-remove-geometry-params initial-frame-alist)) | |
36fc9c9f RS |
112 | ;; Handle `reverse' as a parameter. |
113 | (if (cdr (or (assq 'reverse initial-frame-alist) | |
88046be2 | 114 | (assq 'reverse default-frame-alist))) |
36fc9c9f RS |
115 | (let ((params (frame-parameters frame-initial-frame))) |
116 | (modify-frame-parameters | |
117 | frame-initial-frame | |
949d4ac7 RS |
118 | ;; Must set cursor-color after background color. |
119 | ;; So put it first. | |
118c9082 JB |
120 | (list (cons 'cursor-color |
121 | (cdr (assq 'background-color params))) | |
122 | (cons 'foreground-color | |
123 | (cdr (assq 'background-color params))) | |
124 | (cons 'background-color | |
125 | (cdr (assq 'foreground-color params))) | |
126 | (cons 'mouse-color | |
127 | (cdr (assq 'background-color params))) | |
128 | (cons 'border-color | |
129 | (cdr (assq 'background-color params))))))))) | |
7eadab74 | 130 | |
dc6d9681 JB |
131 | ;; At this point, we know that we have a frame open, so we |
132 | ;; can delete the terminal frame. | |
133 | (delete-frame terminal-frame) | |
134 | (setq terminal-frame nil)) | |
64c669bc JB |
135 | |
136 | ;; No, we're not running a window system. Arrange to cause errors. | |
dc6d9681 | 137 | (setq frame-creation-function |
9198945a MB |
138 | (function |
139 | (lambda (parameters) | |
140 | (error | |
8290babd | 141 | "Can't create multiple frames without a window system")))))) |
64c669bc | 142 | |
7eadab74 JB |
143 | ;;; startup.el calls this function after loading the user's init |
144 | ;;; file. Now default-frame-alist and initial-frame-alist contain | |
145 | ;;; information to which we must react; do what needs to be done. | |
dc6d9681 | 146 | (defun frame-notice-user-settings () |
7eadab74 JB |
147 | |
148 | ;; Creating and deleting frames may shift the selected frame around, | |
149 | ;; and thus the current buffer. Protect against that. We don't | |
150 | ;; want to use save-excursion here, because that may also try to set | |
151 | ;; the buffer of the selected window, which fails when the selected | |
152 | ;; window is the minibuffer. | |
153 | (let ((old-buffer (current-buffer))) | |
154 | ||
155 | ;; If the initial frame is still around, apply initial-frame-alist | |
156 | ;; and default-frame-alist to it. | |
157 | (if (frame-live-p frame-initial-frame) | |
158 | ||
159 | ;; The initial frame we create above always has a minibuffer. | |
160 | ;; If the user wants to remove it, or make it a minibuffer-only | |
161 | ;; frame, then we'll have to delete the current frame and make a | |
162 | ;; new one; you can't remove or add a root window to/from an | |
163 | ;; existing frame. | |
164 | ;; | |
ec558adc JB |
165 | ;; NOTE: default-frame-alist was nil when we created the |
166 | ;; existing frame. We need to explicitly include | |
167 | ;; default-frame-alist in the parameters of the screen we | |
168 | ;; create here, so that its new value, gleaned from the user's | |
169 | ;; .emacs file, will be applied to the existing screen. | |
7eadab74 JB |
170 | (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist) |
171 | (assq 'minibuffer default-frame-alist) | |
172 | '(minibuffer . t))) | |
173 | t)) | |
174 | ;; Create the new frame. | |
175 | (let ((new | |
176 | (new-frame | |
177 | (append initial-frame-alist | |
178 | default-frame-alist | |
179 | (frame-parameters frame-initial-frame))))) | |
180 | ||
181 | ;; The initial frame, which we are about to delete, may be | |
182 | ;; the only frame with a minibuffer. If it is, create a | |
183 | ;; new one. | |
184 | (or (delq frame-initial-frame (minibuffer-frame-list)) | |
185 | (new-frame (append minibuffer-frame-alist | |
186 | '((minibuffer . only))))) | |
187 | ||
188 | ;; If the initial frame is serving as a surrogate | |
189 | ;; minibuffer frame for any frames, we need to wean them | |
190 | ;; onto a new frame. The default-minibuffer-frame | |
191 | ;; variable must be handled similarly. | |
192 | (let ((users-of-initial | |
193 | (filtered-frame-list | |
194 | (function (lambda (frame) | |
195 | (and (not (eq frame frame-initial-frame)) | |
196 | (eq (window-frame | |
197 | (minibuffer-window frame)) | |
198 | frame-initial-frame))))))) | |
199 | (if (or users-of-initial | |
200 | (eq default-minibuffer-frame frame-initial-frame)) | |
201 | ||
202 | ;; Choose an appropriate frame. Prefer frames which | |
203 | ;; are only minibuffers. | |
204 | (let* ((new-surrogate | |
205 | (car | |
206 | (or (filtered-frame-list | |
207 | (function | |
208 | (lambda (frame) | |
209 | (eq (cdr (assq 'minibuffer | |
210 | (frame-parameters frame))) | |
211 | 'only)))) | |
212 | (minibuffer-frame-list)))) | |
213 | (new-minibuffer (minibuffer-window new-surrogate))) | |
214 | ||
215 | (if (eq default-minibuffer-frame frame-initial-frame) | |
216 | (setq default-minibuffer-frame new-surrogate)) | |
217 | ||
218 | ;; Wean the frames using frame-initial-frame as | |
219 | ;; their minibuffer frame. | |
220 | (mapcar | |
221 | (function | |
222 | (lambda (frame) | |
223 | (modify-frame-parameters | |
224 | frame (list (cons 'minibuffer new-minibuffer))))) | |
225 | users-of-initial)))) | |
ec558adc JB |
226 | |
227 | ;; Redirect events enqueued at this frame to the new frame. | |
228 | ;; Is this a good idea? | |
7eadab74 | 229 | (redirect-frame-focus frame-initial-frame new) |
ec558adc | 230 | |
7eadab74 | 231 | ;; Finally, get rid of the old frame. |
0cffbbb9 | 232 | (delete-frame frame-initial-frame t)) |
7eadab74 JB |
233 | |
234 | ;; Otherwise, we don't need all that rigamarole; just apply | |
235 | ;; the new parameters. | |
3f2f8c83 RS |
236 | (let (newparms allparms tail) |
237 | (setq allparms (append initial-frame-alist | |
238 | default-frame-alist)) | |
239 | (setq tail allparms) | |
240 | ;; Find just the parms that have changed since we first | |
241 | ;; made this frame. Those are the ones actually set by | |
242 | ;; the init file. For those parms whose values we already knew | |
243 | ;; (such as those spec'd by command line options) | |
244 | ;; it is undesirable to specify the parm again | |
245 | ;; once the user has seen the frame and been able to alter it | |
246 | ;; manually. | |
247 | (while tail | |
248 | (let (newval oldval) | |
249 | (setq oldval (cdr (assq (car (car tail)) | |
250 | frame-initial-frame-alist))) | |
251 | (setq newval (cdr (assq (car (car tail)) allparms))) | |
252 | (or (eq oldval newval) | |
253 | (setq newparms | |
254 | (cons (cons (car (car tail)) newval) newparms)))) | |
255 | (setq tail (cdr tail))) | |
256 | (modify-frame-parameters frame-initial-frame | |
257 | (nreverse newparms))))) | |
64c669bc | 258 | |
7eadab74 JB |
259 | ;; Restore the original buffer. |
260 | (set-buffer old-buffer) | |
261 | ||
262 | ;; Make sure the initial frame can be GC'd if it is ever deleted. | |
d202f1f2 JB |
263 | ;; Make sure frame-notice-user-settings does nothing if called twice. |
264 | (setq frame-initial-frame nil))) | |
64c669bc JB |
265 | |
266 | \f | |
7eadab74 | 267 | ;;;; Creation of additional frames, and other frame miscellanea |
dc6d9681 | 268 | |
7eadab74 | 269 | ;;; Return some frame other than the current frame, creating one if |
eb8c3be9 | 270 | ;;; necessary. Note that the minibuffer frame, if separate, is not |
7eadab74 | 271 | ;;; considered (see next-frame). |
7253d8e0 | 272 | (defun get-other-frame () |
dc6d9681 JB |
273 | (let ((s (if (equal (next-frame (selected-frame)) (selected-frame)) |
274 | (new-frame) | |
275 | (next-frame (selected-frame))))) | |
64c669bc JB |
276 | s)) |
277 | ||
dc6d9681 JB |
278 | (defun next-multiframe-window () |
279 | "Select the next window, regardless of which frame it is on." | |
64c669bc JB |
280 | (interactive) |
281 | (select-window (next-window (selected-window) | |
282 | (> (minibuffer-depth) 0) | |
283 | t))) | |
284 | ||
dc6d9681 JB |
285 | (defun previous-multiframe-window () |
286 | "Select the previous window, regardless of which frame it is on." | |
64c669bc JB |
287 | (interactive) |
288 | (select-window (previous-window (selected-window) | |
289 | (> (minibuffer-depth) 0) | |
290 | t))) | |
291 | ||
92e443b1 | 292 | ;; Alias, kept temporarily. |
31e1d920 | 293 | (defalias 'new-frame 'make-frame) |
92e443b1 | 294 | (defun make-frame (&optional parameters) |
dc6d9681 | 295 | "Create a new frame, displaying the current buffer. |
bc93c097 | 296 | |
43a2e52c | 297 | Optional argument PARAMETERS is an alist of parameters for the new |
dc6d9681 | 298 | frame. Specifically, PARAMETERS is a list of pairs, each having one |
43a2e52c JB |
299 | of the following forms: |
300 | ||
eaa974e1 | 301 | \(name . STRING) - The frame should be named STRING. |
43a2e52c | 302 | |
eaa974e1 | 303 | \(height . NUMBER) - The frame should be NUMBER text lines high. If |
43a2e52c JB |
304 | this parameter is present, the width parameter must also be |
305 | given. | |
306 | ||
eaa974e1 | 307 | \(width . NUMBER) - The frame should be NUMBER characters in width. |
43a2e52c JB |
308 | If this parameter is present, the height parameter must also |
309 | be given. | |
310 | ||
eaa974e1 | 311 | \(minibuffer . t) - the frame should have a minibuffer |
0ca90494 | 312 | \(minibuffer . nil) - the frame should have no minibuffer |
eaa974e1 JB |
313 | \(minibuffer . only) - the frame should contain only a minibuffer |
314 | \(minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window. | |
43a2e52c | 315 | |
eaa974e1 JB |
316 | The documentation for the function `x-create-frame' describes |
317 | additional frame parameters that Emacs recognizes for X window frames." | |
64c669bc | 318 | (interactive) |
dc6d9681 | 319 | (funcall frame-creation-function parameters)) |
64c669bc | 320 | |
7eadab74 JB |
321 | (defun filtered-frame-list (predicate) |
322 | "Return a list of all live frames which satisfy PREDICATE." | |
323 | (let ((frames (frame-list)) | |
324 | good-frames) | |
325 | (while (consp frames) | |
326 | (if (funcall predicate (car frames)) | |
327 | (setq good-frames (cons (car frames) good-frames))) | |
328 | (setq frames (cdr frames))) | |
329 | good-frames)) | |
330 | ||
331 | (defun minibuffer-frame-list () | |
332 | "Return a list of all frames with their own minibuffers." | |
333 | (filtered-frame-list | |
334 | (function (lambda (frame) | |
335 | (eq frame (window-frame (minibuffer-window frame))))))) | |
336 | ||
58bf6042 JB |
337 | (defun frame-remove-geometry-params (param-list) |
338 | "Return the parameter list PARAM-LIST, but with geometry specs removed. | |
339 | This deletes all bindings in PARAM-LIST for `top', `left', `width', | |
340 | and `height' parameters. | |
341 | Emacs uses this to avoid overriding explicit moves and resizings from | |
342 | the user during startup." | |
343 | (setq param-list (cons nil param-list)) | |
344 | (let ((tail param-list)) | |
345 | (while (consp (cdr tail)) | |
346 | (if (and (consp (car (cdr tail))) | |
347 | (memq (car (car (cdr tail))) '(height width top left))) | |
348 | (setcdr tail (cdr (cdr tail))) | |
349 | (setq tail (cdr tail))))) | |
350 | (cdr param-list)) | |
351 | ||
352 | ||
ceab6935 RM |
353 | (defun other-frame (arg) |
354 | "Select the ARG'th different frame, deiconify and raise it. | |
355 | All frames are arranged in a cyclic order. | |
356 | This command selects the frame ARG steps away in that order. | |
357 | A negative ARG moves in the opposite order." | |
358 | (interactive "p") | |
359 | (let ((frame (selected-frame))) | |
360 | (while (> arg 0) | |
361 | (setq frame (next-frame frame) | |
362 | arg (1- arg))) | |
363 | (while (< arg 0) | |
364 | (setq frame (previous-frame frame) | |
365 | arg (1- arg))) | |
366 | (make-frame-visible frame) | |
367 | (raise-frame frame) | |
368 | (select-frame frame))) | |
64c669bc | 369 | \f |
dc6d9681 JB |
370 | ;;;; Frame configurations |
371 | ||
372 | (defun current-frame-configuration () | |
373 | "Return a list describing the positions and states of all frames. | |
376a7584 JB |
374 | Its car is `frame-configuration'. |
375 | Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG), | |
376 | where | |
377 | FRAME is a frame object, | |
378 | ALIST is an association list specifying some of FRAME's parameters, and | |
379 | WINDOW-CONFIG is a window configuration object for FRAME." | |
380 | (cons 'frame-configuration | |
381 | (mapcar (function | |
382 | (lambda (frame) | |
383 | (list frame | |
384 | (frame-parameters frame) | |
385 | (current-window-configuration frame)))) | |
386 | (frame-list)))) | |
dc6d9681 JB |
387 | |
388 | (defun set-frame-configuration (configuration) | |
389 | "Restore the frames to the state described by CONFIGURATION. | |
390 | Each frame listed in CONFIGURATION has its position, size, window | |
06b1a5ef | 391 | configuration, and other parameters set as specified in CONFIGURATION." |
376a7584 JB |
392 | (or (frame-configuration-p configuration) |
393 | (signal 'wrong-type-argument | |
394 | (list 'frame-configuration-p configuration))) | |
395 | (let ((config-alist (cdr configuration)) | |
396 | frames-to-delete) | |
06b1a5ef | 397 | (mapcar (function |
dc6d9681 | 398 | (lambda (frame) |
376a7584 | 399 | (let ((parameters (assq frame config-alist))) |
06b1a5ef JB |
400 | (if parameters |
401 | (progn | |
98e9d14b JB |
402 | (modify-frame-parameters |
403 | frame | |
404 | ;; Since we can't set a frame's minibuffer status, | |
405 | ;; we might as well omit the parameter altogether. | |
406 | (let* ((parms (nth 1 parameters)) | |
407 | (mini (assq 'minibuffer parms))) | |
408 | (if mini (setq parms (delq mini parms))) | |
409 | parms)) | |
06b1a5ef | 410 | (set-window-configuration (nth 2 parameters))) |
dc6d9681 JB |
411 | (setq frames-to-delete (cons frame frames-to-delete)))))) |
412 | (frame-list)) | |
413 | (mapcar 'delete-frame frames-to-delete))) | |
64c669bc | 414 | |
376a7584 JB |
415 | (defun frame-configuration-p (object) |
416 | "Return non-nil if OBJECT seems to be a frame configuration. | |
417 | Any list whose car is `frame-configuration' is assumed to be a frame | |
418 | configuration." | |
419 | (and (consp object) | |
420 | (eq (car object) 'frame-configuration))) | |
421 | ||
64c669bc | 422 | \f |
dc6d9681 JB |
423 | ;;;; Convenience functions for accessing and interactively changing |
424 | ;;;; frame parameters. | |
64c669bc | 425 | |
151bdc83 | 426 | (defun frame-height (&optional frame) |
dc6d9681 JB |
427 | "Return number of lines available for display on FRAME. |
428 | If FRAME is omitted, describe the currently selected frame." | |
151bdc83 | 429 | (cdr (assq 'height (frame-parameters frame)))) |
dc6d9681 JB |
430 | |
431 | (defun frame-width (&optional frame) | |
432 | "Return number of columns available for display on FRAME. | |
433 | If FRAME is omitted, describe the currently selected frame." | |
151bdc83 | 434 | (cdr (assq 'width (frame-parameters frame)))) |
dc6d9681 | 435 | |
64c669bc | 436 | (defun set-default-font (font-name) |
7eadab74 JB |
437 | "Set the font of the selected frame to FONT. |
438 | When called interactively, prompt for the name of the font to use." | |
64c669bc | 439 | (interactive "sFont name: ") |
dc6d9681 | 440 | (modify-frame-parameters (selected-frame) |
7eadab74 | 441 | (list (cons 'font font-name)))) |
64c669bc | 442 | |
8290babd | 443 | (defun set-background-color (color-name) |
7eadab74 JB |
444 | "Set the background color of the selected frame to COLOR. |
445 | When called interactively, prompt for the name of the color to use." | |
64c669bc | 446 | (interactive "sColor: ") |
dc6d9681 | 447 | (modify-frame-parameters (selected-frame) |
7eadab74 | 448 | (list (cons 'background-color color-name)))) |
64c669bc | 449 | |
8290babd | 450 | (defun set-foreground-color (color-name) |
7eadab74 JB |
451 | "Set the foreground color of the selected frame to COLOR. |
452 | When called interactively, prompt for the name of the color to use." | |
64c669bc | 453 | (interactive "sColor: ") |
dc6d9681 | 454 | (modify-frame-parameters (selected-frame) |
7eadab74 | 455 | (list (cons 'foreground-color color-name)))) |
64c669bc JB |
456 | |
457 | (defun set-cursor-color (color-name) | |
7eadab74 JB |
458 | "Set the text cursor color of the selected frame to COLOR. |
459 | When called interactively, prompt for the name of the color to use." | |
64c669bc | 460 | (interactive "sColor: ") |
dc6d9681 | 461 | (modify-frame-parameters (selected-frame) |
7eadab74 | 462 | (list (cons 'cursor-color color-name)))) |
64c669bc | 463 | |
eaa974e1 | 464 | (defun set-mouse-color (color-name) |
7eadab74 JB |
465 | "Set the color of the mouse pointer of the selected frame to COLOR. |
466 | When called interactively, prompt for the name of the color to use." | |
64c669bc | 467 | (interactive "sColor: ") |
dc6d9681 | 468 | (modify-frame-parameters (selected-frame) |
7eadab74 JB |
469 | (list (cons 'mouse-color color-name)))) |
470 | ||
eaa974e1 JB |
471 | (defun set-border-color (color-name) |
472 | "Set the color of the border of the selected frame to COLOR. | |
473 | When called interactively, prompt for the name of the color to use." | |
474 | (interactive "sColor: ") | |
475 | (modify-frame-parameters (selected-frame) | |
476 | (list (cons 'border-color color-name)))) | |
477 | ||
478 | (defun auto-raise-mode (arg) | |
7eadab74 JB |
479 | "Toggle whether or not the selected frame should auto-raise. |
480 | With arg, turn auto-raise mode on if and only if arg is positive." | |
481 | (interactive "P") | |
482 | (if (null arg) | |
483 | (setq arg | |
484 | (if (cdr (assq 'auto-raise (frame-parameters (selected-frame)))) | |
485 | -1 1))) | |
dc6d9681 | 486 | (modify-frame-parameters (selected-frame) |
7eadab74 JB |
487 | (list (cons 'auto-raise (> arg 0))))) |
488 | ||
eaa974e1 | 489 | (defun auto-lower-mode (arg) |
7eadab74 JB |
490 | "Toggle whether or not the selected frame should auto-lower. |
491 | With arg, turn auto-lower mode on if and only if arg is positive." | |
492 | (interactive "P") | |
493 | (if (null arg) | |
494 | (setq arg | |
495 | (if (cdr (assq 'auto-lower (frame-parameters (selected-frame)))) | |
496 | -1 1))) | |
dc6d9681 | 497 | (modify-frame-parameters (selected-frame) |
7eadab74 JB |
498 | (list (cons 'auto-lower (> arg 0))))) |
499 | ||
7e85c6b5 | 500 | (defun toggle-scroll-bar (arg) |
0ca90494 JB |
501 | "Toggle whether or not the selected frame has vertical scroll bars. |
502 | With arg, turn vertical scroll bars on if and only if arg is positive." | |
7eadab74 JB |
503 | (interactive "P") |
504 | (if (null arg) | |
505 | (setq arg | |
0ca90494 | 506 | (if (cdr (assq 'vertical-scroll-bars |
7eadab74 JB |
507 | (frame-parameters (selected-frame)))) |
508 | -1 1))) | |
dc6d9681 | 509 | (modify-frame-parameters (selected-frame) |
0ca90494 | 510 | (list (cons 'vertical-scroll-bars (> arg 0))))) |
7eadab74 | 511 | |
8290babd | 512 | (defun toggle-horizontal-scroll-bar (arg) |
0ca90494 JB |
513 | "Toggle whether or not the selected frame has horizontal scroll bars. |
514 | With arg, turn horizontal scroll bars on if and only if arg is positive. | |
515 | Horizontal scroll bars aren't implemented yet." | |
7eadab74 | 516 | (interactive "P") |
8290babd | 517 | (error "Horizontal scroll bars aren't implemented yet")) |
64c669bc | 518 | |
64c669bc | 519 | \f |
dc6d9681 | 520 | ;;;; Aliases for backward compatibility with Emacs 18. |
31e1d920 ER |
521 | (defalias 'screen-height 'frame-height) |
522 | (defalias 'screen-width 'frame-width) | |
9e2b097b JB |
523 | |
524 | (defun set-screen-width (cols &optional pretend) | |
525 | "Obsolete function to change the size of the screen to COLS columns.\n\ | |
526 | Optional second arg non-nil means that redisplay should use COLS columns\n\ | |
527 | but that the idea of the actual width of the frame should not be changed.\n\ | |
528 | This function is provided only for compatibility with Emacs 18; new code\n\ | |
fe668515 | 529 | should use `set-frame-width instead'." |
9e2b097b JB |
530 | (set-frame-width (selected-frame) cols pretend)) |
531 | ||
532 | (defun set-screen-height (lines &optional pretend) | |
533 | "Obsolete function to change the height of the screen to LINES lines.\n\ | |
534 | Optional second arg non-nil means that redisplay should use LINES lines\n\ | |
535 | but that the idea of the actual height of the screen should not be changed.\n\ | |
536 | This function is provided only for compatibility with Emacs 18; new code\n\ | |
fe668515 | 537 | should use `set-frame-width' instead." |
9e2b097b JB |
538 | (set-frame-height (selected-frame) lines pretend)) |
539 | ||
540 | (make-obsolete 'screen-height 'frame-height) | |
541 | (make-obsolete 'screen-width 'frame-width) | |
542 | (make-obsolete 'set-screen-width 'set-frame-width) | |
543 | (make-obsolete 'set-screen-height 'set-frame-height) | |
dc6d9681 JB |
544 | |
545 | \f | |
64c669bc | 546 | ;;;; Key bindings |
daa37602 | 547 | (defvar ctl-x-5-map (make-sparse-keymap) |
dc6d9681 | 548 | "Keymap for frame commands.") |
31e1d920 | 549 | (defalias 'ctl-x-5-prefix ctl-x-5-map) |
daa37602 | 550 | (define-key ctl-x-map "5" 'ctl-x-5-prefix) |
64c669bc | 551 | |
dc6d9681 JB |
552 | (define-key ctl-x-5-map "2" 'new-frame) |
553 | (define-key ctl-x-5-map "0" 'delete-frame) | |
ceab6935 | 554 | (define-key ctl-x-5-map "o" 'other-frame) |
49116ac0 | 555 | |
dc6d9681 | 556 | (provide 'frame) |
c88ab9ce | 557 | |
dc6d9681 | 558 | ;;; frame.el ends here |