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