0
|
1 /* Window creation, deletion and examination for XEmacs.
|
|
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
4 Copyright (C) 1995, 1996 Ben Wing.
|
|
5 Copyright (C) 1996 Chuck Thompson.
|
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: FSF 19.30. */
|
|
25 /* Beginning to diverge significantly. */
|
|
26
|
|
27 /* This file has been Mule-ized. */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31
|
|
32 #include "buffer.h"
|
|
33 #include "faces.h"
|
|
34 #include "frame.h"
|
|
35 #include "objects.h"
|
|
36 #include "glyphs.h"
|
|
37 #include "redisplay.h"
|
|
38 #include "window.h"
|
|
39 #include "commands.h"
|
|
40
|
272
|
41 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configurationp;
|
|
42 Lisp_Object Qscroll_up, Qscroll_down, Qdisplay_buffer;
|
0
|
43
|
|
44 #ifdef MEMORY_USAGE_STATS
|
272
|
45 Lisp_Object Qface_cache, Qglyph_cache, Qline_start_cache, Qother_redisplay;
|
0
|
46 #ifdef HAVE_SCROLLBARS
|
|
47 Lisp_Object Qscrollbar_instances;
|
|
48 #endif
|
|
49 #endif
|
|
50
|
272
|
51 EXFUN (Fnext_window, 4);
|
|
52
|
0
|
53 static int window_pixel_width_to_char_width (struct window *w,
|
|
54 int pixel_width,
|
|
55 int include_margins_p);
|
|
56 static int window_char_width_to_pixel_width (struct window *w,
|
|
57 int char_width,
|
|
58 int include_margins_p);
|
|
59 static int window_pixel_height_to_char_height (struct window *w,
|
|
60 int pixel_height,
|
|
61 int include_gutters_p);
|
|
62 static int window_char_height_to_pixel_height (struct window *w,
|
|
63 int char_height,
|
|
64 int include_gutters_p);
|
263
|
65 static void change_window_height (struct window *w, int delta, int widthflag,
|
|
66 int inpixels);
|
0
|
67
|
|
68 /* Thickness of shadow border around 3d modelines. */
|
|
69 Lisp_Object Vmodeline_shadow_thickness;
|
|
70
|
|
71 /* Whether a modeline should be displayed. */
|
|
72 Lisp_Object Vhas_modeline_p;
|
|
73
|
|
74 /* Scroll if point lands on the bottom line and that line is partially
|
|
75 clipped. */
|
|
76 int scroll_on_clipped_lines;
|
|
77
|
|
78 /* The minibuffer window of the selected frame.
|
|
79 Note that you cannot test for minibufferness of an arbitrary window
|
|
80 by comparing against this; but you can test for minibufferness of
|
|
81 the selected window. */
|
|
82 Lisp_Object minibuf_window;
|
|
83
|
|
84 /* Non-nil means it is the window for C-M-v to scroll
|
|
85 when the minibuffer is selected. */
|
274
|
86 Lisp_Object Vminibuffer_scroll_window;
|
0
|
87
|
|
88 /* Non-nil means this is the buffer whose window C-M-v should scroll. */
|
|
89 Lisp_Object Vother_window_scroll_buffer;
|
|
90
|
102
|
91 /* Non-nil means it's the function to call to display temp buffers. */
|
0
|
92 Lisp_Object Vtemp_buffer_show_function;
|
|
93
|
|
94 Lisp_Object Vtemp_buffer_show_hook;
|
|
95
|
|
96 /* If a window gets smaller than either of these, it is removed. */
|
|
97 int window_min_height;
|
|
98 int window_min_width;
|
|
99
|
|
100 /* Hook run at end of temp_output_buffer_show. */
|
|
101 Lisp_Object Qtemp_buffer_show_hook;
|
|
102
|
|
103 /* Number of lines of continuity in scrolling by screenfuls. */
|
|
104 int next_screen_context_lines;
|
|
105
|
|
106 /* List of freed window configurations with 1 - 10 windows. */
|
|
107 Lisp_Object Vwindow_configuration_free_list[10];
|
|
108
|
|
109 #define SET_LAST_MODIFIED(w, cache_too) \
|
|
110 do { \
|
|
111 (w)->last_modified[CURRENT_DISP] = Qzero; \
|
|
112 (w)->last_modified[DESIRED_DISP] = Qzero; \
|
|
113 (w)->last_modified[CMOTION_DISP] = Qzero; \
|
|
114 if (cache_too) \
|
|
115 (w)->line_cache_last_updated = Qzero; \
|
|
116 } while (0)
|
|
117
|
|
118 #define SET_LAST_FACECHANGE(w) \
|
|
119 do { \
|
|
120 (w)->last_facechange[CURRENT_DISP] = Qzero; \
|
|
121 (w)->last_facechange[DESIRED_DISP] = Qzero; \
|
|
122 (w)->last_facechange[CMOTION_DISP] = Qzero; \
|
|
123 } while (0)
|
|
124
|
|
125
|
102
|
126 #define MARK_DISP_VARIABLE(field) \
|
|
127 ((markobj) (window->field[CURRENT_DISP])); \
|
|
128 ((markobj) (window->field[DESIRED_DISP])); \
|
0
|
129 ((markobj) (window->field[CMOTION_DISP]));
|
|
130
|
|
131 static Lisp_Object
|
|
132 mark_window (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
133 {
|
|
134 struct window *window = XWINDOW (obj);
|
|
135 ((markobj) (window->frame));
|
|
136 ((markobj) (window->mini_p));
|
|
137 ((markobj) (window->next));
|
|
138 ((markobj) (window->prev));
|
|
139 ((markobj) (window->hchild));
|
|
140 ((markobj) (window->vchild));
|
|
141 ((markobj) (window->parent));
|
|
142 ((markobj) (window->buffer));
|
|
143 MARK_DISP_VARIABLE (start);
|
|
144 MARK_DISP_VARIABLE (pointm);
|
|
145 ((markobj) (window->sb_point)); /* #### move to scrollbar.c? */
|
|
146 ((markobj) (window->use_time));
|
|
147 MARK_DISP_VARIABLE (last_modified);
|
|
148 MARK_DISP_VARIABLE (last_point);
|
|
149 MARK_DISP_VARIABLE (last_start);
|
|
150 MARK_DISP_VARIABLE (last_facechange);
|
|
151 ((markobj) (window->line_cache_last_updated));
|
|
152 ((markobj) (window->redisplay_end_trigger));
|
|
153 /* Cached specifiers: */
|
|
154 ((markobj) (window->display_table));
|
|
155 ((markobj) (window->has_modeline_p));
|
|
156 ((markobj) (window->modeline_shadow_thickness));
|
|
157 #ifdef HAVE_SCROLLBARS
|
|
158 ((markobj) (window->scrollbar_width));
|
|
159 ((markobj) (window->scrollbar_height));
|
282
|
160 ((markobj) (window->horizontal_scrollbar_visible_p));
|
|
161 ((markobj) (window->vertical_scrollbar_visible_p));
|
|
162 ((markobj) (window->scrollbar_on_left_p));
|
|
163 ((markobj) (window->scrollbar_on_top_p));
|
0
|
164 ((markobj) (window->scrollbar_pointer));
|
102
|
165 #endif /* HAVE_SCROLLBARS */
|
0
|
166 ((markobj) (window->left_margin_width));
|
|
167 ((markobj) (window->right_margin_width));
|
|
168 #ifdef HAVE_TOOLBARS
|
|
169 ((markobj) (window->toolbar[0]));
|
|
170 ((markobj) (window->toolbar[1]));
|
|
171 ((markobj) (window->toolbar[2]));
|
|
172 ((markobj) (window->toolbar[3]));
|
|
173 ((markobj) (window->toolbar_size[0]));
|
|
174 ((markobj) (window->toolbar_size[1]));
|
|
175 ((markobj) (window->toolbar_size[2]));
|
|
176 ((markobj) (window->toolbar_size[3]));
|
|
177 ((markobj) (window->toolbar_visible_p[0]));
|
|
178 ((markobj) (window->toolbar_visible_p[1]));
|
|
179 ((markobj) (window->toolbar_visible_p[2]));
|
|
180 ((markobj) (window->toolbar_visible_p[3]));
|
|
181 ((markobj) (window->toolbar_buttons_captioned_p));
|
|
182 ((markobj) (window->default_toolbar));
|
|
183 ((markobj) (window->default_toolbar_height));
|
|
184 ((markobj) (window->default_toolbar_width));
|
|
185 ((markobj) (window->default_toolbar_visible_p));
|
102
|
186 #endif /* HAVE_TOOLBARS */
|
0
|
187 ((markobj) (window->minimum_line_ascent));
|
|
188 ((markobj) (window->minimum_line_descent));
|
|
189 ((markobj) (window->use_left_overflow));
|
|
190 ((markobj) (window->use_right_overflow));
|
|
191 #ifdef HAVE_MENUBARS
|
|
192 ((markobj) (window->menubar_visible_p));
|
102
|
193 #endif /* HAVE_MENUBARS */
|
0
|
194 ((markobj) (window->text_cursor_visible_p));
|
|
195 /* End cached specifiers. */
|
|
196 ((markobj) (window->dedicated));
|
|
197 mark_face_cachels (window->face_cachels, markobj);
|
|
198 mark_glyph_cachels (window->glyph_cachels, markobj);
|
173
|
199 return Qnil;
|
0
|
200 }
|
|
201
|
|
202 static void
|
|
203 print_window (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
204 {
|
|
205 char buf[200];
|
|
206
|
|
207 if (print_readably)
|
|
208 error ("printing unreadable object #<window 0x%x>",
|
|
209 XWINDOW (obj)->header.uid);
|
185
|
210
|
0
|
211 write_c_string ("#<window", printcharfun);
|
|
212 if (!NILP (XWINDOW (obj)->buffer))
|
|
213 {
|
|
214 Lisp_Object name = XBUFFER (XWINDOW (obj)->buffer)->name;
|
|
215 write_c_string (" on ", printcharfun);
|
|
216 print_internal (name, printcharfun, 1);
|
|
217 }
|
|
218 sprintf (buf, " 0x%x>", XWINDOW (obj)->header.uid);
|
|
219 write_c_string (buf, printcharfun);
|
|
220 }
|
|
221
|
|
222 static void
|
|
223 finalize_window (void *header, int for_disksave)
|
|
224 {
|
|
225 struct window *w = (struct window *) header;
|
|
226
|
|
227 if (w->line_start_cache)
|
|
228 {
|
|
229 Dynarr_free (w->line_start_cache);
|
|
230 w->line_start_cache = 0;
|
|
231 }
|
|
232
|
|
233 if (w->face_cachels)
|
|
234 {
|
|
235 int i;
|
|
236
|
|
237 for (i = 0; i < Dynarr_length (w->face_cachels); i++)
|
|
238 {
|
|
239 struct face_cachel *cachel = Dynarr_atp (w->face_cachels, i);
|
|
240 if (cachel->merged_faces)
|
|
241 {
|
|
242 Dynarr_free (cachel->merged_faces);
|
|
243 cachel->merged_faces = 0;
|
|
244 }
|
|
245 }
|
|
246 Dynarr_free (w->face_cachels);
|
|
247 w->face_cachels = 0;
|
|
248 }
|
|
249
|
|
250 if (w->glyph_cachels)
|
|
251 {
|
|
252 Dynarr_free (w->glyph_cachels);
|
|
253 w->glyph_cachels = 0;
|
|
254 }
|
|
255 }
|
|
256
|
272
|
257 DEFINE_LRECORD_IMPLEMENTATION ("window", window,
|
|
258 mark_window, print_window, finalize_window,
|
|
259 0, 0, struct window);
|
|
260
|
|
261
|
0
|
262 #define INIT_DISP_VARIABLE(field, initialization) \
|
|
263 p->field[CURRENT_DISP] = initialization; \
|
|
264 p->field[DESIRED_DISP] = initialization; \
|
|
265 p->field[CMOTION_DISP] = initialization;
|
|
266
|
|
267 /* We have an implicit assertion that the first two elements (default
|
|
268 and modeline faces) are always present in the face_element_cache.
|
|
269 Normally redisplay ensures this. However, it is possible for a
|
|
270 window to get created and functions which reference these values
|
|
271 called before redisplay works with the window for the first time.
|
|
272 All callers of allocate_window should therefore call
|
|
273 reset_face_cachels on the created window. We can't do it
|
|
274 here because the window must have its frame pointer set or
|
|
275 reset_face_cachels will fail. */
|
|
276 Lisp_Object
|
|
277 allocate_window (void)
|
|
278 {
|
272
|
279 Lisp_Object val;
|
185
|
280 struct window *p = alloc_lcrecord_type (struct window, lrecord_window);
|
0
|
281
|
|
282 zero_lcrecord (p);
|
|
283 XSETWINDOW (val, p);
|
|
284
|
|
285 p->dead = 0;
|
|
286 p->frame = Qnil;
|
|
287 p->mini_p = Qnil;
|
|
288 p->next = Qnil;
|
|
289 p->prev = Qnil;
|
185
|
290 p->hchild = Qnil;
|
|
291 p->vchild = Qnil;
|
0
|
292 p->parent = Qnil;
|
|
293 p->buffer = Qnil;
|
|
294 INIT_DISP_VARIABLE (start, Fmake_marker ());
|
|
295 INIT_DISP_VARIABLE (pointm, Fmake_marker ());
|
|
296 p->sb_point = Fmake_marker ();
|
|
297 p->use_time = Qzero;
|
|
298 INIT_DISP_VARIABLE (last_modified, Qzero);
|
|
299 INIT_DISP_VARIABLE (last_point, Fmake_marker ());
|
|
300 INIT_DISP_VARIABLE (last_start, Fmake_marker ());
|
|
301 INIT_DISP_VARIABLE (last_facechange, Qzero);
|
185
|
302 p->face_cachels = Dynarr_new (face_cachel);
|
|
303 p->glyph_cachels = Dynarr_new (glyph_cachel);
|
|
304 p->line_start_cache = Dynarr_new (line_start_cache);
|
0
|
305 p->line_cache_last_updated = Qzero;
|
|
306 INIT_DISP_VARIABLE (last_point_x, 0);
|
|
307 INIT_DISP_VARIABLE (last_point_y, 0);
|
|
308 INIT_DISP_VARIABLE (window_end_pos, 0);
|
|
309 p->redisplay_end_trigger = Qnil;
|
|
310 /* cached specifier values: will get set properly later */
|
|
311 p->display_table = Qnil;
|
|
312 p->has_modeline_p = Qnil;
|
|
313 p->modeline_shadow_thickness = Qnil;
|
|
314 #ifdef HAVE_SCROLLBARS
|
|
315 p->scrollbar_width = Qnil;
|
|
316 p->scrollbar_height = Qnil;
|
282
|
317 p->horizontal_scrollbar_visible_p = Qnil;
|
|
318 p->vertical_scrollbar_visible_p = Qnil;
|
|
319 p->scrollbar_on_left_p = Qnil;
|
|
320 p->scrollbar_on_top_p = Qnil;
|
0
|
321 #endif
|
|
322 p->left_margin_width = Qnil;
|
|
323 p->right_margin_width = Qnil;
|
|
324 #ifdef HAVE_TOOLBARS
|
|
325 p->toolbar_size[0] = Qnil;
|
|
326 p->toolbar_size[1] = Qnil;
|
|
327 p->toolbar_size[2] = Qnil;
|
|
328 p->toolbar_size[3] = Qnil;
|
272
|
329 p->toolbar_buttons_captioned_p = Qnil;
|
0
|
330 #endif
|
|
331 p->minimum_line_ascent = Qnil;
|
|
332 p->minimum_line_descent = Qnil;
|
|
333 p->use_left_overflow = Qnil;
|
|
334 p->use_right_overflow = Qnil;
|
|
335 #ifdef HAVE_MENUBARS
|
|
336 p->menubar_visible_p = Qnil;
|
|
337 #endif
|
|
338 p->text_cursor_visible_p = Qnil;
|
|
339 /* end cached specifier values. */
|
|
340
|
|
341 p->dedicated = Qnil;
|
|
342 p->windows_changed = 1;
|
|
343 p->shadow_thickness_changed = 1;
|
|
344
|
173
|
345 return val;
|
0
|
346 }
|
|
347 #undef INIT_DISP_VARIABLE
|
|
348
|
|
349 /*
|
|
350 * The redisplay structures used to be stored with each window. While
|
|
351 * they are logically something associated with frames they can't be
|
|
352 * stored there with a redisplay which handles variable height lines.
|
|
353 * Lines in horizontally split windows might not line up. So they get
|
|
354 * stored with the windows.
|
|
355 *
|
|
356 * The problem with this is window configurations. When restoring a
|
|
357 * window configuration it now becomes problematic to do an
|
|
358 * incremental redisplay. The solution is to store the redisplay
|
|
359 * structures with the frame as they should be but laid out in the
|
|
360 * same manner as the window structure. Thus is born the window
|
|
361 * mirror.
|
|
362 *
|
|
363 * It also becomes a convenient place to stick scrollbar instances
|
|
364 * since they extrapolate out to having the same problem described for
|
|
365 * the display structures.
|
|
366 */
|
|
367
|
102
|
368 /* Create a new window mirror structure and associated redisplay
|
0
|
369 structs. */
|
|
370 static struct window_mirror *
|
|
371 new_window_mirror (struct frame *f)
|
|
372 {
|
185
|
373 struct window_mirror *t = xnew_and_zero (struct window_mirror);
|
0
|
374
|
|
375 t->frame = f;
|
|
376
|
185
|
377 t->current_display_lines = Dynarr_new (display_line);
|
|
378 t->desired_display_lines = Dynarr_new (display_line);
|
0
|
379 t->buffer = NULL;
|
|
380
|
|
381 #ifdef HAVE_SCROLLBARS
|
|
382 t->scrollbar_vertical_instance = NULL;
|
|
383 t->scrollbar_horizontal_instance = NULL;
|
|
384 #endif
|
|
385
|
|
386 return t;
|
|
387 }
|
|
388
|
|
389 /* Synchronize the mirror structure with a given window structure.
|
|
390 This is normally called from update_frame_window_mirror with a
|
|
391 starting window of f->root_window. */
|
|
392 static struct window_mirror *
|
|
393 update_mirror_internal (Lisp_Object win, struct window_mirror *mir)
|
|
394 {
|
|
395 if (NILP (win))
|
|
396 {
|
|
397 if (mir)
|
|
398 {
|
|
399 free_window_mirror (mir);
|
272
|
400 mir = NULL;
|
0
|
401 }
|
|
402 return mir;
|
|
403 }
|
|
404 else
|
|
405 if (!mir)
|
|
406 mir = new_window_mirror (XFRAME (XWINDOW (win)->frame));
|
|
407
|
102
|
408 mir->next = update_mirror_internal (XWINDOW (win)->next, mir->next);
|
0
|
409 mir->hchild = update_mirror_internal (XWINDOW (win)->hchild, mir->hchild);
|
|
410 mir->vchild = update_mirror_internal (XWINDOW (win)->vchild, mir->vchild);
|
|
411
|
|
412 /*
|
|
413 * If the redisplay structs are not empty and the mirror has
|
|
414 * children, then this mirror structure was formerly being used for
|
|
415 * display but is no longer. Reset its current display structs so
|
|
416 * that redisplay doesn't accidentally think they are accurate if it
|
|
417 * is later used for display purposes once again. Also, mark the
|
|
418 * scrollbar instance as not active.
|
|
419 */
|
|
420 if (mir->vchild || mir->hchild)
|
|
421 {
|
|
422 /* The redisplay structures are big. Leaving them around in
|
|
423 non-leaf windows can add up to a lot of wasted space. So
|
|
424 don't do it. */
|
|
425 free_display_structs (mir);
|
185
|
426 mir->current_display_lines = Dynarr_new (display_line);
|
|
427 mir->desired_display_lines = Dynarr_new (display_line);
|
0
|
428
|
|
429 #ifdef HAVE_SCROLLBARS
|
|
430 update_window_scrollbars (XWINDOW (win), mir, 0, 0);
|
|
431 #endif
|
|
432 mir->buffer = NULL;
|
|
433 }
|
|
434
|
|
435 return mir;
|
|
436 }
|
|
437
|
|
438 /* Given a window mirror, determine which real window it contains the
|
|
439 redisplay structures for. */
|
|
440 static Lisp_Object
|
|
441 real_window_internal (Lisp_Object win, struct window_mirror *rmir,
|
|
442 struct window_mirror *mir)
|
|
443 {
|
|
444 Lisp_Object retval;
|
|
445
|
|
446 for (; !NILP (win) && rmir ; win = XWINDOW (win)->next, rmir = rmir->next)
|
|
447 {
|
|
448 if (mir == rmir)
|
|
449 return win;
|
|
450 if (!NILP (XWINDOW (win)->vchild))
|
|
451 {
|
|
452 retval = real_window_internal (XWINDOW (win)->vchild, rmir->vchild,
|
|
453 mir);
|
|
454 if (!NILP (retval))
|
|
455 return retval;
|
|
456 }
|
|
457 if (!NILP (XWINDOW (win)->hchild))
|
|
458 {
|
|
459 retval = real_window_internal (XWINDOW (win)->hchild, rmir->hchild,
|
|
460 mir);
|
|
461 if (!NILP (retval))
|
|
462 return retval;
|
|
463 }
|
|
464 }
|
|
465
|
|
466 return Qnil;
|
|
467 }
|
|
468
|
|
469 /* Given a real window, find the mirror structure which contains its
|
|
470 redisplay structures. */
|
|
471 static struct window_mirror *
|
|
472 find_window_mirror_internal (Lisp_Object win, struct window_mirror *rmir,
|
|
473 struct window *w)
|
|
474 {
|
|
475 for (; !NILP (win); win = XWINDOW (win)->next, rmir = rmir->next)
|
|
476 {
|
|
477 if (w == XWINDOW (win))
|
|
478 return rmir;
|
272
|
479
|
|
480 if (!NILP (XWINDOW (win)->vchild))
|
|
481 {
|
|
482 struct window_mirror *retval =
|
|
483 find_window_mirror_internal (XWINDOW (win)->vchild,
|
|
484 rmir->vchild, w);
|
|
485 if (retval) return retval;
|
|
486 }
|
|
487
|
|
488 if (!NILP (XWINDOW (win)->hchild))
|
|
489 {
|
|
490 struct window_mirror *retval =
|
|
491 find_window_mirror_internal (XWINDOW (win)->hchild,
|
|
492 rmir->hchild, w);
|
|
493 if (retval) return retval;
|
|
494 }
|
0
|
495 }
|
|
496
|
|
497 return 0;
|
|
498 }
|
|
499
|
|
500 /* Update the mirror structure for the given frame. */
|
|
501 void
|
|
502 update_frame_window_mirror (struct frame *f)
|
|
503 {
|
|
504 f->root_mirror = update_mirror_internal (f->root_window, f->root_mirror);
|
|
505 f->mirror_dirty = 0;
|
|
506 }
|
|
507
|
|
508 /* Free a given mirror structure along with all of its children as
|
|
509 well as their associated display structures. */
|
|
510 void
|
|
511 free_window_mirror (struct window_mirror *mir)
|
|
512 {
|
|
513 while (mir)
|
|
514 {
|
272
|
515 struct window_mirror *prev = mir;
|
0
|
516 if (mir->hchild) free_window_mirror (mir->hchild);
|
|
517 if (mir->vchild) free_window_mirror (mir->vchild);
|
|
518 #ifdef HAVE_SCROLLBARS
|
|
519 release_window_mirror_scrollbars (mir);
|
|
520 #endif
|
|
521 free_display_structs (mir);
|
|
522 mir = mir->next;
|
272
|
523 xfree (prev);
|
0
|
524 }
|
|
525 }
|
|
526
|
|
527 /* Given a mirror structure, return the window it mirrors. Calls
|
|
528 real_window_internal to do most of the work. */
|
|
529 Lisp_Object
|
|
530 real_window (struct window_mirror *mir, int no_abort)
|
|
531 {
|
272
|
532 Lisp_Object retval = real_window_internal (mir->frame->root_window,
|
|
533 mir->frame->root_mirror, mir);
|
0
|
534 if (NILP (retval) && !no_abort)
|
|
535 abort ();
|
|
536
|
|
537 return retval;
|
|
538 }
|
|
539
|
|
540 /* Given a real window, return its mirror structure. Calls
|
|
541 find_window_mirror_internal to do all of the work. */
|
|
542 struct window_mirror *
|
|
543 find_window_mirror (struct window *w)
|
|
544 {
|
|
545 struct frame *f = XFRAME (w->frame);
|
|
546 if (f->mirror_dirty)
|
|
547 update_frame_window_mirror (f);
|
|
548 return find_window_mirror_internal (f->root_window, f->root_mirror, w);
|
|
549 }
|
|
550
|
|
551 /*****************************************************************************
|
|
552 find_window_by_pixel_pos
|
|
553
|
|
554 Given a pixel position relative to a frame, find the window at that
|
|
555 position.
|
|
556 ****************************************************************************/
|
|
557 struct window *
|
272
|
558 find_window_by_pixel_pos (int pix_x, int pix_y, Lisp_Object win)
|
0
|
559 {
|
|
560 if (NILP (win))
|
|
561 return 0;
|
|
562
|
|
563 for (; !NILP (win); win = XWINDOW (win)->next)
|
|
564 {
|
272
|
565 struct window *w;
|
|
566
|
|
567 if (!NILP (XWINDOW (win)->vchild))
|
|
568 {
|
|
569 w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->vchild);
|
|
570 if (w) return w;
|
|
571 }
|
|
572 if (!NILP (XWINDOW (win)->hchild))
|
|
573 {
|
|
574 w = find_window_by_pixel_pos (pix_x, pix_y, XWINDOW (win)->hchild);
|
|
575 if (w) return w;
|
|
576 }
|
0
|
577 w = XWINDOW (win);
|
|
578 if (pix_x >= WINDOW_LEFT (w)
|
|
579 && pix_x <= WINDOW_RIGHT (w)
|
|
580 && pix_y >= WINDOW_TOP (w)
|
|
581 && pix_y <= WINDOW_BOTTOM (w))
|
|
582 return w;
|
|
583 }
|
272
|
584 return NULL;
|
0
|
585 }
|
|
586
|
|
587 /* Return a pointer to the display structures for the given window. */
|
|
588 display_line_dynarr *
|
|
589 window_display_lines (struct window *w, int which)
|
|
590 {
|
|
591 struct window_mirror *t;
|
|
592
|
|
593 if (XFRAME (w->frame)->mirror_dirty)
|
|
594 update_frame_window_mirror (XFRAME (w->frame));
|
|
595 t = find_window_mirror (w);
|
|
596 if (!t)
|
|
597 abort ();
|
|
598
|
|
599 if (which == CURRENT_DISP)
|
|
600 return t->current_display_lines;
|
|
601 else if (which == DESIRED_DISP)
|
|
602 return t->desired_display_lines;
|
|
603 else if (which == CMOTION_DISP)
|
|
604 /* The CMOTION_DISP display lines are global. */
|
|
605 return cmotion_display_lines;
|
|
606 else
|
|
607 abort ();
|
|
608
|
|
609 return 0; /* shut up compiler */
|
|
610 }
|
|
611
|
|
612 struct buffer *
|
|
613 window_display_buffer (struct window *w)
|
|
614 {
|
|
615 struct window_mirror *t;
|
|
616
|
|
617 if (XFRAME (w->frame)->mirror_dirty)
|
|
618 update_frame_window_mirror (XFRAME (w->frame));
|
|
619 t = find_window_mirror (w);
|
|
620 if (!t)
|
|
621 abort ();
|
|
622
|
|
623 return t->buffer;
|
|
624 }
|
|
625
|
|
626 void
|
|
627 set_window_display_buffer (struct window *w, struct buffer *b)
|
|
628 {
|
|
629 struct window_mirror *t;
|
|
630
|
|
631 if (XFRAME (w->frame)->mirror_dirty)
|
|
632 update_frame_window_mirror (XFRAME (w->frame));
|
|
633 t = find_window_mirror (w);
|
|
634 if (!t)
|
|
635 abort ();
|
|
636
|
|
637 t->buffer = b;
|
|
638 }
|
|
639
|
|
640
|
102
|
641 /* Determining a window's position based solely on its pixel
|
0
|
642 positioning doesn't work. Instead, we do it the intelligent way,
|
|
643 by checking its positioning in the window hierarchy. */
|
|
644 int
|
|
645 window_is_leftmost (struct window *w)
|
|
646 {
|
|
647 Lisp_Object parent, current_ancestor, window;
|
|
648
|
|
649 XSETWINDOW (window, w);
|
|
650
|
|
651 parent = XWINDOW (window)->parent;
|
|
652 current_ancestor = window;
|
|
653
|
|
654 while (!NILP (parent))
|
|
655 {
|
|
656 if (!NILP (XWINDOW (parent)->hchild) &&
|
|
657 !EQ (XWINDOW (parent)->hchild, current_ancestor))
|
|
658 return 0;
|
|
659
|
|
660 current_ancestor = parent;
|
|
661 parent = XWINDOW (parent)->parent;
|
|
662 }
|
|
663
|
|
664 return 1;
|
|
665 }
|
|
666
|
|
667 int
|
|
668 window_is_rightmost (struct window *w)
|
|
669 {
|
|
670 Lisp_Object parent, current_ancestor, window;
|
|
671
|
|
672 XSETWINDOW (window, w);
|
|
673
|
|
674 parent = XWINDOW (window)->parent;
|
|
675 current_ancestor = window;
|
|
676
|
|
677 while (!NILP (parent))
|
|
678 {
|
|
679 if (!NILP (XWINDOW (parent)->hchild)
|
|
680 && !NILP (XWINDOW (current_ancestor)->next))
|
|
681 return 0;
|
|
682
|
|
683 current_ancestor = parent;
|
|
684 parent = XWINDOW (parent)->parent;
|
|
685 }
|
|
686
|
|
687 return 1;
|
|
688 }
|
|
689
|
|
690 static int
|
|
691 window_full_width_p (struct window *w)
|
|
692 {
|
|
693 return window_is_leftmost (w) && window_is_rightmost (w);
|
|
694 }
|
|
695
|
|
696 static int
|
|
697 window_is_highest (struct window *w)
|
|
698 {
|
|
699 Lisp_Object parent, current_ancestor, window;
|
|
700
|
|
701 XSETWINDOW (window, w);
|
|
702
|
|
703 parent = XWINDOW (window)->parent;
|
|
704 current_ancestor = window;
|
|
705
|
|
706 while (!NILP (parent))
|
|
707 {
|
|
708 if (!NILP (XWINDOW (parent)->vchild) &&
|
|
709 !EQ (XWINDOW (parent)->vchild, current_ancestor))
|
|
710 return 0;
|
|
711
|
|
712 current_ancestor = parent;
|
|
713 parent = XWINDOW (parent)->parent;
|
|
714 }
|
|
715
|
|
716 /* This is really to catch the minibuffer but we make it generic in
|
|
717 case we ever change things around to let the minibuffer be on top. */
|
|
718 if (NILP (XWINDOW (current_ancestor)->prev))
|
|
719 return 1;
|
|
720 else
|
|
721 return 0;
|
|
722 }
|
|
723
|
|
724 static int
|
|
725 window_is_lowest (struct window *w)
|
|
726 {
|
|
727 Lisp_Object parent, current_ancestor, window;
|
|
728
|
|
729 XSETWINDOW (window, w);
|
|
730
|
|
731 parent = XWINDOW (window)->parent;
|
|
732 current_ancestor = window;
|
|
733
|
|
734 while (!NILP (parent))
|
|
735 {
|
|
736 if (!NILP (XWINDOW (parent)->vchild)
|
|
737 && !NILP (XWINDOW (current_ancestor)->next))
|
|
738 return 0;
|
|
739
|
|
740 current_ancestor = parent;
|
|
741 parent = XWINDOW (parent)->parent;
|
|
742 }
|
|
743
|
|
744 return 1;
|
|
745 }
|
|
746
|
|
747 #if 0 /* not currently used */
|
|
748
|
|
749 static int
|
|
750 window_full_height_p (struct window *w)
|
|
751 {
|
|
752 return window_is_highest (w) && window_is_lowest (w);
|
|
753 }
|
|
754
|
|
755 #endif
|
|
756
|
|
757 int
|
|
758 window_truncation_on (struct window *w)
|
|
759 {
|
|
760 /* Horizontally scrolled windows are truncated. */
|
|
761 if (w->hscroll)
|
|
762 return 1;
|
|
763
|
|
764 /* If truncate_partial_width_windows is true and the window is not
|
|
765 the full width of the frame it is truncated. */
|
|
766 if (truncate_partial_width_windows
|
|
767 && !(window_is_leftmost (w) && window_is_rightmost (w)))
|
|
768 return 1;
|
|
769
|
|
770 /* If the window's buffer's value of truncate_lines is non-nil, then
|
|
771 the window is truncated. */
|
|
772 if (!NILP (XBUFFER (w->buffer)->truncate_lines))
|
|
773 return 1;
|
|
774
|
|
775 return 0;
|
|
776 }
|
|
777
|
|
778 int
|
|
779 window_needs_vertical_divider (struct window *w)
|
|
780 {
|
|
781 #ifdef HAVE_SCROLLBARS
|
149
|
782 return (!window_scrollbar_width (w) &&
|
282
|
783 (!NILP (w->scrollbar_on_left_p) ?
|
149
|
784 !window_is_leftmost (w) :
|
|
785 !window_is_rightmost (w)));
|
0
|
786 #else
|
149
|
787 return !window_is_leftmost (w);
|
102
|
788 #endif /* HAVE_SCROLLBARS */
|
0
|
789 }
|
|
790
|
|
791 int
|
|
792 window_scrollbar_width (struct window *w)
|
|
793 {
|
|
794 #ifdef HAVE_SCROLLBARS
|
|
795 if (!WINDOW_WIN_P (w)
|
|
796 || MINI_WINDOW_P (w)
|
282
|
797 || NILP (w->buffer)
|
|
798 || NILP (w->vertical_scrollbar_visible_p))
|
0
|
799 /* #### when does NILP (w->buffer) happen? */
|
|
800 return 0;
|
|
801
|
|
802 return XINT (w->scrollbar_width);
|
|
803 #else
|
|
804 return 0;
|
102
|
805 #endif /* HAVE_SCROLLBARS */
|
0
|
806 }
|
|
807
|
|
808 /* Horizontal scrollbars are only active on windows with truncation
|
|
809 turned on. */
|
|
810 int
|
|
811 window_scrollbar_height (struct window *w)
|
|
812 {
|
|
813 #ifdef HAVE_SCROLLBARS
|
|
814 if (!WINDOW_WIN_P (w)
|
|
815 || MINI_WINDOW_P (w)
|
|
816 || NILP (w->buffer)
|
282
|
817 || NILP (w->horizontal_scrollbar_visible_p)
|
0
|
818 || !window_truncation_on (w))
|
|
819 return 0;
|
|
820
|
|
821 return XINT (w->scrollbar_height);
|
|
822 #else
|
|
823 return 0;
|
102
|
824 #endif /* HAVE_SCROLLBARS */
|
0
|
825 }
|
|
826
|
|
827 int
|
|
828 window_modeline_height (struct window *w)
|
|
829 {
|
|
830 struct frame *f = XFRAME (w->frame);
|
|
831 int modeline_height;
|
|
832
|
|
833 if (MINI_WINDOW_P (w) || NILP (w->buffer))
|
|
834 {
|
|
835 modeline_height = 0;
|
|
836 }
|
|
837 else if (!WINDOW_HAS_MODELINE_P (w))
|
|
838 {
|
|
839 if (window_scrollbar_height (w))
|
|
840 modeline_height = 0;
|
|
841 else
|
|
842 {
|
|
843 modeline_height = FRAMEMETH (f, divider_height, ());
|
|
844
|
|
845 if (!EQ (Qzero, w->modeline_shadow_thickness) && FRAME_WIN_P (f))
|
|
846 modeline_height += (2 * MODELINE_SHADOW_THICKNESS (w));
|
|
847 }
|
|
848 }
|
|
849 else
|
|
850 {
|
|
851 if (noninteractive)
|
|
852 modeline_height = 0;
|
|
853 else
|
|
854 {
|
|
855 display_line_dynarr *dla;
|
|
856
|
|
857 /* We don't force a regeneration of the modeline here.
|
|
858 Instead it is now a precondition that any function calling
|
|
859 this should make sure that one of these structures is
|
|
860 up-to-date. In practice this only affects two internal
|
|
861 redisplay functions, regenerate_window and
|
|
862 regenerate_window_point_center. */
|
|
863 /* We check DESIRED_DISP because if it is valid it is more
|
|
864 up-to-date than CURRENT_DISP. For calls to this outside
|
|
865 of redisplay it doesn't matter which structure we check
|
|
866 since there is a redisplay condition that these
|
|
867 structures be identical outside of redisplay. */
|
|
868 dla = window_display_lines (w, DESIRED_DISP);
|
|
869 if (dla && Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline)
|
|
870 modeline_height = (Dynarr_atp (dla, 0)->ascent +
|
|
871 Dynarr_atp (dla, 0)->descent);
|
|
872 else
|
|
873 {
|
|
874 dla = window_display_lines (w, CURRENT_DISP);
|
|
875 if (dla && Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline)
|
|
876 modeline_height = (Dynarr_atp (dla, 0)->ascent +
|
|
877 Dynarr_atp (dla, 0)->descent);
|
|
878 else
|
|
879 /* This should be an abort except I'm not yet 100%
|
|
880 confident that it won't ever get hit (though I
|
|
881 haven't been able to trigger it). It is extremely
|
|
882 unlikely to cause any noticable problem and even if
|
|
883 it does it will be a minor display glitch. */
|
|
884 /* #### Bullshit alert. It does get hit and it causes
|
|
885 noticeable glitches. real_current_modeline_height
|
|
886 is a kludge to fix this for 19.14. */
|
|
887 modeline_height = real_current_modeline_height (w);
|
|
888 }
|
|
889
|
|
890 if (!EQ (Qzero, w->modeline_shadow_thickness) && FRAME_WIN_P (f))
|
|
891 modeline_height += (2 * MODELINE_SHADOW_THICKNESS (w));
|
|
892 }
|
|
893 }
|
|
894
|
|
895 return modeline_height;
|
|
896 }
|
|
897
|
|
898 /*****************************************************************************
|
|
899 margin_width_internal
|
|
900
|
|
901 For a given window, return the width in pixels of the specified margin.
|
|
902 ****************************************************************************/
|
|
903 static int
|
|
904 margin_width_internal (struct window *w, int left_margin)
|
|
905 {
|
|
906 struct buffer *b;
|
|
907 int window_cwidth = window_char_width (w, 1);
|
|
908 int margin_cwidth;
|
|
909 int font_width;
|
272
|
910 Lisp_Object window;
|
0
|
911
|
|
912 /* We might be getting called on a non-leaf. */
|
|
913 if (NILP (w->buffer))
|
|
914 return 0;
|
|
915
|
|
916 /* The minibuffer never has margins. */
|
|
917 if (MINI_WINDOW_P (w))
|
|
918 return 0;
|
|
919
|
|
920 XSETWINDOW (window, w);
|
|
921 b = XBUFFER (w->buffer);
|
|
922 margin_cwidth = (left_margin ? XINT (w->left_margin_width) :
|
|
923 XINT (w->right_margin_width));
|
|
924
|
|
925 default_face_height_and_width (window, 0, &font_width);
|
|
926
|
|
927 /* The left margin takes precedence over the right margin so we
|
|
928 subtract its width from the space available for the right
|
|
929 margin. */
|
|
930 if (!left_margin)
|
|
931 window_cwidth -= XINT (w->left_margin_width);
|
|
932
|
|
933 /* The margin cannot be wider than the window is. We allow the
|
|
934 value to be bigger since it is possible for the user to enlarge
|
|
935 the window such that the left margin value would no longer be too
|
|
936 big, but we won't return a value that is larger. */
|
|
937 if (margin_cwidth > window_cwidth)
|
|
938 margin_cwidth = window_cwidth;
|
|
939
|
|
940 /* At the user level the margin is always specified in characters.
|
|
941 Internally however it is manipulated in terms of pixels. */
|
173
|
942 return margin_cwidth * font_width;
|
0
|
943 }
|
|
944
|
|
945 int
|
|
946 window_left_margin_width (struct window *w)
|
|
947 {
|
|
948 return margin_width_internal (w, 1);
|
|
949 }
|
|
950
|
|
951 int
|
|
952 window_right_margin_width (struct window *w)
|
|
953 {
|
|
954 return margin_width_internal (w, 0);
|
|
955 }
|
|
956
|
|
957 static int
|
|
958 window_top_toolbar_height (struct window *w)
|
|
959 {
|
|
960 /* #### implement this shit. */
|
|
961 return 0;
|
|
962 }
|
|
963
|
|
964 /* #### Currently used in scrollbar.c. Does it actually need to be? */
|
|
965 int
|
|
966 window_bottom_toolbar_height (struct window *w)
|
|
967 {
|
|
968 return 0;
|
|
969 }
|
|
970
|
|
971 static int
|
|
972 window_left_toolbar_width (struct window *w)
|
|
973 {
|
|
974 return 0;
|
|
975 }
|
|
976
|
|
977 static int
|
|
978 window_right_toolbar_width (struct window *w)
|
|
979 {
|
|
980 return 0;
|
|
981 }
|
|
982
|
|
983 /*****************************************************************************
|
|
984 Window Gutters
|
|
985
|
|
986 The gutters of a window are those areas in the boundary defined by
|
|
987 w->pixel_top, w->pixel_left, w->pixel_height and w->pixel_width which
|
|
988 do not contain text. Items which may be in the gutters include
|
|
989 scrollbars, toolbars and modelines. The margin areas are not
|
|
990 included. This is an exception made because redisplay special cases
|
|
991 the handling of those areas in many places in such a way that
|
|
992 including them in the gutter area would make life difficult.
|
|
993
|
|
994 The size functions refer to height for the bottom and top gutters and
|
|
995 width for the left and right gutters. The starting position
|
|
996 functions refer to the Y coord for bottom and top gutters and the X
|
|
997 coord for left and right gutters. All starting positions are
|
|
998 relative to the frame, not the window.
|
|
999 ****************************************************************************/
|
|
1000
|
|
1001 int
|
|
1002 window_top_gutter_height (struct window *w)
|
|
1003 {
|
|
1004 int toolbar_height = window_top_toolbar_height (w);
|
|
1005
|
|
1006 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
1007 return 0;
|
|
1008
|
|
1009 #ifdef HAVE_SCROLLBARS
|
282
|
1010 if (!NILP (w->scrollbar_on_top_p))
|
0
|
1011 return window_scrollbar_height (w) + toolbar_height;
|
|
1012 else
|
|
1013 #endif
|
|
1014 return toolbar_height;
|
|
1015 }
|
|
1016
|
|
1017 int
|
|
1018 window_bottom_gutter_height (struct window *w)
|
|
1019 {
|
185
|
1020 int other_height;
|
0
|
1021
|
|
1022 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
1023 return 0;
|
|
1024 else
|
|
1025 other_height =
|
|
1026 window_modeline_height (w) + window_bottom_toolbar_height (w);
|
|
1027
|
|
1028 #ifdef HAVE_SCROLLBARS
|
282
|
1029 if (NILP (w->scrollbar_on_top_p))
|
0
|
1030 return window_scrollbar_height (w) + other_height;
|
|
1031 else
|
|
1032 #endif
|
|
1033 return other_height;
|
|
1034 }
|
|
1035
|
|
1036 static int
|
|
1037 window_left_right_gutter_width_internal (struct window *w, int modeline)
|
|
1038 {
|
|
1039 struct frame *f = XFRAME (w->frame);
|
|
1040 int scrollbar_width = window_scrollbar_width (w);
|
|
1041
|
|
1042 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
1043 return 0;
|
|
1044
|
|
1045 if (!modeline)
|
|
1046 {
|
|
1047 if (scrollbar_width)
|
|
1048 return scrollbar_width;
|
|
1049 else if (window_needs_vertical_divider (w))
|
|
1050 return FRAMEMETH (f, divider_width, ());
|
|
1051 else
|
|
1052 return 0;
|
|
1053 }
|
|
1054 else
|
|
1055 {
|
|
1056 /* The shadows on the 3D modelines provide a visual break
|
|
1057 between the modelines of horizontally split windows. 2D
|
|
1058 modelines need some help, though. */
|
|
1059 if (!EQ (Qzero, w->modeline_shadow_thickness))
|
|
1060 return 0;
|
|
1061 else if (window_needs_vertical_divider (w))
|
|
1062 return FRAMEMETH (f, divider_width, ());
|
|
1063 else
|
|
1064 return 0;
|
|
1065 }
|
|
1066 }
|
|
1067
|
|
1068 int
|
|
1069 window_left_gutter_width (struct window *w, int modeline)
|
|
1070 {
|
|
1071 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
1072 return 0;
|
|
1073
|
|
1074 #ifdef HAVE_SCROLLBARS
|
282
|
1075 if (!NILP (w->scrollbar_on_left_p))
|
0
|
1076 {
|
|
1077 #endif
|
|
1078 return (window_left_right_gutter_width_internal (w, modeline) +
|
|
1079 window_left_toolbar_width (w));
|
|
1080 #ifdef HAVE_SCROLLBARS
|
|
1081 }
|
|
1082 else
|
|
1083 return window_left_toolbar_width (w);
|
|
1084 #endif
|
|
1085 }
|
|
1086
|
|
1087 int
|
|
1088 window_right_gutter_width (struct window *w, int modeline)
|
|
1089 {
|
|
1090 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
1091 return 0;
|
|
1092
|
|
1093 #ifdef HAVE_SCROLLBARS
|
282
|
1094 if (NILP (w->scrollbar_on_left_p))
|
0
|
1095 {
|
|
1096 return (window_left_right_gutter_width_internal (w, modeline) +
|
|
1097 window_right_toolbar_width (w));
|
|
1098 }
|
|
1099 else
|
|
1100 #endif
|
|
1101 return window_right_toolbar_width (w);
|
|
1102 }
|
|
1103
|
|
1104
|
20
|
1105 DEFUN ("windowp", Fwindowp, 1, 1, 0, /*
|
0
|
1106 Return t if OBJ is a window.
|
20
|
1107 */
|
|
1108 (obj))
|
0
|
1109 {
|
173
|
1110 return WINDOWP (obj) ? Qt : Qnil;
|
0
|
1111 }
|
|
1112
|
20
|
1113 DEFUN ("window-live-p", Fwindow_live_p, 1, 1, 0, /*
|
0
|
1114 Return t if OBJ is a window which is currently visible.
|
20
|
1115 */
|
|
1116 (obj))
|
0
|
1117 {
|
173
|
1118 return WINDOWP (obj) && WINDOW_LIVE_P (XWINDOW (obj)) ? Qt : Qnil;
|
0
|
1119 }
|
|
1120
|
20
|
1121 DEFUN ("selected-window", Fselected_window, 0, 1, 0, /*
|
0
|
1122 Return the window that the cursor now appears in and commands apply to.
|
|
1123 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return
|
|
1124 the selected window used by that frame. If CON-DEV-OR-FRAME is a device,
|
|
1125 then the selected frame on that device will be used. If CON-DEV-OR-FRAME
|
|
1126 is a console, the selected frame on that console's selected device will
|
|
1127 be used. Otherwise, the selected frame is used.
|
20
|
1128 */
|
|
1129 (con_dev_or_frame))
|
0
|
1130 {
|
|
1131 if (NILP (con_dev_or_frame) && NILP (Fselected_device (Qnil)))
|
|
1132 return Qnil; /* happens at startup */
|
|
1133
|
272
|
1134 {
|
|
1135 struct frame *f = decode_frame_or_selected (con_dev_or_frame);
|
|
1136 return FRAME_SELECTED_WINDOW (f);
|
|
1137 }
|
0
|
1138 }
|
|
1139
|
20
|
1140 DEFUN ("minibuffer-window", Fminibuffer_window, 0, 1, 0, /*
|
0
|
1141 Return the window used now for minibuffers.
|
|
1142 If the optional argument CON-DEV-OR-FRAME is specified and is a frame, return
|
|
1143 the minibuffer window used by that frame. If CON-DEV-OR-FRAME is a device,
|
|
1144 then the selected frame on that device will be used. If CON-DEV-OR-FRAME
|
|
1145 is a console, the selected frame on that console's selected device will
|
|
1146 be used. Otherwise, the selected frame is used.
|
20
|
1147 */
|
|
1148 (con_dev_or_frame))
|
0
|
1149 {
|
272
|
1150 return FRAME_MINIBUF_WINDOW (decode_frame_or_selected (con_dev_or_frame));
|
0
|
1151 }
|
|
1152
|
20
|
1153 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 1, 1, 0, /*
|
0
|
1154 Return non-nil if WINDOW is a minibuffer window.
|
20
|
1155 */
|
|
1156 (window))
|
0
|
1157 {
|
173
|
1158 return MINI_WINDOW_P (decode_window (window)) ? Qt : Qnil;
|
0
|
1159 }
|
|
1160
|
20
|
1161 DEFUN ("window-first-hchild", Fwindow_first_hchild, 1, 1, 0, /*
|
0
|
1162 Return the first horizontal child of WINDOW, or nil.
|
20
|
1163 */
|
|
1164 (window))
|
0
|
1165 {
|
102
|
1166 return decode_window (window)->hchild;
|
0
|
1167 }
|
|
1168
|
20
|
1169 DEFUN ("window-first-vchild", Fwindow_first_vchild, 1, 1, 0, /*
|
0
|
1170 Return the first vertical child of WINDOW, or nil.
|
20
|
1171 */
|
|
1172 (window))
|
0
|
1173 {
|
102
|
1174 return decode_window (window)->vchild;
|
0
|
1175 }
|
|
1176
|
20
|
1177 DEFUN ("window-next-child", Fwindow_next_child, 1, 1, 0, /*
|
0
|
1178 Return the next window on the same level as WINDOW, or nil.
|
20
|
1179 */
|
|
1180 (window))
|
0
|
1181 {
|
102
|
1182 return decode_window (window)->next;
|
0
|
1183 }
|
|
1184
|
20
|
1185 DEFUN ("window-previous-child", Fwindow_previous_child, 1, 1, 0, /*
|
0
|
1186 Return the previous window on the same level as WINDOW, or nil.
|
20
|
1187 */
|
|
1188 (window))
|
0
|
1189 {
|
102
|
1190 return decode_window (window)->prev;
|
0
|
1191 }
|
|
1192
|
20
|
1193 DEFUN ("window-parent", Fwindow_parent, 1, 1, 0, /*
|
0
|
1194 Return the parent of WINDOW, or nil.
|
20
|
1195 */
|
|
1196 (window))
|
0
|
1197 {
|
102
|
1198 return decode_window (window)->parent;
|
0
|
1199 }
|
|
1200
|
20
|
1201 DEFUN ("window-lowest-p", Fwindow_lowest_p, 1, 1, 0, /*
|
0
|
1202 Return non-nil if WINDOW is along the bottom of its frame.
|
20
|
1203 */
|
|
1204 (window))
|
0
|
1205 {
|
102
|
1206 return window_is_lowest (decode_window (window)) ? Qt : Qnil;
|
0
|
1207 }
|
|
1208
|
20
|
1209 DEFUN ("window-highest-p", Fwindow_highest_p, 1, 1, 0, /*
|
0
|
1210 Return non-nil if WINDOW is along the top of its frame.
|
20
|
1211 */
|
|
1212 (window))
|
0
|
1213 {
|
102
|
1214 return window_is_highest (decode_window (window)) ? Qt : Qnil;
|
0
|
1215 }
|
|
1216
|
20
|
1217 DEFUN ("window-leftmost-p", Fwindow_leftmost_p, 1, 1, 0, /*
|
0
|
1218 Return non-nil if WINDOW is along the left edge of its frame.
|
20
|
1219 */
|
|
1220 (window))
|
0
|
1221 {
|
102
|
1222 return window_is_leftmost (decode_window (window)) ? Qt : Qnil;
|
0
|
1223 }
|
|
1224
|
20
|
1225 DEFUN ("window-rightmost-p", Fwindow_rightmost_p, 1, 1, 0, /*
|
0
|
1226 Return non-nil if WINDOW is along the right edge of its frame.
|
20
|
1227 */
|
|
1228 (window))
|
0
|
1229 {
|
102
|
1230 return window_is_rightmost (decode_window (window)) ? Qt : Qnil;
|
0
|
1231 }
|
|
1232
|
20
|
1233 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, 0, 2, 0, /*
|
0
|
1234 Return t if position POS is currently on the frame in WINDOW.
|
|
1235 Returns nil if that position is scrolled vertically out of view.
|
|
1236 POS defaults to point in WINDOW's buffer; WINDOW, to the selected window.
|
20
|
1237 */
|
|
1238 (pos, window))
|
0
|
1239 {
|
102
|
1240 struct window *w = decode_window (window);
|
272
|
1241 Bufpos top = marker_position (w->start[CURRENT_DISP]);
|
0
|
1242 Bufpos posint;
|
272
|
1243 struct buffer *buf = XBUFFER (w->buffer);
|
0
|
1244
|
|
1245 if (NILP (pos))
|
|
1246 posint = BUF_PT (buf);
|
|
1247 else
|
|
1248 {
|
|
1249 CHECK_INT_COERCE_MARKER (pos);
|
|
1250 posint = XINT (pos);
|
|
1251 }
|
|
1252
|
|
1253 if (posint < top || posint > BUF_ZV (buf))
|
|
1254 return Qnil;
|
|
1255
|
|
1256 /* w->start can be out of range. If it is, do something reasonable. */
|
|
1257 if (top < BUF_BEGV (buf) || top > BUF_ZV (buf))
|
|
1258 return Qnil;
|
|
1259
|
272
|
1260 return point_would_be_visible (w, top, posint) ? Qt : Qnil;
|
0
|
1261 }
|
|
1262
|
|
1263
|
|
1264 struct window *
|
|
1265 decode_window (Lisp_Object window)
|
|
1266 {
|
|
1267 if (NILP (window))
|
|
1268 return XWINDOW (Fselected_window (Qnil));
|
|
1269
|
|
1270 CHECK_LIVE_WINDOW (window);
|
|
1271 return XWINDOW (window);
|
|
1272 }
|
|
1273
|
20
|
1274 DEFUN ("window-buffer", Fwindow_buffer, 0, 1, 0, /*
|
0
|
1275 Return the buffer that WINDOW is displaying.
|
20
|
1276 */
|
|
1277 (window))
|
0
|
1278 {
|
|
1279 return decode_window (window)->buffer;
|
|
1280 }
|
|
1281
|
20
|
1282 DEFUN ("window-frame", Fwindow_frame, 0, 1, 0, /*
|
0
|
1283 Return the frame that window WINDOW is on.
|
20
|
1284 */
|
|
1285 (window))
|
0
|
1286 {
|
|
1287 return decode_window (window)->frame;
|
|
1288 }
|
|
1289
|
20
|
1290 DEFUN ("window-height", Fwindow_height, 0, 1, 0, /*
|
0
|
1291 Return the number of default lines in WINDOW.
|
|
1292 This actually works by dividing the window's pixel height (including
|
|
1293 the modeline and horizontal scrollbar, if any) by the height of the
|
|
1294 default font; therefore, the number of displayed lines will probably
|
|
1295 be different.
|
|
1296 Use `window-height' to get consistent results in geometry calculations.
|
|
1297 Use `window-displayed-height' to get the actual number of lines
|
|
1298 currently displayed in a window.
|
20
|
1299 */
|
|
1300 (window))
|
0
|
1301 {
|
|
1302 return make_int (window_char_height (decode_window (window), 1));
|
|
1303 }
|
|
1304
|
20
|
1305 DEFUN ("window-displayed-height", Fwindow_displayed_height, 0, 1, 0, /*
|
0
|
1306 Return the number of lines currently displayed in WINDOW.
|
|
1307 This counts the actual number of lines displayed in WINDOW
|
272
|
1308 \(as opposed to `window-height'). The modeline and horizontal
|
0
|
1309 scrollbar do not count as lines. If there is some blank space
|
|
1310 between the end of the buffer and the end of the window, this
|
|
1311 function pretends that there are lines of text in the default
|
|
1312 font there.
|
20
|
1313 */
|
70
|
1314 (window))
|
0
|
1315 {
|
|
1316 return make_int (window_displayed_height (decode_window (window)));
|
|
1317 }
|
|
1318
|
20
|
1319 DEFUN ("window-pixel-height", Fwindow_pixel_height, 0, 1, 0, /*
|
0
|
1320 Return the height of WINDOW in pixels. Defaults to current window.
|
|
1321 This includes the window's modeline and horizontal scrollbar (if any).
|
20
|
1322 */
|
|
1323 (window))
|
0
|
1324 {
|
173
|
1325 return make_int (decode_window (window)->pixel_height);
|
0
|
1326 }
|
|
1327
|
276
|
1328 DEFUN ("window-text-pixel-height", Fwindow_text_pixel_height, 0, 1, 0, /*
|
|
1329 Return the height in pixels of the text-displaying portion of WINDOW.
|
|
1330 Unlike `window-pixel-height', the space occupied by the modeline and
|
|
1331 horizontal scrollbar, if any, is not counted.
|
263
|
1332 */
|
|
1333 (window))
|
|
1334 {
|
276
|
1335 struct window *w = decode_window (window);
|
|
1336
|
|
1337 return make_int (WINDOW_TEXT_HEIGHT (w));
|
263
|
1338 }
|
|
1339
|
20
|
1340 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /*
|
0
|
1341 Return the number of display columns in WINDOW.
|
|
1342 This is the width that is usable columns available for text in WINDOW.
|
20
|
1343 */
|
|
1344 (window))
|
0
|
1345 {
|
173
|
1346 return make_int (window_char_width (decode_window (window), 0));
|
0
|
1347 }
|
|
1348
|
20
|
1349 DEFUN ("window-pixel-width", Fwindow_pixel_width, 0, 1, 0, /*
|
0
|
1350 Return the width of WINDOW in pixels. Defaults to current window.
|
20
|
1351 */
|
|
1352 (window))
|
0
|
1353 {
|
173
|
1354 return make_int (decode_window (window)->pixel_width);
|
0
|
1355 }
|
|
1356
|
276
|
1357 DEFUN ("window-text-pixel-width", Fwindow_text_pixel_width, 0, 1, 0, /*
|
|
1358 Return the width in pixels of the text-displaying portion of WINDOW.
|
|
1359 Unlike `window-pixel-width', the space occupied by the vertical
|
|
1360 scrollbar or divider, if any, is not counted.
|
|
1361 */
|
|
1362 (window))
|
|
1363 {
|
|
1364 struct window *w = decode_window (window);
|
|
1365
|
|
1366 return make_int (WINDOW_TEXT_WIDTH (w));
|
|
1367 }
|
|
1368
|
20
|
1369 DEFUN ("window-hscroll", Fwindow_hscroll, 0, 1, 0, /*
|
0
|
1370 Return the number of columns by which WINDOW is scrolled from left margin.
|
20
|
1371 */
|
|
1372 (window))
|
0
|
1373 {
|
173
|
1374 return make_int (decode_window (window)->hscroll);
|
0
|
1375 }
|
|
1376
|
267
|
1377 #ifdef MODELINE_IS_SCROLLABLE
|
257
|
1378 DEFUN ("modeline-hscroll", Fmodeline_hscroll, 0, 1, 0, /*
|
272
|
1379 Return the number of columns by which WINDOW's modeline is scrolled from
|
257
|
1380 left margin. If the window has no modeline, return nil.
|
|
1381 */
|
|
1382 (window))
|
|
1383 {
|
280
|
1384 struct window *w = decode_window (window);
|
|
1385
|
257
|
1386 return (WINDOW_HAS_MODELINE_P (w)) ? make_int (w->modeline_hscroll) : Qnil;
|
|
1387 }
|
272
|
1388
|
257
|
1389 DEFUN ("set-modeline-hscroll", Fset_modeline_hscroll, 2, 2, 0, /*
|
|
1390 Set number of columns WINDOW's modeline is scrolled from left margin to NCOL.
|
|
1391 NCOL should be zero or positive. If NCOL is negative, it will be forced to 0.
|
|
1392 If the window has no modeline, do nothing and return nil.
|
|
1393 */
|
|
1394 (window, ncol))
|
|
1395 {
|
280
|
1396 struct window *w = decode_window (window);
|
|
1397
|
257
|
1398 if (WINDOW_HAS_MODELINE_P (w))
|
|
1399 {
|
280
|
1400 int ncols;
|
257
|
1401 CHECK_INT (ncol);
|
|
1402 ncols = XINT (ncol);
|
|
1403 if (ncols < 0) ncols = 0;
|
|
1404 if (w->modeline_hscroll != ncols)
|
|
1405 MARK_MODELINE_CHANGED;
|
|
1406 w->modeline_hscroll = ncols;
|
|
1407 return ncol;
|
|
1408 }
|
|
1409 return Qnil;
|
|
1410 }
|
272
|
1411 #endif /* MODELINE_IS_SCROLLABLE */
|
|
1412
|
|
1413 DEFUN ("set-window-hscroll", Fset_window_hscroll, 2, 2, 0, /*
|
|
1414 Set number of columns WINDOW is scrolled from left margin to NCOL.
|
|
1415 NCOL should be zero or positive.
|
|
1416 */
|
|
1417 (window, ncol))
|
|
1418 {
|
|
1419 struct window *w;
|
|
1420 int ncols;
|
|
1421
|
|
1422 CHECK_INT (ncol);
|
|
1423 ncols = XINT (ncol);
|
|
1424 if (ncols < 0) ncols = 0;
|
|
1425 w = decode_window (window);
|
|
1426 if (w->hscroll != ncols)
|
|
1427 MARK_CLIP_CHANGED; /* FSF marks differently but we aren't FSF. */
|
|
1428 w->hscroll = ncols;
|
|
1429 return ncol;
|
|
1430 }
|
257
|
1431
|
276
|
1432 #if 0 /* bogus FSF crock */
|
0
|
1433
|
149
|
1434 xxDEFUN ("window-redisplay-end-trigger",
|
|
1435 Fwindow_redisplay_end_trigger, 0, 1, 0, /*
|
0
|
1436 Return WINDOW's redisplay end trigger value.
|
|
1437 See `set-window-redisplay-end-trigger' for more information.
|
102
|
1438 */
|
|
1439 (window))
|
0
|
1440 {
|
|
1441 return decode_window (window)->redisplay_end_trigger;
|
|
1442 }
|
|
1443
|
149
|
1444 xxDEFUN ("set-window-redisplay-end-trigger",
|
|
1445 Fset_window_redisplay_end_trigger, 2, 2, 0, /*
|
0
|
1446 Set WINDOW's redisplay end trigger value to VALUE.
|
|
1447 VALUE should be a buffer position (typically a marker) or nil.
|
|
1448 If it is a buffer position, then if redisplay in WINDOW reaches a position
|
|
1449 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called
|
|
1450 with two arguments: WINDOW, and the end trigger value.
|
|
1451 Afterwards the end-trigger value is reset to nil.
|
185
|
1452 */
|
102
|
1453 (window, value))
|
0
|
1454 {
|
102
|
1455 return (decode_window (window)->redisplay_end_trigger = value);
|
0
|
1456 }
|
|
1457
|
|
1458 #endif /* 0 */
|
|
1459
|
20
|
1460 DEFUN ("window-pixel-edges", Fwindow_pixel_edges, 0, 1, 0, /*
|
0
|
1461 Return a list of the pixel edge coordinates of WINDOW.
|
|
1462 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.
|
|
1463 The frame toolbars and menubars are considered to be outside of this area.
|
20
|
1464 */
|
|
1465 (window))
|
0
|
1466 {
|
|
1467 struct window *w = decode_window (window);
|
|
1468 struct frame *f = XFRAME (w->frame);
|
149
|
1469
|
|
1470 int left = w->pixel_left - FRAME_LEFT_BORDER_END (f);
|
|
1471 int top = w->pixel_top - FRAME_TOP_BORDER_END (f);
|
0
|
1472
|
|
1473 return list4 (make_int (left),
|
|
1474 make_int (top),
|
|
1475 make_int (left + w->pixel_width),
|
|
1476 make_int (top + w->pixel_height));
|
|
1477 }
|
|
1478
|
276
|
1479 DEFUN ("window-text-pixel-edges", Fwindow_text_pixel_edges, 0, 1, 0, /*
|
|
1480 Return a list of the pixel edge coordinates of the text area of WINDOW.
|
|
1481 Returns the list \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at the
|
|
1482 top left corner of the window.
|
|
1483 */
|
|
1484 (window))
|
|
1485 {
|
|
1486 struct window *w = decode_window (window);
|
|
1487
|
|
1488 int left = window_left_gutter_width (w, /* modeline = */ 0);
|
|
1489 int top = window_top_gutter_height (w);
|
|
1490 int right = WINDOW_WIDTH (w) - window_right_gutter_width (w, 0);
|
|
1491 int bottom = WINDOW_HEIGHT (w) - window_bottom_gutter_height (w);
|
|
1492
|
|
1493 return list4 (make_int (left),
|
|
1494 make_int (top),
|
|
1495 make_int (right),
|
|
1496 make_int (bottom));
|
|
1497 }
|
|
1498
|
20
|
1499 DEFUN ("window-point", Fwindow_point, 0, 1, 0, /*
|
0
|
1500 Return current value of point in WINDOW.
|
|
1501 For a nonselected window, this is the value point would have
|
|
1502 if that window were selected.
|
|
1503
|
|
1504 Note that, when WINDOW is the selected window and its buffer
|
|
1505 is also currently selected, the value returned is the same as (point).
|
|
1506 It would be more strictly correct to return the `top-level' value
|
|
1507 of point, outside of any save-excursion forms.
|
|
1508 But that is hard to define.
|
20
|
1509 */
|
|
1510 (window))
|
0
|
1511 {
|
|
1512 struct window *w = decode_window (window);
|
|
1513
|
|
1514 /* The special check for current buffer is necessary for this
|
|
1515 function to work as defined when called within an excursion. */
|
|
1516 if (w == XWINDOW (Fselected_window (XFRAME (w->frame)->device))
|
|
1517 && current_buffer == XBUFFER (w->buffer))
|
|
1518 return Fpoint (Qnil);
|
|
1519 return Fmarker_position (w->pointm[CURRENT_DISP]);
|
|
1520 }
|
|
1521
|
20
|
1522 DEFUN ("window-start", Fwindow_start, 0, 1, 0, /*
|
0
|
1523 Return position at which display currently starts in WINDOW.
|
|
1524 This is updated by redisplay or by calling `set-window-start'.
|
20
|
1525 */
|
|
1526 (window))
|
0
|
1527 {
|
|
1528 return Fmarker_position (decode_window (window)->start[CURRENT_DISP]);
|
|
1529 }
|
|
1530
|
20
|
1531 DEFUN ("window-end", Fwindow_end, 0, 2, 0, /*
|
0
|
1532 Return position at which display currently ends in WINDOW.
|
|
1533 This is updated by redisplay, when it runs to completion.
|
|
1534 Simply changing the buffer text or setting `window-start'
|
|
1535 does not update this value.
|
|
1536 If GUARANTEE is non-nil, then the return value is guaranteed to be
|
|
1537 the value of window-end at the end of the next full redisplay assuming
|
|
1538 nothing else changes in the meantime. This function is potentially much
|
|
1539 slower with this flag set.
|
20
|
1540 */
|
|
1541 (window, guarantee))
|
0
|
1542 {
|
|
1543 struct window *w = decode_window (window);
|
|
1544
|
|
1545 if (NILP (guarantee))
|
|
1546 {
|
280
|
1547 Lisp_Object buf;
|
|
1548 buf = w->buffer;
|
0
|
1549 CHECK_BUFFER (buf);
|
272
|
1550 return make_int (BUF_Z (XBUFFER (buf)) - w->window_end_pos[CURRENT_DISP]);
|
0
|
1551 }
|
|
1552 else
|
|
1553 {
|
|
1554 Bufpos startp = marker_position (w->start[CURRENT_DISP]);
|
173
|
1555 return make_int (end_of_last_line (w, startp));
|
0
|
1556 }
|
|
1557 }
|
|
1558
|
20
|
1559 DEFUN ("set-window-point", Fset_window_point, 2, 2, 0, /*
|
0
|
1560 Make point value in WINDOW be at position POS in WINDOW's buffer.
|
20
|
1561 */
|
|
1562 (window, pos))
|
0
|
1563 {
|
|
1564 struct window *w = decode_window (window);
|
|
1565
|
|
1566 CHECK_INT_COERCE_MARKER (pos);
|
|
1567 if (w == XWINDOW (Fselected_window (Qnil)))
|
223
|
1568 Fgoto_char (pos, Qnil);
|
0
|
1569 else
|
|
1570 set_marker_restricted (w->pointm[CURRENT_DISP], pos, w->buffer);
|
|
1571
|
|
1572 MARK_POINT_CHANGED;
|
|
1573 return pos;
|
|
1574 }
|
|
1575
|
20
|
1576 DEFUN ("set-window-start", Fset_window_start, 2, 3, 0, /*
|
0
|
1577 Make display in WINDOW start at position POS in WINDOW's buffer.
|
|
1578 Optional third arg NOFORCE non-nil inhibits next redisplay
|
|
1579 from overriding motion of point in order to display at this exact start.
|
20
|
1580 */
|
|
1581 (window, pos, noforce))
|
0
|
1582 {
|
|
1583 struct window *w = decode_window (window);
|
|
1584
|
|
1585 CHECK_INT_COERCE_MARKER (pos);
|
|
1586 set_marker_restricted (w->start[CURRENT_DISP], pos, w->buffer);
|
|
1587 /* this is not right, but much easier than doing what is right. */
|
|
1588 w->start_at_line_beg = 0;
|
|
1589 if (NILP (noforce))
|
|
1590 w->force_start = 1;
|
|
1591 w->redo_modeline = 1;
|
|
1592 SET_LAST_MODIFIED (w, 0);
|
|
1593 SET_LAST_FACECHANGE (w);
|
|
1594
|
|
1595 MARK_WINDOWS_CHANGED (w);
|
|
1596
|
|
1597 return pos;
|
|
1598 }
|
|
1599
|
20
|
1600 DEFUN ("window-dedicated-p", Fwindow_dedicated_p, 1, 1, 0, /*
|
0
|
1601 Return WINDOW's dedicated object, usually t or nil.
|
|
1602 See also `set-window-dedicated-p'.
|
20
|
1603 */
|
|
1604 (window))
|
0
|
1605 {
|
|
1606 return decode_window (window)->dedicated;
|
|
1607 }
|
|
1608
|
20
|
1609 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, 2, 2, 0, /*
|
0
|
1610 Control whether WINDOW is dedicated to the buffer it displays.
|
|
1611 If it is dedicated, Emacs will not automatically change
|
|
1612 which buffer appears in it.
|
|
1613 The second argument is the new value for the dedication flag;
|
|
1614 non-nil means yes.
|
20
|
1615 */
|
|
1616 (window, arg))
|
0
|
1617 {
|
272
|
1618 struct window *w = decode_window (window);
|
0
|
1619
|
149
|
1620 w->dedicated = NILP (arg) ? Qnil : Qt;
|
0
|
1621
|
|
1622 return w->dedicated;
|
|
1623 }
|
|
1624
|
|
1625 /* FSFmacs has window-display-table here. We have display table as a
|
|
1626 specifier. */
|
|
1627
|
|
1628
|
|
1629 /* Record info on buffer window w is displaying
|
|
1630 when it is about to cease to display that buffer. */
|
|
1631 static void
|
|
1632 unshow_buffer (struct window *w)
|
|
1633 {
|
|
1634 Lisp_Object buf = w->buffer;
|
|
1635
|
|
1636 if (XBUFFER (buf) != XMARKER (w->pointm[CURRENT_DISP])->buffer)
|
|
1637 abort ();
|
|
1638
|
|
1639 /* FSF disables this check, so I'll do it too. I hope it won't
|
|
1640 break things. --ben */
|
|
1641 #if 0
|
|
1642 if (w == XWINDOW (Fselected_window (Qnil))
|
|
1643 || ! EQ (buf, XWINDOW (Fselected_window (Qnil))->buffer))
|
|
1644 /* Do this except when the selected window's buffer
|
|
1645 is being removed from some other window. */
|
|
1646 #endif
|
|
1647 /* last_window_start records the start position that this buffer
|
|
1648 had in the last window to be disconnected from it.
|
|
1649 Now that this statement is unconditional,
|
|
1650 it is possible for the buffer to be displayed in the
|
|
1651 selected window, while last_window_start reflects another
|
|
1652 window which was recently showing the same buffer.
|
|
1653 Some people might say that might be a good thing. Let's see. */
|
|
1654 XBUFFER (buf)->last_window_start =
|
|
1655 marker_position (w->start[CURRENT_DISP]);
|
|
1656
|
|
1657 /* Point in the selected window's buffer
|
|
1658 is actually stored in that buffer, and the window's pointm isn't used.
|
|
1659 So don't clobber point in that buffer. */
|
|
1660 if (! EQ (buf, XWINDOW (Fselected_window (Qnil))->buffer))
|
|
1661 {
|
|
1662 struct buffer *b= XBUFFER (buf);
|
|
1663 BUF_SET_PT (b, bufpos_clip_to_bounds (BUF_BEGV (b),
|
|
1664 marker_position (w->pointm[CURRENT_DISP]),
|
|
1665 BUF_ZV (b)));
|
|
1666 }
|
|
1667 }
|
|
1668
|
|
1669 /* Put REPLACEMENT into the window structure in place of OLD. */
|
|
1670 static void
|
|
1671 replace_window (Lisp_Object old, Lisp_Object replacement)
|
|
1672 {
|
|
1673 Lisp_Object tem;
|
|
1674 struct window *o = XWINDOW (old), *p = XWINDOW (replacement);
|
|
1675
|
|
1676 /* If OLD is its frame's root_window, then replacement is the new
|
|
1677 root_window for that frame. */
|
|
1678
|
|
1679 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame))))
|
|
1680 FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement;
|
|
1681
|
|
1682 WINDOW_LEFT (p) = WINDOW_LEFT (o);
|
|
1683 WINDOW_TOP (p) = WINDOW_TOP (o);
|
|
1684 WINDOW_WIDTH (p) = WINDOW_WIDTH (o);
|
|
1685 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o);
|
|
1686
|
|
1687 p->next = tem = o->next;
|
|
1688 if (!NILP (tem))
|
|
1689 XWINDOW (tem)->prev = replacement;
|
|
1690
|
|
1691 p->prev = tem = o->prev;
|
|
1692 if (!NILP (tem))
|
|
1693 XWINDOW (tem)->next = replacement;
|
|
1694
|
|
1695 p->parent = tem = o->parent;
|
|
1696 if (!NILP (tem))
|
|
1697 {
|
|
1698 if (EQ (XWINDOW (tem)->vchild, old))
|
|
1699 XWINDOW (tem)->vchild = replacement;
|
|
1700 if (EQ (XWINDOW (tem)->hchild, old))
|
|
1701 XWINDOW (tem)->hchild = replacement;
|
|
1702 }
|
|
1703
|
|
1704 /* #### Here, if replacement is a vertical combination
|
|
1705 and so is its new parent, we should make replacement's
|
|
1706 children be children of that parent instead. */
|
|
1707 }
|
|
1708
|
|
1709 /* we're deleting W; set the structure of W to indicate this. */
|
|
1710
|
|
1711 static void
|
|
1712 mark_window_as_deleted (struct window *w)
|
|
1713 {
|
|
1714 /* In the loop
|
|
1715 (while t (split-window) (delete-window))
|
|
1716 we end up with a tree of deleted windows which are all connected
|
|
1717 through the `next' slot. This might not seem so bad, as they're
|
|
1718 deleted, and will presumably be GCed - but if even *one* of those
|
|
1719 windows is still being pointed to, by the user, or by a window
|
|
1720 configuration, then *all* of those windows stick around.
|
|
1721
|
|
1722 Since the window-configuration code doesn't need any of the
|
|
1723 pointers to other windows (they are all recreated from the
|
|
1724 window-config data), we set them all to nil so that we
|
|
1725 are able to collect more actual garbage.
|
|
1726 */
|
|
1727 w->next = Qnil;
|
|
1728 w->prev = Qnil;
|
|
1729 w->hchild = Qnil;
|
|
1730 w->vchild = Qnil;
|
|
1731 w->parent = Qnil;
|
|
1732
|
|
1733 w->dead = 1;
|
|
1734
|
|
1735 /* Free the extra data structures attached to windows immediately so
|
|
1736 they don't sit around consuming excess space. They will be
|
|
1737 reinitialized by the window-configuration code as necessary. */
|
|
1738 finalize_window ((void *) w, 0);
|
|
1739 }
|
|
1740
|
20
|
1741 DEFUN ("delete-window", Fdelete_window, 0, 2, "", /*
|
0
|
1742 Remove WINDOW from the display. Default is selected window.
|
|
1743 If window is the only one on the frame, the frame is destroyed.
|
|
1744 Normally, you cannot delete the last non-minibuffer-only frame (you must
|
|
1745 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional
|
|
1746 second argument FORCE is non-nil, you can delete the last frame. (This
|
|
1747 will automatically call `save-buffers-kill-emacs'.)
|
20
|
1748 */
|
|
1749 (window, force))
|
0
|
1750 {
|
|
1751 /* This function can GC if this is the only window in the frame */
|
|
1752 struct window *w;
|
|
1753 Lisp_Object parent;
|
|
1754 struct window *par;
|
|
1755 Lisp_Object frame;
|
|
1756 struct frame *f;
|
|
1757 struct device *d;
|
|
1758
|
|
1759 /* Note: this function is called by other C code on non-leaf
|
|
1760 windows. */
|
|
1761
|
|
1762 /* Do the equivalent of decode_window() but don't error out on
|
|
1763 deleted window; it's OK to delete an already-deleted window. */
|
|
1764 if (NILP (window))
|
|
1765 window = Fselected_window (Qnil);
|
|
1766 else
|
|
1767 CHECK_WINDOW (window);
|
|
1768 w = XWINDOW (window);
|
|
1769
|
|
1770 /* It's okay to delete an already-deleted window. */
|
|
1771 if (! WINDOW_LIVE_P (w))
|
|
1772 return Qnil;
|
|
1773
|
|
1774 frame = WINDOW_FRAME (w);
|
|
1775 f = XFRAME (frame);
|
|
1776 d = XDEVICE (FRAME_DEVICE (f));
|
|
1777
|
|
1778 if (TOP_LEVEL_WINDOW_P (w))
|
|
1779 {
|
|
1780 if (NILP (memq_no_quit (frame, DEVICE_FRAME_LIST (d))))
|
|
1781 /* this frame isn't fully initialized yet; don't blow up. */
|
|
1782 return Qnil;
|
|
1783
|
|
1784 if (MINI_WINDOW_P (XWINDOW (window)))
|
|
1785 error ("Attempt to delete the minibuffer window");
|
|
1786
|
|
1787 /* It has been suggested that it's a good thing for C-x 0 to have this
|
|
1788 behavior, but not such a good idea for #'delete-window to have it.
|
|
1789 Maybe C-x 0 should be bound to something else, or maybe frame
|
|
1790 deletion should only happen when this is called interactively.
|
|
1791 */
|
|
1792 delete_frame_internal (f, !NILP (force), 0, 0);
|
|
1793 return Qnil;
|
|
1794 }
|
|
1795
|
|
1796 /* At this point, we know the window has a parent. */
|
|
1797 parent = w->parent;
|
|
1798 par = XWINDOW (parent);
|
|
1799
|
|
1800 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
1801
|
|
1802 /* Are we trying to delete any frame's selected window?
|
|
1803 Note that we could be dealing with a non-leaf window
|
|
1804 where the selected window is one of our children.
|
|
1805 So, we check by scanning all the ancestors of the
|
|
1806 frame's selected window and comparing each one with
|
|
1807 WINDOW. */
|
|
1808 {
|
|
1809 Lisp_Object pwindow;
|
185
|
1810
|
0
|
1811 pwindow = FRAME_SELECTED_WINDOW (f);
|
185
|
1812
|
0
|
1813 while (!NILP (pwindow))
|
|
1814 {
|
|
1815 if (EQ (window, pwindow))
|
|
1816 break;
|
|
1817 pwindow = XWINDOW (pwindow)->parent;
|
|
1818 }
|
|
1819
|
|
1820 if (EQ (window, pwindow))
|
|
1821 {
|
|
1822 /* OK, we found it. */
|
|
1823 Lisp_Object alternative;
|
|
1824 alternative = Fnext_window (window, Qlambda, Qnil, Qnil);
|
185
|
1825
|
0
|
1826 /* If we're about to delete the selected window on the
|
|
1827 selected frame, then we should use Fselect_window to select
|
|
1828 the new window. On the other hand, if we're about to
|
|
1829 delete the selected window on any other frame, we shouldn't do
|
|
1830 anything but set the frame's selected_window slot. */
|
|
1831 if (EQ (frame, Fselected_frame (Qnil)))
|
282
|
1832 Fselect_window (alternative, Qnil);
|
0
|
1833 else
|
|
1834 set_frame_selected_window (f, alternative);
|
|
1835 }
|
|
1836 }
|
|
1837
|
|
1838 /* w->buffer is nil in a non-leaf window; in this case,
|
|
1839 get rid of the markers we maintain that point into that buffer. */
|
|
1840 if (!NILP (w->buffer))
|
|
1841 {
|
|
1842 unshow_buffer (w);
|
|
1843 unchain_marker (w->pointm[CURRENT_DISP]);
|
|
1844 unchain_marker (w->pointm[DESIRED_DISP]);
|
|
1845 unchain_marker (w->pointm[CMOTION_DISP]);
|
|
1846 unchain_marker (w->start[CURRENT_DISP]);
|
|
1847 unchain_marker (w->start[DESIRED_DISP]);
|
|
1848 unchain_marker (w->start[CMOTION_DISP]);
|
|
1849 unchain_marker (w->sb_point);
|
|
1850 /* This breaks set-window-configuration if windows in the saved
|
|
1851 configuration get deleted and multiple frames are in use. */
|
|
1852 /* w->buffer = Qnil; */
|
|
1853 }
|
185
|
1854
|
0
|
1855 /* close up the hole in the sibling list */
|
|
1856 if (!NILP (w->next))
|
|
1857 XWINDOW (w->next)->prev = w->prev;
|
|
1858 if (!NILP (w->prev))
|
|
1859 XWINDOW (w->prev)->next = w->next;
|
|
1860 if (EQ (window, par->hchild))
|
|
1861 par->hchild = w->next;
|
|
1862 if (EQ (window, par->vchild))
|
|
1863 par->vchild = w->next;
|
|
1864
|
|
1865 /* Find one of our siblings to give our space to. */
|
|
1866 {
|
|
1867 Lisp_Object sib = w->prev;
|
|
1868 if (NILP (sib))
|
|
1869 {
|
|
1870 /* If w gives its space to its next sibling, that sibling needs
|
|
1871 to have its top/left side pulled back to where w's is.
|
|
1872 set_window_{height,width} will re-position the sibling's
|
|
1873 children. */
|
|
1874 sib = w->next;
|
|
1875 WINDOW_TOP (XWINDOW (sib)) = WINDOW_TOP (w);
|
|
1876 WINDOW_LEFT (XWINDOW (sib)) = WINDOW_LEFT (w);
|
|
1877 }
|
185
|
1878
|
0
|
1879 /* Stretch that sibling. */
|
|
1880 if (!NILP (par->vchild))
|
|
1881 set_window_pixheight
|
|
1882 (sib, (WINDOW_HEIGHT (XWINDOW (sib)) + WINDOW_HEIGHT (w)), 1);
|
|
1883 if (!NILP (par->hchild))
|
|
1884 set_window_pixwidth
|
|
1885 (sib, (WINDOW_WIDTH (XWINDOW (sib)) + WINDOW_WIDTH (w)), 1);
|
|
1886 }
|
|
1887
|
|
1888 /* If parent now has only one child,
|
|
1889 put the child into the parent's place. */
|
|
1890 {
|
|
1891 Lisp_Object parchild = par->hchild;
|
|
1892 if (NILP (parchild))
|
|
1893 parchild = par->vchild;
|
|
1894 if (NILP (XWINDOW (parchild)->next))
|
|
1895 {
|
|
1896 replace_window (parent, parchild);
|
|
1897 mark_window_as_deleted (XWINDOW (parent));
|
|
1898 }
|
|
1899 }
|
|
1900
|
|
1901 /* Since we may be deleting combination windows, we must make sure that
|
|
1902 not only W but all its children have been marked as deleted. */
|
|
1903 if (!NILP (w->hchild))
|
|
1904 delete_all_subwindows (XWINDOW (w->hchild));
|
|
1905 else if (!NILP (w->vchild))
|
|
1906 delete_all_subwindows (XWINDOW (w->vchild));
|
|
1907
|
|
1908 mark_window_as_deleted (w);
|
|
1909
|
|
1910 f->mirror_dirty = 1;
|
|
1911 return Qnil;
|
|
1912 }
|
|
1913
|
|
1914
|
20
|
1915 DEFUN ("next-window", Fnext_window, 0, 4, 0, /*
|
0
|
1916 Return next window after WINDOW in canonical ordering of windows.
|
|
1917 If omitted, WINDOW defaults to the selected window.
|
|
1918
|
|
1919 Optional second arg MINIBUF t means count the minibuffer window even
|
|
1920 if not active. MINIBUF nil or omitted means count the minibuffer iff
|
|
1921 it is active. MINIBUF neither t nor nil means not to count the
|
|
1922 minibuffer even if it is active.
|
|
1923
|
|
1924 Several frames may share a single minibuffer; if the minibuffer
|
|
1925 counts, all windows on all frames that share that minibuffer count
|
|
1926 too. Therefore, `next-window' can be used to iterate through the
|
|
1927 set of windows even when the minibuffer is on another frame. If the
|
|
1928 minibuffer does not count, only windows from WINDOW's frame count.
|
|
1929
|
|
1930 Optional third arg ALL-FRAMES t means include windows on all frames.
|
|
1931 ALL-FRAMES nil or omitted means cycle within the frames as specified
|
|
1932 above. ALL-FRAMES = `visible' means include windows on all visible frames.
|
|
1933 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
|
|
1934 If ALL-FRAMES is a frame, restrict search to windows on that frame.
|
|
1935 Anything else means restrict to WINDOW's frame.
|
|
1936
|
|
1937 Optional fourth argument CONSOLE controls which consoles or devices the
|
|
1938 returned window may be on. If CONSOLE is a console, return windows only
|
|
1939 on that console. If CONSOLE is a device, return windows only on that
|
|
1940 device. If CONSOLE is a console type, return windows only on consoles
|
|
1941 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
1942 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
1943 on WINDOW's console. Otherwise, all windows are considered.
|
|
1944
|
|
1945 If you use consistent values for MINIBUF, ALL-FRAMES, and CONSOLE, you
|
|
1946 can use `next-window' to iterate through the entire cycle of acceptable
|
|
1947 windows, eventually ending up back at the window you started with.
|
|
1948 `previous-window' traverses the same cycle, in the reverse order.
|
20
|
1949 */
|
70
|
1950 (window, minibuf, all_frames, console))
|
0
|
1951 {
|
|
1952 Lisp_Object tem;
|
|
1953 Lisp_Object start_window;
|
|
1954
|
|
1955 if (NILP (window))
|
|
1956 window = Fselected_window (Qnil);
|
|
1957 else
|
|
1958 CHECK_LIVE_WINDOW (window);
|
|
1959
|
|
1960 start_window = window;
|
|
1961
|
|
1962 /* minibuf == nil may or may not include minibuffers.
|
|
1963 Decide if it does. */
|
|
1964 if (NILP (minibuf))
|
|
1965 minibuf = (minibuf_level ? minibuf_window : Qlambda);
|
|
1966 else if (! EQ (minibuf, Qt))
|
|
1967 minibuf = Qlambda;
|
|
1968 /* Now minibuf can be t => count all minibuffer windows,
|
|
1969 lambda => count none of them,
|
|
1970 or a specific minibuffer window (the active one) to count. */
|
|
1971
|
|
1972 /* all_frames == nil doesn't specify which frames to include. */
|
|
1973 if (NILP (all_frames))
|
|
1974 all_frames = (! EQ (minibuf, Qlambda)
|
|
1975 ? (FRAME_MINIBUF_WINDOW
|
|
1976 (XFRAME
|
|
1977 (WINDOW_FRAME
|
|
1978 (XWINDOW (window)))))
|
|
1979 : Qnil);
|
|
1980 else if (EQ (all_frames, Qvisible))
|
|
1981 ;
|
|
1982 else if (ZEROP (all_frames))
|
|
1983 ;
|
|
1984 else if (FRAMEP (all_frames) && ! EQ (all_frames, Fwindow_frame (window)))
|
|
1985 /* If all_frames is a frame and window arg isn't on that frame, just
|
|
1986 return the first window on the frame. */
|
|
1987 return frame_first_window (XFRAME (all_frames));
|
|
1988 else if (! EQ (all_frames, Qt))
|
|
1989 all_frames = Qnil;
|
|
1990 /* Now all_frames is t meaning search all frames,
|
|
1991 nil meaning search just current frame,
|
|
1992 visible meaning search just visible frames,
|
|
1993 0 meaning search visible and iconified frames,
|
|
1994 or a window, meaning search the frame that window belongs to. */
|
|
1995
|
|
1996 /* Do this loop at least once, to get the next window, and perhaps
|
|
1997 again, if we hit the minibuffer and that is not acceptable. */
|
|
1998 do
|
|
1999 {
|
|
2000 /* Find a window that actually has a next one. This loop
|
|
2001 climbs up the tree. */
|
|
2002 while (tem = XWINDOW (window)->next, NILP (tem))
|
|
2003 if (tem = XWINDOW (window)->parent, !NILP (tem))
|
|
2004 window = tem;
|
|
2005 else /* window must be minibuffer window now */
|
|
2006 {
|
|
2007 /* We've reached the end of this frame.
|
|
2008 Which other frames are acceptable? */
|
|
2009 tem = WINDOW_FRAME (XWINDOW (window));
|
|
2010
|
|
2011 if (! NILP (all_frames))
|
|
2012 {
|
|
2013 Lisp_Object tem1;
|
|
2014
|
|
2015 tem1 = tem;
|
|
2016 tem = next_frame (tem, all_frames, console);
|
|
2017 /* In the case where the minibuffer is active,
|
|
2018 and we include its frame as well as the selected one,
|
|
2019 next_frame may get stuck in that frame.
|
|
2020 If that happens, go back to the selected frame
|
|
2021 so we can complete the cycle. */
|
|
2022 if (EQ (tem, tem1))
|
|
2023 XSETFRAME (tem, selected_frame ());
|
|
2024 }
|
|
2025
|
|
2026 tem = FRAME_ROOT_WINDOW (XFRAME (tem));
|
|
2027 break;
|
|
2028 }
|
|
2029
|
|
2030 window = tem;
|
|
2031
|
|
2032 /* If we're in a combination window, find its first child and
|
|
2033 recurse on that. Otherwise, we've found the window we want. */
|
|
2034 while (1)
|
|
2035 {
|
|
2036 if (!NILP (XWINDOW (window)->hchild))
|
|
2037 window = XWINDOW (window)->hchild;
|
|
2038 else if (!NILP (XWINDOW (window)->vchild))
|
|
2039 window = XWINDOW (window)->vchild;
|
|
2040 else break;
|
|
2041 }
|
|
2042 }
|
|
2043 /* "acceptable" is the correct spelling. */
|
|
2044 /* Which windows are acceptable?
|
|
2045 Exit the loop and accept this window if
|
|
2046 this isn't a minibuffer window,
|
|
2047 or we're accepting all minibuffer windows,
|
|
2048 or this is the active minibuffer and we are accepting that one, or
|
|
2049 we've come all the way around and we're back at the original window. */
|
|
2050 while (MINI_WINDOW_P (XWINDOW (window))
|
|
2051 && ! EQ (minibuf, Qt)
|
|
2052 && ! EQ (minibuf, window)
|
|
2053 && ! EQ (window, start_window));
|
|
2054
|
|
2055 return window;
|
|
2056 }
|
|
2057
|
20
|
2058 DEFUN ("previous-window", Fprevious_window, 0, 4, 0, /*
|
110
|
2059 Return the window preceding WINDOW in canonical ordering of windows.
|
0
|
2060 If omitted, WINDOW defaults to the selected window.
|
|
2061
|
|
2062 Optional second arg MINIBUF t means count the minibuffer window even
|
|
2063 if not active. MINIBUF nil or omitted means count the minibuffer iff
|
|
2064 it is active. MINIBUF neither t nor nil means not to count the
|
|
2065 minibuffer even if it is active.
|
|
2066
|
|
2067 Several frames may share a single minibuffer; if the minibuffer
|
|
2068 counts, all windows on all frames that share that minibuffer count
|
|
2069 too. Therefore, `previous-window' can be used to iterate through
|
|
2070 the set of windows even when the minibuffer is on another frame. If
|
|
2071 the minibuffer does not count, only windows from WINDOW's frame count
|
|
2072
|
|
2073 If optional third arg ALL-FRAMES t means include windows on all frames.
|
|
2074 ALL-FRAMES nil or omitted means cycle within the frames as specified
|
|
2075 above. ALL-FRAMES = `visible' means include windows on all visible frames.
|
|
2076 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
|
|
2077 If ALL-FRAMES is a frame, restrict search to windows on that frame.
|
|
2078 Anything else means restrict to WINDOW's frame.
|
|
2079
|
|
2080 Optional fourth argument CONSOLE controls which consoles or devices the
|
|
2081 returned window may be on. If CONSOLE is a console, return windows only
|
|
2082 on that console. If CONSOLE is a device, return windows only on that
|
|
2083 device. If CONSOLE is a console type, return windows only on consoles
|
|
2084 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2085 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2086 on WINDOW's console. Otherwise, all windows are considered.
|
|
2087
|
|
2088 If you use consistent values for MINIBUF, ALL-FRAMES, and CONSOLE, you
|
|
2089 can use `previous-window' to iterate through the entire cycle of acceptable
|
|
2090 windows, eventually ending up back at the window you started with.
|
|
2091 `next-window' traverses the same cycle, in the reverse order.
|
20
|
2092 */
|
70
|
2093 (window, minibuf, all_frames, console))
|
0
|
2094 {
|
|
2095 Lisp_Object tem;
|
|
2096 Lisp_Object start_window;
|
|
2097
|
|
2098 if (NILP (window))
|
|
2099 window = Fselected_window (Qnil);
|
|
2100 else
|
|
2101 CHECK_LIVE_WINDOW (window);
|
|
2102
|
|
2103 start_window = window;
|
|
2104
|
|
2105 /* minibuf == nil may or may not include minibuffers.
|
|
2106 Decide if it does. */
|
|
2107 if (NILP (minibuf))
|
|
2108 minibuf = (minibuf_level ? minibuf_window : Qlambda);
|
|
2109 else if (! EQ (minibuf, Qt))
|
|
2110 minibuf = Qlambda;
|
|
2111 /* Now minibuf can be t => count all minibuffer windows,
|
|
2112 lambda => count none of them,
|
|
2113 or a specific minibuffer window (the active one) to count. */
|
|
2114
|
|
2115 /* all_frames == nil doesn't specify which frames to include.
|
|
2116 Decide which frames it includes. */
|
|
2117 if (NILP (all_frames))
|
|
2118 all_frames = (! EQ (minibuf, Qlambda)
|
|
2119 ? (FRAME_MINIBUF_WINDOW
|
|
2120 (XFRAME
|
|
2121 (WINDOW_FRAME
|
|
2122 (XWINDOW (window)))))
|
|
2123 : Qnil);
|
|
2124 else if (EQ (all_frames, Qvisible))
|
|
2125 ;
|
|
2126 else if (ZEROP (all_frames))
|
|
2127 ;
|
|
2128 else if (FRAMEP (all_frames) && ! EQ (all_frames, Fwindow_frame (window)))
|
|
2129 /* If all_frames is a frame and window arg isn't on that frame, just
|
|
2130 return the first window on the frame. */
|
|
2131 return frame_first_window (XFRAME (all_frames));
|
|
2132 else if (! EQ (all_frames, Qt))
|
|
2133 all_frames = Qnil;
|
|
2134 /* Now all_frames is t meaning search all frames,
|
|
2135 nil meaning search just current frame,
|
|
2136 visible meaning search just visible frames,
|
|
2137 0 meaning search visible and iconified frames,
|
|
2138 or a window, meaning search the frame that window belongs to. */
|
|
2139
|
|
2140 /* Do this loop at least once, to get the next window, and perhaps
|
|
2141 again, if we hit the minibuffer and that is not acceptable. */
|
|
2142 do
|
|
2143 {
|
|
2144 /* Find a window that actually has a next one. This loop
|
|
2145 climbs up the tree. */
|
|
2146 while (tem = XWINDOW (window)->prev, NILP (tem))
|
|
2147 if (tem = XWINDOW (window)->parent, !NILP (tem))
|
|
2148 window = tem;
|
|
2149 else /* window must be minibuffer window now */
|
|
2150 {
|
|
2151 /* We have found the top window on the frame.
|
|
2152 Which frames are acceptable? */
|
|
2153 tem = WINDOW_FRAME (XWINDOW (window));
|
|
2154
|
|
2155 if (! NILP (all_frames))
|
|
2156 /* It's actually important that we use prev_frame here,
|
|
2157 rather than next_frame. All the windows acceptable
|
|
2158 according to the given parameters should form a ring;
|
|
2159 Fnext_window and Fprevious_window should go back and
|
|
2160 forth around the ring. If we use next_frame here,
|
|
2161 then Fnext_window and Fprevious_window take different
|
|
2162 paths through the set of acceptable windows.
|
|
2163 window_loop assumes that these `ring' requirement are
|
|
2164 met. */
|
|
2165 {
|
|
2166 Lisp_Object tem1;
|
|
2167
|
|
2168 tem1 = tem;
|
|
2169 tem = prev_frame (tem, all_frames, console);
|
|
2170 /* In the case where the minibuffer is active,
|
|
2171 and we include its frame as well as the selected one,
|
|
2172 next_frame may get stuck in that frame.
|
|
2173 If that happens, go back to the selected frame
|
|
2174 so we can complete the cycle. */
|
|
2175 if (EQ (tem, tem1))
|
|
2176 XSETFRAME (tem, selected_frame ());
|
|
2177 }
|
|
2178
|
|
2179 /* If this frame has a minibuffer, find that window first,
|
|
2180 because it is conceptually the last window in that frame. */
|
|
2181 if (FRAME_HAS_MINIBUF_P (XFRAME (tem)))
|
|
2182 tem = FRAME_MINIBUF_WINDOW (XFRAME (tem));
|
|
2183 else
|
|
2184 tem = FRAME_ROOT_WINDOW (XFRAME (tem));
|
|
2185
|
|
2186 break;
|
|
2187 }
|
|
2188
|
|
2189 window = tem;
|
|
2190
|
|
2191 /* If we're in a combination window, find its first child and
|
|
2192 recurse on that. Otherwise, we've found the window we want. */
|
|
2193 while (1)
|
|
2194 {
|
|
2195 if (!NILP (XWINDOW (window)->hchild))
|
|
2196 window = XWINDOW (window)->hchild;
|
|
2197 else if (!NILP (XWINDOW (window)->vchild))
|
|
2198 window = XWINDOW (window)->vchild;
|
|
2199 else break;
|
|
2200 while (tem = XWINDOW (window)->next, !NILP (tem))
|
|
2201 window = tem;
|
|
2202 }
|
|
2203 }
|
|
2204 /* Which windows are acceptable?
|
|
2205 Exit the loop and accept this window if
|
|
2206 this isn't a minibuffer window,
|
|
2207 or we're accepting all minibuffer windows,
|
|
2208 or this is the active minibuffer and we are accepting that one, or
|
|
2209 we've come all the way around and we're back at the original window. */
|
|
2210 while (MINI_WINDOW_P (XWINDOW (window))
|
|
2211 && ! EQ (minibuf, Qt)
|
|
2212 && ! EQ (minibuf, window)
|
|
2213 && ! EQ (window, start_window));
|
|
2214
|
|
2215 return window;
|
|
2216 }
|
|
2217
|
20
|
2218 DEFUN ("next-vertical-window", Fnext_vertical_window, 0, 1, 0, /*
|
0
|
2219 Return the next window which is vertically after WINDOW.
|
20
|
2220 */
|
|
2221 (window))
|
0
|
2222 {
|
|
2223 Lisp_Object root;
|
|
2224 struct window *w = decode_window (window);
|
|
2225 XSETWINDOW (window, w);
|
|
2226
|
|
2227 if (MINI_WINDOW_P (XWINDOW (window)))
|
|
2228 return Qnil;
|
|
2229
|
|
2230 root = FRAME_ROOT_WINDOW (XFRAME (WINDOW_FRAME (XWINDOW (window))));
|
|
2231
|
|
2232 if (EQ (window, root))
|
|
2233 {
|
|
2234 while (1)
|
|
2235 if (!NILP (XWINDOW (window)->hchild))
|
|
2236 window = XWINDOW (window)->hchild;
|
|
2237 else if (!NILP (XWINDOW (window)->vchild))
|
|
2238 window = XWINDOW (window)->vchild;
|
|
2239 else
|
|
2240 return window;
|
|
2241 }
|
|
2242
|
|
2243 do
|
|
2244 {
|
|
2245 if (!NILP (XWINDOW (window)->parent) &&
|
|
2246 !NILP (XWINDOW (XWINDOW (window)->parent)->vchild))
|
|
2247 {
|
|
2248 if (!NILP (XWINDOW (window)->next))
|
|
2249 return XWINDOW (window)->next;
|
|
2250 else
|
|
2251 window = XWINDOW (window)->parent;
|
|
2252 }
|
|
2253 else
|
|
2254 window = XWINDOW (window)->parent;
|
|
2255 }
|
|
2256 while (!EQ (window, root));
|
|
2257
|
|
2258 while (1)
|
|
2259 if (!NILP (XWINDOW (window)->hchild))
|
|
2260 window = XWINDOW (window)->hchild;
|
|
2261 else if (!NILP (XWINDOW (window)->vchild))
|
|
2262 window = XWINDOW (window)->vchild;
|
|
2263 else
|
|
2264 return window;
|
|
2265 }
|
|
2266
|
20
|
2267 DEFUN ("other-window", Fother_window, 1, 3, "p", /*
|
0
|
2268 Select the N'th different window on this frame.
|
|
2269 All windows on current frame are arranged in a cyclic order.
|
|
2270 This command selects the window N steps away in that order.
|
|
2271 A negative N moves in the opposite order.
|
|
2272
|
|
2273 If optional argument FRAME is `visible', search all visible frames.
|
|
2274 If FRAME is 0, search all visible and iconified frames.
|
|
2275 If FRAME is t, search all frames.
|
|
2276 If FRAME is nil, search only the selected frame.
|
|
2277 If FRAME is a frame, search only that frame.
|
|
2278
|
|
2279 Optional third argument CONSOLE controls which consoles or devices the
|
|
2280 returned window may be on. If CONSOLE is a console, return windows only
|
|
2281 on that console. If CONSOLE is a device, return windows only on that
|
|
2282 device. If CONSOLE is a console type, return windows only on consoles
|
|
2283 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2284 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2285 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2286 Otherwise, all windows are considered.
|
20
|
2287 */
|
|
2288 (n, frame, console))
|
0
|
2289 {
|
|
2290 int i;
|
|
2291 Lisp_Object w;
|
|
2292
|
|
2293 CHECK_INT (n);
|
|
2294 w = Fselected_window (Qnil);
|
|
2295 i = XINT (n);
|
|
2296
|
|
2297 while (i > 0)
|
|
2298 {
|
|
2299 w = Fnext_window (w, Qnil, frame, console);
|
|
2300 i--;
|
|
2301 }
|
|
2302 while (i < 0)
|
|
2303 {
|
|
2304 w = Fprevious_window (w, Qnil, frame, console);
|
|
2305 i++;
|
|
2306 }
|
282
|
2307 Fselect_window (w, Qnil);
|
0
|
2308 return Qnil;
|
|
2309 }
|
|
2310
|
|
2311
|
|
2312 /* Look at all windows, performing an operation specified by TYPE
|
|
2313 with argument OBJ.
|
|
2314
|
|
2315 If FRAMES is Qt, look at all frames, if Qnil, look at just the selected
|
|
2316 frame. If FRAMES is a frame, just look at windows on that frame.
|
|
2317 If MINI is non-zero, perform the operation on minibuffer windows too.
|
|
2318 */
|
|
2319
|
|
2320 enum window_loop
|
|
2321 {
|
|
2322 WINDOW_LOOP_UNUSED,
|
|
2323 GET_BUFFER_WINDOW, /* Arg is buffer */
|
|
2324 GET_LRU_WINDOW, /* Arg is t for full-width windows only */
|
|
2325 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */
|
|
2326 DELETE_BUFFER_WINDOWS, /* Arg is buffer */
|
|
2327 GET_LARGEST_WINDOW,
|
|
2328 UNSHOW_BUFFER, /* Arg is buffer */
|
|
2329 GET_BUFFER_WINDOW_COUNT, /* Arg is buffer */
|
|
2330 GET_BUFFER_MRU_WINDOW /* Arg is buffer */
|
|
2331 };
|
|
2332
|
|
2333 static Lisp_Object
|
|
2334 window_loop (enum window_loop type,
|
185
|
2335 Lisp_Object obj,
|
0
|
2336 int mini,
|
|
2337 Lisp_Object frames,
|
|
2338 int dedicated_too,
|
|
2339 Lisp_Object console)
|
|
2340 {
|
|
2341 /* This function can GC if type == DELETE_BUFFER_WINDOWS or UNSHOW_BUFFER */
|
|
2342 Lisp_Object w;
|
|
2343 Lisp_Object best_window = Qnil;
|
|
2344 Lisp_Object next_window;
|
|
2345 Lisp_Object last_window;
|
|
2346 struct frame *frame;
|
|
2347 Lisp_Object frame_arg = Qt;
|
|
2348 int count = 0; /* for GET_BUFFER_WINDOW_COUNT */
|
|
2349 /* #### I think the change of "precomputing" last_window and next_window
|
|
2350 * #### catch the lossage this is meant(?) to punt on...
|
|
2351 */
|
185
|
2352 int lose_lose = 0;
|
0
|
2353 Lisp_Object devcons, concons;
|
|
2354
|
|
2355 /* FRAME_ARG is Qlambda to stick to one frame,
|
|
2356 Qvisible to consider all visible frames,
|
|
2357 or Qt otherwise. */
|
|
2358
|
|
2359 /* If we're only looping through windows on a particular frame,
|
|
2360 FRAME points to that frame. If we're looping through windows
|
|
2361 on all frames, FRAME is 0. */
|
|
2362
|
|
2363 if (FRAMEP (frames))
|
|
2364 frame = XFRAME (frames);
|
|
2365 else if (NILP (frames))
|
|
2366 frame = selected_frame ();
|
|
2367 else
|
|
2368 frame = 0;
|
|
2369 if (frame)
|
|
2370 frame_arg = Qlambda;
|
|
2371 else if (ZEROP (frames))
|
|
2372 frame_arg = frames;
|
|
2373 else if (EQ (frames, Qvisible))
|
|
2374 frame_arg = frames;
|
185
|
2375
|
0
|
2376 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
2377 {
|
|
2378 Lisp_Object device = XCAR (devcons);
|
272
|
2379 Lisp_Object the_frame;
|
0
|
2380
|
|
2381 if (frame)
|
|
2382 XSETFRAME (the_frame, frame);
|
|
2383 else
|
|
2384 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
|
|
2385
|
|
2386 if (NILP (the_frame))
|
|
2387 continue;
|
|
2388
|
|
2389 if (!device_matches_console_spec (the_frame, device, console))
|
|
2390 continue;
|
|
2391
|
|
2392 /* Pick a window to start with. */
|
|
2393 if (WINDOWP (obj))
|
|
2394 w = obj;
|
|
2395 else
|
|
2396 w = FRAME_SELECTED_WINDOW (XFRAME (the_frame));
|
|
2397
|
|
2398 /* Figure out the last window we're going to mess with. Since
|
|
2399 Fnext_window, given the same options, is guaranteed to go in a
|
|
2400 ring, we can just use Fprevious_window to find the last one.
|
|
2401
|
|
2402 We can't just wait until we hit the first window again,
|
|
2403 because it might be deleted. */
|
|
2404
|
|
2405 last_window = Fprevious_window (w, mini ? Qt : Qnil, frame_arg, Qt);
|
|
2406
|
|
2407 best_window = Qnil;
|
|
2408 for (;;)
|
|
2409 {
|
|
2410 struct window *p = XWINDOW (w);
|
|
2411 struct frame *w_frame = XFRAME (WINDOW_FRAME (p));
|
|
2412
|
|
2413 /* Pick the next window now, since some operations will delete
|
|
2414 the current window. */
|
|
2415 next_window = Fnext_window (w, mini ? Qt : Qnil, frame_arg, Qt);
|
|
2416
|
|
2417 /* #### Still needed ?? */
|
185
|
2418 /* Given the outstanding quality of the rest of this code,
|
0
|
2419 I feel no shame about putting this piece of shit in. */
|
|
2420 if (++lose_lose >= 500)
|
|
2421 return Qnil;
|
|
2422
|
|
2423 /* Note that we do not pay attention here to whether
|
|
2424 the frame is visible, since Fnext_window skips non-visible frames
|
|
2425 if that is desired, under the control of frame_arg. */
|
|
2426 if (! MINI_WINDOW_P (p)
|
|
2427 || (mini && minibuf_level > 0))
|
|
2428 switch (type)
|
|
2429 {
|
|
2430 case GET_BUFFER_WINDOW:
|
|
2431 {
|
|
2432 if (XBUFFER (p->buffer) == XBUFFER (obj))
|
|
2433 return w;
|
|
2434 break;
|
|
2435 }
|
|
2436
|
|
2437 case GET_BUFFER_WINDOW_COUNT:
|
|
2438 {
|
|
2439 if (XBUFFER (p->buffer) == XBUFFER (obj))
|
|
2440 count++;
|
|
2441 break;
|
|
2442 }
|
|
2443
|
|
2444 case GET_LRU_WINDOW:
|
|
2445 {
|
|
2446 /* t as arg means consider only full-width windows */
|
|
2447 if (!NILP (obj)
|
|
2448 && !window_full_width_p (p))
|
|
2449 break;
|
|
2450 /* Ignore dedicated windows and minibuffers. */
|
|
2451 if (MINI_WINDOW_P (p)
|
|
2452 || (dedicated_too ? 0 : !NILP (p->dedicated)))
|
|
2453 break;
|
|
2454 if (NILP (best_window)
|
|
2455 || (XINT (XWINDOW (best_window)->use_time)
|
|
2456 > XINT (p->use_time)))
|
|
2457 best_window = w;
|
|
2458 break;
|
|
2459 }
|
|
2460
|
|
2461 case GET_BUFFER_MRU_WINDOW:
|
|
2462 {
|
|
2463 /* #### what about the first check in GET_LRU_WINDOW? */
|
|
2464 /* Ignore dedicated windows and minibuffers. */
|
|
2465 if (MINI_WINDOW_P (p)
|
|
2466 || (dedicated_too ? 0 : !NILP (p->dedicated)))
|
|
2467 break;
|
|
2468
|
|
2469 if (XBUFFER (p->buffer) == XBUFFER (obj))
|
|
2470 {
|
|
2471 if (NILP (best_window)
|
|
2472 || (XINT (XWINDOW (best_window)->use_time)
|
|
2473 < XINT (p->use_time)))
|
|
2474 best_window = w;
|
|
2475 }
|
|
2476 break;
|
|
2477 }
|
|
2478
|
|
2479 case DELETE_OTHER_WINDOWS:
|
|
2480 {
|
|
2481 /* Don't delete the last window on a frame; this can
|
|
2482 happen when the minibuffer is selected, and would
|
|
2483 cause the frame to be deleted. */
|
|
2484 if (p != XWINDOW (obj) && !TOP_LEVEL_WINDOW_P (XWINDOW (w)))
|
|
2485 Fdelete_window (w, Qnil);
|
|
2486 break;
|
|
2487 }
|
|
2488
|
|
2489 case DELETE_BUFFER_WINDOWS:
|
|
2490 {
|
|
2491 if (EQ (p->buffer, obj))
|
|
2492 {
|
|
2493 struct frame *f = XFRAME (WINDOW_FRAME (p));
|
|
2494
|
|
2495 /* If this window is dedicated, and in a frame
|
|
2496 of its own, kill the frame. */
|
|
2497 if (EQ (w, FRAME_ROOT_WINDOW (f))
|
|
2498 && !NILP (p->dedicated)
|
|
2499 && other_visible_frames (f))
|
|
2500 {
|
|
2501 /* Skip the other windows on this frame.
|
|
2502 There might be one, the minibuffer! */
|
|
2503 if (! EQ (w, last_window))
|
|
2504 while (f == XFRAME (WINDOW_FRAME
|
|
2505 (XWINDOW (next_window))))
|
|
2506 {
|
|
2507 /* As we go, check for the end of the
|
|
2508 loop. We mustn't start going
|
|
2509 around a second time. */
|
|
2510 if (EQ (next_window, last_window))
|
|
2511 {
|
|
2512 last_window = w;
|
|
2513 break;
|
|
2514 }
|
|
2515 next_window = Fnext_window (next_window,
|
|
2516 mini ? Qt : Qnil,
|
|
2517 frame_arg, Qt);
|
|
2518 }
|
|
2519 /* Now we can safely delete the frame. */
|
|
2520 Fdelete_frame (WINDOW_FRAME (p), Qnil);
|
|
2521 }
|
|
2522 else
|
|
2523 /* If we're deleting the buffer displayed in
|
|
2524 the only window on the frame, find a new
|
|
2525 buffer to display there. */
|
|
2526 if (NILP (p->parent))
|
|
2527 {
|
|
2528 Lisp_Object new_buffer;
|
|
2529 new_buffer = Fother_buffer (obj, Qnil, Qnil);
|
|
2530 if (NILP (new_buffer))
|
|
2531 new_buffer = Fget_buffer_create (QSscratch);
|
|
2532 Fset_window_buffer (w, new_buffer);
|
|
2533 if (EQ (w, Fselected_window (Qnil)))
|
|
2534 Fset_buffer (p->buffer);
|
|
2535 }
|
|
2536 else
|
|
2537 Fdelete_window (w, Qnil);
|
|
2538 }
|
|
2539 break;
|
|
2540 }
|
|
2541
|
|
2542 case GET_LARGEST_WINDOW:
|
|
2543 {
|
|
2544 /* Ignore dedicated windows and minibuffers. */
|
|
2545 if (MINI_WINDOW_P (p)
|
|
2546 || (dedicated_too ? 0 : !NILP (p->dedicated)))
|
|
2547 break;
|
|
2548 {
|
|
2549 /* write the check as follows to avoid tripping
|
|
2550 error_check_window() --ben */
|
|
2551 struct window *b = NILP (best_window) ? 0 :
|
|
2552 XWINDOW (best_window);
|
|
2553 if (NILP (best_window)
|
|
2554 || ((WINDOW_HEIGHT (p) * WINDOW_WIDTH (p))
|
|
2555 > (WINDOW_HEIGHT (b) * WINDOW_WIDTH (b))))
|
|
2556 best_window = w;
|
|
2557 }
|
|
2558 break;
|
|
2559 }
|
|
2560
|
|
2561 case UNSHOW_BUFFER:
|
|
2562 {
|
|
2563 if (EQ (p->buffer, obj))
|
|
2564 {
|
|
2565 /* Find another buffer to show in this window. */
|
|
2566 Lisp_Object another_buffer =
|
|
2567 Fother_buffer (obj, Qnil, Qnil);
|
|
2568 if (NILP (another_buffer))
|
|
2569 another_buffer
|
|
2570 = Fget_buffer_create (QSscratch);
|
|
2571 /* If this window is dedicated, and in a frame
|
|
2572 of its own, kill the frame. */
|
|
2573 if (EQ (w, FRAME_ROOT_WINDOW (w_frame))
|
|
2574 && !NILP (p->dedicated)
|
|
2575 && other_visible_frames (w_frame))
|
|
2576 {
|
|
2577 /* Skip the other windows on this frame.
|
|
2578 There might be one, the minibuffer! */
|
|
2579 if (! EQ (w, last_window))
|
|
2580 while (w_frame == XFRAME (WINDOW_FRAME
|
|
2581 (XWINDOW (next_window))))
|
|
2582 {
|
|
2583 /* As we go, check for the end of the
|
|
2584 loop. We mustn't start going
|
|
2585 around a second time. */
|
|
2586 if (EQ (next_window, last_window))
|
|
2587 {
|
|
2588 last_window = w;
|
|
2589 break;
|
|
2590 }
|
|
2591 next_window = Fnext_window (next_window,
|
|
2592 mini ? Qt : Qnil,
|
|
2593 frame_arg, Qt);
|
|
2594 }
|
|
2595 /* Now we can safely delete the frame. */
|
|
2596 delete_frame_internal (XFRAME (WINDOW_FRAME (p)),
|
|
2597 0, 0, 0);
|
|
2598 }
|
|
2599 else
|
|
2600 {
|
|
2601 /* Otherwise show a different buffer in the
|
|
2602 window. */
|
|
2603 p->dedicated = Qnil;
|
|
2604 Fset_window_buffer (w, another_buffer);
|
|
2605 if (EQ (w, Fselected_window (Qnil)))
|
|
2606 Fset_buffer (p->buffer);
|
|
2607 }
|
|
2608 }
|
|
2609 break;
|
|
2610 }
|
|
2611
|
185
|
2612 default:
|
0
|
2613 abort ();
|
|
2614 }
|
|
2615
|
|
2616 if (EQ (w, last_window))
|
|
2617 break;
|
|
2618
|
|
2619 w = next_window;
|
|
2620 }
|
|
2621 }
|
|
2622
|
173
|
2623 return type == GET_BUFFER_WINDOW_COUNT ? make_int (count) : best_window;
|
0
|
2624 }
|
|
2625
|
|
2626 #if 0 /* not currently used */
|
|
2627
|
|
2628 int
|
|
2629 buffer_window_count (struct buffer *b, struct frame *f)
|
|
2630 {
|
|
2631 Lisp_Object buffer, frame;
|
|
2632
|
|
2633 XSETFRAME (frame, f);
|
|
2634 XSETBUFFER (buffer, b);
|
|
2635
|
|
2636 return XINT (window_loop (GET_BUFFER_WINDOW_COUNT, buffer, 0, frame, 1,
|
|
2637 Qnil));
|
|
2638 }
|
|
2639
|
|
2640 int
|
|
2641 buffer_window_mru (struct window *w)
|
|
2642 {
|
185
|
2643 Lisp_Object window =
|
0
|
2644 window_loop (GET_BUFFER_MRU_WINDOW, w->buffer, 0, w->frame, 1, Qnil);
|
|
2645
|
|
2646 if (NILP (window))
|
|
2647 return 0;
|
|
2648 else if (XWINDOW (window) == w)
|
|
2649 return 1;
|
|
2650 else
|
|
2651 return 0;
|
|
2652 }
|
|
2653
|
|
2654 #endif
|
|
2655
|
|
2656
|
20
|
2657 DEFUN ("get-lru-window", Fget_lru_window, 0, 2, 0, /*
|
0
|
2658 Return the window least recently selected or used for display.
|
|
2659 If optional argument FRAME is `visible', search all visible frames.
|
|
2660 If FRAME is 0, search all visible and iconified frames.
|
|
2661 If FRAME is t, search all frames.
|
|
2662 If FRAME is nil, search only the selected frame.
|
|
2663 If FRAME is a frame, search only that frame.
|
|
2664
|
|
2665 Optional second argument CONSOLE controls which consoles or devices the
|
|
2666 returned window may be on. If CONSOLE is a console, return windows only
|
|
2667 on that console. If CONSOLE is a device, return windows only on that
|
|
2668 device. If CONSOLE is a console type, return windows only on consoles
|
|
2669 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2670 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2671 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2672 Otherwise, all windows are considered.
|
20
|
2673 */
|
|
2674 (frame, console))
|
0
|
2675 {
|
|
2676 Lisp_Object w;
|
|
2677 /* First try for a non-dedicated window that is full-width */
|
|
2678 w = window_loop (GET_LRU_WINDOW, Qt, 0, frame, 0, console);
|
|
2679 if (!NILP (w) && !EQ (w, Fselected_window (Qnil)))
|
|
2680 return w;
|
|
2681
|
|
2682 /* Then try for any non-dedicated window */
|
|
2683 w = window_loop (GET_LRU_WINDOW, Qnil, 0, frame, 0, console);
|
|
2684 if (!NILP (w) && !EQ (w, Fselected_window (Qnil)))
|
|
2685 return w;
|
|
2686
|
|
2687 #if 0
|
|
2688 /* FSFmacs never returns a dedicated window here. If we do,
|
|
2689 it makes `display-buffer' not work right. #### All of this
|
|
2690 shit is so disgusting and awful that it needs to be rethought
|
|
2691 from scratch. */
|
|
2692 /* then try for a dedicated window that is full-width */
|
|
2693 w = window_loop (GET_LRU_WINDOW, Qt, 0, frame, 1, console);
|
|
2694 if (!NILP (w) && !EQ (w, Fselected_window (Qnil)))
|
|
2695 return w;
|
|
2696
|
|
2697 /* If none of them, then all windows, dedicated or not. */
|
|
2698 w = window_loop (GET_LRU_WINDOW, Qnil, 0, frame, 1, console);
|
|
2699
|
|
2700 /* At this point we damn well better have found something. */
|
|
2701 if (NILP (w)) abort ();
|
|
2702 #endif
|
|
2703
|
173
|
2704 return w;
|
0
|
2705 }
|
|
2706
|
20
|
2707 DEFUN ("get-largest-window", Fget_largest_window, 0, 2, 0, /*
|
0
|
2708 Return the window largest in area.
|
|
2709 If optional argument FRAME is `visible', search all visible frames.
|
|
2710 If FRAME is 0, search all visible and iconified frames.
|
|
2711 If FRAME is t, search all frames.
|
|
2712 If FRAME is nil, search only the selected frame.
|
|
2713 If FRAME is a frame, search only that frame.
|
|
2714
|
|
2715 Optional second argument CONSOLE controls which consoles or devices the
|
|
2716 returned window may be on. If CONSOLE is a console, return windows only
|
|
2717 on that console. If CONSOLE is a device, return windows only on that
|
|
2718 device. If CONSOLE is a console type, return windows only on consoles
|
|
2719 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2720 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2721 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2722 Otherwise, all windows are considered.
|
20
|
2723 */
|
|
2724 (frame, console))
|
0
|
2725 {
|
|
2726 /* Don't search dedicated windows because FSFmacs doesn't.
|
|
2727 This stuff is all black magic so don't try to apply common
|
|
2728 sense to it. */
|
|
2729 return window_loop (GET_LARGEST_WINDOW, Qnil, 0, frame, 0, console);
|
|
2730 }
|
|
2731
|
20
|
2732 DEFUN ("get-buffer-window", Fget_buffer_window, 1, 3, 0, /*
|
0
|
2733 Return a window currently displaying BUFFER, or nil if none.
|
|
2734 If optional argument FRAME is `visible', search all visible frames.
|
|
2735 If optional argument FRAME is 0, search all visible and iconified frames.
|
|
2736 If FRAME is t, search all frames.
|
|
2737 If FRAME is nil, search only the selected frame.
|
|
2738 If FRAME is a frame, search only that frame.
|
|
2739
|
|
2740 Optional third argument CONSOLE controls which consoles or devices the
|
|
2741 returned window may be on. If CONSOLE is a console, return windows only
|
|
2742 on that console. If CONSOLE is a device, return windows only on that
|
|
2743 device. If CONSOLE is a console type, return windows only on consoles
|
|
2744 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2745 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2746 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2747 Otherwise, all windows are considered.
|
20
|
2748 */
|
|
2749 (buffer, frame, console))
|
0
|
2750 {
|
|
2751 buffer = Fget_buffer (buffer);
|
|
2752 if (BUFFERP (buffer))
|
|
2753 /* Search dedicated windows too. (Doesn't matter here anyway.) */
|
|
2754 return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame, 1, console);
|
|
2755 else
|
|
2756 return Qnil;
|
|
2757 }
|
|
2758
|
|
2759 /* These functions used to be `buffer-left-margin-pixel-width', etc.
|
|
2760 but there is no sensible way to implement those functions, since
|
|
2761 you can't in general derive a window from a buffer. */
|
|
2762
|
280
|
2763 DEFUN ("window-left-margin-pixel-width", Fwindow_left_margin_pixel_width,
|
|
2764 0, 1, 0, /*
|
0
|
2765 Return the width in pixels of the left outside margin of window WINDOW.
|
|
2766 If WINDOW is nil, the selected window is assumed.
|
20
|
2767 */
|
|
2768 (window))
|
0
|
2769 {
|
149
|
2770 return make_int (window_left_margin_width (decode_window (window)));
|
0
|
2771 }
|
|
2772
|
280
|
2773 DEFUN ("window-right-margin-pixel-width", Fwindow_right_margin_pixel_width,
|
|
2774 0, 1, 0, /*
|
0
|
2775 Return the width in pixels of the right outside margin of window WINDOW.
|
|
2776 If WINDOW is nil, the selected window is assumed.
|
20
|
2777 */
|
|
2778 (window))
|
0
|
2779 {
|
149
|
2780 return make_int (window_right_margin_width (decode_window (window)));
|
0
|
2781 }
|
|
2782
|
20
|
2783 DEFUN ("delete-other-windows", Fdelete_other_windows, 0, 1, "", /*
|
0
|
2784 Make WINDOW (or the selected window) fill its frame.
|
|
2785 Only the frame WINDOW is on is affected.
|
|
2786 This function tries to reduce display jumps
|
|
2787 by keeping the text previously visible in WINDOW
|
|
2788 in the same place on the frame. Doing this depends on
|
|
2789 the value of (window-start WINDOW), so if calling this function
|
|
2790 in a program gives strange scrolling, make sure the window-start
|
|
2791 value is reasonable when this function is called.
|
20
|
2792 */
|
|
2793 (window))
|
0
|
2794 {
|
|
2795 struct window *w = decode_window (window);
|
|
2796 struct buffer *b = XBUFFER (w->buffer);
|
|
2797 Bufpos start_pos;
|
|
2798 int old_top = WINDOW_TOP (w);
|
|
2799
|
|
2800 XSETWINDOW (window, w);
|
|
2801
|
|
2802 if (MINI_WINDOW_P (w) && old_top > 0)
|
|
2803 error ("Can't expand minibuffer to full frame");
|
|
2804
|
|
2805 /* Ignore dedicated windows. */
|
|
2806 window_loop (DELETE_OTHER_WINDOWS, window, 0, w->frame, 0, Qnil);
|
|
2807
|
|
2808 start_pos = marker_position (w->start[CURRENT_DISP]);
|
|
2809
|
|
2810 /* Try to minimize scrolling, by setting the window start to the
|
|
2811 point which will cause the text at the old window start to be at
|
|
2812 the same place on the frame. But don't try to do this if the
|
|
2813 window start is outside the visible portion (as might happen when
|
|
2814 the display is not current, due to typeahead). */
|
|
2815 if (start_pos >= BUF_BEGV (b) && start_pos <= BUF_ZV (b)
|
|
2816 && !MINI_WINDOW_P (w))
|
|
2817 {
|
|
2818 Bufpos new_start = start_with_line_at_pixpos (w, start_pos, old_top);
|
|
2819
|
|
2820 if (new_start >= BUF_BEGV (b) && new_start <= BUF_ZV (b))
|
|
2821 {
|
|
2822 Fset_marker (w->start[CURRENT_DISP], make_int (new_start),
|
|
2823 w->buffer);
|
|
2824 w->start_at_line_beg = beginning_of_line_p (b, new_start);
|
|
2825 }
|
|
2826 /* We need to do this, so that the window-scroll-functions
|
|
2827 get called. */
|
|
2828 w->force_start = 1;
|
|
2829 }
|
|
2830
|
|
2831 return Qnil;
|
|
2832 }
|
|
2833
|
20
|
2834 DEFUN ("delete-windows-on", Fdelete_windows_on, 1, 3,
|
|
2835 "bDelete windows on (buffer): ", /*
|
0
|
2836 Delete all windows showing BUFFER.
|
|
2837 Optional second argument FRAME controls which frames are affected.
|
|
2838 If nil or omitted, delete all windows showing BUFFER in any frame.
|
|
2839 If t, delete only windows showing BUFFER in the selected frame.
|
|
2840 If `visible', delete all windows showing BUFFER in any visible frame.
|
|
2841 If a frame, delete only windows showing BUFFER in that frame.
|
|
2842
|
|
2843 Optional third argument CONSOLE controls which consoles or devices the
|
|
2844 returned window may be on. If CONSOLE is a console, return windows only
|
|
2845 on that console. If CONSOLE is a device, return windows only on that
|
|
2846 device. If CONSOLE is a console type, return windows only on consoles
|
|
2847 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2848 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2849 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2850 Otherwise, all windows are considered.
|
20
|
2851 */
|
|
2852 (buffer, frame, console))
|
0
|
2853 {
|
|
2854 /* This function can GC */
|
|
2855 /* FRAME uses t and nil to mean the opposite of what window_loop
|
|
2856 expects. */
|
|
2857 if (!FRAMEP (frame))
|
|
2858 frame = NILP (frame) ? Qt : Qnil;
|
|
2859
|
|
2860 if (!NILP (buffer))
|
|
2861 {
|
|
2862 buffer = Fget_buffer (buffer);
|
|
2863 CHECK_BUFFER (buffer);
|
|
2864 /* Ignore dedicated windows. */
|
|
2865 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame, 0, console);
|
|
2866 }
|
|
2867 return Qnil;
|
|
2868 }
|
|
2869
|
20
|
2870 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, 1, 1,
|
|
2871 "bReplace buffer in windows: ", /*
|
0
|
2872 Replace BUFFER with some other buffer in all windows showing it.
|
20
|
2873 */
|
|
2874 (buffer))
|
0
|
2875 {
|
|
2876 /* This function can GC */
|
|
2877 if (!NILP (buffer))
|
|
2878 {
|
|
2879 buffer = Fget_buffer (buffer);
|
|
2880 CHECK_BUFFER (buffer);
|
|
2881 /* Ignore dedicated windows. */
|
|
2882 window_loop (UNSHOW_BUFFER, buffer, 0, Qt, 0, Qnil);
|
|
2883 }
|
|
2884 return Qnil;
|
|
2885 }
|
|
2886
|
|
2887 /* The smallest acceptable dimensions for a window. Anything smaller
|
|
2888 might crash Emacs. */
|
|
2889 #define MIN_SAFE_WINDOW_WIDTH (2)
|
|
2890 #define MIN_SAFE_WINDOW_HEIGHT (2)
|
|
2891
|
|
2892 /* Make sure that window_min_height and window_min_width are
|
|
2893 not too small; if they are, set them to safe minima. */
|
|
2894
|
|
2895 static void
|
|
2896 check_min_window_sizes (void)
|
|
2897 {
|
|
2898 /* Smaller values might permit a crash. */
|
|
2899 if (window_min_width < MIN_SAFE_WINDOW_WIDTH)
|
|
2900 window_min_width = MIN_SAFE_WINDOW_WIDTH;
|
|
2901 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT)
|
|
2902 window_min_height = MIN_SAFE_WINDOW_HEIGHT;
|
|
2903 }
|
|
2904
|
|
2905 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
|
|
2906 minimum allowable size. */
|
|
2907 void
|
|
2908 check_frame_size (struct frame *frame, int *rows, int *cols)
|
|
2909 {
|
|
2910 /* For height, we have to see whether the frame has a minibuffer, and
|
|
2911 whether it wants a modeline. */
|
|
2912 int min_height =
|
|
2913 (FRAME_MINIBUF_ONLY_P (frame) ? MIN_SAFE_WINDOW_HEIGHT - 1
|
|
2914 : (! FRAME_HAS_MINIBUF_P (frame)) ? MIN_SAFE_WINDOW_HEIGHT
|
|
2915 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1);
|
|
2916
|
|
2917 if (*rows < min_height)
|
|
2918 *rows = min_height;
|
|
2919 if (*cols < MIN_SAFE_WINDOW_WIDTH)
|
|
2920 *cols = MIN_SAFE_WINDOW_WIDTH;
|
|
2921 }
|
|
2922
|
|
2923 /* Normally the window is deleted if it gets too small.
|
|
2924 nodelete nonzero means do not do this.
|
|
2925 (The caller should check later and do so if appropriate) */
|
|
2926 static void
|
|
2927 set_window_pixsize (Lisp_Object window, int new_pixsize, int nodelete,
|
|
2928 int set_height)
|
|
2929 {
|
|
2930 struct window *w = XWINDOW (window);
|
|
2931 struct frame *f = XFRAME (w->frame);
|
|
2932 struct window *c;
|
|
2933 int old_pixsize = (set_height ? WINDOW_HEIGHT (w) : WINDOW_WIDTH (w));
|
|
2934 Lisp_Object child, minor_kid, major_kid;
|
|
2935 int minsize;
|
|
2936 int line_size;
|
|
2937 int defheight, defwidth;
|
|
2938
|
|
2939 /* #### This is very likely incorrect and instead the char_to_pixel_
|
|
2940 functions should be called. */
|
|
2941 default_face_height_and_width (window, &defheight, &defwidth);
|
|
2942 line_size = (set_height ? defheight : defwidth);
|
|
2943
|
272
|
2944 check_min_window_sizes ();
|
|
2945
|
0
|
2946 minsize = (set_height ? window_min_height : window_min_width);
|
|
2947 minsize *= line_size;
|
|
2948
|
|
2949 if (!nodelete
|
|
2950 && !TOP_LEVEL_WINDOW_P (w)
|
|
2951 && new_pixsize < minsize)
|
|
2952 {
|
|
2953 Fdelete_window (window, Qnil);
|
|
2954 return;
|
|
2955 }
|
|
2956
|
|
2957 SET_LAST_MODIFIED (w, 0);
|
|
2958 SET_LAST_FACECHANGE (w);
|
|
2959 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); /* multiple windows affected */
|
|
2960 if (set_height)
|
|
2961 {
|
|
2962 WINDOW_HEIGHT (w) = new_pixsize;
|
|
2963 major_kid = w->vchild;
|
|
2964 minor_kid = w->hchild;
|
|
2965 }
|
|
2966 else
|
|
2967 {
|
|
2968 WINDOW_WIDTH (w) = new_pixsize;
|
|
2969 major_kid = w->hchild;
|
|
2970 minor_kid = w->vchild;
|
|
2971 }
|
|
2972
|
|
2973 if (!NILP (minor_kid))
|
|
2974 {
|
|
2975 for (child = minor_kid; !NILP (child); child = XWINDOW (child)->next)
|
|
2976 {
|
|
2977 if (set_height)
|
|
2978 WINDOW_TOP (XWINDOW (child)) = WINDOW_TOP (w);
|
|
2979 else
|
|
2980 WINDOW_LEFT (XWINDOW (child)) = WINDOW_LEFT (w);
|
|
2981
|
|
2982 set_window_pixsize (child, new_pixsize, nodelete, set_height);
|
|
2983 }
|
|
2984 }
|
|
2985 else if (!NILP (major_kid))
|
|
2986 {
|
|
2987 int last_pos, last_old_pos, pos, old_pos, first;
|
215
|
2988 int pixel_adj_left = new_pixsize - old_pixsize;
|
0
|
2989 int div_val = old_pixsize << 1;
|
|
2990
|
209
|
2991 /*
|
|
2992 * Previously we bailed out here if there was no size change.
|
215
|
2993 * (pixel_adj_left == 0) But this broke toolbar updates. If a
|
|
2994 * toolbar appears or disappears, windows may not change size,
|
|
2995 * but their top and left coordinates need to be updated.
|
209
|
2996 *
|
215
|
2997 * So we don't bail until after the loop below.
|
209
|
2998 */
|
0
|
2999
|
|
3000 last_pos = first = (set_height ? WINDOW_TOP (w) : WINDOW_LEFT (w));
|
|
3001 last_old_pos = 0;
|
|
3002
|
|
3003 for (child = major_kid; !NILP (child); child = c->next)
|
|
3004 {
|
|
3005 c = XWINDOW (child);
|
|
3006
|
|
3007 if (set_height)
|
|
3008 {
|
|
3009 old_pos = last_old_pos + WINDOW_HEIGHT (c);
|
|
3010 WINDOW_TOP (c) = last_pos;
|
|
3011 }
|
|
3012 else
|
|
3013 {
|
|
3014 old_pos = last_old_pos + WINDOW_WIDTH (c);
|
|
3015 WINDOW_LEFT (c) = last_pos;
|
|
3016 }
|
|
3017
|
|
3018 pos = (((old_pos * new_pixsize) << 1) + old_pixsize) / div_val;
|
2
|
3019 /* All but the last window should have a height which is
|
0
|
3020 a multiple of the default line height. */
|
|
3021 if (!NILP (c->next))
|
|
3022 pos = (pos / line_size) * line_size;
|
|
3023
|
|
3024 /* Avoid confusion: don't delete child if it becomes too small */
|
|
3025 set_window_pixsize (child, pos + first - last_pos, 1, set_height);
|
|
3026
|
|
3027 last_pos = pos + first;
|
|
3028 last_old_pos = old_pos;
|
|
3029 }
|
|
3030
|
215
|
3031 /* Sometimes we may get called with our old size. In that case
|
|
3032 we don't need to do anything else. */
|
|
3033 if (!pixel_adj_left)
|
|
3034 return;
|
|
3035
|
0
|
3036 /* Now delete any children that became too small. */
|
|
3037 if (!nodelete)
|
|
3038 for (child = major_kid; !NILP (child); child = XWINDOW (child)->next)
|
|
3039 {
|
|
3040 if (set_height)
|
|
3041 set_window_pixheight (child, WINDOW_HEIGHT (XWINDOW (child)), 0);
|
|
3042 else
|
|
3043 set_window_pixwidth (child, WINDOW_WIDTH (XWINDOW (child)), 0);
|
|
3044 }
|
|
3045 }
|
|
3046 }
|
|
3047
|
|
3048 /* Set the height of WINDOW and all its inferiors. */
|
|
3049 void
|
|
3050 set_window_pixheight (Lisp_Object window, int new_pixheight, int nodelete)
|
|
3051 {
|
|
3052 set_window_pixsize (window, new_pixheight, nodelete, 1);
|
|
3053 }
|
|
3054
|
|
3055 /* Recursively set width of WINDOW and its inferiors. */
|
|
3056 void
|
|
3057 set_window_pixwidth (Lisp_Object window, int new_pixwidth, int nodelete)
|
|
3058 {
|
|
3059 set_window_pixsize (window, new_pixwidth, nodelete, 0);
|
|
3060 }
|
|
3061
|
|
3062
|
|
3063 static int window_select_count;
|
|
3064
|
20
|
3065 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 2, 0, /*
|
0
|
3066 Make WINDOW display BUFFER as its contents.
|
|
3067 BUFFER can be a buffer or buffer name.
|
20
|
3068 */
|
|
3069 (window, buffer))
|
0
|
3070 {
|
|
3071 Lisp_Object tem;
|
|
3072 struct window *w = decode_window (window);
|
|
3073
|
|
3074 buffer = Fget_buffer (buffer);
|
|
3075 CHECK_BUFFER (buffer);
|
|
3076
|
|
3077 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
|
|
3078 error ("Attempt to display deleted buffer");
|
|
3079
|
|
3080 tem = w->buffer;
|
|
3081 if (NILP (tem))
|
|
3082 error ("Window is deleted");
|
|
3083
|
|
3084 /* While this seems like a logical thing to do, it causes problems
|
|
3085 because of saved window configurations. It is possible for a
|
|
3086 buffer to get restored into a window in which it is already being
|
|
3087 displayed, but start and point are actually at completely
|
|
3088 different locations. So we let this function complete fully and
|
|
3089 it will then make sure redisplay correctly updates things.
|
|
3090
|
|
3091 #### This is a kludge. The correct approach is not to do this
|
|
3092 but to fix set-window-configuration. */
|
|
3093 #if 0
|
|
3094 else if (EQ (tem, buffer))
|
149
|
3095 return Qnil;
|
0
|
3096 #endif
|
|
3097 else if (! EQ (tem, Qt)) /* w->buffer is t when the window
|
|
3098 is first being set up. */
|
|
3099 {
|
|
3100 if (!NILP (w->dedicated) && !EQ (tem, buffer))
|
|
3101 error ("Window is dedicated to buffer %s",
|
16
|
3102 XSTRING_DATA (XBUFFER (tem)->name));
|
0
|
3103
|
|
3104 unshow_buffer (w);
|
|
3105 }
|
|
3106
|
|
3107 w->buffer = buffer;
|
|
3108 w->window_end_pos[CURRENT_DISP] = 0;
|
259
|
3109 w->hscroll = 0;
|
|
3110 w->modeline_hscroll = 0;
|
0
|
3111 Fset_marker (w->pointm[CURRENT_DISP],
|
|
3112 make_int (BUF_PT (XBUFFER (buffer))),
|
|
3113 buffer);
|
|
3114 set_marker_restricted (w->start[CURRENT_DISP],
|
|
3115 make_int (XBUFFER (buffer)->last_window_start),
|
|
3116 buffer);
|
|
3117 Fset_marker (w->sb_point, w->start[CURRENT_DISP], buffer);
|
|
3118 w->start_at_line_beg = 0;
|
|
3119 w->force_start = 0; /* Lucid fix */
|
|
3120 SET_LAST_MODIFIED (w, 1);
|
|
3121 SET_LAST_FACECHANGE (w);
|
|
3122 MARK_WINDOWS_CHANGED (w);
|
|
3123 recompute_all_cached_specifiers_in_window (w);
|
|
3124 if (EQ (window, Fselected_window (Qnil)))
|
|
3125 {
|
|
3126 Fset_buffer (buffer);
|
|
3127 }
|
|
3128 return Qnil;
|
|
3129 }
|
|
3130
|
282
|
3131 DEFUN ("select-window", Fselect_window, 1, 2, 0, /*
|
0
|
3132 Select WINDOW. Most editing will apply to WINDOW's buffer.
|
|
3133 The main editor command loop selects the buffer of the selected window
|
|
3134 before each command.
|
282
|
3135
|
|
3136 With non-nil optional argument `norecord', do not modify the
|
|
3137 global or per-frame buffer ordering.
|
20
|
3138 */
|
282
|
3139 (window, norecord))
|
0
|
3140 {
|
|
3141 struct window *w;
|
|
3142 Lisp_Object old_selected_window = Fselected_window (Qnil);
|
185
|
3143
|
0
|
3144 CHECK_LIVE_WINDOW (window);
|
|
3145 w = XWINDOW (window);
|
|
3146
|
|
3147 /* we have already caught dead-window errors */
|
|
3148 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
3149 error ("Trying to select non-leaf window");
|
|
3150
|
|
3151 w->use_time = make_int (++window_select_count);
|
|
3152 if (EQ (window, old_selected_window))
|
|
3153 return window;
|
|
3154
|
|
3155 /* deselect the old window, if it exists (it might not exist if
|
|
3156 the selected device has no frames, which occurs at startup) */
|
|
3157 if (!NILP (old_selected_window))
|
|
3158 {
|
|
3159 struct window *ow = XWINDOW (old_selected_window);
|
|
3160
|
|
3161 Fset_marker (ow->pointm[CURRENT_DISP],
|
|
3162 make_int (BUF_PT (XBUFFER (ow->buffer))),
|
|
3163 ow->buffer);
|
|
3164
|
|
3165 MARK_WINDOWS_CHANGED (ow);
|
|
3166 }
|
|
3167
|
|
3168 /* now select the window's frame */
|
|
3169 set_frame_selected_window (XFRAME (WINDOW_FRAME (w)), window);
|
185
|
3170
|
0
|
3171 select_frame_1 (WINDOW_FRAME (w));
|
|
3172
|
|
3173 /* also select the window's buffer */
|
282
|
3174 if (NILP (norecord))
|
|
3175 Frecord_buffer (w->buffer);
|
0
|
3176 Fset_buffer (w->buffer);
|
|
3177
|
|
3178 /* Go to the point recorded in the window.
|
|
3179 This is important when the buffer is in more
|
|
3180 than one window. It also matters when
|
|
3181 redisplay_window has altered point after scrolling,
|
|
3182 because it makes the change only in the window. */
|
|
3183 {
|
|
3184 Bufpos new_point = marker_position (w->pointm[CURRENT_DISP]);
|
|
3185 if (new_point < BUF_BEGV (current_buffer))
|
|
3186 new_point = BUF_BEGV (current_buffer);
|
|
3187 else if (new_point > BUF_ZV (current_buffer))
|
|
3188 new_point = BUF_ZV (current_buffer);
|
|
3189
|
|
3190 BUF_SET_PT (current_buffer, new_point);
|
|
3191 }
|
|
3192
|
|
3193 MARK_WINDOWS_CHANGED (w);
|
|
3194
|
|
3195 return window;
|
|
3196 }
|
|
3197
|
|
3198 Lisp_Object
|
|
3199 display_buffer (Lisp_Object buffer, Lisp_Object not_this_window_p,
|
|
3200 Lisp_Object override_frame)
|
|
3201 {
|
|
3202 return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame);
|
|
3203 }
|
|
3204
|
|
3205 void
|
|
3206 temp_output_buffer_show (Lisp_Object buf, Lisp_Object same_frame)
|
|
3207 {
|
|
3208 /* This function can GC */
|
|
3209 Lisp_Object window;
|
|
3210 struct window *w;
|
|
3211 struct buffer *b = XBUFFER (buf);
|
|
3212
|
|
3213 BUF_SAVE_MODIFF (XBUFFER (buf)) = BUF_MODIFF (b);
|
|
3214 widen_buffer (b, 0);
|
|
3215 BUF_SET_PT (b, BUF_BEG (b));
|
|
3216
|
272
|
3217 if (!NILP (Vtemp_buffer_show_function))
|
0
|
3218 call1 (Vtemp_buffer_show_function, buf);
|
|
3219 else
|
|
3220 {
|
|
3221 window = display_buffer (buf, Qnil, same_frame);
|
|
3222
|
|
3223 if (!EQ (XWINDOW (window)->frame, Fselected_frame (Qnil)))
|
|
3224 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
|
|
3225
|
274
|
3226 Vminibuffer_scroll_window = window;
|
0
|
3227 w = XWINDOW (window);
|
|
3228 w->hscroll = 0;
|
257
|
3229 w->modeline_hscroll = 0;
|
0
|
3230 set_marker_restricted (w->start[CURRENT_DISP], make_int (1), buf);
|
|
3231 set_marker_restricted (w->pointm[CURRENT_DISP], make_int (1), buf);
|
|
3232 set_marker_restricted (w->sb_point, make_int (1), buf);
|
|
3233
|
185
|
3234 /* Run temp-buffer-show-hook, with the chosen window selected. */
|
0
|
3235 if (!preparing_for_armageddon)
|
|
3236 {
|
|
3237 Lisp_Object tem;
|
|
3238 tem = Fboundp (Qtemp_buffer_show_hook);
|
|
3239 if (!NILP (tem))
|
|
3240 {
|
|
3241 tem = Fsymbol_value (Qtemp_buffer_show_hook);
|
|
3242 if (!NILP (tem))
|
|
3243 {
|
|
3244 int count = specpdl_depth ();
|
|
3245
|
|
3246 /* Select the window that was chosen, for running
|
|
3247 the hook. */
|
|
3248 record_unwind_protect (save_window_excursion_unwind,
|
|
3249 Fcurrent_window_configuration (Qnil));
|
|
3250
|
282
|
3251 Fselect_window (window, Qnil);
|
0
|
3252 run_hook (Qtemp_buffer_show_hook);
|
|
3253 unbind_to (count, Qnil);
|
|
3254 }
|
|
3255 }
|
|
3256 }
|
|
3257 }
|
|
3258 }
|
|
3259
|
|
3260 static void
|
|
3261 make_dummy_parent (Lisp_Object window)
|
|
3262 {
|
272
|
3263 Lisp_Object new;
|
0
|
3264 struct window *o = XWINDOW (window);
|
185
|
3265 struct window *p = alloc_lcrecord_type (struct window, lrecord_window);
|
0
|
3266
|
|
3267 XSETWINDOW (new, p);
|
|
3268 copy_lcrecord (p, o);
|
|
3269
|
|
3270 /* Don't copy the pointers to the line start cache or the face
|
|
3271 instances. */
|
185
|
3272 p->line_start_cache = Dynarr_new (line_start_cache);
|
|
3273 p->face_cachels = Dynarr_new (face_cachel);
|
|
3274 p->glyph_cachels = Dynarr_new (glyph_cachel);
|
0
|
3275
|
|
3276 /* Put new into window structure in place of window */
|
|
3277 replace_window (window, new);
|
|
3278
|
|
3279 o->next = Qnil;
|
|
3280 o->prev = Qnil;
|
|
3281 o->vchild = Qnil;
|
|
3282 o->hchild = Qnil;
|
|
3283 o->parent = new;
|
|
3284
|
|
3285 p->start[CURRENT_DISP] = Qnil;
|
|
3286 p->start[DESIRED_DISP] = Qnil;
|
|
3287 p->start[CMOTION_DISP] = Qnil;
|
|
3288 p->pointm[CURRENT_DISP] = Qnil;
|
|
3289 p->pointm[DESIRED_DISP] = Qnil;
|
|
3290 p->pointm[CMOTION_DISP] = Qnil;
|
|
3291 p->sb_point = Qnil;
|
|
3292 p->buffer = Qnil;
|
|
3293 }
|
|
3294
|
20
|
3295 DEFUN ("split-window", Fsplit_window, 0, 3, "", /*
|
0
|
3296 Split WINDOW, putting SIZE lines in the first of the pair.
|
|
3297 WINDOW defaults to selected one and SIZE to half its size.
|
|
3298 If optional third arg HOR-FLAG is non-nil, split side by side
|
|
3299 and put SIZE columns in the first of the pair.
|
20
|
3300 */
|
|
3301 (window, chsize, horflag))
|
0
|
3302 {
|
|
3303 Lisp_Object new;
|
|
3304 struct window *o, *p;
|
|
3305 struct frame *f;
|
|
3306 int size;
|
|
3307 int psize;
|
|
3308
|
|
3309 if (NILP (window))
|
|
3310 window = Fselected_window (Qnil);
|
|
3311 else
|
|
3312 CHECK_WINDOW (window);
|
|
3313
|
|
3314 o = XWINDOW (window);
|
|
3315 f = XFRAME (WINDOW_FRAME (o));
|
|
3316
|
|
3317 if (NILP (chsize))
|
|
3318 {
|
|
3319 if (!NILP (horflag))
|
|
3320 /* In the new scheme, we are symmetric with respect to separators
|
|
3321 so there is no need to do weird things here. */
|
|
3322 {
|
|
3323 psize = WINDOW_WIDTH (o) >> 1;
|
|
3324 size = window_pixel_width_to_char_width (o, psize, 0);
|
|
3325 }
|
|
3326 else
|
|
3327 {
|
|
3328 psize = WINDOW_HEIGHT (o) >> 1;
|
|
3329 size = window_pixel_height_to_char_height (o, psize, 1);
|
|
3330 }
|
|
3331 }
|
|
3332 else
|
|
3333 {
|
|
3334 CHECK_INT (chsize);
|
|
3335 size = XINT (chsize);
|
|
3336 if (!NILP (horflag))
|
|
3337 psize = window_char_width_to_pixel_width (o, size, 0);
|
|
3338 else
|
|
3339 psize = window_char_height_to_pixel_height (o, size, 1);
|
|
3340 }
|
|
3341
|
|
3342 if (MINI_WINDOW_P (o))
|
|
3343 error ("Attempt to split minibuffer window");
|
|
3344 else if (FRAME_NO_SPLIT_P (XFRAME (WINDOW_FRAME (o))))
|
|
3345 error ("Attempt to split unsplittable frame");
|
|
3346
|
|
3347 check_min_window_sizes ();
|
|
3348
|
|
3349 if (NILP (horflag))
|
|
3350 {
|
|
3351 if (size < window_min_height)
|
|
3352 error ("Window height %d too small (after splitting)", size);
|
|
3353 if (size + window_min_height > window_char_height (o, 1))
|
185
|
3354 error ("Window height %d too small (after splitting)",
|
0
|
3355 window_char_height (o, 1) - size);
|
|
3356 if (NILP (o->parent)
|
|
3357 || NILP (XWINDOW (o->parent)->vchild))
|
|
3358 {
|
|
3359 make_dummy_parent (window);
|
|
3360 reset_face_cachels (XWINDOW (window));
|
|
3361 new = o->parent;
|
|
3362 XWINDOW (new)->vchild = window;
|
|
3363 XFRAME (o->frame)->mirror_dirty = 1;
|
|
3364 }
|
|
3365 }
|
|
3366 else
|
|
3367 {
|
|
3368 if (size < window_min_width)
|
|
3369 error ("Window width %d too small (after splitting)", size);
|
|
3370 if (size + window_min_width > window_char_width (o, 0))
|
185
|
3371 error ("Window width %d too small (after splitting)",
|
0
|
3372 window_char_width (o, 0) - size);
|
|
3373 if (NILP (o->parent)
|
|
3374 || NILP (XWINDOW (o->parent)->hchild))
|
|
3375 {
|
|
3376 make_dummy_parent (window);
|
|
3377 reset_face_cachels (XWINDOW (window));
|
|
3378 new = o->parent;
|
|
3379 XWINDOW (new)->hchild = window;
|
|
3380 XFRAME (o->frame)->mirror_dirty = 1;
|
|
3381 }
|
|
3382 }
|
|
3383
|
|
3384 /* Now we know that window's parent is a vertical combination
|
|
3385 if we are dividing vertically, or a horizontal combination
|
|
3386 if we are making side-by-side windows */
|
|
3387
|
|
3388 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
3389 new = allocate_window ();
|
|
3390 p = XWINDOW (new);
|
|
3391
|
|
3392 p->frame = o->frame;
|
|
3393 p->next = o->next;
|
|
3394 if (!NILP (p->next))
|
|
3395 XWINDOW (p->next)->prev = new;
|
|
3396 p->prev = window;
|
|
3397 o->next = new;
|
|
3398 p->parent = o->parent;
|
|
3399 p->buffer = Qt;
|
|
3400
|
|
3401 reset_face_cachels (p);
|
|
3402 reset_glyph_cachels (p);
|
185
|
3403
|
0
|
3404
|
|
3405 /* Apportion the available frame space among the two new windows */
|
|
3406
|
|
3407 if (!NILP (horflag))
|
|
3408 {
|
|
3409 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o);
|
|
3410 WINDOW_TOP (p) = WINDOW_TOP (o);
|
|
3411 WINDOW_WIDTH (p) = WINDOW_WIDTH (o) - psize;
|
|
3412 WINDOW_WIDTH (o) = psize;
|
|
3413 WINDOW_LEFT (p) = WINDOW_LEFT (o) + psize;
|
|
3414 }
|
|
3415 else
|
|
3416 {
|
|
3417 WINDOW_LEFT (p) = WINDOW_LEFT (o);
|
|
3418 WINDOW_WIDTH (p) = WINDOW_WIDTH (o);
|
|
3419 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o) - psize;
|
|
3420 WINDOW_HEIGHT (o) = psize;
|
|
3421 WINDOW_TOP (p) = WINDOW_TOP (o) + psize;
|
|
3422 }
|
|
3423
|
|
3424 XFRAME (p->frame)->mirror_dirty = 1;
|
|
3425 /* do this last (after the window is completely initialized and
|
|
3426 the mirror-dirty flag is set) so that specifier recomputation
|
|
3427 caused as a result of this will work properly and not abort. */
|
|
3428 Fset_window_buffer (new, o->buffer);
|
|
3429 return new;
|
|
3430 }
|
|
3431
|
|
3432
|
20
|
3433 DEFUN ("enlarge-window", Fenlarge_window, 1, 3, "_p", /*
|
0
|
3434 Make the selected window ARG lines bigger.
|
|
3435 From program, optional second arg non-nil means grow sideways ARG columns,
|
|
3436 and optional third ARG specifies the window to change instead of the
|
|
3437 selected window.
|
20
|
3438 */
|
|
3439 (n, side, window))
|
0
|
3440 {
|
|
3441 struct window *w = decode_window (window);
|
|
3442 CHECK_INT (n);
|
263
|
3443 change_window_height (w, XINT (n), !NILP (side), /* inpixels */ 0);
|
|
3444 return Qnil;
|
|
3445 }
|
|
3446
|
|
3447 DEFUN ("enlarge-window-pixels", Fenlarge_window_pixels, 1, 3, "_p", /*
|
|
3448 Make the selected window ARG pixels bigger.
|
|
3449 From program, optional second arg non-nil means grow sideways ARG pixels,
|
|
3450 and optional third ARG specifies the window to change instead of the
|
|
3451 selected window.
|
|
3452 */
|
|
3453 (n, side, window))
|
|
3454 {
|
|
3455 struct window *w = decode_window (window);
|
|
3456 CHECK_INT (n);
|
|
3457 change_window_height (w, XINT (n), !NILP (side), /* inpixels */ 1);
|
0
|
3458 return Qnil;
|
|
3459 }
|
|
3460
|
20
|
3461 DEFUN ("shrink-window", Fshrink_window, 1, 3, "_p", /*
|
0
|
3462 Make the selected window ARG lines smaller.
|
|
3463 From program, optional second arg non-nil means shrink sideways ARG columns,
|
|
3464 and optional third ARG specifies the window to change instead of the
|
|
3465 selected window.
|
20
|
3466 */
|
|
3467 (n, side, window))
|
0
|
3468 {
|
|
3469 CHECK_INT (n);
|
263
|
3470 change_window_height (decode_window (window), -XINT (n), !NILP (side),
|
|
3471 /* inpixels */ 0);
|
|
3472 return Qnil;
|
|
3473 }
|
|
3474
|
|
3475 DEFUN ("shrink-window-pixels", Fshrink_window_pixels, 1, 3, "_p", /*
|
|
3476 Make the selected window ARG pixels smaller.
|
|
3477 From program, optional second arg non-nil means shrink sideways ARG pixels,
|
|
3478 and optional third ARG specifies the window to change instead of the
|
|
3479 selected window.
|
|
3480 */
|
|
3481 (n, side, window))
|
|
3482 {
|
|
3483 CHECK_INT (n);
|
|
3484 change_window_height (decode_window (window), -XINT (n), !NILP (side),
|
|
3485 /* inpixels */ 1);
|
0
|
3486 return Qnil;
|
|
3487 }
|
|
3488
|
|
3489 static int
|
|
3490 window_pixel_height (Lisp_Object window)
|
|
3491 {
|
149
|
3492 return WINDOW_HEIGHT (XWINDOW (window));
|
0
|
3493 }
|
|
3494
|
|
3495 static int
|
|
3496 window_pixel_height_to_char_height (struct window *w, int pixel_height,
|
|
3497 int include_gutters_p)
|
|
3498 {
|
|
3499 int avail_height;
|
|
3500 int defheight, defwidth;
|
|
3501 int char_height;
|
|
3502 Lisp_Object window;
|
185
|
3503
|
0
|
3504 XSETWINDOW (window, w);
|
185
|
3505
|
0
|
3506 avail_height = (pixel_height -
|
|
3507 (include_gutters_p ? 0 :
|
|
3508 window_top_gutter_height (w) +
|
|
3509 window_bottom_gutter_height (w)));
|
185
|
3510
|
0
|
3511 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3512
|
|
3513 char_height = avail_height / defheight;
|
|
3514
|
|
3515 /* It's the calling function's responsibility to check these values
|
|
3516 and make sure they're not out of range.
|
|
3517
|
|
3518 #### We need to go through the calling functions and actually
|
|
3519 do this. */
|
272
|
3520 return max (0, char_height);
|
0
|
3521 }
|
|
3522
|
|
3523 static int
|
|
3524 window_char_height_to_pixel_height (struct window *w, int char_height,
|
|
3525 int include_gutters_p)
|
|
3526 {
|
|
3527 int avail_height;
|
|
3528 int defheight, defwidth;
|
|
3529 int pixel_height;
|
|
3530
|
|
3531 Lisp_Object window;
|
185
|
3532
|
0
|
3533 XSETWINDOW (window, w);
|
185
|
3534
|
0
|
3535 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3536
|
|
3537 avail_height = char_height * defheight;
|
|
3538 pixel_height = (avail_height +
|
|
3539 (include_gutters_p ? 0 :
|
|
3540 window_top_gutter_height (w) +
|
|
3541 window_bottom_gutter_height (w)));
|
|
3542
|
|
3543 /* It's the calling function's responsibility to check these values
|
|
3544 and make sure they're not out of range.
|
|
3545
|
|
3546 #### We need to go through the calling functions and actually
|
|
3547 do this. */
|
272
|
3548 return max (0, pixel_height);
|
0
|
3549 }
|
|
3550
|
|
3551 /* Return number of default lines of text can fit in the window W.
|
|
3552 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus
|
|
3553 horizontal scrollbar) in the space that is used for the calculation.
|
|
3554 */
|
|
3555 int
|
|
3556 window_char_height (struct window *w, int include_gutters_p)
|
|
3557 {
|
|
3558 return window_pixel_height_to_char_height (w, WINDOW_HEIGHT (w),
|
|
3559 include_gutters_p);
|
|
3560 }
|
|
3561
|
|
3562 /*
|
|
3563 * Return number of lines currently displayed in window w. If
|
|
3564 * end-of-buffer is displayed then the area below end-of-buffer is assume
|
|
3565 * to be blank lines of default height.
|
|
3566 * Does not include the modeline.
|
|
3567 */
|
|
3568 int
|
|
3569 window_displayed_height (struct window *w)
|
|
3570 {
|
|
3571 struct buffer *b = XBUFFER (w->buffer);
|
|
3572 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
3573 int num_lines;
|
|
3574 Charcount end_pos = (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b)
|
|
3575 ? -1
|
|
3576 : w->window_end_pos[CURRENT_DISP]);
|
|
3577
|
|
3578 if (!Dynarr_length (dla))
|
|
3579 return window_char_height (w, 0);
|
|
3580
|
|
3581 num_lines = Dynarr_length (dla);
|
|
3582
|
|
3583 /* #### Document and assert somewhere that w->window_end_pos == -1
|
|
3584 indicates that end-of-buffer is being displayed. */
|
|
3585 if (end_pos == -1)
|
|
3586 {
|
|
3587 struct display_line *dl = Dynarr_atp (dla, 0);
|
|
3588 int ypos1 = dl->ypos + dl->descent;
|
|
3589 int ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
3590 Lisp_Object window;
|
|
3591 int defheight, defwidth;
|
|
3592
|
|
3593 XSETWINDOW (window, w);
|
|
3594
|
|
3595 if (dl->modeline)
|
|
3596 {
|
|
3597 num_lines--;
|
|
3598
|
|
3599 if (Dynarr_length (dla) == 1)
|
|
3600 ypos1 = WINDOW_TEXT_TOP (w);
|
|
3601 else
|
|
3602 {
|
|
3603 dl = Dynarr_atp (dla, Dynarr_length (dla) - 1);
|
|
3604 /* If this line is clipped then we know that there is no
|
|
3605 blank room between eob and the modeline. If we are
|
|
3606 scrolling on clipped lines just know off the clipped
|
|
3607 line and return .*/
|
|
3608 if (scroll_on_clipped_lines && dl->clip)
|
149
|
3609 return num_lines - 1;
|
0
|
3610 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
3611 }
|
|
3612 }
|
|
3613
|
|
3614 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3615 /* #### This probably needs to know about the clipping area once a
|
|
3616 final definition is decided on. */
|
|
3617 num_lines += ((ypos2 - ypos1) / defheight);
|
|
3618 }
|
|
3619 else
|
|
3620 {
|
|
3621 if (num_lines > 1 && Dynarr_atp (dla, 0)->modeline)
|
|
3622 num_lines--;
|
|
3623
|
|
3624 if (scroll_on_clipped_lines
|
|
3625 && Dynarr_atp (dla, Dynarr_length (dla) - 1)->clip)
|
|
3626 num_lines--;
|
|
3627 }
|
|
3628
|
|
3629 return num_lines;
|
|
3630 }
|
|
3631
|
|
3632 static int
|
|
3633 window_pixel_width (Lisp_Object window)
|
|
3634 {
|
149
|
3635 return WINDOW_WIDTH (XWINDOW (window));
|
0
|
3636 }
|
|
3637
|
|
3638 static int
|
|
3639 window_pixel_width_to_char_width (struct window *w, int pixel_width,
|
|
3640 int include_margins_p)
|
|
3641 {
|
|
3642 int avail_width;
|
|
3643 int char_width;
|
|
3644 int defheight, defwidth;
|
|
3645 Lisp_Object window;
|
185
|
3646
|
0
|
3647 XSETWINDOW (window, w);
|
185
|
3648
|
0
|
3649 avail_width = (pixel_width -
|
|
3650 window_left_gutter_width (w, 0) -
|
|
3651 window_right_gutter_width (w, 0) -
|
|
3652 (include_margins_p ? 0 : window_left_margin_width (w)) -
|
|
3653 (include_margins_p ? 0 : window_right_margin_width (w)));
|
185
|
3654
|
0
|
3655 default_face_height_and_width (window, &defheight, &defwidth);
|
185
|
3656
|
0
|
3657 char_width = (avail_width / defwidth);
|
|
3658
|
|
3659 /* It's the calling function's responsibility to check these values
|
|
3660 and make sure they're not out of range.
|
|
3661
|
|
3662 #### We need to go through the calling functions and actually
|
|
3663 do this. */
|
272
|
3664 return max (0, char_width);
|
0
|
3665 }
|
|
3666
|
|
3667 static int
|
|
3668 window_char_width_to_pixel_width (struct window *w, int char_width,
|
|
3669 int include_margins_p)
|
|
3670 {
|
|
3671 int avail_width;
|
|
3672 int pixel_width;
|
|
3673 int defheight, defwidth;
|
|
3674 Lisp_Object window;
|
|
3675
|
|
3676 XSETWINDOW (window, w);
|
|
3677
|
|
3678 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3679
|
|
3680 avail_width = char_width * defwidth;
|
|
3681 pixel_width = (avail_width +
|
|
3682 window_left_gutter_width (w, 0) +
|
|
3683 window_right_gutter_width (w, 0) +
|
|
3684 (include_margins_p ? 0 : window_left_margin_width (w)) +
|
|
3685 (include_margins_p ? 0 : window_right_margin_width (w)));
|
|
3686
|
|
3687 /* It's the calling function's responsibility to check these values
|
|
3688 and make sure they're not out of range.
|
|
3689
|
|
3690 #### We need to go through the calling functions and actually
|
|
3691 do this. */
|
272
|
3692 return max (0, pixel_width);
|
0
|
3693 }
|
|
3694
|
|
3695 /* This returns the usable space which doesn't include space needed by
|
|
3696 scrollbars or divider lines. */
|
|
3697 int
|
|
3698 window_char_width (struct window *w, int include_margins_p)
|
|
3699 {
|
|
3700 return window_pixel_width_to_char_width (w, WINDOW_WIDTH (w),
|
|
3701 include_margins_p);
|
|
3702 }
|
|
3703
|
|
3704 #define MINSIZE(w) \
|
|
3705 (widthflag \
|
|
3706 ? window_min_width * defwidth \
|
|
3707 : (defheight * (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height)))
|
|
3708
|
|
3709 #define CURBEG(w) \
|
|
3710 *(widthflag ? (int *) &WINDOW_LEFT (w) : (int *) &WINDOW_TOP (w))
|
|
3711
|
|
3712 #define CURSIZE(w) \
|
|
3713 *(widthflag ? (int *) &WINDOW_WIDTH (w) : (int *) &WINDOW_HEIGHT (w))
|
|
3714
|
|
3715 #define CURCHARSIZE(w) \
|
|
3716 (widthflag ? window_char_width (w, 0) : window_char_height (w, 1))
|
|
3717
|
|
3718 #define MINCHARSIZE(window) \
|
|
3719 (widthflag ? window_min_width : MINI_WINDOW_P (XWINDOW (window)) \
|
|
3720 ? 1 : window_min_height)
|
|
3721
|
|
3722 /* Unlike set_window_pixheight, this function
|
|
3723 also changes the heights of the siblings so as to
|
|
3724 keep everything consistent. */
|
|
3725
|
|
3726 static void
|
263
|
3727 change_window_height (struct window *win, int delta, int widthflag,
|
|
3728 int inpixels)
|
0
|
3729 {
|
|
3730 Lisp_Object parent;
|
272
|
3731 Lisp_Object window;
|
0
|
3732 struct window *w;
|
|
3733 struct frame *f;
|
|
3734 int *sizep;
|
|
3735 int (*sizefun) (Lisp_Object) = (widthflag
|
|
3736 ? window_pixel_width
|
|
3737 : window_pixel_height);
|
|
3738 void (*setsizefun) (Lisp_Object, int, int) = (widthflag
|
|
3739 ? set_window_pixwidth
|
|
3740 : set_window_pixheight);
|
|
3741 int dim;
|
|
3742 int defheight, defwidth;
|
|
3743
|
|
3744 if (delta == 0)
|
|
3745 return;
|
|
3746
|
|
3747 check_min_window_sizes ();
|
|
3748
|
|
3749 XSETWINDOW (window, win);
|
|
3750 f = XFRAME (win->frame);
|
|
3751 if (EQ (window, FRAME_ROOT_WINDOW (f)))
|
|
3752 error ("Won't change only window");
|
|
3753
|
|
3754 /* #### This is very likely incorrect and instead the char_to_pixel_
|
|
3755 functions should be called. */
|
|
3756 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3757
|
|
3758 while (1)
|
|
3759 {
|
|
3760 w = XWINDOW (window);
|
|
3761 parent = w->parent;
|
|
3762 if (NILP (parent))
|
|
3763 {
|
|
3764 if (widthflag)
|
|
3765 error ("No other window to side of this one");
|
|
3766 break;
|
|
3767 }
|
|
3768 if (widthflag
|
|
3769 ? !NILP (XWINDOW (parent)->hchild)
|
|
3770 : !NILP (XWINDOW (parent)->vchild))
|
|
3771 break;
|
|
3772 window = parent;
|
|
3773 }
|
|
3774
|
|
3775 sizep = &CURSIZE (w);
|
|
3776 dim = CURCHARSIZE (w);
|
|
3777
|
263
|
3778 if ((inpixels && (*sizep + delta) < MINSIZE (window)) ||
|
|
3779 (!inpixels && (dim + delta) < MINCHARSIZE (window)))
|
0
|
3780 {
|
|
3781 if (MINI_WINDOW_P (XWINDOW (window)))
|
|
3782 return;
|
|
3783 else if (!NILP (parent))
|
|
3784 {
|
|
3785 Fdelete_window (window, Qnil);
|
|
3786 return;
|
|
3787 }
|
|
3788 }
|
|
3789
|
263
|
3790 if (!inpixels)
|
|
3791 delta *= (widthflag ? defwidth : defheight);
|
0
|
3792
|
|
3793 {
|
|
3794 int maxdelta;
|
|
3795
|
|
3796 maxdelta = ((!NILP (parent))
|
|
3797 ? (*sizefun) (parent) - *sizep
|
|
3798 : ((!NILP (w->next))
|
|
3799 ? (*sizefun) (w->next) - MINSIZE (w->next)
|
|
3800 : ((!NILP (w->prev))
|
|
3801 ? (*sizefun) (w->prev) - MINSIZE (w->prev)
|
185
|
3802 /* This is a frame with only one window,
|
0
|
3803 a minibuffer-only or a minibufferless frame. */
|
|
3804 : (delta = 0))));
|
|
3805
|
|
3806 if (delta > maxdelta)
|
|
3807 /* This case traps trying to make the minibuffer
|
|
3808 the full frame, or make the only window aside from the
|
|
3809 minibuffer the full frame. */
|
|
3810 delta = maxdelta;
|
|
3811
|
|
3812 if (delta == 0)
|
|
3813 return;
|
|
3814
|
|
3815 #if 0 /* FSFmacs */
|
|
3816 /* #### Chuck: is this correct? */
|
|
3817 if (*sizep + delta < MINSIZE (window))
|
|
3818 {
|
|
3819 Fdelete_window (window);
|
|
3820 return;
|
|
3821 }
|
|
3822 #endif
|
|
3823 }
|
|
3824
|
|
3825 if (!NILP (w->next) &&
|
|
3826 (*sizefun) (w->next) - delta >= (int) MINSIZE (w->next))
|
|
3827 {
|
|
3828 CURBEG (XWINDOW (w->next)) += delta;
|
|
3829 (*setsizefun) (w->next, (*sizefun) (w->next) - delta, 0);
|
|
3830 (*setsizefun) (window, *sizep + delta, 0);
|
|
3831 }
|
|
3832 else if (!NILP (w->prev) &&
|
|
3833 (*sizefun) (w->prev) - delta >= (int) MINSIZE (w->prev))
|
|
3834 {
|
|
3835 (*setsizefun) (w->prev, (*sizefun) (w->prev) - delta, 0);
|
|
3836 CURBEG (w) -= delta;
|
|
3837 (*setsizefun) (window, *sizep + delta, 0);
|
|
3838 }
|
|
3839 else
|
|
3840 {
|
|
3841 int delta1;
|
|
3842 int opht = (*sizefun) (parent);
|
|
3843
|
|
3844 /* If trying to grow this window to or beyond size of the parent,
|
|
3845 make delta1 so big that, on shrinking back down,
|
|
3846 all the siblings end up with less than one line and are deleted. */
|
|
3847 if (opht <= *sizep + delta)
|
|
3848 delta1 = opht * opht * 2;
|
|
3849 /* Otherwise, make delta1 just right so that if we add delta1
|
|
3850 lines to this window and to the parent, and then shrink
|
|
3851 the parent back to its original size, the new proportional
|
|
3852 size of this window will increase by delta. */
|
|
3853 else
|
|
3854 delta1 = (delta * opht * 100) / ((opht - *sizep - delta) * 100);
|
|
3855
|
|
3856 /* Add delta1 lines or columns to this window, and to the parent,
|
|
3857 keeping things consistent while not affecting siblings. */
|
|
3858 CURSIZE (XWINDOW (parent)) = opht + delta1;
|
|
3859 (*setsizefun) (window, *sizep + delta1, 0);
|
|
3860
|
|
3861 /* Squeeze out delta1 lines or columns from our parent,
|
|
3862 shriking this window and siblings proportionately.
|
|
3863 This brings parent back to correct size.
|
|
3864 Delta1 was calculated so this makes this window the desired size,
|
|
3865 taking it all out of the siblings. */
|
|
3866 (*setsizefun) (parent, opht, 0);
|
|
3867 }
|
|
3868
|
|
3869 SET_LAST_MODIFIED (w, 0);
|
|
3870 SET_LAST_FACECHANGE (w);
|
|
3871 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
3872 }
|
|
3873 #undef MINSIZE
|
|
3874 #undef CURBEG
|
|
3875 #undef CURSIZE
|
|
3876 #undef CURCHARSIZE
|
|
3877 #undef MINCHARSIZE
|
|
3878
|
|
3879
|
|
3880
|
|
3881 /* Scroll contents of window WINDOW up N lines. */
|
|
3882 void
|
|
3883 window_scroll (Lisp_Object window, Lisp_Object n, int direction,
|
|
3884 Error_behavior errb)
|
|
3885 {
|
|
3886 struct window *w = XWINDOW (window);
|
|
3887 struct buffer *b = XBUFFER (w->buffer);
|
|
3888 int selected = EQ (window, Fselected_window (Qnil));
|
|
3889 int value = 0;
|
|
3890 Lisp_Object point, tem;
|
|
3891
|
|
3892 if (selected)
|
|
3893 point = make_int (BUF_PT (b));
|
|
3894 else
|
|
3895 {
|
|
3896 Bufpos pos = marker_position (w->pointm[CURRENT_DISP]);
|
|
3897
|
|
3898 if (pos < BUF_BEGV (b))
|
|
3899 pos = BUF_BEGV (b);
|
|
3900 else if (pos > BUF_ZV (b))
|
|
3901 pos = BUF_ZV (b);
|
|
3902
|
|
3903 point = make_int (pos);
|
|
3904 }
|
|
3905
|
|
3906 /* Always set force_start so that redisplay_window will run
|
|
3907 thw window-scroll-functions. */
|
|
3908 w->force_start = 1;
|
|
3909
|
|
3910 /* #### When the fuck does this happen? I'm so glad that history has
|
|
3911 completely documented the behavior of the scrolling functions under
|
|
3912 all circumstances. */
|
|
3913 tem = Fpos_visible_in_window_p (point, window);
|
|
3914 if (NILP (tem))
|
|
3915 {
|
|
3916 Fvertical_motion (make_int (-window_char_height (w, 0) / 2), window);
|
|
3917 Fset_marker (w->start[CURRENT_DISP], point, w->buffer);
|
|
3918 w->start_at_line_beg = beginning_of_line_p (b, XINT (point));
|
|
3919 MARK_WINDOWS_CHANGED (w);
|
|
3920 }
|
|
3921
|
|
3922 if (!NILP (n))
|
|
3923 {
|
|
3924 if (EQ (n, Qminus))
|
|
3925 direction *= -1;
|
|
3926 else
|
|
3927 {
|
|
3928 n = Fprefix_numeric_value (n);
|
|
3929 value = XINT (n) * direction;
|
|
3930
|
|
3931 if (!value)
|
|
3932 return; /* someone just made a pointless call */
|
|
3933 }
|
|
3934 }
|
|
3935
|
|
3936 /* If the user didn't specify how far to scroll then we have to figure it
|
|
3937 out by ourselves. */
|
|
3938 if (NILP (n) || EQ (n, Qminus))
|
|
3939 {
|
|
3940 /* Going forwards is easy. If that is what we are doing then just
|
|
3941 set value and the section which handles the user specifying a
|
|
3942 positive value will work. */
|
|
3943 if (direction == 1)
|
|
3944 {
|
|
3945 value = window_displayed_height (w) - next_screen_context_lines;
|
|
3946 value = (value < 1 ? 1 : value);
|
|
3947 }
|
|
3948
|
|
3949 /* Going backwards is hard. We can't use the same loop used if the
|
|
3950 user specified a negative value because we care about
|
|
3951 next_screen_context_lines. In a variable height world you don't
|
|
3952 know how many lines above you can actually be displayed and still
|
|
3953 have the context lines appear. So we leave value set to 0 and add
|
|
3954 a separate section to deal with this. */
|
|
3955
|
|
3956 }
|
|
3957
|
|
3958 if (direction == 1 && !value)
|
|
3959 {
|
|
3960 return;
|
|
3961 }
|
|
3962 else if (value > 0)
|
|
3963 {
|
|
3964 int vtarget;
|
|
3965 Bufpos startp, old_start;
|
|
3966
|
|
3967 old_start = marker_position (w->start[CURRENT_DISP]);
|
|
3968 startp = vmotion (w, old_start, value, &vtarget);
|
|
3969
|
|
3970 if (vtarget < value &&
|
|
3971 (w->window_end_pos[CURRENT_DISP] == -1
|
|
3972 || (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b))))
|
|
3973 {
|
|
3974 maybe_signal_error (Qend_of_buffer, Qnil, Qwindow, errb);
|
|
3975 return;
|
|
3976 }
|
|
3977 else
|
|
3978 {
|
|
3979 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
|
|
3980 w->buffer);
|
|
3981 w->force_start = 1;
|
|
3982 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
3983 MARK_WINDOWS_CHANGED (w);
|
|
3984
|
|
3985 if (!point_would_be_visible (w, startp, XINT (point)))
|
|
3986 {
|
|
3987 if (selected)
|
|
3988 BUF_SET_PT (b, startp);
|
|
3989 else
|
|
3990 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
3991 make_int (startp),
|
|
3992 w->buffer);
|
|
3993 }
|
|
3994 }
|
|
3995 }
|
|
3996 else if (value < 0)
|
|
3997 {
|
|
3998 int vtarget;
|
|
3999 Bufpos startp, old_start;
|
|
4000
|
|
4001 old_start = marker_position (w->start[CURRENT_DISP]);
|
|
4002 startp = vmotion (w, old_start, value, &vtarget);
|
|
4003
|
|
4004 if (vtarget > value
|
|
4005 && marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
|
|
4006 {
|
|
4007 maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
|
|
4008 return;
|
|
4009 }
|
|
4010 else
|
|
4011 {
|
|
4012 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
|
|
4013 w->buffer);
|
|
4014 w->force_start = 1;
|
|
4015 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
4016 MARK_WINDOWS_CHANGED (w);
|
|
4017
|
|
4018 if (!point_would_be_visible (w, startp, XINT (point)))
|
|
4019 {
|
|
4020 Bufpos new_point;
|
|
4021
|
|
4022 if (MINI_WINDOW_P (w))
|
|
4023 new_point = startp;
|
|
4024 else
|
|
4025 new_point = start_of_last_line (w, startp);
|
|
4026
|
|
4027 if (selected)
|
|
4028 BUF_SET_PT (b, new_point);
|
|
4029 else
|
|
4030 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
4031 make_int (new_point),
|
|
4032 w->buffer);
|
|
4033 }
|
|
4034 }
|
|
4035 }
|
|
4036 else /* value == 0 && direction == -1 */
|
|
4037 {
|
|
4038 if (marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
|
|
4039 {
|
|
4040 maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
|
|
4041 return;
|
|
4042 }
|
|
4043 else
|
|
4044 {
|
|
4045 int vtarget;
|
|
4046 int movement = next_screen_context_lines - 1;
|
|
4047 Bufpos old_startp = marker_position (w->start[CURRENT_DISP]);
|
|
4048 Bufpos bottom = vmotion (w, old_startp, movement, &vtarget);
|
|
4049 Bufpos startp =
|
|
4050 start_with_point_on_display_line (w, bottom,
|
|
4051 -1 - (movement - vtarget));
|
|
4052
|
|
4053 if (startp >= old_startp)
|
|
4054 startp = vmotion (w, old_startp, -1, NULL);
|
|
4055
|
|
4056 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
|
|
4057 w->buffer);
|
|
4058 w->force_start = 1;
|
|
4059 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
4060 MARK_WINDOWS_CHANGED (w);
|
|
4061
|
|
4062 if (!point_would_be_visible (w, startp, XINT (point)))
|
|
4063 {
|
|
4064 Bufpos new_point = start_of_last_line (w, startp);
|
|
4065
|
|
4066 if (selected)
|
|
4067 BUF_SET_PT (b, new_point);
|
|
4068 else
|
|
4069 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
4070 make_int (new_point),
|
|
4071 w->buffer);
|
|
4072 }
|
|
4073 }
|
|
4074 }
|
|
4075
|
|
4076 }
|
|
4077
|
20
|
4078 DEFUN ("scroll-up", Fscroll_up, 0, 1, "_P", /*
|
0
|
4079 Scroll text of current window upward ARG lines; or near full screen if no ARG.
|
|
4080 A near full screen is `next-screen-context-lines' less than a full screen.
|
|
4081 Negative ARG means scroll downward.
|
|
4082 When calling from a program, supply a number as argument or nil.
|
265
|
4083 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
|
|
4084 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
|
|
4085 signaled.
|
20
|
4086 */
|
|
4087 (n))
|
0
|
4088 {
|
265
|
4089 window_scroll (Fselected_window (Qnil), n, 1, ERROR_ME);
|
0
|
4090 return Qnil;
|
|
4091 }
|
|
4092
|
20
|
4093 DEFUN ("scroll-down", Fscroll_down, 0, 1, "_P", /*
|
0
|
4094 Scroll text of current window downward ARG lines; or near full screen if no ARG.
|
|
4095 A near full screen is `next-screen-context-lines' less than a full screen.
|
|
4096 Negative ARG means scroll upward.
|
|
4097 When calling from a program, supply a number as argument or nil.
|
265
|
4098 On attempt to scroll past end of buffer, `end-of-buffer' is signaled.
|
|
4099 On attempt to scroll past beginning of buffer, `beginning-of-buffer' is
|
|
4100 signaled.
|
20
|
4101 */
|
|
4102 (n))
|
0
|
4103 {
|
265
|
4104 window_scroll (Fselected_window (Qnil), n, -1, ERROR_ME);
|
0
|
4105 return Qnil;
|
|
4106 }
|
|
4107
|
20
|
4108 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling, 0, 0, 0, /*
|
185
|
4109 Return the other window for "other window scroll" commands.
|
0
|
4110 If in the minibuffer, `minibuffer-scroll-window' if non-nil
|
|
4111 specifies the window.
|
|
4112 If `other-window-scroll-buffer' is non-nil, a window
|
|
4113 showing that buffer is used.
|
20
|
4114 */
|
|
4115 ())
|
0
|
4116 {
|
|
4117 Lisp_Object window;
|
|
4118 Lisp_Object selected_window = Fselected_window (Qnil);
|
|
4119
|
|
4120 if (MINI_WINDOW_P (XWINDOW (selected_window))
|
274
|
4121 && !NILP (Vminibuffer_scroll_window))
|
|
4122 window = Vminibuffer_scroll_window;
|
0
|
4123 /* If buffer is specified, scroll that buffer. */
|
|
4124 else if (!NILP (Vother_window_scroll_buffer))
|
|
4125 {
|
|
4126 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil, Qnil);
|
|
4127 if (NILP (window))
|
|
4128 window = display_buffer (Vother_window_scroll_buffer, Qt, Qnil);
|
|
4129 }
|
|
4130 else
|
|
4131 {
|
|
4132 /* Nothing specified; look for a neighboring window on the same
|
|
4133 frame. */
|
|
4134 window = Fnext_window (selected_window, Qnil, Qnil, Qnil);
|
|
4135
|
|
4136 if (EQ (window, selected_window))
|
|
4137 /* That didn't get us anywhere; look for a window on another
|
|
4138 visible frame. */
|
|
4139 do
|
|
4140 window = Fnext_window (window, Qnil, Qt, Qnil);
|
|
4141 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window))))
|
|
4142 && ! EQ (window, selected_window));
|
|
4143 }
|
|
4144
|
|
4145 CHECK_LIVE_WINDOW (window);
|
|
4146
|
|
4147 if (EQ (window, selected_window))
|
|
4148 error ("There is no other window");
|
|
4149
|
|
4150 return window;
|
|
4151 }
|
|
4152
|
20
|
4153 DEFUN ("scroll-other-window", Fscroll_other_window, 0, 1, "_P", /*
|
0
|
4154 Scroll next window upward ARG lines; or near full frame if no ARG.
|
|
4155 The next window is the one below the current one; or the one at the top
|
|
4156 if the current one is at the bottom. Negative ARG means scroll downward.
|
|
4157 When calling from a program, supply a number as argument or nil.
|
|
4158
|
274
|
4159 If in the minibuffer, `minibuffer-scroll-window' if non-nil
|
0
|
4160 specifies the window to scroll.
|
|
4161 If `other-window-scroll-buffer' is non-nil, scroll the window
|
|
4162 showing that buffer, popping the buffer up if necessary.
|
20
|
4163 */
|
|
4164 (n))
|
0
|
4165 {
|
|
4166 window_scroll (Fother_window_for_scrolling (), n, 1, ERROR_ME);
|
|
4167 return Qnil;
|
|
4168 }
|
|
4169
|
20
|
4170 DEFUN ("scroll-left", Fscroll_left, 0, 1, "_P", /*
|
0
|
4171 Scroll selected window display ARG columns left.
|
|
4172 Default for ARG is window width minus 2.
|
20
|
4173 */
|
|
4174 (arg))
|
0
|
4175 {
|
|
4176 Lisp_Object window = Fselected_window (Qnil);
|
|
4177 struct window *w = XWINDOW (window);
|
|
4178
|
|
4179 if (NILP (arg))
|
|
4180 arg = make_int (window_char_width (w, 0) - 2);
|
|
4181 else
|
|
4182 arg = Fprefix_numeric_value (arg);
|
|
4183
|
149
|
4184 return Fset_window_hscroll (window, make_int (w->hscroll + XINT (arg)));
|
0
|
4185 }
|
|
4186
|
20
|
4187 DEFUN ("scroll-right", Fscroll_right, 0, 1, "_P", /*
|
0
|
4188 Scroll selected window display ARG columns right.
|
|
4189 Default for ARG is window width minus 2.
|
20
|
4190 */
|
|
4191 (arg))
|
0
|
4192 {
|
|
4193 Lisp_Object window = Fselected_window (Qnil);
|
|
4194 struct window *w = XWINDOW (window);
|
|
4195
|
|
4196 if (NILP (arg))
|
|
4197 arg = make_int (window_char_width (w, 0) - 2);
|
|
4198 else
|
|
4199 arg = Fprefix_numeric_value (arg);
|
|
4200
|
149
|
4201 return Fset_window_hscroll (window, make_int (w->hscroll - XINT (arg)));
|
0
|
4202 }
|
280
|
4203
|
|
4204 DEFUN ("center-to-window-line", Fcenter_to_window_line, 0, 2, "_P", /*
|
|
4205 Center point in WINDOW. With N, put point on line N.
|
0
|
4206 The desired position of point is always relative to the window.
|
|
4207 If WINDOW is nil, the selected window is used.
|
20
|
4208 */
|
|
4209 (n, window))
|
0
|
4210 {
|
280
|
4211 struct window *w = decode_window (window);
|
|
4212 struct buffer *b = XBUFFER (w->buffer);
|
|
4213 Bufpos opoint = BUF_PT (b);
|
0
|
4214 Bufpos startp;
|
280
|
4215
|
|
4216 if (NILP (n))
|
|
4217 startp = start_with_line_at_pixpos (w, opoint, window_half_pixpos (w));
|
0
|
4218 else
|
|
4219 {
|
|
4220 n = Fprefix_numeric_value (n);
|
|
4221 CHECK_INT (n);
|
|
4222 startp = start_with_point_on_display_line (w, opoint, XINT (n));
|
|
4223 }
|
|
4224
|
|
4225 Fset_marker (w->start[CURRENT_DISP], make_int (startp), w->buffer);
|
185
|
4226
|
0
|
4227 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
4228 w->force_start = 1;
|
|
4229 MARK_WINDOWS_CHANGED (w);
|
|
4230 return Qnil;
|
|
4231 }
|
280
|
4232
|
20
|
4233 DEFUN ("move-to-window-line", Fmove_to_window_line, 1, 2, "_P", /*
|
0
|
4234 Position point relative to WINDOW.
|
|
4235 With no argument, position text at center of window.
|
|
4236 An argument specifies window line; zero means top of window,
|
|
4237 negative means relative to bottom of window.
|
|
4238 If WINDOW is nil, the selected window is used.
|
20
|
4239 */
|
|
4240 (arg, window))
|
0
|
4241 {
|
|
4242 struct window *w;
|
|
4243 struct buffer *b;
|
|
4244 int height;
|
|
4245 Bufpos start, new_point;
|
|
4246 int selected;
|
|
4247
|
280
|
4248 /* Don't use decode_window() because we need the new value of
|
|
4249 WINDOW. */
|
0
|
4250 if (NILP (window))
|
|
4251 window = Fselected_window (Qnil);
|
|
4252 else
|
|
4253 CHECK_WINDOW (window);
|
|
4254 w = XWINDOW (window);
|
|
4255 b = XBUFFER (w->buffer);
|
|
4256
|
|
4257 height = window_displayed_height (w);
|
|
4258 selected = EQ (window, Fselected_window (w->frame));
|
|
4259
|
|
4260 if (NILP (arg))
|
|
4261 {
|
|
4262 int retval;
|
|
4263
|
|
4264 if (XINT (w->last_modified[CURRENT_DISP]) >= BUF_MODIFF (b)
|
|
4265 && XINT (w->last_facechange[CURRENT_DISP]) >= BUF_FACECHANGE (b))
|
|
4266 {
|
|
4267 new_point = point_at_center (w, CURRENT_DISP, 0, 0);
|
|
4268
|
|
4269 if (selected)
|
|
4270 BUF_SET_PT (b, new_point);
|
|
4271 else
|
|
4272 Fset_window_point (window, make_int (new_point));
|
|
4273
|
|
4274 retval = line_at_center (w, CURRENT_DISP, 0, 0);
|
|
4275 }
|
|
4276 else
|
|
4277 {
|
|
4278 start = marker_position (w->start[CURRENT_DISP]);
|
|
4279 if (start < BUF_BEGV (b))
|
|
4280 start = BUF_BEGV (b);
|
|
4281 else if (start > BUF_ZV (b))
|
|
4282 start = BUF_ZV (b);
|
|
4283
|
|
4284 if (selected)
|
|
4285 new_point = BUF_PT (b);
|
|
4286 else
|
|
4287 new_point = marker_position (w->pointm[CURRENT_DISP]);
|
|
4288
|
|
4289 new_point = point_at_center (w, CMOTION_DISP, start, BUF_PT (b));
|
|
4290
|
|
4291 if (selected)
|
|
4292 BUF_SET_PT (b, new_point);
|
|
4293 else
|
|
4294 Fset_window_point (window, make_int (new_point));
|
|
4295
|
|
4296 retval = line_at_center (w, CMOTION_DISP, start, BUF_PT (b));
|
|
4297 }
|
|
4298
|
149
|
4299 return make_int (retval);
|
0
|
4300 }
|
|
4301 else
|
|
4302 {
|
|
4303 /* #### Is this going to work right when at eob? */
|
|
4304 arg = Fprefix_numeric_value (arg);
|
|
4305 if (XINT (arg) < 0)
|
|
4306 XSETINT (arg, XINT (arg) + height);
|
|
4307 }
|
|
4308
|
|
4309 start = marker_position (w->start[CURRENT_DISP]);
|
|
4310 if (start < BUF_BEGV (b) || start > BUF_ZV (b))
|
|
4311 {
|
|
4312 if (selected)
|
|
4313 new_point = BUF_PT (b);
|
|
4314 else
|
|
4315 new_point = marker_position (w->pointm[CURRENT_DISP]);
|
|
4316
|
|
4317 new_point = vmotion (XWINDOW (window), new_point, -height / 2, 0);
|
|
4318
|
|
4319 if (selected)
|
|
4320 BUF_SET_PT (b, new_point);
|
|
4321 else
|
|
4322 Fset_window_point (window, make_int (new_point));
|
|
4323
|
|
4324 Fset_marker (w->start[CURRENT_DISP], make_int (new_point),
|
|
4325 w->buffer);
|
|
4326 w->start_at_line_beg = beginning_of_line_p (b, new_point);
|
|
4327 w->force_start = 1;
|
|
4328 }
|
|
4329 else
|
|
4330 {
|
|
4331 if (selected)
|
|
4332 BUF_SET_PT (b, start);
|
|
4333 else
|
|
4334 Fset_window_point (window, make_int (start));
|
|
4335 }
|
|
4336
|
|
4337 if (selected)
|
|
4338 return Fvertical_motion (arg, window);
|
|
4339 else
|
|
4340 {
|
|
4341 int vpos;
|
|
4342 new_point = vmotion (XWINDOW (window),
|
|
4343 marker_position (w->pointm[CURRENT_DISP]),
|
|
4344 XINT (arg), &vpos);
|
|
4345 Fset_window_point (window, make_int (new_point));
|
|
4346 return make_int (vpos);
|
|
4347 }
|
|
4348 }
|
|
4349
|
|
4350
|
|
4351 static int
|
|
4352 map_windows_1 (Lisp_Object window,
|
|
4353 int (*mapfun) (struct window *w, void *closure),
|
|
4354 void *closure)
|
|
4355 {
|
|
4356 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
4357 {
|
272
|
4358 int retval;
|
0
|
4359 struct window *w = XWINDOW (window);
|
251
|
4360
|
0
|
4361 if (!NILP (w->vchild))
|
|
4362 retval = map_windows_1 (w->vchild, mapfun, closure);
|
|
4363 else if (!NILP (w->hchild))
|
|
4364 retval = map_windows_1 (w->hchild, mapfun, closure);
|
|
4365 else
|
|
4366 retval = (mapfun) (w, closure);
|
272
|
4367
|
0
|
4368 if (retval)
|
|
4369 return retval;
|
|
4370 }
|
|
4371
|
272
|
4372 return 0;
|
0
|
4373 }
|
|
4374
|
|
4375 /* Map MAPFUN over the windows in F. CLOSURE is passed to each
|
251
|
4376 invocation of MAPFUN. If any invocation of MAPFUN returns
|
|
4377 non-zero, the mapping is halted. Otherwise, map_windows() maps
|
|
4378 over all windows in F.
|
|
4379
|
|
4380 If MAPFUN create or delete windows, the behaviour is undefined. */
|
|
4381
|
|
4382 void
|
0
|
4383 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure),
|
|
4384 void *closure)
|
|
4385 {
|
251
|
4386 if (f)
|
|
4387 map_windows_1 (FRAME_ROOT_WINDOW (f), mapfun, closure);
|
|
4388 else
|
|
4389 {
|
|
4390 Lisp_Object frmcons, devcons, concons;
|
|
4391
|
|
4392 FRAME_LOOP_NO_BREAK(frmcons, devcons, concons)
|
|
4393 {
|
|
4394 if (map_windows_1 (FRAME_ROOT_WINDOW (XFRAME (XCAR (frmcons))),
|
|
4395 mapfun, closure))
|
|
4396 return;
|
|
4397 }
|
|
4398 }
|
0
|
4399 }
|
|
4400
|
|
4401
|
|
4402 static void
|
|
4403 modeline_shadow_thickness_changed (Lisp_Object specifier, struct window *w,
|
|
4404 Lisp_Object oldval)
|
|
4405 {
|
|
4406 w->shadow_thickness_changed = 1;
|
|
4407 MARK_WINDOWS_CHANGED (w);
|
|
4408 }
|
|
4409
|
|
4410 /* also used in scrollbar.c */
|
|
4411 void
|
|
4412 some_window_value_changed (Lisp_Object specifier, struct window *w,
|
|
4413 Lisp_Object oldval)
|
|
4414 {
|
|
4415 MARK_WINDOWS_CHANGED (w);
|
|
4416 }
|
|
4417
|
|
4418 #ifdef MEMORY_USAGE_STATS
|
|
4419
|
|
4420 struct window_stats
|
|
4421 {
|
|
4422 int face;
|
|
4423 int glyph;
|
|
4424 #ifdef HAVE_SCROLLBARS
|
|
4425 int scrollbar;
|
|
4426 #endif
|
|
4427 int line_start;
|
|
4428 int other_redisplay;
|
|
4429 int other;
|
|
4430 };
|
|
4431
|
|
4432 static void
|
|
4433 compute_window_mirror_usage (struct window_mirror *mir,
|
|
4434 struct window_stats *stats,
|
|
4435 struct overhead_stats *ovstats)
|
|
4436 {
|
|
4437 if (!mir)
|
|
4438 return;
|
|
4439 stats->other += malloced_storage_size (mir, sizeof (struct window_mirror),
|
|
4440 ovstats);
|
|
4441 #ifdef HAVE_SCROLLBARS
|
|
4442 {
|
|
4443 struct device *d = XDEVICE (FRAME_DEVICE (mir->frame));
|
|
4444
|
|
4445 stats->scrollbar +=
|
|
4446 compute_scrollbar_instance_usage (d, mir->scrollbar_vertical_instance,
|
|
4447 ovstats);
|
|
4448 stats->scrollbar +=
|
|
4449 compute_scrollbar_instance_usage (d, mir->scrollbar_horizontal_instance,
|
|
4450 ovstats);
|
|
4451 }
|
149
|
4452 #endif /* HAVE_SCROLLBARS */
|
0
|
4453 stats->other_redisplay +=
|
|
4454 compute_display_line_dynarr_usage (mir->current_display_lines, ovstats);
|
|
4455 stats->other_redisplay +=
|
|
4456 compute_display_line_dynarr_usage (mir->desired_display_lines, ovstats);
|
|
4457 }
|
|
4458
|
|
4459 static void
|
|
4460 compute_window_usage (struct window *w, struct window_stats *stats,
|
|
4461 struct overhead_stats *ovstats)
|
|
4462 {
|
272
|
4463 xzero (*stats);
|
0
|
4464 stats->other += malloced_storage_size (w, sizeof (struct window), ovstats);
|
|
4465 stats->face += compute_face_cachel_usage (w->face_cachels, ovstats);
|
|
4466 stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ovstats);
|
|
4467 stats->line_start +=
|
|
4468 compute_line_start_cache_dynarr_usage (w->line_start_cache, ovstats);
|
|
4469 compute_window_mirror_usage (find_window_mirror (w), stats, ovstats);
|
|
4470 }
|
|
4471
|
20
|
4472 DEFUN ("window-memory-usage", Fwindow_memory_usage, 1, 1, 0, /*
|
0
|
4473 Return stats about the memory usage of window WINDOW.
|
272
|
4474 The values returned are in the form of an alist of usage types and byte
|
0
|
4475 counts. The byte counts attempt to encompass all the memory used
|
|
4476 by the window (separate from the memory logically associated with a
|
|
4477 buffer or frame), including internal structures and any malloc()
|
|
4478 overhead associated with them. In practice, the byte counts are
|
|
4479 underestimated because certain memory usage is very hard to determine
|
272
|
4480 \(e.g. the amount of memory used inside the Xt library or inside the
|
0
|
4481 X server) and because there is other stuff that might logically
|
|
4482 be associated with a window, buffer, or frame (e.g. window configurations,
|
|
4483 glyphs) but should not obviously be included in the usage counts.
|
|
4484
|
|
4485 Multiple slices of the total memory usage may be returned, separated
|
|
4486 by a nil. Each slice represents a particular view of the memory, a
|
|
4487 particular way of partitioning it into groups. Within a slice, there
|
|
4488 is no overlap between the groups of memory, and each slice collectively
|
|
4489 represents all the memory concerned.
|
20
|
4490 */
|
|
4491 (window))
|
0
|
4492 {
|
|
4493 struct window_stats stats;
|
|
4494 struct overhead_stats ovstats;
|
272
|
4495 Lisp_Object val = Qnil;
|
0
|
4496
|
|
4497 CHECK_WINDOW (window); /* dead windows should be allowed, no? */
|
272
|
4498 xzero (ovstats);
|
0
|
4499 compute_window_usage (XWINDOW (window), &stats, &ovstats);
|
|
4500
|
272
|
4501 val = acons (Qface_cache, make_int (stats.face), val);
|
|
4502 val = acons (Qglyph_cache, make_int (stats.glyph), val);
|
0
|
4503 #ifdef HAVE_SCROLLBARS
|
272
|
4504 val = acons (Qscrollbar_instances, make_int (stats.scrollbar), val);
|
0
|
4505 #endif
|
272
|
4506 val = acons (Qline_start_cache, make_int (stats.line_start), val);
|
|
4507 val = acons (Qother_redisplay, make_int (stats.other_redisplay), val);
|
|
4508 val = acons (Qother, make_int (stats.other), val);
|
|
4509 val = Fcons (Qnil, val);
|
|
4510 val = acons (Qactually_requested, make_int (ovstats.was_requested), val);
|
|
4511 val = acons (Qmalloc_overhead, make_int (ovstats.malloc_overhead), val);
|
|
4512 val = acons (Qdynarr_overhead, make_int (ovstats.dynarr_overhead), val);
|
|
4513
|
|
4514 return Fnreverse (val);
|
0
|
4515 }
|
|
4516
|
|
4517 #endif /* MEMORY_USAGE_STATS */
|
|
4518
|
|
4519
|
|
4520 /************************************************************************/
|
|
4521 /* Window configurations */
|
|
4522 /************************************************************************/
|
|
4523
|
|
4524 /* #### This window configuration stuff has had serious bugs lurking in it
|
|
4525 for years; it would be a -huge- win if this was reimplemented in lisp.
|
|
4526 */
|
|
4527
|
|
4528 /* If you add anything to this structure make sure saved_window_equal
|
|
4529 knows about it. */
|
|
4530 struct saved_window
|
|
4531 {
|
|
4532 Lisp_Object window; /* window */
|
|
4533 Lisp_Object buffer; /* buffer */
|
|
4534 Lisp_Object start; /* copied marker */
|
|
4535 Lisp_Object pointm; /* copied marker */
|
|
4536 Lisp_Object sb_point; /* copied marker */
|
|
4537 Lisp_Object mark; /* copied marker */
|
|
4538 int pixel_left;
|
|
4539 int pixel_top;
|
|
4540 int pixel_width;
|
|
4541 int pixel_height;
|
|
4542 int hscroll;
|
257
|
4543 int modeline_hscroll;
|
0
|
4544 int parent_index; /* index into saved_windows */
|
|
4545 int prev_index; /* index into saved_windows */
|
|
4546 Lisp_Object dedicated;
|
|
4547 char start_at_line_beg; /* boolean */
|
255
|
4548 Lisp_Object display_table;
|
|
4549 Lisp_Object modeline_shadow_thickness;
|
|
4550 Lisp_Object has_modeline_p;
|
|
4551 #ifdef HAVE_SCROLLBARS
|
|
4552 Lisp_Object scrollbar_width;
|
|
4553 Lisp_Object scrollbar_height;
|
282
|
4554 Lisp_Object horizontal_scrollbar_visible_p;
|
|
4555 Lisp_Object vertical_scrollbar_visible_p;
|
|
4556 Lisp_Object scrollbar_on_left_p;
|
|
4557 Lisp_Object scrollbar_on_top_p;
|
255
|
4558 Lisp_Object scrollbar_pointer;
|
|
4559 #endif /* HAVE_SCROLLBARS */
|
|
4560 #ifdef HAVE_TOOLBARS
|
|
4561 Lisp_Object toolbar[4];
|
|
4562 Lisp_Object toolbar_size[4];
|
|
4563 Lisp_Object toolbar_border_width[4];
|
|
4564 Lisp_Object toolbar_visible_p[4];
|
|
4565 Lisp_Object toolbar_buttons_captioned_p;
|
|
4566 Lisp_Object default_toolbar;
|
|
4567 Lisp_Object default_toolbar_width, default_toolbar_height;
|
|
4568 Lisp_Object default_toolbar_visible_p;
|
|
4569 Lisp_Object default_toolbar_border_width;
|
|
4570 #endif /* HAVE_TOOLBARS */
|
|
4571 Lisp_Object left_margin_width, right_margin_width;
|
|
4572 Lisp_Object minimum_line_ascent, minimum_line_descent;
|
|
4573 Lisp_Object use_left_overflow, use_right_overflow;
|
|
4574 #ifdef HAVE_MENUBARS
|
|
4575 Lisp_Object menubar_visible_p;
|
|
4576 #endif /* HAVE_MENUBARS */
|
|
4577 Lisp_Object text_cursor_visible_p;
|
0
|
4578 };
|
|
4579
|
|
4580 /* If you add anything to this structure make sure window_config_equal
|
|
4581 knows about it. */
|
|
4582 struct window_config
|
|
4583 {
|
|
4584 struct lcrecord_header header;
|
|
4585 int frame_width;
|
|
4586 int frame_height;
|
|
4587 #if 0 /* FSFmacs */
|
|
4588 Lisp_Object selected_frame;
|
|
4589 #endif
|
|
4590 Lisp_Object current_window;
|
|
4591 Lisp_Object current_buffer;
|
274
|
4592 Lisp_Object minibuffer_scroll_window;
|
0
|
4593 Lisp_Object root_window;
|
|
4594 /* Record the values of window-min-width and window-min-height
|
|
4595 so that window sizes remain consistent with them. */
|
|
4596 int min_width, min_height;
|
|
4597 int saved_windows_count;
|
|
4598 /* Zero-sized arrays aren't ANSI C */
|
|
4599 struct saved_window saved_windows[1];
|
|
4600 };
|
272
|
4601
|
0
|
4602 #define SAVED_WINDOW_N(conf, n) (&((conf)->saved_windows[(n)]))
|
|
4603 #define XWINDOW_CONFIGURATION(x) XRECORD (x, window_configuration, struct window_config)
|
|
4604 #define XSETWINDOW_CONFIGURATION(x, p) XSETRECORD (x, p, window_configuration)
|
|
4605 #define WINDOW_CONFIGURATIONP(x) RECORDP (x, window_configuration)
|
|
4606 #define GC_WINDOW_CONFIGURATIONP(x) GC_RECORDP (x, window_configuration)
|
|
4607 #define CHECK_WINDOW_CONFIGURATION(x) CHECK_RECORD (x, window_configuration)
|
|
4608
|
|
4609 static Lisp_Object
|
|
4610 mark_window_config (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
4611 {
|
|
4612 struct window_config *config = XWINDOW_CONFIGURATION (obj);
|
|
4613 int i;
|
|
4614 ((markobj) (config->current_window));
|
|
4615 ((markobj) (config->current_buffer));
|
274
|
4616 ((markobj) (config->minibuffer_scroll_window));
|
0
|
4617 ((markobj) (config->root_window));
|
217
|
4618
|
0
|
4619 for (i = 0; i < config->saved_windows_count; i++)
|
|
4620 {
|
|
4621 struct saved_window *s = SAVED_WINDOW_N (config, i);
|
|
4622 ((markobj) (s->window));
|
|
4623 ((markobj) (s->buffer));
|
|
4624 ((markobj) (s->start));
|
|
4625 ((markobj) (s->pointm));
|
|
4626 ((markobj) (s->sb_point));
|
|
4627 ((markobj) (s->mark));
|
|
4628 ((markobj) (s->dedicated));
|
|
4629 }
|
149
|
4630 return Qnil;
|
0
|
4631 }
|
|
4632
|
272
|
4633 static size_t
|
0
|
4634 sizeof_window_config_for_n_windows (int n)
|
|
4635 {
|
|
4636 return (sizeof (struct window_config) +
|
|
4637 /* n - 1 because zero-sized arrays aren't ANSI C */
|
|
4638 (n - 1) *sizeof (struct saved_window));
|
|
4639 }
|
|
4640
|
272
|
4641 static size_t
|
0
|
4642 sizeof_window_config (CONST void *h)
|
|
4643 {
|
185
|
4644 CONST struct window_config *c = (CONST struct window_config *) h;
|
0
|
4645 return sizeof_window_config_for_n_windows (c->saved_windows_count);
|
|
4646 }
|
|
4647
|
|
4648 static void
|
|
4649 print_window_config (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
4650 {
|
|
4651 struct window_config *config = XWINDOW_CONFIGURATION (obj);
|
|
4652 char buf[200];
|
|
4653 if (print_readably)
|
|
4654 error ("printing unreadable object #<window-configuration 0x%x>",
|
|
4655 config->header.uid);
|
|
4656 write_c_string ("#<window-configuration ", printcharfun);
|
|
4657 sprintf (buf, "0x%x>", config->header.uid);
|
|
4658 write_c_string (buf, printcharfun);
|
|
4659 }
|
|
4660
|
272
|
4661 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("window-configuration",
|
|
4662 window_configuration,
|
|
4663 mark_window_config,
|
|
4664 print_window_config,
|
|
4665 0, 0, 0, sizeof_window_config,
|
|
4666 struct window_config);
|
|
4667
|
|
4668
|
0
|
4669 /* Returns a boolean indicating whether the two saved windows are
|
|
4670 identical. */
|
|
4671 static int
|
|
4672 saved_window_equal (struct saved_window *win1, struct saved_window *win2)
|
|
4673 {
|
149
|
4674 return
|
|
4675 EQ (win1->window, win2->window) &&
|
|
4676 EQ (win1->buffer, win2->buffer) &&
|
195
|
4677 internal_equal (win1->start, win2->start, 0) &&
|
|
4678 internal_equal (win1->pointm, win2->pointm, 0) &&
|
|
4679 internal_equal (win1->sb_point, win2->sb_point, 0) &&
|
|
4680 internal_equal (win1->mark, win2->mark, 0) &&
|
149
|
4681 win1->pixel_left == win2->pixel_left &&
|
|
4682 win1->pixel_top == win2->pixel_top &&
|
|
4683 win1->pixel_width == win2->pixel_width &&
|
|
4684 win1->pixel_height == win2->pixel_height &&
|
|
4685 win1->hscroll == win2->hscroll &&
|
257
|
4686 win1->modeline_hscroll == win2->modeline_hscroll &&
|
149
|
4687 win1->parent_index == win2->parent_index &&
|
|
4688 win1->prev_index == win2->prev_index &&
|
|
4689 EQ (win1->dedicated, win2->dedicated) &&
|
255
|
4690 win1->start_at_line_beg == win2->start_at_line_beg &&
|
|
4691 internal_equal(win1->display_table, win2->display_table, 0) &&
|
|
4692 EQ(win1->modeline_shadow_thickness, win2->modeline_shadow_thickness) &&
|
|
4693 EQ(win1->has_modeline_p, win2->has_modeline_p) &&
|
|
4694 #ifdef HAVE_SCROLLBARS
|
|
4695 EQ(win1->scrollbar_width, win2->scrollbar_width) &&
|
|
4696 EQ(win1->scrollbar_height, win2->scrollbar_height) &&
|
282
|
4697 EQ(win1->horizontal_scrollbar_visible_p, win2->horizontal_scrollbar_visible_p) &&
|
|
4698 EQ(win1->vertical_scrollbar_visible_p, win2->vertical_scrollbar_visible_p) &&
|
|
4699 EQ(win1->scrollbar_on_left_p, win2->scrollbar_on_left_p) &&
|
|
4700 EQ(win1->scrollbar_on_top_p, win2->scrollbar_on_top_p) &&
|
255
|
4701 EQ(win1->scrollbar_pointer, win2->scrollbar_pointer) &&
|
|
4702 #endif /* HAVE_SCROLLBARS */
|
|
4703 #ifdef HAVE_TOOLBARS
|
|
4704 internal_equal(win1->toolbar[0], win2->toolbar[0], 0) &&
|
|
4705 internal_equal(win1->toolbar[1], win2->toolbar[1], 0) &&
|
|
4706 internal_equal(win1->toolbar[2], win2->toolbar[2], 0) &&
|
|
4707 internal_equal(win1->toolbar[3], win2->toolbar[3], 0) &&
|
|
4708 internal_equal(win1->toolbar_border_width[0], win2->toolbar_border_width[0], 0) &&
|
|
4709 internal_equal(win1->toolbar_border_width[1], win2->toolbar_border_width[1], 0) &&
|
|
4710 internal_equal(win1->toolbar_border_width[2], win2->toolbar_border_width[2], 0) &&
|
|
4711 internal_equal(win1->toolbar_border_width[3], win2->toolbar_border_width[3], 0) &&
|
|
4712 internal_equal(win1->toolbar_size[0], win2->toolbar_size[0], 0) &&
|
|
4713 internal_equal(win1->toolbar_size[1], win2->toolbar_size[1], 0) &&
|
|
4714 internal_equal(win1->toolbar_size[2], win2->toolbar_size[2], 0) &&
|
|
4715 internal_equal(win1->toolbar_size[3], win2->toolbar_size[3], 0) &&
|
|
4716 internal_equal(win1->toolbar_visible_p[0], win2->toolbar_visible_p[0], 0) &&
|
|
4717 internal_equal(win1->toolbar_visible_p[1], win2->toolbar_visible_p[1], 0) &&
|
|
4718 internal_equal(win1->toolbar_visible_p[2], win2->toolbar_visible_p[2], 0) &&
|
|
4719 internal_equal(win1->toolbar_visible_p[3], win2->toolbar_visible_p[3], 0) &&
|
|
4720 EQ(win1->toolbar_buttons_captioned_p, win2->toolbar_buttons_captioned_p) &&
|
|
4721 internal_equal(win1->default_toolbar, win2->default_toolbar, 0) &&
|
|
4722 EQ(win1->default_toolbar_width, win2->default_toolbar_width) &&
|
|
4723 EQ(win1->default_toolbar_height, win2->default_toolbar_height) &&
|
|
4724 EQ(win1->default_toolbar_visible_p, win2->default_toolbar_visible_p) &&
|
|
4725 EQ(win1->default_toolbar_border_width, win2->default_toolbar_border_width) &&
|
|
4726 #endif /* HAVE_TOOLBARS */
|
|
4727 EQ(win1->left_margin_width, win2->left_margin_width) &&
|
|
4728 EQ(win1->right_margin_width, win2->right_margin_width) &&
|
|
4729 EQ(win1->minimum_line_ascent, win2->minimum_line_ascent) &&
|
|
4730 EQ(win1->minimum_line_descent, win2->minimum_line_descent) &&
|
|
4731 EQ(win1->use_left_overflow, win2->use_left_overflow) &&
|
|
4732 EQ(win1->use_right_overflow, win2->use_right_overflow) &&
|
|
4733 #ifdef HAVE_MENUBARS
|
|
4734 EQ(win1->menubar_visible_p, win2->menubar_visible_p) &&
|
|
4735 #endif /* HAVE_MENUBARS */
|
|
4736 EQ(win1->text_cursor_visible_p, win2->text_cursor_visible_p);
|
0
|
4737 }
|
|
4738
|
|
4739 /* Returns a boolean indicating whether the two given configurations
|
|
4740 are identical. */
|
|
4741 static int
|
|
4742 window_config_equal (Lisp_Object conf1, Lisp_Object conf2)
|
|
4743 {
|
|
4744 struct window_config *fig1, *fig2;
|
|
4745 int i;
|
|
4746
|
|
4747 /* First check if they are truly the same. */
|
|
4748 if (EQ (conf1, conf2))
|
|
4749 return 1;
|
|
4750
|
|
4751 fig1 = XWINDOW_CONFIGURATION (conf1);
|
|
4752 fig2 = XWINDOW_CONFIGURATION (conf2);
|
|
4753
|
149
|
4754 if (!((fig1->saved_windows_count == fig2->saved_windows_count) &&
|
274
|
4755 EQ (fig1->current_window, fig2->current_window) &&
|
|
4756 EQ (fig1->current_buffer, fig2->current_buffer) &&
|
|
4757 EQ (fig1->root_window, fig2->root_window) &&
|
|
4758 EQ (fig1->minibuffer_scroll_window, fig2->minibuffer_scroll_window) &&
|
149
|
4759 fig1->frame_width == fig2->frame_width &&
|
|
4760 fig1->frame_height == fig2->frame_height))
|
0
|
4761 return 0;
|
|
4762
|
|
4763 for (i = 0; i < fig1->saved_windows_count; i++)
|
|
4764 {
|
|
4765 if (!saved_window_equal (SAVED_WINDOW_N (fig1, i),
|
|
4766 SAVED_WINDOW_N (fig2, i)))
|
|
4767 return 0;
|
|
4768 }
|
|
4769
|
|
4770 return 1;
|
|
4771 }
|
|
4772
|
20
|
4773 DEFUN ("window-configuration-p", Fwindow_configuration_p, 1, 1, 0, /*
|
272
|
4774 Return t if OBJECT is a window-configuration object.
|
20
|
4775 */
|
|
4776 (obj))
|
0
|
4777 {
|
149
|
4778 return WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil;
|
0
|
4779 }
|
|
4780
|
251
|
4781 static int
|
|
4782 mark_windows_in_use_closure (struct window *w, void *closure)
|
0
|
4783 {
|
251
|
4784 int mark = *(int *)closure;
|
|
4785 w->config_mark = mark;
|
|
4786 return 0;
|
|
4787 }
|
|
4788
|
|
4789 static void
|
|
4790 mark_windows_in_use (struct frame *f, int mark)
|
|
4791 {
|
|
4792 map_windows (f, mark_windows_in_use_closure, &mark);
|
0
|
4793 }
|
|
4794
|
|
4795 /* Lisp_Object return value so it can be used in record_unwind_protect() */
|
|
4796 static Lisp_Object
|
|
4797 free_window_configuration (Lisp_Object window_config)
|
|
4798 {
|
|
4799 int i;
|
|
4800 struct window_config *config = XWINDOW_CONFIGURATION (window_config);
|
|
4801
|
|
4802 /* Free all the markers. It's not completely necessary that
|
|
4803 we do this (window configs sitting in a free list aren't
|
|
4804 marked normally so the markers wouldn't be marked anyway)
|
|
4805 but it's more efficient. */
|
|
4806 for (i = 0; i < config->saved_windows_count; i++)
|
|
4807 {
|
|
4808 struct saved_window *p = SAVED_WINDOW_N (config, i);
|
|
4809
|
|
4810 if (!NILP (p->pointm))
|
|
4811 {
|
|
4812 free_marker (XMARKER (p->pointm));
|
|
4813 p->pointm = Qnil;
|
|
4814 }
|
|
4815 if (!NILP (p->start))
|
|
4816 {
|
|
4817 free_marker (XMARKER (p->start));
|
|
4818 p->start = Qnil;
|
|
4819 }
|
|
4820 if (!NILP (p->sb_point))
|
|
4821 {
|
|
4822 free_marker (XMARKER (p->sb_point));
|
|
4823 p->sb_point = Qnil;
|
|
4824 }
|
|
4825 if (!NILP (p->mark))
|
|
4826 {
|
|
4827 free_marker (XMARKER (p->mark));
|
|
4828 p->mark = Qnil;
|
|
4829 }
|
|
4830 }
|
|
4831
|
|
4832 if (config->saved_windows_count <= countof (Vwindow_configuration_free_list))
|
|
4833 free_managed_lcrecord (Vwindow_configuration_free_list
|
|
4834 [config->saved_windows_count - 1],
|
|
4835 window_config);
|
|
4836
|
|
4837 return Qnil;
|
|
4838 }
|
|
4839
|
20
|
4840 DEFUN ("set-window-configuration", Fset_window_configuration, 1, 1, 0, /*
|
0
|
4841 Set the configuration of windows and buffers as specified by CONFIGURATION.
|
|
4842 CONFIGURATION must be a value previously returned
|
|
4843 by `current-window-configuration' (which see).
|
20
|
4844 */
|
|
4845 (configuration))
|
0
|
4846 {
|
|
4847 struct window *w;
|
|
4848 struct window_config *config;
|
|
4849 struct saved_window *p;
|
|
4850 Lisp_Object new_current_buffer;
|
|
4851 int k;
|
|
4852 Lisp_Object frame;
|
|
4853 struct frame *f;
|
|
4854 struct gcpro gcpro1;
|
|
4855 Lisp_Object old_window_config;
|
|
4856 int previous_frame_height;
|
|
4857 int previous_frame_width;
|
|
4858 int specpdl_count = specpdl_depth ();
|
|
4859
|
|
4860 GCPRO1 (configuration);
|
|
4861
|
|
4862 CHECK_WINDOW_CONFIGURATION (configuration);
|
|
4863 config = XWINDOW_CONFIGURATION (configuration);
|
|
4864
|
|
4865 frame = XWINDOW (SAVED_WINDOW_N (config, 0)->window)->frame;
|
|
4866 f = XFRAME (frame);
|
|
4867
|
|
4868 /* Do not signal an error here if the frame was deleted. There are
|
|
4869 reasonable cases where we could get here with a deleted frame and
|
|
4870 just want to do close to nothing instead. */
|
|
4871
|
|
4872 if (FRAME_LIVE_P (f))
|
|
4873 {
|
|
4874 /* restore the frame characteristics */
|
185
|
4875
|
0
|
4876 new_current_buffer = config->current_buffer;
|
|
4877 if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer)))
|
|
4878 new_current_buffer = Qnil;
|
|
4879
|
|
4880 /*
|
|
4881 * Assumed precondition: w->config_mark = 0 for all w
|
|
4882 * This procedure should ensure this is true by the time it exits
|
|
4883 * to ensure the precondition for future calls.
|
|
4884 *
|
|
4885 * We use w->config_mark to know whether we're modifying a
|
|
4886 * window that is currently visible on the frame (#### we
|
|
4887 * should just be able to check whether the window is dead
|
|
4888 * or not, but this way is safer?). As we process each
|
|
4889 * window, we set its config_mark to 0. At the end, we
|
|
4890 * go through all the windows that used to be on the frame,
|
|
4891 * set each one's config_mark to 0 (to maintain the
|
|
4892 * assumed precondition) and delete each one that's no
|
|
4893 * longer in use.
|
|
4894 *
|
|
4895 * #### Using a window-configuration to keep track of
|
|
4896 * the current windows is wasteful. All we need is the
|
|
4897 * list of windows, so we could just use a dynarr.
|
|
4898 */
|
|
4899 old_window_config = Fcurrent_window_configuration (frame);
|
|
4900
|
|
4901 /* If the new configuration is already equal to the old, then stop
|
|
4902 right here. This saves the work below and it also saves
|
|
4903 triggering a full redisplay of this window. This is a huge win
|
|
4904 when using the mouse since the mode motion code uses
|
|
4905 save-window-excursion extensively but will rarely cause the
|
|
4906 configuration to actually change. */
|
|
4907 if (window_config_equal (configuration, old_window_config))
|
|
4908 {
|
|
4909 free_window_configuration (old_window_config);
|
|
4910 UNGCPRO;
|
|
4911 return Qnil;
|
|
4912 }
|
|
4913
|
|
4914 /* We can't quit or even check for quit because that may cause
|
|
4915 investigation of the frame state, which may crash if the frame is
|
|
4916 in an inconsistent state. */
|
|
4917 begin_dont_check_for_quit ();
|
|
4918 record_unwind_protect (free_window_configuration, old_window_config);
|
|
4919
|
251
|
4920 mark_windows_in_use (f, 1);
|
0
|
4921
|
|
4922 previous_frame_width = FRAME_WIDTH (f);
|
|
4923 previous_frame_height = FRAME_HEIGHT (f);
|
|
4924 /* If the frame has been resized since this window configuration was
|
|
4925 made, we change the frame to the size specified in the
|
|
4926 configuration, restore the configuration, and then resize it
|
|
4927 back. We keep track of the prevailing height in these variables. */
|
|
4928 if (config->frame_height != FRAME_HEIGHT (f)
|
|
4929 || config->frame_width != FRAME_WIDTH (f))
|
|
4930 change_frame_size (f, config->frame_height, config->frame_width, 0);
|
|
4931
|
|
4932 /* Temporarily avoid any problems with windows that are smaller
|
|
4933 than they are supposed to be. */
|
|
4934 window_min_height = 1;
|
|
4935 window_min_width = 1;
|
|
4936
|
|
4937 /* OK, now restore all the windows in the window config.
|
|
4938 This may involve "undeleting" windows, since the
|
|
4939 windows in the window config may be deleted.
|
|
4940 */
|
|
4941 for (k = 0; k < config->saved_windows_count; k++)
|
|
4942 {
|
|
4943 p = SAVED_WINDOW_N (config, k);
|
|
4944 w = XWINDOW (p->window);
|
|
4945 w->next = Qnil;
|
|
4946
|
|
4947 /* The window might be dead. In this case, its redisplay
|
|
4948 structures were freed, so we need to reallocate them. */
|
|
4949 if (!w->face_cachels)
|
|
4950 {
|
185
|
4951 w->face_cachels = Dynarr_new (face_cachel);
|
0
|
4952 reset_face_cachels (w);
|
|
4953 }
|
|
4954 if (!w->glyph_cachels)
|
185
|
4955 w->glyph_cachels = Dynarr_new (glyph_cachel);
|
0
|
4956 if (!w->line_start_cache)
|
185
|
4957 w->line_start_cache = Dynarr_new (line_start_cache);
|
0
|
4958 w->dead = 0;
|
|
4959
|
|
4960 if (p->parent_index >= 0)
|
|
4961 w->parent = SAVED_WINDOW_N (config, p->parent_index)->window;
|
|
4962 else
|
|
4963 w->parent = Qnil;
|
|
4964
|
|
4965 if (p->prev_index >= 0)
|
|
4966 {
|
|
4967 w->prev = SAVED_WINDOW_N (config, p->prev_index)->window;
|
|
4968
|
|
4969 /* This is true for a minibuffer-only frame. */
|
|
4970 if (!NILP (w->mini_p) && EQ (w->prev, p->window))
|
|
4971 w->next = Qnil;
|
|
4972 else
|
|
4973 XWINDOW (w->prev)->next = p->window;
|
|
4974 }
|
|
4975 else
|
|
4976 {
|
|
4977 w->prev = Qnil;
|
|
4978 if (!NILP (w->parent))
|
|
4979 {
|
|
4980 if (WINDOW_WIDTH (p) == WINDOW_WIDTH (XWINDOW (w->parent)))
|
|
4981 {
|
|
4982 XWINDOW (w->parent)->vchild = p->window;
|
|
4983 XWINDOW (w->parent)->hchild = Qnil;
|
|
4984 }
|
|
4985 else
|
|
4986 {
|
|
4987 XWINDOW (w->parent)->hchild = p->window;
|
|
4988 XWINDOW (w->parent)->vchild = Qnil;
|
|
4989 }
|
|
4990 }
|
|
4991 }
|
|
4992 if (!w->config_mark)
|
|
4993 {
|
|
4994 /* #### This should be equivalent to the window previously
|
|
4995 having been dead. If we're brave, we'll put in an
|
|
4996 assertion to this effect. */
|
|
4997 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
4998 }
|
|
4999 else /* if (!EQ (w->buffer, p->buffer)) */
|
|
5000 {
|
|
5001 /* With the new redisplay we let it know that a change has
|
|
5002 been made and it will take care of the rest. If we don't
|
|
5003 tell it something has possibly changed it could lead to
|
|
5004 incorrect display. */
|
|
5005 MARK_WINDOWS_CHANGED (w);
|
|
5006 }
|
|
5007
|
|
5008 WINDOW_LEFT (w) = WINDOW_LEFT (p);
|
|
5009 WINDOW_TOP (w) = WINDOW_TOP (p);
|
|
5010 WINDOW_WIDTH (w) = WINDOW_WIDTH (p);
|
|
5011 WINDOW_HEIGHT (w) = WINDOW_HEIGHT (p);
|
|
5012 w->hscroll = p->hscroll;
|
257
|
5013 w->modeline_hscroll = p->modeline_hscroll;
|
255
|
5014 w->display_table = p->display_table;
|
|
5015 w->modeline_shadow_thickness = p->modeline_shadow_thickness;
|
|
5016 w->has_modeline_p = p->has_modeline_p;
|
|
5017 #ifdef HAVE_SCROLLBARS
|
|
5018 w->scrollbar_width = p->scrollbar_width;
|
|
5019 w->scrollbar_height = p->scrollbar_height;
|
282
|
5020 w->horizontal_scrollbar_visible_p = p->horizontal_scrollbar_visible_p;
|
|
5021 w->vertical_scrollbar_visible_p = p->vertical_scrollbar_visible_p;
|
|
5022 w->scrollbar_on_left_p = p->scrollbar_on_left_p;
|
|
5023 w->scrollbar_on_top_p = p->scrollbar_on_top_p;
|
255
|
5024 w->scrollbar_pointer = p->scrollbar_pointer;
|
|
5025 #endif /* HAVE_SCROLLBARS */
|
|
5026 #ifdef HAVE_TOOLBARS
|
|
5027 {
|
|
5028 int ix;
|
|
5029 for (ix = 0; ix < 4; ix++)
|
|
5030 {
|
|
5031 w->toolbar[ix] = p->toolbar[ix];
|
|
5032 w->toolbar_size[ix] = p->toolbar_size[ix];
|
|
5033 w->toolbar_border_width[ix] = p->toolbar_border_width[ix];
|
|
5034 w->toolbar_visible_p[ix] = p->toolbar_visible_p[ix];
|
|
5035 }
|
|
5036 }
|
|
5037 w->toolbar_buttons_captioned_p = p->toolbar_buttons_captioned_p;
|
|
5038 w->default_toolbar = p->default_toolbar;
|
|
5039 w->default_toolbar_width = p->default_toolbar_width;
|
263
|
5040 w->default_toolbar_height = p->default_toolbar_height;
|
255
|
5041 w->default_toolbar_visible_p = p->default_toolbar_visible_p;
|
|
5042 w->default_toolbar_border_width = p->default_toolbar_border_width;
|
|
5043 #endif /* HAVE_TOOLBARS */
|
|
5044 w->left_margin_width = p->left_margin_width;
|
|
5045 w->right_margin_width = p->right_margin_width;
|
|
5046 w->minimum_line_ascent = p->minimum_line_ascent;
|
|
5047 w->minimum_line_descent = p->minimum_line_descent;
|
|
5048 w->use_left_overflow = p->use_left_overflow;
|
|
5049 w->use_right_overflow = p->use_right_overflow;
|
|
5050 #ifdef HAVE_MENUBARS
|
|
5051 w->menubar_visible_p = p->menubar_visible_p;
|
|
5052 #endif /* HAVE_MENUBARS */
|
|
5053 w->text_cursor_visible_p = p->text_cursor_visible_p;
|
0
|
5054 w->dedicated = p->dedicated;
|
|
5055 w->line_cache_last_updated = Qzero;
|
|
5056 SET_LAST_MODIFIED (w, 1);
|
|
5057 SET_LAST_FACECHANGE (w);
|
|
5058 w->config_mark = 0;
|
|
5059
|
|
5060 /* Reinstall the saved buffer and pointers into it. */
|
|
5061 if (NILP (p->buffer))
|
|
5062 w->buffer = p->buffer;
|
|
5063 else
|
|
5064 {
|
|
5065 if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
|
|
5066 /* If saved buffer is alive, install it. */
|
|
5067 {
|
|
5068 w->buffer = p->buffer;
|
|
5069 w->start_at_line_beg = p->start_at_line_beg;
|
|
5070 set_marker_restricted (w->start[CURRENT_DISP],
|
|
5071 Fmarker_position (p->start),
|
|
5072 w->buffer);
|
|
5073 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
5074 Fmarker_position (p->pointm),
|
|
5075 w->buffer);
|
|
5076 set_marker_restricted (w->sb_point,
|
|
5077 Fmarker_position (p->sb_point),
|
|
5078 w->buffer);
|
|
5079 Fset_marker (XBUFFER (w->buffer)->mark,
|
|
5080 Fmarker_position (p->mark), w->buffer);
|
|
5081
|
|
5082 /* As documented in Fcurrent_window_configuration, don't
|
|
5083 save the location of point in the buffer which was current
|
|
5084 when the window configuration was recorded. */
|
|
5085 if (!EQ (p->buffer, new_current_buffer) &&
|
|
5086 XBUFFER (p->buffer) == current_buffer)
|
223
|
5087 Fgoto_char (w->pointm[CURRENT_DISP], Qnil);
|
0
|
5088 }
|
|
5089 else if (NILP (w->buffer) ||
|
|
5090 !BUFFER_LIVE_P (XBUFFER (w->buffer)))
|
|
5091 /* Else if window's old buffer is dead too, get a live one. */
|
|
5092 {
|
|
5093 /* #### The following line makes me nervous... */
|
|
5094 /* w->buffer = Fcdr (Fcar (XFRAME (w->frame)->buffer_alist));*/
|
|
5095 w->buffer = Fget_buffer_create (QSscratch);
|
|
5096 /* w->buffer = Fother_buffer (Qnil, w->frame, Qnil); */
|
|
5097 /* This will set the markers to beginning of visible
|
|
5098 range. */
|
|
5099 set_marker_restricted (w->start[CURRENT_DISP], Qzero, w->buffer);
|
|
5100 set_marker_restricted (w->pointm[CURRENT_DISP], Qzero,
|
|
5101 w->buffer);
|
|
5102 set_marker_restricted (w->sb_point, Qzero, w->buffer);
|
|
5103 w->start_at_line_beg = 1;
|
|
5104 }
|
|
5105 else
|
|
5106 /* Keeping window's old buffer; make sure the markers
|
|
5107 are real. */
|
|
5108 {
|
|
5109 /* Set window markers at start of visible range. */
|
|
5110 if (XMARKER (w->start[CURRENT_DISP])->buffer == 0)
|
|
5111 set_marker_restricted (w->start[CURRENT_DISP], Qzero,
|
|
5112 w->buffer);
|
|
5113 if (XMARKER (w->sb_point)->buffer == 0)
|
|
5114 set_marker_restricted (w->sb_point, Qzero, w->buffer);
|
|
5115 if (XMARKER (w->pointm[CURRENT_DISP])->buffer == 0)
|
|
5116 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
5117 make_int
|
|
5118 (BUF_PT (XBUFFER (w->buffer))),
|
|
5119 w->buffer);
|
|
5120 w->start_at_line_beg = 1;
|
|
5121 }
|
|
5122 }
|
|
5123 }
|
|
5124
|
|
5125 FRAME_ROOT_WINDOW (f) = config->root_window;
|
|
5126 /* Note that FSFmacs unilaterally calls Fselect_window() here, and
|
|
5127 then calls do_switch_frame() below to select the frame that was
|
|
5128 recorded in the window config as being selected.
|
|
5129
|
|
5130 Instead, we don't ever change the selected frame, and either
|
|
5131 call Fselect_window() below if the window config's frame is
|
|
5132 currently selected, or just set the selected window of the
|
|
5133 window config's frame. */
|
|
5134
|
|
5135 /* Set the frame height to the value it had before this function. */
|
|
5136 if (previous_frame_height != FRAME_HEIGHT (f)
|
|
5137 || previous_frame_width != FRAME_WIDTH (f))
|
|
5138 change_frame_size (f, previous_frame_height, previous_frame_width, 0);
|
|
5139
|
|
5140 /* If restoring in the current frame make the window current,
|
|
5141 otherwise just update the frame selected_window slot to be
|
|
5142 the restored current_window. */
|
|
5143 if (f == selected_frame ())
|
|
5144 {
|
|
5145 /* When using `pop-window-configuration', often the minibuffer
|
|
5146 ends up as the selected window even though it's not active ...
|
|
5147 I really don't know the cause of this, but it should never
|
|
5148 happen. This kludge should fix it.
|
|
5149
|
|
5150 #### Find out why this is really going wrong. */
|
|
5151 if (!minibuf_level &&
|
|
5152 MINI_WINDOW_P (XWINDOW (config->current_window)))
|
|
5153 Fselect_window (Fnext_window (config->current_window,
|
282
|
5154 Qnil, Qnil, Qnil),
|
|
5155 Qnil);
|
0
|
5156 else
|
282
|
5157 Fselect_window (config->current_window, Qnil);
|
0
|
5158 if (!NILP (new_current_buffer))
|
|
5159 Fset_buffer (new_current_buffer);
|
|
5160 else
|
|
5161 Fset_buffer (XWINDOW (Fselected_window (Qnil))->buffer);
|
|
5162 }
|
|
5163 else
|
|
5164 set_frame_selected_window (f, config->current_window);
|
|
5165 }
|
173
|
5166 else
|
|
5167 old_window_config = Qnil; /* Warning suppression */
|
0
|
5168
|
|
5169 /* Restore the minimum heights recorded in the configuration. */
|
|
5170 window_min_height = config->min_height;
|
|
5171 window_min_width = config->min_width;
|
|
5172
|
|
5173 #if 0 /* FSFmacs */
|
|
5174 /* see above comment */
|
|
5175 /* Fselect_window will have made f the selected frame, so we
|
|
5176 reselect the proper frame here. Fhandle_switch_frame will change the
|
|
5177 selected window too, but that doesn't make the call to
|
|
5178 Fselect_window above totally superfluous; it still sets f's
|
|
5179 selected window. */
|
|
5180 if (FRAME_LIVE_P (XFRAME (config->selected_frame)))
|
|
5181 do_switch_frame (config->selected_frame, Qnil, 0);
|
|
5182 #endif
|
|
5183
|
274
|
5184 Vminibuffer_scroll_window = config->minibuffer_scroll_window;
|
0
|
5185
|
|
5186 if (FRAME_LIVE_P (f))
|
|
5187 {
|
|
5188 /* Do this before calling recompute_all_cached_specifiers_in_window()
|
|
5189 so that things like redisplay_redraw_cursor() won't abort due
|
|
5190 to no window mirror present. */
|
|
5191 f->mirror_dirty = 1;
|
|
5192
|
|
5193 config = XWINDOW_CONFIGURATION (old_window_config);
|
|
5194 for (k = 0; k < config->saved_windows_count; k++)
|
|
5195 {
|
|
5196 p = SAVED_WINDOW_N (config, k);
|
|
5197 w = XWINDOW (p->window);
|
|
5198 /* Remember, we set w->config_mark on all currently visible
|
|
5199 windows, and reset it on all newly visible windows.
|
|
5200 Any windows still marked need to be deleted. */
|
|
5201 if (w->config_mark)
|
|
5202 {
|
|
5203 mark_window_as_deleted (w);
|
|
5204 w->config_mark = 0;
|
|
5205 }
|
|
5206 else
|
|
5207 {
|
|
5208 /* We just potentially changed the window's buffer and
|
|
5209 potentially turned a dead window into a live one,
|
|
5210 so we need to recompute the cached specifier values. */
|
|
5211 recompute_all_cached_specifiers_in_window (w);
|
|
5212 }
|
|
5213 }
|
|
5214 }
|
|
5215
|
|
5216 /* Now restore things, when everything else if OK. */
|
|
5217
|
|
5218 unbind_to (specpdl_count, Qnil);
|
|
5219
|
|
5220 UNGCPRO;
|
|
5221
|
149
|
5222 return Qnil;
|
0
|
5223 }
|
|
5224
|
|
5225 /* Mark all subwindows of a window as deleted. The argument
|
|
5226 W is actually the subwindow tree of the window in question. */
|
|
5227
|
|
5228 void
|
|
5229 delete_all_subwindows (struct window *w)
|
|
5230 {
|
272
|
5231 if (!NILP (w->next)) delete_all_subwindows (XWINDOW (w->next));
|
|
5232 if (!NILP (w->vchild)) delete_all_subwindows (XWINDOW (w->vchild));
|
|
5233 if (!NILP (w->hchild)) delete_all_subwindows (XWINDOW (w->hchild));
|
0
|
5234
|
|
5235 mark_window_as_deleted (w);
|
|
5236 }
|
|
5237
|
|
5238
|
|
5239 static int
|
|
5240 count_windows (struct window *window)
|
|
5241 {
|
272
|
5242 return 1 +
|
|
5243 (!NILP (window->next) ? count_windows (XWINDOW (window->next)) : 0) +
|
|
5244 (!NILP (window->vchild) ? count_windows (XWINDOW (window->vchild)) : 0) +
|
|
5245 (!NILP (window->hchild) ? count_windows (XWINDOW (window->hchild)) : 0);
|
0
|
5246 }
|
|
5247
|
|
5248 static int
|
|
5249 saved_window_index (Lisp_Object window, struct window_config *config, int lim)
|
|
5250 {
|
|
5251 int j;
|
|
5252 for (j = 0; j < lim; j++)
|
|
5253 {
|
|
5254 if (EQ (SAVED_WINDOW_N (config, j)->window, window))
|
149
|
5255 return j;
|
272
|
5256 }
|
0
|
5257 abort ();
|
|
5258 return 0; /* suppress compiler warning */
|
|
5259 }
|
|
5260
|
|
5261 static int
|
|
5262 save_window_save (Lisp_Object window, struct window_config *config, int i)
|
|
5263 {
|
|
5264 struct window *w;
|
|
5265
|
|
5266 for (; !NILP (window); window = w->next)
|
|
5267 {
|
272
|
5268 struct saved_window *p = SAVED_WINDOW_N (config, i);
|
|
5269
|
0
|
5270 w = XWINDOW (window);
|
|
5271 i++;
|
|
5272 p->window = window;
|
|
5273 p->buffer = w->buffer;
|
|
5274 WINDOW_LEFT (p) = WINDOW_LEFT (w);
|
|
5275 WINDOW_TOP (p) = WINDOW_TOP (w);
|
|
5276 WINDOW_WIDTH (p) = WINDOW_WIDTH (w);
|
|
5277 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (w);
|
|
5278 p->hscroll = w->hscroll;
|
257
|
5279 p->modeline_hscroll = w->modeline_hscroll;
|
255
|
5280 p->display_table = w->display_table;
|
|
5281 p->modeline_shadow_thickness = w->modeline_shadow_thickness;
|
|
5282 p->has_modeline_p = w->has_modeline_p;
|
|
5283 #ifdef HAVE_SCROLLBARS
|
|
5284 p->scrollbar_width = w->scrollbar_width;
|
|
5285 p->scrollbar_height = w->scrollbar_height;
|
282
|
5286 p->horizontal_scrollbar_visible_p = w->horizontal_scrollbar_visible_p;
|
|
5287 p->vertical_scrollbar_visible_p = w->vertical_scrollbar_visible_p;
|
|
5288 p->scrollbar_on_left_p = w->scrollbar_on_left_p;
|
|
5289 p->scrollbar_on_top_p = w->scrollbar_on_top_p;
|
255
|
5290 p->scrollbar_pointer = w->scrollbar_pointer;
|
|
5291 #endif /* HAVE_SCROLLBARS */
|
|
5292 #ifdef HAVE_TOOLBARS
|
|
5293 {
|
|
5294 int ix;
|
|
5295 for (ix = 0; ix < 4; ix++)
|
|
5296 {
|
|
5297 p->toolbar[ix] = w->toolbar[ix];
|
|
5298 p->toolbar_size[ix] = w->toolbar_size[ix];
|
|
5299 p->toolbar_border_width[ix] = w->toolbar_border_width[ix];
|
|
5300 p->toolbar_visible_p[ix] = w->toolbar_visible_p[ix];
|
|
5301 }
|
|
5302 }
|
|
5303 p->toolbar_buttons_captioned_p = w->toolbar_buttons_captioned_p;
|
|
5304 p->default_toolbar = w->default_toolbar;
|
|
5305 p->default_toolbar_width = w->default_toolbar_width;
|
263
|
5306 p->default_toolbar_height = w->default_toolbar_height;
|
255
|
5307 p->default_toolbar_visible_p = w->default_toolbar_visible_p;
|
|
5308 p->default_toolbar_border_width = w->default_toolbar_border_width;
|
|
5309 #endif /* HAVE_TOOLBARS */
|
|
5310 p->left_margin_width = w->left_margin_width;
|
|
5311 p->right_margin_width = w->right_margin_width;
|
|
5312 p->minimum_line_ascent = w->minimum_line_ascent;
|
|
5313 p->minimum_line_descent = w->minimum_line_descent;
|
|
5314 p->use_left_overflow = w->use_left_overflow;
|
|
5315 p->use_right_overflow = w->use_right_overflow;
|
|
5316 #ifdef HAVE_MENUBARS
|
|
5317 p->menubar_visible_p = w->menubar_visible_p;
|
|
5318 #endif /* HAVE_MENUBARS */
|
|
5319 p->text_cursor_visible_p = w->text_cursor_visible_p;
|
|
5320
|
0
|
5321 if (!NILP (w->buffer))
|
|
5322 {
|
|
5323 /* Save w's value of point in the window configuration.
|
|
5324 If w is the selected window, then get the value of point
|
|
5325 from the buffer; pointm is garbage in the selected window. */
|
|
5326 if (EQ (window, Fselected_window (Qnil)))
|
|
5327 {
|
|
5328 p->pointm = noseeum_make_marker ();
|
|
5329 Fset_marker (p->pointm,
|
|
5330 make_int (BUF_PT (XBUFFER (w->buffer))),
|
|
5331 w->buffer);
|
|
5332 }
|
|
5333 else
|
|
5334 p->pointm = noseeum_copy_marker (w->pointm[CURRENT_DISP], Qnil);
|
|
5335
|
|
5336 p->start = noseeum_copy_marker (w->start[CURRENT_DISP], Qnil);
|
|
5337 p->sb_point = noseeum_copy_marker (w->sb_point, Qnil);
|
|
5338 p->start_at_line_beg = w->start_at_line_beg;
|
|
5339
|
|
5340 p->mark = noseeum_copy_marker (XBUFFER (w->buffer)->mark, Qnil);
|
|
5341 }
|
|
5342 else
|
|
5343 {
|
|
5344 p->pointm = Qnil;
|
|
5345 p->start = Qnil;
|
|
5346 p->sb_point = Qnil;
|
|
5347 p->mark = Qnil;
|
|
5348 p->start_at_line_beg = 0;
|
|
5349 }
|
|
5350
|
|
5351 if (NILP (w->parent))
|
|
5352 p->parent_index = -1;
|
|
5353 else
|
|
5354 p->parent_index = saved_window_index (w->parent, config, i);
|
|
5355 if (NILP (w->prev))
|
|
5356 p->prev_index = -1;
|
|
5357 else
|
|
5358 p->prev_index = saved_window_index (w->prev, config, i);
|
|
5359 p->dedicated = w->dedicated;
|
|
5360 if (!NILP (w->vchild))
|
|
5361 i = save_window_save (w->vchild, config, i);
|
|
5362 if (!NILP (w->hchild))
|
|
5363 i = save_window_save (w->hchild, config, i);
|
|
5364 }
|
|
5365
|
|
5366 return i;
|
|
5367 }
|
|
5368
|
|
5369 #if 0 /* FSFmacs */
|
|
5370 /* Added to doc string:
|
|
5371
|
|
5372 This also records the currently selected frame, and FRAME's focus
|
|
5373 redirection (see `redirect-frame-focus').
|
|
5374
|
|
5375 */
|
|
5376 #endif
|
|
5377
|
20
|
5378 DEFUN ("current-window-configuration", Fcurrent_window_configuration, 0, 1, 0, /*
|
0
|
5379 Return an object representing the current window configuration of FRAME.
|
|
5380 If FRAME is nil or omitted, use the selected frame.
|
|
5381 This describes the number of windows, their sizes and current buffers,
|
|
5382 and for each displayed buffer, where display starts, and the positions of
|
|
5383 point and mark. An exception is made for point in the current buffer:
|
|
5384 its value is -not- saved.
|
20
|
5385 */
|
|
5386 (frame))
|
0
|
5387 {
|
272
|
5388 Lisp_Object result;
|
|
5389 struct frame *f = decode_frame (frame);
|
0
|
5390 struct window_config *config;
|
272
|
5391 int n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
|
|
5392
|
0
|
5393 if (n_windows <= countof (Vwindow_configuration_free_list))
|
272
|
5394 config = XWINDOW_CONFIGURATION (allocate_managed_lcrecord
|
|
5395 (Vwindow_configuration_free_list
|
|
5396 [n_windows - 1]));
|
0
|
5397 else
|
|
5398 /* More than ten windows; just allocate directly */
|
185
|
5399 config = (struct window_config *)
|
|
5400 alloc_lcrecord (sizeof_window_config_for_n_windows (n_windows),
|
|
5401 lrecord_window_configuration);
|
0
|
5402 XSETWINDOW_CONFIGURATION (result, config);
|
|
5403
|
|
5404 config->frame_width = FRAME_WIDTH (f);
|
|
5405 config->frame_height = FRAME_HEIGHT (f);
|
|
5406 config->current_window = FRAME_SELECTED_WINDOW (f);
|
|
5407 XSETBUFFER (config->current_buffer, current_buffer);
|
274
|
5408 config->minibuffer_scroll_window = Vminibuffer_scroll_window;
|
0
|
5409 config->root_window = FRAME_ROOT_WINDOW (f);
|
|
5410 config->min_height = window_min_height;
|
|
5411 config->min_width = window_min_width;
|
|
5412 config->saved_windows_count = n_windows;
|
|
5413 save_window_save (FRAME_ROOT_WINDOW (f), config, 0);
|
149
|
5414 return result;
|
0
|
5415 }
|
|
5416
|
|
5417 Lisp_Object
|
|
5418 save_window_excursion_unwind (Lisp_Object window_config)
|
|
5419 {
|
|
5420 Lisp_Object val = Fset_window_configuration (window_config);
|
|
5421 free_window_configuration (window_config);
|
|
5422 return val;
|
|
5423 }
|
|
5424
|
20
|
5425 DEFUN ("save-window-excursion", Fsave_window_excursion, 0, UNEVALLED, 0, /*
|
0
|
5426 Execute body, preserving window sizes and contents.
|
|
5427 Restores which buffer appears in which window, where display starts,
|
|
5428 as well as the current buffer.
|
|
5429 Does not restore the value of point in current buffer.
|
20
|
5430 */
|
|
5431 (args))
|
0
|
5432 {
|
|
5433 /* This function can GC */
|
|
5434 Lisp_Object val;
|
|
5435 int speccount = specpdl_depth ();
|
|
5436
|
|
5437 record_unwind_protect (save_window_excursion_unwind,
|
|
5438 Fcurrent_window_configuration (Qnil));
|
|
5439 val = Fprogn (args);
|
|
5440 return unbind_to (speccount, val);
|
|
5441 }
|
|
5442
|
|
5443
|
|
5444 #ifdef DEBUG_XEMACS
|
|
5445 /* This is short and simple in elisp, but... it was written to debug
|
|
5446 problems purely on the C side. That is where we need to call it so
|
|
5447 here it is. */
|
|
5448 static void
|
|
5449 debug_print_window (Lisp_Object window, int level)
|
|
5450 {
|
272
|
5451 int i;
|
|
5452 Lisp_Object child = Fwindow_first_vchild (window);
|
|
5453
|
0
|
5454 if (NILP (child))
|
|
5455 child = Fwindow_first_hchild (window);
|
|
5456
|
272
|
5457 for (i = level; i > 0; i--)
|
|
5458 putc ('\t', stderr);
|
|
5459
|
|
5460 fputs ("#<window", stderr);
|
|
5461 {
|
|
5462 Lisp_Object buffer = XWINDOW (window)->buffer;
|
|
5463 if (!NILP (buffer) && BUFFERP (buffer))
|
|
5464 fprintf (stderr, " on %s", XSTRING_DATA (XBUFFER (buffer)->name));
|
|
5465 }
|
0
|
5466 fprintf (stderr, " 0x%x>", XWINDOW (window)->header.uid);
|
|
5467
|
|
5468 while (!NILP (child))
|
|
5469 {
|
|
5470 debug_print_window (child, level + 1);
|
|
5471 child = Fwindow_next_child (child);
|
|
5472 }
|
|
5473 }
|
|
5474
|
|
5475 void debug_print_windows (struct frame *f);
|
|
5476 void
|
|
5477 debug_print_windows (struct frame *f)
|
|
5478 {
|
|
5479 debug_print_window (f->root_window, 0);
|
272
|
5480 putc ('\n', stderr);
|
0
|
5481 }
|
|
5482 #endif /* DEBUG_XEMACS */
|
|
5483
|
|
5484
|
|
5485 /************************************************************************/
|
|
5486 /* initialization */
|
|
5487 /************************************************************************/
|
|
5488
|
|
5489 void
|
|
5490 syms_of_window (void)
|
|
5491 {
|
|
5492 defsymbol (&Qwindowp, "windowp");
|
|
5493 defsymbol (&Qwindow_live_p, "window-live-p");
|
|
5494 defsymbol (&Qwindow_configurationp, "window-configuration-p");
|
|
5495 defsymbol (&Qscroll_up, "scroll-up");
|
|
5496 defsymbol (&Qscroll_down, "scroll-down");
|
|
5497 defsymbol (&Qtemp_buffer_show_hook, "temp-buffer-show-hook");
|
|
5498 defsymbol (&Qdisplay_buffer, "display-buffer");
|
|
5499
|
|
5500 #ifdef MEMORY_USAGE_STATS
|
|
5501 defsymbol (&Qface_cache, "face-cache");
|
|
5502 defsymbol (&Qglyph_cache, "glyph-cache");
|
|
5503 defsymbol (&Qline_start_cache, "line-start-cache");
|
|
5504 #ifdef HAVE_SCROLLBARS
|
|
5505 defsymbol (&Qscrollbar_instances, "scrollbar-instances");
|
|
5506 #endif
|
|
5507 defsymbol (&Qother_redisplay, "other-redisplay");
|
|
5508 /* Qother in general.c */
|
|
5509 #endif
|
|
5510
|
20
|
5511 DEFSUBR (Fselected_window);
|
|
5512 DEFSUBR (Fminibuffer_window);
|
|
5513 DEFSUBR (Fwindow_minibuffer_p);
|
|
5514 DEFSUBR (Fwindowp);
|
|
5515 DEFSUBR (Fwindow_live_p);
|
|
5516 DEFSUBR (Fwindow_first_hchild);
|
|
5517 DEFSUBR (Fwindow_first_vchild);
|
|
5518 DEFSUBR (Fwindow_next_child);
|
|
5519 DEFSUBR (Fwindow_previous_child);
|
|
5520 DEFSUBR (Fwindow_parent);
|
|
5521 DEFSUBR (Fwindow_lowest_p);
|
|
5522 DEFSUBR (Fwindow_highest_p);
|
|
5523 DEFSUBR (Fwindow_leftmost_p);
|
|
5524 DEFSUBR (Fwindow_rightmost_p);
|
|
5525 DEFSUBR (Fpos_visible_in_window_p);
|
|
5526 DEFSUBR (Fwindow_buffer);
|
|
5527 DEFSUBR (Fwindow_frame);
|
|
5528 DEFSUBR (Fwindow_height);
|
|
5529 DEFSUBR (Fwindow_displayed_height);
|
|
5530 DEFSUBR (Fwindow_width);
|
|
5531 DEFSUBR (Fwindow_pixel_height);
|
|
5532 DEFSUBR (Fwindow_pixel_width);
|
276
|
5533 DEFSUBR (Fwindow_text_pixel_height);
|
|
5534 DEFSUBR (Fwindow_text_pixel_width);
|
20
|
5535 DEFSUBR (Fwindow_hscroll);
|
265
|
5536 #ifdef MODELINE_IS_SCROLLABLE
|
257
|
5537 DEFSUBR (Fmodeline_hscroll);
|
272
|
5538 DEFSUBR (Fset_modeline_hscroll);
|
265
|
5539 #endif /* MODELINE_IS_SCROLLABLE */
|
276
|
5540 #if 0 /* bogus FSF crock */
|
20
|
5541 DEFSUBR (Fwindow_redisplay_end_trigger);
|
|
5542 DEFSUBR (Fset_window_redisplay_end_trigger);
|
0
|
5543 #endif
|
20
|
5544 DEFSUBR (Fset_window_hscroll);
|
|
5545 DEFSUBR (Fwindow_pixel_edges);
|
276
|
5546 DEFSUBR (Fwindow_text_pixel_edges);
|
20
|
5547 DEFSUBR (Fwindow_point);
|
|
5548 DEFSUBR (Fwindow_start);
|
|
5549 DEFSUBR (Fwindow_end);
|
|
5550 DEFSUBR (Fset_window_point);
|
|
5551 DEFSUBR (Fset_window_start);
|
|
5552 DEFSUBR (Fwindow_dedicated_p);
|
|
5553 DEFSUBR (Fset_window_dedicated_p);
|
|
5554 DEFSUBR (Fnext_window);
|
|
5555 DEFSUBR (Fprevious_window);
|
|
5556 DEFSUBR (Fnext_vertical_window);
|
|
5557 DEFSUBR (Fother_window);
|
|
5558 DEFSUBR (Fget_lru_window);
|
|
5559 DEFSUBR (Fget_largest_window);
|
|
5560 DEFSUBR (Fget_buffer_window);
|
|
5561 DEFSUBR (Fwindow_left_margin_pixel_width);
|
|
5562 DEFSUBR (Fwindow_right_margin_pixel_width);
|
|
5563 DEFSUBR (Fdelete_other_windows);
|
|
5564 DEFSUBR (Fdelete_windows_on);
|
|
5565 DEFSUBR (Freplace_buffer_in_windows);
|
|
5566 DEFSUBR (Fdelete_window);
|
|
5567 DEFSUBR (Fset_window_buffer);
|
|
5568 DEFSUBR (Fselect_window);
|
|
5569 DEFSUBR (Fsplit_window);
|
|
5570 DEFSUBR (Fenlarge_window);
|
263
|
5571 DEFSUBR (Fenlarge_window_pixels);
|
20
|
5572 DEFSUBR (Fshrink_window);
|
263
|
5573 DEFSUBR (Fshrink_window_pixels);
|
20
|
5574 DEFSUBR (Fscroll_up);
|
|
5575 DEFSUBR (Fscroll_down);
|
|
5576 DEFSUBR (Fscroll_left);
|
|
5577 DEFSUBR (Fscroll_right);
|
|
5578 DEFSUBR (Fother_window_for_scrolling);
|
|
5579 DEFSUBR (Fscroll_other_window);
|
280
|
5580 DEFSUBR (Fcenter_to_window_line);
|
20
|
5581 DEFSUBR (Fmove_to_window_line);
|
0
|
5582 #ifdef MEMORY_USAGE_STATS
|
20
|
5583 DEFSUBR (Fwindow_memory_usage);
|
0
|
5584 #endif
|
20
|
5585 DEFSUBR (Fwindow_configuration_p);
|
|
5586 DEFSUBR (Fset_window_configuration);
|
|
5587 DEFSUBR (Fcurrent_window_configuration);
|
|
5588 DEFSUBR (Fsave_window_excursion);
|
0
|
5589 }
|
|
5590
|
|
5591 void
|
|
5592 vars_of_window (void)
|
|
5593 {
|
|
5594 /* Make sure all windows get marked */
|
|
5595 minibuf_window = Qnil;
|
|
5596 staticpro (&minibuf_window);
|
|
5597
|
|
5598 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /*
|
|
5599 *Non-nil means to scroll if point lands on a line which is clipped.
|
|
5600 */ );
|
|
5601 scroll_on_clipped_lines = 1;
|
|
5602
|
|
5603 DEFVAR_LISP ("temp-buffer-show-hook", &Vtemp_buffer_show_hook /*
|
|
5604 See `temp-buffer-show-function'.
|
|
5605 */ );
|
|
5606 Vtemp_buffer_show_hook = Qnil;
|
|
5607
|
|
5608 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function /*
|
|
5609 Non-nil means call as function to display a help buffer.
|
|
5610 The function is called with one argument, the buffer to be displayed.
|
|
5611 Used by `with-output-to-temp-buffer'.
|
|
5612 If this function is used, then it must do the entire job of showing
|
|
5613 the buffer; `temp-buffer-show-hook' is not run unless this function runs it.
|
|
5614 */ );
|
|
5615 Vtemp_buffer_show_function = Qnil;
|
|
5616
|
274
|
5617 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuffer_scroll_window /*
|
0
|
5618 Non-nil means it is the window that \\<minibuffer-local-map>\\[scroll-other-window] in minibuffer should scroll.
|
|
5619 */ );
|
274
|
5620 Vminibuffer_scroll_window = Qnil;
|
0
|
5621
|
|
5622 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer /*
|
|
5623 If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window.
|
|
5624 */ );
|
|
5625 Vother_window_scroll_buffer = Qnil;
|
|
5626
|
|
5627 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines /*
|
|
5628 *Number of lines of continuity when scrolling by screenfuls.
|
|
5629 */ );
|
|
5630 next_screen_context_lines = 2;
|
|
5631
|
|
5632 DEFVAR_INT ("window-min-height", &window_min_height /*
|
|
5633 *Delete any window less than this tall (including its modeline).
|
|
5634 */ );
|
|
5635 window_min_height = 4;
|
|
5636
|
|
5637 DEFVAR_INT ("window-min-width", &window_min_width /*
|
|
5638 *Delete any window less than this wide.
|
|
5639 */ );
|
|
5640 window_min_width = 10;
|
|
5641
|
|
5642 {
|
|
5643 int i;
|
|
5644
|
|
5645 for (i = 0; i < countof (Vwindow_configuration_free_list); i++)
|
|
5646 {
|
|
5647 Vwindow_configuration_free_list[i] =
|
|
5648 make_lcrecord_list (sizeof_window_config_for_n_windows (i + 1),
|
|
5649 lrecord_window_configuration);
|
|
5650 staticpro (&Vwindow_configuration_free_list[i]);
|
|
5651 }
|
|
5652 }
|
|
5653 }
|
|
5654
|
|
5655 void
|
|
5656 specifier_vars_of_window (void)
|
|
5657 {
|
|
5658 DEFVAR_SPECIFIER ("modeline-shadow-thickness", &Vmodeline_shadow_thickness /*
|
|
5659 *How thick to draw 3D shadows around modelines.
|
|
5660 If this is set to 0, modelines will be the traditional 2D. Sizes above
|
|
5661 10 will be accepted but the maximum thickness that will be drawn is 10.
|
|
5662 This is a specifier; use `set-specifier' to change it.
|
|
5663 */ );
|
|
5664 Vmodeline_shadow_thickness = Fmake_specifier (Qinteger);
|
|
5665 /* The initial value for modeline-shadow-thickness is 2, but if the
|
|
5666 user removes all specifications we provide a fallback value of 0,
|
|
5667 which is probably what was expected. */
|
|
5668 set_specifier_fallback (Vmodeline_shadow_thickness,
|
|
5669 list1 (Fcons (Qnil, Qzero)));
|
|
5670 Fadd_spec_to_specifier (Vmodeline_shadow_thickness, make_int (2),
|
|
5671 Qnil, Qnil, Qnil);
|
|
5672 set_specifier_caching (Vmodeline_shadow_thickness,
|
|
5673 slot_offset (struct window,
|
|
5674 modeline_shadow_thickness),
|
|
5675 modeline_shadow_thickness_changed,
|
|
5676 0, 0);
|
185
|
5677
|
0
|
5678 DEFVAR_SPECIFIER ("has-modeline-p", &Vhas_modeline_p /*
|
|
5679 *Whether the modeline should be displayed.
|
|
5680 This is a specifier; use `set-specifier' to change it.
|
|
5681 */ );
|
|
5682 Vhas_modeline_p = Fmake_specifier (Qboolean);
|
|
5683 set_specifier_fallback (Vhas_modeline_p,
|
|
5684 list1 (Fcons (Qnil, Qt)));
|
|
5685 set_specifier_caching (Vhas_modeline_p,
|
|
5686 slot_offset (struct window,
|
|
5687 has_modeline_p),
|
|
5688 /* #### It's strange that we need a special
|
|
5689 flag to indicate that the shadow-thickness
|
|
5690 has changed, but not one to indicate that
|
|
5691 the modeline has been turned off or on. */
|
|
5692 some_window_value_changed,
|
|
5693 0, 0);
|
|
5694 }
|