* ccl.c (CCL_CODE_RANGE): Allow negative numbers. (Bug#8751)
[bpt/emacs.git] / src / window.h
1 /* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2011
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 extern Lisp_Object Qleft, Qright;
26
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.
30
31 All windows in use are arranged into a tree, with pointers up and down.
32
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.
40
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.
44
45 Non-leaf windows are either vertical or horizontal combinations.
46
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.
54
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.
59
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.
63
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.
71
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.
77
78 A dead window has its buffer, hchild, and vchild windows all nil. */
79
80 struct cursor_pos
81 {
82 /* Pixel position. These are always window relative. */
83 int x, y;
84
85 /* Glyph matrix position. */
86 int hpos, vpos;
87 };
88
89 struct window
90 {
91 /* This is for Lisp; the terminal code does not refer to it. */
92 struct vectorlike_header header;
93
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;
162
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;
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, right_fringe_width;
170
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;
174
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;
181
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;
227
228 /* Original window height and top before mini-window was enlarged. */
229 Lisp_Object orig_total_lines, orig_top_line;
230
231 /* An alist with parameteres. */
232 Lisp_Object window_parameters;
233
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. */
237
238 /* Glyph matrices. */
239 struct glyph_matrix *current_matrix;
240 struct glyph_matrix *desired_matrix;
241
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;
246
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;
250
251 /* Intended cursor position. This is a position within the
252 glyph matrix. */
253 struct cursor_pos cursor;
254
255 /* Where the cursor actually is. */
256 struct cursor_pos phys_cursor;
257
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;
261
262 /* This is handy for undrawing the cursor. */
263 int phys_cursor_ascent, phys_cursor_height;
264
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;
268
269 /* 0 means cursor is logically on, 1 means it's off. Used for
270 blinking cursor. */
271 unsigned cursor_off_p : 1;
272
273 /* Value of cursor_off_p as of the last redisplay. */
274 unsigned last_cursor_off_p : 1;
275
276 /* 1 means desired matrix has been build and window must be
277 updated in update_frame. */
278 unsigned must_be_updated_p : 1;
279
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;
283
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;
288
289 /* Amount by which lines of this window are scrolled in
290 y-direction (smooth scrolling). */
291 int vscroll;
292
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;
296 };
297
298 /* 1 if W is a minibuffer window. */
299
300 #define MINI_WINDOW_P(W) (!NILP ((W)->mini_p))
301
302 /* General window layout:
303
304 LEFT_EDGE_COL RIGHT_EDGE_COL
305 | |
306 | |
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
323
324 */
325
326
327 /* A handy macro. */
328
329 #define WINDOW_XFRAME(W) \
330 (XFRAME (WINDOW_FRAME ((W))))
331
332 /* Return the canonical column width of the frame of window W. */
333
334 #define WINDOW_FRAME_COLUMN_WIDTH(W) \
335 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
336
337 /* Return the canonical column width of the frame of window W. */
338
339 #define WINDOW_FRAME_LINE_HEIGHT(W) \
340 (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
341
342 /* Return the width of window W in canonical column units.
343 This includes scroll bars and fringes. */
344
345 #define WINDOW_TOTAL_COLS(W) \
346 (XFASTINT ((W)->total_cols))
347
348 /* Return the height of window W in canonical line units.
349 This includes header and mode lines, if any. */
350
351 #define WINDOW_TOTAL_LINES(W) \
352 (XFASTINT ((W)->total_lines))
353
354 /* Return the total pixel width of window W. */
355
356 #define WINDOW_TOTAL_WIDTH(W) \
357 (WINDOW_TOTAL_COLS (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
358
359 /* Return the total pixel height of window W. */
360
361 #define WINDOW_TOTAL_HEIGHT(W) \
362 (WINDOW_TOTAL_LINES (W) * WINDOW_FRAME_LINE_HEIGHT (W))
363
364
365 /* Return the canonical frame column at which window W starts.
366 This includes a left-hand scroll bar, if any. */
367
368 #define WINDOW_LEFT_EDGE_COL(W) \
369 (XFASTINT ((W)->left_col))
370
371 /* Return the canonical frame column before which window W ends.
372 This includes a right-hand scroll bar, if any. */
373
374 #define WINDOW_RIGHT_EDGE_COL(W) \
375 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
376
377 /* Return the canonical frame line at which window W starts.
378 This includes a header line, if any. */
379
380 #define WINDOW_TOP_EDGE_LINE(W) \
381 (XFASTINT ((W)->top_line))
382
383 /* Return the canonical frame line before which window W ends.
384 This includes a mode line, if any. */
385
386 #define WINDOW_BOTTOM_EDGE_LINE(W) \
387 (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
388
389
390 /* Return the frame x-position at which window W starts.
391 This includes a left-hand scroll bar, if any. */
392
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))
396
397 /* Return the frame x- position before which window W ends.
398 This includes a right-hand scroll bar, if any. */
399
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))
403
404 /* 1 if W is a menu bar window. */
405
406 #define WINDOW_MENU_BAR_P(W) \
407 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
408 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
409
410 /* 1 if W is a tool bar window. */
411
412 #define WINDOW_TOOL_BAR_P(W) \
413 (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
414 && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
415
416 /* Return the frame y-position at which window W starts.
417 This includes a header line, if any. */
418
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))
423
424 /* Return the frame y-position before which window W ends.
425 This includes a mode line, if any. */
426
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))
431
432
433 /* 1 if window W takes up the full width of its frame. */
434
435 #define WINDOW_FULL_WIDTH_P(W) \
436 (WINDOW_TOTAL_COLS (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
437
438 /* 1 if window W's has no other windows to its left in its frame. */
439
440 #define WINDOW_LEFTMOST_P(W) \
441 (WINDOW_LEFT_EDGE_COL (W) == 0)
442
443 /* 1 if window W's has no other windows to its right in its frame. */
444
445 #define WINDOW_RIGHTMOST_P(W) \
446 (WINDOW_RIGHT_EDGE_COL (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
447
448
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. */
452
453 #define WINDOW_BOX_LEFT_EDGE_COL(W) \
454 (WINDOW_LEFT_EDGE_COL (W) \
455 + WINDOW_LEFT_SCROLL_BAR_COLS (W))
456
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. */
460
461 #define WINDOW_BOX_RIGHT_EDGE_COL(W) \
462 (WINDOW_RIGHT_EDGE_COL (W) \
463 - WINDOW_RIGHT_SCROLL_BAR_COLS (W))
464
465
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. */
469
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))
473
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. */
477
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))
481
482
483 /* Width of left margin area in columns. */
484
485 #define WINDOW_LEFT_MARGIN_COLS(W) \
486 (NILP ((W)->left_margin_cols) \
487 ? 0 \
488 : XINT ((W)->left_margin_cols))
489
490 /* Width of right marginal area in columns. */
491
492 #define WINDOW_RIGHT_MARGIN_COLS(W) \
493 (NILP ((W)->right_margin_cols) \
494 ? 0 \
495 : XINT ((W)->right_margin_cols))
496
497 /* Width of left margin area in pixels. */
498
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)))
504
505 /* Width of right marginal area in pixels. */
506
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)))
512
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. */
518
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)))
527
528 /* Column-width of the left and right fringe. */
529
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))
534
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))
539
540 /* Pixel-width of the left and right fringe. */
541
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)))
546
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)))
551
552 /* Total width of fringes in pixels. */
553
554 #define WINDOW_TOTAL_FRINGE_WIDTH(W) \
555 (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
556
557 /* Are fringes outside display margins in window W. */
558
559 #define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
560 (!NILP ((W)->fringes_outside_margins))
561
562 /* Say whether scroll bars are currently enabled for window W,
563 and which side they are on. */
564
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) \
573
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))
578
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))
583
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))
588
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. */
592
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)))
597
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. */
601
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)))
608
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. */
612
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)
617
618 /* Width of a left scroll bar area in window W , measured in pixels. */
619
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)
624
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. */
628
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)
633
634 /* Width of a left scroll bar area in window W , measured in pixels. */
635
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)
640
641
642 /* Actual width of a scroll bar in window W, measured in columns. */
643
644 #define WINDOW_SCROLL_BAR_COLS(w) \
645 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
646 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
647 : 0)
648
649 /* Width of a left scroll bar area in window W , measured in pixels. */
650
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)
655
656
657 /* Return the frame position where the scroll bar of window W starts. */
658
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))
663
664
665 /* Height in pixels, and in lines, of the mode line.
666 May be zero if W doesn't have a mode line. */
667
668 #define WINDOW_MODE_LINE_HEIGHT(W) \
669 (WINDOW_WANTS_MODELINE_P ((W)) \
670 ? CURRENT_MODE_LINE_HEIGHT (W) \
671 : 0)
672
673 #define WINDOW_MODE_LINE_LINES(W) \
674 (!! WINDOW_WANTS_MODELINE_P ((W)))
675
676 /* Height in pixels, and in lines, of the header line.
677 Zero if W doesn't have a header line. */
678
679 #define WINDOW_HEADER_LINE_HEIGHT(W) \
680 (WINDOW_WANTS_HEADER_LINE_P ((W)) \
681 ? CURRENT_HEADER_LINE_HEIGHT (W) \
682 : 0)
683
684 #define WINDOW_HEADER_LINE_LINES(W) \
685 (!! WINDOW_WANTS_HEADER_LINE_P ((W)))
686
687 /* Pixel height of window W without mode line. */
688
689 #define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W) \
690 (WINDOW_TOTAL_HEIGHT ((W)) \
691 - WINDOW_MODE_LINE_HEIGHT ((W)))
692
693 /* Pixel height of window W without mode and header line. */
694
695 #define WINDOW_BOX_TEXT_HEIGHT(W) \
696 (WINDOW_TOTAL_HEIGHT ((W)) \
697 - WINDOW_MODE_LINE_HEIGHT ((W)) \
698 - WINDOW_HEADER_LINE_HEIGHT ((W)))
699
700
701 /* Convert window W relative pixel X to frame pixel coordinates. */
702
703 #define WINDOW_TO_FRAME_PIXEL_X(W, X) \
704 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
705
706 /* Convert window W relative pixel Y to frame pixel coordinates. */
707
708 #define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
709 ((Y) + WINDOW_TOP_EDGE_Y ((W)))
710
711 /* Convert frame relative pixel X to window relative pixel X. */
712
713 #define FRAME_TO_WINDOW_PIXEL_X(W, X) \
714 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
715
716 /* Convert frame relative pixel Y to window relative pixel Y. */
717
718 #define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
719 ((Y) - WINDOW_TOP_EDGE_Y ((W)))
720
721 /* Convert a text area relative x-position in window W to frame X
722 pixel coordinates. */
723
724 #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
725 (window_box_left ((W), TEXT_AREA) + (X))
726
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.
731
732 This value is always the same as
733 FRAME_SELECTED_WINDOW (selected_frame). */
734
735 extern Lisp_Object selected_window;
736
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. */
740
741 extern int window_select_count;
742
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. */
746
747 extern Lisp_Object minibuf_window;
748
749 /* Non-nil means it is the window whose mode line should be
750 shown as the selected window when the minibuffer is selected. */
751
752 extern Lisp_Object minibuf_selected_window;
753
754 /* Window that the mouse is over (nil if no mouse support). */
755
756 extern Lisp_Object Vmouse_window;
757
758 /* Last mouse-click event (nil if no mouse support). */
759
760 extern Lisp_Object Vmouse_event;
761
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);
778
779 void run_window_configuration_change_hook (struct frame *f);
780
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. */
784
785 void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
786 int run_hooks_p, int keep_margins_p);
787
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. */
791
792 extern Lisp_Object echo_area_window;
793
794 /* Depth in recursive edits. */
795
796 extern int command_loop_level;
797
798 /* Depth in minibuffer invocations. */
799
800 extern int minibuf_level;
801
802 /* true if we should redraw the mode lines on the next redisplay. */
803
804 extern int update_mode_lines;
805
806 /* Nonzero if BEGV - BEG or Z - ZV of current buffer has changed since
807 last redisplay that finished. */
808
809 extern int clip_changed;
810
811 /* Nonzero if window sizes or contents have changed since last
812 redisplay that finished */
813
814 extern int windows_or_buffers_changed;
815
816 /* Nonzero means a frame's cursor type has been changed. */
817
818 extern int cursor_type_changed;
819
820 /* Number of windows displaying the selected buffer. Normally this is
821 1, but it can be more. */
822
823 extern int buffer_shared;
824
825 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
826 minimum allowable size. */
827
828 extern void check_frame_size (struct frame *frame, int *rows, int *cols);
829
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. */
833
834 struct glyph *get_phys_cursor_glyph (struct window *w);
835
836 /* Value is non-zero if WINDOW is a live window. */
837
838 #define WINDOW_LIVE_P(WINDOW) \
839 (WINDOWP ((WINDOW)) && !NILP (XWINDOW ((WINDOW))->buffer))
840
841
842 /* These used to be in lisp.h. */
843
844 extern Lisp_Object Qwindowp, Qwindow_live_p;
845 extern Lisp_Object Vwindow_list;
846
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);
865
866 extern int window_box_text_cols (struct window *w);
867
868 #endif /* not WINDOW_H_INCLUDED */