* ccl.c (CCL_CODE_RANGE): Allow negative numbers. (Bug#8751)
[emacs.git] / src / window.h
blobb1f6560445ecc78cdd88045c5a811ebc365ab2c5
1 /* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2011
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
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.
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.
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/>. */
20 #ifndef WINDOW_H_INCLUDED
21 #define WINDOW_H_INCLUDED
23 #include "dispextern.h"
25 extern Lisp_Object Qleft, Qright;
27 /* Windows are allocated as if they were vectors, but then the
28 Lisp data type is changed to Lisp_Window. They are garbage
29 collected along with the vectors.
31 All windows in use are arranged into a tree, with pointers up and down.
33 Windows that are leaves of the tree are actually displayed
34 and show the contents of buffers. Windows that are not leaves
35 are used for representing the way groups of leaf windows are
36 arranged on the frame. Leaf windows never become non-leaves.
37 They are deleted only by calling delete-window on them (but
38 this can be done implicitly). Combination windows can be created
39 and deleted at any time.
41 A leaf window has a non-nil buffer field, and also
42 has markers in its start and pointm fields. Non-leaf windows
43 have nil in these fields.
45 Non-leaf windows are either vertical or horizontal combinations.
47 A vertical combination window has children that are arranged on the frame
48 one above the next. Its vchild field points to the uppermost child.
49 The parent field of each of the children points to the vertical
50 combination window. The next field of each child points to the
51 child below it, or is nil for the lowest child. The prev field
52 of each child points to the child above it, or is nil for the
53 highest child.
55 A horizontal combination window has children that are side by side.
56 Its hchild field points to the leftmost child. In each child
57 the next field points to the child to the right and the prev field
58 points to the child to the left.
60 The children of a vertical combination window may be leaf windows
61 or horizontal combination windows. The children of a horizontal
62 combination window may be leaf windows or vertical combination windows.
64 At the top of the tree are two windows which have nil as parent.
65 The second of these is minibuf_window. The first one manages all
66 the frame area that is not minibuffer, and is called the root window.
67 Different windows can be the root at different times;
68 initially the root window is a leaf window, but if more windows
69 are created then that leaf window ceases to be root and a newly
70 made combination window becomes root instead.
72 In any case, on screens which have an ordinary window and a
73 minibuffer, prev of the minibuf window is the root window and next of
74 the root window is the minibuf window. On minibufferless screens or
75 minibuffer-only screens, the root window and the minibuffer window are
76 one and the same, so its prev and next members are nil.
78 A dead window has its buffer, hchild, and vchild windows all nil. */
80 struct cursor_pos
82 /* Pixel position. These are always window relative. */
83 int x, y;
85 /* Glyph matrix position. */
86 int hpos, vpos;
89 struct window
91 /* This is for Lisp; the terminal code does not refer to it. */
92 struct vectorlike_header header;
94 /* The frame this window is on. */
95 Lisp_Object frame;
96 /* t if this window is a minibuffer window. */
97 Lisp_Object mini_p;
98 /* Following child (to right or down) at same level of tree */
99 Lisp_Object next;
100 /* Preceding child (to left or up) at same level of tree */
101 Lisp_Object prev;
102 /* First child of this window. */
103 /* vchild is used if this is a vertical combination,
104 hchild if this is a horizontal combination. */
105 Lisp_Object hchild, vchild;
106 /* The window this one is a child of. */
107 Lisp_Object parent;
108 /* The upper left corner coordinates of this window,
109 as integers relative to upper left corner of frame = 0, 0 */
110 Lisp_Object left_col;
111 Lisp_Object top_line;
112 /* The size of the window */
113 Lisp_Object total_lines;
114 Lisp_Object total_cols;
115 /* The buffer displayed in this window */
116 /* Of the fields vchild, hchild and buffer, only one is non-nil. */
117 Lisp_Object buffer;
118 /* A marker pointing to where in the text to start displaying.
119 BIDI Note: This is the _logical-order_ start, i.e. the smallest
120 buffer position visible in the window, not necessarily the
121 character displayed in the top left corner of the window. */
122 Lisp_Object start;
123 /* A marker pointing to where in the text point is in this window,
124 used only when the window is not selected.
125 This exists so that when multiple windows show one buffer
126 each one can have its own value of point. */
127 Lisp_Object pointm;
128 /* Non-nil means next redisplay must use the value of start
129 set up for it in advance. Set by scrolling commands. */
130 Lisp_Object force_start;
131 /* Non-nil means we have explicitly changed the value of start,
132 but that the next redisplay is not obliged to use the new value.
133 This is used in Fdelete_other_windows to force a call to
134 Vwindow_scroll_functions; also by Frecenter with argument. */
135 Lisp_Object optional_new_start;
136 /* Number of columns display within the window is scrolled to the left. */
137 Lisp_Object hscroll;
138 /* Minimum hscroll for automatic hscrolling. This is the value
139 the user has set, by set-window-hscroll for example. */
140 Lisp_Object min_hscroll;
141 /* Number saying how recently window was selected */
142 Lisp_Object use_time;
143 /* Unique number of window assigned when it was created */
144 Lisp_Object sequence_number;
145 /* No permanent meaning; used by save-window-excursion's bookkeeping */
146 Lisp_Object temslot;
147 /* text.modified of displayed buffer as of last time display completed */
148 Lisp_Object last_modified;
149 /* BUF_OVERLAY_MODIFIED of displayed buffer as of last complete update. */
150 Lisp_Object last_overlay_modified;
151 /* Value of point at that time */
152 Lisp_Object last_point;
153 /* Non-nil if the buffer was "modified" when the window
154 was last updated. */
155 Lisp_Object last_had_star;
156 /* This window's vertical scroll bar. This field is only for use
157 by the window-system-dependent code which implements the
158 scroll bars; it can store anything it likes here. If this
159 window is newly created and we haven't displayed a scroll bar in
160 it yet, or if the frame doesn't have any scroll bars, this is nil. */
161 Lisp_Object vertical_scroll_bar;
163 /* Width of left and right marginal areas. A value of nil means
164 no margin. */
165 Lisp_Object left_margin_cols, right_margin_cols;
167 /* Width of left and right fringes.
168 A value of nil or t means use frame values. */
169 Lisp_Object left_fringe_width, right_fringe_width;
171 /* Non-nil means fringes are drawn outside display margins;
172 othersize draw them between margin areas and text. */
173 Lisp_Object fringes_outside_margins;
175 /* Pixel width of scroll bars.
176 A value of nil or t means use frame values. */
177 Lisp_Object scroll_bar_width;
178 /* Type of vertical scroll bar. A value of nil means
179 no scroll bar. A value of t means use frame value. */
180 Lisp_Object vertical_scroll_bar_type;
182 /* Frame coords of mark as of last time display completed */
183 /* May be nil if mark does not exist or was not on frame */
184 Lisp_Object last_mark_x;
185 Lisp_Object last_mark_y;
186 /* Z - the buffer position of the last glyph in the current matrix
187 of W. Only valid if WINDOW_END_VALID is not nil. */
188 Lisp_Object window_end_pos;
189 /* Glyph matrix row of the last glyph in the current matrix
190 of W. Only valid if WINDOW_END_VALID is not nil. */
191 Lisp_Object window_end_vpos;
192 /* t if window_end_pos is truly valid.
193 This is nil if nontrivial redisplay is preempted
194 since in that case the frame image that window_end_pos
195 did not get onto the frame. */
196 Lisp_Object window_end_valid;
197 /* Non-nil means must regenerate mode line of this window */
198 Lisp_Object update_mode_line;
199 /* Non-nil means current value of `start'
200 was the beginning of a line when it was chosen. */
201 Lisp_Object start_at_line_beg;
202 /* Display-table to use for displaying chars in this window.
203 Nil means use the buffer's own display-table. */
204 Lisp_Object display_table;
205 /* Non-nil means window is marked as dedicated. */
206 Lisp_Object dedicated;
207 /* Line number and position of a line somewhere above the
208 top of the screen. */
209 /* If this field is nil, it means we don't have a base line. */
210 Lisp_Object base_line_number;
211 /* If this field is nil, it means we don't have a base line.
212 If it is a buffer, it means don't display the line number
213 as long as the window shows that buffer. */
214 Lisp_Object base_line_pos;
215 /* If we have highlighted the region (or any part of it),
216 this is the mark position that we used, as an integer. */
217 Lisp_Object region_showing;
218 /* The column number currently displayed in this window's mode line,
219 or nil if column numbers are not being displayed. */
220 Lisp_Object column_number_displayed;
221 /* If redisplay in this window goes beyond this buffer position,
222 must run the redisplay-end-trigger-hook. */
223 Lisp_Object redisplay_end_trigger;
224 /* Non-nil means resizing windows will attempt to resize this window
225 proportionally. */
226 Lisp_Object resize_proportionally;
228 /* Original window height and top before mini-window was enlarged. */
229 Lisp_Object orig_total_lines, orig_top_line;
231 /* An alist with parameteres. */
232 Lisp_Object window_parameters;
234 /* No Lisp data may follow below this point without changing
235 mark_object in alloc.c. The member current_matrix must be the
236 first non-Lisp member. */
238 /* Glyph matrices. */
239 struct glyph_matrix *current_matrix;
240 struct glyph_matrix *desired_matrix;
242 /* Scaling factor for the glyph_matrix size calculation in this window.
243 Used if window contains many small images or uses proportional fonts,
244 as the normal may yield a matrix which is too small. */
245 int nrows_scale_factor, ncols_scale_factor;
247 /* Cursor position as of last update that completed without
248 pause. This is the position of last_point. */
249 struct cursor_pos last_cursor;
251 /* Intended cursor position. This is a position within the
252 glyph matrix. */
253 struct cursor_pos cursor;
255 /* Where the cursor actually is. */
256 struct cursor_pos phys_cursor;
258 /* Cursor type and width of last cursor drawn on the window.
259 Used for X and w32 frames; -1 initially. */
260 int phys_cursor_type, phys_cursor_width;
262 /* This is handy for undrawing the cursor. */
263 int phys_cursor_ascent, phys_cursor_height;
265 /* Non-zero means the cursor is currently displayed. This can be
266 set to zero by functions overpainting the cursor image. */
267 unsigned phys_cursor_on_p : 1;
269 /* 0 means cursor is logically on, 1 means it's off. Used for
270 blinking cursor. */
271 unsigned cursor_off_p : 1;
273 /* Value of cursor_off_p as of the last redisplay. */
274 unsigned last_cursor_off_p : 1;
276 /* 1 means desired matrix has been build and window must be
277 updated in update_frame. */
278 unsigned must_be_updated_p : 1;
280 /* Flag indicating that this window is not a real one.
281 Currently only used for menu bar windows of frames. */
282 unsigned pseudo_window_p : 1;
284 /* 1 means the window start of this window is frozen and may not
285 be changed during redisplay. If point is not in the window,
286 accept that. */
287 unsigned frozen_window_start_p : 1;
289 /* Amount by which lines of this window are scrolled in
290 y-direction (smooth scrolling). */
291 int vscroll;
293 /* Z_BYTE - the buffer position of the last glyph in the current matrix
294 of W. Only valid if WINDOW_END_VALID is not nil. */
295 int window_end_bytepos;
298 /* 1 if W is a minibuffer window. */
300 #define MINI_WINDOW_P(W) (!NILP ((W)->mini_p))
302 /* General window layout:
304 LEFT_EDGE_COL RIGHT_EDGE_COL
307 | BOX_LEFT_EDGE_COL |
308 | | BOX_RIGHT_EDGE_COL |
309 | | | |
310 v v v v
311 <-><-><---><-----------><---><-><->
312 ^ ^ ^ ^ ^ ^ ^
313 | | | | | | |
314 | | | | | | +-- RIGHT_SCROLL_BAR_COLS
315 | | | | | +----- RIGHT_FRINGE_WIDTH
316 | | | | +--------- RIGHT_MARGIN_COLS
317 | | | |
318 | | | +------------------ TEXT_AREA_COLS
319 | | |
320 | | +--------------------------- LEFT_MARGIN_COLS
321 | +------------------------------- LEFT_FRINGE_WIDTH
322 +---------------------------------- LEFT_SCROLL_BAR_COLS
327 /* A handy macro. */
329 #define WINDOW_XFRAME(W) \
330 (XFRAME (WINDOW_FRAME ((W))))
332 /* Return the canonical column width of the frame of window W. */
334 #define WINDOW_FRAME_COLUMN_WIDTH(W) \
335 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
337 /* Return the canonical column width of the frame of window W. */
339 #define WINDOW_FRAME_LINE_HEIGHT(W) \
340 (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
342 /* Return the width of window W in canonical column units.
343 This includes scroll bars and fringes. */
345 #define WINDOW_TOTAL_COLS(W) \
346 (XFASTINT ((W)->total_cols))
348 /* Return the height of window W in canonical line units.
349 This includes header and mode lines, if any. */
351 #define WINDOW_TOTAL_LINES(W) \
352 (XFASTINT ((W)->total_lines))
354 /* Return the total pixel width of window W. */
356 #define WINDOW_TOTAL_WIDTH(W) \
357 (WINDOW_TOTAL_COLS (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
359 /* Return the total pixel height of window W. */
361 #define WINDOW_TOTAL_HEIGHT(W) \
362 (WINDOW_TOTAL_LINES (W) * WINDOW_FRAME_LINE_HEIGHT (W))
365 /* Return the canonical frame column at which window W starts.
366 This includes a left-hand scroll bar, if any. */
368 #define WINDOW_LEFT_EDGE_COL(W) \
369 (XFASTINT ((W)->left_col))
371 /* Return the canonical frame column before which window W ends.
372 This includes a right-hand scroll bar, if any. */
374 #define WINDOW_RIGHT_EDGE_COL(W) \
375 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
377 /* Return the canonical frame line at which window W starts.
378 This includes a header line, if any. */
380 #define WINDOW_TOP_EDGE_LINE(W) \
381 (XFASTINT ((W)->top_line))
383 /* Return the canonical frame line before which window W ends.
384 This includes a mode line, if any. */
386 #define WINDOW_BOTTOM_EDGE_LINE(W) \
387 (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
390 /* Return the frame x-position at which window W starts.
391 This includes a left-hand scroll bar, if any. */
393 #define WINDOW_LEFT_EDGE_X(W) \
394 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
395 + WINDOW_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
397 /* Return the frame x- position before which window W ends.
398 This includes a right-hand scroll bar, if any. */
400 #define WINDOW_RIGHT_EDGE_X(W) \
401 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
402 + WINDOW_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
404 /* 1 if W is a menu bar window. */
406 #define WINDOW_MENU_BAR_P(W) \
407 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
408 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
410 /* 1 if W is a tool bar window. */
412 #define WINDOW_TOOL_BAR_P(W) \
413 (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
414 && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
416 /* Return the frame y-position at which window W starts.
417 This includes a header line, if any. */
419 #define WINDOW_TOP_EDGE_Y(W) \
420 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
421 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
422 + WINDOW_TOP_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
424 /* Return the frame y-position before which window W ends.
425 This includes a mode line, if any. */
427 #define WINDOW_BOTTOM_EDGE_Y(W) \
428 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
429 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
430 + WINDOW_BOTTOM_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
433 /* 1 if window W takes up the full width of its frame. */
435 #define WINDOW_FULL_WIDTH_P(W) \
436 (WINDOW_TOTAL_COLS (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
438 /* 1 if window W's has no other windows to its left in its frame. */
440 #define WINDOW_LEFTMOST_P(W) \
441 (WINDOW_LEFT_EDGE_COL (W) == 0)
443 /* 1 if window W's has no other windows to its right in its frame. */
445 #define WINDOW_RIGHTMOST_P(W) \
446 (WINDOW_RIGHT_EDGE_COL (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
449 /* Return the frame column at which the text (or left fringe) in
450 window W starts. This is different from the `LEFT_EDGE' because it
451 does not include a left-hand scroll bar if any. */
453 #define WINDOW_BOX_LEFT_EDGE_COL(W) \
454 (WINDOW_LEFT_EDGE_COL (W) \
455 + WINDOW_LEFT_SCROLL_BAR_COLS (W))
457 /* Return the window column before which the text in window W ends.
458 This is different from WINDOW_RIGHT_EDGE_COL because it does not
459 include a scroll bar or window-separating line on the right edge. */
461 #define WINDOW_BOX_RIGHT_EDGE_COL(W) \
462 (WINDOW_RIGHT_EDGE_COL (W) \
463 - WINDOW_RIGHT_SCROLL_BAR_COLS (W))
466 /* Return the frame position at which the text (or left fringe) in
467 window W starts. This is different from the `LEFT_EDGE' because it
468 does not include a left-hand scroll bar if any. */
470 #define WINDOW_BOX_LEFT_EDGE_X(W) \
471 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
472 + WINDOW_BOX_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
474 /* Return the window column before which the text in window W ends.
475 This is different from WINDOW_RIGHT_EDGE_COL because it does not
476 include a scroll bar or window-separating line on the right edge. */
478 #define WINDOW_BOX_RIGHT_EDGE_X(W) \
479 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
480 + WINDOW_BOX_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
483 /* Width of left margin area in columns. */
485 #define WINDOW_LEFT_MARGIN_COLS(W) \
486 (NILP ((W)->left_margin_cols) \
487 ? 0 \
488 : XINT ((W)->left_margin_cols))
490 /* Width of right marginal area in columns. */
492 #define WINDOW_RIGHT_MARGIN_COLS(W) \
493 (NILP ((W)->right_margin_cols) \
494 ? 0 \
495 : XINT ((W)->right_margin_cols))
497 /* Width of left margin area in pixels. */
499 #define WINDOW_LEFT_MARGIN_WIDTH(W) \
500 (NILP ((W)->left_margin_cols) \
501 ? 0 \
502 : (XINT ((W)->left_margin_cols) \
503 * WINDOW_FRAME_COLUMN_WIDTH (W)))
505 /* Width of right marginal area in pixels. */
507 #define WINDOW_RIGHT_MARGIN_WIDTH(W) \
508 (NILP ((W)->right_margin_cols) \
509 ? 0 \
510 : (XINT ((W)->right_margin_cols) \
511 * WINDOW_FRAME_COLUMN_WIDTH (W)))
513 /* Total width of fringes reserved for drawing truncation bitmaps,
514 continuation bitmaps and alike. The width is in canonical char
515 units of the frame. This must currently be the case because window
516 sizes aren't pixel values. If it weren't the case, we wouldn't be
517 able to split windows horizontally nicely. */
519 #define WINDOW_FRINGE_COLS(W) \
520 ((INTEGERP ((W)->left_fringe_width) \
521 || INTEGERP ((W)->right_fringe_width)) \
522 ? ((WINDOW_LEFT_FRINGE_WIDTH (W) \
523 + WINDOW_RIGHT_FRINGE_WIDTH (W) \
524 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
525 / WINDOW_FRAME_COLUMN_WIDTH (W)) \
526 : FRAME_FRINGE_COLS (WINDOW_XFRAME (W)))
528 /* Column-width of the left and right fringe. */
530 #define WINDOW_LEFT_FRINGE_COLS(W) \
531 ((WINDOW_LEFT_FRINGE_WIDTH ((W)) \
532 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
533 / WINDOW_FRAME_COLUMN_WIDTH (W))
535 #define WINDOW_RIGHT_FRINGE_COLS(W) \
536 ((WINDOW_RIGHT_FRINGE_WIDTH ((W)) \
537 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
538 / WINDOW_FRAME_COLUMN_WIDTH (W))
540 /* Pixel-width of the left and right fringe. */
542 #define WINDOW_LEFT_FRINGE_WIDTH(W) \
543 (INTEGERP ((W)->left_fringe_width) \
544 ? XFASTINT ((W)->left_fringe_width) \
545 : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
547 #define WINDOW_RIGHT_FRINGE_WIDTH(W) \
548 (INTEGERP ((W)->right_fringe_width) \
549 ? XFASTINT ((W)->right_fringe_width) \
550 : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
552 /* Total width of fringes in pixels. */
554 #define WINDOW_TOTAL_FRINGE_WIDTH(W) \
555 (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
557 /* Are fringes outside display margins in window W. */
559 #define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
560 (!NILP ((W)->fringes_outside_margins))
562 /* Say whether scroll bars are currently enabled for window W,
563 and which side they are on. */
565 #define WINDOW_VERTICAL_SCROLL_BAR_TYPE(w) \
566 (EQ ((w)->vertical_scroll_bar_type, Qt) \
567 ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (w)) \
568 : EQ ((w)->vertical_scroll_bar_type, Qleft) \
569 ? vertical_scroll_bar_left \
570 : EQ ((w)->vertical_scroll_bar_type, Qright) \
571 ? vertical_scroll_bar_right \
572 : vertical_scroll_bar_none) \
574 #define WINDOW_HAS_VERTICAL_SCROLL_BAR(w) \
575 (EQ ((w)->vertical_scroll_bar_type, Qt) \
576 ? FRAME_HAS_VERTICAL_SCROLL_BARS (WINDOW_XFRAME (w)) \
577 : !NILP ((w)->vertical_scroll_bar_type))
579 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(w) \
580 (EQ ((w)->vertical_scroll_bar_type, Qt) \
581 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (WINDOW_XFRAME (w)) \
582 : EQ ((w)->vertical_scroll_bar_type, Qleft))
584 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT(w) \
585 (EQ ((w)->vertical_scroll_bar_type, Qt) \
586 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (WINDOW_XFRAME (w))\
587 : EQ ((w)->vertical_scroll_bar_type, Qright))
589 /* Width that a scroll bar in window W should have, if there is one.
590 Measured in pixels. If scroll bars are turned off, this is still
591 nonzero. */
593 #define WINDOW_CONFIG_SCROLL_BAR_WIDTH(w) \
594 (INTEGERP ((w)->scroll_bar_width) \
595 ? XFASTINT ((w)->scroll_bar_width) \
596 : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (w)))
598 /* Width that a scroll bar in window W should have, if there is one.
599 Measured in columns (characters). If scroll bars are turned off,
600 this is still nonzero. */
602 #define WINDOW_CONFIG_SCROLL_BAR_COLS(w) \
603 (INTEGERP ((w)->scroll_bar_width) \
604 ? ((XFASTINT ((w)->scroll_bar_width) \
605 + WINDOW_FRAME_COLUMN_WIDTH (w) - 1) \
606 / WINDOW_FRAME_COLUMN_WIDTH (w)) \
607 : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (w)))
609 /* Width of a scroll bar in window W, measured in columns (characters),
610 but only if scroll bars are on the left. If scroll bars are on
611 the right in this frame, or there are no scroll bars, value is 0. */
613 #define WINDOW_LEFT_SCROLL_BAR_COLS(w) \
614 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
615 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w)) \
616 : 0)
618 /* Width of a left scroll bar area in window W , measured in pixels. */
620 #define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(w) \
621 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
622 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
623 : 0)
625 /* Width of a scroll bar in window W, measured in columns (characters),
626 but only if scroll bars are on the right. If scroll bars are on
627 the left in this frame, or there are no scroll bars, value is 0. */
629 #define WINDOW_RIGHT_SCROLL_BAR_COLS(w) \
630 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
631 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
632 : 0)
634 /* Width of a left scroll bar area in window W , measured in pixels. */
636 #define WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(w) \
637 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
638 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
639 : 0)
642 /* Actual width of a scroll bar in window W, measured in columns. */
644 #define WINDOW_SCROLL_BAR_COLS(w) \
645 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
646 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
647 : 0)
649 /* Width of a left scroll bar area in window W , measured in pixels. */
651 #define WINDOW_SCROLL_BAR_AREA_WIDTH(w) \
652 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
653 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
654 : 0)
657 /* Return the frame position where the scroll bar of window W starts. */
659 #define WINDOW_SCROLL_BAR_AREA_X(W) \
660 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
661 ? WINDOW_BOX_RIGHT_EDGE_X (W) \
662 : WINDOW_LEFT_EDGE_X (W))
665 /* Height in pixels, and in lines, of the mode line.
666 May be zero if W doesn't have a mode line. */
668 #define WINDOW_MODE_LINE_HEIGHT(W) \
669 (WINDOW_WANTS_MODELINE_P ((W)) \
670 ? CURRENT_MODE_LINE_HEIGHT (W) \
671 : 0)
673 #define WINDOW_MODE_LINE_LINES(W) \
674 (!! WINDOW_WANTS_MODELINE_P ((W)))
676 /* Height in pixels, and in lines, of the header line.
677 Zero if W doesn't have a header line. */
679 #define WINDOW_HEADER_LINE_HEIGHT(W) \
680 (WINDOW_WANTS_HEADER_LINE_P ((W)) \
681 ? CURRENT_HEADER_LINE_HEIGHT (W) \
682 : 0)
684 #define WINDOW_HEADER_LINE_LINES(W) \
685 (!! WINDOW_WANTS_HEADER_LINE_P ((W)))
687 /* Pixel height of window W without mode line. */
689 #define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W) \
690 (WINDOW_TOTAL_HEIGHT ((W)) \
691 - WINDOW_MODE_LINE_HEIGHT ((W)))
693 /* Pixel height of window W without mode and header line. */
695 #define WINDOW_BOX_TEXT_HEIGHT(W) \
696 (WINDOW_TOTAL_HEIGHT ((W)) \
697 - WINDOW_MODE_LINE_HEIGHT ((W)) \
698 - WINDOW_HEADER_LINE_HEIGHT ((W)))
701 /* Convert window W relative pixel X to frame pixel coordinates. */
703 #define WINDOW_TO_FRAME_PIXEL_X(W, X) \
704 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
706 /* Convert window W relative pixel Y to frame pixel coordinates. */
708 #define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
709 ((Y) + WINDOW_TOP_EDGE_Y ((W)))
711 /* Convert frame relative pixel X to window relative pixel X. */
713 #define FRAME_TO_WINDOW_PIXEL_X(W, X) \
714 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
716 /* Convert frame relative pixel Y to window relative pixel Y. */
718 #define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
719 ((Y) - WINDOW_TOP_EDGE_Y ((W)))
721 /* Convert a text area relative x-position in window W to frame X
722 pixel coordinates. */
724 #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
725 (window_box_left ((W), TEXT_AREA) + (X))
727 /* This is the window in which the terminal's cursor should
728 be left when nothing is being done with it. This must
729 always be a leaf window, and its buffer is selected by
730 the top level editing loop at the end of each command.
732 This value is always the same as
733 FRAME_SELECTED_WINDOW (selected_frame). */
735 extern Lisp_Object selected_window;
737 /* This is a time stamp for window selection, so we can find the least
738 recently used window. Its only users are Fselect_window,
739 init_window_once, and make_frame. */
741 extern int window_select_count;
743 /* The minibuffer window of the selected frame.
744 Note that you cannot test for minibufferness of an arbitrary window
745 by comparing against this; use the MINI_WINDOW_P macro instead. */
747 extern Lisp_Object minibuf_window;
749 /* Non-nil means it is the window whose mode line should be
750 shown as the selected window when the minibuffer is selected. */
752 extern Lisp_Object minibuf_selected_window;
754 /* Window that the mouse is over (nil if no mouse support). */
756 extern Lisp_Object Vmouse_window;
758 /* Last mouse-click event (nil if no mouse support). */
760 extern Lisp_Object Vmouse_event;
762 EXFUN (Fnext_window, 3);
763 EXFUN (Fselect_window, 2);
764 EXFUN (Fset_window_buffer, 3);
765 EXFUN (Fset_window_point, 2);
766 extern Lisp_Object make_window (void);
767 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
768 enum window_part *, int);
769 EXFUN (Fwindow_dedicated_p, 1);
770 extern void set_window_height (Lisp_Object, int, int);
771 extern void set_window_width (Lisp_Object, int, int);
772 extern void change_window_heights (Lisp_Object, int);
773 extern void delete_all_subwindows (struct window *);
774 extern void freeze_window_starts (struct frame *, int);
775 extern void grow_mini_window (struct window *, int);
776 extern void shrink_mini_window (struct window *);
777 extern int window_relative_x_coord (struct window *, enum window_part, int);
779 void run_window_configuration_change_hook (struct frame *f);
781 /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero
782 means it's allowed to run hooks. See make_frame for a case where
783 it's not allowed. */
785 void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
786 int run_hooks_p, int keep_margins_p);
788 /* This is the window where the echo area message was displayed. It
789 is always a minibuffer window, but it may not be the same window
790 currently active as a minibuffer. */
792 extern Lisp_Object echo_area_window;
794 /* Depth in recursive edits. */
796 extern int command_loop_level;
798 /* Depth in minibuffer invocations. */
800 extern int minibuf_level;
802 /* true if we should redraw the mode lines on the next redisplay. */
804 extern int update_mode_lines;
806 /* Nonzero if BEGV - BEG or Z - ZV of current buffer has changed since
807 last redisplay that finished. */
809 extern int clip_changed;
811 /* Nonzero if window sizes or contents have changed since last
812 redisplay that finished */
814 extern int windows_or_buffers_changed;
816 /* Nonzero means a frame's cursor type has been changed. */
818 extern int cursor_type_changed;
820 /* Number of windows displaying the selected buffer. Normally this is
821 1, but it can be more. */
823 extern int buffer_shared;
825 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
826 minimum allowable size. */
828 extern void check_frame_size (struct frame *frame, int *rows, int *cols);
830 /* Return a pointer to the glyph W's physical cursor is on. Value is
831 null if W's current matrix is invalid, so that no meaningfull glyph
832 can be returned. */
834 struct glyph *get_phys_cursor_glyph (struct window *w);
836 /* Value is non-zero if WINDOW is a live window. */
838 #define WINDOW_LIVE_P(WINDOW) \
839 (WINDOWP ((WINDOW)) && !NILP (XWINDOW ((WINDOW))->buffer))
842 /* These used to be in lisp.h. */
844 extern Lisp_Object Qwindowp, Qwindow_live_p;
845 extern Lisp_Object Vwindow_list;
847 EXFUN (Fselected_window, 0);
848 EXFUN (Fwindow_minibuffer_p, 1);
849 EXFUN (Fdelete_window, 1);
850 EXFUN (Fwindow_buffer, 1);
851 EXFUN (Fget_buffer_window, 2);
852 EXFUN (Fset_window_configuration, 1);
853 EXFUN (Fcurrent_window_configuration, 1);
854 extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);
855 EXFUN (Fpos_visible_in_window_p, 3);
856 extern void mark_window_cursors_off (struct window *);
857 extern int window_internal_height (struct window *);
858 EXFUN (Frecenter, 1);
859 extern void temp_output_buffer_show (Lisp_Object);
860 extern void replace_buffer_in_all_windows (Lisp_Object);
861 extern void init_window_once (void);
862 extern void init_window (void);
863 extern void syms_of_window (void);
864 extern void keys_of_window (void);
866 extern int window_box_text_cols (struct window *w);
868 #endif /* not WINDOW_H_INCLUDED */