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