* window.h (WSET): Remove.
[bpt/emacs.git] / src / window.h
1 /* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2012
3 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef WINDOW_H_INCLUDED
21 #define WINDOW_H_INCLUDED
22
23 #include "dispextern.h"
24
25 INLINE_HEADER_BEGIN
26 #ifndef WINDOW_INLINE
27 # define WINDOW_INLINE INLINE
28 #endif
29
30 extern Lisp_Object Qleft, Qright;
31
32 /* Windows are allocated as if they were vectors, but then the
33 Lisp data type is changed to Lisp_Window. They are garbage
34 collected along with the vectors.
35
36 All windows in use are arranged into a tree, with pointers up and down.
37
38 Windows that are leaves of the tree are actually displayed
39 and show the contents of buffers. Windows that are not leaves
40 are used for representing the way groups of leaf windows are
41 arranged on the frame. Leaf windows never become non-leaves.
42 They are deleted only by calling delete-window on them (but
43 this can be done implicitly). Combination windows can be created
44 and deleted at any time.
45
46 A 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
50 Non-leaf windows are either vertical or horizontal combinations.
51
52 A vertical combination window has children that are arranged on the frame
53 one above the next. Its vchild field points to the uppermost child.
54 The parent field of each of the children points to the vertical
55 combination window. The next field of each child points to the
56 child below it, or is nil for the lowest child. The prev field
57 of each child points to the child above it, or is nil for the
58 highest child.
59
60 A horizontal combination window has children that are side by side.
61 Its hchild field points to the leftmost child. In each child
62 the next field points to the child to the right and the prev field
63 points to the child to the left.
64
65 The children of a vertical combination window may be leaf windows
66 or horizontal combination windows. The children of a horizontal
67 combination window may be leaf windows or vertical combination windows.
68
69 At the top of the tree are two windows which have nil as parent.
70 The second of these is minibuf_window. The first one manages all
71 the frame area that is not minibuffer, and is called the root window.
72 Different windows can be the root at different times;
73 initially the root window is a leaf window, but if more windows
74 are created then that leaf window ceases to be root and a newly
75 made combination window becomes root instead.
76
77 In any case, on screens which have an ordinary window and a
78 minibuffer, prev of the minibuf window is the root window and next of
79 the root window is the minibuf window. On minibufferless screens or
80 minibuffer-only screens, the root window and the minibuffer window are
81 one and the same, so its prev and next members are nil.
82
83 A dead window has its buffer, hchild, and vchild windows all nil. */
84
85 struct 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
94 struct window
95 {
96 /* This is for Lisp; the terminal code does not refer to it. */
97 struct vectorlike_header header;
98
99 /* The frame this window is on. */
100 Lisp_Object frame;
101
102 /* Following (to right or down) and preceding (to left or up) child
103 at same level of tree. */
104 Lisp_Object next;
105 Lisp_Object prev;
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. */
111 Lisp_Object hchild;
112 Lisp_Object vchild;
113
114 /* The window this one is a child of. */
115 Lisp_Object parent;
116
117 /* The upper left corner coordinates of this window, as integers
118 relative to upper left corner of frame = 0, 0. */
119 Lisp_Object left_col;
120 Lisp_Object top_line;
121
122 /* The size of the window. */
123 Lisp_Object total_lines;
124 Lisp_Object total_cols;
125
126 /* The normal size of the window. */
127 Lisp_Object normal_lines;
128 Lisp_Object normal_cols;
129
130 /* New sizes of the window. */
131 Lisp_Object new_total;
132 Lisp_Object new_normal;
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. */
137 Lisp_Object buffer;
138
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. */
143 Lisp_Object start;
144
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. */
149 Lisp_Object pointm;
150
151 /* No permanent meaning; used by save-window-excursion's
152 bookkeeping. */
153 Lisp_Object temslot;
154
155 /* This window's vertical scroll bar. This field is only for use
156 by the window-system-dependent code which implements the
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. */
160 Lisp_Object vertical_scroll_bar;
161
162 /* Width of left and right marginal areas. A value of nil means
163 no margin. */
164 Lisp_Object left_margin_cols;
165 Lisp_Object right_margin_cols;
166
167 /* Width of left and right fringes.
168 A value of nil or t means use frame values. */
169 Lisp_Object left_fringe_width;
170 Lisp_Object right_fringe_width;
171
172 /* Pixel width of scroll bars.
173 A value of nil or t means use frame values. */
174 Lisp_Object scroll_bar_width;
175
176 /* Type of vertical scroll bar. A value of nil means
177 no scroll bar. A value of t means use frame value. */
178 Lisp_Object vertical_scroll_bar_type;
179
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. */
182 Lisp_Object window_end_pos;
183 /* Glyph matrix row of the last glyph in the current matrix
184 of W. Only valid if WINDOW_END_VALID is not nil. */
185 Lisp_Object window_end_vpos;
186 /* t if window_end_pos is truly valid.
187 This is nil if nontrivial redisplay is preempted
188 since in that case the frame image that window_end_pos
189 did not get onto the frame. */
190 Lisp_Object window_end_valid;
191
192 /* Display-table to use for displaying chars in this window.
193 Nil means use the buffer's own display-table. */
194 Lisp_Object display_table;
195
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. */
199 Lisp_Object dedicated;
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. */
204 Lisp_Object base_line_number;
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. */
208 Lisp_Object base_line_pos;
209
210 /* If we have highlighted the region (or any part of it),
211 this is the mark position that we used, as an integer. */
212 Lisp_Object region_showing;
213
214 /* The column number currently displayed in this window's mode line,
215 or nil if column numbers are not being displayed. */
216 Lisp_Object column_number_displayed;
217
218 /* If redisplay in this window goes beyond this buffer position,
219 must run the redisplay-end-trigger-hook. */
220 Lisp_Object redisplay_end_trigger;
221
222 /* t means this window's child windows are not (re-)combined. */
223 Lisp_Object combination_limit;
224
225 /* Alist of <buffer, window-start, window-point> triples listing
226 buffers previously shown in this window. */
227 Lisp_Object prev_buffers;
228
229 /* List of buffers re-shown in this window. */
230 Lisp_Object next_buffers;
231
232 /* An alist with parameters. */
233 Lisp_Object window_parameters;
234
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
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
249 /* Number of columns display within the window is scrolled to the left. */
250 ptrdiff_t hscroll;
251
252 /* Minimum hscroll for automatic hscrolling. This is the value
253 the user has set, by set-window-hscroll for example. */
254 ptrdiff_t min_hscroll;
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
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
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;
280
281 /* Where the cursor actually is. */
282 struct cursor_pos phys_cursor;
283
284 /* Cursor type and width of last cursor drawn on the window.
285 Used for X and w32 frames; -1 initially. */
286 int phys_cursor_type, phys_cursor_width;
287
288 /* This is handy for undrawing the cursor. */
289 int phys_cursor_ascent, phys_cursor_height;
290
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
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
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
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
343 /* Amount by which lines of this window are scrolled in
344 y-direction (smooth scrolling). */
345 int vscroll;
346
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;
350 };
351
352 /* Most code should use these functions to set Lisp fields in struct
353 window. */
354 WINDOW_INLINE void
355 wset_buffer (struct window *w, Lisp_Object val)
356 {
357 w->buffer = val;
358 }
359 WINDOW_INLINE void
360 wset_frame (struct window *w, Lisp_Object val)
361 {
362 w->frame = val;
363 }
364 WINDOW_INLINE void
365 wset_left_col (struct window *w, Lisp_Object val)
366 {
367 w->left_col = val;
368 }
369 WINDOW_INLINE void
370 wset_next (struct window *w, Lisp_Object val)
371 {
372 w->next = val;
373 }
374 WINDOW_INLINE void
375 wset_prev (struct window *w, Lisp_Object val)
376 {
377 w->prev = val;
378 }
379 WINDOW_INLINE void
380 wset_redisplay_end_trigger (struct window *w, Lisp_Object val)
381 {
382 w->redisplay_end_trigger = val;
383 }
384 WINDOW_INLINE void
385 wset_top_line (struct window *w, Lisp_Object val)
386 {
387 w->top_line = val;
388 }
389 WINDOW_INLINE void
390 wset_total_cols (struct window *w, Lisp_Object val)
391 {
392 w->total_cols = val;
393 }
394 WINDOW_INLINE void
395 wset_total_lines (struct window *w, Lisp_Object val)
396 {
397 w->total_lines = val;
398 }
399 WINDOW_INLINE void
400 wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
401 {
402 w->vertical_scroll_bar = val;
403 }
404 WINDOW_INLINE void
405 wset_window_end_pos (struct window *w, Lisp_Object val)
406 {
407 w->window_end_pos = val;
408 }
409 WINDOW_INLINE void
410 wset_window_end_valid (struct window *w, Lisp_Object val)
411 {
412 w->window_end_valid = val;
413 }
414 WINDOW_INLINE void
415 wset_window_end_vpos (struct window *w, Lisp_Object val)
416 {
417 w->window_end_vpos = val;
418 }
419
420
421 /* 1 if W is a minibuffer window. */
422
423 #define MINI_WINDOW_P(W) ((W)->mini)
424
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
446
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
465 /* Return the width of window W in canonical column units.
466 This includes scroll bars and fringes. */
467
468 #define WINDOW_TOTAL_COLS(W) \
469 (XFASTINT (W->total_cols))
470
471 /* Return the height of window W in canonical line units.
472 This includes header and mode lines, if any. */
473
474 #define WINDOW_TOTAL_LINES(W) \
475 (XFASTINT (W->total_lines))
476
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
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)
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) \
503 (XFASTINT (W->left_col))
504
505 /* Return the canonical frame column before which window W ends.
506 This includes a right-hand scroll bar, if any. */
507
508 #define WINDOW_RIGHT_EDGE_COL(W) \
509 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
510
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) \
515 (XFASTINT (W->top_line))
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
538 /* 1 if W is a menu bar window. */
539
540 #define WINDOW_MENU_BAR_P(W) \
541 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
542 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
543
544 /* 1 if W is a tool bar window. */
545
546 #define WINDOW_TOOL_BAR_P(W) \
547 (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
548 && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
549
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) \
554 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
555 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
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) \
562 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
563 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
564 + WINDOW_BOTTOM_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
565
566
567 /* 1 if window W takes up the full width of its frame. */
568
569 #define WINDOW_FULL_WIDTH_P(W) \
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)
576
577 /* 1 if window W's has no other windows to its right in its frame. */
578
579 #define WINDOW_RIGHTMOST_P(W) \
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
619 #define WINDOW_LEFT_MARGIN_COLS(W) \
620 (NILP (W->left_margin_cols) \
621 ? 0 \
622 : XINT (W->left_margin_cols))
623
624 /* Width of right marginal area in columns. */
625
626 #define WINDOW_RIGHT_MARGIN_COLS(W) \
627 (NILP (W->right_margin_cols) \
628 ? 0 \
629 : XINT (W->right_margin_cols))
630
631 /* Width of left margin area in pixels. */
632
633 #define WINDOW_LEFT_MARGIN_WIDTH(W) \
634 (NILP (W->left_margin_cols) \
635 ? 0 \
636 : (XINT (W->left_margin_cols) \
637 * WINDOW_FRAME_COLUMN_WIDTH (W)))
638
639 /* Width of right marginal area in pixels. */
640
641 #define WINDOW_RIGHT_MARGIN_WIDTH(W) \
642 (NILP (W->right_margin_cols) \
643 ? 0 \
644 : (XINT (W->right_margin_cols) \
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
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)) \
660 : FRAME_FRINGE_COLS (WINDOW_XFRAME (W)))
661
662 /* Column-width of the left and right fringe. */
663
664 #define WINDOW_LEFT_FRINGE_COLS(W) \
665 ((WINDOW_LEFT_FRINGE_WIDTH ((W)) \
666 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
667 / WINDOW_FRAME_COLUMN_WIDTH (W))
668
669 #define WINDOW_RIGHT_FRINGE_COLS(W) \
670 ((WINDOW_RIGHT_FRINGE_WIDTH ((W)) \
671 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
672 / WINDOW_FRAME_COLUMN_WIDTH (W))
673
674 /* Pixel-width of the left and right fringe. */
675
676 #define WINDOW_LEFT_FRINGE_WIDTH(W) \
677 (INTEGERP (W->left_fringe_width) \
678 ? XFASTINT (W->left_fringe_width) \
679 : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
680
681 #define WINDOW_RIGHT_FRINGE_WIDTH(W) \
682 (INTEGERP (W->right_fringe_width) \
683 ? XFASTINT (W->right_fringe_width) \
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) \
694 ((W)->fringes_outside_margins)
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) \
700 (EQ (w->vertical_scroll_bar_type, Qt) \
701 ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (w)) \
702 : EQ (w->vertical_scroll_bar_type, Qleft) \
703 ? vertical_scroll_bar_left \
704 : EQ (w->vertical_scroll_bar_type, Qright) \
705 ? vertical_scroll_bar_right \
706 : vertical_scroll_bar_none) \
707
708 #define WINDOW_HAS_VERTICAL_SCROLL_BAR(w) \
709 (EQ (w->vertical_scroll_bar_type, Qt) \
710 ? FRAME_HAS_VERTICAL_SCROLL_BARS (WINDOW_XFRAME (w)) \
711 : !NILP (w->vertical_scroll_bar_type))
712
713 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(w) \
714 (EQ (w->vertical_scroll_bar_type, Qt) \
715 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (WINDOW_XFRAME (w)) \
716 : EQ (w->vertical_scroll_bar_type, Qleft))
717
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))
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) \
728 (INTEGERP (w->scroll_bar_width) \
729 ? XFASTINT (w->scroll_bar_width) \
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) \
737 (INTEGERP (w->scroll_bar_width) \
738 ? ((XFASTINT (w->scroll_bar_width) \
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) \
748 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
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
754 #define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(w) \
755 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
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) \
764 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
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) \
786 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
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
799 /* Height in pixels, and in lines, of the mode line.
800 May be zero if W doesn't have a mode line. */
801
802 #define WINDOW_MODE_LINE_HEIGHT(W) \
803 (WINDOW_WANTS_MODELINE_P ((W)) \
804 ? CURRENT_MODE_LINE_HEIGHT (W) \
805 : 0)
806
807 #define WINDOW_MODE_LINE_LINES(W) \
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. */
812
813 #define WINDOW_HEADER_LINE_HEIGHT(W) \
814 (WINDOW_WANTS_HEADER_LINE_P ((W)) \
815 ? CURRENT_HEADER_LINE_HEIGHT (W) \
816 : 0)
817
818 #define WINDOW_HEADER_LINE_LINES(W) \
819 (!! WINDOW_WANTS_HEADER_LINE_P ((W)))
820
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
829 #define WINDOW_BOX_TEXT_HEIGHT(W) \
830 (WINDOW_TOTAL_HEIGHT ((W)) \
831 - WINDOW_MODE_LINE_HEIGHT ((W)) \
832 - WINDOW_HEADER_LINE_HEIGHT ((W)))
833
834
835 /* Convert window W relative pixel X to frame pixel coordinates. */
836
837 #define WINDOW_TO_FRAME_PIXEL_X(W, X) \
838 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
839
840 /* Convert window W relative pixel Y to frame pixel coordinates. */
841
842 #define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
843 ((Y) + WINDOW_TOP_EDGE_Y ((W)))
844
845 /* Convert frame relative pixel X to window relative pixel X. */
846
847 #define FRAME_TO_WINDOW_PIXEL_X(W, X) \
848 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
849
850 /* Convert frame relative pixel Y to window relative pixel Y. */
851
852 #define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
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. */
857
858 #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
859 (window_box_left ((W), TEXT_AREA) + (X))
860
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
867 FRAME_SELECTED_WINDOW (selected_frame). */
868
869 extern 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,
873 init_window_once, and make_frame. */
874
875 extern int window_select_count;
876
877 /* The minibuffer window of the selected frame.
878 Note that you cannot test for minibufferness of an arbitrary window
879 by comparing against this; use the MINI_WINDOW_P macro instead. */
880
881 extern Lisp_Object minibuf_window;
882
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
886 extern Lisp_Object minibuf_selected_window;
887
888 /* Window that the mouse is over (nil if no mouse support). */
889
890 extern Lisp_Object Vmouse_window;
891
892 /* Last mouse-click event (nil if no mouse support). */
893
894 extern Lisp_Object Vmouse_event;
895
896 extern Lisp_Object make_window (void);
897 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
898 enum window_part *, int);
899 extern void resize_frame_windows (struct frame *, int, int);
900 extern void delete_all_child_windows (Lisp_Object);
901 extern void freeze_window_starts (struct frame *, int);
902 extern void grow_mini_window (struct window *, int);
903 extern void shrink_mini_window (struct window *);
904 extern int window_relative_x_coord (struct window *, enum window_part, int);
905
906 void run_window_configuration_change_hook (struct frame *f);
907
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
912 void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
913 int run_hooks_p, int keep_margins_p);
914
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
919 extern Lisp_Object echo_area_window;
920
921 /* Depth in recursive edits. */
922
923 extern EMACS_INT command_loop_level;
924
925 /* Depth in minibuffer invocations. */
926
927 extern EMACS_INT minibuf_level;
928
929 /* true if we should redraw the mode lines on the next redisplay. */
930
931 extern int update_mode_lines;
932
933 /* Nonzero if window sizes or contents have changed since last
934 redisplay that finished */
935
936 extern int windows_or_buffers_changed;
937
938 /* Nonzero means a frame's cursor type has been changed. */
939
940 extern int cursor_type_changed;
941
942 /* Number of windows displaying the selected buffer. Normally this is
943 1, but it can be more. */
944
945 extern int buffer_shared;
946
947 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
948 minimum allowable size. */
949
950 extern void check_frame_size (struct frame *frame, int *rows, int *cols);
951
952 /* Return a pointer to the glyph W's physical cursor is on. Value is
953 null if W's current matrix is invalid, so that no meaningful glyph
954 can be returned. */
955
956 struct glyph *get_phys_cursor_glyph (struct window *w);
957
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
965
966 /* Value is non-zero if WINDOW is a live window. */
967 #define WINDOW_LIVE_P(WINDOW) \
968 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer))
969
970 /* These used to be in lisp.h. */
971
972 extern Lisp_Object Qwindowp, Qwindow_live_p;
973 extern Lisp_Object Vwindow_list;
974
975 extern struct window *decode_valid_window (Lisp_Object);
976 extern struct window *decode_live_window (Lisp_Object);
977 extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);
978 extern void mark_window_cursors_off (struct window *);
979 extern int window_internal_height (struct window *);
980 extern int window_body_cols (struct window *w);
981 extern void temp_output_buffer_show (Lisp_Object);
982 extern void replace_buffer_in_windows (Lisp_Object);
983 extern void replace_buffer_in_windows_safely (Lisp_Object);
984 extern void init_window_once (void);
985 extern void init_window (void);
986 extern void syms_of_window (void);
987 extern void keys_of_window (void);
988
989 INLINE_HEADER_END
990
991 #endif /* not WINDOW_H_INCLUDED */