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