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