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