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