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