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