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