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