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