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);
|
|
216 return (Qnil);
|
|
217 }
|
|
218
|
|
219 static void
|
|
220 print_window (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
221 {
|
|
222 char buf[200];
|
|
223
|
|
224 if (print_readably)
|
|
225 error ("printing unreadable object #<window 0x%x>",
|
|
226 XWINDOW (obj)->header.uid);
|
|
227
|
|
228 write_c_string ("#<window", printcharfun);
|
|
229 if (!NILP (XWINDOW (obj)->buffer))
|
|
230 {
|
|
231 Lisp_Object name = XBUFFER (XWINDOW (obj)->buffer)->name;
|
|
232 write_c_string (" on ", printcharfun);
|
|
233 print_internal (name, printcharfun, 1);
|
|
234 }
|
|
235 sprintf (buf, " 0x%x>", XWINDOW (obj)->header.uid);
|
|
236 write_c_string (buf, printcharfun);
|
|
237 }
|
|
238
|
|
239 static void
|
|
240 finalize_window (void *header, int for_disksave)
|
|
241 {
|
|
242 struct window *w = (struct window *) header;
|
|
243
|
|
244 if (w->line_start_cache)
|
|
245 {
|
|
246 Dynarr_free (w->line_start_cache);
|
|
247 w->line_start_cache = 0;
|
|
248 }
|
|
249
|
|
250 if (w->face_cachels)
|
|
251 {
|
|
252 int i;
|
|
253
|
|
254 for (i = 0; i < Dynarr_length (w->face_cachels); i++)
|
|
255 {
|
|
256 struct face_cachel *cachel = Dynarr_atp (w->face_cachels, i);
|
|
257 if (cachel->merged_faces)
|
|
258 {
|
|
259 Dynarr_free (cachel->merged_faces);
|
|
260 cachel->merged_faces = 0;
|
|
261 }
|
|
262 }
|
|
263 Dynarr_free (w->face_cachels);
|
|
264 w->face_cachels = 0;
|
|
265 }
|
|
266
|
|
267 if (w->glyph_cachels)
|
|
268 {
|
|
269 Dynarr_free (w->glyph_cachels);
|
|
270 w->glyph_cachels = 0;
|
|
271 }
|
|
272 }
|
|
273
|
|
274 #define INIT_DISP_VARIABLE(field, initialization) \
|
|
275 p->field[CURRENT_DISP] = initialization; \
|
|
276 p->field[DESIRED_DISP] = initialization; \
|
|
277 p->field[CMOTION_DISP] = initialization;
|
|
278
|
|
279 /* We have an implicit assertion that the first two elements (default
|
|
280 and modeline faces) are always present in the face_element_cache.
|
|
281 Normally redisplay ensures this. However, it is possible for a
|
|
282 window to get created and functions which reference these values
|
|
283 called before redisplay works with the window for the first time.
|
|
284 All callers of allocate_window should therefore call
|
|
285 reset_face_cachels on the created window. We can't do it
|
|
286 here because the window must have its frame pointer set or
|
|
287 reset_face_cachels will fail. */
|
|
288 Lisp_Object
|
|
289 allocate_window (void)
|
|
290 {
|
|
291 Lisp_Object val = Qnil;
|
|
292 struct window *p = alloc_lcrecord (sizeof (struct window),
|
|
293 lrecord_window);
|
|
294
|
|
295 zero_lcrecord (p);
|
|
296 XSETWINDOW (val, p);
|
|
297
|
|
298 p->dead = 0;
|
|
299 p->frame = Qnil;
|
|
300 p->mini_p = Qnil;
|
|
301 p->next = Qnil;
|
|
302 p->prev = Qnil;
|
|
303 p->hchild = Qnil;
|
|
304 p->vchild = Qnil;
|
|
305 p->parent = Qnil;
|
|
306 p->buffer = Qnil;
|
|
307 INIT_DISP_VARIABLE (start, Fmake_marker ());
|
|
308 INIT_DISP_VARIABLE (pointm, Fmake_marker ());
|
|
309 p->sb_point = Fmake_marker ();
|
|
310 p->use_time = Qzero;
|
|
311 INIT_DISP_VARIABLE (last_modified, Qzero);
|
|
312 INIT_DISP_VARIABLE (last_point, Fmake_marker ());
|
|
313 INIT_DISP_VARIABLE (last_start, Fmake_marker ());
|
|
314 INIT_DISP_VARIABLE (last_facechange, Qzero);
|
|
315 p->face_cachels = Dynarr_new (struct face_cachel);
|
|
316 p->glyph_cachels = Dynarr_new (struct glyph_cachel);
|
|
317 p->line_start_cache = Dynarr_new (struct line_start_cache);
|
|
318 p->line_cache_last_updated = Qzero;
|
|
319 INIT_DISP_VARIABLE (last_point_x, 0);
|
|
320 INIT_DISP_VARIABLE (last_point_y, 0);
|
|
321 INIT_DISP_VARIABLE (window_end_pos, 0);
|
|
322 p->redisplay_end_trigger = Qnil;
|
|
323 /* cached specifier values: will get set properly later */
|
|
324 p->display_table = Qnil;
|
|
325 p->has_modeline_p = Qnil;
|
|
326 p->modeline_shadow_thickness = Qnil;
|
|
327 #ifdef HAVE_SCROLLBARS
|
|
328 p->scrollbar_width = Qnil;
|
|
329 p->scrollbar_height = Qnil;
|
|
330 #endif
|
|
331 p->left_margin_width = Qnil;
|
|
332 p->right_margin_width = Qnil;
|
|
333 #ifdef HAVE_TOOLBARS
|
|
334 p->toolbar_size[0] = Qnil;
|
|
335 p->toolbar_size[1] = Qnil;
|
|
336 p->toolbar_size[2] = Qnil;
|
|
337 p->toolbar_size[3] = Qnil;
|
|
338 #endif
|
|
339 p->minimum_line_ascent = Qnil;
|
|
340 p->minimum_line_descent = Qnil;
|
|
341 p->use_left_overflow = Qnil;
|
|
342 p->use_right_overflow = Qnil;
|
|
343 #ifdef HAVE_MENUBARS
|
|
344 p->menubar_visible_p = Qnil;
|
|
345 #endif
|
|
346 #ifdef HAVE_TOOLBARS
|
|
347 p->toolbar_buttons_captioned_p = Qnil;
|
|
348 #endif
|
|
349 p->text_cursor_visible_p = Qnil;
|
|
350 /* end cached specifier values. */
|
|
351
|
|
352 p->dedicated = Qnil;
|
|
353 p->windows_changed = 1;
|
|
354 p->shadow_thickness_changed = 1;
|
|
355
|
|
356 return (val);
|
|
357 }
|
|
358 #undef INIT_DISP_VARIABLE
|
|
359
|
|
360 /*
|
|
361 * The redisplay structures used to be stored with each window. While
|
|
362 * they are logically something associated with frames they can't be
|
|
363 * stored there with a redisplay which handles variable height lines.
|
|
364 * Lines in horizontally split windows might not line up. So they get
|
|
365 * stored with the windows.
|
|
366 *
|
|
367 * The problem with this is window configurations. When restoring a
|
|
368 * window configuration it now becomes problematic to do an
|
|
369 * incremental redisplay. The solution is to store the redisplay
|
|
370 * structures with the frame as they should be but laid out in the
|
|
371 * same manner as the window structure. Thus is born the window
|
|
372 * mirror.
|
|
373 *
|
|
374 * It also becomes a convenient place to stick scrollbar instances
|
|
375 * since they extrapolate out to having the same problem described for
|
|
376 * the display structures.
|
|
377 */
|
|
378
|
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. */
|
|
952 return (margin_cwidth * font_width);
|
|
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 {
|
|
1120 return (WINDOWP (obj) ? Qt : Qnil);
|
|
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 {
|
|
1128 return (WINDOWP (obj) && WINDOW_LIVE_P (XWINDOW (obj)) ? Qt : Qnil);
|
|
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 {
|
102
|
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 {
|
|
1344 return (make_int (decode_window (window)->pixel_height));
|
|
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 {
|
102
|
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 {
|
|
1361 return (make_int (decode_window (window)->pixel_width));
|
|
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 {
|
|
1369 return (make_int (decode_window (window)->hscroll));
|
|
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]);
|
|
1498 return (make_int (end_of_last_line (w, startp)));
|
|
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
|
|
2570 if (type == GET_BUFFER_WINDOW_COUNT)
|
|
2571 return (make_int (count));
|
|
2572 else
|
|
2573 return (best_window);
|
|
2574 }
|
|
2575
|
|
2576 #if 0 /* not currently used */
|
|
2577
|
|
2578 int
|
|
2579 buffer_window_count (struct buffer *b, struct frame *f)
|
|
2580 {
|
|
2581 Lisp_Object buffer, frame;
|
|
2582
|
|
2583 XSETFRAME (frame, f);
|
|
2584 XSETBUFFER (buffer, b);
|
|
2585
|
|
2586 return XINT (window_loop (GET_BUFFER_WINDOW_COUNT, buffer, 0, frame, 1,
|
|
2587 Qnil));
|
|
2588 }
|
|
2589
|
|
2590 int
|
|
2591 buffer_window_mru (struct window *w)
|
|
2592 {
|
|
2593 Lisp_Object window =
|
|
2594 window_loop (GET_BUFFER_MRU_WINDOW, w->buffer, 0, w->frame, 1, Qnil);
|
|
2595
|
|
2596 if (NILP (window))
|
|
2597 return 0;
|
|
2598 else if (XWINDOW (window) == w)
|
|
2599 return 1;
|
|
2600 else
|
|
2601 return 0;
|
|
2602 }
|
|
2603
|
|
2604 #endif
|
|
2605
|
|
2606
|
20
|
2607 DEFUN ("get-lru-window", Fget_lru_window, 0, 2, 0, /*
|
0
|
2608 Return the window least recently selected or used for display.
|
|
2609 If optional argument FRAME is `visible', search all visible frames.
|
|
2610 If FRAME is 0, search all visible and iconified frames.
|
|
2611 If FRAME is t, search all frames.
|
|
2612 If FRAME is nil, search only the selected frame.
|
|
2613 If FRAME is a frame, search only that frame.
|
|
2614
|
|
2615 Optional second argument CONSOLE controls which consoles or devices the
|
|
2616 returned window may be on. If CONSOLE is a console, return windows only
|
|
2617 on that console. If CONSOLE is a device, return windows only on that
|
|
2618 device. If CONSOLE is a console type, return windows only on consoles
|
|
2619 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2620 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2621 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2622 Otherwise, all windows are considered.
|
20
|
2623 */
|
|
2624 (frame, console))
|
0
|
2625 {
|
|
2626 Lisp_Object w;
|
|
2627 /* First try for a non-dedicated window that is full-width */
|
|
2628 w = window_loop (GET_LRU_WINDOW, Qt, 0, frame, 0, console);
|
|
2629 if (!NILP (w) && !EQ (w, Fselected_window (Qnil)))
|
|
2630 return w;
|
|
2631
|
|
2632 /* Then try for any non-dedicated window */
|
|
2633 w = window_loop (GET_LRU_WINDOW, Qnil, 0, frame, 0, console);
|
|
2634 if (!NILP (w) && !EQ (w, Fselected_window (Qnil)))
|
|
2635 return w;
|
|
2636
|
|
2637 #if 0
|
|
2638 /* FSFmacs never returns a dedicated window here. If we do,
|
|
2639 it makes `display-buffer' not work right. #### All of this
|
|
2640 shit is so disgusting and awful that it needs to be rethought
|
|
2641 from scratch. */
|
|
2642 /* then try for a dedicated window that is full-width */
|
|
2643 w = window_loop (GET_LRU_WINDOW, Qt, 0, frame, 1, console);
|
|
2644 if (!NILP (w) && !EQ (w, Fselected_window (Qnil)))
|
|
2645 return w;
|
|
2646
|
|
2647 /* If none of them, then all windows, dedicated or not. */
|
|
2648 w = window_loop (GET_LRU_WINDOW, Qnil, 0, frame, 1, console);
|
|
2649
|
|
2650 /* At this point we damn well better have found something. */
|
|
2651 if (NILP (w)) abort ();
|
|
2652 #endif
|
|
2653
|
|
2654 return (w);
|
|
2655 }
|
|
2656
|
20
|
2657 DEFUN ("get-largest-window", Fget_largest_window, 0, 2, 0, /*
|
0
|
2658 Return the window largest in area.
|
|
2659 If optional argument FRAME is `visible', search all visible frames.
|
|
2660 If FRAME is 0, search all visible and iconified frames.
|
|
2661 If FRAME is t, search all frames.
|
|
2662 If FRAME is nil, search only the selected frame.
|
|
2663 If FRAME is a frame, search only that frame.
|
|
2664
|
|
2665 Optional second argument CONSOLE controls which consoles or devices the
|
|
2666 returned window may be on. If CONSOLE is a console, return windows only
|
|
2667 on that console. If CONSOLE is a device, return windows only on that
|
|
2668 device. If CONSOLE is a console type, return windows only on consoles
|
|
2669 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2670 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2671 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2672 Otherwise, all windows are considered.
|
20
|
2673 */
|
|
2674 (frame, console))
|
0
|
2675 {
|
|
2676 /* Don't search dedicated windows because FSFmacs doesn't.
|
|
2677 This stuff is all black magic so don't try to apply common
|
|
2678 sense to it. */
|
|
2679 return window_loop (GET_LARGEST_WINDOW, Qnil, 0, frame, 0, console);
|
|
2680 }
|
|
2681
|
20
|
2682 DEFUN ("get-buffer-window", Fget_buffer_window, 1, 3, 0, /*
|
0
|
2683 Return a window currently displaying BUFFER, or nil if none.
|
|
2684 If optional argument FRAME is `visible', search all visible frames.
|
|
2685 If optional argument FRAME is 0, search all visible and iconified frames.
|
|
2686 If FRAME is t, search all frames.
|
|
2687 If FRAME is nil, search only the selected frame.
|
|
2688 If FRAME is a frame, search only that frame.
|
|
2689
|
|
2690 Optional third argument CONSOLE controls which consoles or devices the
|
|
2691 returned window may be on. If CONSOLE is a console, return windows only
|
|
2692 on that console. If CONSOLE is a device, return windows only on that
|
|
2693 device. If CONSOLE is a console type, return windows only on consoles
|
|
2694 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2695 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2696 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2697 Otherwise, all windows are considered.
|
20
|
2698 */
|
|
2699 (buffer, frame, console))
|
0
|
2700 {
|
|
2701 buffer = Fget_buffer (buffer);
|
|
2702 if (BUFFERP (buffer))
|
|
2703 /* Search dedicated windows too. (Doesn't matter here anyway.) */
|
|
2704 return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame, 1, console);
|
|
2705 else
|
|
2706 return Qnil;
|
|
2707 }
|
|
2708
|
|
2709 /* These functions used to be `buffer-left-margin-pixel-width', etc.
|
|
2710 but there is no sensible way to implement those functions, since
|
|
2711 you can't in general derive a window from a buffer. */
|
|
2712
|
20
|
2713 DEFUN ("window-left-margin-pixel-width",
|
|
2714 Fwindow_left_margin_pixel_width, 0, 1, 0, /*
|
0
|
2715 Return the width in pixels of the left outside margin of window WINDOW.
|
|
2716 If WINDOW is nil, the selected window is assumed.
|
20
|
2717 */
|
|
2718 (window))
|
0
|
2719 {
|
149
|
2720 return make_int (window_left_margin_width (decode_window (window)));
|
0
|
2721 }
|
|
2722
|
20
|
2723 DEFUN ("window-right-margin-pixel-width",
|
|
2724 Fwindow_right_margin_pixel_width, 0, 1, 0, /*
|
0
|
2725 Return the width in pixels of the right outside margin of window WINDOW.
|
|
2726 If WINDOW is nil, the selected window is assumed.
|
20
|
2727 */
|
|
2728 (window))
|
0
|
2729 {
|
149
|
2730 return make_int (window_right_margin_width (decode_window (window)));
|
0
|
2731 }
|
|
2732
|
20
|
2733 DEFUN ("delete-other-windows", Fdelete_other_windows, 0, 1, "", /*
|
0
|
2734 Make WINDOW (or the selected window) fill its frame.
|
|
2735 Only the frame WINDOW is on is affected.
|
|
2736 This function tries to reduce display jumps
|
|
2737 by keeping the text previously visible in WINDOW
|
|
2738 in the same place on the frame. Doing this depends on
|
|
2739 the value of (window-start WINDOW), so if calling this function
|
|
2740 in a program gives strange scrolling, make sure the window-start
|
|
2741 value is reasonable when this function is called.
|
20
|
2742 */
|
|
2743 (window))
|
0
|
2744 {
|
|
2745 struct window *w = decode_window (window);
|
|
2746 struct buffer *b = XBUFFER (w->buffer);
|
|
2747 Bufpos start_pos;
|
|
2748 int old_top = WINDOW_TOP (w);
|
|
2749
|
|
2750 XSETWINDOW (window, w);
|
|
2751
|
|
2752 if (MINI_WINDOW_P (w) && old_top > 0)
|
|
2753 error ("Can't expand minibuffer to full frame");
|
|
2754
|
|
2755 /* Ignore dedicated windows. */
|
|
2756 window_loop (DELETE_OTHER_WINDOWS, window, 0, w->frame, 0, Qnil);
|
|
2757
|
|
2758 start_pos = marker_position (w->start[CURRENT_DISP]);
|
|
2759
|
|
2760 /* Try to minimize scrolling, by setting the window start to the
|
|
2761 point which will cause the text at the old window start to be at
|
|
2762 the same place on the frame. But don't try to do this if the
|
|
2763 window start is outside the visible portion (as might happen when
|
|
2764 the display is not current, due to typeahead). */
|
|
2765 if (start_pos >= BUF_BEGV (b) && start_pos <= BUF_ZV (b)
|
|
2766 && !MINI_WINDOW_P (w))
|
|
2767 {
|
|
2768 Bufpos new_start = start_with_line_at_pixpos (w, start_pos, old_top);
|
|
2769
|
|
2770 if (new_start >= BUF_BEGV (b) && new_start <= BUF_ZV (b))
|
|
2771 {
|
|
2772 Fset_marker (w->start[CURRENT_DISP], make_int (new_start),
|
|
2773 w->buffer);
|
|
2774 w->start_at_line_beg = beginning_of_line_p (b, new_start);
|
|
2775 }
|
|
2776 /* We need to do this, so that the window-scroll-functions
|
|
2777 get called. */
|
|
2778 w->force_start = 1;
|
|
2779 }
|
|
2780
|
|
2781 return Qnil;
|
|
2782 }
|
|
2783
|
20
|
2784 DEFUN ("delete-windows-on", Fdelete_windows_on, 1, 3,
|
|
2785 "bDelete windows on (buffer): ", /*
|
0
|
2786 Delete all windows showing BUFFER.
|
|
2787 Optional second argument FRAME controls which frames are affected.
|
|
2788 If nil or omitted, delete all windows showing BUFFER in any frame.
|
|
2789 If t, delete only windows showing BUFFER in the selected frame.
|
|
2790 If `visible', delete all windows showing BUFFER in any visible frame.
|
|
2791 If a frame, delete only windows showing BUFFER in that frame.
|
|
2792
|
|
2793 Optional third argument CONSOLE controls which consoles or devices the
|
|
2794 returned window may be on. If CONSOLE is a console, return windows only
|
|
2795 on that console. If CONSOLE is a device, return windows only on that
|
|
2796 device. If CONSOLE is a console type, return windows only on consoles
|
|
2797 of that type. If CONSOLE is 'window-system, return any windows on any
|
|
2798 window-system consoles. If CONSOLE is nil or omitted, return windows only
|
|
2799 on FRAME'S console, or on the selected console if FRAME is not a frame.
|
|
2800 Otherwise, all windows are considered.
|
20
|
2801 */
|
|
2802 (buffer, frame, console))
|
0
|
2803 {
|
|
2804 /* This function can GC */
|
|
2805 /* FRAME uses t and nil to mean the opposite of what window_loop
|
|
2806 expects. */
|
|
2807 if (!FRAMEP (frame))
|
|
2808 frame = NILP (frame) ? Qt : Qnil;
|
|
2809
|
|
2810 if (!NILP (buffer))
|
|
2811 {
|
|
2812 buffer = Fget_buffer (buffer);
|
|
2813 CHECK_BUFFER (buffer);
|
|
2814 /* Ignore dedicated windows. */
|
|
2815 window_loop (DELETE_BUFFER_WINDOWS, buffer, 0, frame, 0, console);
|
|
2816 }
|
|
2817 return Qnil;
|
|
2818 }
|
|
2819
|
20
|
2820 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, 1, 1,
|
|
2821 "bReplace buffer in windows: ", /*
|
0
|
2822 Replace BUFFER with some other buffer in all windows showing it.
|
20
|
2823 */
|
|
2824 (buffer))
|
0
|
2825 {
|
|
2826 /* This function can GC */
|
|
2827 if (!NILP (buffer))
|
|
2828 {
|
|
2829 buffer = Fget_buffer (buffer);
|
|
2830 CHECK_BUFFER (buffer);
|
|
2831 /* Ignore dedicated windows. */
|
|
2832 window_loop (UNSHOW_BUFFER, buffer, 0, Qt, 0, Qnil);
|
|
2833 }
|
|
2834 return Qnil;
|
|
2835 }
|
|
2836
|
|
2837 /* The smallest acceptable dimensions for a window. Anything smaller
|
|
2838 might crash Emacs. */
|
|
2839 #define MIN_SAFE_WINDOW_WIDTH (2)
|
|
2840 #define MIN_SAFE_WINDOW_HEIGHT (2)
|
|
2841
|
|
2842 /* Make sure that window_min_height and window_min_width are
|
|
2843 not too small; if they are, set them to safe minima. */
|
|
2844
|
|
2845 static void
|
|
2846 check_min_window_sizes (void)
|
|
2847 {
|
|
2848 /* Smaller values might permit a crash. */
|
|
2849 if (window_min_width < MIN_SAFE_WINDOW_WIDTH)
|
|
2850 window_min_width = MIN_SAFE_WINDOW_WIDTH;
|
|
2851 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT)
|
|
2852 window_min_height = MIN_SAFE_WINDOW_HEIGHT;
|
|
2853 }
|
|
2854
|
|
2855 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
|
|
2856 minimum allowable size. */
|
|
2857 void
|
|
2858 check_frame_size (struct frame *frame, int *rows, int *cols)
|
|
2859 {
|
|
2860 /* For height, we have to see whether the frame has a minibuffer, and
|
|
2861 whether it wants a modeline. */
|
|
2862 int min_height =
|
|
2863 (FRAME_MINIBUF_ONLY_P (frame) ? MIN_SAFE_WINDOW_HEIGHT - 1
|
|
2864 : (! FRAME_HAS_MINIBUF_P (frame)) ? MIN_SAFE_WINDOW_HEIGHT
|
|
2865 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1);
|
|
2866
|
|
2867 if (*rows < min_height)
|
|
2868 *rows = min_height;
|
|
2869 if (*cols < MIN_SAFE_WINDOW_WIDTH)
|
|
2870 *cols = MIN_SAFE_WINDOW_WIDTH;
|
|
2871 }
|
|
2872
|
|
2873 /* Normally the window is deleted if it gets too small.
|
|
2874 nodelete nonzero means do not do this.
|
|
2875 (The caller should check later and do so if appropriate) */
|
|
2876 static void
|
|
2877 set_window_pixsize (Lisp_Object window, int new_pixsize, int nodelete,
|
|
2878 int set_height)
|
|
2879 {
|
|
2880 struct window *w = XWINDOW (window);
|
|
2881 struct frame *f = XFRAME (w->frame);
|
|
2882 struct window *c;
|
|
2883 int old_pixsize = (set_height ? WINDOW_HEIGHT (w) : WINDOW_WIDTH (w));
|
|
2884 Lisp_Object child, minor_kid, major_kid;
|
|
2885 int minsize;
|
|
2886 int line_size;
|
|
2887 int defheight, defwidth;
|
|
2888
|
|
2889 /* #### This is very likely incorrect and instead the char_to_pixel_
|
|
2890 functions should be called. */
|
|
2891 default_face_height_and_width (window, &defheight, &defwidth);
|
|
2892 line_size = (set_height ? defheight : defwidth);
|
|
2893
|
|
2894 minsize = (set_height ? window_min_height : window_min_width);
|
|
2895 minsize *= line_size;
|
|
2896
|
|
2897 check_min_window_sizes ();
|
|
2898
|
|
2899 if (!nodelete
|
|
2900 && !TOP_LEVEL_WINDOW_P (w)
|
|
2901 && new_pixsize < minsize)
|
|
2902 {
|
|
2903 Fdelete_window (window, Qnil);
|
|
2904 return;
|
|
2905 }
|
|
2906
|
|
2907 SET_LAST_MODIFIED (w, 0);
|
|
2908 SET_LAST_FACECHANGE (w);
|
|
2909 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); /* multiple windows affected */
|
|
2910 if (set_height)
|
|
2911 {
|
|
2912 WINDOW_HEIGHT (w) = new_pixsize;
|
|
2913 major_kid = w->vchild;
|
|
2914 minor_kid = w->hchild;
|
|
2915 }
|
|
2916 else
|
|
2917 {
|
|
2918 WINDOW_WIDTH (w) = new_pixsize;
|
|
2919 major_kid = w->hchild;
|
|
2920 minor_kid = w->vchild;
|
|
2921 }
|
|
2922
|
|
2923 if (!NILP (minor_kid))
|
|
2924 {
|
|
2925 for (child = minor_kid; !NILP (child); child = XWINDOW (child)->next)
|
|
2926 {
|
|
2927 if (set_height)
|
|
2928 WINDOW_TOP (XWINDOW (child)) = WINDOW_TOP (w);
|
|
2929 else
|
|
2930 WINDOW_LEFT (XWINDOW (child)) = WINDOW_LEFT (w);
|
|
2931
|
|
2932 set_window_pixsize (child, new_pixsize, nodelete, set_height);
|
|
2933 }
|
|
2934 }
|
|
2935 else if (!NILP (major_kid))
|
|
2936 {
|
|
2937 int last_pos, last_old_pos, pos, old_pos, first;
|
|
2938 int pixel_adj_left = new_pixsize - old_pixsize;
|
|
2939 int div_val = old_pixsize << 1;
|
|
2940
|
|
2941 /* Sometimes we may get called with our old size. In that case
|
|
2942 we don't need to do anything. */
|
|
2943 if (!pixel_adj_left)
|
|
2944 return;
|
|
2945
|
|
2946 last_pos = first = (set_height ? WINDOW_TOP (w) : WINDOW_LEFT (w));
|
|
2947 last_old_pos = 0;
|
|
2948
|
|
2949 for (child = major_kid; !NILP (child); child = c->next)
|
|
2950 {
|
|
2951 c = XWINDOW (child);
|
|
2952
|
|
2953 if (set_height)
|
|
2954 {
|
|
2955 old_pos = last_old_pos + WINDOW_HEIGHT (c);
|
|
2956 WINDOW_TOP (c) = last_pos;
|
|
2957 }
|
|
2958 else
|
|
2959 {
|
|
2960 old_pos = last_old_pos + WINDOW_WIDTH (c);
|
|
2961 WINDOW_LEFT (c) = last_pos;
|
|
2962 }
|
|
2963
|
|
2964 pos = (((old_pos * new_pixsize) << 1) + old_pixsize) / div_val;
|
2
|
2965 /* All but the last window should have a height which is
|
0
|
2966 a multiple of the default line height. */
|
|
2967 if (!NILP (c->next))
|
|
2968 pos = (pos / line_size) * line_size;
|
|
2969
|
|
2970 /* Avoid confusion: don't delete child if it becomes too small */
|
|
2971 set_window_pixsize (child, pos + first - last_pos, 1, set_height);
|
|
2972
|
|
2973 last_pos = pos + first;
|
|
2974 last_old_pos = old_pos;
|
|
2975 }
|
|
2976
|
|
2977 /* Now delete any children that became too small. */
|
|
2978 if (!nodelete)
|
|
2979 for (child = major_kid; !NILP (child); child = XWINDOW (child)->next)
|
|
2980 {
|
|
2981 if (set_height)
|
|
2982 set_window_pixheight (child, WINDOW_HEIGHT (XWINDOW (child)), 0);
|
|
2983 else
|
|
2984 set_window_pixwidth (child, WINDOW_WIDTH (XWINDOW (child)), 0);
|
|
2985 }
|
|
2986 }
|
|
2987 }
|
|
2988
|
|
2989 /* Set the height of WINDOW and all its inferiors. */
|
|
2990 void
|
|
2991 set_window_pixheight (Lisp_Object window, int new_pixheight, int nodelete)
|
|
2992 {
|
|
2993 set_window_pixsize (window, new_pixheight, nodelete, 1);
|
|
2994 }
|
|
2995
|
|
2996 /* Recursively set width of WINDOW and its inferiors. */
|
|
2997 void
|
|
2998 set_window_pixwidth (Lisp_Object window, int new_pixwidth, int nodelete)
|
|
2999 {
|
|
3000 set_window_pixsize (window, new_pixwidth, nodelete, 0);
|
|
3001 }
|
|
3002
|
|
3003
|
|
3004 static int window_select_count;
|
|
3005
|
20
|
3006 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 2, 0, /*
|
0
|
3007 Make WINDOW display BUFFER as its contents.
|
|
3008 BUFFER can be a buffer or buffer name.
|
20
|
3009 */
|
|
3010 (window, buffer))
|
0
|
3011 {
|
|
3012 Lisp_Object tem;
|
|
3013 struct window *w = decode_window (window);
|
|
3014
|
|
3015 buffer = Fget_buffer (buffer);
|
|
3016 CHECK_BUFFER (buffer);
|
|
3017
|
|
3018 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
|
|
3019 error ("Attempt to display deleted buffer");
|
|
3020
|
|
3021 tem = w->buffer;
|
|
3022 if (NILP (tem))
|
|
3023 error ("Window is deleted");
|
|
3024
|
|
3025 /* While this seems like a logical thing to do, it causes problems
|
|
3026 because of saved window configurations. It is possible for a
|
|
3027 buffer to get restored into a window in which it is already being
|
|
3028 displayed, but start and point are actually at completely
|
|
3029 different locations. So we let this function complete fully and
|
|
3030 it will then make sure redisplay correctly updates things.
|
|
3031
|
|
3032 #### This is a kludge. The correct approach is not to do this
|
|
3033 but to fix set-window-configuration. */
|
|
3034 #if 0
|
|
3035 else if (EQ (tem, buffer))
|
149
|
3036 return Qnil;
|
0
|
3037 #endif
|
|
3038 else if (! EQ (tem, Qt)) /* w->buffer is t when the window
|
|
3039 is first being set up. */
|
|
3040 {
|
|
3041 if (!NILP (w->dedicated) && !EQ (tem, buffer))
|
|
3042 error ("Window is dedicated to buffer %s",
|
16
|
3043 XSTRING_DATA (XBUFFER (tem)->name));
|
0
|
3044
|
|
3045 unshow_buffer (w);
|
|
3046 }
|
|
3047
|
|
3048 w->buffer = buffer;
|
|
3049 w->window_end_pos[CURRENT_DISP] = 0;
|
|
3050 w->hscroll = 0;;
|
|
3051 Fset_marker (w->pointm[CURRENT_DISP],
|
|
3052 make_int (BUF_PT (XBUFFER (buffer))),
|
|
3053 buffer);
|
|
3054 set_marker_restricted (w->start[CURRENT_DISP],
|
|
3055 make_int (XBUFFER (buffer)->last_window_start),
|
|
3056 buffer);
|
|
3057 Fset_marker (w->sb_point, w->start[CURRENT_DISP], buffer);
|
|
3058 w->start_at_line_beg = 0;
|
|
3059 w->force_start = 0; /* Lucid fix */
|
|
3060 SET_LAST_MODIFIED (w, 1);
|
|
3061 SET_LAST_FACECHANGE (w);
|
|
3062 MARK_WINDOWS_CHANGED (w);
|
|
3063 recompute_all_cached_specifiers_in_window (w);
|
|
3064 if (EQ (window, Fselected_window (Qnil)))
|
|
3065 {
|
|
3066 Fset_buffer (buffer);
|
|
3067 #ifdef ENERGIZE
|
|
3068 energize_buffer_shown_hook (w);
|
|
3069 #endif
|
|
3070 }
|
|
3071 return Qnil;
|
|
3072 }
|
|
3073
|
20
|
3074 DEFUN ("select-window", Fselect_window, 1, 1, 0, /*
|
0
|
3075 Select WINDOW. Most editing will apply to WINDOW's buffer.
|
|
3076 The main editor command loop selects the buffer of the selected window
|
|
3077 before each command.
|
20
|
3078 */
|
|
3079 (window))
|
0
|
3080 {
|
|
3081 struct window *w;
|
|
3082 Lisp_Object old_selected_window = Fselected_window (Qnil);
|
|
3083
|
|
3084 CHECK_LIVE_WINDOW (window);
|
|
3085 w = XWINDOW (window);
|
|
3086
|
|
3087 /* we have already caught dead-window errors */
|
|
3088 if (!NILP (w->hchild) || !NILP (w->vchild))
|
|
3089 error ("Trying to select non-leaf window");
|
|
3090
|
|
3091 w->use_time = make_int (++window_select_count);
|
|
3092 if (EQ (window, old_selected_window))
|
|
3093 return window;
|
|
3094
|
|
3095 /* deselect the old window, if it exists (it might not exist if
|
|
3096 the selected device has no frames, which occurs at startup) */
|
|
3097 if (!NILP (old_selected_window))
|
|
3098 {
|
|
3099 struct window *ow = XWINDOW (old_selected_window);
|
|
3100
|
|
3101 #ifdef ENERGIZE
|
|
3102 if (! MINI_WINDOW_P (w))
|
|
3103 energize_window_deselected_hook (ow);
|
|
3104 #endif
|
|
3105
|
|
3106 Fset_marker (ow->pointm[CURRENT_DISP],
|
|
3107 make_int (BUF_PT (XBUFFER (ow->buffer))),
|
|
3108 ow->buffer);
|
|
3109
|
|
3110 MARK_WINDOWS_CHANGED (ow);
|
|
3111 }
|
|
3112
|
|
3113 /* now select the window's frame */
|
|
3114 set_frame_selected_window (XFRAME (WINDOW_FRAME (w)), window);
|
|
3115
|
|
3116 select_frame_1 (WINDOW_FRAME (w));
|
|
3117
|
|
3118 /* also select the window's buffer */
|
|
3119 Frecord_buffer (w->buffer);
|
|
3120 Fset_buffer (w->buffer);
|
|
3121
|
|
3122 /* Go to the point recorded in the window.
|
|
3123 This is important when the buffer is in more
|
|
3124 than one window. It also matters when
|
|
3125 redisplay_window has altered point after scrolling,
|
|
3126 because it makes the change only in the window. */
|
|
3127 {
|
|
3128 Bufpos new_point = marker_position (w->pointm[CURRENT_DISP]);
|
|
3129 if (new_point < BUF_BEGV (current_buffer))
|
|
3130 new_point = BUF_BEGV (current_buffer);
|
|
3131 else if (new_point > BUF_ZV (current_buffer))
|
|
3132 new_point = BUF_ZV (current_buffer);
|
|
3133
|
|
3134 BUF_SET_PT (current_buffer, new_point);
|
|
3135 }
|
|
3136
|
|
3137 MARK_WINDOWS_CHANGED (w);
|
|
3138
|
|
3139 #ifdef ENERGIZE
|
|
3140 if (! MINI_WINDOW_P (w))
|
|
3141 energize_window_selected_hook (w);
|
|
3142 #endif
|
|
3143
|
|
3144 return window;
|
|
3145 }
|
|
3146
|
|
3147 Lisp_Object
|
|
3148 display_buffer (Lisp_Object buffer, Lisp_Object not_this_window_p,
|
|
3149 Lisp_Object override_frame)
|
|
3150 {
|
|
3151 return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame);
|
|
3152 }
|
|
3153
|
|
3154 void
|
|
3155 temp_output_buffer_show (Lisp_Object buf, Lisp_Object same_frame)
|
|
3156 {
|
|
3157 /* This function can GC */
|
|
3158 Lisp_Object window;
|
|
3159 struct window *w;
|
|
3160 struct buffer *b = XBUFFER (buf);
|
|
3161
|
|
3162 BUF_SAVE_MODIFF (XBUFFER (buf)) = BUF_MODIFF (b);
|
|
3163 widen_buffer (b, 0);
|
|
3164 BUF_SET_PT (b, BUF_BEG (b));
|
|
3165
|
|
3166 if (!EQ (Vtemp_buffer_show_function, Qnil))
|
|
3167 call1 (Vtemp_buffer_show_function, buf);
|
|
3168 else
|
|
3169 {
|
|
3170 window = display_buffer (buf, Qnil, same_frame);
|
|
3171
|
|
3172 if (!EQ (XWINDOW (window)->frame, Fselected_frame (Qnil)))
|
|
3173 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
|
|
3174
|
|
3175 Vminibuf_scroll_window = window;
|
|
3176 w = XWINDOW (window);
|
|
3177 w->hscroll = 0;
|
|
3178 set_marker_restricted (w->start[CURRENT_DISP], make_int (1), buf);
|
|
3179 set_marker_restricted (w->pointm[CURRENT_DISP], make_int (1), buf);
|
|
3180 set_marker_restricted (w->sb_point, make_int (1), buf);
|
|
3181
|
|
3182 /* Run temp-buffer-show-hook, with the chosen window selected. */
|
|
3183 if (!preparing_for_armageddon)
|
|
3184 {
|
|
3185 Lisp_Object tem;
|
|
3186 tem = Fboundp (Qtemp_buffer_show_hook);
|
|
3187 if (!NILP (tem))
|
|
3188 {
|
|
3189 tem = Fsymbol_value (Qtemp_buffer_show_hook);
|
|
3190 if (!NILP (tem))
|
|
3191 {
|
|
3192 int count = specpdl_depth ();
|
|
3193
|
|
3194 /* Select the window that was chosen, for running
|
|
3195 the hook. */
|
|
3196 record_unwind_protect (save_window_excursion_unwind,
|
|
3197 Fcurrent_window_configuration (Qnil));
|
|
3198
|
|
3199 Fselect_window (window);
|
|
3200 run_hook (Qtemp_buffer_show_hook);
|
|
3201 unbind_to (count, Qnil);
|
|
3202 }
|
|
3203 }
|
|
3204 }
|
|
3205 }
|
|
3206 }
|
|
3207
|
|
3208 static void
|
|
3209 make_dummy_parent (Lisp_Object window)
|
|
3210 {
|
|
3211 Lisp_Object new = Qnil;
|
|
3212 struct window *o = XWINDOW (window);
|
|
3213 struct window *p = alloc_lcrecord (sizeof (struct window),
|
|
3214 lrecord_window);
|
|
3215
|
|
3216 XSETWINDOW (new, p);
|
|
3217 copy_lcrecord (p, o);
|
|
3218
|
|
3219 /* Don't copy the pointers to the line start cache or the face
|
|
3220 instances. */
|
|
3221 p->line_start_cache = Dynarr_new (struct line_start_cache);
|
|
3222 p->face_cachels = Dynarr_new (struct face_cachel);
|
|
3223 p->glyph_cachels = Dynarr_new (struct glyph_cachel);
|
|
3224
|
|
3225 /* Put new into window structure in place of window */
|
|
3226 replace_window (window, new);
|
|
3227
|
|
3228 o->next = Qnil;
|
|
3229 o->prev = Qnil;
|
|
3230 o->vchild = Qnil;
|
|
3231 o->hchild = Qnil;
|
|
3232 o->parent = new;
|
|
3233
|
|
3234 p->start[CURRENT_DISP] = Qnil;
|
|
3235 p->start[DESIRED_DISP] = Qnil;
|
|
3236 p->start[CMOTION_DISP] = Qnil;
|
|
3237 p->pointm[CURRENT_DISP] = Qnil;
|
|
3238 p->pointm[DESIRED_DISP] = Qnil;
|
|
3239 p->pointm[CMOTION_DISP] = Qnil;
|
|
3240 p->sb_point = Qnil;
|
|
3241 p->buffer = Qnil;
|
|
3242 }
|
|
3243
|
20
|
3244 DEFUN ("split-window", Fsplit_window, 0, 3, "", /*
|
0
|
3245 Split WINDOW, putting SIZE lines in the first of the pair.
|
|
3246 WINDOW defaults to selected one and SIZE to half its size.
|
|
3247 If optional third arg HOR-FLAG is non-nil, split side by side
|
|
3248 and put SIZE columns in the first of the pair.
|
20
|
3249 */
|
|
3250 (window, chsize, horflag))
|
0
|
3251 {
|
|
3252 Lisp_Object new;
|
|
3253 struct window *o, *p;
|
|
3254 struct frame *f;
|
|
3255 int size;
|
|
3256 int psize;
|
|
3257
|
|
3258 if (NILP (window))
|
|
3259 window = Fselected_window (Qnil);
|
|
3260 else
|
|
3261 CHECK_WINDOW (window);
|
|
3262
|
|
3263 o = XWINDOW (window);
|
|
3264 f = XFRAME (WINDOW_FRAME (o));
|
|
3265
|
|
3266 if (NILP (chsize))
|
|
3267 {
|
|
3268 if (!NILP (horflag))
|
|
3269 /* In the new scheme, we are symmetric with respect to separators
|
|
3270 so there is no need to do weird things here. */
|
|
3271 {
|
|
3272 psize = WINDOW_WIDTH (o) >> 1;
|
|
3273 size = window_pixel_width_to_char_width (o, psize, 0);
|
|
3274 }
|
|
3275 else
|
|
3276 {
|
|
3277 psize = WINDOW_HEIGHT (o) >> 1;
|
|
3278 size = window_pixel_height_to_char_height (o, psize, 1);
|
|
3279 }
|
|
3280 }
|
|
3281 else
|
|
3282 {
|
|
3283 CHECK_INT (chsize);
|
|
3284 size = XINT (chsize);
|
|
3285 if (!NILP (horflag))
|
|
3286 psize = window_char_width_to_pixel_width (o, size, 0);
|
|
3287 else
|
|
3288 psize = window_char_height_to_pixel_height (o, size, 1);
|
|
3289 }
|
|
3290
|
|
3291 if (MINI_WINDOW_P (o))
|
|
3292 error ("Attempt to split minibuffer window");
|
|
3293 else if (FRAME_NO_SPLIT_P (XFRAME (WINDOW_FRAME (o))))
|
|
3294 error ("Attempt to split unsplittable frame");
|
|
3295
|
|
3296 check_min_window_sizes ();
|
|
3297
|
|
3298 if (NILP (horflag))
|
|
3299 {
|
|
3300 if (size < window_min_height)
|
|
3301 error ("Window height %d too small (after splitting)", size);
|
|
3302 if (size + window_min_height > window_char_height (o, 1))
|
|
3303 error ("Window height %d too small (after splitting)",
|
|
3304 window_char_height (o, 1) - size);
|
|
3305 if (NILP (o->parent)
|
|
3306 || NILP (XWINDOW (o->parent)->vchild))
|
|
3307 {
|
|
3308 make_dummy_parent (window);
|
|
3309 reset_face_cachels (XWINDOW (window));
|
|
3310 new = o->parent;
|
|
3311 XWINDOW (new)->vchild = window;
|
|
3312 XFRAME (o->frame)->mirror_dirty = 1;
|
|
3313 }
|
|
3314 }
|
|
3315 else
|
|
3316 {
|
|
3317 if (size < window_min_width)
|
|
3318 error ("Window width %d too small (after splitting)", size);
|
|
3319 if (size + window_min_width > window_char_width (o, 0))
|
|
3320 error ("Window width %d too small (after splitting)",
|
|
3321 window_char_width (o, 0) - size);
|
|
3322 if (NILP (o->parent)
|
|
3323 || NILP (XWINDOW (o->parent)->hchild))
|
|
3324 {
|
|
3325 make_dummy_parent (window);
|
|
3326 reset_face_cachels (XWINDOW (window));
|
|
3327 new = o->parent;
|
|
3328 XWINDOW (new)->hchild = window;
|
|
3329 XFRAME (o->frame)->mirror_dirty = 1;
|
|
3330 }
|
|
3331 }
|
|
3332
|
|
3333 /* Now we know that window's parent is a vertical combination
|
|
3334 if we are dividing vertically, or a horizontal combination
|
|
3335 if we are making side-by-side windows */
|
|
3336
|
|
3337 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
3338 new = allocate_window ();
|
|
3339 p = XWINDOW (new);
|
|
3340
|
|
3341 p->frame = o->frame;
|
|
3342 p->next = o->next;
|
|
3343 if (!NILP (p->next))
|
|
3344 XWINDOW (p->next)->prev = new;
|
|
3345 p->prev = window;
|
|
3346 o->next = new;
|
|
3347 p->parent = o->parent;
|
|
3348 p->buffer = Qt;
|
|
3349
|
|
3350 reset_face_cachels (p);
|
|
3351 reset_glyph_cachels (p);
|
|
3352
|
|
3353
|
|
3354 /* Apportion the available frame space among the two new windows */
|
|
3355
|
|
3356 if (!NILP (horflag))
|
|
3357 {
|
|
3358 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o);
|
|
3359 WINDOW_TOP (p) = WINDOW_TOP (o);
|
|
3360 WINDOW_WIDTH (p) = WINDOW_WIDTH (o) - psize;
|
|
3361 WINDOW_WIDTH (o) = psize;
|
|
3362 WINDOW_LEFT (p) = WINDOW_LEFT (o) + psize;
|
|
3363 }
|
|
3364 else
|
|
3365 {
|
|
3366 WINDOW_LEFT (p) = WINDOW_LEFT (o);
|
|
3367 WINDOW_WIDTH (p) = WINDOW_WIDTH (o);
|
|
3368 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (o) - psize;
|
|
3369 WINDOW_HEIGHT (o) = psize;
|
|
3370 WINDOW_TOP (p) = WINDOW_TOP (o) + psize;
|
|
3371 }
|
|
3372
|
|
3373 XFRAME (p->frame)->mirror_dirty = 1;
|
|
3374 /* do this last (after the window is completely initialized and
|
|
3375 the mirror-dirty flag is set) so that specifier recomputation
|
|
3376 caused as a result of this will work properly and not abort. */
|
|
3377 Fset_window_buffer (new, o->buffer);
|
|
3378 return new;
|
|
3379 }
|
|
3380
|
|
3381
|
20
|
3382 DEFUN ("enlarge-window", Fenlarge_window, 1, 3, "_p", /*
|
0
|
3383 Make the selected window ARG lines bigger.
|
|
3384 From program, optional second arg non-nil means grow sideways ARG columns,
|
|
3385 and optional third ARG specifies the window to change instead of the
|
|
3386 selected window.
|
20
|
3387 */
|
|
3388 (n, side, window))
|
0
|
3389 {
|
|
3390 struct window *w = decode_window (window);
|
|
3391 CHECK_INT (n);
|
|
3392 change_window_height (w, XINT (n), !NILP (side));
|
|
3393 return Qnil;
|
|
3394 }
|
|
3395
|
20
|
3396 DEFUN ("shrink-window", Fshrink_window, 1, 3, "_p", /*
|
0
|
3397 Make the selected window ARG lines smaller.
|
|
3398 From program, optional second arg non-nil means shrink sideways ARG columns,
|
|
3399 and optional third ARG specifies the window to change instead of the
|
|
3400 selected window.
|
20
|
3401 */
|
|
3402 (n, side, window))
|
0
|
3403 {
|
|
3404 CHECK_INT (n);
|
149
|
3405 change_window_height (decode_window (window), -XINT (n), !NILP (side));
|
0
|
3406 return Qnil;
|
|
3407 }
|
|
3408
|
|
3409 static int
|
|
3410 window_pixel_height (Lisp_Object window)
|
|
3411 {
|
149
|
3412 return WINDOW_HEIGHT (XWINDOW (window));
|
0
|
3413 }
|
|
3414
|
|
3415 static int
|
|
3416 window_pixel_height_to_char_height (struct window *w, int pixel_height,
|
|
3417 int include_gutters_p)
|
|
3418 {
|
|
3419 int avail_height;
|
|
3420 int defheight, defwidth;
|
|
3421 int char_height;
|
|
3422 Lisp_Object window;
|
|
3423
|
|
3424 XSETWINDOW (window, w);
|
|
3425
|
|
3426 avail_height = (pixel_height -
|
|
3427 (include_gutters_p ? 0 :
|
|
3428 window_top_gutter_height (w) +
|
|
3429 window_bottom_gutter_height (w)));
|
|
3430
|
|
3431 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3432
|
|
3433 char_height = avail_height / defheight;
|
|
3434
|
|
3435 /* It's the calling function's responsibility to check these values
|
|
3436 and make sure they're not out of range.
|
|
3437
|
|
3438 #### We need to go through the calling functions and actually
|
|
3439 do this. */
|
|
3440 if (char_height < 0)
|
|
3441 return 0;
|
|
3442 else
|
|
3443 return char_height;
|
|
3444 }
|
|
3445
|
|
3446 static int
|
|
3447 window_char_height_to_pixel_height (struct window *w, int char_height,
|
|
3448 int include_gutters_p)
|
|
3449 {
|
|
3450 int avail_height;
|
|
3451 int defheight, defwidth;
|
|
3452 int pixel_height;
|
|
3453
|
|
3454 Lisp_Object window;
|
|
3455
|
|
3456 XSETWINDOW (window, w);
|
|
3457
|
|
3458 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3459
|
|
3460 avail_height = char_height * defheight;
|
|
3461 pixel_height = (avail_height +
|
|
3462 (include_gutters_p ? 0 :
|
|
3463 window_top_gutter_height (w) +
|
|
3464 window_bottom_gutter_height (w)));
|
|
3465
|
|
3466 /* It's the calling function's responsibility to check these values
|
|
3467 and make sure they're not out of range.
|
|
3468
|
|
3469 #### We need to go through the calling functions and actually
|
|
3470 do this. */
|
|
3471 if (pixel_height < 0)
|
|
3472 return 0;
|
|
3473 else
|
|
3474 return pixel_height;
|
|
3475 }
|
|
3476
|
|
3477 /* Return number of default lines of text can fit in the window W.
|
|
3478 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus
|
|
3479 horizontal scrollbar) in the space that is used for the calculation.
|
|
3480 */
|
|
3481 int
|
|
3482 window_char_height (struct window *w, int include_gutters_p)
|
|
3483 {
|
|
3484 return window_pixel_height_to_char_height (w, WINDOW_HEIGHT (w),
|
|
3485 include_gutters_p);
|
|
3486 }
|
|
3487
|
|
3488 /*
|
|
3489 * Return number of lines currently displayed in window w. If
|
|
3490 * end-of-buffer is displayed then the area below end-of-buffer is assume
|
|
3491 * to be blank lines of default height.
|
|
3492 * Does not include the modeline.
|
|
3493 */
|
|
3494 int
|
|
3495 window_displayed_height (struct window *w)
|
|
3496 {
|
|
3497 struct buffer *b = XBUFFER (w->buffer);
|
|
3498 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
3499 int num_lines;
|
|
3500 Charcount end_pos = (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b)
|
|
3501 ? -1
|
|
3502 : w->window_end_pos[CURRENT_DISP]);
|
|
3503
|
|
3504 if (!Dynarr_length (dla))
|
|
3505 return window_char_height (w, 0);
|
|
3506
|
|
3507 num_lines = Dynarr_length (dla);
|
|
3508
|
|
3509 /* #### Document and assert somewhere that w->window_end_pos == -1
|
|
3510 indicates that end-of-buffer is being displayed. */
|
|
3511 if (end_pos == -1)
|
|
3512 {
|
|
3513 struct display_line *dl = Dynarr_atp (dla, 0);
|
|
3514 int ypos1 = dl->ypos + dl->descent;
|
|
3515 int ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
3516 Lisp_Object window;
|
|
3517 int defheight, defwidth;
|
|
3518
|
|
3519 XSETWINDOW (window, w);
|
|
3520
|
|
3521 if (dl->modeline)
|
|
3522 {
|
|
3523 num_lines--;
|
|
3524
|
|
3525 if (Dynarr_length (dla) == 1)
|
|
3526 ypos1 = WINDOW_TEXT_TOP (w);
|
|
3527 else
|
|
3528 {
|
|
3529 dl = Dynarr_atp (dla, Dynarr_length (dla) - 1);
|
|
3530 /* If this line is clipped then we know that there is no
|
|
3531 blank room between eob and the modeline. If we are
|
|
3532 scrolling on clipped lines just know off the clipped
|
|
3533 line and return .*/
|
|
3534 if (scroll_on_clipped_lines && dl->clip)
|
149
|
3535 return num_lines - 1;
|
0
|
3536 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
3537 }
|
|
3538 }
|
|
3539
|
|
3540 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3541 /* #### This probably needs to know about the clipping area once a
|
|
3542 final definition is decided on. */
|
|
3543 num_lines += ((ypos2 - ypos1) / defheight);
|
|
3544 }
|
|
3545 else
|
|
3546 {
|
|
3547 if (num_lines > 1 && Dynarr_atp (dla, 0)->modeline)
|
|
3548 num_lines--;
|
|
3549
|
|
3550 if (scroll_on_clipped_lines
|
|
3551 && Dynarr_atp (dla, Dynarr_length (dla) - 1)->clip)
|
|
3552 num_lines--;
|
|
3553 }
|
|
3554
|
|
3555 return num_lines;
|
|
3556 }
|
|
3557
|
|
3558 static int
|
|
3559 window_pixel_width (Lisp_Object window)
|
|
3560 {
|
149
|
3561 return WINDOW_WIDTH (XWINDOW (window));
|
0
|
3562 }
|
|
3563
|
|
3564 static int
|
|
3565 window_pixel_width_to_char_width (struct window *w, int pixel_width,
|
|
3566 int include_margins_p)
|
|
3567 {
|
|
3568 int avail_width;
|
|
3569 int char_width;
|
|
3570 int defheight, defwidth;
|
|
3571 Lisp_Object window;
|
|
3572
|
|
3573 XSETWINDOW (window, w);
|
|
3574
|
|
3575 avail_width = (pixel_width -
|
|
3576 window_left_gutter_width (w, 0) -
|
|
3577 window_right_gutter_width (w, 0) -
|
|
3578 (include_margins_p ? 0 : window_left_margin_width (w)) -
|
|
3579 (include_margins_p ? 0 : window_right_margin_width (w)));
|
|
3580
|
|
3581 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3582
|
|
3583 char_width = (avail_width / defwidth);
|
|
3584
|
|
3585 /* It's the calling function's responsibility to check these values
|
|
3586 and make sure they're not out of range.
|
|
3587
|
|
3588 #### We need to go through the calling functions and actually
|
|
3589 do this. */
|
|
3590 if (char_width < 0)
|
|
3591 return 0;
|
|
3592 else
|
|
3593 return char_width;
|
|
3594 }
|
|
3595
|
|
3596 static int
|
|
3597 window_char_width_to_pixel_width (struct window *w, int char_width,
|
|
3598 int include_margins_p)
|
|
3599 {
|
|
3600 int avail_width;
|
|
3601 int pixel_width;
|
|
3602 int defheight, defwidth;
|
|
3603 Lisp_Object window;
|
|
3604
|
|
3605 XSETWINDOW (window, w);
|
|
3606
|
|
3607 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3608
|
|
3609 avail_width = char_width * defwidth;
|
|
3610 pixel_width = (avail_width +
|
|
3611 window_left_gutter_width (w, 0) +
|
|
3612 window_right_gutter_width (w, 0) +
|
|
3613 (include_margins_p ? 0 : window_left_margin_width (w)) +
|
|
3614 (include_margins_p ? 0 : window_right_margin_width (w)));
|
|
3615
|
|
3616 /* It's the calling function's responsibility to check these values
|
|
3617 and make sure they're not out of range.
|
|
3618
|
|
3619 #### We need to go through the calling functions and actually
|
|
3620 do this. */
|
|
3621 if (pixel_width < 0)
|
|
3622 return 0;
|
|
3623 else
|
|
3624 return pixel_width;
|
|
3625 }
|
|
3626
|
|
3627 /* This returns the usable space which doesn't include space needed by
|
|
3628 scrollbars or divider lines. */
|
|
3629 int
|
|
3630 window_char_width (struct window *w, int include_margins_p)
|
|
3631 {
|
|
3632 return window_pixel_width_to_char_width (w, WINDOW_WIDTH (w),
|
|
3633 include_margins_p);
|
|
3634 }
|
|
3635
|
|
3636 #define MINSIZE(w) \
|
|
3637 (widthflag \
|
|
3638 ? window_min_width * defwidth \
|
|
3639 : (defheight * (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height)))
|
|
3640
|
|
3641 #define CURBEG(w) \
|
|
3642 *(widthflag ? (int *) &WINDOW_LEFT (w) : (int *) &WINDOW_TOP (w))
|
|
3643
|
|
3644 #define CURSIZE(w) \
|
|
3645 *(widthflag ? (int *) &WINDOW_WIDTH (w) : (int *) &WINDOW_HEIGHT (w))
|
|
3646
|
|
3647 #define CURCHARSIZE(w) \
|
|
3648 (widthflag ? window_char_width (w, 0) : window_char_height (w, 1))
|
|
3649
|
|
3650 #define MINCHARSIZE(window) \
|
|
3651 (widthflag ? window_min_width : MINI_WINDOW_P (XWINDOW (window)) \
|
|
3652 ? 1 : window_min_height)
|
|
3653
|
|
3654 /* Unlike set_window_pixheight, this function
|
|
3655 also changes the heights of the siblings so as to
|
|
3656 keep everything consistent. */
|
|
3657
|
|
3658 static void
|
|
3659 change_window_height (struct window *win, int delta, int widthflag)
|
|
3660 {
|
|
3661 Lisp_Object parent;
|
|
3662 Lisp_Object window = Qnil;
|
|
3663 struct window *w;
|
|
3664 struct frame *f;
|
|
3665 int *sizep;
|
|
3666 int (*sizefun) (Lisp_Object) = (widthflag
|
|
3667 ? window_pixel_width
|
|
3668 : window_pixel_height);
|
|
3669 void (*setsizefun) (Lisp_Object, int, int) = (widthflag
|
|
3670 ? set_window_pixwidth
|
|
3671 : set_window_pixheight);
|
|
3672 int dim;
|
|
3673 int defheight, defwidth;
|
|
3674
|
|
3675 if (delta == 0)
|
|
3676 return;
|
|
3677
|
|
3678 check_min_window_sizes ();
|
|
3679
|
|
3680 XSETWINDOW (window, win);
|
|
3681 f = XFRAME (win->frame);
|
|
3682 if (EQ (window, FRAME_ROOT_WINDOW (f)))
|
|
3683 error ("Won't change only window");
|
|
3684
|
|
3685 /* #### This is very likely incorrect and instead the char_to_pixel_
|
|
3686 functions should be called. */
|
|
3687 default_face_height_and_width (window, &defheight, &defwidth);
|
|
3688
|
|
3689 while (1)
|
|
3690 {
|
|
3691 w = XWINDOW (window);
|
|
3692 parent = w->parent;
|
|
3693 if (NILP (parent))
|
|
3694 {
|
|
3695 if (widthflag)
|
|
3696 error ("No other window to side of this one");
|
|
3697 break;
|
|
3698 }
|
|
3699 if (widthflag
|
|
3700 ? !NILP (XWINDOW (parent)->hchild)
|
|
3701 : !NILP (XWINDOW (parent)->vchild))
|
|
3702 break;
|
|
3703 window = parent;
|
|
3704 }
|
|
3705
|
|
3706 sizep = &CURSIZE (w);
|
|
3707 dim = CURCHARSIZE (w);
|
|
3708
|
|
3709 if ((dim + delta) < MINCHARSIZE (window))
|
|
3710 {
|
|
3711 if (MINI_WINDOW_P (XWINDOW (window)))
|
|
3712 return;
|
|
3713 else if (!NILP (parent))
|
|
3714 {
|
|
3715 Fdelete_window (window, Qnil);
|
|
3716 return;
|
|
3717 }
|
|
3718 }
|
|
3719
|
|
3720 delta *= (widthflag ? defwidth : defheight);
|
|
3721
|
|
3722 {
|
|
3723 int maxdelta;
|
|
3724
|
|
3725 maxdelta = ((!NILP (parent))
|
|
3726 ? (*sizefun) (parent) - *sizep
|
|
3727 : ((!NILP (w->next))
|
|
3728 ? (*sizefun) (w->next) - MINSIZE (w->next)
|
|
3729 : ((!NILP (w->prev))
|
|
3730 ? (*sizefun) (w->prev) - MINSIZE (w->prev)
|
|
3731 /* This is a frame with only one window,
|
|
3732 a minibuffer-only or a minibufferless frame. */
|
|
3733 : (delta = 0))));
|
|
3734
|
|
3735 if (delta > maxdelta)
|
|
3736 /* This case traps trying to make the minibuffer
|
|
3737 the full frame, or make the only window aside from the
|
|
3738 minibuffer the full frame. */
|
|
3739 delta = maxdelta;
|
|
3740
|
|
3741 if (delta == 0)
|
|
3742 return;
|
|
3743
|
|
3744 #if 0 /* FSFmacs */
|
|
3745 /* #### Chuck: is this correct? */
|
|
3746 if (*sizep + delta < MINSIZE (window))
|
|
3747 {
|
|
3748 Fdelete_window (window);
|
|
3749 return;
|
|
3750 }
|
|
3751 #endif
|
|
3752 }
|
|
3753
|
|
3754 if (!NILP (w->next) &&
|
|
3755 (*sizefun) (w->next) - delta >= (int) MINSIZE (w->next))
|
|
3756 {
|
|
3757 CURBEG (XWINDOW (w->next)) += delta;
|
|
3758 (*setsizefun) (w->next, (*sizefun) (w->next) - delta, 0);
|
|
3759 (*setsizefun) (window, *sizep + delta, 0);
|
|
3760 }
|
|
3761 else if (!NILP (w->prev) &&
|
|
3762 (*sizefun) (w->prev) - delta >= (int) MINSIZE (w->prev))
|
|
3763 {
|
|
3764 (*setsizefun) (w->prev, (*sizefun) (w->prev) - delta, 0);
|
|
3765 CURBEG (w) -= delta;
|
|
3766 (*setsizefun) (window, *sizep + delta, 0);
|
|
3767 }
|
|
3768 else
|
|
3769 {
|
|
3770 int delta1;
|
|
3771 int opht = (*sizefun) (parent);
|
|
3772
|
|
3773 /* If trying to grow this window to or beyond size of the parent,
|
|
3774 make delta1 so big that, on shrinking back down,
|
|
3775 all the siblings end up with less than one line and are deleted. */
|
|
3776 if (opht <= *sizep + delta)
|
|
3777 delta1 = opht * opht * 2;
|
|
3778 /* Otherwise, make delta1 just right so that if we add delta1
|
|
3779 lines to this window and to the parent, and then shrink
|
|
3780 the parent back to its original size, the new proportional
|
|
3781 size of this window will increase by delta. */
|
|
3782 else
|
|
3783 delta1 = (delta * opht * 100) / ((opht - *sizep - delta) * 100);
|
|
3784
|
|
3785 /* Add delta1 lines or columns to this window, and to the parent,
|
|
3786 keeping things consistent while not affecting siblings. */
|
|
3787 CURSIZE (XWINDOW (parent)) = opht + delta1;
|
|
3788 (*setsizefun) (window, *sizep + delta1, 0);
|
|
3789
|
|
3790 /* Squeeze out delta1 lines or columns from our parent,
|
|
3791 shriking this window and siblings proportionately.
|
|
3792 This brings parent back to correct size.
|
|
3793 Delta1 was calculated so this makes this window the desired size,
|
|
3794 taking it all out of the siblings. */
|
|
3795 (*setsizefun) (parent, opht, 0);
|
|
3796 }
|
|
3797
|
|
3798 SET_LAST_MODIFIED (w, 0);
|
|
3799 SET_LAST_FACECHANGE (w);
|
|
3800 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
3801 }
|
|
3802 #undef MINSIZE
|
|
3803 #undef CURBEG
|
|
3804 #undef CURSIZE
|
|
3805 #undef CURCHARSIZE
|
|
3806 #undef MINCHARSIZE
|
|
3807
|
|
3808
|
|
3809
|
|
3810 /* Scroll contents of window WINDOW up N lines. */
|
|
3811 void
|
|
3812 window_scroll (Lisp_Object window, Lisp_Object n, int direction,
|
|
3813 Error_behavior errb)
|
|
3814 {
|
|
3815 struct window *w = XWINDOW (window);
|
|
3816 struct buffer *b = XBUFFER (w->buffer);
|
|
3817 int selected = EQ (window, Fselected_window (Qnil));
|
|
3818 int value = 0;
|
|
3819 Lisp_Object point, tem;
|
|
3820
|
|
3821 if (selected)
|
|
3822 point = make_int (BUF_PT (b));
|
|
3823 else
|
|
3824 {
|
|
3825 Bufpos pos = marker_position (w->pointm[CURRENT_DISP]);
|
|
3826
|
|
3827 if (pos < BUF_BEGV (b))
|
|
3828 pos = BUF_BEGV (b);
|
|
3829 else if (pos > BUF_ZV (b))
|
|
3830 pos = BUF_ZV (b);
|
|
3831
|
|
3832 point = make_int (pos);
|
|
3833 }
|
|
3834
|
|
3835 /* Always set force_start so that redisplay_window will run
|
|
3836 thw window-scroll-functions. */
|
|
3837 w->force_start = 1;
|
|
3838
|
|
3839 /* #### When the fuck does this happen? I'm so glad that history has
|
|
3840 completely documented the behavior of the scrolling functions under
|
|
3841 all circumstances. */
|
|
3842 tem = Fpos_visible_in_window_p (point, window);
|
|
3843 if (NILP (tem))
|
|
3844 {
|
|
3845 Fvertical_motion (make_int (-window_char_height (w, 0) / 2), window);
|
|
3846 Fset_marker (w->start[CURRENT_DISP], point, w->buffer);
|
|
3847 w->start_at_line_beg = beginning_of_line_p (b, XINT (point));
|
|
3848 MARK_WINDOWS_CHANGED (w);
|
|
3849 }
|
|
3850
|
|
3851 if (!NILP (n))
|
|
3852 {
|
|
3853 if (EQ (n, Qminus))
|
|
3854 direction *= -1;
|
|
3855 else
|
|
3856 {
|
|
3857 n = Fprefix_numeric_value (n);
|
|
3858 value = XINT (n) * direction;
|
|
3859
|
|
3860 if (!value)
|
|
3861 return; /* someone just made a pointless call */
|
|
3862 }
|
|
3863 }
|
|
3864
|
|
3865 /* If the user didn't specify how far to scroll then we have to figure it
|
|
3866 out by ourselves. */
|
|
3867 if (NILP (n) || EQ (n, Qminus))
|
|
3868 {
|
|
3869 /* Going forwards is easy. If that is what we are doing then just
|
|
3870 set value and the section which handles the user specifying a
|
|
3871 positive value will work. */
|
|
3872 if (direction == 1)
|
|
3873 {
|
|
3874 value = window_displayed_height (w) - next_screen_context_lines;
|
|
3875 value = (value < 1 ? 1 : value);
|
|
3876 }
|
|
3877
|
|
3878 /* Going backwards is hard. We can't use the same loop used if the
|
|
3879 user specified a negative value because we care about
|
|
3880 next_screen_context_lines. In a variable height world you don't
|
|
3881 know how many lines above you can actually be displayed and still
|
|
3882 have the context lines appear. So we leave value set to 0 and add
|
|
3883 a separate section to deal with this. */
|
|
3884
|
|
3885 }
|
|
3886
|
|
3887 if (direction == 1 && !value)
|
|
3888 {
|
|
3889 return;
|
|
3890 }
|
|
3891 else if (value > 0)
|
|
3892 {
|
|
3893 int vtarget;
|
|
3894 Bufpos startp, old_start;
|
|
3895
|
|
3896 old_start = marker_position (w->start[CURRENT_DISP]);
|
|
3897 startp = vmotion (w, old_start, value, &vtarget);
|
|
3898
|
|
3899 if (vtarget < value &&
|
|
3900 (w->window_end_pos[CURRENT_DISP] == -1
|
|
3901 || (BUF_Z (b) - w->window_end_pos[CURRENT_DISP] > BUF_ZV (b))))
|
|
3902 {
|
|
3903 maybe_signal_error (Qend_of_buffer, Qnil, Qwindow, errb);
|
|
3904 return;
|
|
3905 }
|
|
3906 else
|
|
3907 {
|
|
3908 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
|
|
3909 w->buffer);
|
|
3910 w->force_start = 1;
|
|
3911 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
3912 MARK_WINDOWS_CHANGED (w);
|
|
3913
|
|
3914 if (!point_would_be_visible (w, startp, XINT (point)))
|
|
3915 {
|
|
3916 if (selected)
|
|
3917 BUF_SET_PT (b, startp);
|
|
3918 else
|
|
3919 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
3920 make_int (startp),
|
|
3921 w->buffer);
|
|
3922 }
|
|
3923 }
|
|
3924 }
|
|
3925 else if (value < 0)
|
|
3926 {
|
|
3927 int vtarget;
|
|
3928 Bufpos startp, old_start;
|
|
3929
|
|
3930 old_start = marker_position (w->start[CURRENT_DISP]);
|
|
3931 startp = vmotion (w, old_start, value, &vtarget);
|
|
3932
|
|
3933 if (vtarget > value
|
|
3934 && marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
|
|
3935 {
|
|
3936 maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
|
|
3937 return;
|
|
3938 }
|
|
3939 else
|
|
3940 {
|
|
3941 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
|
|
3942 w->buffer);
|
|
3943 w->force_start = 1;
|
|
3944 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
3945 MARK_WINDOWS_CHANGED (w);
|
|
3946
|
|
3947 if (!point_would_be_visible (w, startp, XINT (point)))
|
|
3948 {
|
|
3949 Bufpos new_point;
|
|
3950
|
|
3951 if (MINI_WINDOW_P (w))
|
|
3952 new_point = startp;
|
|
3953 else
|
|
3954 new_point = start_of_last_line (w, startp);
|
|
3955
|
|
3956 if (selected)
|
|
3957 BUF_SET_PT (b, new_point);
|
|
3958 else
|
|
3959 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
3960 make_int (new_point),
|
|
3961 w->buffer);
|
|
3962 }
|
|
3963 }
|
|
3964 }
|
|
3965 else /* value == 0 && direction == -1 */
|
|
3966 {
|
|
3967 if (marker_position (w->start[CURRENT_DISP]) == BUF_BEGV (b))
|
|
3968 {
|
|
3969 maybe_signal_error (Qbeginning_of_buffer, Qnil, Qwindow, errb);
|
|
3970 return;
|
|
3971 }
|
|
3972 else
|
|
3973 {
|
|
3974 int vtarget;
|
|
3975 int movement = next_screen_context_lines - 1;
|
|
3976 Bufpos old_startp = marker_position (w->start[CURRENT_DISP]);
|
|
3977 Bufpos bottom = vmotion (w, old_startp, movement, &vtarget);
|
|
3978 Bufpos startp =
|
|
3979 start_with_point_on_display_line (w, bottom,
|
|
3980 -1 - (movement - vtarget));
|
|
3981
|
|
3982 if (startp >= old_startp)
|
|
3983 startp = vmotion (w, old_startp, -1, NULL);
|
|
3984
|
|
3985 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
|
|
3986 w->buffer);
|
|
3987 w->force_start = 1;
|
|
3988 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
3989 MARK_WINDOWS_CHANGED (w);
|
|
3990
|
|
3991 if (!point_would_be_visible (w, startp, XINT (point)))
|
|
3992 {
|
|
3993 Bufpos new_point = start_of_last_line (w, startp);
|
|
3994
|
|
3995 if (selected)
|
|
3996 BUF_SET_PT (b, new_point);
|
|
3997 else
|
|
3998 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
3999 make_int (new_point),
|
|
4000 w->buffer);
|
|
4001 }
|
|
4002 }
|
|
4003 }
|
|
4004
|
|
4005 }
|
|
4006
|
98
|
4007 extern int signal_error_on_buffer_boundary;
|
|
4008
|
20
|
4009 DEFUN ("scroll-up", Fscroll_up, 0, 1, "_P", /*
|
0
|
4010 Scroll text of current window upward ARG lines; or near full screen if no ARG.
|
|
4011 A near full screen is `next-screen-context-lines' less than a full screen.
|
|
4012 Negative ARG means scroll downward.
|
|
4013 When calling from a program, supply a number as argument or nil.
|
98
|
4014
|
|
4015 If `signal-error-on-buffer-boundary' is nil, the usual error and
|
|
4016 loss of zmacs region is suppressed when moving past end of buffer.
|
20
|
4017 */
|
|
4018 (n))
|
0
|
4019 {
|
98
|
4020 Error_behavior errb =
|
|
4021 signal_error_on_buffer_boundary ? ERROR_ME : ERROR_ME_NOT;
|
|
4022
|
|
4023 window_scroll (Fselected_window (Qnil), n, 1, errb);
|
0
|
4024 return Qnil;
|
|
4025 }
|
|
4026
|
20
|
4027 DEFUN ("scroll-down", Fscroll_down, 0, 1, "_P", /*
|
0
|
4028 Scroll text of current window downward ARG lines; or near full screen if no ARG.
|
|
4029 A near full screen is `next-screen-context-lines' less than a full screen.
|
|
4030 Negative ARG means scroll upward.
|
|
4031 When calling from a program, supply a number as argument or nil.
|
98
|
4032
|
|
4033 If `signal-error-on-buffer-boundary' is nil, the usual error and
|
|
4034 loss of zmacs region is suppressed when moving past end of buffer.
|
20
|
4035 */
|
|
4036 (n))
|
0
|
4037 {
|
98
|
4038 Error_behavior errb =
|
|
4039 signal_error_on_buffer_boundary ? ERROR_ME : ERROR_ME_NOT;
|
|
4040
|
|
4041 window_scroll (Fselected_window (Qnil), n, -1, errb);
|
0
|
4042 return Qnil;
|
|
4043 }
|
|
4044
|
20
|
4045 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling, 0, 0, 0, /*
|
0
|
4046 Return the other window for \"other window scroll\" commands.
|
|
4047 If in the minibuffer, `minibuffer-scroll-window' if non-nil
|
|
4048 specifies the window.
|
|
4049 If `other-window-scroll-buffer' is non-nil, a window
|
|
4050 showing that buffer is used.
|
20
|
4051 */
|
|
4052 ())
|
0
|
4053 {
|
|
4054 Lisp_Object window;
|
|
4055 Lisp_Object selected_window = Fselected_window (Qnil);
|
|
4056
|
|
4057 if (MINI_WINDOW_P (XWINDOW (selected_window))
|
|
4058 && !NILP (Vminibuf_scroll_window))
|
|
4059 window = Vminibuf_scroll_window;
|
|
4060 /* If buffer is specified, scroll that buffer. */
|
|
4061 else if (!NILP (Vother_window_scroll_buffer))
|
|
4062 {
|
|
4063 window = Fget_buffer_window (Vother_window_scroll_buffer, Qnil, Qnil);
|
|
4064 if (NILP (window))
|
|
4065 window = display_buffer (Vother_window_scroll_buffer, Qt, Qnil);
|
|
4066 }
|
|
4067 else
|
|
4068 {
|
|
4069 /* Nothing specified; look for a neighboring window on the same
|
|
4070 frame. */
|
|
4071 window = Fnext_window (selected_window, Qnil, Qnil, Qnil);
|
|
4072
|
|
4073 if (EQ (window, selected_window))
|
|
4074 /* That didn't get us anywhere; look for a window on another
|
|
4075 visible frame. */
|
|
4076 do
|
|
4077 window = Fnext_window (window, Qnil, Qt, Qnil);
|
|
4078 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window))))
|
|
4079 && ! EQ (window, selected_window));
|
|
4080 }
|
|
4081
|
|
4082 CHECK_LIVE_WINDOW (window);
|
|
4083
|
|
4084 if (EQ (window, selected_window))
|
|
4085 error ("There is no other window");
|
|
4086
|
|
4087 return window;
|
|
4088 }
|
|
4089
|
20
|
4090 DEFUN ("scroll-other-window", Fscroll_other_window, 0, 1, "_P", /*
|
0
|
4091 Scroll next window upward ARG lines; or near full frame if no ARG.
|
|
4092 The next window is the one below the current one; or the one at the top
|
|
4093 if the current one is at the bottom. Negative ARG means scroll downward.
|
|
4094 When calling from a program, supply a number as argument or nil.
|
|
4095
|
|
4096 If in the minibuffer, `minibuf-scroll-window' if non-nil
|
|
4097 specifies the window to scroll.
|
|
4098 If `other-window-scroll-buffer' is non-nil, scroll the window
|
|
4099 showing that buffer, popping the buffer up if necessary.
|
20
|
4100 */
|
|
4101 (n))
|
0
|
4102 {
|
|
4103 window_scroll (Fother_window_for_scrolling (), n, 1, ERROR_ME);
|
|
4104 return Qnil;
|
|
4105 }
|
|
4106
|
20
|
4107 DEFUN ("scroll-left", Fscroll_left, 0, 1, "_P", /*
|
0
|
4108 Scroll selected window display ARG columns left.
|
|
4109 Default for ARG is window width minus 2.
|
20
|
4110 */
|
|
4111 (arg))
|
0
|
4112 {
|
|
4113 Lisp_Object window = Fselected_window (Qnil);
|
|
4114 struct window *w = XWINDOW (window);
|
|
4115
|
|
4116 if (NILP (arg))
|
|
4117 arg = make_int (window_char_width (w, 0) - 2);
|
|
4118 else
|
|
4119 arg = Fprefix_numeric_value (arg);
|
|
4120
|
149
|
4121 return Fset_window_hscroll (window, make_int (w->hscroll + XINT (arg)));
|
0
|
4122 }
|
|
4123
|
20
|
4124 DEFUN ("scroll-right", Fscroll_right, 0, 1, "_P", /*
|
0
|
4125 Scroll selected window display ARG columns right.
|
|
4126 Default for ARG is window width minus 2.
|
20
|
4127 */
|
|
4128 (arg))
|
0
|
4129 {
|
|
4130 Lisp_Object window = Fselected_window (Qnil);
|
|
4131 struct window *w = XWINDOW (window);
|
|
4132
|
|
4133 if (NILP (arg))
|
|
4134 arg = make_int (window_char_width (w, 0) - 2);
|
|
4135 else
|
|
4136 arg = Fprefix_numeric_value (arg);
|
|
4137
|
149
|
4138 return Fset_window_hscroll (window, make_int (w->hscroll - XINT (arg)));
|
0
|
4139 }
|
|
4140
|
20
|
4141 DEFUN ("recenter", Frecenter, 0, 2, "_P", /*
|
0
|
4142 Center point in WINDOW and redisplay frame. With ARG, put point on line ARG.
|
|
4143 The desired position of point is always relative to the window.
|
|
4144 Just C-u as prefix means put point in the center of the window.
|
|
4145 No arg (i.e., it is nil) erases the entire frame and then
|
|
4146 redraws with point in the center of the window.
|
|
4147 If WINDOW is nil, the selected window is used.
|
20
|
4148 */
|
|
4149 (n, window))
|
0
|
4150 {
|
|
4151 struct window *w;
|
|
4152 struct buffer *b;
|
|
4153 Bufpos startp;
|
|
4154 Bufpos opoint;
|
|
4155
|
|
4156 if (NILP (window))
|
|
4157 window = Fselected_window (Qnil);
|
|
4158 else
|
|
4159 CHECK_WINDOW (window);
|
|
4160 w = XWINDOW (window);
|
|
4161 b = XBUFFER (w->buffer);
|
|
4162
|
|
4163 opoint = BUF_PT (b);
|
|
4164
|
|
4165 if (NILP (n) || CONSP (n))
|
|
4166 {
|
|
4167 struct frame *f = XFRAME (w->frame);
|
|
4168
|
|
4169 if (NILP (n))
|
|
4170 {
|
|
4171 MARK_FRAME_CHANGED (f);
|
|
4172 SET_FRAME_CLEAR (f);
|
|
4173 }
|
|
4174
|
|
4175 startp = start_with_line_at_pixpos (w, opoint, window_half_pixpos (w));
|
|
4176 }
|
|
4177 else
|
|
4178 {
|
|
4179 n = Fprefix_numeric_value (n);
|
|
4180 CHECK_INT (n);
|
|
4181
|
|
4182 startp = start_with_point_on_display_line (w, opoint, XINT (n));
|
|
4183 }
|
|
4184
|
|
4185 Fset_marker (w->start[CURRENT_DISP], make_int (startp), w->buffer);
|
|
4186
|
|
4187 w->start_at_line_beg = beginning_of_line_p (b, startp);
|
|
4188 w->force_start = 1;
|
|
4189 MARK_WINDOWS_CHANGED (w);
|
|
4190 return Qnil;
|
|
4191 }
|
|
4192
|
20
|
4193 DEFUN ("move-to-window-line", Fmove_to_window_line, 1, 2, "_P", /*
|
0
|
4194 Position point relative to WINDOW.
|
|
4195 With no argument, position text at center of window.
|
|
4196 An argument specifies window line; zero means top of window,
|
|
4197 negative means relative to bottom of window.
|
|
4198 If WINDOW is nil, the selected window is used.
|
20
|
4199 */
|
|
4200 (arg, window))
|
0
|
4201 {
|
|
4202 struct window *w;
|
|
4203 struct buffer *b;
|
|
4204 int height;
|
|
4205 Bufpos start, new_point;
|
|
4206 int selected;
|
|
4207
|
|
4208 if (NILP (window))
|
|
4209 window = Fselected_window (Qnil);
|
|
4210 else
|
|
4211 CHECK_WINDOW (window);
|
|
4212 w = XWINDOW (window);
|
|
4213 b = XBUFFER (w->buffer);
|
|
4214
|
|
4215 height = window_displayed_height (w);
|
|
4216 selected = EQ (window, Fselected_window (w->frame));
|
|
4217
|
|
4218 if (NILP (arg))
|
|
4219 {
|
|
4220 int retval;
|
|
4221
|
|
4222 if (XINT (w->last_modified[CURRENT_DISP]) >= BUF_MODIFF (b)
|
|
4223 && XINT (w->last_facechange[CURRENT_DISP]) >= BUF_FACECHANGE (b))
|
|
4224 {
|
|
4225 new_point = point_at_center (w, CURRENT_DISP, 0, 0);
|
|
4226
|
|
4227 if (selected)
|
|
4228 BUF_SET_PT (b, new_point);
|
|
4229 else
|
|
4230 Fset_window_point (window, make_int (new_point));
|
|
4231
|
|
4232 retval = line_at_center (w, CURRENT_DISP, 0, 0);
|
|
4233 }
|
|
4234 else
|
|
4235 {
|
|
4236 start = marker_position (w->start[CURRENT_DISP]);
|
|
4237 if (start < BUF_BEGV (b))
|
|
4238 start = BUF_BEGV (b);
|
|
4239 else if (start > BUF_ZV (b))
|
|
4240 start = BUF_ZV (b);
|
|
4241
|
|
4242 if (selected)
|
|
4243 new_point = BUF_PT (b);
|
|
4244 else
|
|
4245 new_point = marker_position (w->pointm[CURRENT_DISP]);
|
|
4246
|
|
4247 new_point = point_at_center (w, CMOTION_DISP, start, BUF_PT (b));
|
|
4248
|
|
4249 if (selected)
|
|
4250 BUF_SET_PT (b, new_point);
|
|
4251 else
|
|
4252 Fset_window_point (window, make_int (new_point));
|
|
4253
|
|
4254 retval = line_at_center (w, CMOTION_DISP, start, BUF_PT (b));
|
|
4255 }
|
|
4256
|
149
|
4257 return make_int (retval);
|
0
|
4258 }
|
|
4259 else
|
|
4260 {
|
|
4261 /* #### Is this going to work right when at eob? */
|
|
4262 arg = Fprefix_numeric_value (arg);
|
|
4263 if (XINT (arg) < 0)
|
|
4264 XSETINT (arg, XINT (arg) + height);
|
|
4265 }
|
|
4266
|
|
4267 start = marker_position (w->start[CURRENT_DISP]);
|
|
4268 if (start < BUF_BEGV (b) || start > BUF_ZV (b))
|
|
4269 {
|
|
4270 if (selected)
|
|
4271 new_point = BUF_PT (b);
|
|
4272 else
|
|
4273 new_point = marker_position (w->pointm[CURRENT_DISP]);
|
|
4274
|
|
4275 new_point = vmotion (XWINDOW (window), new_point, -height / 2, 0);
|
|
4276
|
|
4277 if (selected)
|
|
4278 BUF_SET_PT (b, new_point);
|
|
4279 else
|
|
4280 Fset_window_point (window, make_int (new_point));
|
|
4281
|
|
4282 Fset_marker (w->start[CURRENT_DISP], make_int (new_point),
|
|
4283 w->buffer);
|
|
4284 w->start_at_line_beg = beginning_of_line_p (b, new_point);
|
|
4285 w->force_start = 1;
|
|
4286 }
|
|
4287 else
|
|
4288 {
|
|
4289 if (selected)
|
|
4290 BUF_SET_PT (b, start);
|
|
4291 else
|
|
4292 Fset_window_point (window, make_int (start));
|
|
4293 }
|
|
4294
|
|
4295 if (selected)
|
|
4296 return Fvertical_motion (arg, window);
|
|
4297 else
|
|
4298 {
|
|
4299 int vpos;
|
|
4300 new_point = vmotion (XWINDOW (window),
|
|
4301 marker_position (w->pointm[CURRENT_DISP]),
|
|
4302 XINT (arg), &vpos);
|
|
4303 Fset_window_point (window, make_int (new_point));
|
|
4304 return make_int (vpos);
|
|
4305 }
|
|
4306 }
|
|
4307
|
|
4308
|
|
4309 static int
|
|
4310 map_windows_1 (Lisp_Object window,
|
|
4311 int (*mapfun) (struct window *w, void *closure),
|
|
4312 void *closure)
|
|
4313 {
|
|
4314 int retval;
|
|
4315
|
|
4316 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
4317 {
|
|
4318 struct window *w = XWINDOW (window);
|
|
4319 if (!NILP (w->vchild))
|
|
4320 retval = map_windows_1 (w->vchild, mapfun, closure);
|
|
4321 else if (!NILP (w->hchild))
|
|
4322 retval = map_windows_1 (w->hchild, mapfun, closure);
|
|
4323 else
|
|
4324 retval = (mapfun) (w, closure);
|
|
4325 if (retval)
|
|
4326 return retval;
|
|
4327 }
|
|
4328
|
|
4329 return 0;
|
|
4330 }
|
|
4331
|
|
4332 /* Map MAPFUN over the windows in F. CLOSURE is passed to each
|
|
4333 invocation of MAPFUN. If any invocation of MAPFUN returns non-zero,
|
|
4334 the mapping is halted and the value returned is the return value
|
|
4335 of map_windows(). Otherwise, map_windows() maps over all windows
|
|
4336 in F and returns 0. */
|
|
4337
|
|
4338 int
|
|
4339 map_windows (struct frame *f, int (*mapfun) (struct window *w, void *closure),
|
|
4340 void *closure)
|
|
4341 {
|
|
4342 return map_windows_1 (FRAME_ROOT_WINDOW (f), mapfun, closure);
|
|
4343 }
|
|
4344
|
|
4345
|
|
4346 static void
|
|
4347 modeline_shadow_thickness_changed (Lisp_Object specifier, struct window *w,
|
|
4348 Lisp_Object oldval)
|
|
4349 {
|
|
4350 w->shadow_thickness_changed = 1;
|
|
4351 MARK_WINDOWS_CHANGED (w);
|
|
4352 }
|
|
4353
|
|
4354 /* also used in scrollbar.c */
|
|
4355 void
|
|
4356 some_window_value_changed (Lisp_Object specifier, struct window *w,
|
|
4357 Lisp_Object oldval)
|
|
4358 {
|
|
4359 MARK_WINDOWS_CHANGED (w);
|
|
4360 }
|
|
4361
|
|
4362 #ifdef MEMORY_USAGE_STATS
|
|
4363
|
|
4364 struct window_stats
|
|
4365 {
|
|
4366 int face;
|
|
4367 int glyph;
|
|
4368 #ifdef HAVE_SCROLLBARS
|
|
4369 int scrollbar;
|
|
4370 #endif
|
|
4371 int line_start;
|
|
4372 int other_redisplay;
|
|
4373 int other;
|
|
4374 };
|
|
4375
|
|
4376 static void
|
|
4377 compute_window_mirror_usage (struct window_mirror *mir,
|
|
4378 struct window_stats *stats,
|
|
4379 struct overhead_stats *ovstats)
|
|
4380 {
|
|
4381 if (!mir)
|
|
4382 return;
|
|
4383 stats->other += malloced_storage_size (mir, sizeof (struct window_mirror),
|
|
4384 ovstats);
|
|
4385 #ifdef HAVE_SCROLLBARS
|
|
4386 {
|
|
4387 struct device *d = XDEVICE (FRAME_DEVICE (mir->frame));
|
|
4388
|
|
4389 stats->scrollbar +=
|
|
4390 compute_scrollbar_instance_usage (d, mir->scrollbar_vertical_instance,
|
|
4391 ovstats);
|
|
4392 stats->scrollbar +=
|
|
4393 compute_scrollbar_instance_usage (d, mir->scrollbar_horizontal_instance,
|
|
4394 ovstats);
|
|
4395 }
|
149
|
4396 #endif /* HAVE_SCROLLBARS */
|
0
|
4397 stats->other_redisplay +=
|
|
4398 compute_display_line_dynarr_usage (mir->current_display_lines, ovstats);
|
|
4399 stats->other_redisplay +=
|
|
4400 compute_display_line_dynarr_usage (mir->desired_display_lines, ovstats);
|
|
4401 }
|
|
4402
|
|
4403 static void
|
|
4404 compute_window_usage (struct window *w, struct window_stats *stats,
|
|
4405 struct overhead_stats *ovstats)
|
|
4406 {
|
|
4407 memset (stats, 0, sizeof (*stats));
|
|
4408 stats->other += malloced_storage_size (w, sizeof (struct window), ovstats);
|
|
4409 stats->face += compute_face_cachel_usage (w->face_cachels, ovstats);
|
|
4410 stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ovstats);
|
|
4411 stats->line_start +=
|
|
4412 compute_line_start_cache_dynarr_usage (w->line_start_cache, ovstats);
|
|
4413 compute_window_mirror_usage (find_window_mirror (w), stats, ovstats);
|
|
4414 }
|
|
4415
|
20
|
4416 DEFUN ("window-memory-usage", Fwindow_memory_usage, 1, 1, 0, /*
|
0
|
4417 Return stats about the memory usage of window WINDOW.
|
|
4418 The values returned are in the form an alist of usage types and byte
|
|
4419 counts. The byte counts attempt to encompass all the memory used
|
|
4420 by the window (separate from the memory logically associated with a
|
|
4421 buffer or frame), including internal structures and any malloc()
|
|
4422 overhead associated with them. In practice, the byte counts are
|
|
4423 underestimated because certain memory usage is very hard to determine
|
|
4424 (e.g. the amount of memory used inside the Xt library or inside the
|
|
4425 X server) and because there is other stuff that might logically
|
|
4426 be associated with a window, buffer, or frame (e.g. window configurations,
|
|
4427 glyphs) but should not obviously be included in the usage counts.
|
|
4428
|
|
4429 Multiple slices of the total memory usage may be returned, separated
|
|
4430 by a nil. Each slice represents a particular view of the memory, a
|
|
4431 particular way of partitioning it into groups. Within a slice, there
|
|
4432 is no overlap between the groups of memory, and each slice collectively
|
|
4433 represents all the memory concerned.
|
20
|
4434 */
|
|
4435 (window))
|
0
|
4436 {
|
|
4437 struct window_stats stats;
|
|
4438 struct overhead_stats ovstats;
|
|
4439
|
|
4440 CHECK_WINDOW (window); /* dead windows should be allowed, no? */
|
|
4441 memset (&ovstats, 0, sizeof (ovstats));
|
|
4442 compute_window_usage (XWINDOW (window), &stats, &ovstats);
|
|
4443
|
|
4444 return nconc2 (
|
|
4445 #ifdef HAVE_SCROLLBARS
|
|
4446 list6
|
|
4447 #else
|
|
4448 list5
|
|
4449 #endif
|
|
4450 (Fcons (Qface_cache, make_int (stats.face)),
|
|
4451 Fcons (Qglyph_cache, make_int (stats.glyph)),
|
|
4452 #ifdef HAVE_SCROLLBARS
|
|
4453 Fcons (Qscrollbar_instances, make_int (stats.scrollbar)),
|
|
4454 #endif
|
|
4455 Fcons (Qline_start_cache, make_int (stats.line_start)),
|
|
4456 Fcons (Qother_redisplay, make_int (stats.other_redisplay)),
|
|
4457 Fcons (Qother, make_int (stats.other))),
|
|
4458 list4 (Qnil,
|
|
4459 Fcons (Qactually_requested,
|
|
4460 make_int (ovstats.was_requested)),
|
|
4461 Fcons (Qmalloc_overhead,
|
|
4462 make_int (ovstats.malloc_overhead)),
|
|
4463 Fcons (Qdynarr_overhead,
|
|
4464 make_int (ovstats.dynarr_overhead))));
|
|
4465 }
|
|
4466
|
|
4467 #endif /* MEMORY_USAGE_STATS */
|
|
4468
|
|
4469
|
|
4470 /************************************************************************/
|
|
4471 /* Window configurations */
|
|
4472 /************************************************************************/
|
|
4473
|
|
4474 /* #### This window configuration stuff has had serious bugs lurking in it
|
|
4475 for years; it would be a -huge- win if this was reimplemented in lisp.
|
|
4476 */
|
|
4477
|
|
4478 /* If you add anything to this structure make sure saved_window_equal
|
|
4479 knows about it. */
|
|
4480 struct saved_window
|
|
4481 {
|
|
4482 Lisp_Object window; /* window */
|
|
4483 Lisp_Object buffer; /* buffer */
|
|
4484 Lisp_Object start; /* copied marker */
|
|
4485 Lisp_Object pointm; /* copied marker */
|
|
4486 Lisp_Object sb_point; /* copied marker */
|
|
4487 Lisp_Object mark; /* copied marker */
|
|
4488 int pixel_left;
|
|
4489 int pixel_top;
|
|
4490 int pixel_width;
|
|
4491 int pixel_height;
|
|
4492 int hscroll;
|
|
4493 int parent_index; /* index into saved_windows */
|
|
4494 int prev_index; /* index into saved_windows */
|
|
4495 Lisp_Object dedicated;
|
|
4496 char start_at_line_beg; /* boolean */
|
|
4497 };
|
|
4498
|
|
4499 /* If you add anything to this structure make sure window_config_equal
|
|
4500 knows about it. */
|
|
4501 struct window_config
|
|
4502 {
|
|
4503 struct lcrecord_header header;
|
|
4504 int frame_width;
|
|
4505 int frame_height;
|
|
4506 #if 0 /* FSFmacs */
|
|
4507 Lisp_Object selected_frame;
|
|
4508 #endif
|
|
4509 Lisp_Object current_window;
|
|
4510 Lisp_Object current_buffer;
|
|
4511 Lisp_Object minibuf_scroll_window;
|
|
4512 Lisp_Object root_window;
|
|
4513 /* Record the values of window-min-width and window-min-height
|
|
4514 so that window sizes remain consistent with them. */
|
|
4515 int min_width, min_height;
|
|
4516 #ifdef ENERGIZE
|
|
4517 /* The buffer whose p_sheets are visible */
|
|
4518 Lisp_Object p_sheet_buffer;
|
|
4519 #endif
|
|
4520 int saved_windows_count;
|
|
4521 /* Zero-sized arrays aren't ANSI C */
|
|
4522 struct saved_window saved_windows[1];
|
|
4523 };
|
|
4524 #define SAVED_WINDOW_N(conf, n) (&((conf)->saved_windows[(n)]))
|
|
4525
|
|
4526 static Lisp_Object mark_window_config (Lisp_Object, void (*) (Lisp_Object));
|
|
4527 static void print_window_config (Lisp_Object, Lisp_Object, int);
|
|
4528 static unsigned int sizeof_window_config (CONST void *);
|
|
4529
|
|
4530 #define XWINDOW_CONFIGURATION(x) XRECORD (x, window_configuration, struct window_config)
|
|
4531 #define XSETWINDOW_CONFIGURATION(x, p) XSETRECORD (x, p, window_configuration)
|
|
4532 #define WINDOW_CONFIGURATIONP(x) RECORDP (x, window_configuration)
|
|
4533 #define GC_WINDOW_CONFIGURATIONP(x) GC_RECORDP (x, window_configuration)
|
|
4534 #define CHECK_WINDOW_CONFIGURATION(x) CHECK_RECORD (x, window_configuration)
|
|
4535
|
|
4536 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("window-configuration",
|
|
4537 window_configuration,
|
|
4538 mark_window_config,
|
|
4539 print_window_config,
|
|
4540 0, 0, 0, sizeof_window_config,
|
|
4541 struct window_config);
|
|
4542
|
|
4543 static Lisp_Object
|
|
4544 mark_window_config (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
4545 {
|
|
4546 struct window_config *config = XWINDOW_CONFIGURATION (obj);
|
|
4547 int i;
|
|
4548 ((markobj) (config->current_window));
|
|
4549 ((markobj) (config->current_buffer));
|
|
4550 ((markobj) (config->minibuf_scroll_window));
|
|
4551 ((markobj) (config->root_window));
|
|
4552 #ifdef ENERGIZE
|
|
4553 ((markobj) (config->p_sheet_buffer));
|
|
4554 #endif
|
|
4555 for (i = 0; i < config->saved_windows_count; i++)
|
|
4556 {
|
|
4557 struct saved_window *s = SAVED_WINDOW_N (config, i);
|
|
4558 ((markobj) (s->window));
|
|
4559 ((markobj) (s->buffer));
|
|
4560 ((markobj) (s->start));
|
|
4561 ((markobj) (s->pointm));
|
|
4562 ((markobj) (s->sb_point));
|
|
4563 ((markobj) (s->mark));
|
|
4564 ((markobj) (s->dedicated));
|
|
4565 }
|
149
|
4566 return Qnil;
|
0
|
4567 }
|
|
4568
|
|
4569 static int
|
|
4570 sizeof_window_config_for_n_windows (int n)
|
|
4571 {
|
|
4572 return (sizeof (struct window_config) +
|
|
4573 /* n - 1 because zero-sized arrays aren't ANSI C */
|
|
4574 (n - 1) *sizeof (struct saved_window));
|
|
4575 }
|
|
4576
|
|
4577 static unsigned int
|
|
4578 sizeof_window_config (CONST void *h)
|
|
4579 {
|
|
4580 CONST struct window_config *c = h;
|
|
4581 return sizeof_window_config_for_n_windows (c->saved_windows_count);
|
|
4582 }
|
|
4583
|
|
4584 static void
|
|
4585 print_window_config (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
4586 {
|
|
4587 struct window_config *config = XWINDOW_CONFIGURATION (obj);
|
|
4588 char buf[200];
|
|
4589 if (print_readably)
|
|
4590 error ("printing unreadable object #<window-configuration 0x%x>",
|
|
4591 config->header.uid);
|
|
4592 write_c_string ("#<window-configuration ", printcharfun);
|
|
4593 sprintf (buf, "0x%x>", config->header.uid);
|
|
4594 write_c_string (buf, printcharfun);
|
|
4595 }
|
|
4596
|
|
4597 /* Returns a boolean indicating whether the two saved windows are
|
|
4598 identical. */
|
|
4599 static int
|
|
4600 saved_window_equal (struct saved_window *win1, struct saved_window *win2)
|
|
4601 {
|
149
|
4602 return
|
|
4603 EQ (win1->window, win2->window) &&
|
|
4604 EQ (win1->buffer, win2->buffer) &&
|
|
4605 !NILP (Fequal (win1->start, win2->start)) &&
|
|
4606 !NILP (Fequal (win1->pointm, win2->pointm)) &&
|
|
4607 !NILP (Fequal (win1->sb_point, win2->sb_point)) &&
|
|
4608 !NILP (Fequal (win1->mark, win2->mark)) &&
|
|
4609 win1->pixel_left == win2->pixel_left &&
|
|
4610 win1->pixel_top == win2->pixel_top &&
|
|
4611 win1->pixel_width == win2->pixel_width &&
|
|
4612 win1->pixel_height == win2->pixel_height &&
|
|
4613 win1->hscroll == win2->hscroll &&
|
|
4614 win1->parent_index == win2->parent_index &&
|
|
4615 win1->prev_index == win2->prev_index &&
|
|
4616 EQ (win1->dedicated, win2->dedicated) &&
|
|
4617 win1->start_at_line_beg == win2->start_at_line_beg;
|
0
|
4618 }
|
|
4619
|
|
4620 /* Returns a boolean indicating whether the two given configurations
|
|
4621 are identical. */
|
|
4622 static int
|
|
4623 window_config_equal (Lisp_Object conf1, Lisp_Object conf2)
|
|
4624 {
|
|
4625 struct window_config *fig1, *fig2;
|
|
4626 int i;
|
|
4627
|
|
4628 /* First check if they are truly the same. */
|
|
4629 if (EQ (conf1, conf2))
|
|
4630 return 1;
|
|
4631
|
|
4632 fig1 = XWINDOW_CONFIGURATION (conf1);
|
|
4633 fig2 = XWINDOW_CONFIGURATION (conf2);
|
|
4634
|
149
|
4635 if (!((fig1->saved_windows_count == fig2->saved_windows_count) &&
|
|
4636 EQ (fig1->current_window, fig2->current_window) &&
|
|
4637 EQ (fig1->current_buffer, fig2->current_buffer) &&
|
|
4638 EQ (fig1->root_window, fig2->root_window) &&
|
|
4639 EQ (fig1->minibuf_scroll_window, fig2->minibuf_scroll_window) &&
|
|
4640 #ifdef ENERGIZE
|
|
4641 EQ (fig1->p_sheet_buffer, fig2->p_sheet_buffer) &&
|
|
4642 #endif
|
|
4643 fig1->frame_width == fig2->frame_width &&
|
|
4644 fig1->frame_height == fig2->frame_height))
|
0
|
4645 return 0;
|
|
4646
|
|
4647 for (i = 0; i < fig1->saved_windows_count; i++)
|
|
4648 {
|
|
4649 if (!saved_window_equal (SAVED_WINDOW_N (fig1, i),
|
|
4650 SAVED_WINDOW_N (fig2, i)))
|
|
4651 return 0;
|
|
4652 }
|
|
4653
|
|
4654 return 1;
|
|
4655 }
|
|
4656
|
20
|
4657 DEFUN ("window-configuration-p", Fwindow_configuration_p, 1, 1, 0, /*
|
0
|
4658 T if OBJECT is a window-configuration object.
|
20
|
4659 */
|
|
4660 (obj))
|
0
|
4661 {
|
149
|
4662 return WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil;
|
0
|
4663 }
|
|
4664
|
|
4665 /*
|
|
4666 * There are getting to be a lot of functions which traverse the
|
|
4667 * window structure doing various things. It may be worth writing a
|
|
4668 * generic map-windows function.
|
|
4669 * #### I just did. Feel free to rewrite. --ben
|
|
4670 */
|
|
4671 void
|
|
4672 mark_windows_in_use (Lisp_Object window, int mark)
|
|
4673 {
|
|
4674 for (; !NILP (window) ; window = XWINDOW (window)->next)
|
|
4675 {
|
|
4676 XWINDOW (window)->config_mark = mark;
|
|
4677
|
|
4678 if (!NILP (XWINDOW (window)->vchild))
|
|
4679 mark_windows_in_use (XWINDOW (window)->vchild, mark);
|
|
4680 else if (!NILP (XWINDOW (window)->hchild))
|
|
4681 mark_windows_in_use (XWINDOW (window)->hchild, mark);
|
|
4682 }
|
|
4683 }
|
|
4684
|
|
4685 /* Lisp_Object return value so it can be used in record_unwind_protect() */
|
|
4686 static Lisp_Object
|
|
4687 free_window_configuration (Lisp_Object window_config)
|
|
4688 {
|
|
4689 int i;
|
|
4690 struct window_config *config = XWINDOW_CONFIGURATION (window_config);
|
|
4691
|
|
4692 /* Free all the markers. It's not completely necessary that
|
|
4693 we do this (window configs sitting in a free list aren't
|
|
4694 marked normally so the markers wouldn't be marked anyway)
|
|
4695 but it's more efficient. */
|
|
4696 for (i = 0; i < config->saved_windows_count; i++)
|
|
4697 {
|
|
4698 struct saved_window *p = SAVED_WINDOW_N (config, i);
|
|
4699
|
|
4700 if (!NILP (p->pointm))
|
|
4701 {
|
|
4702 free_marker (XMARKER (p->pointm));
|
|
4703 p->pointm = Qnil;
|
|
4704 }
|
|
4705 if (!NILP (p->start))
|
|
4706 {
|
|
4707 free_marker (XMARKER (p->start));
|
|
4708 p->start = Qnil;
|
|
4709 }
|
|
4710 if (!NILP (p->sb_point))
|
|
4711 {
|
|
4712 free_marker (XMARKER (p->sb_point));
|
|
4713 p->sb_point = Qnil;
|
|
4714 }
|
|
4715 if (!NILP (p->mark))
|
|
4716 {
|
|
4717 free_marker (XMARKER (p->mark));
|
|
4718 p->mark = Qnil;
|
|
4719 }
|
|
4720 }
|
|
4721
|
|
4722 if (config->saved_windows_count <= countof (Vwindow_configuration_free_list))
|
|
4723 free_managed_lcrecord (Vwindow_configuration_free_list
|
|
4724 [config->saved_windows_count - 1],
|
|
4725 window_config);
|
|
4726
|
|
4727 return Qnil;
|
|
4728 }
|
|
4729
|
20
|
4730 DEFUN ("set-window-configuration", Fset_window_configuration, 1, 1, 0, /*
|
0
|
4731 Set the configuration of windows and buffers as specified by CONFIGURATION.
|
|
4732 CONFIGURATION must be a value previously returned
|
|
4733 by `current-window-configuration' (which see).
|
20
|
4734 */
|
|
4735 (configuration))
|
0
|
4736 {
|
|
4737 struct window *w;
|
|
4738 struct window_config *config;
|
|
4739 struct saved_window *p;
|
|
4740 Lisp_Object new_current_buffer;
|
|
4741 int k;
|
|
4742 Lisp_Object frame;
|
|
4743 struct frame *f;
|
|
4744 struct gcpro gcpro1;
|
|
4745 Lisp_Object old_window_config;
|
|
4746 int previous_frame_height;
|
|
4747 int previous_frame_width;
|
|
4748 int specpdl_count = specpdl_depth ();
|
|
4749
|
|
4750 GCPRO1 (configuration);
|
|
4751
|
|
4752 CHECK_WINDOW_CONFIGURATION (configuration);
|
|
4753 config = XWINDOW_CONFIGURATION (configuration);
|
|
4754
|
|
4755 frame = XWINDOW (SAVED_WINDOW_N (config, 0)->window)->frame;
|
|
4756 f = XFRAME (frame);
|
|
4757
|
|
4758 /* Do not signal an error here if the frame was deleted. There are
|
|
4759 reasonable cases where we could get here with a deleted frame and
|
|
4760 just want to do close to nothing instead. */
|
|
4761
|
|
4762 if (FRAME_LIVE_P (f))
|
|
4763 {
|
|
4764 /* restore the frame characteristics */
|
|
4765 #ifdef ENERGIZE
|
|
4766 if (FRAME_X_P (f))
|
|
4767 {
|
|
4768 Lisp_Object new_desired = config->p_sheet_buffer;
|
|
4769
|
|
4770 if (BUFFERP (new_desired) &&
|
|
4771 !BUFFER_LIVE_P (XBUFFER (new_desired)))
|
|
4772 new_desired = Qnil; /* the desired buffer was killed */
|
|
4773
|
|
4774 /* need to restore the desired buffer */
|
|
4775 if (!EQ (new_desired, desired_psheet_buffer (f)))
|
|
4776 make_psheets_desired (f, new_desired);
|
|
4777 }
|
|
4778 #endif
|
|
4779
|
|
4780 new_current_buffer = config->current_buffer;
|
|
4781 if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer)))
|
|
4782 new_current_buffer = Qnil;
|
|
4783
|
|
4784 /*
|
|
4785 * Assumed precondition: w->config_mark = 0 for all w
|
|
4786 * This procedure should ensure this is true by the time it exits
|
|
4787 * to ensure the precondition for future calls.
|
|
4788 *
|
|
4789 * We use w->config_mark to know whether we're modifying a
|
|
4790 * window that is currently visible on the frame (#### we
|
|
4791 * should just be able to check whether the window is dead
|
|
4792 * or not, but this way is safer?). As we process each
|
|
4793 * window, we set its config_mark to 0. At the end, we
|
|
4794 * go through all the windows that used to be on the frame,
|
|
4795 * set each one's config_mark to 0 (to maintain the
|
|
4796 * assumed precondition) and delete each one that's no
|
|
4797 * longer in use.
|
|
4798 *
|
|
4799 * #### Using a window-configuration to keep track of
|
|
4800 * the current windows is wasteful. All we need is the
|
|
4801 * list of windows, so we could just use a dynarr.
|
|
4802 */
|
|
4803 old_window_config = Fcurrent_window_configuration (frame);
|
|
4804
|
|
4805 /* If the new configuration is already equal to the old, then stop
|
|
4806 right here. This saves the work below and it also saves
|
|
4807 triggering a full redisplay of this window. This is a huge win
|
|
4808 when using the mouse since the mode motion code uses
|
|
4809 save-window-excursion extensively but will rarely cause the
|
|
4810 configuration to actually change. */
|
|
4811 if (window_config_equal (configuration, old_window_config))
|
|
4812 {
|
|
4813 free_window_configuration (old_window_config);
|
|
4814 UNGCPRO;
|
|
4815 return Qnil;
|
|
4816 }
|
|
4817
|
|
4818 /* We can't quit or even check for quit because that may cause
|
|
4819 investigation of the frame state, which may crash if the frame is
|
|
4820 in an inconsistent state. */
|
|
4821 begin_dont_check_for_quit ();
|
|
4822 record_unwind_protect (free_window_configuration, old_window_config);
|
|
4823
|
|
4824 mark_windows_in_use (f->root_window, 1);
|
|
4825
|
|
4826 previous_frame_width = FRAME_WIDTH (f);
|
|
4827 previous_frame_height = FRAME_HEIGHT (f);
|
|
4828 /* If the frame has been resized since this window configuration was
|
|
4829 made, we change the frame to the size specified in the
|
|
4830 configuration, restore the configuration, and then resize it
|
|
4831 back. We keep track of the prevailing height in these variables. */
|
|
4832 if (config->frame_height != FRAME_HEIGHT (f)
|
|
4833 || config->frame_width != FRAME_WIDTH (f))
|
|
4834 change_frame_size (f, config->frame_height, config->frame_width, 0);
|
|
4835
|
|
4836 /* Temporarily avoid any problems with windows that are smaller
|
|
4837 than they are supposed to be. */
|
|
4838 window_min_height = 1;
|
|
4839 window_min_width = 1;
|
|
4840
|
|
4841 /* OK, now restore all the windows in the window config.
|
|
4842 This may involve "undeleting" windows, since the
|
|
4843 windows in the window config may be deleted.
|
|
4844 */
|
|
4845 for (k = 0; k < config->saved_windows_count; k++)
|
|
4846 {
|
|
4847 p = SAVED_WINDOW_N (config, k);
|
|
4848 w = XWINDOW (p->window);
|
|
4849 w->next = Qnil;
|
|
4850
|
|
4851 /* The window might be dead. In this case, its redisplay
|
|
4852 structures were freed, so we need to reallocate them. */
|
|
4853 if (!w->face_cachels)
|
|
4854 {
|
|
4855 w->face_cachels = Dynarr_new (struct face_cachel);
|
|
4856 reset_face_cachels (w);
|
|
4857 }
|
|
4858 if (!w->glyph_cachels)
|
|
4859 w->glyph_cachels = Dynarr_new (struct glyph_cachel);
|
|
4860 if (!w->line_start_cache)
|
|
4861 w->line_start_cache = Dynarr_new (struct line_start_cache);
|
|
4862 w->dead = 0;
|
|
4863
|
|
4864 if (p->parent_index >= 0)
|
|
4865 w->parent = SAVED_WINDOW_N (config, p->parent_index)->window;
|
|
4866 else
|
|
4867 w->parent = Qnil;
|
|
4868
|
|
4869 if (p->prev_index >= 0)
|
|
4870 {
|
|
4871 w->prev = SAVED_WINDOW_N (config, p->prev_index)->window;
|
|
4872
|
|
4873 /* This is true for a minibuffer-only frame. */
|
|
4874 if (!NILP (w->mini_p) && EQ (w->prev, p->window))
|
|
4875 w->next = Qnil;
|
|
4876 else
|
|
4877 XWINDOW (w->prev)->next = p->window;
|
|
4878 }
|
|
4879 else
|
|
4880 {
|
|
4881 w->prev = Qnil;
|
|
4882 if (!NILP (w->parent))
|
|
4883 {
|
|
4884 if (WINDOW_WIDTH (p) == WINDOW_WIDTH (XWINDOW (w->parent)))
|
|
4885 {
|
|
4886 XWINDOW (w->parent)->vchild = p->window;
|
|
4887 XWINDOW (w->parent)->hchild = Qnil;
|
|
4888 }
|
|
4889 else
|
|
4890 {
|
|
4891 XWINDOW (w->parent)->hchild = p->window;
|
|
4892 XWINDOW (w->parent)->vchild = Qnil;
|
|
4893 }
|
|
4894 }
|
|
4895 }
|
|
4896 if (!w->config_mark)
|
|
4897 {
|
|
4898 /* #### This should be equivalent to the window previously
|
|
4899 having been dead. If we're brave, we'll put in an
|
|
4900 assertion to this effect. */
|
|
4901 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
|
|
4902 }
|
|
4903 else /* if (!EQ (w->buffer, p->buffer)) */
|
|
4904 {
|
|
4905 /* With the new redisplay we let it know that a change has
|
|
4906 been made and it will take care of the rest. If we don't
|
|
4907 tell it something has possibly changed it could lead to
|
|
4908 incorrect display. */
|
|
4909 MARK_WINDOWS_CHANGED (w);
|
|
4910 }
|
|
4911
|
|
4912 WINDOW_LEFT (w) = WINDOW_LEFT (p);
|
|
4913 WINDOW_TOP (w) = WINDOW_TOP (p);
|
|
4914 WINDOW_WIDTH (w) = WINDOW_WIDTH (p);
|
|
4915 WINDOW_HEIGHT (w) = WINDOW_HEIGHT (p);
|
|
4916 w->hscroll = p->hscroll;
|
|
4917 /* #### Here we need to restore the saved specs for
|
|
4918 has-modeline-p, scrollbar-width, scrollbar-height,
|
|
4919 modeline-shadow-thickness, left-margin-width,
|
|
4920 right-margin-width, and current-display-table. */
|
|
4921 w->dedicated = p->dedicated;
|
|
4922 w->line_cache_last_updated = Qzero;
|
|
4923 SET_LAST_MODIFIED (w, 1);
|
|
4924 SET_LAST_FACECHANGE (w);
|
|
4925 w->config_mark = 0;
|
|
4926
|
|
4927 /* Reinstall the saved buffer and pointers into it. */
|
|
4928 if (NILP (p->buffer))
|
|
4929 w->buffer = p->buffer;
|
|
4930 else
|
|
4931 {
|
|
4932 if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
|
|
4933 /* If saved buffer is alive, install it. */
|
|
4934 {
|
|
4935 w->buffer = p->buffer;
|
|
4936 w->start_at_line_beg = p->start_at_line_beg;
|
|
4937 set_marker_restricted (w->start[CURRENT_DISP],
|
|
4938 Fmarker_position (p->start),
|
|
4939 w->buffer);
|
|
4940 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
4941 Fmarker_position (p->pointm),
|
|
4942 w->buffer);
|
|
4943 set_marker_restricted (w->sb_point,
|
|
4944 Fmarker_position (p->sb_point),
|
|
4945 w->buffer);
|
|
4946 Fset_marker (XBUFFER (w->buffer)->mark,
|
|
4947 Fmarker_position (p->mark), w->buffer);
|
|
4948
|
|
4949 /* As documented in Fcurrent_window_configuration, don't
|
|
4950 save the location of point in the buffer which was current
|
|
4951 when the window configuration was recorded. */
|
|
4952 if (!EQ (p->buffer, new_current_buffer) &&
|
|
4953 XBUFFER (p->buffer) == current_buffer)
|
|
4954 Fgoto_char (w->pointm[CURRENT_DISP], Fcurrent_buffer ());
|
|
4955 }
|
|
4956 else if (NILP (w->buffer) ||
|
|
4957 !BUFFER_LIVE_P (XBUFFER (w->buffer)))
|
|
4958 /* Else if window's old buffer is dead too, get a live one. */
|
|
4959 {
|
|
4960 /* #### The following line makes me nervous... */
|
|
4961 /* w->buffer = Fcdr (Fcar (XFRAME (w->frame)->buffer_alist));*/
|
|
4962 w->buffer = Fget_buffer_create (QSscratch);
|
|
4963 /* w->buffer = Fother_buffer (Qnil, w->frame, Qnil); */
|
|
4964 /* This will set the markers to beginning of visible
|
|
4965 range. */
|
|
4966 set_marker_restricted (w->start[CURRENT_DISP], Qzero, w->buffer);
|
|
4967 set_marker_restricted (w->pointm[CURRENT_DISP], Qzero,
|
|
4968 w->buffer);
|
|
4969 set_marker_restricted (w->sb_point, Qzero, w->buffer);
|
|
4970 w->start_at_line_beg = 1;
|
|
4971 }
|
|
4972 else
|
|
4973 /* Keeping window's old buffer; make sure the markers
|
|
4974 are real. */
|
|
4975 {
|
|
4976 /* Set window markers at start of visible range. */
|
|
4977 if (XMARKER (w->start[CURRENT_DISP])->buffer == 0)
|
|
4978 set_marker_restricted (w->start[CURRENT_DISP], Qzero,
|
|
4979 w->buffer);
|
|
4980 if (XMARKER (w->sb_point)->buffer == 0)
|
|
4981 set_marker_restricted (w->sb_point, Qzero, w->buffer);
|
|
4982 if (XMARKER (w->pointm[CURRENT_DISP])->buffer == 0)
|
|
4983 set_marker_restricted (w->pointm[CURRENT_DISP],
|
|
4984 make_int
|
|
4985 (BUF_PT (XBUFFER (w->buffer))),
|
|
4986 w->buffer);
|
|
4987 w->start_at_line_beg = 1;
|
|
4988 }
|
|
4989 }
|
|
4990 }
|
|
4991
|
|
4992 FRAME_ROOT_WINDOW (f) = config->root_window;
|
|
4993 /* Note that FSFmacs unilaterally calls Fselect_window() here, and
|
|
4994 then calls do_switch_frame() below to select the frame that was
|
|
4995 recorded in the window config as being selected.
|
|
4996
|
|
4997 Instead, we don't ever change the selected frame, and either
|
|
4998 call Fselect_window() below if the window config's frame is
|
|
4999 currently selected, or just set the selected window of the
|
|
5000 window config's frame. */
|
|
5001
|
|
5002 /* Set the frame height to the value it had before this function. */
|
|
5003 if (previous_frame_height != FRAME_HEIGHT (f)
|
|
5004 || previous_frame_width != FRAME_WIDTH (f))
|
|
5005 change_frame_size (f, previous_frame_height, previous_frame_width, 0);
|
|
5006
|
|
5007 /* If restoring in the current frame make the window current,
|
|
5008 otherwise just update the frame selected_window slot to be
|
|
5009 the restored current_window. */
|
|
5010 if (f == selected_frame ())
|
|
5011 {
|
|
5012 /* When using `pop-window-configuration', often the minibuffer
|
|
5013 ends up as the selected window even though it's not active ...
|
|
5014 I really don't know the cause of this, but it should never
|
|
5015 happen. This kludge should fix it.
|
|
5016
|
|
5017 #### Find out why this is really going wrong. */
|
|
5018 if (!minibuf_level &&
|
|
5019 MINI_WINDOW_P (XWINDOW (config->current_window)))
|
|
5020 Fselect_window (Fnext_window (config->current_window,
|
|
5021 Qnil, Qnil, Qnil));
|
|
5022 else
|
|
5023 Fselect_window (config->current_window);
|
|
5024 if (!NILP (new_current_buffer))
|
|
5025 Fset_buffer (new_current_buffer);
|
|
5026 else
|
|
5027 Fset_buffer (XWINDOW (Fselected_window (Qnil))->buffer);
|
|
5028 #ifdef ENERGIZE
|
|
5029 energize_buffer_shown_hook (XWINDOW (Fselected_window (Qnil)));
|
|
5030 #endif
|
|
5031 }
|
|
5032 else
|
|
5033 set_frame_selected_window (f, config->current_window);
|
|
5034 }
|
|
5035
|
|
5036 /* Restore the minimum heights recorded in the configuration. */
|
|
5037 window_min_height = config->min_height;
|
|
5038 window_min_width = config->min_width;
|
|
5039
|
|
5040 #if 0 /* FSFmacs */
|
|
5041 /* see above comment */
|
|
5042 /* Fselect_window will have made f the selected frame, so we
|
|
5043 reselect the proper frame here. Fhandle_switch_frame will change the
|
|
5044 selected window too, but that doesn't make the call to
|
|
5045 Fselect_window above totally superfluous; it still sets f's
|
|
5046 selected window. */
|
|
5047 if (FRAME_LIVE_P (XFRAME (config->selected_frame)))
|
|
5048 do_switch_frame (config->selected_frame, Qnil, 0);
|
|
5049 #endif
|
|
5050
|
|
5051 Vminibuf_scroll_window = config->minibuf_scroll_window;
|
|
5052
|
|
5053 if (FRAME_LIVE_P (f))
|
|
5054 {
|
|
5055 /* Do this before calling recompute_all_cached_specifiers_in_window()
|
|
5056 so that things like redisplay_redraw_cursor() won't abort due
|
|
5057 to no window mirror present. */
|
|
5058 f->mirror_dirty = 1;
|
|
5059
|
|
5060 config = XWINDOW_CONFIGURATION (old_window_config);
|
|
5061 for (k = 0; k < config->saved_windows_count; k++)
|
|
5062 {
|
|
5063 p = SAVED_WINDOW_N (config, k);
|
|
5064 w = XWINDOW (p->window);
|
|
5065 /* Remember, we set w->config_mark on all currently visible
|
|
5066 windows, and reset it on all newly visible windows.
|
|
5067 Any windows still marked need to be deleted. */
|
|
5068 if (w->config_mark)
|
|
5069 {
|
|
5070 mark_window_as_deleted (w);
|
|
5071 w->config_mark = 0;
|
|
5072 }
|
|
5073 else
|
|
5074 {
|
|
5075 /* We just potentially changed the window's buffer and
|
|
5076 potentially turned a dead window into a live one,
|
|
5077 so we need to recompute the cached specifier values. */
|
|
5078 recompute_all_cached_specifiers_in_window (w);
|
|
5079 }
|
|
5080 }
|
|
5081 }
|
|
5082
|
|
5083 /* Now restore things, when everything else if OK. */
|
|
5084
|
|
5085 unbind_to (specpdl_count, Qnil);
|
|
5086
|
|
5087 UNGCPRO;
|
|
5088
|
149
|
5089 return Qnil;
|
0
|
5090 }
|
|
5091
|
|
5092 /* Mark all subwindows of a window as deleted. The argument
|
|
5093 W is actually the subwindow tree of the window in question. */
|
|
5094
|
|
5095 void
|
|
5096 delete_all_subwindows (struct window *w)
|
|
5097 {
|
|
5098 if (!NILP (w->next))
|
|
5099 delete_all_subwindows (XWINDOW (w->next));
|
|
5100 if (!NILP (w->vchild))
|
|
5101 delete_all_subwindows (XWINDOW (w->vchild));
|
|
5102 if (!NILP (w->hchild))
|
|
5103 delete_all_subwindows (XWINDOW (w->hchild));
|
|
5104
|
|
5105 mark_window_as_deleted (w);
|
|
5106 }
|
|
5107
|
|
5108
|
|
5109 static int
|
|
5110 count_windows (struct window *window)
|
|
5111 {
|
|
5112 int count = 1;
|
|
5113 if (!NILP (window->next))
|
|
5114 count += count_windows (XWINDOW (window->next));
|
|
5115 if (!NILP (window->vchild))
|
|
5116 count += count_windows (XWINDOW (window->vchild));
|
|
5117 if (!NILP (window->hchild))
|
|
5118 count += count_windows (XWINDOW (window->hchild));
|
|
5119 return count;
|
|
5120 }
|
|
5121
|
|
5122 static int
|
|
5123 saved_window_index (Lisp_Object window, struct window_config *config, int lim)
|
|
5124 {
|
|
5125 int j;
|
|
5126 for (j = 0; j < lim; j++)
|
|
5127 {
|
|
5128 if (EQ (SAVED_WINDOW_N (config, j)->window, window))
|
149
|
5129 return j;
|
0
|
5130 }
|
|
5131 abort ();
|
|
5132 return 0; /* suppress compiler warning */
|
|
5133 }
|
|
5134
|
|
5135 static int
|
|
5136 save_window_save (Lisp_Object window, struct window_config *config, int i)
|
|
5137 {
|
|
5138 struct saved_window *p;
|
|
5139 struct window *w;
|
|
5140
|
|
5141 for (; !NILP (window); window = w->next)
|
|
5142 {
|
|
5143 p = SAVED_WINDOW_N (config, i);
|
|
5144 w = XWINDOW (window);
|
|
5145
|
|
5146 i++;
|
|
5147 p->window = window;
|
|
5148 p->buffer = w->buffer;
|
|
5149 WINDOW_LEFT (p) = WINDOW_LEFT (w);
|
|
5150 WINDOW_TOP (p) = WINDOW_TOP (w);
|
|
5151 WINDOW_WIDTH (p) = WINDOW_WIDTH (w);
|
|
5152 WINDOW_HEIGHT (p) = WINDOW_HEIGHT (w);
|
|
5153 p->hscroll = w->hscroll;
|
|
5154 /* #### Here we need to save the specs for
|
|
5155 has-modeline-p, scrollbar-width, scrollbar-height,
|
|
5156 modeline-shadow-thickness, left-margin-width,
|
|
5157 right-margin-width, current-display-table, etc. */
|
|
5158 if (!NILP (w->buffer))
|
|
5159 {
|
|
5160 /* Save w's value of point in the window configuration.
|
|
5161 If w is the selected window, then get the value of point
|
|
5162 from the buffer; pointm is garbage in the selected window. */
|
|
5163 if (EQ (window, Fselected_window (Qnil)))
|
|
5164 {
|
|
5165 p->pointm = noseeum_make_marker ();
|
|
5166 Fset_marker (p->pointm,
|
|
5167 make_int (BUF_PT (XBUFFER (w->buffer))),
|
|
5168 w->buffer);
|
|
5169 }
|
|
5170 else
|
|
5171 p->pointm = noseeum_copy_marker (w->pointm[CURRENT_DISP], Qnil);
|
|
5172
|
|
5173 p->start = noseeum_copy_marker (w->start[CURRENT_DISP], Qnil);
|
|
5174 p->sb_point = noseeum_copy_marker (w->sb_point, Qnil);
|
|
5175 p->start_at_line_beg = w->start_at_line_beg;
|
|
5176
|
|
5177 p->mark = noseeum_copy_marker (XBUFFER (w->buffer)->mark, Qnil);
|
|
5178 }
|
|
5179 else
|
|
5180 {
|
|
5181 p->pointm = Qnil;
|
|
5182 p->start = Qnil;
|
|
5183 p->sb_point = Qnil;
|
|
5184 p->mark = Qnil;
|
|
5185 p->start_at_line_beg = 0;
|
|
5186 }
|
|
5187
|
|
5188 if (NILP (w->parent))
|
|
5189 p->parent_index = -1;
|
|
5190 else
|
|
5191 p->parent_index = saved_window_index (w->parent, config, i);
|
|
5192 if (NILP (w->prev))
|
|
5193 p->prev_index = -1;
|
|
5194 else
|
|
5195 p->prev_index = saved_window_index (w->prev, config, i);
|
|
5196 p->dedicated = w->dedicated;
|
|
5197 if (!NILP (w->vchild))
|
|
5198 i = save_window_save (w->vchild, config, i);
|
|
5199 if (!NILP (w->hchild))
|
|
5200 i = save_window_save (w->hchild, config, i);
|
|
5201 }
|
|
5202
|
|
5203 return i;
|
|
5204 }
|
|
5205
|
|
5206 #if 0 /* FSFmacs */
|
|
5207 /* Added to doc string:
|
|
5208
|
|
5209 This also records the currently selected frame, and FRAME's focus
|
|
5210 redirection (see `redirect-frame-focus').
|
|
5211
|
|
5212 */
|
|
5213 #endif
|
|
5214
|
20
|
5215 DEFUN ("current-window-configuration", Fcurrent_window_configuration, 0, 1, 0, /*
|
0
|
5216 Return an object representing the current window configuration of FRAME.
|
|
5217 If FRAME is nil or omitted, use the selected frame.
|
|
5218 This describes the number of windows, their sizes and current buffers,
|
|
5219 and for each displayed buffer, where display starts, and the positions of
|
|
5220 point and mark. An exception is made for point in the current buffer:
|
|
5221 its value is -not- saved.
|
20
|
5222 */
|
|
5223 (frame))
|
0
|
5224 {
|
|
5225 Lisp_Object result = Qnil;
|
|
5226 struct frame *f;
|
|
5227 int n_windows;
|
|
5228
|
|
5229 struct window_config *config;
|
|
5230
|
|
5231 f = decode_frame (frame);
|
|
5232
|
|
5233 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
|
|
5234 if (n_windows <= countof (Vwindow_configuration_free_list))
|
|
5235 config =
|
|
5236 XWINDOW_CONFIGURATION (allocate_managed_lcrecord
|
|
5237 (Vwindow_configuration_free_list
|
|
5238 [n_windows - 1]));
|
|
5239 else
|
|
5240 /* More than ten windows; just allocate directly */
|
|
5241 config = alloc_lcrecord (sizeof_window_config_for_n_windows (n_windows),
|
|
5242 lrecord_window_configuration);
|
|
5243 XSETWINDOW_CONFIGURATION (result, config);
|
|
5244
|
|
5245 config->frame_width = FRAME_WIDTH (f);
|
|
5246 config->frame_height = FRAME_HEIGHT (f);
|
|
5247 config->current_window = FRAME_SELECTED_WINDOW (f);
|
|
5248 XSETBUFFER (config->current_buffer, current_buffer);
|
|
5249 config->minibuf_scroll_window = Vminibuf_scroll_window;
|
|
5250 config->root_window = FRAME_ROOT_WINDOW (f);
|
|
5251 config->min_height = window_min_height;
|
|
5252 config->min_width = window_min_width;
|
|
5253 config->saved_windows_count = n_windows;
|
|
5254 #ifdef ENERGIZE
|
|
5255 {
|
|
5256 config->p_sheet_buffer = desired_psheet_buffer (f);
|
|
5257 if (ZEROP (config->p_sheet_buffer)) /* #### necessaryp? */
|
|
5258 config->p_sheet_buffer = Qnil;
|
|
5259 }
|
|
5260 #endif
|
|
5261 save_window_save (FRAME_ROOT_WINDOW (f), config, 0);
|
149
|
5262 return result;
|
0
|
5263 }
|
|
5264
|
|
5265 Lisp_Object
|
|
5266 save_window_excursion_unwind (Lisp_Object window_config)
|
|
5267 {
|
|
5268 Lisp_Object val = Fset_window_configuration (window_config);
|
|
5269 free_window_configuration (window_config);
|
|
5270 return val;
|
|
5271 }
|
|
5272
|
20
|
5273 DEFUN ("save-window-excursion", Fsave_window_excursion, 0, UNEVALLED, 0, /*
|
0
|
5274 Execute body, preserving window sizes and contents.
|
|
5275 Restores which buffer appears in which window, where display starts,
|
|
5276 as well as the current buffer.
|
|
5277 Does not restore the value of point in current buffer.
|
20
|
5278 */
|
|
5279 (args))
|
0
|
5280 {
|
|
5281 /* This function can GC */
|
|
5282 Lisp_Object val;
|
|
5283 int speccount = specpdl_depth ();
|
|
5284
|
|
5285 record_unwind_protect (save_window_excursion_unwind,
|
|
5286 Fcurrent_window_configuration (Qnil));
|
|
5287 val = Fprogn (args);
|
|
5288 return unbind_to (speccount, val);
|
|
5289 }
|
|
5290
|
|
5291
|
|
5292 #ifdef DEBUG_XEMACS
|
|
5293 /* This is short and simple in elisp, but... it was written to debug
|
|
5294 problems purely on the C side. That is where we need to call it so
|
|
5295 here it is. */
|
|
5296 static void
|
|
5297 debug_print_window (Lisp_Object window, int level)
|
|
5298 {
|
|
5299 Lisp_Object child;
|
|
5300 int i = level;
|
|
5301
|
|
5302 child = Fwindow_first_vchild (window);
|
|
5303 if (NILP (child))
|
|
5304 child = Fwindow_first_hchild (window);
|
|
5305
|
|
5306 while (i > 0)
|
|
5307 {
|
|
5308 fprintf (stderr, "\t");
|
|
5309 i--;
|
|
5310 }
|
|
5311
|
|
5312 fprintf (stderr, "#<window");
|
|
5313 if (!NILP (XWINDOW (window)->buffer) && BUFFERP (XWINDOW (window)->buffer))
|
|
5314 {
|
|
5315 struct buffer *b = XBUFFER (XWINDOW (window)->buffer);
|
16
|
5316 fprintf (stderr, " on %s", XSTRING_DATA (b->name));
|
0
|
5317 }
|
|
5318 fprintf (stderr, " 0x%x>", XWINDOW (window)->header.uid);
|
|
5319
|
|
5320 while (!NILP (child))
|
|
5321 {
|
|
5322 debug_print_window (child, level + 1);
|
|
5323 child = Fwindow_next_child (child);
|
|
5324 }
|
|
5325 }
|
|
5326
|
|
5327 void debug_print_windows (struct frame *f);
|
|
5328 void
|
|
5329 debug_print_windows (struct frame *f)
|
|
5330 {
|
|
5331 debug_print_window (f->root_window, 0);
|
|
5332 fprintf (stderr, "\n");
|
|
5333 }
|
|
5334 #endif /* DEBUG_XEMACS */
|
|
5335
|
|
5336
|
|
5337 /************************************************************************/
|
|
5338 /* initialization */
|
|
5339 /************************************************************************/
|
|
5340
|
|
5341 void
|
|
5342 syms_of_window (void)
|
|
5343 {
|
|
5344 defsymbol (&Qwindowp, "windowp");
|
|
5345 defsymbol (&Qwindow_live_p, "window-live-p");
|
|
5346 defsymbol (&Qwindow_configurationp, "window-configuration-p");
|
|
5347 defsymbol (&Qscroll_up, "scroll-up");
|
|
5348 defsymbol (&Qscroll_down, "scroll-down");
|
|
5349 defsymbol (&Qtemp_buffer_show_hook, "temp-buffer-show-hook");
|
|
5350 defsymbol (&Qdisplay_buffer, "display-buffer");
|
|
5351
|
|
5352 #ifdef MEMORY_USAGE_STATS
|
|
5353 defsymbol (&Qface_cache, "face-cache");
|
|
5354 defsymbol (&Qglyph_cache, "glyph-cache");
|
|
5355 defsymbol (&Qline_start_cache, "line-start-cache");
|
|
5356 #ifdef HAVE_SCROLLBARS
|
|
5357 defsymbol (&Qscrollbar_instances, "scrollbar-instances");
|
|
5358 #endif
|
|
5359 defsymbol (&Qother_redisplay, "other-redisplay");
|
|
5360 /* Qother in general.c */
|
|
5361 #endif
|
|
5362
|
20
|
5363 DEFSUBR (Fselected_window);
|
|
5364 DEFSUBR (Fminibuffer_window);
|
|
5365 DEFSUBR (Fwindow_minibuffer_p);
|
|
5366 DEFSUBR (Fwindowp);
|
|
5367 DEFSUBR (Fwindow_live_p);
|
|
5368 DEFSUBR (Fwindow_first_hchild);
|
|
5369 DEFSUBR (Fwindow_first_vchild);
|
|
5370 DEFSUBR (Fwindow_next_child);
|
|
5371 DEFSUBR (Fwindow_previous_child);
|
|
5372 DEFSUBR (Fwindow_parent);
|
|
5373 DEFSUBR (Fwindow_lowest_p);
|
|
5374 DEFSUBR (Fwindow_highest_p);
|
|
5375 DEFSUBR (Fwindow_leftmost_p);
|
|
5376 DEFSUBR (Fwindow_rightmost_p);
|
|
5377 DEFSUBR (Fpos_visible_in_window_p);
|
|
5378 DEFSUBR (Fwindow_buffer);
|
|
5379 DEFSUBR (Fwindow_frame);
|
|
5380 DEFSUBR (Fwindow_height);
|
|
5381 DEFSUBR (Fwindow_displayed_height);
|
|
5382 DEFSUBR (Fwindow_width);
|
|
5383 DEFSUBR (Fwindow_pixel_height);
|
|
5384 DEFSUBR (Fwindow_pixel_width);
|
|
5385 DEFSUBR (Fwindow_hscroll);
|
0
|
5386 #if 0 /* bogus RMS crock */
|
20
|
5387 DEFSUBR (Fwindow_redisplay_end_trigger);
|
|
5388 DEFSUBR (Fset_window_redisplay_end_trigger);
|
0
|
5389 #endif
|
20
|
5390 DEFSUBR (Fset_window_hscroll);
|
|
5391 DEFSUBR (Fwindow_pixel_edges);
|
|
5392 DEFSUBR (Fwindow_point);
|
|
5393 DEFSUBR (Fwindow_start);
|
|
5394 DEFSUBR (Fwindow_end);
|
|
5395 DEFSUBR (Fset_window_point);
|
|
5396 DEFSUBR (Fset_window_start);
|
|
5397 DEFSUBR (Fwindow_dedicated_p);
|
|
5398 DEFSUBR (Fset_window_dedicated_p);
|
|
5399 DEFSUBR (Fnext_window);
|
|
5400 DEFSUBR (Fprevious_window);
|
|
5401 DEFSUBR (Fnext_vertical_window);
|
|
5402 DEFSUBR (Fother_window);
|
|
5403 DEFSUBR (Fget_lru_window);
|
|
5404 DEFSUBR (Fget_largest_window);
|
|
5405 DEFSUBR (Fget_buffer_window);
|
|
5406 DEFSUBR (Fwindow_left_margin_pixel_width);
|
|
5407 DEFSUBR (Fwindow_right_margin_pixel_width);
|
|
5408 DEFSUBR (Fdelete_other_windows);
|
|
5409 DEFSUBR (Fdelete_windows_on);
|
|
5410 DEFSUBR (Freplace_buffer_in_windows);
|
|
5411 DEFSUBR (Fdelete_window);
|
|
5412 DEFSUBR (Fset_window_buffer);
|
|
5413 DEFSUBR (Fselect_window);
|
|
5414 DEFSUBR (Fsplit_window);
|
|
5415 DEFSUBR (Fenlarge_window);
|
|
5416 DEFSUBR (Fshrink_window);
|
|
5417 DEFSUBR (Fscroll_up);
|
|
5418 DEFSUBR (Fscroll_down);
|
|
5419 DEFSUBR (Fscroll_left);
|
|
5420 DEFSUBR (Fscroll_right);
|
|
5421 DEFSUBR (Fother_window_for_scrolling);
|
|
5422 DEFSUBR (Fscroll_other_window);
|
|
5423 DEFSUBR (Frecenter);
|
|
5424 DEFSUBR (Fmove_to_window_line);
|
0
|
5425 #ifdef MEMORY_USAGE_STATS
|
20
|
5426 DEFSUBR (Fwindow_memory_usage);
|
0
|
5427 #endif
|
20
|
5428 DEFSUBR (Fwindow_configuration_p);
|
|
5429 DEFSUBR (Fset_window_configuration);
|
|
5430 DEFSUBR (Fcurrent_window_configuration);
|
|
5431 DEFSUBR (Fsave_window_excursion);
|
0
|
5432 }
|
|
5433
|
|
5434 void
|
|
5435 vars_of_window (void)
|
|
5436 {
|
|
5437 /* Make sure all windows get marked */
|
|
5438 minibuf_window = Qnil;
|
|
5439 staticpro (&minibuf_window);
|
|
5440
|
|
5441 DEFVAR_BOOL ("scroll-on-clipped-lines", &scroll_on_clipped_lines /*
|
|
5442 *Non-nil means to scroll if point lands on a line which is clipped.
|
|
5443 */ );
|
|
5444 scroll_on_clipped_lines = 1;
|
|
5445
|
|
5446 DEFVAR_LISP ("temp-buffer-show-hook", &Vtemp_buffer_show_hook /*
|
|
5447 See `temp-buffer-show-function'.
|
|
5448 */ );
|
|
5449 Vtemp_buffer_show_hook = Qnil;
|
|
5450
|
|
5451 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function /*
|
|
5452 Non-nil means call as function to display a help buffer.
|
|
5453 The function is called with one argument, the buffer to be displayed.
|
|
5454 Used by `with-output-to-temp-buffer'.
|
|
5455 If this function is used, then it must do the entire job of showing
|
|
5456 the buffer; `temp-buffer-show-hook' is not run unless this function runs it.
|
|
5457 */ );
|
|
5458 Vtemp_buffer_show_function = Qnil;
|
|
5459
|
|
5460 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window /*
|
|
5461 Non-nil means it is the window that \\<minibuffer-local-map>\\[scroll-other-window] in minibuffer should scroll.
|
|
5462 */ );
|
|
5463 Vminibuf_scroll_window = Qnil;
|
|
5464
|
|
5465 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer /*
|
|
5466 If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window.
|
|
5467 */ );
|
|
5468 Vother_window_scroll_buffer = Qnil;
|
|
5469
|
|
5470 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines /*
|
|
5471 *Number of lines of continuity when scrolling by screenfuls.
|
|
5472 */ );
|
|
5473 next_screen_context_lines = 2;
|
|
5474
|
|
5475 DEFVAR_INT ("window-min-height", &window_min_height /*
|
|
5476 *Delete any window less than this tall (including its modeline).
|
|
5477 */ );
|
|
5478 window_min_height = 4;
|
|
5479
|
|
5480 DEFVAR_INT ("window-min-width", &window_min_width /*
|
|
5481 *Delete any window less than this wide.
|
|
5482 */ );
|
|
5483 window_min_width = 10;
|
|
5484
|
|
5485 {
|
|
5486 int i;
|
|
5487
|
|
5488 for (i = 0; i < countof (Vwindow_configuration_free_list); i++)
|
|
5489 {
|
|
5490 Vwindow_configuration_free_list[i] =
|
|
5491 make_lcrecord_list (sizeof_window_config_for_n_windows (i + 1),
|
|
5492 lrecord_window_configuration);
|
|
5493 staticpro (&Vwindow_configuration_free_list[i]);
|
|
5494 }
|
|
5495 }
|
|
5496 }
|
|
5497
|
|
5498 void
|
|
5499 specifier_vars_of_window (void)
|
|
5500 {
|
|
5501 DEFVAR_SPECIFIER ("modeline-shadow-thickness", &Vmodeline_shadow_thickness /*
|
|
5502 *How thick to draw 3D shadows around modelines.
|
|
5503 If this is set to 0, modelines will be the traditional 2D. Sizes above
|
|
5504 10 will be accepted but the maximum thickness that will be drawn is 10.
|
|
5505 This is a specifier; use `set-specifier' to change it.
|
|
5506 */ );
|
|
5507 Vmodeline_shadow_thickness = Fmake_specifier (Qinteger);
|
|
5508 /* The initial value for modeline-shadow-thickness is 2, but if the
|
|
5509 user removes all specifications we provide a fallback value of 0,
|
|
5510 which is probably what was expected. */
|
|
5511 set_specifier_fallback (Vmodeline_shadow_thickness,
|
|
5512 list1 (Fcons (Qnil, Qzero)));
|
|
5513 Fadd_spec_to_specifier (Vmodeline_shadow_thickness, make_int (2),
|
|
5514 Qnil, Qnil, Qnil);
|
|
5515 set_specifier_caching (Vmodeline_shadow_thickness,
|
|
5516 slot_offset (struct window,
|
|
5517 modeline_shadow_thickness),
|
|
5518 modeline_shadow_thickness_changed,
|
|
5519 0, 0);
|
|
5520
|
|
5521 DEFVAR_SPECIFIER ("has-modeline-p", &Vhas_modeline_p /*
|
|
5522 *Whether the modeline should be displayed.
|
|
5523 This is a specifier; use `set-specifier' to change it.
|
|
5524 */ );
|
|
5525 Vhas_modeline_p = Fmake_specifier (Qboolean);
|
|
5526 set_specifier_fallback (Vhas_modeline_p,
|
|
5527 list1 (Fcons (Qnil, Qt)));
|
|
5528 set_specifier_caching (Vhas_modeline_p,
|
|
5529 slot_offset (struct window,
|
|
5530 has_modeline_p),
|
|
5531 /* #### It's strange that we need a special
|
|
5532 flag to indicate that the shadow-thickness
|
|
5533 has changed, but not one to indicate that
|
|
5534 the modeline has been turned off or on. */
|
|
5535 some_window_value_changed,
|
|
5536 0, 0);
|
|
5537 }
|