0
|
1 /* Window definitions for XEmacs.
|
|
2 Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995
|
|
3 Free Software Foundation, Inc.
|
|
4 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
5 Copyright (C) 1995, 1996 Ben Wing.
|
|
6 Copyright (C) 1996 Chuck Thompson.
|
|
7
|
|
8 This file is part of XEmacs.
|
|
9
|
|
10 XEmacs is free software; you can redistribute it and/or modify it
|
|
11 under the terms of the GNU General Public License as published by the
|
|
12 Free Software Foundation; either version 2, or (at your option) any
|
|
13 later version.
|
|
14
|
|
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
18 for more details.
|
|
19
|
|
20 You should have received a copy of the GNU General Public License
|
|
21 along with XEmacs; see the file COPYING. If not, write to
|
|
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 Boston, MA 02111-1307, USA. */
|
|
24
|
|
25 /* Synched up with: FSF 19.30. */
|
|
26
|
|
27 #ifndef _XEMACS_WINDOW_H_
|
|
28 #define _XEMACS_WINDOW_H_
|
|
29
|
|
30 #include "redisplay.h"
|
|
31 #include "scrollbar.h"
|
|
32
|
|
33 /* All windows in use are arranged into a tree, with pointers up and down.
|
|
34
|
|
35 Windows that are leaves of the tree are actually displayed
|
|
36 and show the contents of buffers. Windows that are not leaves
|
|
37 are used for representing the way groups of leaf windows are
|
|
38 arranged on the frame. Leaf windows never become non-leaves.
|
|
39 They are deleted only by calling delete-window on them (but
|
|
40 this can be done implicitly). Combination windows can be created
|
|
41 and deleted at any time.
|
|
42
|
|
43 A leaf window has a non-nil buffer field, and also
|
|
44 has markers in its start and pointm fields. Non-leaf windows
|
|
45 have nil in these fields.
|
|
46
|
|
47 Non-leaf windows are either vertical or horizontal combinations.
|
|
48
|
|
49 A vertical combination window has children that are arranged on the frame
|
|
50 one above the next. Its vchild field points to the uppermost child.
|
|
51 The parent field of each of the children points to the vertical
|
|
52 combination window. The next field of each child points to the
|
|
53 child below it, or is nil for the lowest child. The prev field
|
|
54 of each child points to the child above it, or is nil for the
|
|
55 highest child.
|
|
56
|
|
57 A horizontal combination window has children that are side by side.
|
|
58 Its hchild field points to the leftmost child. In each child
|
|
59 the next field points to the child to the right and the prev field
|
|
60 points to the child to the left.
|
|
61
|
|
62 The children of a vertical combination window may be leaf windows
|
|
63 or horizontal combination windows. The children of a horizontal
|
|
64 combination window may be leaf windows or vertical combination windows.
|
|
65
|
|
66 At the top of the tree are two windows which have nil as parent.
|
|
67 The second of these is minibuf_window. The first one manages all
|
|
68 the frame area that is not minibuffer, and is called the root window.
|
|
69 Different windows can be the root at different times;
|
|
70 initially the root window is a leaf window, but if more windows
|
|
71 are created then that leaf window ceases to be root and a newly
|
|
72 made combination window becomes root instead.
|
|
73
|
|
74 In any case, on screens which have an ordinary window and a
|
|
75 minibuffer, prev of the minibuf window is the root window and next of
|
|
76 the root window is the minibuf window. On minibufferless screens or
|
|
77 minibuffer-only screens, the root window and the minibuffer window are
|
|
78 one and the same, so its prev and next members are nil.
|
|
79
|
|
80 A dead window has the `dead' flag set on it. Note that unlike other
|
|
81 dead objects, dead windows can be made live again through restoring a
|
|
82 window configuration. This means that the values in a dead window
|
|
83 need to be preserved, except for those that are reconstructed by from
|
|
84 the window configuration. */
|
|
85
|
|
86 struct window
|
|
87 {
|
|
88 struct lcrecord_header header;
|
|
89
|
|
90 /* The frame this window is on. */
|
|
91 Lisp_Object frame;
|
|
92 /* t if this window is a minibuffer window. */
|
|
93 Lisp_Object mini_p;
|
|
94 /* Following child (to right or down) at same level of tree */
|
|
95 Lisp_Object next;
|
|
96 /* Preceding child (to left or up) at same level of tree */
|
|
97 Lisp_Object prev;
|
|
98 /* First child of this window. */
|
|
99 /* vchild is used if this is a vertical combination,
|
|
100 hchild if this is a horizontal combination. */
|
|
101 Lisp_Object hchild, vchild;
|
|
102 /* The window this one is a child of. */
|
|
103 Lisp_Object parent;
|
|
104
|
|
105 /* The upper left corner coordinates of this window,
|
|
106 as integers (pixels) relative to upper left corner of frame = 0, 0 */
|
|
107 int pixel_left;
|
|
108 int pixel_top;
|
|
109 /* The size of the window (in pixels) */
|
|
110 int pixel_height;
|
|
111 int pixel_width;
|
|
112
|
|
113 /* The buffer displayed in this window */
|
|
114 /* Of the fields vchild, hchild and buffer, only one is non-nil. */
|
|
115 Lisp_Object buffer;
|
|
116 /* A marker pointing to where in the text to start displaying */
|
|
117 /* need one for each set of display structures */
|
|
118 Lisp_Object start[3];
|
|
119 /* A marker pointing to where in the text point is in this window,
|
|
120 used only when the window is not selected.
|
|
121 This exists so that when multiple windows show one buffer
|
|
122 each one can have its own value of point. */
|
|
123 /* need one for each set of display structures */
|
|
124 Lisp_Object pointm[3];
|
|
125 /* A marker pointing to where in the text the scrollbar is pointing */
|
|
126 Lisp_Object sb_point;
|
|
127 /* Number of columns display within the window is scrolled to the left. */
|
|
128 int hscroll;
|
|
129 /* Number saying how recently window was selected */
|
|
130 Lisp_Object use_time;
|
|
131 /* text.modified of displayed buffer as of last time display completed */
|
|
132 Lisp_Object last_modified[3];
|
|
133 /* Value of point at that time */
|
|
134 Lisp_Object last_point[3];
|
|
135 /* Value of start at that time */
|
|
136 Lisp_Object last_start[3];
|
|
137 /* buf.face_change as of last time display completed */
|
|
138 Lisp_Object last_facechange[3];
|
|
139
|
|
140 /* face cache elements correct for this window and its current buffer */
|
|
141 face_cachel_dynarr *face_cachels;
|
|
142 /* glyph cache elements correct for this window and its current buffer */
|
|
143 glyph_cachel_dynarr *glyph_cachels;
|
|
144
|
|
145
|
|
146 /* List of starting positions for display lines. Only valid if
|
|
147 buffer has not changed. */
|
|
148 line_start_cache_dynarr *line_start_cache;
|
|
149 Lisp_Object line_cache_last_updated;
|
|
150 int line_cache_validation_override;
|
|
151
|
|
152 /* Length of longest line currently displayed. Used to control the
|
|
153 width of the horizontal scrollbars. */
|
|
154 int max_line_len;
|
|
155
|
|
156 /* Frame coords of point at that time */
|
|
157 int last_point_x[3];
|
|
158 int last_point_y[3];
|
|
159
|
|
160 /* Number of characters in buffer past bottom of window,
|
|
161 as of last redisplay that finished. */
|
|
162 /* need one for each set of display structures */
|
|
163 int window_end_pos[3];
|
|
164
|
|
165 /* Non-nil means window is marked as dedicated. */
|
|
166 Lisp_Object dedicated;
|
|
167
|
|
168 #if 0 /* FSFmacs */
|
|
169 /* The column number currently displayed in this window's mode line,
|
|
170 or nil if column numbers are not being displayed. */
|
|
171 Lisp_Object column_number_displayed;
|
|
172 #endif
|
|
173 /* If redisplay in this window goes beyond this buffer position,
|
|
174 must run the redisplay-end-trigger-functions. */
|
|
175 Lisp_Object redisplay_end_trigger;
|
|
176
|
|
177 /* Set by redisplay to the last position seen. This is used
|
|
178 to implement the redisplay-end-trigger-functions. */
|
|
179 Bufpos last_redisplay_pos;
|
|
180
|
|
181 /* specifier values cached in the struct window: */
|
|
182
|
|
183 /* Display-table to use for displaying chars in this window. */
|
|
184 Lisp_Object display_table;
|
|
185 /* Thickness of modeline shadow, in pixels. If negative, draw
|
|
186 as recessed. */
|
|
187 Lisp_Object modeline_shadow_thickness;
|
|
188 /* Non-nil means to display a modeline for the buffer. */
|
|
189 Lisp_Object has_modeline_p;
|
|
190 #ifdef HAVE_SCROLLBARS
|
|
191 /* Width of vertical scrollbars. */
|
|
192 Lisp_Object scrollbar_width;
|
|
193 /* Height of horizontal scrollbars. */
|
|
194 Lisp_Object scrollbar_height;
|
|
195 /* Pointer to use for vertical and horizontal scrollbars. */
|
|
196 Lisp_Object scrollbar_pointer;
|
|
197 #endif
|
|
198 #ifdef HAVE_TOOLBARS
|
|
199 /* Toolbar specification for each of the four positions.
|
|
200 This is not a size hog because the value here is not copied,
|
|
201 and will be shared with the specs in the specifier. */
|
|
202 Lisp_Object toolbar[4];
|
|
203 /* Toolbar size for each of the four positions. */
|
|
204 Lisp_Object toolbar_size[4];
|
|
205 /* Toolbar visibility status for each of the four positions. */
|
|
206 Lisp_Object toolbar_visible_p[4];
|
|
207 /* Caption status of toolbar. */
|
|
208 Lisp_Object toolbar_buttons_captioned_p;
|
|
209 /* The following four don't really need to be cached except
|
|
210 that we need to know when they've changed. */
|
|
211 Lisp_Object default_toolbar;
|
|
212 Lisp_Object default_toolbar_width, default_toolbar_height;
|
|
213 Lisp_Object default_toolbar_visible_p;
|
|
214 #endif
|
|
215 Lisp_Object left_margin_width, right_margin_width;
|
|
216 Lisp_Object minimum_line_ascent, minimum_line_descent;
|
|
217 Lisp_Object use_left_overflow, use_right_overflow;
|
|
218 #ifdef HAVE_MENUBARS
|
|
219 /* Visibility of menubar. */
|
|
220 Lisp_Object menubar_visible_p;
|
|
221 #endif
|
|
222 Lisp_Object text_cursor_visible_p;
|
|
223
|
|
224 /* one-bit flags: */
|
|
225
|
|
226 /* marker used when restoring a window configuration */
|
|
227 unsigned int config_mark :1;
|
|
228 /* Non-zero means window was dead. */
|
|
229 unsigned int dead :1;
|
|
230 /* Non-zero means next redisplay must use the value of start
|
|
231 set up for it in advance. Set by scrolling commands. */
|
|
232 unsigned int force_start :1;
|
|
233 /* Non-zero means must regenerate modeline of this window */
|
|
234 unsigned int redo_modeline :1;
|
|
235 /* Non-zero means current value of `start'
|
|
236 was the beginning of a line when it was chosen. */
|
|
237 unsigned int start_at_line_beg :1;
|
|
238 /* new redisplay flag */
|
|
239 unsigned int windows_changed :1;
|
|
240 unsigned int shadow_thickness_changed :1;
|
|
241 };
|
|
242
|
|
243 #define CURRENT_DISP 0
|
|
244 #define DESIRED_DISP 1
|
|
245 #define CMOTION_DISP 2
|
|
246
|
|
247 struct window_mirror
|
|
248 {
|
|
249 /* Frame this mirror is on. */
|
|
250 struct frame *frame;
|
|
251
|
|
252 /* Following child (to right or down) at same level of tree */
|
|
253 struct window_mirror *next;
|
|
254
|
|
255 /* There is no prev field because we never traverse this structure
|
|
256 backwards. Same goes for the parent field. */
|
|
257
|
|
258 /* First child of this window. */
|
|
259 /* vchild is used if this is a vertical combination,
|
|
260 hchild if this is a horizontal combination. */
|
|
261 struct window_mirror *hchild, *vchild;
|
|
262
|
|
263 /* Dynamic array of display lines */
|
|
264 display_line_dynarr *current_display_lines;
|
|
265 display_line_dynarr *desired_display_lines;
|
|
266
|
|
267 /* Buffer current_display_lines represent. */
|
|
268 struct buffer *buffer;
|
|
269
|
|
270 #ifdef HAVE_SCROLLBARS
|
|
271 /* Scrollbars associated with window, if any. */
|
|
272 struct scrollbar_instance *scrollbar_vertical_instance;
|
|
273 struct scrollbar_instance *scrollbar_horizontal_instance;
|
|
274 #endif
|
|
275
|
|
276 /* Flag indicating whether a subwindow is currently being displayed. */
|
16
|
277 unsigned int subwindows_being_displayed :1;
|
0
|
278
|
|
279 /* Keep track of the truncation status in this window so we can
|
|
280 detect when it has changed. #### Magic variables would be a huge
|
|
281 win here. */
|
16
|
282 unsigned int truncate_win :1;
|
0
|
283 };
|
|
284
|
|
285 #ifdef emacs /* some things other than emacs want the structs */
|
|
286
|
|
287 DECLARE_LRECORD (window, struct window);
|
|
288 #define XWINDOW(x) XRECORD (x, window, struct window)
|
|
289 #define XSETWINDOW(x, p) XSETRECORD (x, p, window)
|
|
290 #define WINDOWP(x) RECORDP (x, window)
|
|
291 #define GC_WINDOWP(x) GC_RECORDP (x, window)
|
|
292 #define CHECK_WINDOW(x) CHECK_RECORD (x, window)
|
|
293 #define CONCHECK_WINDOW(x) CONCHECK_RECORD (x, window)
|
|
294
|
|
295 extern Lisp_Object Qwindow_live_p;
|
|
296
|
|
297 #define WINDOW_LIVE_P(x) (!(x)->dead)
|
|
298 #define CHECK_LIVE_WINDOW(x) \
|
|
299 do { CHECK_WINDOW (x); \
|
|
300 if (!WINDOW_LIVE_P (XWINDOW (x))) \
|
|
301 dead_wrong_type_argument (Qwindow_live_p, (x)); \
|
|
302 } while (0)
|
|
303 #define CONCHECK_LIVE_WINDOW(x) \
|
|
304 do { CONCHECK_WINDOW (x); \
|
|
305 if (!WINDOW_LIVE_P (XWINDOW (x))) \
|
|
306 x = wrong_type_argument (Qwindow_live_p, (x)); \
|
|
307 } while (0)
|
|
308
|
|
309 /* 1 if W is a minibuffer window. */
|
|
310 #define MINI_WINDOW_P(W) (!EQ ((W)->mini_p, Qnil))
|
|
311
|
|
312 /* 1 if we are dealing with a parentless window (this includes the
|
|
313 root window on a frame and the minibuffer window; both of these
|
|
314 are siblings). */
|
|
315 #define TOP_LEVEL_WINDOW_P(w) NILP ((w)->parent)
|
|
316
|
|
317 /* Set all redisplay flags indicating a window has changed */
|
|
318 #define MARK_WINDOWS_CHANGED(w) do { \
|
|
319 (w)->windows_changed = 1; \
|
|
320 if (!NILP (w->frame)) \
|
|
321 MARK_FRAME_WINDOWS_CHANGED (XFRAME (w->frame)); \
|
|
322 else \
|
|
323 windows_changed = 1; } while (0)
|
|
324
|
|
325 #define WINDOW_TTY_P(w) FRAME_TTY_P (XFRAME ((w)->frame))
|
|
326 #define WINDOW_X_P(w) FRAME_X_P (XFRAME ((w)->frame))
|
|
327 #define WINDOW_NS_P(w) FRAME_NS_P (XFRAME ((w)->frame))
|
|
328 #define WINDOW_WIN_P(w) FRAME_WIN_P (XFRAME ((w)->frame))
|
|
329
|
|
330 DECLARE_LRECORD (window_configuration, struct window_config);
|
|
331
|
|
332 /* The minibuffer window of the selected frame.
|
|
333 Note that you cannot test for minibufferness of an arbitrary window
|
|
334 by comparing against this; but you can test for minibufferness of
|
|
335 the selected window or of any window that is displayed. */
|
|
336 extern Lisp_Object minibuf_window;
|
|
337
|
|
338 /* Non-nil => window to for C-M-v to scroll
|
|
339 when the minibuffer is selected. */
|
|
340 extern Lisp_Object Vminibuf_scroll_window;
|
|
341
|
|
342 /* Prompt to display in front of the minibuffer contents, or nil */
|
|
343 extern Lisp_Object Vminibuf_prompt;
|
|
344
|
|
345 /* Depth in minibuffer invocations */
|
|
346 extern int minibuf_level;
|
|
347
|
|
348 Lisp_Object allocate_window (void);
|
|
349 int window_char_width (struct window *, int include_margins_p);
|
|
350 int window_char_height (struct window *, int include_gutters_p);
|
|
351 int window_displayed_height (struct window *);
|
|
352 int window_is_leftmost (struct window *w);
|
|
353 int window_is_rightmost (struct window *w);
|
|
354 int window_truncation_on (struct window *w);
|
|
355 int window_needs_vertical_divider (struct window *);
|
|
356 int window_scrollbar_width (struct window *w);
|
|
357 int window_scrollbar_height (struct window *w);
|
|
358 int window_modeline_height (struct window *w);
|
|
359 int window_left_margin_width (struct window *w);
|
|
360 int window_right_margin_width (struct window *w);
|
|
361 int window_top_gutter_height (struct window *w);
|
|
362 int window_bottom_gutter_height (struct window *w);
|
|
363 int window_left_gutter_width (struct window *w, int modeline);
|
|
364 int window_right_gutter_width (struct window *w, int modeline);
|
|
365 int window_bottom_toolbar_height (struct window *w);
|
|
366
|
|
367 void delete_all_subwindows (struct window *w);
|
|
368 void set_window_pixheight (Lisp_Object window, int pixheight,
|
|
369 int nodelete);
|
|
370 void set_window_pixwidth (Lisp_Object window, int pixwidth,
|
|
371 int nodelete);
|
|
372 void window_scroll (Lisp_Object window, Lisp_Object n, int direction,
|
|
373 Error_behavior errb);
|
|
374 int buffer_window_count (struct buffer *b, struct frame *f);
|
|
375 int buffer_window_mru (struct window *w);
|
|
376 void check_frame_size (struct frame *frame, int *rows, int *cols);
|
|
377 void mark_windows_in_use (Lisp_Object window, int mark);
|
|
378 struct window *decode_window (Lisp_Object window);
|
|
379 struct window *find_window_by_pixel_pos (unsigned int pix_x,
|
|
380 unsigned int pix_y,
|
|
381 Lisp_Object win);
|
|
382
|
|
383 /* new functions to handle the window mirror */
|
|
384 void free_window_mirror (struct window_mirror *mir);
|
|
385 Lisp_Object real_window (struct window_mirror *mir, int no_abort);
|
|
386 struct window_mirror *find_window_mirror (struct window *w);
|
|
387 display_line_dynarr *window_display_lines (struct window *w, int);
|
|
388 struct buffer *window_display_buffer (struct window *w);
|
|
389 void set_window_display_buffer (struct window *w, struct buffer *b);
|
|
390 void update_frame_window_mirror (struct frame *f);
|
|
391
|
|
392 int map_windows (struct frame *f,
|
|
393 int (*mapfun) (struct window *w, void *closure),
|
|
394 void *closure);
|
|
395 void some_window_value_changed (Lisp_Object specifier, struct window *w,
|
|
396 Lisp_Object oldval);
|
|
397
|
|
398 #define WINDOW_FRAME(w) ((w)->frame)
|
|
399 #define WINDOW_BUFFER(w) ((w)->buffer)
|
|
400 #define WINDOW_DEVICE(w) FRAME_DEVICE (XFRAME (WINDOW_FRAME (w)))
|
|
401 #define WINDOW_CONSOLE(w) DEVICE_CONSOLE (XDEVICE (WINDOW_DEVICE (w)))
|
|
402
|
|
403 /* XEmacs window size and positioning macros. */
|
|
404 #define WINDOW_TOP(w) ((w)->pixel_top)
|
|
405 #define WINDOW_TEXT_TOP(w) (WINDOW_TOP (w) + window_top_gutter_height (w))
|
|
406 #define WINDOW_BOTTOM(w) ((w)->pixel_top + (w)->pixel_height)
|
|
407 #define WINDOW_TEXT_BOTTOM(w) (WINDOW_BOTTOM (w) - window_bottom_gutter_height (w))
|
|
408 #define WINDOW_LEFT(w) ((w)->pixel_left)
|
|
409 #define WINDOW_TEXT_LEFT(w) (WINDOW_LEFT (w) + window_left_gutter_width (w, 0))
|
|
410 #define WINDOW_MODELINE_LEFT(w) \
|
|
411 (WINDOW_LEFT (w) + window_left_gutter_width (w, 1))
|
|
412 #define WINDOW_RIGHT(w) ((w)->pixel_left + (w)->pixel_width)
|
|
413 #define WINDOW_TEXT_RIGHT(w) \
|
|
414 (WINDOW_RIGHT (w) - window_right_gutter_width (w, 0))
|
|
415 #define WINDOW_MODELINE_RIGHT(w) \
|
|
416 (WINDOW_RIGHT (w) - window_right_gutter_width (w, 1))
|
|
417
|
|
418 #define WINDOW_HEIGHT(w) ((w)->pixel_height)
|
|
419 #define WINDOW_TEXT_HEIGHT(w) (WINDOW_TEXT_BOTTOM (w) - WINDOW_TEXT_TOP (w))
|
|
420 #define WINDOW_WIDTH(w) ((w)->pixel_width)
|
|
421 #define WINDOW_TEXT_WIDTH(w) (WINDOW_TEXT_RIGHT (w) - WINDOW_TEXT_LEFT (w))
|
|
422
|
|
423 #define WINDOW_HAS_MODELINE_P(w) (!NILP (w->has_modeline_p))
|
|
424
|
|
425 #define MODELINE_OFF_SHADOW_THICKNESS_ADJUSTED(win) \
|
|
426 abs ((!WINDOW_HAS_MODELINE_P (win) \
|
|
427 ? ((XINT (win->modeline_shadow_thickness) > 1) \
|
|
428 ? XINT (win->modeline_shadow_thickness) - 1 \
|
|
429 : ((XINT (win->modeline_shadow_thickness) < -1) \
|
|
430 ? XINT (win->modeline_shadow_thickness) + 1 \
|
|
431 : XINT (win->modeline_shadow_thickness))) \
|
|
432 : XINT (win->modeline_shadow_thickness)))
|
|
433
|
|
434 #define MODELINE_SHADOW_THICKNESS(win) \
|
|
435 (MODELINE_OFF_SHADOW_THICKNESS_ADJUSTED (win) > 10 \
|
|
436 ? 10 \
|
|
437 : MODELINE_OFF_SHADOW_THICKNESS_ADJUSTED (win))
|
|
438
|
|
439 #endif /* emacs */
|
|
440
|
|
441 #endif /* _XEMACS_WINDOW_H_ */
|