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