Mercurial > emacs
annotate src/window.c @ 1308:2660a7053836
* buffer.c: #include intervals.h.
author | Joseph Arceneaux <jla@gnu.org> |
---|---|
date | Fri, 02 Oct 1992 23:43:16 +0000 |
parents | 5c66007ecabb |
children | f03e559aac3e |
rev | line source |
---|---|
265 | 1 /* Window creation, deletion and examination for GNU Emacs. |
2 Does not include redisplay. | |
708 | 3 Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. |
265 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
708 | 9 the Free Software Foundation; either version 2, or (at your option) |
265 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | |
21 #include "config.h" | |
22 #include "lisp.h" | |
23 #include "buffer.h" | |
769 | 24 #include "frame.h" |
265 | 25 #include "window.h" |
26 #include "commands.h" | |
27 #include "indent.h" | |
28 #include "termchar.h" | |
29 #include "disptab.h" | |
522 | 30 #include "keyboard.h" |
265 | 31 |
32 Lisp_Object Qwindowp; | |
33 | |
34 Lisp_Object Fnext_window (), Fdelete_window (), Fselect_window (); | |
35 Lisp_Object Fset_window_buffer (), Fsplit_window (), Frecenter (); | |
36 | |
37 static void delete_all_subwindows (); | |
38 static struct window *decode_window(); | |
39 | |
40 /* This is the window in which the terminal's cursor should | |
41 be left when nothing is being done with it. This must | |
42 always be a leaf window, and its buffer is selected by | |
43 the top level editing loop at the end of each command. | |
44 | |
45 This value is always the same as | |
769 | 46 FRAME_SELECTED_WINDOW (selected_frame). */ |
265 | 47 |
48 Lisp_Object selected_window; | |
49 | |
769 | 50 /* The minibuffer window of the selected frame. |
265 | 51 Note that you cannot test for minibufferness of an arbitrary window |
52 by comparing against this; but you can test for minibufferness of | |
53 the selected window. */ | |
54 Lisp_Object minibuf_window; | |
55 | |
56 /* Non-nil means it is the window for C-M-v to scroll | |
57 when the minibuffer is selected. */ | |
58 Lisp_Object Vminibuf_scroll_window; | |
59 | |
60 /* Non-nil means this is the buffer whose window C-M-v should scroll. */ | |
61 Lisp_Object Vother_window_scroll_buffer; | |
62 | |
63 /* Window that the mouse is over (nil if no mouse support). */ | |
64 Lisp_Object Vmouse_window; | |
65 | |
66 /* Last mouse click data structure (nil if no mouse support). */ | |
67 Lisp_Object Vmouse_event; | |
68 | |
69 /* Non-nil means it's function to call to display temp buffers. */ | |
70 Lisp_Object Vtemp_buffer_show_function; | |
71 | |
72 /* If a window gets smaller than either of these, it is removed. */ | |
73 int window_min_height; | |
74 int window_min_width; | |
75 | |
76 /* Nonzero implies Fdisplay_buffer should create windows. */ | |
77 int pop_up_windows; | |
78 | |
769 | 79 /* Nonzero implies make new frames for Fdisplay_buffer. */ |
80 int pop_up_frames; | |
265 | 81 |
82 /* Non-nil means use this function instead of default */ | |
769 | 83 Lisp_Object Vpop_up_frame_function; |
265 | 84 |
85 /* Function to call to handle Fdisplay_buffer. */ | |
86 Lisp_Object Vdisplay_buffer_function; | |
87 | |
88 /* Fdisplay_buffer always splits the largest window | |
89 if that window is more than this high. */ | |
90 int split_height_threshold; | |
91 | |
92 /* Number of lines of continuity in scrolling by screenfuls. */ | |
93 int next_screen_context_lines; | |
94 | |
95 /* Incremented for each window created. */ | |
96 static int sequence_number; | |
97 | |
98 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
99 | |
100 DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, | |
101 "Returns t if OBJ is a window.") | |
102 (obj) | |
103 Lisp_Object obj; | |
104 { | |
105 return XTYPE (obj) == Lisp_Window ? Qt : Qnil; | |
106 } | |
107 | |
108 Lisp_Object | |
109 make_window () | |
110 { | |
111 register Lisp_Object val; | |
112 register struct window *p; | |
113 | |
114 /* Add sizeof (Lisp_Object) here because sizeof (struct Lisp_Vector) | |
115 includes the first element. */ | |
116 val = Fmake_vector ( | |
117 make_number ((sizeof (struct window) - sizeof (struct Lisp_Vector) | |
118 + sizeof (Lisp_Object)) | |
119 / sizeof (Lisp_Object)), | |
120 Qnil); | |
121 XSETTYPE (val, Lisp_Window); | |
122 p = XWINDOW (val); | |
123 XFASTINT (p->sequence_number) = ++sequence_number; | |
124 XFASTINT (p->left) = XFASTINT (p->top) | |
125 = XFASTINT (p->height) = XFASTINT (p->width) | |
126 = XFASTINT (p->hscroll) = 0; | |
127 XFASTINT (p->last_point_x) = XFASTINT (p->last_point_y) = 0; | |
128 p->start = Fmake_marker (); | |
129 p->pointm = Fmake_marker (); | |
130 XFASTINT (p->use_time) = 0; | |
769 | 131 p->frame = Qnil; |
265 | 132 p->display_table = Qnil; |
133 p->dedicated = Qnil; | |
134 return val; | |
135 } | |
136 | |
137 DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, | |
138 "Return the window that the cursor now appears in and commands apply to.") | |
139 () | |
140 { | |
141 return selected_window; | |
142 } | |
143 | |
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
144 DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
145 "Return the window used now for minibuffers.\n\ |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
146 If the optional argument FRAME is specified, return the minibuffer window\n\ |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
147 used by that frame.") |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
148 (frame) |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
149 Lisp_Object frame; |
265 | 150 { |
769 | 151 #ifdef MULTI_FRAME |
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
152 if (NILP (frame)) |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
153 XSET (frame, Lisp_Frame, selected_frame); |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
154 else |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
155 CHECK_LIVE_FRAME (frame, 0); |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
156 #endif |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
157 |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
158 return FRAME_MINIBUF_WINDOW (XFRAME (frame)); |
265 | 159 } |
160 | |
161 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 1, 1, 0, | |
162 "Returns non-nil if WINDOW is a minibuffer window.") | |
163 (window) | |
164 Lisp_Object window; | |
165 { | |
166 struct window *w = decode_window (window); | |
167 return (MINI_WINDOW_P (w) ? Qt : Qnil); | |
168 } | |
169 | |
170 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, | |
171 Spos_visible_in_window_p, 0, 2, 0, | |
769 | 172 "Return t if position POS is currently on the frame in WINDOW.\n\ |
265 | 173 Returns nil if that position is scrolled vertically out of view.\n\ |
174 POS defaults to point; WINDOW, to the selected window.") | |
175 (pos, window) | |
176 Lisp_Object pos, window; | |
177 { | |
178 register struct window *w; | |
179 register int top; | |
180 register int height; | |
181 register int posint; | |
182 register struct buffer *buf; | |
183 struct position posval; | |
184 | |
485 | 185 if (NILP (pos)) |
265 | 186 posint = point; |
187 else | |
188 { | |
189 CHECK_NUMBER_COERCE_MARKER (pos, 0); | |
190 posint = XINT (pos); | |
191 } | |
192 | |
485 | 193 if (NILP (window)) |
265 | 194 window = selected_window; |
195 else | |
196 CHECK_WINDOW (window, 1); | |
197 w = XWINDOW (window); | |
198 top = marker_position (w->start); | |
199 | |
200 if (posint < top) | |
201 return Qnil; | |
202 | |
203 height = XFASTINT (w->height) - ! MINI_WINDOW_P (w); | |
204 | |
205 buf = XBUFFER (w->buffer); | |
206 if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf)) | |
207 { | |
769 | 208 /* If frame is up to date, |
265 | 209 use the info recorded about how much text fit on it. */ |
210 if (posint < BUF_Z (buf) - XFASTINT (w->window_end_pos) | |
211 || (XFASTINT (w->window_end_vpos) < height)) | |
212 return Qt; | |
213 return Qnil; | |
214 } | |
215 else | |
216 { | |
217 if (posint > BUF_Z (buf)) | |
218 return Qnil; | |
219 | |
220 /* If that info is not correct, calculate afresh */ | |
221 posval = *compute_motion (top, 0, 0, posint, height, 0, | |
222 XFASTINT (w->width) - 1 | |
223 - (XFASTINT (w->width) + XFASTINT (w->left) | |
769 | 224 != FRAME_WIDTH (XFRAME (w->frame))), |
265 | 225 XINT (w->hscroll), 0); |
226 | |
227 return posval.vpos < height ? Qt : Qnil; | |
228 } | |
229 } | |
230 | |
231 static struct window * | |
232 decode_window (window) | |
233 register Lisp_Object window; | |
234 { | |
485 | 235 if (NILP (window)) |
265 | 236 return XWINDOW (selected_window); |
237 | |
238 CHECK_WINDOW (window, 0); | |
239 return XWINDOW (window); | |
240 } | |
241 | |
242 DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, | |
243 "Return the buffer that WINDOW is displaying.") | |
244 (window) | |
245 Lisp_Object window; | |
246 { | |
247 return decode_window (window)->buffer; | |
248 } | |
249 | |
250 DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0, | |
251 "Return the number of lines in WINDOW (including its mode line).") | |
252 (window) | |
253 Lisp_Object window; | |
254 { | |
255 return decode_window (window)->height; | |
256 } | |
257 | |
258 DEFUN ("window-width", Fwindow_width, Swindow_width, 0, 1, 0, | |
259 "Return the number of columns in WINDOW.") | |
260 (window) | |
261 Lisp_Object window; | |
262 { | |
263 register struct window *w = decode_window (window); | |
264 register int width = w->width; | |
265 | |
266 /* If this window does not end at the right margin, | |
267 must deduct one column for the border */ | |
769 | 268 if ((width + w->left) == FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) |
265 | 269 return width; |
270 return width - 1; | |
271 } | |
272 | |
273 DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, | |
274 "Return the number of columns by which WINDOW is scrolled from left margin.") | |
275 (window) | |
276 Lisp_Object window; | |
277 { | |
278 return decode_window (window)->hscroll; | |
279 } | |
280 | |
281 DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, | |
282 "Set number of columns WINDOW is scrolled from left margin to NCOL.\n\ | |
283 NCOL should be zero or positive.") | |
284 (window, ncol) | |
285 register Lisp_Object window, ncol; | |
286 { | |
287 register struct window *w; | |
288 | |
289 CHECK_NUMBER (ncol, 1); | |
290 if (XINT (ncol) < 0) XFASTINT (ncol) = 0; | |
291 if (XFASTINT (ncol) >= (1 << (SHORTBITS - 1))) | |
292 args_out_of_range (ncol, Qnil); | |
293 w = decode_window (window); | |
294 if (w->hscroll != ncol) | |
295 clip_changed = 1; /* Prevent redisplay shortcuts */ | |
296 w->hscroll = ncol; | |
297 return ncol; | |
298 } | |
299 | |
300 DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0, | |
301 "Return a list of the edge coordinates of WINDOW.\n\ | |
769 | 302 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.\n\ |
265 | 303 RIGHT is one more than the rightmost column used by WINDOW,\n\ |
304 and BOTTOM is one more than the bottommost row used by WINDOW\n\ | |
305 and its mode-line.") | |
306 (window) | |
307 Lisp_Object window; | |
308 { | |
309 register struct window *w = decode_window (window); | |
310 | |
311 return Fcons (w->left, Fcons (w->top, | |
312 Fcons (make_number (XFASTINT (w->left) + XFASTINT (w->width)), | |
313 Fcons (make_number (XFASTINT (w->top) | |
314 + XFASTINT (w->height)), | |
315 Qnil)))); | |
316 } | |
317 | |
432 | 318 /* Test if the character at column *x, row *y is within window *w. |
319 If it is not, return 0; | |
320 if it is in the window's text area, | |
321 set *x and *y to its location relative to the upper left corner | |
322 of the window, and | |
323 return 1; | |
324 if it is on the window's modeline, return 2; | |
325 if it is on the border between the window and its right sibling, | |
326 return 3. */ | |
327 static int | |
328 coordinates_in_window (w, x, y) | |
329 register struct window *w; | |
330 register int *x, *y; | |
331 { | |
332 register int left = XINT (w->left); | |
333 register int width = XINT (w->width); | |
334 register int window_height = XINT (w->height); | |
335 register int top = XFASTINT (w->top); | |
336 | |
337 if ( *x < left || *x >= left + width | |
338 || *y < top || *y >= top + window_height) | |
339 return 0; | |
340 | |
341 /* Is the character is the mode line? */ | |
342 if (*y == top + window_height - 1 | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
343 && ! MINI_WINDOW_P (w)) |
432 | 344 return 2; |
345 | |
346 /* Is the character in the right border? */ | |
347 if (*x == left + width - 1 | |
769 | 348 && left + width != FRAME_WIDTH (XFRAME (w->frame))) |
432 | 349 return 3; |
350 | |
351 *x -= left; | |
352 *y -= top; | |
353 return 1; | |
354 } | |
355 | |
356 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | |
357 Scoordinates_in_window_p, 2, 2, 0, | |
358 "Return non-nil if COORDINATES are in WINDOW.\n\ | |
708 | 359 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ |
769 | 360 measured in characters from the upper-left corner of the frame.\n\ |
708 | 361 (0 . 0) denotes the character in the upper left corner of the\n\ |
769 | 362 frame.\n\ |
432 | 363 If COORDINATES are in the text portion of WINDOW,\n\ |
364 the coordinates relative to the window are returned.\n\ | |
732 | 365 If they are in the mode line of WINDOW, `mode-line' is returned.\n\ |
432 | 366 If they are on the border between WINDOW and its right sibling,\n\ |
732 | 367 `vertical-line' is returned.") |
432 | 368 (coordinates, window) |
369 register Lisp_Object coordinates, window; | |
370 { | |
371 int x, y; | |
372 | |
373 CHECK_WINDOW (window, 0); | |
374 CHECK_CONS (coordinates, 1); | |
375 x = XINT (Fcar (coordinates)); | |
376 y = XINT (Fcdr (coordinates)); | |
377 | |
378 switch (coordinates_in_window (XWINDOW (window), &x, &y)) | |
379 { | |
380 case 0: /* NOT in window at all. */ | |
381 return Qnil; | |
382 | |
383 case 1: /* In text part of window. */ | |
384 return Fcons (x, y); | |
385 | |
386 case 2: /* In mode line of window. */ | |
387 return Qmode_line; | |
388 | |
389 case 3: /* On right border of window. */ | |
732 | 390 return Qvertical_line; |
432 | 391 |
392 default: | |
393 abort (); | |
394 } | |
395 } | |
396 | |
265 | 397 /* Find the window containing column x, row y, and return it as a |
432 | 398 Lisp_Object. If x, y is on the window's modeline, set *part |
399 to 1; if it is on the separating line between the window and its | |
400 right sibling, set it to 2; otherwise set it to 0. If there is no | |
401 window under x, y return nil and leave *part unmodified. */ | |
265 | 402 Lisp_Object |
769 | 403 window_from_coordinates (frame, x, y, part) |
404 FRAME_PTR frame; | |
265 | 405 int x, y; |
432 | 406 int *part; |
265 | 407 { |
408 register Lisp_Object tem, first; | |
409 | |
769 | 410 tem = first = FRAME_SELECTED_WINDOW (frame); |
265 | 411 |
432 | 412 do |
265 | 413 { |
414 int found = coordinates_in_window (XWINDOW (tem), &x, &y); | |
415 | |
416 if (found) | |
417 { | |
432 | 418 *part = found - 1; |
265 | 419 return tem; |
420 } | |
421 | |
432 | 422 tem = Fnext_window (tem, Qt, Qlambda); |
265 | 423 } |
432 | 424 while (! EQ (tem, first)); |
425 | |
426 return Qnil; | |
265 | 427 } |
428 | |
681
026f978690be
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
555
diff
changeset
|
429 DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, |
769 | 430 "Return window containing row ROW, column COLUMN on FRAME.\n\ |
431 If omitted, FRAME defaults to the currently selected frame.\n\ | |
432 The top left corner of the frame is considered to be row 0,\n\ | |
548 | 433 column 0.") |
769 | 434 (row, column, frame) |
435 Lisp_Object row, column, frame; | |
265 | 436 { |
437 int part; | |
438 | |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
439 #ifdef MULTI_FRAME |
769 | 440 if (NILP (frame)) |
441 XSET (frame, Lisp_Frame, selected_frame); | |
432 | 442 else |
769 | 443 CHECK_LIVE_FRAME (frame, 2); |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
444 #endif |
548 | 445 CHECK_NUMBER (row, 0); |
446 CHECK_NUMBER (column, 1); | |
265 | 447 |
769 | 448 return window_from_coordinates (XFRAME (frame), |
548 | 449 XINT (row), XINT (column), |
265 | 450 &part); |
451 } | |
452 | |
453 DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, | |
454 "Return current value of point in WINDOW.\n\ | |
455 For a nonselected window, this is the value point would have\n\ | |
456 if that window were selected.\n\ | |
457 \n\ | |
458 Note that, when WINDOW is the selected window and its buffer\n\ | |
459 is also currently selected, the value returned is the same as (point).\n\ | |
460 It would be more strictly correct to return the `top-level' value\n\ | |
461 of point, outside of any save-excursion forms.\n\ | |
462 But that is hard to define.") | |
463 (window) | |
464 Lisp_Object window; | |
465 { | |
466 register struct window *w = decode_window (window); | |
467 | |
468 if (w == XWINDOW (selected_window) | |
469 && current_buffer == XBUFFER (w->buffer)) | |
470 return Fpoint (); | |
471 return Fmarker_position (w->pointm); | |
472 } | |
473 | |
474 DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, | |
475 "Return position at which display currently starts in WINDOW.") | |
476 (window) | |
477 Lisp_Object window; | |
478 { | |
479 return Fmarker_position (decode_window (window)->start); | |
480 } | |
481 | |
482 DEFUN ("window-end", Fwindow_end, Swindow_end, 0, 1, 0, | |
483 "Return position at which display currently ends in WINDOW.") | |
484 (window) | |
485 Lisp_Object window; | |
486 { | |
487 Lisp_Object value; | |
488 struct window *w = decode_window (window); | |
489 | |
490 XSET (value, Lisp_Int, | |
491 BUF_Z (current_buffer) - XFASTINT (w->window_end_pos)); | |
492 | |
493 return value; | |
494 } | |
495 | |
496 DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, | |
497 "Make point value in WINDOW be at position POS in WINDOW's buffer.") | |
498 (window, pos) | |
499 Lisp_Object window, pos; | |
500 { | |
501 register struct window *w = decode_window (window); | |
502 | |
503 CHECK_NUMBER_COERCE_MARKER (pos, 1); | |
504 if (w == XWINDOW (selected_window)) | |
505 Fgoto_char (pos); | |
506 else | |
507 set_marker_restricted (w->pointm, pos, w->buffer); | |
508 | |
509 return pos; | |
510 } | |
511 | |
512 DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, | |
513 "Make display in WINDOW start at position POS in WINDOW's buffer.\n\ | |
514 Optional third arg NOFORCE non-nil inhibits next redisplay\n\ | |
515 from overriding motion of point in order to display at this exact start.") | |
516 (window, pos, noforce) | |
517 Lisp_Object window, pos, noforce; | |
518 { | |
519 register struct window *w = decode_window (window); | |
520 | |
521 CHECK_NUMBER_COERCE_MARKER (pos, 1); | |
522 set_marker_restricted (w->start, pos, w->buffer); | |
523 /* this is not right, but much easier than doing what is right. */ | |
524 w->start_at_line_beg = Qnil; | |
485 | 525 if (NILP (noforce)) |
265 | 526 w->force_start = Qt; |
527 w->update_mode_line = Qt; | |
528 XFASTINT (w->last_modified) = 0; | |
338 | 529 if (!EQ (window, selected_window)) |
530 windows_or_buffers_changed++; | |
265 | 531 return pos; |
532 } | |
533 | |
534 DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, | |
535 1, 1, 0, | |
536 "Return WINDOW's dedicated object, usually t or nil.\n\ | |
537 See also `set-window-buffer-dedicated'.") | |
538 (window) | |
539 Lisp_Object window; | |
540 { | |
541 return decode_window (window)->dedicated; | |
542 } | |
543 | |
722
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
544 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, |
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
545 Sset_window_dedicated_p, 2, 2, 0, |
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
546 "Control whether WINDOW is dedicated to the buffer it displays.\n\ |
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
547 If it is dedicated, Emacs will not automatically change\n\ |
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
548 which buffer appears in it.\n\ |
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
549 The second argument is the new value for the dedication flag;\n\ |
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
550 non-nil means yes.") |
265 | 551 (window, arg) |
552 Lisp_Object window, arg; | |
553 { | |
554 register struct window *w = decode_window (window); | |
555 | |
485 | 556 if (NILP (arg)) |
265 | 557 w->dedicated = Qnil; |
558 else | |
722
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
559 w->dedicated = Qt; |
265 | 560 |
561 return w->dedicated; | |
562 } | |
563 | |
564 DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, | |
565 0, 1, 0, | |
566 "Return the display-table that WINDOW is using.") | |
567 (window) | |
568 Lisp_Object window; | |
569 { | |
570 return decode_window (window)->display_table; | |
571 } | |
572 | |
573 /* Get the display table for use currently on window W. | |
574 This is either W's display table or W's buffer's display table. | |
575 Ignore the specified tables if they are not valid; | |
576 if no valid table is specified, return 0. */ | |
577 | |
578 struct Lisp_Vector * | |
579 window_display_table (w) | |
580 struct window *w; | |
581 { | |
582 Lisp_Object tem; | |
583 tem = w->display_table; | |
584 if (XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == DISP_TABLE_SIZE) | |
585 return XVECTOR (tem); | |
586 tem = XBUFFER (w->buffer)->display_table; | |
587 if (XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == DISP_TABLE_SIZE) | |
588 return XVECTOR (tem); | |
589 tem = Vstandard_display_table; | |
590 if (XTYPE (tem) == Lisp_Vector && XVECTOR (tem)->size == DISP_TABLE_SIZE) | |
591 return XVECTOR (tem); | |
592 return 0; | |
593 } | |
594 | |
555 | 595 DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, |
265 | 596 "Set WINDOW's display-table to TABLE.") |
597 (window, table) | |
598 register Lisp_Object window, table; | |
599 { | |
600 register struct window *w; | |
601 register Lisp_Object z; /* Return value. */ | |
602 | |
603 w = decode_window (window); | |
604 w->display_table = table; | |
605 return table; | |
606 } | |
607 | |
608 /* Record info on buffer window w is displaying | |
609 when it is about to cease to display that buffer. */ | |
610 static | |
611 unshow_buffer (w) | |
612 register struct window *w; | |
613 { | |
614 Lisp_Object buf = w->buffer; | |
615 | |
616 if (XBUFFER (buf) != XMARKER (w->pointm)->buffer) | |
617 abort (); | |
618 | |
619 if (w == XWINDOW (selected_window) | |
620 || ! EQ (buf, XWINDOW (selected_window)->buffer)) | |
621 /* Do this except when the selected window's buffer | |
622 is being removed from some other window. */ | |
623 XBUFFER (buf)->last_window_start = marker_position (w->start); | |
624 | |
625 /* Point in the selected window's buffer | |
626 is actually stored in that buffer, and the window's pointm isn't used. | |
627 So don't clobber point in that buffer. */ | |
628 if (! EQ (buf, XWINDOW (selected_window)->buffer)) | |
629 BUF_PT (XBUFFER (buf)) | |
630 = clip_to_bounds (BUF_BEGV (XBUFFER (buf)), | |
631 marker_position (w->pointm), | |
632 BUF_ZV (XBUFFER (buf))); | |
633 } | |
634 | |
635 /* Put replacement into the window structure in place of old. */ | |
636 static | |
637 replace_window (old, replacement) | |
638 Lisp_Object old, replacement; | |
639 { | |
640 register Lisp_Object tem; | |
641 register struct window *o = XWINDOW (old), *p = XWINDOW (replacement); | |
642 | |
769 | 643 /* If OLD is its frame's root_window, then replacement is the new |
644 root_window for that frame. */ | |
265 | 645 |
769 | 646 if (old == FRAME_ROOT_WINDOW (XFRAME (o->frame))) |
647 FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement; | |
265 | 648 |
649 p->left = o->left; | |
650 p->top = o->top; | |
651 p->width = o->width; | |
652 p->height = o->height; | |
653 | |
654 p->next = tem = o->next; | |
485 | 655 if (!NILP (tem)) |
265 | 656 XWINDOW (tem)->prev = replacement; |
657 | |
658 p->prev = tem = o->prev; | |
485 | 659 if (!NILP (tem)) |
265 | 660 XWINDOW (tem)->next = replacement; |
661 | |
662 p->parent = tem = o->parent; | |
485 | 663 if (!NILP (tem)) |
265 | 664 { |
665 if (EQ (XWINDOW (tem)->vchild, old)) | |
666 XWINDOW (tem)->vchild = replacement; | |
667 if (EQ (XWINDOW (tem)->hchild, old)) | |
668 XWINDOW (tem)->hchild = replacement; | |
669 } | |
670 | |
671 /*** Here, if replacement is a vertical combination | |
672 and so is its new parent, we should make replacement's | |
673 children be children of that parent instead. ***/ | |
674 } | |
675 | |
676 DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "", | |
677 "Remove WINDOW from the display. Default is selected window.") | |
678 (window) | |
679 register Lisp_Object window; | |
680 { | |
681 register Lisp_Object tem, parent, sib; | |
682 register struct window *p; | |
683 register struct window *par; | |
684 | |
485 | 685 if (NILP (window)) |
265 | 686 window = selected_window; |
687 else | |
688 CHECK_WINDOW (window, 0); | |
689 | |
690 p = XWINDOW (window); | |
691 parent = p->parent; | |
485 | 692 if (NILP (parent)) |
265 | 693 error ("Attempt to delete minibuffer or sole ordinary window"); |
694 par = XWINDOW (parent); | |
695 | |
696 windows_or_buffers_changed++; | |
697 | |
698 if (EQ (window, selected_window)) | |
699 Fselect_window (Fnext_window (window, Qnil, Qnil)); | |
700 | |
701 tem = p->buffer; | |
702 /* tem is null for dummy parent windows | |
703 (which have inferiors but not any contents themselves) */ | |
485 | 704 if (!NILP (tem)) |
265 | 705 { |
706 unshow_buffer (p); | |
707 unchain_marker (p->pointm); | |
708 unchain_marker (p->start); | |
709 p->buffer = Qnil; | |
710 } | |
711 | |
712 tem = p->next; | |
485 | 713 if (!NILP (tem)) |
265 | 714 XWINDOW (tem)->prev = p->prev; |
715 | |
716 tem = p->prev; | |
485 | 717 if (!NILP (tem)) |
265 | 718 XWINDOW (tem)->next = p->next; |
719 | |
720 if (EQ (window, par->hchild)) | |
721 par->hchild = p->next; | |
722 if (EQ (window, par->vchild)) | |
723 par->vchild = p->next; | |
724 | |
725 /* Find one of our siblings to give our space to. */ | |
726 sib = p->prev; | |
485 | 727 if (NILP (sib)) |
265 | 728 { |
729 /* If p gives its space to its next sibling, that sibling needs | |
730 to have its top/left side pulled back to where p's is. | |
731 set_window_{height,width} will re-position the sibling's | |
732 children. */ | |
733 sib = p->next; | |
734 XFASTINT (XWINDOW (sib)->top) = p->top; | |
735 XFASTINT (XWINDOW (sib)->left) = p->left; | |
736 } | |
737 | |
738 /* Stretch that sibling. */ | |
485 | 739 if (!NILP (par->vchild)) |
265 | 740 set_window_height (sib, |
741 XFASTINT (XWINDOW (sib)->height) + XFASTINT (p->height), | |
742 1); | |
485 | 743 if (!NILP (par->hchild)) |
265 | 744 set_window_width (sib, |
745 XFASTINT (XWINDOW (sib)->width) + XFASTINT (p->width), | |
746 1); | |
747 | |
748 /* If parent now has only one child, | |
749 put the child into the parent's place. */ | |
750 | |
751 tem = par->hchild; | |
485 | 752 if (NILP (tem)) |
265 | 753 tem = par->vchild; |
485 | 754 if (NILP (XWINDOW (tem)->next)) |
265 | 755 replace_window (parent, tem); |
756 return Qnil; | |
757 } | |
758 | |
432 | 759 |
769 | 760 extern Lisp_Object next_frame (), prev_frame (); |
432 | 761 |
762 DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0, | |
763 "Return next window after WINDOW in canonical ordering of windows.\n\ | |
764 If omitted, WINDOW defaults to the selected window.\n\ | |
765 \n\ | |
766 Optional second arg MINIBUF t means count the minibuffer window even\n\ | |
767 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\ | |
768 it is active. MINIBUF neither t nor nil means not to count the\n\ | |
769 minibuffer even if it is active.\n\ | |
770 \n\ | |
769 | 771 Several frames may share a single minibuffer; if the minibuffer\n\ |
772 counts, all windows on all frames that share that minibuffer count\n\ | |
432 | 773 too. This means that next-window may be used to iterate through the\n\ |
769 | 774 set of windows even when the minibuffer is on another frame. If the\n\ |
775 minibuffer does not count, only windows from WINDOW's frame count.\n\ | |
432 | 776 \n\ |
769 | 777 Optional third arg ALL-FRAMES t means include windows on all frames.\n\ |
778 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\ | |
779 above. If neither nil nor t, restrict to WINDOW's frame.") | |
780 (window, minibuf, all_frames) | |
781 register Lisp_Object window, minibuf, all_frames; | |
265 | 782 { |
432 | 783 register Lisp_Object tem; |
784 Lisp_Object start_window; | |
265 | 785 |
485 | 786 if (NILP (window)) |
432 | 787 window = selected_window; |
788 else | |
789 CHECK_WINDOW (window, 0); | |
790 | |
791 start_window = window; | |
792 | |
793 /* minibuf == nil may or may not include minibuffers. | |
794 Decide if it does. */ | |
485 | 795 if (NILP (minibuf)) |
432 | 796 minibuf = (minibuf_level ? Qt : Qlambda); |
797 | |
769 | 798 /* all_frames == nil doesn't specify which frames to include. |
799 Decide which frames it includes. */ | |
800 if (NILP (all_frames)) | |
801 all_frames = (EQ (minibuf, Qt) | |
802 ? (FRAME_MINIBUF_WINDOW | |
803 (XFRAME | |
804 (WINDOW_FRAME | |
432 | 805 (XWINDOW (window))))) |
806 : Qnil); | |
769 | 807 else if (! EQ (all_frames, Qt)) |
808 all_frames = Qnil; | |
432 | 809 |
265 | 810 /* Do this loop at least once, to get the next window, and perhaps |
811 again, if we hit the minibuffer and that is not acceptable. */ | |
812 do | |
813 { | |
814 /* Find a window that actually has a next one. This loop | |
815 climbs up the tree. */ | |
485 | 816 while (tem = XWINDOW (window)->next, NILP (tem)) |
817 if (tem = XWINDOW (window)->parent, !NILP (tem)) | |
265 | 818 window = tem; |
432 | 819 else |
265 | 820 { |
769 | 821 /* We've reached the end of this frame. |
822 Which other frames are acceptable? */ | |
823 tem = WINDOW_FRAME (XWINDOW (window)); | |
824 #ifdef MULTI_FRAME | |
825 if (! NILP (all_frames)) | |
826 tem = next_frame (tem, all_frames); | |
432 | 827 #endif |
769 | 828 tem = FRAME_ROOT_WINDOW (XFRAME (tem)); |
432 | 829 |
265 | 830 break; |
831 } | |
832 | |
833 window = tem; | |
432 | 834 |
265 | 835 /* If we're in a combination window, find its first child and |
836 recurse on that. Otherwise, we've found the window we want. */ | |
837 while (1) | |
838 { | |
485 | 839 if (!NILP (XWINDOW (window)->hchild)) |
265 | 840 window = XWINDOW (window)->hchild; |
485 | 841 else if (!NILP (XWINDOW (window)->vchild)) |
265 | 842 window = XWINDOW (window)->vchild; |
843 else break; | |
844 } | |
845 } | |
432 | 846 /* Which windows are acceptible? |
847 Exit the loop and accept this window if | |
265 | 848 this isn't a minibuffer window, or |
432 | 849 we're accepting minibuffer windows, or |
850 we've come all the way around and we're back at the original window. */ | |
265 | 851 while (MINI_WINDOW_P (XWINDOW (window)) |
432 | 852 && ! EQ (minibuf, Qt) |
853 && window != start_window); | |
265 | 854 |
855 return window; | |
856 } | |
857 | |
432 | 858 DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0, |
859 "Return the window preceeding WINDOW in canonical ordering of windows.\n\ | |
860 If omitted, WINDOW defaults to the selected window.\n\ | |
861 \n\ | |
862 Optional second arg MINIBUF t means count the minibuffer window even\n\ | |
863 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\ | |
864 it is active. MINIBUF neither t nor nil means not to count the\n\ | |
865 minibuffer even if it is active.\n\ | |
866 \n\ | |
769 | 867 Several frames may share a single minibuffer; if the minibuffer\n\ |
868 counts, all windows on all frames that share that minibuffer count\n\ | |
432 | 869 too. This means that previous-window may be used to iterate through\n\ |
769 | 870 the set of windows even when the minibuffer is on another frame. If\n\ |
871 the minibuffer does not count, only windows from WINDOW's frame\n\ | |
432 | 872 count.\n\ |
873 \n\ | |
769 | 874 Optional third arg ALL-FRAMES t means include windows on all frames.\n\ |
875 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\ | |
876 above. If neither nil nor t, restrict to WINDOW's frame.") | |
877 (window, minibuf, all_frames) | |
878 register Lisp_Object window, minibuf, all_frames; | |
265 | 879 { |
880 register Lisp_Object tem; | |
432 | 881 Lisp_Object start_window; |
265 | 882 |
485 | 883 if (NILP (window)) |
265 | 884 window = selected_window; |
885 else | |
886 CHECK_WINDOW (window, 0); | |
887 | |
432 | 888 start_window = window; |
265 | 889 |
432 | 890 /* minibuf == nil may or may not include minibuffers. |
891 Decide if it does. */ | |
485 | 892 if (NILP (minibuf)) |
432 | 893 minibuf = (minibuf_level ? Qt : Qlambda); |
265 | 894 |
769 | 895 /* all_frames == nil doesn't specify which frames to include. |
896 Decide which frames it includes. */ | |
897 if (NILP (all_frames)) | |
898 all_frames = (EQ (minibuf, Qt) | |
899 ? (FRAME_MINIBUF_WINDOW | |
900 (XFRAME | |
901 (WINDOW_FRAME | |
432 | 902 (XWINDOW (window))))) |
903 : Qnil); | |
769 | 904 else if (! EQ (all_frames, Qt)) |
905 all_frames = Qnil; | |
265 | 906 |
907 /* Do this loop at least once, to get the previous window, and perhaps | |
908 again, if we hit the minibuffer and that is not acceptable. */ | |
909 do | |
910 { | |
911 /* Find a window that actually has a previous one. This loop | |
912 climbs up the tree. */ | |
485 | 913 while (tem = XWINDOW (window)->prev, NILP (tem)) |
914 if (tem = XWINDOW (window)->parent, !NILP (tem)) | |
265 | 915 window = tem; |
432 | 916 else |
265 | 917 { |
769 | 918 /* We have found the top window on the frame. |
919 Which frames are acceptable? */ | |
920 tem = WINDOW_FRAME (XWINDOW (window)); | |
921 #ifdef MULTI_FRAME | |
922 if (! NILP (all_frames)) | |
923 tem = next_frame (tem, all_frames); | |
265 | 924 #endif |
769 | 925 tem = FRAME_ROOT_WINDOW (XFRAME (tem)); |
432 | 926 |
265 | 927 break; |
928 } | |
929 | |
930 window = tem; | |
931 /* If we're in a combination window, find its last child and | |
932 recurse on that. Otherwise, we've found the window we want. */ | |
933 while (1) | |
934 { | |
485 | 935 if (!NILP (XWINDOW (window)->hchild)) |
265 | 936 window = XWINDOW (window)->hchild; |
485 | 937 else if (!NILP (XWINDOW (window)->vchild)) |
265 | 938 window = XWINDOW (window)->vchild; |
939 else break; | |
485 | 940 while (tem = XWINDOW (window)->next, !NILP (tem)) |
265 | 941 window = tem; |
942 } | |
943 } | |
432 | 944 /* Which windows are acceptable? |
945 Exit the loop and accept this window if | |
265 | 946 this isn't a minibuffer window, or |
432 | 947 we're accepting minibuffer windows, or |
948 we've come all the way around and we're back at the original window. */ | |
265 | 949 while (MINI_WINDOW_P (XWINDOW (window)) |
432 | 950 && !EQ (minibuf, Qt) |
951 && window != start_window); | |
265 | 952 |
953 return window; | |
954 } | |
955 | |
338 | 956 DEFUN ("other-window", Fother_window, Sother_window, 1, 2, "p", |
769 | 957 "Select the ARG'th different window on this frame.\n\ |
958 All windows on current frame are arranged in a cyclic order.\n\ | |
265 | 959 This command selects the window ARG steps away in that order.\n\ |
960 A negative ARG moves in the opposite order. If the optional second\n\ | |
769 | 961 argument ALL_FRAMES is non-nil, cycle through all frames.") |
962 (n, all_frames) | |
963 register Lisp_Object n, all_frames; | |
265 | 964 { |
965 register int i; | |
966 register Lisp_Object w; | |
967 | |
968 CHECK_NUMBER (n, 0); | |
969 w = selected_window; | |
970 i = XINT (n); | |
971 | |
972 while (i > 0) | |
973 { | |
769 | 974 w = Fnext_window (w, Qnil, all_frames); |
265 | 975 i--; |
976 } | |
977 while (i < 0) | |
978 { | |
769 | 979 w = Fprevious_window (w, Qnil, all_frames); |
265 | 980 i++; |
981 } | |
982 Fselect_window (w); | |
983 return Qnil; | |
984 } | |
985 | |
986 /* Look at all windows, performing an operation specified by TYPE | |
987 with argument OBJ. | |
769 | 988 If FRAMES is Qt, look at all frames, if Qnil, look at just the selected |
989 frame. If FRAMES is a frame, just look at windows on that frame. | |
265 | 990 If MINI is non-zero, perform the operation on minibuffer windows too. |
991 */ | |
992 | |
993 enum window_loop | |
994 { | |
995 WINDOW_LOOP_UNUSED, | |
996 GET_BUFFER_WINDOW, /* Arg is buffer */ | |
997 GET_LRU_WINDOW, /* Arg is t for full-width windows only */ | |
998 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */ | |
999 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ | |
1000 GET_LARGEST_WINDOW, | |
1001 UNSHOW_BUFFER, /* Arg is buffer */ | |
1002 }; | |
1003 | |
1004 static Lisp_Object | |
769 | 1005 window_loop (type, obj, mini, frames) |
265 | 1006 enum window_loop type; |
769 | 1007 register Lisp_Object obj, frames; |
265 | 1008 int mini; |
1009 { | |
1010 register Lisp_Object w; | |
1011 register Lisp_Object best_window; | |
1012 register Lisp_Object next_window; | |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1013 register Lisp_Object last_window; |
769 | 1014 FRAME_PTR frame; |
265 | 1015 |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1016 #ifdef MULTI_FRAME |
769 | 1017 /* If we're only looping through windows on a particular frame, |
1018 frame points to that frame. If we're looping through windows | |
1019 on all frames, frame is 0. */ | |
1020 if (FRAMEP (frames)) | |
1021 frame = XFRAME (frames); | |
1022 else if (NILP (frames)) | |
1023 frame = selected_frame; | |
265 | 1024 else |
769 | 1025 frame = 0; |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1026 #else |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1027 frame = 0; |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1028 #endif |
265 | 1029 |
1030 /* Pick a window to start with. */ | |
1031 if (XTYPE (obj) == Lisp_Window) | |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1032 w = obj; |
769 | 1033 else if (frame) |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1034 w = FRAME_SELECTED_WINDOW (frame); |
265 | 1035 else |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1036 w = FRAME_SELECTED_WINDOW (selected_frame); |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1037 |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1038 /* Figure out the last window we're going to mess with. Since |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1039 Fnext_window, given the same options, is guaranteed to go in a |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1040 ring, we can just use Fprevious_window to find the last one. |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1041 |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1042 We can't just wait until we hit the first window again, because |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1043 it might be deleted. */ |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1044 |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1045 #ifdef MULTI_FRAME |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1046 if (frame) |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1047 last_window = Fprevious_window (w, (mini ? Qt : Qnil), Qlambda); |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1048 else |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1049 #endif /* MULTI_FRAME */ |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1050 /* We know frame is 0, so we're looping through all frames. |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1051 Or we know this isn't a MULTI_FRAME Emacs, so who cares? */ |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1052 last_window = Fprevious_window (w, mini ? Qt : Qnil, Qt); |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1053 |
265 | 1054 best_window = Qnil; |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1055 for (;;) |
265 | 1056 { |
1057 /* Pick the next window now, since some operations will delete | |
1058 the current window. */ | |
769 | 1059 #ifdef MULTI_FRAME |
1060 if (frame) | |
432 | 1061 next_window = Fnext_window (w, (mini ? Qt : Qnil), Qlambda); |
265 | 1062 else |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1063 #endif /* MULTI_FRAME */ |
769 | 1064 /* We know frame is 0, so we're looping through all frames. |
1065 Or we know this isn't a MULTI_FRAME Emacs, so who cares? */ | |
265 | 1066 next_window = Fnext_window (w, mini ? Qt : Qnil, Qt); |
1067 | |
1068 if (!MINI_WINDOW_P (XWINDOW (w)) | |
1069 || (mini && minibuf_level > 0)) | |
1070 switch (type) | |
1071 { | |
1072 case GET_BUFFER_WINDOW: | |
1073 #if 0 | |
769 | 1074 /* Ignore invisible and iconified frames. */ |
1075 if (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (w)))) | |
1076 || FRAME_ICONIFIED_P (XFRAME (WINDOW_FRAME (XWINDOW (w))))) | |
265 | 1077 break; |
1078 #endif | |
1079 if (XBUFFER (XWINDOW (w)->buffer) == XBUFFER (obj)) | |
1080 return w; | |
1081 break; | |
1082 | |
1083 case GET_LRU_WINDOW: | |
1084 /* t as arg means consider only full-width windows */ | |
732 | 1085 if (!NILP (obj) && XFASTINT (XWINDOW (w)->width) |
769 | 1086 != FRAME_WIDTH (frame)) |
265 | 1087 break; |
1088 #if 0 | |
769 | 1089 /* Ignore invisible and iconified frames. */ |
1090 if (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (w)))) | |
1091 || FRAME_ICONIFIED_P (XFRAME (WINDOW_FRAME (XWINDOW (w))))) | |
265 | 1092 break; |
1093 #endif | |
1094 /* Ignore dedicated windows and minibuffers. */ | |
1095 if (MINI_WINDOW_P (XWINDOW (w)) | |
485 | 1096 || !NILP (XWINDOW (w)->dedicated)) |
265 | 1097 break; |
485 | 1098 if (NILP (best_window) |
265 | 1099 || (XFASTINT (XWINDOW (best_window)->use_time) |
1100 > XFASTINT (XWINDOW (w)->use_time))) | |
1101 best_window = w; | |
1102 break; | |
1103 | |
1104 case DELETE_OTHER_WINDOWS: | |
1105 if (XWINDOW (w) != XWINDOW (obj)) | |
1106 Fdelete_window (w); | |
1107 break; | |
1108 | |
1109 case DELETE_BUFFER_WINDOWS: | |
1110 if (EQ (XWINDOW (w)->buffer, obj)) | |
1111 { | |
1112 /* If we're deleting the buffer displayed in the only window | |
769 | 1113 on the frame, find a new buffer to display there. */ |
485 | 1114 if (NILP (XWINDOW (w)->parent)) |
265 | 1115 { |
1116 Lisp_Object new_buffer = Fother_buffer (obj); | |
485 | 1117 if (NILP (new_buffer)) |
265 | 1118 new_buffer |
1119 = Fget_buffer_create (build_string ("*scratch*")); | |
1120 Fset_window_buffer (w, new_buffer); | |
1121 Fset_buffer (XWINDOW (w)->buffer); | |
1122 } | |
1123 else | |
1124 Fdelete_window (w); | |
1125 } | |
1126 break; | |
1127 | |
1128 case GET_LARGEST_WINDOW: | |
1129 #if 0 | |
769 | 1130 /* Ignore invisible and iconified frames. */ |
1131 if (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (w)))) | |
1132 || FRAME_ICONIFIED_P (XFRAME (WINDOW_FRAME (XWINDOW (w))))) | |
265 | 1133 break; |
1134 #endif | |
1135 /* Ignore dedicated windows and minibuffers. */ | |
1136 if (MINI_WINDOW_P (XWINDOW (w)) | |
485 | 1137 || !NILP (XWINDOW (w)->dedicated)) |
265 | 1138 break; |
1139 { | |
1140 struct window *best_window_ptr = XWINDOW (best_window); | |
1141 struct window *w_ptr = XWINDOW (w); | |
485 | 1142 if (NILP (best_window) || |
265 | 1143 (XFASTINT (w_ptr->height) * XFASTINT (w_ptr->width)) |
1144 > (XFASTINT (best_window_ptr->height) | |
1145 * XFASTINT (best_window_ptr->width))) | |
1146 best_window = w; | |
1147 } | |
1148 break; | |
1149 | |
1150 case UNSHOW_BUFFER: | |
1151 if (EQ (XWINDOW (w)->buffer, obj)) | |
1152 { | |
1153 /* Find another buffer to show in this window. */ | |
1154 Lisp_Object another_buffer = Fother_buffer (obj); | |
485 | 1155 if (NILP (another_buffer)) |
265 | 1156 another_buffer |
1157 = Fget_buffer_create (build_string ("*scratch*")); | |
1158 Fset_window_buffer (w, another_buffer); | |
1159 if (EQ (w, selected_window)) | |
1160 Fset_buffer (XWINDOW (w)->buffer); | |
1161 } | |
1162 break; | |
1163 } | |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1164 |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1165 if (EQ (w, last_window)) |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1166 break; |
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
1167 |
265 | 1168 w = next_window; |
1169 } | |
1170 | |
1171 return best_window; | |
1172 } | |
1173 | |
1174 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0, | |
1175 "Return the window least recently selected or used for display.\n\ | |
769 | 1176 If optional argument FRAMES is t, search all frames. If FRAME is a\n\ |
1177 frame, search only that frame.\n") | |
1178 (frames) | |
1179 Lisp_Object frames; | |
265 | 1180 { |
1181 register Lisp_Object w; | |
1182 /* First try for a window that is full-width */ | |
769 | 1183 w = window_loop (GET_LRU_WINDOW, Qt, 0, frames); |
485 | 1184 if (!NILP (w) && !EQ (w, selected_window)) |
265 | 1185 return w; |
1186 /* If none of them, try the rest */ | |
769 | 1187 return window_loop (GET_LRU_WINDOW, Qnil, 0, frames); |
265 | 1188 } |
1189 | |
1190 DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0, | |
1191 "Return the largest window in area.\n\ | |
769 | 1192 If optional argument FRAMES is t, search all frames. If FRAME is a\n\ |
1193 frame, search only that frame.\n") | |
1194 (frame) | |
1195 Lisp_Object frame; | |
265 | 1196 { |
1197 return window_loop (GET_LARGEST_WINDOW, Qnil, 0, | |
769 | 1198 frame); |
265 | 1199 } |
1200 | |
1201 DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 1, 2, 0, | |
1202 "Return a window currently displaying BUFFER, or nil if none.\n\ | |
769 | 1203 If optional argument FRAMES is t, search all frames. If FRAME is a\n\ |
1204 frame, search only that frame.\n") | |
1205 (buffer, frame) | |
1206 Lisp_Object buffer, frame; | |
265 | 1207 { |
1208 buffer = Fget_buffer (buffer); | |
1209 if (XTYPE (buffer) == Lisp_Buffer) | |
769 | 1210 return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame); |
265 | 1211 else |
1212 return Qnil; | |
1213 } | |
1214 | |
1215 DEFUN ("delete-other-windows", Fdelete_other_windows, Sdelete_other_windows, | |
1216 0, 1, "", | |
769 | 1217 "Make WINDOW (or the selected window) fill its frame.\n\ |
1218 Only the frame WINDOW is on is affected.") | |
265 | 1219 (window) |
1220 Lisp_Object window; | |
1221 { | |
1222 struct window *w; | |
1223 int opoint = point; | |
1224 struct buffer *obuf = current_buffer; | |
1225 int top; | |
1226 | |
485 | 1227 if (NILP (window)) |
265 | 1228 window = selected_window; |
1229 else | |
1230 CHECK_WINDOW (window, 0); | |
1231 | |
1232 w = XWINDOW (window); | |
1233 top = XFASTINT (w->top); | |
1234 | |
769 | 1235 window_loop (DELETE_OTHER_WINDOWS, window, 0, WINDOW_FRAME(w)); |
265 | 1236 |
1237 Fset_buffer (w->buffer); | |
1238 SET_PT (marker_position (w->start)); | |
1239 Frecenter (make_number (top)); | |
1240 | |
1241 set_buffer_internal (obuf); | |
1242 SET_PT (opoint); | |
1243 return Qnil; | |
1244 } | |
1245 | |
1246 DEFUN ("delete-windows-on", Fdelete_windows_on, Sdelete_windows_on, | |
1247 1, 1, "bDelete windows on (buffer): ", | |
1248 "Delete all windows showing BUFFER.") | |
1249 (buffer) | |
1250 Lisp_Object buffer; | |
1251 { | |
485 | 1252 if (!NILP (buffer)) |
265 | 1253 { |
1254 buffer = Fget_buffer (buffer); | |
1255 CHECK_BUFFER (buffer, 0); | |
1256 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, Qt); | |
1257 } | |
1258 return Qnil; | |
1259 } | |
1260 | |
1261 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, | |
1262 Sreplace_buffer_in_windows, | |
1263 1, 1, "bReplace buffer in windows: ", | |
1264 "Replace BUFFER with some other buffer in all windows showing it.") | |
1265 (buffer) | |
1266 Lisp_Object buffer; | |
1267 { | |
485 | 1268 if (!NILP (buffer)) |
265 | 1269 { |
1270 buffer = Fget_buffer (buffer); | |
1271 CHECK_BUFFER (buffer, 0); | |
1272 window_loop (UNSHOW_BUFFER, buffer, 0, Qt); | |
1273 } | |
1274 return Qnil; | |
1275 } | |
1276 | |
1277 /* Set the height of WINDOW and all its inferiors. */ | |
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1278 |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1279 /* The smallest acceptable dimensions for a window. Anything smaller |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1280 might crash Emacs. */ |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1281 #define MIN_SAFE_WINDOW_WIDTH (2) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1282 #define MIN_SAFE_WINDOW_HEIGHT (2) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1283 |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1284 /* Make sure that window_min_height and window_min_width are |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1285 not too small; if they are, set them to safe minima. */ |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1286 |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1287 static void |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1288 check_min_window_sizes () |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1289 { |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1290 /* Smaller values might permit a crash. */ |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1291 if (window_min_width < MIN_SAFE_WINDOW_WIDTH) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1292 window_min_width = MIN_SAFE_WINDOW_WIDTH; |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1293 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1294 window_min_height = MIN_SAFE_WINDOW_HEIGHT; |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1295 } |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1296 |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1297 /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1298 minimum allowable size. */ |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1299 extern void |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1300 check_frame_size (frame, rows, cols) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1301 FRAME_PTR frame; |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1302 int *rows, *cols; |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1303 { |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1304 /* For height, we have to see whether the frame has a minibuffer, and |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1305 whether it wants a mode line. */ |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1306 int min_height = |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1307 ((FRAME_MINIBUF_ONLY_P (frame) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1308 || ! FRAME_HAS_MINIBUF_P (frame)) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1309 ? MIN_SAFE_WINDOW_HEIGHT |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1310 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1311 |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1312 if (*rows < min_height) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1313 *rows = min_height; |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1314 if (*cols < MIN_SAFE_WINDOW_WIDTH) |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1315 *cols = MIN_SAFE_WINDOW_WIDTH; |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1316 } |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1317 |
265 | 1318 /* Normally the window is deleted if it gets too small. |
1319 nodelete nonzero means do not do this. | |
1320 (The caller should check later and do so if appropriate) */ | |
1321 | |
1322 set_window_height (window, height, nodelete) | |
1323 Lisp_Object window; | |
1324 int height; | |
1325 int nodelete; | |
1326 { | |
1327 register struct window *w = XWINDOW (window); | |
1328 register struct window *c; | |
1329 int oheight = XFASTINT (w->height); | |
1330 int top, pos, lastbot, opos, lastobot; | |
1331 Lisp_Object child; | |
1332 | |
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1333 check_min_window_sizes (); |
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1334 |
265 | 1335 if (!nodelete |
485 | 1336 && ! NILP (w->parent) |
265 | 1337 && height < window_min_height) |
1338 { | |
1339 Fdelete_window (window); | |
1340 return; | |
1341 } | |
1342 | |
1343 XFASTINT (w->last_modified) = 0; | |
1344 windows_or_buffers_changed++; | |
1345 XFASTINT (w->height) = height; | |
485 | 1346 if (!NILP (w->hchild)) |
265 | 1347 { |
485 | 1348 for (child = w->hchild; !NILP (child); child = XWINDOW (child)->next) |
265 | 1349 { |
1350 XWINDOW (child)->top = w->top; | |
1351 set_window_height (child, height, nodelete); | |
1352 } | |
1353 } | |
485 | 1354 else if (!NILP (w->vchild)) |
265 | 1355 { |
1356 lastbot = top = XFASTINT (w->top); | |
1357 lastobot = 0; | |
485 | 1358 for (child = w->vchild; !NILP (child); child = c->next) |
265 | 1359 { |
1360 c = XWINDOW (child); | |
1361 | |
1362 opos = lastobot + XFASTINT (c->height); | |
1363 | |
1364 XFASTINT (c->top) = lastbot; | |
1365 | |
1366 pos = (((opos * height) << 1) + oheight) / (oheight << 1); | |
1367 | |
1368 /* Avoid confusion: inhibit deletion of child if becomes too small */ | |
1369 set_window_height (child, pos + top - lastbot, 1); | |
1370 | |
1371 /* Now advance child to next window, | |
1372 and set lastbot if child was not just deleted. */ | |
1373 lastbot = pos + top; | |
1374 lastobot = opos; | |
1375 } | |
1376 /* Now delete any children that became too small. */ | |
1377 if (!nodelete) | |
485 | 1378 for (child = w->vchild; !NILP (child); child = XWINDOW (child)->next) |
265 | 1379 { |
1380 set_window_height (child, XINT (XWINDOW (child)->height), 0); | |
1381 } | |
1382 } | |
1383 } | |
1384 | |
1385 /* Recursively set width of WINDOW and its inferiors. */ | |
1386 | |
1387 set_window_width (window, width, nodelete) | |
1388 Lisp_Object window; | |
1389 int width; | |
1390 int nodelete; | |
1391 { | |
1392 register struct window *w = XWINDOW (window); | |
1393 register struct window *c; | |
1394 int owidth = XFASTINT (w->width); | |
1395 int left, pos, lastright, opos, lastoright; | |
1396 Lisp_Object child; | |
1397 | |
1398 if (!nodelete && width < window_min_width) | |
1399 { | |
1400 Fdelete_window (window); | |
1401 return; | |
1402 } | |
1403 | |
1404 XFASTINT (w->last_modified) = 0; | |
1405 windows_or_buffers_changed++; | |
1406 XFASTINT (w->width) = width; | |
485 | 1407 if (!NILP (w->vchild)) |
265 | 1408 { |
485 | 1409 for (child = w->vchild; !NILP (child); child = XWINDOW (child)->next) |
265 | 1410 { |
1411 XWINDOW (child)->left = w->left; | |
1412 set_window_width (child, width, nodelete); | |
1413 } | |
1414 } | |
485 | 1415 else if (!NILP (w->hchild)) |
265 | 1416 { |
1417 lastright = left = XFASTINT (w->left); | |
1418 lastoright = 0; | |
485 | 1419 for (child = w->hchild; !NILP (child); child = c->next) |
265 | 1420 { |
1421 c = XWINDOW (child); | |
1422 | |
1423 opos = lastoright + XFASTINT (c->width); | |
1424 | |
1425 XFASTINT (c->left) = lastright; | |
1426 | |
1427 pos = (((opos * width) << 1) + owidth) / (owidth << 1); | |
1428 | |
1429 /* Inhibit deletion for becoming too small */ | |
1430 set_window_width (child, pos + left - lastright, 1); | |
1431 | |
1432 /* Now advance child to next window, | |
1433 and set lastright if child was not just deleted. */ | |
1434 lastright = pos + left, lastoright = opos; | |
1435 } | |
1436 /* Delete children that became too small */ | |
1437 if (!nodelete) | |
485 | 1438 for (child = w->hchild; !NILP (child); child = XWINDOW (child)->next) |
265 | 1439 { |
1440 set_window_width (child, XINT (XWINDOW (child)->width), 0); | |
1441 } | |
1442 } | |
1443 } | |
1444 | |
362 | 1445 int window_select_count; |
265 | 1446 |
1447 DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 2, 0, | |
1448 "Make WINDOW display BUFFER as its contents.\n\ | |
1449 BUFFER can be a buffer or buffer name.") | |
1450 (window, buffer) | |
1451 register Lisp_Object window, buffer; | |
1452 { | |
1453 register Lisp_Object tem; | |
1454 register struct window *w = decode_window (window); | |
1455 | |
1456 buffer = Fget_buffer (buffer); | |
1457 CHECK_BUFFER (buffer, 1); | |
1458 | |
485 | 1459 if (NILP (XBUFFER (buffer)->name)) |
265 | 1460 error ("Attempt to display deleted buffer"); |
1461 | |
1462 tem = w->buffer; | |
485 | 1463 if (NILP (tem)) |
265 | 1464 error ("Window is deleted"); |
1465 else if (! EQ (tem, Qt)) /* w->buffer is t when the window | |
1466 is first being set up. */ | |
1467 { | |
485 | 1468 if (!NILP (w->dedicated) && !EQ (tem, buffer)) |
265 | 1469 error ("Window is dedicated to %s\n", tem); |
1470 | |
1471 unshow_buffer (w); | |
1472 } | |
1473 | |
1474 w->buffer = buffer; | |
1475 Fset_marker (w->pointm, | |
1476 make_number (BUF_PT (XBUFFER (buffer))), | |
1477 buffer); | |
1478 set_marker_restricted (w->start, | |
1479 make_number (XBUFFER (buffer)->last_window_start), | |
1480 buffer); | |
1481 w->start_at_line_beg = Qnil; | |
1482 XFASTINT (w->last_modified) = 0; | |
1483 windows_or_buffers_changed++; | |
1484 if (EQ (window, selected_window)) | |
1485 Fset_buffer (buffer); | |
1486 | |
1487 return Qnil; | |
1488 } | |
1489 | |
1490 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 1, 0, | |
1491 "Select WINDOW. Most editing will apply to WINDOW's buffer.\n\ | |
1492 The main editor command loop selects the buffer of the selected window\n\ | |
1493 before each command.") | |
1494 (window) | |
1495 register Lisp_Object window; | |
1496 { | |
1497 register struct window *w; | |
1498 register struct window *ow = XWINDOW (selected_window); | |
1499 | |
1500 CHECK_WINDOW (window, 0); | |
1501 | |
1502 w = XWINDOW (window); | |
1503 | |
485 | 1504 if (NILP (w->buffer)) |
265 | 1505 error ("Trying to select deleted window or non-leaf window"); |
1506 | |
1507 XFASTINT (w->use_time) = ++window_select_count; | |
1508 if (EQ (window, selected_window)) | |
1509 return window; | |
1510 | |
1511 Fset_marker (ow->pointm, make_number (BUF_PT (XBUFFER (ow->buffer))), | |
1512 ow->buffer); | |
1513 | |
1514 selected_window = window; | |
769 | 1515 #ifdef MULTI_FRAME |
1516 if (XFRAME (WINDOW_FRAME (w)) != selected_frame) | |
265 | 1517 { |
769 | 1518 XFRAME (WINDOW_FRAME (w))->selected_window = window; |
1519 Fselect_frame (WINDOW_FRAME (w), Qnil); | |
265 | 1520 } |
1521 else | |
769 | 1522 selected_frame->selected_window = window; |
265 | 1523 #endif |
1524 | |
1525 record_buffer (w->buffer); | |
1526 Fset_buffer (w->buffer); | |
1527 | |
1528 /* Go to the point recorded in the window. | |
1529 This is important when the buffer is in more | |
1530 than one window. It also matters when | |
1531 redisplay_window has altered point after scrolling, | |
1532 because it makes the change only in the window. */ | |
1533 { | |
1534 register int new_point = marker_position (w->pointm); | |
1535 if (new_point < BEGV) | |
1536 SET_PT (BEGV); | |
1537 if (new_point > ZV) | |
1538 SET_PT (ZV); | |
1539 else | |
1540 SET_PT (new_point); | |
1541 } | |
1542 | |
1543 windows_or_buffers_changed++; | |
1544 return window; | |
1545 } | |
1546 | |
735 | 1547 DEFUN ("display-buffer", Fdisplay_buffer, Sdisplay_buffer, 1, 2, |
1548 "BDisplay buffer:\nP", | |
265 | 1549 "Make BUFFER appear in some window but don't select it.\n\ |
1550 BUFFER can be a buffer or a buffer name.\n\ | |
1551 If BUFFER is shown already in some window, just use that one,\n\ | |
1552 unless the window is the selected window and the optional second\n\ | |
1553 argument NOT_THIS_WINDOW is non-nil.\n\ | |
1554 Returns the window displaying BUFFER.") | |
1555 (buffer, not_this_window) | |
1556 register Lisp_Object buffer, not_this_window; | |
1557 { | |
1558 register Lisp_Object window; | |
1559 | |
1560 buffer = Fget_buffer (buffer); | |
1561 CHECK_BUFFER (buffer, 0); | |
1562 | |
485 | 1563 if (!NILP (Vdisplay_buffer_function)) |
265 | 1564 return call2 (Vdisplay_buffer_function, buffer, not_this_window); |
1565 | |
485 | 1566 if (NILP (not_this_window) |
265 | 1567 && XBUFFER (XWINDOW (selected_window)->buffer) == XBUFFER (buffer)) |
1568 return selected_window; | |
1569 | |
1570 window = Fget_buffer_window (buffer, Qnil); | |
485 | 1571 if (!NILP (window) |
1572 && (NILP (not_this_window) || !EQ (window, selected_window))) | |
265 | 1573 return window; |
1574 | |
769 | 1575 #ifdef MULTI_FRAME |
1576 /* If there are no frames open that have more than a minibuffer, | |
1577 we need to create a new frame. */ | |
1578 if (pop_up_frames || last_nonminibuf_frame == 0) | |
265 | 1579 { |
1580 window | |
769 | 1581 = Fframe_selected_window (call0 (Vpop_up_frame_function)); |
265 | 1582 Fset_window_buffer (window, buffer); |
1583 #if 0 | |
769 | 1584 Fselect_frame (XWINDOW (window)->frame, Qnil); |
265 | 1585 #endif |
1586 return window; | |
1587 } | |
769 | 1588 #endif /* MULTI_FRAME */ |
265 | 1589 |
358 | 1590 if (pop_up_windows |
769 | 1591 #ifdef MULTI_FRAME |
1592 || FRAME_MINIBUF_ONLY_P (selected_frame) | |
358 | 1593 #endif |
1594 ) | |
1595 { | |
769 | 1596 Lisp_Object frames = Qnil; |
358 | 1597 |
769 | 1598 #ifdef MULTI_FRAME |
1599 if (FRAME_MINIBUF_ONLY_P (selected_frame)) | |
1600 XSET (frames, Lisp_Frame, last_nonminibuf_frame); | |
265 | 1601 #endif |
1602 /* Don't try to create a window if would get an error */ | |
1603 if (split_height_threshold < window_min_height << 1) | |
1604 split_height_threshold = window_min_height << 1; | |
1605 | |
769 | 1606 window = Fget_largest_window (frames); |
265 | 1607 |
485 | 1608 if (!NILP (window) |
265 | 1609 && window_height (window) >= split_height_threshold |
1610 && | |
1611 (XFASTINT (XWINDOW (window)->width) | |
769 | 1612 == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window)))))) |
265 | 1613 window = Fsplit_window (window, Qnil, Qnil); |
1614 else | |
1615 { | |
769 | 1616 window = Fget_lru_window (frames); |
265 | 1617 if ((EQ (window, selected_window) |
1618 || EQ (XWINDOW (window)->parent, Qnil)) | |
1619 && window_height (window) >= window_min_height << 1) | |
1620 window = Fsplit_window (window, Qnil, Qnil); | |
1621 } | |
1622 } | |
1623 else | |
1624 window = Fget_lru_window (Qnil); | |
1625 | |
1626 Fset_window_buffer (window, buffer); | |
1627 return window; | |
1628 } | |
1629 | |
1630 void | |
1631 temp_output_buffer_show (buf) | |
1632 register Lisp_Object buf; | |
1633 { | |
1634 register struct buffer *old = current_buffer; | |
1635 register Lisp_Object window; | |
1636 register struct window *w; | |
1637 | |
1638 Fset_buffer (buf); | |
1639 XBUFFER (buf)->save_modified = MODIFF; | |
1640 BEGV = BEG; | |
1641 ZV = Z; | |
1642 SET_PT (BEG); | |
1643 clip_changed = 1; | |
1644 set_buffer_internal (old); | |
1645 | |
1646 if (!EQ (Vtemp_buffer_show_function, Qnil)) | |
1647 call1 (Vtemp_buffer_show_function, buf); | |
1648 else | |
1649 { | |
1650 window = Fdisplay_buffer (buf, Qnil); | |
1651 | |
769 | 1652 #ifdef MULTI_FRAME |
1653 if (XFRAME (XWINDOW (window)->frame) != selected_frame) | |
1654 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); | |
1655 #endif /* MULTI_FRAME */ | |
265 | 1656 Vminibuf_scroll_window = window; |
1657 w = XWINDOW (window); | |
1658 XFASTINT (w->hscroll) = 0; | |
1659 set_marker_restricted (w->start, make_number (1), buf); | |
1660 set_marker_restricted (w->pointm, make_number (1), buf); | |
1661 } | |
1662 } | |
1663 | |
1664 static | |
1665 make_dummy_parent (window) | |
1666 Lisp_Object window; | |
1667 { | |
1668 register Lisp_Object old, new; | |
1669 register struct window *o, *p; | |
1670 | |
1671 old = window; | |
1672 XSETTYPE (old, Lisp_Vector); | |
1673 new = Fcopy_sequence (old); | |
1674 XSETTYPE (new, Lisp_Window); | |
1675 | |
1676 o = XWINDOW (old); | |
1677 p = XWINDOW (new); | |
1678 XFASTINT (p->sequence_number) = ++sequence_number; | |
1679 | |
1680 /* Put new into window structure in place of window */ | |
1681 replace_window (window, new); | |
1682 | |
1683 o->next = Qnil; | |
1684 o->prev = Qnil; | |
1685 o->vchild = Qnil; | |
1686 o->hchild = Qnil; | |
1687 o->parent = new; | |
1688 | |
1689 p->start = Qnil; | |
1690 p->pointm = Qnil; | |
1691 p->buffer = Qnil; | |
1692 } | |
1693 | |
1694 DEFUN ("split-window", Fsplit_window, Ssplit_window, 0, 3, "", | |
1695 "Split WINDOW, putting SIZE lines in the first of the pair.\n\ | |
1696 WINDOW defaults to selected one and SIZE to half its size.\n\ | |
1697 If optional third arg HOR-FLAG is non-nil, split side by side\n\ | |
1698 and put SIZE columns in the first of the pair.") | |
1699 (window, chsize, horflag) | |
1700 Lisp_Object window, chsize, horflag; | |
1701 { | |
1702 register Lisp_Object new; | |
1703 register struct window *o, *p; | |
1704 register int size; | |
1705 | |
485 | 1706 if (NILP (window)) |
265 | 1707 window = selected_window; |
1708 else | |
1709 CHECK_WINDOW (window, 0); | |
1710 | |
1711 o = XWINDOW (window); | |
1712 | |
485 | 1713 if (NILP (chsize)) |
265 | 1714 { |
485 | 1715 if (!NILP (horflag)) |
265 | 1716 /* Round odd size up, since this is for the left-hand window, |
1717 and it will lose a column for the separators. */ | |
1718 size = ((XFASTINT (o->width) + 1) & -2) >> 1; | |
1719 else | |
1720 size = XFASTINT (o->height) >> 1; | |
1721 } | |
1722 else | |
1723 { | |
1724 CHECK_NUMBER (chsize, 1); | |
1725 size = XINT (chsize); | |
1726 } | |
1727 | |
1728 if (MINI_WINDOW_P (o)) | |
1729 error ("Attempt to split minibuffer window"); | |
769 | 1730 else if (FRAME_NO_SPLIT_P (XFRAME (WINDOW_FRAME (o)))) |
1731 error ("Attempt to split unsplittable frame"); | |
265 | 1732 |
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1733 check_min_window_sizes (); |
265 | 1734 |
485 | 1735 if (NILP (horflag)) |
265 | 1736 { |
1737 if (size < window_min_height | |
1738 || size + window_min_height > XFASTINT (o->height)) | |
1739 args_out_of_range_3 (window, chsize, horflag); | |
485 | 1740 if (NILP (o->parent) |
1741 || NILP (XWINDOW (o->parent)->vchild)) | |
265 | 1742 { |
1743 make_dummy_parent (window); | |
1744 new = o->parent; | |
1745 XWINDOW (new)->vchild = window; | |
1746 } | |
1747 } | |
1748 else | |
1749 { | |
1750 if (size < window_min_width | |
1751 || size + window_min_width > XFASTINT (o->width)) | |
1752 args_out_of_range_3 (window, chsize, horflag); | |
485 | 1753 if (NILP (o->parent) |
1754 || NILP (XWINDOW (o->parent)->hchild)) | |
265 | 1755 { |
1756 make_dummy_parent (window); | |
1757 new = o->parent; | |
1758 XWINDOW (new)->hchild = window; | |
1759 } | |
1760 } | |
1761 | |
1762 /* Now we know that window's parent is a vertical combination | |
1763 if we are dividing vertically, or a horizontal combination | |
1764 if we are making side-by-side windows */ | |
1765 | |
1766 windows_or_buffers_changed++; | |
1767 new = make_window (); | |
1768 p = XWINDOW (new); | |
1769 | |
769 | 1770 p->frame = o->frame; |
265 | 1771 p->next = o->next; |
485 | 1772 if (!NILP (p->next)) |
265 | 1773 XWINDOW (p->next)->prev = new; |
1774 p->prev = window; | |
1775 o->next = new; | |
1776 p->parent = o->parent; | |
1777 p->buffer = Qt; | |
1778 | |
1779 Fset_window_buffer (new, o->buffer); | |
1780 | |
769 | 1781 /* Apportion the available frame space among the two new windows */ |
265 | 1782 |
485 | 1783 if (!NILP (horflag)) |
265 | 1784 { |
1785 p->height = o->height; | |
1786 p->top = o->top; | |
1787 XFASTINT (p->width) = XFASTINT (o->width) - size; | |
1788 XFASTINT (o->width) = size; | |
1789 XFASTINT (p->left) = XFASTINT (o->left) + size; | |
1790 } | |
1791 else | |
1792 { | |
1793 p->left = o->left; | |
1794 p->width = o->width; | |
1795 XFASTINT (p->height) = XFASTINT (o->height) - size; | |
1796 XFASTINT (o->height) = size; | |
1797 XFASTINT (p->top) = XFASTINT (o->top) + size; | |
1798 } | |
1799 | |
1800 return new; | |
1801 } | |
1802 | |
1803 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 2, "p", | |
1804 "Make current window ARG lines bigger.\n\ | |
1805 From program, optional second arg non-nil means grow sideways ARG columns.") | |
1806 (n, side) | |
1807 register Lisp_Object n, side; | |
1808 { | |
1809 CHECK_NUMBER (n, 0); | |
485 | 1810 change_window_height (XINT (n), !NILP (side)); |
265 | 1811 return Qnil; |
1812 } | |
1813 | |
1814 DEFUN ("shrink-window", Fshrink_window, Sshrink_window, 1, 2, "p", | |
1815 "Make current window ARG lines smaller.\n\ | |
1816 From program, optional second arg non-nil means shrink sideways ARG columns.") | |
1817 (n, side) | |
1818 register Lisp_Object n, side; | |
1819 { | |
1820 CHECK_NUMBER (n, 0); | |
485 | 1821 change_window_height (-XINT (n), !NILP (side)); |
265 | 1822 return Qnil; |
1823 } | |
1824 | |
1825 int | |
1826 window_height (window) | |
1827 Lisp_Object window; | |
1828 { | |
1829 register struct window *p = XWINDOW (window); | |
1830 return XFASTINT (p->height); | |
1831 } | |
1832 | |
1833 int | |
1834 window_width (window) | |
1835 Lisp_Object window; | |
1836 { | |
1837 register struct window *p = XWINDOW (window); | |
1838 return XFASTINT (p->width); | |
1839 } | |
1840 | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1841 #define MINSIZE(w) \ |
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1842 (widthflag \ |
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1843 ? window_min_width \ |
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1844 : (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height)) |
265 | 1845 |
1846 #define CURBEG(w) \ | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1847 *(widthflag ? (int *) &(XWINDOW (w)->left) : (int *) &(XWINDOW (w)->top)) |
265 | 1848 |
1849 #define CURSIZE(w) \ | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1850 *(widthflag ? (int *) &(XWINDOW (w)->width) : (int *) &(XWINDOW (w)->height)) |
265 | 1851 |
1852 /* Unlike set_window_height, this function | |
1853 also changes the heights of the siblings so as to | |
1854 keep everything consistent. */ | |
1855 | |
1856 change_window_height (delta, widthflag) | |
1857 register int delta; | |
1858 int widthflag; | |
1859 { | |
1860 register Lisp_Object parent; | |
1861 Lisp_Object window; | |
1862 register struct window *p; | |
1863 int *sizep; | |
1864 int (*sizefun) () = widthflag ? window_width : window_height; | |
1865 register int (*setsizefun) () = (widthflag | |
1866 ? set_window_width | |
1867 : set_window_height); | |
1868 | |
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
1869 check_min_window_sizes (); |
265 | 1870 |
1871 window = selected_window; | |
1872 while (1) | |
1873 { | |
1874 p = XWINDOW (window); | |
1875 parent = p->parent; | |
485 | 1876 if (NILP (parent)) |
265 | 1877 { |
1878 if (widthflag) | |
1879 error ("No other window to side of this one"); | |
1880 break; | |
1881 } | |
485 | 1882 if (widthflag ? !NILP (XWINDOW (parent)->hchild) |
1883 : !NILP (XWINDOW (parent)->vchild)) | |
265 | 1884 break; |
1885 window = parent; | |
1886 } | |
1887 | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1888 sizep = &CURSIZE (window); |
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1889 |
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1890 if (*sizep + delta < MINSIZE (window)) |
265 | 1891 { |
1892 Fdelete_window (window); | |
1893 return; | |
1894 } | |
1895 | |
1896 { | |
1897 register int maxdelta; | |
1898 | |
485 | 1899 maxdelta = (!NILP (parent) ? (*sizefun) (parent) - *sizep |
1900 : !NILP (p->next) ? (*sizefun) (p->next) - MINSIZE (p->next) | |
1901 : !NILP (p->prev) ? (*sizefun) (p->prev) - MINSIZE (p->prev) | |
769 | 1902 /* This is a frame with only one window, a minibuffer-only |
1903 or a minibufferless frame. */ | |
432 | 1904 : (delta = 0)); |
265 | 1905 |
1906 if (delta > maxdelta) | |
1907 /* This case traps trying to make the minibuffer | |
769 | 1908 the full frame, or make the only window aside from the |
1909 minibuffer the full frame. */ | |
265 | 1910 delta = maxdelta; |
432 | 1911 |
1912 if (delta == 0) | |
1913 return; | |
265 | 1914 } |
1915 | |
485 | 1916 if (!NILP (p->next) && |
265 | 1917 (*sizefun) (p->next) - delta >= MINSIZE (p->next)) |
1918 { | |
1919 (*setsizefun) (p->next, (*sizefun) (p->next) - delta, 0); | |
1920 (*setsizefun) (window, *sizep + delta, 0); | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1921 CURBEG (p->next) += delta; |
265 | 1922 /* This does not change size of p->next, |
1923 but it propagates the new top edge to its children */ | |
1924 (*setsizefun) (p->next, (*sizefun) (p->next), 0); | |
1925 } | |
485 | 1926 else if (!NILP (p->prev) && |
265 | 1927 (*sizefun) (p->prev) - delta >= MINSIZE (p->prev)) |
1928 { | |
1929 (*setsizefun) (p->prev, (*sizefun) (p->prev) - delta, 0); | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1930 CURBEG (window) -= delta; |
265 | 1931 (*setsizefun) (window, *sizep + delta, 0); |
1932 } | |
1933 else | |
1934 { | |
1935 register int delta1; | |
1936 register int opht = (*sizefun) (parent); | |
1937 | |
1938 /* If trying to grow this window to or beyond size of the parent, | |
1939 make delta1 so big that, on shrinking back down, | |
1940 all the siblings end up with less than one line and are deleted. */ | |
1941 if (opht <= *sizep + delta) | |
1942 delta1 = opht * opht * 2; | |
1943 /* Otherwise, make delta1 just right so that if we add delta1 | |
1944 lines to this window and to the parent, and then shrink | |
1945 the parent back to its original size, the new proportional | |
1946 size of this window will increase by delta. */ | |
1947 else | |
1948 delta1 = (delta * opht * 100) / ((opht - *sizep - delta) * 100); | |
1949 | |
1950 /* Add delta1 lines or columns to this window, and to the parent, | |
1951 keeping things consistent while not affecting siblings. */ | |
1049
25046e48ce9a
* window.c (coordinates_in_window): Do not assume that all
Jim Blandy <jimb@redhat.com>
parents:
1016
diff
changeset
|
1952 CURSIZE (parent) = opht + delta1; |
265 | 1953 (*setsizefun) (window, *sizep + delta1, 0); |
1954 | |
1955 /* Squeeze out delta1 lines or columns from our parent, | |
1956 shriking this window and siblings proportionately. | |
1957 This brings parent back to correct size. | |
1958 Delta1 was calculated so this makes this window the desired size, | |
1959 taking it all out of the siblings. */ | |
1960 (*setsizefun) (parent, opht, 0); | |
1961 } | |
1962 | |
1963 XFASTINT (p->last_modified) = 0; | |
1964 } | |
1965 #undef MINSIZE | |
1966 #undef CURBEG | |
1967 #undef CURSIZE | |
1968 | |
1969 | |
1970 /* Return number of lines of text (not counting mode line) in W. */ | |
1971 | |
1972 int | |
1973 window_internal_height (w) | |
1974 struct window *w; | |
1975 { | |
1976 int ht = XFASTINT (w->height); | |
1977 | |
1978 if (MINI_WINDOW_P (w)) | |
1979 return ht; | |
1980 | |
485 | 1981 if (!NILP (w->parent) || !NILP (w->vchild) || !NILP (w->hchild) |
1982 || !NILP (w->next) || !NILP (w->prev) | |
769 | 1983 || FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME (w)))) |
265 | 1984 return ht - 1; |
1985 | |
1986 return ht; | |
1987 } | |
1988 | |
1989 /* Scroll contents of window WINDOW up N lines. */ | |
1990 | |
1991 void | |
522 | 1992 window_scroll (window, n, noerror) |
265 | 1993 Lisp_Object window; |
1994 int n; | |
522 | 1995 int noerror; |
265 | 1996 { |
1997 register struct window *w = XWINDOW (window); | |
1998 register int opoint = point; | |
1999 register int pos; | |
2000 register int ht = window_internal_height (w); | |
2001 register Lisp_Object tem; | |
2002 int lose; | |
2003 Lisp_Object bolp, nmoved; | |
2004 | |
2005 XFASTINT (tem) = point; | |
2006 tem = Fpos_visible_in_window_p (tem, window); | |
2007 | |
485 | 2008 if (NILP (tem)) |
265 | 2009 { |
2010 Fvertical_motion (make_number (- ht / 2)); | |
2011 XFASTINT (tem) = point; | |
2012 Fset_marker (w->start, tem, w->buffer); | |
2013 w->force_start = Qt; | |
2014 } | |
2015 | |
2016 SET_PT (marker_position (w->start)); | |
2017 lose = n < 0 && point == BEGV; | |
2018 Fvertical_motion (make_number (n)); | |
2019 pos = point; | |
2020 bolp = Fbolp (); | |
2021 SET_PT (opoint); | |
2022 | |
2023 if (lose) | |
522 | 2024 { |
2025 if (noerror) | |
2026 return; | |
2027 else | |
2028 Fsignal (Qbeginning_of_buffer, Qnil); | |
2029 } | |
265 | 2030 |
2031 if (pos < ZV) | |
2032 { | |
2033 set_marker_restricted (w->start, make_number (pos), w->buffer); | |
2034 w->start_at_line_beg = bolp; | |
2035 w->update_mode_line = Qt; | |
2036 XFASTINT (w->last_modified) = 0; | |
2037 if (pos > opoint) | |
2038 SET_PT (pos); | |
2039 if (n < 0) | |
2040 { | |
2041 SET_PT (pos); | |
2042 tem = Fvertical_motion (make_number (ht)); | |
2043 if (point > opoint || XFASTINT (tem) < ht) | |
2044 SET_PT (opoint); | |
2045 else | |
2046 Fvertical_motion (make_number (-1)); | |
2047 } | |
2048 } | |
2049 else | |
522 | 2050 { |
2051 if (noerror) | |
2052 return; | |
2053 else | |
2054 Fsignal (Qend_of_buffer, Qnil); | |
2055 } | |
265 | 2056 } |
2057 | |
2058 /* This is the guts of Fscroll_up and Fscroll_down. */ | |
2059 | |
2060 static void | |
2061 scroll_command (n, direction) | |
2062 register Lisp_Object n; | |
2063 int direction; | |
2064 { | |
2065 register int defalt; | |
2066 int count = specpdl_ptr - specpdl; | |
2067 | |
548 | 2068 /* If selected window's buffer isn't current, make it current for the moment. |
2069 But don't screw up if window_scroll gets an error. */ | |
265 | 2070 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) |
548 | 2071 { |
2072 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
2073 Fset_buffer (XWINDOW (selected_window)->buffer); | |
2074 } | |
265 | 2075 |
2076 defalt = (window_internal_height (XWINDOW (selected_window)) | |
2077 - next_screen_context_lines); | |
2078 defalt = direction * (defalt < 1 ? 1 : defalt); | |
2079 | |
485 | 2080 if (NILP (n)) |
522 | 2081 window_scroll (selected_window, defalt, 0); |
265 | 2082 else if (EQ (n, Qminus)) |
522 | 2083 window_scroll (selected_window, - defalt, 0); |
265 | 2084 else |
2085 { | |
2086 n = Fprefix_numeric_value (n); | |
522 | 2087 window_scroll (selected_window, XINT (n) * direction, 0); |
265 | 2088 } |
548 | 2089 |
2090 unbind_to (count, Qnil); | |
265 | 2091 } |
2092 | |
2093 DEFUN ("scroll-up", Fscroll_up, Sscroll_up, 0, 1, "P", | |
2094 "Scroll text of current window upward ARG lines; or near full screen if no ARG.\n\ | |
2095 A near full screen is `next-screen-context-lines' less than a full screen.\n\ | |
2096 When calling from a program, supply a number as argument or nil.") | |
2097 (n) | |
2098 Lisp_Object n; | |
2099 { | |
2100 scroll_command (n, 1); | |
2101 return Qnil; | |
2102 } | |
2103 | |
2104 DEFUN ("scroll-down", Fscroll_down, Sscroll_down, 0, 1, "P", | |
2105 "Scroll text of current window downward ARG lines; or near full screen if no ARG.\n\ | |
2106 A near full screen is `next-screen-context-lines' less than a full screen.\n\ | |
2107 When calling from a program, supply a number as argument or nil.") | |
2108 (n) | |
2109 Lisp_Object n; | |
2110 { | |
2111 scroll_command (n, -1); | |
2112 return Qnil; | |
2113 } | |
2114 | |
2115 DEFUN ("scroll-other-window", Fscroll_other_window, Sscroll_other_window, 0, 1, "P", | |
2116 "Scroll text of next window upward ARG lines; or near full screen if no ARG.\n\ | |
2117 The next window is the one below the current one; or the one at the top\n\ | |
2118 if the current one is at the bottom.\n\ | |
2119 When calling from a program, supply a number as argument or nil.\n\ | |
2120 \n\ | |
2121 If in the minibuffer, `minibuf-scroll-window' if non-nil\n\ | |
2122 specifies the window to scroll.\n\ | |
2123 If `other-window-scroll-buffer' is non-nil, scroll the window\n\ | |
2124 showing that buffer, popping the buffer up if necessary.") | |
2125 (n) | |
2126 register Lisp_Object n; | |
2127 { | |
2128 register Lisp_Object window; | |
2129 register int ht; | |
2130 register struct window *w; | |
2131 register int count = specpdl_ptr - specpdl; | |
2132 | |
2133 if (MINI_WINDOW_P (XWINDOW (selected_window)) | |
485 | 2134 && !NILP (Vminibuf_scroll_window)) |
265 | 2135 window = Vminibuf_scroll_window; |
2136 /* If buffer is specified, scroll that buffer. */ | |
485 | 2137 else if (!NILP (Vother_window_scroll_buffer)) |
265 | 2138 { |
2139 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil); | |
485 | 2140 if (NILP (window)) |
265 | 2141 window = Fdisplay_buffer (Vother_window_scroll_buffer, Qt); |
2142 } | |
2143 else | |
2144 /* Nothing specified; pick a neighboring window. */ | |
2145 window = Fnext_window (selected_window, Qnil, Qt); | |
2146 CHECK_WINDOW (window, 0); | |
2147 | |
2148 if (EQ (window, selected_window)) | |
2149 error ("There is no other window"); | |
2150 | |
2151 w = XWINDOW (window); | |
2152 ht = window_internal_height (w); | |
2153 | |
2154 /* Don't screw up if window_scroll gets an error. */ | |
2155 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
2156 | |
2157 Fset_buffer (w->buffer); | |
2158 SET_PT (marker_position (w->pointm)); | |
2159 | |
485 | 2160 if (NILP (n)) |
522 | 2161 window_scroll (window, ht - next_screen_context_lines, 1); |
265 | 2162 else if (EQ (n, Qminus)) |
522 | 2163 window_scroll (window, next_screen_context_lines - ht, 1); |
265 | 2164 else |
2165 { | |
2166 if (XTYPE (n) == Lisp_Cons) | |
2167 n = Fcar (n); | |
2168 CHECK_NUMBER (n, 0); | |
522 | 2169 window_scroll (window, XINT (n), 1); |
265 | 2170 } |
2171 | |
2172 Fset_marker (w->pointm, make_number (point), Qnil); | |
2173 unbind_to (count); | |
2174 | |
2175 return Qnil; | |
2176 } | |
2177 | |
2178 DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 1, 1, "P", | |
2179 "Scroll selected window display ARG columns left.\n\ | |
2180 Default for ARG is window width minus 2.") | |
2181 (arg) | |
2182 register Lisp_Object arg; | |
2183 { | |
2184 | |
485 | 2185 if (NILP (arg)) |
265 | 2186 XFASTINT (arg) = XFASTINT (XWINDOW (selected_window)->width) - 2; |
2187 else | |
2188 arg = Fprefix_numeric_value (arg); | |
2189 | |
2190 return | |
2191 Fset_window_hscroll (selected_window, | |
2192 make_number (XINT (XWINDOW (selected_window)->hscroll) | |
2193 + XINT (arg))); | |
2194 } | |
2195 | |
2196 DEFUN ("scroll-right", Fscroll_right, Sscroll_right, 1, 1, "P", | |
2197 "Scroll selected window display ARG columns right.\n\ | |
2198 Default for ARG is window width minus 2.") | |
2199 (arg) | |
2200 register Lisp_Object arg; | |
2201 { | |
485 | 2202 if (NILP (arg)) |
265 | 2203 XFASTINT (arg) = XFASTINT (XWINDOW (selected_window)->width) - 2; |
2204 else | |
2205 arg = Fprefix_numeric_value (arg); | |
2206 | |
2207 return | |
2208 Fset_window_hscroll (selected_window, | |
2209 make_number (XINT (XWINDOW (selected_window)->hscroll) | |
2210 - XINT (arg))); | |
2211 } | |
2212 | |
2213 DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", | |
769 | 2214 "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\ |
265 | 2215 The desired position of point is always relative to the current window.\n\ |
769 | 2216 Just C-u as prefix means put point in the center of the window.\n\ |
2217 No arg (i.e., it is nil) erases the entire frame and then\n\ | |
2218 redraws with point in the center of the current window.") | |
265 | 2219 (n) |
2220 register Lisp_Object n; | |
2221 { | |
2222 register struct window *w = XWINDOW (selected_window); | |
2223 register int ht = window_internal_height (w); | |
2224 register int opoint = point; | |
2225 | |
485 | 2226 if (NILP (n)) |
265 | 2227 { |
769 | 2228 extern int frame_garbaged; |
265 | 2229 |
769 | 2230 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w))); |
265 | 2231 XFASTINT (n) = ht / 2; |
2232 } | |
2233 else if (XTYPE (n) == Lisp_Cons) /* Just C-u. */ | |
2234 { | |
2235 XFASTINT (n) = ht / 2; | |
2236 } | |
2237 else | |
2238 { | |
2239 n = Fprefix_numeric_value (n); | |
2240 CHECK_NUMBER (n, 0); | |
2241 } | |
2242 | |
2243 if (XINT (n) < 0) | |
2244 XSETINT (n, XINT (n) + ht); | |
2245 | |
2246 XSETINT (n, - XINT (n)); | |
2247 | |
2248 Fvertical_motion (n); | |
2249 Fset_marker (w->start, make_number (point), w->buffer); | |
2250 w->start_at_line_beg = Fbolp (); | |
2251 | |
2252 SET_PT (opoint); | |
2253 w->force_start = Qt; | |
2254 | |
2255 return Qnil; | |
2256 } | |
2257 | |
2258 DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, | |
2259 1, 1, "P", | |
2260 "Position point relative to window.\n\ | |
2261 With no argument, position text at center of window.\n\ | |
769 | 2262 An argument specifies frame line; zero means top of window,\n\ |
265 | 2263 negative means relative to bottom of window.") |
2264 (arg) | |
2265 register Lisp_Object arg; | |
2266 { | |
2267 register struct window *w = XWINDOW (selected_window); | |
2268 register int height = window_internal_height (w); | |
2269 register int start; | |
2270 | |
485 | 2271 if (NILP (arg)) |
265 | 2272 XFASTINT (arg) = height / 2; |
2273 else | |
2274 { | |
2275 arg = Fprefix_numeric_value (arg); | |
2276 if (XINT (arg) < 0) | |
2277 XSETINT (arg, XINT (arg) + height); | |
2278 } | |
2279 | |
2280 start = marker_position (w->start); | |
2281 if (start < BEGV || start > ZV) | |
2282 { | |
2283 Fvertical_motion (make_number (- height / 2)); | |
2284 Fset_marker (w->start, make_number (point), w->buffer); | |
2285 w->start_at_line_beg = Fbolp (); | |
2286 w->force_start = Qt; | |
2287 } | |
2288 else | |
2289 SET_PT (start); | |
2290 | |
2291 return Fvertical_motion (arg); | |
2292 } | |
2293 | |
2294 struct save_window_data | |
2295 { | |
2296 int size_from_Lisp_Vector_struct; | |
2297 struct Lisp_Vector *next_from_Lisp_Vector_struct; | |
769 | 2298 Lisp_Object frame_width, frame_height; |
265 | 2299 Lisp_Object current_window; |
2300 Lisp_Object current_buffer; | |
2301 Lisp_Object minibuf_scroll_window; | |
2302 Lisp_Object root_window; | |
2303 /* A vector, interpreted as a struct saved_window */ | |
2304 Lisp_Object saved_windows; | |
2305 }; | |
2306 #define SAVE_WINDOW_DATA_SIZE 7 /* Arg to Fmake_vector */ | |
2307 | |
2308 /* This is saved as a Lisp_Vector */ | |
2309 struct saved_window | |
2310 { | |
2311 /* these first two must agree with struct Lisp_Vector in lisp.h */ | |
2312 int size_from_Lisp_Vector_struct; | |
2313 struct Lisp_Vector *next_from_Lisp_Vector_struct; | |
2314 | |
2315 Lisp_Object window; | |
2316 Lisp_Object buffer, start, pointm, mark; | |
2317 Lisp_Object left, top, width, height, hscroll; | |
2318 Lisp_Object parent, prev; | |
2319 Lisp_Object start_at_line_beg; | |
2320 Lisp_Object display_table; | |
2321 }; | |
2322 #define SAVED_WINDOW_VECTOR_SIZE 14 /* Arg to Fmake_vector */ | |
2323 | |
2324 #define SAVED_WINDOW_N(swv,n) \ | |
2325 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)]))) | |
2326 | |
2327 DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0, | |
2328 "T if OBJECT is a window-configration object.") | |
2329 (obj) | |
2330 Lisp_Object obj; | |
2331 { | |
2332 if (XTYPE (obj) == Lisp_Window_Configuration) | |
2333 return Qt; | |
2334 return Qnil; | |
2335 } | |
2336 | |
2337 | |
2338 DEFUN ("set-window-configuration", | |
2339 Fset_window_configuration, Sset_window_configuration, | |
2340 1, 1, 0, | |
2341 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\ | |
2342 CONFIGURATION must be a value previously returned\n\ | |
2343 by `current-window-configuration' (which see).") | |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2344 (configuration) |
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2345 Lisp_Object configuration; |
265 | 2346 { |
2347 register struct window *w; | |
2348 register struct save_window_data *data; | |
2349 struct Lisp_Vector *saved_windows; | |
2350 register struct saved_window *p; | |
2351 register Lisp_Object tem; | |
2352 Lisp_Object new_current_buffer; | |
2353 int k; | |
769 | 2354 FRAME_PTR f; |
265 | 2355 |
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2356 /* Save screen height here so we can go back to it at the end. */ |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2357 int previous_frame_height; |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2358 int previous_frame_width; |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2359 int frame_size_change; |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2360 |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2361 while (XTYPE (configuration) != Lisp_Window_Configuration) |
265 | 2362 { |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2363 configuration = wrong_type_argument (intern ("window-configuration-p"), |
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2364 configuration); |
265 | 2365 } |
2366 | |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2367 data = (struct save_window_data *) XVECTOR (configuration); |
265 | 2368 saved_windows = XVECTOR (data->saved_windows); |
2369 | |
769 | 2370 f = XFRAME (XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame); |
265 | 2371 |
769 | 2372 if (XFASTINT (data->frame_height) != FRAME_HEIGHT (f) |
2373 || XFASTINT (data->frame_width) != FRAME_WIDTH (f)) | |
265 | 2374 { |
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2375 previous_frame_height = FRAME_HEIGHT (f); |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2376 previous_frame_width = FRAME_WIDTH (f); |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2377 frame_size_change = 1; |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2378 |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2379 change_frame_size (f, data->frame_height, data->frame_width, 0, 0); |
265 | 2380 } |
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2381 else |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2382 frame_size_change = 0; |
265 | 2383 |
2384 windows_or_buffers_changed++; | |
2385 new_current_buffer = data->current_buffer; | |
485 | 2386 if (NILP (XBUFFER (new_current_buffer)->name)) |
265 | 2387 new_current_buffer = Qnil; |
2388 | |
1237
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2389 /* Kludge Alert! |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2390 Mark all windows now on frame as "deleted". |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2391 Restoring the new configuration "undeletes" any that are in it. |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2392 |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2393 Save their current buffers in their height fields, since we may |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2394 need it later, if the buffer saved in the configuration is now |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2395 dead. */ |
769 | 2396 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f))); |
265 | 2397 |
2398 for (k = 0; k < saved_windows->size; k++) | |
2399 { | |
2400 p = SAVED_WINDOW_N (saved_windows, k); | |
2401 w = XWINDOW (p->window); | |
2402 w->next = Qnil; | |
2403 | |
485 | 2404 if (!NILP (p->parent)) |
265 | 2405 w->parent = SAVED_WINDOW_N (saved_windows, XFASTINT (p->parent))->window; |
2406 else | |
2407 w->parent = Qnil; | |
2408 | |
485 | 2409 if (!NILP (p->prev)) |
265 | 2410 { |
2411 w->prev = SAVED_WINDOW_N (saved_windows, XFASTINT (p->prev))->window; | |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2412 XWINDOW (w->prev)->next = p->window; |
265 | 2413 } |
2414 else | |
2415 { | |
2416 w->prev = Qnil; | |
485 | 2417 if (!NILP (w->parent)) |
265 | 2418 { |
2419 if (EQ (p->width, XWINDOW (w->parent)->width)) | |
2420 { | |
2421 XWINDOW (w->parent)->vchild = p->window; | |
2422 XWINDOW (w->parent)->hchild = Qnil; | |
2423 } | |
2424 else | |
2425 { | |
2426 XWINDOW (w->parent)->hchild = p->window; | |
2427 XWINDOW (w->parent)->vchild = Qnil; | |
2428 } | |
2429 } | |
2430 } | |
1237
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2431 |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2432 /* If we squirreled away the buffer in the window's height, |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2433 restore it now. */ |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2434 if (XTYPE (w->height) == Lisp_Buffer) |
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2435 w->buffer = w->height; |
265 | 2436 w->left = p->left; |
2437 w->top = p->top; | |
2438 w->width = p->width; | |
2439 w->height = p->height; | |
2440 w->hscroll = p->hscroll; | |
2441 w->display_table = p->display_table; | |
2442 XFASTINT (w->last_modified) = 0; | |
2443 | |
2444 /* Reinstall the saved buffer and pointers into it. */ | |
485 | 2445 if (NILP (p->buffer)) |
265 | 2446 w->buffer = p->buffer; |
2447 else | |
2448 { | |
485 | 2449 if (!NILP (XBUFFER (p->buffer)->name)) |
265 | 2450 /* If saved buffer is alive, install it. */ |
2451 { | |
2452 w->buffer = p->buffer; | |
2453 w->start_at_line_beg = p->start_at_line_beg; | |
2454 set_marker_restricted (w->start, Fmarker_position (p->start), w->buffer); | |
2455 set_marker_restricted (w->pointm, Fmarker_position (p->pointm), w->buffer); | |
2456 Fset_marker (XBUFFER (w->buffer)->mark, | |
2457 Fmarker_position (p->mark), w->buffer); | |
2458 | |
2459 if (!EQ (p->buffer, new_current_buffer) && | |
2460 XBUFFER (p->buffer) == current_buffer) | |
2461 Fgoto_char (w->pointm); | |
2462 } | |
485 | 2463 else if (NILP (XBUFFER (w->buffer)->name)) |
265 | 2464 /* Else if window's old buffer is dead too, get a live one. */ |
2465 { | |
2466 w->buffer = Fcdr (Fcar (Vbuffer_alist)); | |
2467 /* This will set the markers to beginning of visible range. */ | |
2468 set_marker_restricted (w->start, make_number (0), w->buffer); | |
2469 set_marker_restricted (w->pointm, make_number (0), w->buffer); | |
2470 w->start_at_line_beg = Qt; | |
2471 } | |
2472 else | |
2473 /* Keeping window's old buffer; make sure the markers are real. */ | |
2474 /* Else if window's old buffer is dead too, get a live one. */ | |
2475 { | |
2476 /* Set window markers at start of visible range. */ | |
2477 if (XMARKER (w->start)->buffer == 0) | |
2478 set_marker_restricted (w->start, make_number (0), w->buffer); | |
2479 if (XMARKER (w->pointm)->buffer == 0) | |
2480 set_marker_restricted (w->pointm, | |
2481 make_number (BUF_PT (XBUFFER (w->buffer))), | |
2482 w->buffer); | |
2483 w->start_at_line_beg = Qt; | |
2484 } | |
2485 } | |
2486 } | |
2487 | |
769 | 2488 FRAME_ROOT_WINDOW (f) = data->root_window; |
1280
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2489 /* We also need to restore the frame's selected window; that's taken |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2490 care of below, either by calling Fselect_window, or by explicit |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2491 assignment. */ |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2492 |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2493 #if 0 /* I don't understand why this is needed, and it causes |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2494 problems when the frame's old selected window has been |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2495 deleted. */ |
769 | 2496 #ifdef MULTI_FRAME |
972
f47d221cbfe6
* window.c (MIN_SAFE_WINDOW_HEIGHT, MIN_SAFE_WINDOW_WIDTH): Macros
Jim Blandy <jimb@redhat.com>
parents:
780
diff
changeset
|
2497 if (f != selected_frame && ! FRAME_TERMCAP_P (f)) |
769 | 2498 Fselect_frame (WINDOW_FRAME (XWINDOW (data->root_window)), Qnil); |
265 | 2499 #endif |
1280
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2500 #endif |
265 | 2501 |
1123
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2502 /* Set the screen height to the value it had before this function. */ |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2503 if (frame_size_change) |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2504 change_frame_size (f, previous_frame_height, previous_frame_width, 0, 0); |
55e605674fb1
* window.c (minibuffer_window): Accept an optional FRAME argument;
Jim Blandy <jimb@redhat.com>
parents:
1049
diff
changeset
|
2505 |
769 | 2506 if (f == selected_frame) |
265 | 2507 { |
2508 Fselect_window (data->current_window); | |
485 | 2509 if (!NILP (new_current_buffer)) |
265 | 2510 Fset_buffer (new_current_buffer); |
2511 else | |
2512 Fset_buffer (XWINDOW (selected_window)->buffer); | |
2513 } | |
1280
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2514 else |
5c66007ecabb
* window.c (Fset_window_configuration): Don't select the frame
Jim Blandy <jimb@redhat.com>
parents:
1237
diff
changeset
|
2515 FRAME_SELECTED_WINDOW (f) = data->current_window; |
265 | 2516 |
2517 Vminibuf_scroll_window = data->minibuf_scroll_window; | |
2518 return (Qnil); | |
2519 } | |
2520 | |
769 | 2521 /* Mark all windows now on frame as deleted |
265 | 2522 by setting their buffers to nil. */ |
2523 | |
2524 static void | |
2525 delete_all_subwindows (w) | |
2526 register struct window *w; | |
2527 { | |
1237
3929b2135e58
* window.c (delete_all_subwindows): Save the window's buffer in
Jim Blandy <jimb@redhat.com>
parents:
1123
diff
changeset
|
2528 w->height = w->buffer; /* See Fset_window_configuration for excuse. */ |
265 | 2529 w->buffer = Qnil; |
485 | 2530 if (!NILP (w->next)) |
265 | 2531 delete_all_subwindows (XWINDOW (w->next)); |
485 | 2532 if (!NILP (w->vchild)) |
265 | 2533 delete_all_subwindows (XWINDOW (w->vchild)); |
485 | 2534 if (!NILP (w->hchild)) |
265 | 2535 delete_all_subwindows (XWINDOW (w->hchild)); |
2536 } | |
2537 | |
2538 static int | |
2539 count_windows (window) | |
2540 register struct window *window; | |
2541 { | |
2542 register int count = 1; | |
485 | 2543 if (!NILP (window->next)) |
265 | 2544 count += count_windows (XWINDOW (window->next)); |
485 | 2545 if (!NILP (window->vchild)) |
265 | 2546 count += count_windows (XWINDOW (window->vchild)); |
485 | 2547 if (!NILP (window->hchild)) |
265 | 2548 count += count_windows (XWINDOW (window->hchild)); |
2549 return count; | |
2550 } | |
2551 | |
2552 static int | |
2553 save_window_save (window, vector, i) | |
2554 Lisp_Object window; | |
2555 struct Lisp_Vector *vector; | |
2556 int i; | |
2557 { | |
2558 register struct saved_window *p; | |
2559 register struct window *w; | |
2560 register Lisp_Object tem; | |
2561 | |
485 | 2562 for (;!NILP (window); window = w->next) |
265 | 2563 { |
2564 p = SAVED_WINDOW_N (vector, i); | |
2565 w = XWINDOW (window); | |
2566 | |
2567 XFASTINT (w->temslot) = i++; | |
2568 p->window = window; | |
2569 p->buffer = w->buffer; | |
2570 p->left = w->left; | |
2571 p->top = w->top; | |
2572 p->width = w->width; | |
2573 p->height = w->height; | |
2574 p->hscroll = w->hscroll; | |
2575 p->display_table = w->display_table; | |
485 | 2576 if (!NILP (w->buffer)) |
265 | 2577 { |
2578 /* Save w's value of point in the window configuration. | |
2579 If w is the selected window, then get the value of point | |
2580 from the buffer; pointm is garbage in the selected window. */ | |
2581 if (EQ (window, selected_window)) | |
2582 { | |
2583 p->pointm = Fmake_marker (); | |
2584 Fset_marker (p->pointm, BUF_PT (XBUFFER (w->buffer)), | |
2585 w->buffer); | |
2586 } | |
2587 else | |
2588 p->pointm = Fcopy_marker (w->pointm); | |
2589 | |
2590 p->start = Fcopy_marker (w->start); | |
2591 p->start_at_line_beg = w->start_at_line_beg; | |
2592 | |
2593 tem = XBUFFER (w->buffer)->mark; | |
2594 p->mark = Fcopy_marker (tem); | |
2595 } | |
2596 else | |
2597 { | |
2598 p->pointm = Qnil; | |
2599 p->start = Qnil; | |
2600 p->mark = Qnil; | |
2601 p->start_at_line_beg = Qnil; | |
2602 } | |
2603 | |
485 | 2604 if (NILP (w->parent)) |
265 | 2605 p->parent = Qnil; |
2606 else | |
2607 p->parent = XWINDOW (w->parent)->temslot; | |
2608 | |
485 | 2609 if (NILP (w->prev)) |
265 | 2610 p->prev = Qnil; |
2611 else | |
2612 p->prev = XWINDOW (w->prev)->temslot; | |
2613 | |
485 | 2614 if (!NILP (w->vchild)) |
265 | 2615 i = save_window_save (w->vchild, vector, i); |
485 | 2616 if (!NILP (w->hchild)) |
265 | 2617 i = save_window_save (w->hchild, vector, i); |
2618 } | |
2619 | |
2620 return i; | |
2621 } | |
2622 | |
2623 DEFUN ("current-window-configuration", | |
358 | 2624 Fcurrent_window_configuration, Scurrent_window_configuration, 0, 1, 0, |
769 | 2625 "Return an object representing the current window configuration of FRAME.\n\ |
2626 If FRAME is nil or omitted, use the selected frame.\n\ | |
265 | 2627 This describes the number of windows, their sizes and current buffers,\n\ |
2628 and for each displayed buffer, where display starts, and the positions of\n\ | |
2629 point and mark. An exception is made for point in the current buffer:\n\ | |
2630 its value is -not- saved.") | |
769 | 2631 (frame) |
2632 Lisp_Object frame; | |
265 | 2633 { |
2634 register Lisp_Object tem; | |
2635 register int n_windows; | |
2636 register struct save_window_data *data; | |
2637 register int i; | |
769 | 2638 FRAME_PTR f; |
265 | 2639 |
769 | 2640 if (NILP (frame)) |
2641 f = selected_frame; | |
358 | 2642 else |
2643 { | |
769 | 2644 CHECK_LIVE_FRAME (frame, 0); |
2645 f = XFRAME (frame); | |
358 | 2646 } |
2647 | |
769 | 2648 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); |
265 | 2649 data = (struct save_window_data *) |
2650 XVECTOR (Fmake_vector (make_number (SAVE_WINDOW_DATA_SIZE), | |
2651 Qnil)); | |
769 | 2652 XFASTINT (data->frame_width) = FRAME_WIDTH (f); |
2653 XFASTINT (data->frame_height) = FRAME_HEIGHT (f); | |
2654 data->current_window = FRAME_SELECTED_WINDOW (f); | |
265 | 2655 XSET (data->current_buffer, Lisp_Buffer, current_buffer); |
2656 data->minibuf_scroll_window = Vminibuf_scroll_window; | |
769 | 2657 data->root_window = FRAME_ROOT_WINDOW (f); |
265 | 2658 tem = Fmake_vector (make_number (n_windows), Qnil); |
2659 data->saved_windows = tem; | |
2660 for (i = 0; i < n_windows; i++) | |
2661 XVECTOR (tem)->contents[i] | |
2662 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE), Qnil); | |
769 | 2663 save_window_save (FRAME_ROOT_WINDOW (f), |
265 | 2664 XVECTOR (tem), 0); |
2665 XSET (tem, Lisp_Window_Configuration, data); | |
2666 return (tem); | |
2667 } | |
2668 | |
2669 DEFUN ("save-window-excursion", Fsave_window_excursion, Ssave_window_excursion, | |
2670 0, UNEVALLED, 0, | |
2671 "Execute body, preserving window sizes and contents.\n\ | |
2672 Restores which buffer appears in which window, where display starts,\n\ | |
2673 as well as the current buffer.\n\ | |
2674 Does not restore the value of point in current buffer.") | |
2675 (args) | |
2676 Lisp_Object args; | |
2677 { | |
2678 register Lisp_Object val; | |
2679 register int count = specpdl_ptr - specpdl; | |
2680 | |
2681 record_unwind_protect (Fset_window_configuration, | |
358 | 2682 Fcurrent_window_configuration (Qnil)); |
265 | 2683 val = Fprogn (args); |
2684 return unbind_to (count, val); | |
2685 } | |
2686 | |
2687 init_window_once () | |
2688 { | |
769 | 2689 #ifdef MULTI_FRAME |
2690 selected_frame = make_terminal_frame (); | |
2691 minibuf_window = selected_frame->minibuffer_window; | |
2692 selected_window = selected_frame->selected_window; | |
2693 last_nonminibuf_frame = selected_frame; | |
2694 #else /* not MULTI_FRAME */ | |
265 | 2695 extern Lisp_Object get_minibuffer (); |
2696 | |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
2697 minibuf_window = make_window (); |
769 | 2698 FRAME_ROOT_WINDOW (selected_frame) = make_window (); |
265 | 2699 |
769 | 2700 XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->next = minibuf_window; |
2701 XWINDOW (minibuf_window)->prev = FRAME_ROOT_WINDOW (selected_frame); | |
983
eb19dfaec9c4
* window.c (window_loop): This used to keep track of the first
Jim Blandy <jimb@redhat.com>
parents:
972
diff
changeset
|
2702 XWINDOW (minibuf_window)->mini_p = Qt; |
265 | 2703 |
2704 /* These values 9 and 10 are arbitrary, | |
2705 just so that there is "something there." | |
2706 Correct values are put in in init_xdisp */ | |
2707 | |
769 | 2708 XFASTINT (XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->width) = 10; |
265 | 2709 XFASTINT (XWINDOW (minibuf_window)->width) = 10; |
2710 | |
769 | 2711 XFASTINT (XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->height) = 9; |
265 | 2712 XFASTINT (XWINDOW (minibuf_window)->top) = 9; |
2713 XFASTINT (XWINDOW (minibuf_window)->height) = 1; | |
2714 | |
2715 /* Prevent error in Fset_window_buffer. */ | |
769 | 2716 XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->buffer = Qt; |
265 | 2717 XWINDOW (minibuf_window)->buffer = Qt; |
2718 | |
2719 /* Now set them up for real. */ | |
769 | 2720 Fset_window_buffer (FRAME_ROOT_WINDOW (selected_frame), |
732 | 2721 Fcurrent_buffer ()); |
265 | 2722 Fset_window_buffer (minibuf_window, get_minibuffer (0)); |
2723 | |
769 | 2724 selected_window = FRAME_ROOT_WINDOW (selected_frame); |
362 | 2725 /* Make sure this window seems more recently used than |
2726 a newly-created, never-selected window. Increment | |
2727 window_select_count so the first selection ever will get | |
2728 something newer than this. */ | |
2729 XFASTINT (XWINDOW (selected_window)->use_time) = ++window_select_count; | |
769 | 2730 #endif /* not MULTI_FRAME */ |
265 | 2731 } |
2732 | |
2733 syms_of_window () | |
2734 { | |
2735 Qwindowp = intern ("windowp"); | |
2736 staticpro (&Qwindowp); | |
2737 | |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2738 #ifndef MULTI_FRAME |
265 | 2739 /* Make sure all windows get marked */ |
2740 staticpro (&minibuf_window); | |
1016
817b0ce337d7
* window.c (Fset_window_configuration): Removed #if 0'd code which
Jim Blandy <jimb@redhat.com>
parents:
983
diff
changeset
|
2741 #endif |
265 | 2742 |
2743 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, | |
2744 "Non-nil means call as function to display a help buffer.\n\ | |
2745 Used by `with-output-to-temp-buffer'."); | |
2746 Vtemp_buffer_show_function = Qnil; | |
2747 | |
2748 DEFVAR_LISP ("display-buffer-function", &Vdisplay_buffer_function, | |
2749 "If non-nil, function to call to handle `display-buffer'.\n\ | |
2750 It will receive two args, the buffer and a flag which if non-nil means\n\ | |
2751 that the currently selected window is not acceptable.\n\ | |
2752 Commands such as `switch-to-buffer-other-window' and `find-file-other-window'\n\ | |
2753 work using this function."); | |
2754 Vdisplay_buffer_function = Qnil; | |
2755 | |
2756 DEFVAR_LISP ("mouse-window", &Vmouse_window, | |
2757 "Window that the last mouse click occurred on."); | |
2758 Vmouse_window = Qnil; | |
2759 | |
2760 DEFVAR_LISP ("mouse-event", &Vmouse_event, | |
2761 "The last mouse-event object. A list of four elements:\n\ | |
769 | 2762 ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ).\n\ |
265 | 2763 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\ |
2764 WINDOW is the window that the click applies do.\n\ | |
769 | 2765 If FRAME-PART is non-nil, the event was on a scrollbar;\n\ |
265 | 2766 then Y-POS is really the total length of the scrollbar, while X-POS is\n\ |
2767 the relative position of the scrollbar's value within that total length.\n\ | |
769 | 2768 FRAME-PART is one of the following symbols:\n\ |
265 | 2769 `vertical-scrollbar', `vertical-slider',\n\ |
2770 `vertical-thumbup', `vertical-thumbdown',\n\ | |
2771 `horizontal-scrollbar', `horizontal-slider',\n\ | |
2772 `horizontal-thumbleft', `horizontal-thumbright'"); | |
2773 Vmouse_event = Qnil; | |
2774 | |
2775 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window, | |
2776 "Non-nil means it is the window that C-M-v in minibuffer should scroll."); | |
2777 Vminibuf_scroll_window = Qnil; | |
2778 | |
2779 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer, | |
2780 "If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window."); | |
2781 Vother_window_scroll_buffer = Qnil; | |
2782 | |
769 | 2783 #ifdef MULTI_FRAME |
2784 DEFVAR_BOOL ("pop-up-frames", &pop_up_frames, | |
780 | 2785 "*Non-nil means `display-buffer' should make a separate frame."); |
769 | 2786 pop_up_frames = 0; |
265 | 2787 |
769 | 2788 DEFVAR_LISP ("pop-up-frame-function", &Vpop_up_frame_function, |
2789 "*If non-nil, function to call to handle automatic new frame creation.\n\ | |
2790 It is called with no arguments and should return a newly created frame.\n\ | |
265 | 2791 \n\ |
769 | 2792 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'\n\ |
2793 where `pop-up-frame-alist' would hold the default frame parameters."); | |
2794 Vpop_up_frame_function = Qnil; | |
265 | 2795 #endif |
2796 | |
2797 DEFVAR_BOOL ("pop-up-windows", &pop_up_windows, | |
2798 "*Non-nil means display-buffer should make new windows."); | |
2799 pop_up_windows = 1; | |
2800 | |
2801 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines, | |
2802 "*Number of lines of continuity when scrolling by screenfuls."); | |
2803 next_screen_context_lines = 2; | |
2804 | |
2805 DEFVAR_INT ("split-height-threshold", &split_height_threshold, | |
2806 "*display-buffer would prefer to split the largest window if this large.\n\ | |
2807 If there is only one window, it is split regardless of this value."); | |
2808 split_height_threshold = 500; | |
2809 | |
2810 DEFVAR_INT ("window-min-height", &window_min_height, | |
2811 "*Delete any window less than this tall (including its mode line)."); | |
2812 window_min_height = 4; | |
2813 | |
2814 DEFVAR_INT ("window-min-width", &window_min_width, | |
2815 "*Delete any window less than this wide."); | |
2816 window_min_width = 10; | |
2817 | |
2818 defsubr (&Sselected_window); | |
2819 defsubr (&Sminibuffer_window); | |
2820 defsubr (&Swindow_minibuffer_p); | |
2821 defsubr (&Swindowp); | |
2822 defsubr (&Spos_visible_in_window_p); | |
2823 defsubr (&Swindow_buffer); | |
2824 defsubr (&Swindow_height); | |
2825 defsubr (&Swindow_width); | |
2826 defsubr (&Swindow_hscroll); | |
2827 defsubr (&Sset_window_hscroll); | |
2828 defsubr (&Swindow_edges); | |
432 | 2829 defsubr (&Scoordinates_in_window_p); |
2830 defsubr (&Swindow_at); | |
265 | 2831 defsubr (&Swindow_point); |
2832 defsubr (&Swindow_start); | |
2833 defsubr (&Swindow_end); | |
2834 defsubr (&Sset_window_point); | |
2835 defsubr (&Sset_window_start); | |
2836 defsubr (&Swindow_dedicated_p); | |
722
0a2391511b46
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
708
diff
changeset
|
2837 defsubr (&Sset_window_dedicated_p); |
265 | 2838 defsubr (&Swindow_display_table); |
2839 defsubr (&Sset_window_display_table); | |
2840 defsubr (&Snext_window); | |
2841 defsubr (&Sprevious_window); | |
2842 defsubr (&Sother_window); | |
2843 defsubr (&Sget_lru_window); | |
2844 defsubr (&Sget_largest_window); | |
2845 defsubr (&Sget_buffer_window); | |
2846 defsubr (&Sdelete_other_windows); | |
2847 defsubr (&Sdelete_windows_on); | |
2848 defsubr (&Sreplace_buffer_in_windows); | |
2849 defsubr (&Sdelete_window); | |
2850 defsubr (&Sset_window_buffer); | |
2851 defsubr (&Sselect_window); | |
2852 defsubr (&Sdisplay_buffer); | |
2853 defsubr (&Ssplit_window); | |
2854 defsubr (&Senlarge_window); | |
2855 defsubr (&Sshrink_window); | |
2856 defsubr (&Sscroll_up); | |
2857 defsubr (&Sscroll_down); | |
2858 defsubr (&Sscroll_left); | |
2859 defsubr (&Sscroll_right); | |
2860 defsubr (&Sscroll_other_window); | |
2861 defsubr (&Srecenter); | |
2862 defsubr (&Smove_to_window_line); | |
2863 defsubr (&Swindow_configuration_p); | |
2864 defsubr (&Sset_window_configuration); | |
2865 defsubr (&Scurrent_window_configuration); | |
2866 defsubr (&Ssave_window_excursion); | |
2867 } | |
2868 | |
2869 keys_of_window () | |
2870 { | |
2871 initial_define_key (control_x_map, '1', "delete-other-windows"); | |
2872 initial_define_key (control_x_map, '2', "split-window"); | |
2873 initial_define_key (control_x_map, '0', "delete-window"); | |
2874 initial_define_key (control_x_map, 'o', "other-window"); | |
2875 initial_define_key (control_x_map, '^', "enlarge-window"); | |
2876 initial_define_key (control_x_map, '<', "scroll-left"); | |
2877 initial_define_key (control_x_map, '>', "scroll-right"); | |
2878 | |
2879 initial_define_key (global_map, Ctl ('V'), "scroll-up"); | |
2880 initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); | |
2881 initial_define_key (meta_map, 'v', "scroll-down"); | |
2882 | |
2883 initial_define_key (global_map, Ctl('L'), "recenter"); | |
2884 initial_define_key (meta_map, 'r', "move-to-window-line"); | |
2885 } |