* window.h (WSET): Remove.
[bpt/emacs.git] / src / window.h
CommitLineData
83b2229f 1/* Window definitions for GNU Emacs.
acaf905b 2 Copyright (C) 1985-1986, 1993, 1995, 1997-2012
8cabe764 3 Free Software Foundation, Inc.
83b2229f
JB
4
5This file is part of GNU Emacs.
6
b9b1cc14 7GNU Emacs is free software: you can redistribute it and/or modify
83b2229f 8it under the terms of the GNU General Public License as published by
b9b1cc14
GM
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
83b2229f
JB
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
b9b1cc14 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
83b2229f 19
f43dd834
GM
20#ifndef WINDOW_H_INCLUDED
21#define WINDOW_H_INCLUDED
22
23#include "dispextern.h"
83b2229f 24
e8c17b81
PE
25INLINE_HEADER_BEGIN
26#ifndef WINDOW_INLINE
27# define WINDOW_INLINE INLINE
28#endif
29
6000501b
KS
30extern Lisp_Object Qleft, Qright;
31
83b2229f
JB
32/* Windows are allocated as if they were vectors, but then the
33Lisp data type is changed to Lisp_Window. They are garbage
34collected along with the vectors.
35
36All windows in use are arranged into a tree, with pointers up and down.
37
38Windows that are leaves of the tree are actually displayed
39and show the contents of buffers. Windows that are not leaves
40are used for representing the way groups of leaf windows are
44fa5b1e 41arranged on the frame. Leaf windows never become non-leaves.
83b2229f
JB
42They are deleted only by calling delete-window on them (but
43this can be done implicitly). Combination windows can be created
44and deleted at any time.
45
46A leaf window has a non-nil buffer field, and also
47 has markers in its start and pointm fields. Non-leaf windows
48 have nil in these fields.
49
50Non-leaf windows are either vertical or horizontal combinations.
51
44fa5b1e 52A vertical combination window has children that are arranged on the frame
83b2229f
JB
53one above the next. Its vchild field points to the uppermost child.
54The parent field of each of the children points to the vertical
55combination window. The next field of each child points to the
56child below it, or is nil for the lowest child. The prev field
57of each child points to the child above it, or is nil for the
58highest child.
59
60A horizontal combination window has children that are side by side.
61Its hchild field points to the leftmost child. In each child
62the next field points to the child to the right and the prev field
63points to the child to the left.
64
65The children of a vertical combination window may be leaf windows
66or horizontal combination windows. The children of a horizontal
67combination window may be leaf windows or vertical combination windows.
68
69At the top of the tree are two windows which have nil as parent.
70The second of these is minibuf_window. The first one manages all
44fa5b1e 71the frame area that is not minibuffer, and is called the root window.
83b2229f
JB
72Different windows can be the root at different times;
73initially the root window is a leaf window, but if more windows
74are created then that leaf window ceases to be root and a newly
75made combination window becomes root instead.
76
fbfed6f0
JB
77In any case, on screens which have an ordinary window and a
78minibuffer, prev of the minibuf window is the root window and next of
79the root window is the minibuf window. On minibufferless screens or
80minibuffer-only screens, the root window and the minibuffer window are
27daff1e 81one and the same, so its prev and next members are nil.
83b2229f 82
27daff1e 83A dead window has its buffer, hchild, and vchild windows all nil. */
83b2229f 84
f43dd834
GM
85struct cursor_pos
86{
87 /* Pixel position. These are always window relative. */
88 int x, y;
89
90 /* Glyph matrix position. */
91 int hpos, vpos;
92};
93
83b2229f
JB
94struct window
95 {
eab3844f 96 /* This is for Lisp; the terminal code does not refer to it. */
b102ceb1 97 struct vectorlike_header header;
eab3844f 98
44fa5b1e 99 /* The frame this window is on. */
d3d50620 100 Lisp_Object frame;
496e208e 101
496e208e
MR
102 /* Following (to right or down) and preceding (to left or up) child
103 at same level of tree. */
d3d50620
DA
104 Lisp_Object next;
105 Lisp_Object prev;
496e208e
MR
106
107 /* First child of this window: vchild is used if this is a vertical
108 combination, hchild if this is a horizontal combination. Of the
109 fields vchild, hchild and buffer, one and only one is non-nil
110 unless the window is dead. */
d3d50620
DA
111 Lisp_Object hchild;
112 Lisp_Object vchild;
496e208e
MR
113
114 /* The window this one is a child of. */
d3d50620 115 Lisp_Object parent;
496e208e
MR
116
117 /* The upper left corner coordinates of this window, as integers
118 relative to upper left corner of frame = 0, 0. */
d3d50620
DA
119 Lisp_Object left_col;
120 Lisp_Object top_line;
496e208e
MR
121
122 /* The size of the window. */
d3d50620
DA
123 Lisp_Object total_lines;
124 Lisp_Object total_cols;
496e208e
MR
125
126 /* The normal size of the window. */
d3d50620
DA
127 Lisp_Object normal_lines;
128 Lisp_Object normal_cols;
496e208e
MR
129
130 /* New sizes of the window. */
d3d50620
DA
131 Lisp_Object new_total;
132 Lisp_Object new_normal;
496e208e
MR
133
134 /* The buffer displayed in this window. Of the fields vchild,
135 hchild and buffer, one and only one is non-nil unless the window
136 is dead. */
d3d50620 137 Lisp_Object buffer;
496e208e 138
6bff6497
EZ
139 /* A marker pointing to where in the text to start displaying.
140 BIDI Note: This is the _logical-order_ start, i.e. the smallest
141 buffer position visible in the window, not necessarily the
142 character displayed in the top left corner of the window. */
d3d50620 143 Lisp_Object start;
496e208e 144
83b2229f
JB
145 /* A marker pointing to where in the text point is in this window,
146 used only when the window is not selected.
147 This exists so that when multiple windows show one buffer
148 each one can have its own value of point. */
d3d50620 149 Lisp_Object pointm;
496e208e 150
496e208e
MR
151 /* No permanent meaning; used by save-window-excursion's
152 bookkeeping. */
d3d50620 153 Lisp_Object temslot;
496e208e 154
a3c87d4e 155 /* This window's vertical scroll bar. This field is only for use
7c299e7a 156 by the window-system-dependent code which implements the
a3c87d4e
JB
157 scroll bars; it can store anything it likes here. If this
158 window is newly created and we haven't displayed a scroll bar in
159 it yet, or if the frame doesn't have any scroll bars, this is nil. */
d3d50620 160 Lisp_Object vertical_scroll_bar;
20a558dc 161
f43dd834
GM
162 /* Width of left and right marginal areas. A value of nil means
163 no margin. */
d3d50620
DA
164 Lisp_Object left_margin_cols;
165 Lisp_Object right_margin_cols;
6000501b
KS
166
167 /* Width of left and right fringes.
168 A value of nil or t means use frame values. */
d3d50620
DA
169 Lisp_Object left_fringe_width;
170 Lisp_Object right_fringe_width;
6000501b
KS
171
172 /* Pixel width of scroll bars.
173 A value of nil or t means use frame values. */
d3d50620 174 Lisp_Object scroll_bar_width;
496e208e 175
6000501b
KS
176 /* Type of vertical scroll bar. A value of nil means
177 no scroll bar. A value of t means use frame value. */
d3d50620 178 Lisp_Object vertical_scroll_bar_type;
f43dd834 179
f43dd834
GM
180 /* Z - the buffer position of the last glyph in the current matrix
181 of W. Only valid if WINDOW_END_VALID is not nil. */
d3d50620 182 Lisp_Object window_end_pos;
f43dd834
GM
183 /* Glyph matrix row of the last glyph in the current matrix
184 of W. Only valid if WINDOW_END_VALID is not nil. */
d3d50620 185 Lisp_Object window_end_vpos;
83b2229f
JB
186 /* t if window_end_pos is truly valid.
187 This is nil if nontrivial redisplay is preempted
44fa5b1e
JB
188 since in that case the frame image that window_end_pos
189 did not get onto the frame. */
d3d50620 190 Lisp_Object window_end_valid;
496e208e 191
83b2229f
JB
192 /* Display-table to use for displaying chars in this window.
193 Nil means use the buffer's own display-table. */
d3d50620 194 Lisp_Object display_table;
496e208e 195
c98ff5dd
DA
196 /* Non-nil usually means window is marked as dedicated.
197 Note Lisp code may set this to something beyond Qnil
198 and Qt, so bitfield can't be used here. */
d3d50620 199 Lisp_Object dedicated;
496e208e
MR
200
201 /* Line number and position of a line somewhere above the top of the
202 screen. If this field is nil, it means we don't have a base
203 line. */
d3d50620 204 Lisp_Object base_line_number;
e024395e
RS
205 /* If this field is nil, it means we don't have a base line.
206 If it is a buffer, it means don't display the line number
207 as long as the window shows that buffer. */
d3d50620 208 Lisp_Object base_line_pos;
496e208e 209
096855a6
RS
210 /* If we have highlighted the region (or any part of it),
211 this is the mark position that we used, as an integer. */
d3d50620 212 Lisp_Object region_showing;
496e208e 213
1262267a
KH
214 /* The column number currently displayed in this window's mode line,
215 or nil if column numbers are not being displayed. */
d3d50620 216 Lisp_Object column_number_displayed;
496e208e 217
a3bee872
RS
218 /* If redisplay in this window goes beyond this buffer position,
219 must run the redisplay-end-trigger-hook. */
d3d50620 220 Lisp_Object redisplay_end_trigger;
177c0ea7 221
b6f67890 222 /* t means this window's child windows are not (re-)combined. */
d3d50620 223 Lisp_Object combination_limit;
496e208e
MR
224
225 /* Alist of <buffer, window-start, window-point> triples listing
226 buffers previously shown in this window. */
d3d50620 227 Lisp_Object prev_buffers;
496e208e
MR
228
229 /* List of buffers re-shown in this window. */
d3d50620 230 Lisp_Object next_buffers;
496e208e 231
e1dbe924 232 /* An alist with parameters. */
d3d50620 233 Lisp_Object window_parameters;
e6841c3b 234
f43dd834
GM
235 /* No Lisp data may follow below this point without changing
236 mark_object in alloc.c. The member current_matrix must be the
237 first non-Lisp member. */
238
239 /* Glyph matrices. */
240 struct glyph_matrix *current_matrix;
241 struct glyph_matrix *desired_matrix;
242
45942c7d
DA
243 /* Number saying how recently window was selected. */
244 int use_time;
245
246 /* Unique number of window assigned when it was created. */
247 int sequence_number;
248
80b00b08 249 /* Number of columns display within the window is scrolled to the left. */
ea2ac797 250 ptrdiff_t hscroll;
80b00b08
DA
251
252 /* Minimum hscroll for automatic hscrolling. This is the value
253 the user has set, by set-window-hscroll for example. */
ea2ac797 254 ptrdiff_t min_hscroll;
80b00b08
DA
255
256 /* Displayed buffer's text modification events counter as of last time
257 display completed. */
258 EMACS_INT last_modified;
259
260 /* Displayed buffer's overlays modification events counter as of last
261 complete update. */
262 EMACS_INT last_overlay_modified;
263
264 /* Value of point at that time. Since this is a position in a buffer,
265 it should be positive. */
266 ptrdiff_t last_point;
267
71a0ff9a
KS
268 /* Scaling factor for the glyph_matrix size calculation in this window.
269 Used if window contains many small images or uses proportional fonts,
270 as the normal may yield a matrix which is too small. */
271 int nrows_scale_factor, ncols_scale_factor;
272
f43dd834
GM
273 /* Cursor position as of last update that completed without
274 pause. This is the position of last_point. */
275 struct cursor_pos last_cursor;
276
277 /* Intended cursor position. This is a position within the
278 glyph matrix. */
279 struct cursor_pos cursor;
177c0ea7 280
f43dd834
GM
281 /* Where the cursor actually is. */
282 struct cursor_pos phys_cursor;
177c0ea7
JB
283
284 /* Cursor type and width of last cursor drawn on the window.
7e913f91
KS
285 Used for X and w32 frames; -1 initially. */
286 int phys_cursor_type, phys_cursor_width;
f43dd834
GM
287
288 /* This is handy for undrawing the cursor. */
289 int phys_cursor_ascent, phys_cursor_height;
177c0ea7 290
c98ff5dd
DA
291 /* Non-zero if this window is a minibuffer window. */
292 unsigned mini : 1;
293
294 /* Non-zero means must regenerate mode line of this window */
295 unsigned update_mode_line : 1;
296
297 /* Non-nil if the buffer was "modified" when the window
298 was last updated. */
299 unsigned last_had_star : 1;
300
301 /* Non-zero means current value of `start'
302 was the beginning of a line when it was chosen. */
303 unsigned start_at_line_beg : 1;
304
305 /* Non-zero means next redisplay must use the value of start
306 set up for it in advance. Set by scrolling commands. */
307 unsigned force_start : 1;
308
309 /* Non-zero means we have explicitly changed the value of start,
310 but that the next redisplay is not obliged to use the new value.
311 This is used in Fdelete_other_windows to force a call to
312 Vwindow_scroll_functions; also by Frecenter with argument. */
313 unsigned optional_new_start : 1;
314
f43dd834
GM
315 /* Non-zero means the cursor is currently displayed. This can be
316 set to zero by functions overpainting the cursor image. */
317 unsigned phys_cursor_on_p : 1;
318
319 /* 0 means cursor is logically on, 1 means it's off. Used for
320 blinking cursor. */
321 unsigned cursor_off_p : 1;
322
323 /* Value of cursor_off_p as of the last redisplay. */
324 unsigned last_cursor_off_p : 1;
325
326 /* 1 means desired matrix has been build and window must be
327 updated in update_frame. */
328 unsigned must_be_updated_p : 1;
329
330 /* Flag indicating that this window is not a real one.
331 Currently only used for menu bar windows of frames. */
332 unsigned pseudo_window_p : 1;
333
91a47a68
DN
334 /* 1 means the window start of this window is frozen and may not
335 be changed during redisplay. If point is not in the window,
336 accept that. */
337 unsigned frozen_window_start_p : 1;
338
2af3565e
DA
339 /* Non-zero means fringes are drawn outside display margins.
340 Otherwise draw them between margin areas and text. */
341 unsigned fringes_outside_margins : 1;
342
f43dd834
GM
343 /* Amount by which lines of this window are scrolled in
344 y-direction (smooth scrolling). */
345 int vscroll;
177c0ea7 346
2af3565e
DA
347 /* Z_BYTE - the buffer position of the last glyph in the current matrix of W.
348 Should be nonnegative, and only valid if window_end_valid is not nil. */
349 ptrdiff_t window_end_bytepos;
f43dd834 350};
83b2229f 351
e8c17b81
PE
352/* Most code should use these functions to set Lisp fields in struct
353 window. */
354WINDOW_INLINE void
355wset_buffer (struct window *w, Lisp_Object val)
356{
357 w->buffer = val;
358}
359WINDOW_INLINE void
360wset_frame (struct window *w, Lisp_Object val)
361{
362 w->frame = val;
363}
364WINDOW_INLINE void
365wset_left_col (struct window *w, Lisp_Object val)
366{
367 w->left_col = val;
368}
369WINDOW_INLINE void
370wset_next (struct window *w, Lisp_Object val)
371{
372 w->next = val;
373}
374WINDOW_INLINE void
375wset_prev (struct window *w, Lisp_Object val)
376{
377 w->prev = val;
378}
379WINDOW_INLINE void
380wset_redisplay_end_trigger (struct window *w, Lisp_Object val)
381{
382 w->redisplay_end_trigger = val;
383}
384WINDOW_INLINE void
385wset_top_line (struct window *w, Lisp_Object val)
386{
387 w->top_line = val;
388}
389WINDOW_INLINE void
390wset_total_cols (struct window *w, Lisp_Object val)
391{
392 w->total_cols = val;
393}
394WINDOW_INLINE void
395wset_total_lines (struct window *w, Lisp_Object val)
396{
397 w->total_lines = val;
398}
399WINDOW_INLINE void
400wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
401{
402 w->vertical_scroll_bar = val;
403}
404WINDOW_INLINE void
405wset_window_end_pos (struct window *w, Lisp_Object val)
406{
407 w->window_end_pos = val;
408}
409WINDOW_INLINE void
410wset_window_end_valid (struct window *w, Lisp_Object val)
411{
412 w->window_end_valid = val;
413}
414WINDOW_INLINE void
415wset_window_end_vpos (struct window *w, Lisp_Object val)
416{
417 w->window_end_vpos = val;
418}
419
420
83b2229f
JB
421/* 1 if W is a minibuffer window. */
422
c98ff5dd 423#define MINI_WINDOW_P(W) ((W)->mini)
83b2229f 424
6000501b
KS
425/* General window layout:
426
427 LEFT_EDGE_COL RIGHT_EDGE_COL
428 | |
429 | |
430 | BOX_LEFT_EDGE_COL |
431 | | BOX_RIGHT_EDGE_COL |
432 | | | |
433 v v v v
434 <-><-><---><-----------><---><-><->
435 ^ ^ ^ ^ ^ ^ ^
436 | | | | | | |
437 | | | | | | +-- RIGHT_SCROLL_BAR_COLS
438 | | | | | +----- RIGHT_FRINGE_WIDTH
439 | | | | +--------- RIGHT_MARGIN_COLS
440 | | | |
441 | | | +------------------ TEXT_AREA_COLS
442 | | |
443 | | +--------------------------- LEFT_MARGIN_COLS
444 | +------------------------------- LEFT_FRINGE_WIDTH
445 +---------------------------------- LEFT_SCROLL_BAR_COLS
754dc3d8 446
6000501b
KS
447*/
448
449
450/* A handy macro. */
451
452#define WINDOW_XFRAME(W) \
453 (XFRAME (WINDOW_FRAME ((W))))
454
455/* Return the canonical column width of the frame of window W. */
456
457#define WINDOW_FRAME_COLUMN_WIDTH(W) \
458 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
459
460/* Return the canonical column width of the frame of window W. */
461
462#define WINDOW_FRAME_LINE_HEIGHT(W) \
463 (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
464
92f774f3 465/* Return the width of window W in canonical column units.
6000501b 466 This includes scroll bars and fringes. */
8516ba9a 467
6000501b 468#define WINDOW_TOTAL_COLS(W) \
d3d50620 469 (XFASTINT (W->total_cols))
6000501b 470
92f774f3 471/* Return the height of window W in canonical line units.
6000501b
KS
472 This includes header and mode lines, if any. */
473
474#define WINDOW_TOTAL_LINES(W) \
d3d50620 475 (XFASTINT (W->total_lines))
6000501b 476
6000501b
KS
477/* Return the total pixel width of window W. */
478
479#define WINDOW_TOTAL_WIDTH(W) \
480 (WINDOW_TOTAL_COLS (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
481
482/* Return the total pixel height of window W. */
483
484#define WINDOW_TOTAL_HEIGHT(W) \
485 (WINDOW_TOTAL_LINES (W) * WINDOW_FRAME_LINE_HEIGHT (W))
486
496e208e
MR
487/* For HORFLAG non-zero the total number of columns of window W. Otherwise
488 the total number of lines of W. */
489
490#define WINDOW_TOTAL_SIZE(w, horflag) \
491 (horflag ? WINDOW_TOTAL_COLS (w) : WINDOW_TOTAL_LINES (w))
492
493/* The smallest acceptable dimensions for a window. Anything smaller
494 might crash Emacs. */
495
496#define MIN_SAFE_WINDOW_WIDTH (2)
497#define MIN_SAFE_WINDOW_HEIGHT (1)
6000501b
KS
498
499/* Return the canonical frame column at which window W starts.
500 This includes a left-hand scroll bar, if any. */
501
502#define WINDOW_LEFT_EDGE_COL(W) \
d3d50620 503 (XFASTINT (W->left_col))
6000501b
KS
504
505/* Return the canonical frame column before which window W ends.
8516ba9a
RS
506 This includes a right-hand scroll bar, if any. */
507
6000501b
KS
508#define WINDOW_RIGHT_EDGE_COL(W) \
509 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
8516ba9a 510
6000501b
KS
511/* Return the canonical frame line at which window W starts.
512 This includes a header line, if any. */
513
514#define WINDOW_TOP_EDGE_LINE(W) \
d3d50620 515 (XFASTINT (W->top_line))
6000501b
KS
516
517/* Return the canonical frame line before which window W ends.
518 This includes a mode line, if any. */
519
520#define WINDOW_BOTTOM_EDGE_LINE(W) \
521 (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
522
523
524/* Return the frame x-position at which window W starts.
525 This includes a left-hand scroll bar, if any. */
526
527#define WINDOW_LEFT_EDGE_X(W) \
528 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
529 + WINDOW_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
530
531/* Return the frame x- position before which window W ends.
532 This includes a right-hand scroll bar, if any. */
533
534#define WINDOW_RIGHT_EDGE_X(W) \
535 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
536 + WINDOW_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
537
4b00d3b1
YM
538/* 1 if W is a menu bar window. */
539
540#define WINDOW_MENU_BAR_P(W) \
e69b0960
DA
541 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
542 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
4b00d3b1
YM
543
544/* 1 if W is a tool bar window. */
545
546#define WINDOW_TOOL_BAR_P(W) \
e69b0960
DA
547 (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
548 && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
4b00d3b1 549
6000501b
KS
550/* Return the frame y-position at which window W starts.
551 This includes a header line, if any. */
552
553#define WINDOW_TOP_EDGE_Y(W) \
4b00d3b1
YM
554 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
555 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
6000501b
KS
556 + WINDOW_TOP_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
557
558/* Return the frame y-position before which window W ends.
559 This includes a mode line, if any. */
560
561#define WINDOW_BOTTOM_EDGE_Y(W) \
4b00d3b1
YM
562 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
563 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
6000501b 564 + WINDOW_BOTTOM_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
14a65ffe 565
8516ba9a 566
177c0ea7 567/* 1 if window W takes up the full width of its frame. */
8516ba9a
RS
568
569#define WINDOW_FULL_WIDTH_P(W) \
6000501b
KS
570 (WINDOW_TOTAL_COLS (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
571
572/* 1 if window W's has no other windows to its left in its frame. */
573
574#define WINDOW_LEFTMOST_P(W) \
575 (WINDOW_LEFT_EDGE_COL (W) == 0)
8516ba9a 576
177c0ea7 577/* 1 if window W's has no other windows to its right in its frame. */
8516ba9a
RS
578
579#define WINDOW_RIGHTMOST_P(W) \
6000501b
KS
580 (WINDOW_RIGHT_EDGE_COL (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
581
582
583/* Return the frame column at which the text (or left fringe) in
584 window W starts. This is different from the `LEFT_EDGE' because it
585 does not include a left-hand scroll bar if any. */
586
587#define WINDOW_BOX_LEFT_EDGE_COL(W) \
588 (WINDOW_LEFT_EDGE_COL (W) \
589 + WINDOW_LEFT_SCROLL_BAR_COLS (W))
590
591/* Return the window column before which the text in window W ends.
592 This is different from WINDOW_RIGHT_EDGE_COL because it does not
593 include a scroll bar or window-separating line on the right edge. */
594
595#define WINDOW_BOX_RIGHT_EDGE_COL(W) \
596 (WINDOW_RIGHT_EDGE_COL (W) \
597 - WINDOW_RIGHT_SCROLL_BAR_COLS (W))
598
599
600/* Return the frame position at which the text (or left fringe) in
601 window W starts. This is different from the `LEFT_EDGE' because it
602 does not include a left-hand scroll bar if any. */
603
604#define WINDOW_BOX_LEFT_EDGE_X(W) \
605 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
606 + WINDOW_BOX_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
607
608/* Return the window column before which the text in window W ends.
609 This is different from WINDOW_RIGHT_EDGE_COL because it does not
610 include a scroll bar or window-separating line on the right edge. */
611
612#define WINDOW_BOX_RIGHT_EDGE_X(W) \
613 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
614 + WINDOW_BOX_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
615
616
617/* Width of left margin area in columns. */
618
d3d50620
DA
619#define WINDOW_LEFT_MARGIN_COLS(W) \
620 (NILP (W->left_margin_cols) \
621 ? 0 \
622 : XINT (W->left_margin_cols))
6000501b
KS
623
624/* Width of right marginal area in columns. */
625
d3d50620
DA
626#define WINDOW_RIGHT_MARGIN_COLS(W) \
627 (NILP (W->right_margin_cols) \
628 ? 0 \
629 : XINT (W->right_margin_cols))
6000501b
KS
630
631/* Width of left margin area in pixels. */
632
d3d50620
DA
633#define WINDOW_LEFT_MARGIN_WIDTH(W) \
634 (NILP (W->left_margin_cols) \
635 ? 0 \
636 : (XINT (W->left_margin_cols) \
6000501b
KS
637 * WINDOW_FRAME_COLUMN_WIDTH (W)))
638
639/* Width of right marginal area in pixels. */
640
d3d50620
DA
641#define WINDOW_RIGHT_MARGIN_WIDTH(W) \
642 (NILP (W->right_margin_cols) \
643 ? 0 \
644 : (XINT (W->right_margin_cols) \
6000501b
KS
645 * WINDOW_FRAME_COLUMN_WIDTH (W)))
646
647/* Total width of fringes reserved for drawing truncation bitmaps,
648 continuation bitmaps and alike. The width is in canonical char
649 units of the frame. This must currently be the case because window
650 sizes aren't pixel values. If it weren't the case, we wouldn't be
651 able to split windows horizontally nicely. */
652
d3d50620
DA
653#define WINDOW_FRINGE_COLS(W) \
654 ((INTEGERP (W->left_fringe_width) \
655 || INTEGERP (W->right_fringe_width)) \
656 ? ((WINDOW_LEFT_FRINGE_WIDTH (W) \
657 + WINDOW_RIGHT_FRINGE_WIDTH (W) \
658 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
659 / WINDOW_FRAME_COLUMN_WIDTH (W)) \
6000501b
KS
660 : FRAME_FRINGE_COLS (WINDOW_XFRAME (W)))
661
01aa0b2e
RS
662/* Column-width of the left and right fringe. */
663
d3d50620
DA
664#define WINDOW_LEFT_FRINGE_COLS(W) \
665 ((WINDOW_LEFT_FRINGE_WIDTH ((W)) \
666 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
01aa0b2e
RS
667 / WINDOW_FRAME_COLUMN_WIDTH (W))
668
d3d50620
DA
669#define WINDOW_RIGHT_FRINGE_COLS(W) \
670 ((WINDOW_RIGHT_FRINGE_WIDTH ((W)) \
671 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
01aa0b2e
RS
672 / WINDOW_FRAME_COLUMN_WIDTH (W))
673
6000501b
KS
674/* Pixel-width of the left and right fringe. */
675
676#define WINDOW_LEFT_FRINGE_WIDTH(W) \
d3d50620
DA
677 (INTEGERP (W->left_fringe_width) \
678 ? XFASTINT (W->left_fringe_width) \
6000501b
KS
679 : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
680
681#define WINDOW_RIGHT_FRINGE_WIDTH(W) \
d3d50620
DA
682 (INTEGERP (W->right_fringe_width) \
683 ? XFASTINT (W->right_fringe_width) \
6000501b
KS
684 : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
685
686/* Total width of fringes in pixels. */
687
688#define WINDOW_TOTAL_FRINGE_WIDTH(W) \
689 (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
690
691/* Are fringes outside display margins in window W. */
692
693#define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
2af3565e 694 ((W)->fringes_outside_margins)
6000501b
KS
695
696/* Say whether scroll bars are currently enabled for window W,
697 and which side they are on. */
698
699#define WINDOW_VERTICAL_SCROLL_BAR_TYPE(w) \
d3d50620 700 (EQ (w->vertical_scroll_bar_type, Qt) \
6000501b 701 ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (w)) \
d3d50620 702 : EQ (w->vertical_scroll_bar_type, Qleft) \
6000501b 703 ? vertical_scroll_bar_left \
d3d50620 704 : EQ (w->vertical_scroll_bar_type, Qright) \
6000501b
KS
705 ? vertical_scroll_bar_right \
706 : vertical_scroll_bar_none) \
707
708#define WINDOW_HAS_VERTICAL_SCROLL_BAR(w) \
d3d50620 709 (EQ (w->vertical_scroll_bar_type, Qt) \
6000501b 710 ? FRAME_HAS_VERTICAL_SCROLL_BARS (WINDOW_XFRAME (w)) \
d3d50620 711 : !NILP (w->vertical_scroll_bar_type))
6000501b
KS
712
713#define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(w) \
d3d50620 714 (EQ (w->vertical_scroll_bar_type, Qt) \
6000501b 715 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (WINDOW_XFRAME (w)) \
d3d50620 716 : EQ (w->vertical_scroll_bar_type, Qleft))
6000501b 717
d3d50620
DA
718#define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT(w) \
719 (EQ (w->vertical_scroll_bar_type, Qt) \
720 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (WINDOW_XFRAME (w)) \
721 : EQ (w->vertical_scroll_bar_type, Qright))
6000501b
KS
722
723/* Width that a scroll bar in window W should have, if there is one.
724 Measured in pixels. If scroll bars are turned off, this is still
725 nonzero. */
726
727#define WINDOW_CONFIG_SCROLL_BAR_WIDTH(w) \
d3d50620
DA
728 (INTEGERP (w->scroll_bar_width) \
729 ? XFASTINT (w->scroll_bar_width) \
6000501b
KS
730 : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (w)))
731
732/* Width that a scroll bar in window W should have, if there is one.
733 Measured in columns (characters). If scroll bars are turned off,
734 this is still nonzero. */
735
736#define WINDOW_CONFIG_SCROLL_BAR_COLS(w) \
d3d50620
DA
737 (INTEGERP (w->scroll_bar_width) \
738 ? ((XFASTINT (w->scroll_bar_width) \
6000501b
KS
739 + WINDOW_FRAME_COLUMN_WIDTH (w) - 1) \
740 / WINDOW_FRAME_COLUMN_WIDTH (w)) \
741 : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (w)))
742
743/* Width of a scroll bar in window W, measured in columns (characters),
744 but only if scroll bars are on the left. If scroll bars are on
745 the right in this frame, or there are no scroll bars, value is 0. */
746
747#define WINDOW_LEFT_SCROLL_BAR_COLS(w) \
d3d50620 748 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
6000501b
KS
749 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w)) \
750 : 0)
751
752/* Width of a left scroll bar area in window W , measured in pixels. */
753
d3d50620
DA
754#define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(w) \
755 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
6000501b
KS
756 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
757 : 0)
758
759/* Width of a scroll bar in window W, measured in columns (characters),
760 but only if scroll bars are on the right. If scroll bars are on
761 the left in this frame, or there are no scroll bars, value is 0. */
762
763#define WINDOW_RIGHT_SCROLL_BAR_COLS(w) \
d3d50620 764 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
6000501b
KS
765 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
766 : 0)
767
768/* Width of a left scroll bar area in window W , measured in pixels. */
769
770#define WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(w) \
771 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
772 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
773 : 0)
774
775
776/* Actual width of a scroll bar in window W, measured in columns. */
777
778#define WINDOW_SCROLL_BAR_COLS(w) \
779 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
780 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
781 : 0)
782
783/* Width of a left scroll bar area in window W , measured in pixels. */
784
785#define WINDOW_SCROLL_BAR_AREA_WIDTH(w) \
d3d50620 786 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
6000501b
KS
787 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
788 : 0)
789
790
791/* Return the frame position where the scroll bar of window W starts. */
792
793#define WINDOW_SCROLL_BAR_AREA_X(W) \
794 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
795 ? WINDOW_BOX_RIGHT_EDGE_X (W) \
796 : WINDOW_LEFT_EDGE_X (W))
797
798
01aa0b2e
RS
799/* Height in pixels, and in lines, of the mode line.
800 May be zero if W doesn't have a mode line. */
6000501b
KS
801
802#define WINDOW_MODE_LINE_HEIGHT(W) \
803 (WINDOW_WANTS_MODELINE_P ((W)) \
804 ? CURRENT_MODE_LINE_HEIGHT (W) \
805 : 0)
806
d3d50620 807#define WINDOW_MODE_LINE_LINES(W) \
01aa0b2e
RS
808 (!! WINDOW_WANTS_MODELINE_P ((W)))
809
810/* Height in pixels, and in lines, of the header line.
811 Zero if W doesn't have a header line. */
6000501b
KS
812
813#define WINDOW_HEADER_LINE_HEIGHT(W) \
814 (WINDOW_WANTS_HEADER_LINE_P ((W)) \
815 ? CURRENT_HEADER_LINE_HEIGHT (W) \
816 : 0)
817
d3d50620 818#define WINDOW_HEADER_LINE_LINES(W) \
01aa0b2e
RS
819 (!! WINDOW_WANTS_HEADER_LINE_P ((W)))
820
6000501b
KS
821/* Pixel height of window W without mode line. */
822
823#define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W) \
824 (WINDOW_TOTAL_HEIGHT ((W)) \
825 - WINDOW_MODE_LINE_HEIGHT ((W)))
826
827/* Pixel height of window W without mode and header line. */
828
d3d50620
DA
829#define WINDOW_BOX_TEXT_HEIGHT(W) \
830 (WINDOW_TOTAL_HEIGHT ((W)) \
831 - WINDOW_MODE_LINE_HEIGHT ((W)) \
6000501b
KS
832 - WINDOW_HEADER_LINE_HEIGHT ((W)))
833
834
835/* Convert window W relative pixel X to frame pixel coordinates. */
836
d3d50620 837#define WINDOW_TO_FRAME_PIXEL_X(W, X) \
6000501b
KS
838 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
839
840/* Convert window W relative pixel Y to frame pixel coordinates. */
841
d3d50620 842#define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
6000501b
KS
843 ((Y) + WINDOW_TOP_EDGE_Y ((W)))
844
845/* Convert frame relative pixel X to window relative pixel X. */
846
d3d50620 847#define FRAME_TO_WINDOW_PIXEL_X(W, X) \
6000501b
KS
848 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
849
850/* Convert frame relative pixel Y to window relative pixel Y. */
851
d3d50620 852#define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
6000501b
KS
853 ((Y) - WINDOW_TOP_EDGE_Y ((W)))
854
855/* Convert a text area relative x-position in window W to frame X
856 pixel coordinates. */
177c0ea7 857
d3d50620 858#define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
6000501b 859 (window_box_left ((W), TEXT_AREA) + (X))
f43dd834 860
83b2229f
JB
861/* This is the window in which the terminal's cursor should
862 be left when nothing is being done with it. This must
863 always be a leaf window, and its buffer is selected by
864 the top level editing loop at the end of each command.
865
866 This value is always the same as
44fa5b1e 867 FRAME_SELECTED_WINDOW (selected_frame). */
83b2229f
JB
868
869extern Lisp_Object selected_window;
870
871/* This is a time stamp for window selection, so we can find the least
872 recently used window. Its only users are Fselect_window,
44fa5b1e 873 init_window_once, and make_frame. */
83b2229f
JB
874
875extern int window_select_count;
876
44fa5b1e 877/* The minibuffer window of the selected frame.
83b2229f 878 Note that you cannot test for minibufferness of an arbitrary window
fbfed6f0 879 by comparing against this; use the MINI_WINDOW_P macro instead. */
83b2229f
JB
880
881extern Lisp_Object minibuf_window;
882
76e316e0
KS
883/* Non-nil means it is the window whose mode line should be
884 shown as the selected window when the minibuffer is selected. */
885
5705966b 886extern Lisp_Object minibuf_selected_window;
76e316e0 887
83b2229f 888/* Window that the mouse is over (nil if no mouse support). */
f43dd834 889
83b2229f
JB
890extern Lisp_Object Vmouse_window;
891
892/* Last mouse-click event (nil if no mouse support). */
f43dd834 893
83b2229f
JB
894extern Lisp_Object Vmouse_event;
895
383e0970 896extern Lisp_Object make_window (void);
383e0970 897extern Lisp_Object window_from_coordinates (struct frame *, int, int,
9173a8fb 898 enum window_part *, int);
9397e56f 899extern void resize_frame_windows (struct frame *, int, int);
be7f5545 900extern void delete_all_child_windows (Lisp_Object);
383e0970 901extern void freeze_window_starts (struct frame *, int);
383e0970
J
902extern void grow_mini_window (struct window *, int);
903extern void shrink_mini_window (struct window *);
9173a8fb 904extern int window_relative_x_coord (struct window *, enum window_part, int);
57209cba 905
ef264c42 906void run_window_configuration_change_hook (struct frame *f);
83b2229f 907
f43dd834
GM
908/* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero
909 means it's allowed to run hooks. See make_frame for a case where
910 it's not allowed. */
911
383e0970
J
912void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
913 int run_hooks_p, int keep_margins_p);
f43dd834 914
f43dd834
GM
915/* This is the window where the echo area message was displayed. It
916 is always a minibuffer window, but it may not be the same window
917 currently active as a minibuffer. */
918
c0acc112
RS
919extern Lisp_Object echo_area_window;
920
83b2229f 921/* Depth in recursive edits. */
f43dd834 922
62f19c19 923extern EMACS_INT command_loop_level;
83b2229f
JB
924
925/* Depth in minibuffer invocations. */
f43dd834 926
62f19c19 927extern EMACS_INT minibuf_level;
83b2229f 928
e0f24100 929/* true if we should redraw the mode lines on the next redisplay. */
f43dd834 930
83b2229f
JB
931extern int update_mode_lines;
932
f43dd834
GM
933/* Nonzero if window sizes or contents have changed since last
934 redisplay that finished */
935
83b2229f
JB
936extern int windows_or_buffers_changed;
937
d1a0ea0a
RS
938/* Nonzero means a frame's cursor type has been changed. */
939
940extern int cursor_type_changed;
941
f43dd834
GM
942/* Number of windows displaying the selected buffer. Normally this is
943 1, but it can be more. */
944
83b2229f 945extern int buffer_shared;
fbfed6f0
JB
946
947/* If *ROWS or *COLS are too small a size for FRAME, set them to the
948 minimum allowable size. */
f43dd834 949
383e0970 950extern void check_frame_size (struct frame *frame, int *rows, int *cols);
f43dd834
GM
951
952/* Return a pointer to the glyph W's physical cursor is on. Value is
c80e3b4a 953 null if W's current matrix is invalid, so that no meaningful glyph
f43dd834
GM
954 can be returned. */
955
383e0970 956struct glyph *get_phys_cursor_glyph (struct window *w);
f43dd834 957
52162052
MR
958/* Value is non-zero if WINDOW is a valid window. */
959#define WINDOW_VALID_P(WINDOW) \
960 (WINDOWP (WINDOW) \
961 && (!NILP (XWINDOW (WINDOW)->buffer) \
962 || !NILP (XWINDOW (WINDOW)->vchild) \
963 || !NILP (XWINDOW (WINDOW)->hchild)))
964
91523be9 965
52162052 966/* Value is non-zero if WINDOW is a live window. */
077288cf 967#define WINDOW_LIVE_P(WINDOW) \
d3d50620 968 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer))
9a274fbd
SM
969
970/* These used to be in lisp.h. */
971
972extern Lisp_Object Qwindowp, Qwindow_live_p;
973extern Lisp_Object Vwindow_list;
974
52162052
MR
975extern struct window *decode_valid_window (Lisp_Object);
976extern struct window *decode_live_window (Lisp_Object);
383e0970 977extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);
383e0970
J
978extern void mark_window_cursors_off (struct window *);
979extern int window_internal_height (struct window *);
496e208e 980extern int window_body_cols (struct window *w);
383e0970 981extern void temp_output_buffer_show (Lisp_Object);
b6e3633c 982extern void replace_buffer_in_windows (Lisp_Object);
9397e56f 983extern void replace_buffer_in_windows_safely (Lisp_Object);
383e0970
J
984extern void init_window_once (void);
985extern void init_window (void);
986extern void syms_of_window (void);
987extern void keys_of_window (void);
988
e8c17b81
PE
989INLINE_HEADER_END
990
f43dd834 991#endif /* not WINDOW_H_INCLUDED */