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