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