aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.h')
-rw-r--r--src/window.h211
1 files changed, 93 insertions, 118 deletions
diff --git a/src/window.h b/src/window.h
index 2a12226c0aa..411756f045e 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,6 +1,6 @@
1/* Window definitions for GNU Emacs. 1/* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2012 2 Copyright (C) 1985-1986, 1993, 1995, 1997-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -41,14 +41,13 @@ They are deleted only by calling delete-window on them (but
41this can be done implicitly). Combination windows can be created 41this can be done implicitly). Combination windows can be created
42and deleted at any time. 42and deleted at any time.
43 43
44A leaf window has a non-nil buffer field, and also 44A leaf window has a buffer stored in contents field and markers in its start
45 has markers in its start and pointm fields. Non-leaf windows 45and pointm fields. Non-leaf windows have nil in the latter two fields.
46 have nil in these fields.
47 46
48Non-leaf windows are either vertical or horizontal combinations. 47Non-leaf windows are either vertical or horizontal combinations.
49 48
50A vertical combination window has children that are arranged on the frame 49A vertical combination window has children that are arranged on the frame
51one above the next. Its vchild field points to the uppermost child. 50one above the next. Its contents field points to the uppermost child.
52The parent field of each of the children points to the vertical 51The parent field of each of the children points to the vertical
53combination window. The next field of each child points to the 52combination window. The next field of each child points to the
54child below it, or is nil for the lowest child. The prev field 53child below it, or is nil for the lowest child. The prev field
@@ -56,7 +55,7 @@ of each child points to the child above it, or is nil for the
56highest child. 55highest child.
57 56
58A horizontal combination window has children that are side by side. 57A horizontal combination window has children that are side by side.
59Its hchild field points to the leftmost child. In each child 58Its contents field points to the leftmost child. In each child
60the next field points to the child to the right and the prev field 59the next field points to the child to the right and the prev field
61points to the child to the left. 60points to the child to the left.
62 61
@@ -78,7 +77,7 @@ the root window is the minibuf window. On minibufferless screens or
78minibuffer-only screens, the root window and the minibuffer window are 77minibuffer-only screens, the root window and the minibuffer window are
79one and the same, so its prev and next members are nil. 78one and the same, so its prev and next members are nil.
80 79
81A dead window has its buffer, hchild, and vchild windows all nil. */ 80A dead window has its contents field set to nil. */
82 81
83struct cursor_pos 82struct cursor_pos
84{ 83{
@@ -102,37 +101,22 @@ struct window
102 Lisp_Object next; 101 Lisp_Object next;
103 Lisp_Object prev; 102 Lisp_Object prev;
104 103
105 /* First child of this window: vchild is used if this is a vertical
106 combination, hchild if this is a horizontal combination. Of the
107 fields vchild, hchild and buffer, one and only one is non-nil
108 unless the window is dead. */
109 Lisp_Object hchild;
110 Lisp_Object vchild;
111
112 /* The window this one is a child of. */ 104 /* The window this one is a child of. */
113 Lisp_Object parent; 105 Lisp_Object parent;
114 106
115 /* The upper left corner coordinates of this window, as integers 107 /* The normal size of the window. These are fractions, but we do
116 relative to upper left corner of frame = 0, 0. */ 108 not use C doubles to avoid creating new Lisp_Float objects while
117 Lisp_Object left_col; 109 interfacing Lisp in Fwindow_normal_size. */
118 Lisp_Object top_line;
119
120 /* The size of the window. */
121 Lisp_Object total_lines;
122 Lisp_Object total_cols;
123
124 /* The normal size of the window. */
125 Lisp_Object normal_lines; 110 Lisp_Object normal_lines;
126 Lisp_Object normal_cols; 111 Lisp_Object normal_cols;
127 112
128 /* New sizes of the window. */ 113 /* New sizes of the window. Note that Lisp code may set new_normal
114 to something beyond an integer, so C int can't be used here. */
129 Lisp_Object new_total; 115 Lisp_Object new_total;
130 Lisp_Object new_normal; 116 Lisp_Object new_normal;
131 117
132 /* The buffer displayed in this window. Of the fields vchild, 118 /* May be buffer, window, or nil. */
133 hchild and buffer, one and only one is non-nil unless the window 119 Lisp_Object contents;
134 is dead. */
135 Lisp_Object buffer;
136 120
137 /* A marker pointing to where in the text to start displaying. 121 /* A marker pointing to where in the text to start displaying.
138 BIDI Note: This is the _logical-order_ start, i.e. the smallest 122 BIDI Note: This is the _logical-order_ start, i.e. the smallest
@@ -175,17 +159,13 @@ struct window
175 no scroll bar. A value of t means use frame value. */ 159 no scroll bar. A value of t means use frame value. */
176 Lisp_Object vertical_scroll_bar_type; 160 Lisp_Object vertical_scroll_bar_type;
177 161
178 /* Z - the buffer position of the last glyph in the current matrix 162 /* Z - the buffer position of the last glyph in the current
179 of W. Only valid if WINDOW_END_VALID is not nil. */ 163 matrix of W. Only valid if window_end_valid is nonzero. */
180 Lisp_Object window_end_pos; 164 Lisp_Object window_end_pos;
165
181 /* Glyph matrix row of the last glyph in the current matrix 166 /* Glyph matrix row of the last glyph in the current matrix
182 of W. Only valid if WINDOW_END_VALID is not nil. */ 167 of W. Only valid if window_end_valid is nonzero. */
183 Lisp_Object window_end_vpos; 168 Lisp_Object window_end_vpos;
184 /* t if window_end_pos is truly valid.
185 This is nil if nontrivial redisplay is preempted
186 since in that case the frame image that window_end_pos
187 did not get onto the frame. */
188 Lisp_Object window_end_valid;
189 169
190 /* Display-table to use for displaying chars in this window. 170 /* Display-table to use for displaying chars in this window.
191 Nil means use the buffer's own display-table. */ 171 Nil means use the buffer's own display-table. */
@@ -196,23 +176,6 @@ struct window
196 and Qt, so bitfield can't be used here. */ 176 and Qt, so bitfield can't be used here. */
197 Lisp_Object dedicated; 177 Lisp_Object dedicated;
198 178
199 /* Line number and position of a line somewhere above the top of the
200 screen. If this field is nil, it means we don't have a base
201 line. */
202 Lisp_Object base_line_number;
203 /* If this field is nil, it means we don't have a base line.
204 If it is a buffer, it means don't display the line number
205 as long as the window shows that buffer. */
206 Lisp_Object base_line_pos;
207
208 /* If we have highlighted the region (or any part of it),
209 this is the mark position that we used, as an integer. */
210 Lisp_Object region_showing;
211
212 /* The column number currently displayed in this window's mode line,
213 or nil if column numbers are not being displayed. */
214 Lisp_Object column_number_displayed;
215
216 /* If redisplay in this window goes beyond this buffer position, 179 /* If redisplay in this window goes beyond this buffer position,
217 must run the redisplay-end-trigger-hook. */ 180 must run the redisplay-end-trigger-hook. */
218 Lisp_Object redisplay_end_trigger; 181 Lisp_Object redisplay_end_trigger;
@@ -242,8 +205,14 @@ struct window
242 /* Number saying how recently window was selected. */ 205 /* Number saying how recently window was selected. */
243 int use_time; 206 int use_time;
244 207
245 /* Unique number of window assigned when it was created. */ 208 /* The upper left corner coordinates of this window,
246 int sequence_number; 209 relative to upper left corner of frame = 0, 0. */
210 int left_col;
211 int top_line;
212
213 /* The size of the window. */
214 int total_lines;
215 int total_cols;
247 216
248 /* Number of columns display within the window is scrolled to the left. */ 217 /* Number of columns display within the window is scrolled to the left. */
249 ptrdiff_t hscroll; 218 ptrdiff_t hscroll;
@@ -261,9 +230,22 @@ struct window
261 EMACS_INT last_overlay_modified; 230 EMACS_INT last_overlay_modified;
262 231
263 /* Value of point at that time. Since this is a position in a buffer, 232 /* Value of point at that time. Since this is a position in a buffer,
264 it should be positive. */ 233 it should be positive. */
265 ptrdiff_t last_point; 234 ptrdiff_t last_point;
266 235
236 /* Line number and position of a line somewhere above the top of the
237 screen. If this field is zero, it means we don't have a base line. */
238 ptrdiff_t base_line_number;
239
240 /* If this field is zero, it means we don't have a base line.
241 If it is -1, it means don't display the line number as long
242 as the window shows its buffer. */
243 ptrdiff_t base_line_pos;
244
245 /* The column number currently displayed in this window's mode
246 line, or -1 if column numbers are not being displayed. */
247 ptrdiff_t column_number_displayed;
248
267 /* Scaling factor for the glyph_matrix size calculation in this window. 249 /* Scaling factor for the glyph_matrix size calculation in this window.
268 Used if window contains many small images or uses proportional fonts, 250 Used if window contains many small images or uses proportional fonts,
269 as the normal may yield a matrix which is too small. */ 251 as the normal may yield a matrix which is too small. */
@@ -290,7 +272,11 @@ struct window
290 /* Non-zero if this window is a minibuffer window. */ 272 /* Non-zero if this window is a minibuffer window. */
291 unsigned mini : 1; 273 unsigned mini : 1;
292 274
293 /* Non-zero means must regenerate mode line of this window */ 275 /* Meaningful only if contents is a window, non-zero if this
276 internal window is used in horizontal combination. */
277 unsigned horizontal : 1;
278
279 /* Non-zero means must regenerate mode line of this window. */
294 unsigned update_mode_line : 1; 280 unsigned update_mode_line : 1;
295 281
296 /* Non-nil if the buffer was "modified" when the window 282 /* Non-nil if the buffer was "modified" when the window
@@ -339,33 +325,32 @@ struct window
339 Otherwise draw them between margin areas and text. */ 325 Otherwise draw them between margin areas and text. */
340 unsigned fringes_outside_margins : 1; 326 unsigned fringes_outside_margins : 1;
341 327
328 /* Nonzero if window_end_pos and window_end_vpos are truly valid.
329 This is zero if nontrivial redisplay is preempted since in that case
330 the frame image that window_end_pos did not get onto the frame. */
331 unsigned window_end_valid : 1;
332
342 /* Amount by which lines of this window are scrolled in 333 /* Amount by which lines of this window are scrolled in
343 y-direction (smooth scrolling). */ 334 y-direction (smooth scrolling). */
344 int vscroll; 335 int vscroll;
345 336
346 /* Z_BYTE - the buffer position of the last glyph in the current matrix of W. 337 /* If we have highlighted the region (or any part of it), the mark
347 Should be nonnegative, and only valid if window_end_valid is not nil. */ 338 (region start) position; otherwise zero. */
339 ptrdiff_t region_showing;
340
341 /* Z_BYTE - buffer position of the last glyph in the current matrix of W.
342 Should be nonnegative, and only valid if window_end_valid is nonzero. */
348 ptrdiff_t window_end_bytepos; 343 ptrdiff_t window_end_bytepos;
349}; 344};
350 345
351/* Most code should use these functions to set Lisp fields in struct 346/* Most code should use these functions to set Lisp fields in struct
352 window. */ 347 window. */
353WINDOW_INLINE void 348WINDOW_INLINE void
354wset_buffer (struct window *w, Lisp_Object val)
355{
356 w->buffer = val;
357}
358WINDOW_INLINE void
359wset_frame (struct window *w, Lisp_Object val) 349wset_frame (struct window *w, Lisp_Object val)
360{ 350{
361 w->frame = val; 351 w->frame = val;
362} 352}
363WINDOW_INLINE void 353WINDOW_INLINE void
364wset_left_col (struct window *w, Lisp_Object val)
365{
366 w->left_col = val;
367}
368WINDOW_INLINE void
369wset_next (struct window *w, Lisp_Object val) 354wset_next (struct window *w, Lisp_Object val)
370{ 355{
371 w->next = val; 356 w->next = val;
@@ -381,21 +366,6 @@ wset_redisplay_end_trigger (struct window *w, Lisp_Object val)
381 w->redisplay_end_trigger = val; 366 w->redisplay_end_trigger = val;
382} 367}
383WINDOW_INLINE void 368WINDOW_INLINE void
384wset_top_line (struct window *w, Lisp_Object val)
385{
386 w->top_line = val;
387}
388WINDOW_INLINE void
389wset_total_cols (struct window *w, Lisp_Object val)
390{
391 w->total_cols = val;
392}
393WINDOW_INLINE void
394wset_total_lines (struct window *w, Lisp_Object val)
395{
396 w->total_lines = val;
397}
398WINDOW_INLINE void
399wset_vertical_scroll_bar (struct window *w, Lisp_Object val) 369wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
400{ 370{
401 w->vertical_scroll_bar = val; 371 w->vertical_scroll_bar = val;
@@ -406,11 +376,6 @@ wset_window_end_pos (struct window *w, Lisp_Object val)
406 w->window_end_pos = val; 376 w->window_end_pos = val;
407} 377}
408WINDOW_INLINE void 378WINDOW_INLINE void
409wset_window_end_valid (struct window *w, Lisp_Object val)
410{
411 w->window_end_valid = val;
412}
413WINDOW_INLINE void
414wset_window_end_vpos (struct window *w, Lisp_Object val) 379wset_window_end_vpos (struct window *w, Lisp_Object val)
415{ 380{
416 w->window_end_vpos = val; 381 w->window_end_vpos = val;
@@ -457,6 +422,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
457 422
458/* A handy macro. */ 423/* A handy macro. */
459 424
425/* Non-zero if W is leaf (carry the buffer). */
426
427#define WINDOW_LEAF_P(W) \
428 (BUFFERP ((W)->contents))
429
430/* Non-zero if W is a member of horizontal combination. */
431
432#define WINDOW_HORIZONTAL_COMBINATION_P(W) \
433 (WINDOWP ((W)->contents) && (W)->horizontal)
434
435/* Non-zero if W is a member of vertical combination. */
436
437#define WINDOW_VERTICAL_COMBINATION_P(W) \
438 (WINDOWP ((W)->contents) && !(W)->horizontal)
439
460#define WINDOW_XFRAME(W) \ 440#define WINDOW_XFRAME(W) \
461 (XFRAME (WINDOW_FRAME ((W)))) 441 (XFRAME (WINDOW_FRAME ((W))))
462 442
@@ -473,14 +453,12 @@ wset_next_buffers (struct window *w, Lisp_Object val)
473/* Return the width of window W in canonical column units. 453/* Return the width of window W in canonical column units.
474 This includes scroll bars and fringes. */ 454 This includes scroll bars and fringes. */
475 455
476#define WINDOW_TOTAL_COLS(W) \ 456#define WINDOW_TOTAL_COLS(W) (W)->total_cols
477 (XFASTINT (W->total_cols))
478 457
479/* Return the height of window W in canonical line units. 458/* Return the height of window W in canonical line units.
480 This includes header and mode lines, if any. */ 459 This includes header and mode lines, if any. */
481 460
482#define WINDOW_TOTAL_LINES(W) \ 461#define WINDOW_TOTAL_LINES(W) (W)->total_lines
483 (XFASTINT (W->total_lines))
484 462
485/* Return the total pixel width of window W. */ 463/* Return the total pixel width of window W. */
486 464
@@ -507,8 +485,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
507/* Return the canonical frame column at which window W starts. 485/* Return the canonical frame column at which window W starts.
508 This includes a left-hand scroll bar, if any. */ 486 This includes a left-hand scroll bar, if any. */
509 487
510#define WINDOW_LEFT_EDGE_COL(W) \ 488#define WINDOW_LEFT_EDGE_COL(W) (W)->left_col
511 (XFASTINT (W->left_col))
512 489
513/* Return the canonical frame column before which window W ends. 490/* Return the canonical frame column before which window W ends.
514 This includes a right-hand scroll bar, if any. */ 491 This includes a right-hand scroll bar, if any. */
@@ -519,8 +496,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
519/* Return the canonical frame line at which window W starts. 496/* Return the canonical frame line at which window W starts.
520 This includes a header line, if any. */ 497 This includes a header line, if any. */
521 498
522#define WINDOW_TOP_EDGE_LINE(W) \ 499#define WINDOW_TOP_EDGE_LINE(W) (W)->top_line
523 (XFASTINT (W->top_line))
524 500
525/* Return the canonical frame line before which window W ends. 501/* Return the canonical frame line before which window W ends.
526 This includes a mode line, if any. */ 502 This includes a mode line, if any. */
@@ -545,9 +521,14 @@ wset_next_buffers (struct window *w, Lisp_Object val)
545 521
546/* 1 if W is a menu bar window. */ 522/* 1 if W is a menu bar window. */
547 523
524#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
548#define WINDOW_MENU_BAR_P(W) \ 525#define WINDOW_MENU_BAR_P(W) \
549 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \ 526 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
550 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window)) 527 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
528#else
529/* No menu bar windows if X toolkit is in use. */
530#define WINDOW_MENU_BAR_P(W) (0)
531#endif
551 532
552/* 1 if W is a tool bar window. */ 533/* 1 if W is a tool bar window. */
553 534
@@ -903,10 +884,10 @@ extern Lisp_Object Vmouse_event;
903 884
904extern Lisp_Object make_window (void); 885extern Lisp_Object make_window (void);
905extern Lisp_Object window_from_coordinates (struct frame *, int, int, 886extern Lisp_Object window_from_coordinates (struct frame *, int, int,
906 enum window_part *, int); 887 enum window_part *, bool);
907extern void resize_frame_windows (struct frame *, int, int); 888extern void resize_frame_windows (struct frame *, int, bool);
908extern void delete_all_child_windows (Lisp_Object); 889extern void delete_all_child_windows (Lisp_Object);
909extern void freeze_window_starts (struct frame *, int); 890extern void freeze_window_starts (struct frame *, bool);
910extern void grow_mini_window (struct window *, int); 891extern void grow_mini_window (struct window *, int);
911extern void shrink_mini_window (struct window *); 892extern void shrink_mini_window (struct window *);
912extern int window_relative_x_coord (struct window *, enum window_part, int); 893extern int window_relative_x_coord (struct window *, enum window_part, int);
@@ -918,7 +899,7 @@ void run_window_configuration_change_hook (struct frame *f);
918 it's not allowed. */ 899 it's not allowed. */
919 900
920void set_window_buffer (Lisp_Object window, Lisp_Object buffer, 901void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
921 int run_hooks_p, int keep_margins_p); 902 bool run_hooks_p, bool keep_margins_p);
922 903
923/* This is the window where the echo area message was displayed. It 904/* This is the window where the echo area message was displayed. It
924 is always a minibuffer window, but it may not be the same window 905 is always a minibuffer window, but it may not be the same window
@@ -939,7 +920,7 @@ extern EMACS_INT minibuf_level;
939extern int update_mode_lines; 920extern int update_mode_lines;
940 921
941/* Nonzero if window sizes or contents have changed since last 922/* Nonzero if window sizes or contents have changed since last
942 redisplay that finished */ 923 redisplay that finished. */
943 924
944extern int windows_or_buffers_changed; 925extern int windows_or_buffers_changed;
945 926
@@ -947,11 +928,6 @@ extern int windows_or_buffers_changed;
947 928
948extern int cursor_type_changed; 929extern int cursor_type_changed;
949 930
950/* Number of windows displaying the selected buffer. Normally this is
951 1, but it can be more. */
952
953extern int buffer_shared;
954
955/* If *ROWS or *COLS are too small a size for FRAME, set them to the 931/* If *ROWS or *COLS are too small a size for FRAME, set them to the
956 minimum allowable size. */ 932 minimum allowable size. */
957 933
@@ -964,20 +940,17 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols);
964struct glyph *get_phys_cursor_glyph (struct window *w); 940struct glyph *get_phys_cursor_glyph (struct window *w);
965 941
966/* Value is non-zero if WINDOW is a valid window. */ 942/* Value is non-zero if WINDOW is a valid window. */
967#define WINDOW_VALID_P(WINDOW) \ 943#define WINDOW_VALID_P(WINDOW) \
968 (WINDOWP (WINDOW) \ 944 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \
969 && (!NILP (XWINDOW (WINDOW)->buffer) \ 945
970 || !NILP (XWINDOW (WINDOW)->vchild) \ 946/* A window of any sort, leaf or interior, is "valid" if its
971 || !NILP (XWINDOW (WINDOW)->hchild))) 947 contents slot is non-nil. */
972
973/* A window of any sort, leaf or interior, is "valid" if one
974 of its buffer, vchild, or hchild members is non-nil. */
975#define CHECK_VALID_WINDOW(WINDOW) \ 948#define CHECK_VALID_WINDOW(WINDOW) \
976 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) 949 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
977 950
978/* Value is non-zero if WINDOW is a live window. */ 951/* Value is non-zero if WINDOW is a live window. */
979#define WINDOW_LIVE_P(WINDOW) \ 952#define WINDOW_LIVE_P(WINDOW) \
980 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) 953 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
981 954
982/* A window is "live" if and only if it shows a buffer. */ 955/* A window is "live" if and only if it shows a buffer. */
983#define CHECK_LIVE_WINDOW(WINDOW) \ 956#define CHECK_LIVE_WINDOW(WINDOW) \
@@ -997,6 +970,8 @@ extern int window_body_cols (struct window *w);
997extern void temp_output_buffer_show (Lisp_Object); 970extern void temp_output_buffer_show (Lisp_Object);
998extern void replace_buffer_in_windows (Lisp_Object); 971extern void replace_buffer_in_windows (Lisp_Object);
999extern void replace_buffer_in_windows_safely (Lisp_Object); 972extern void replace_buffer_in_windows_safely (Lisp_Object);
973/* This looks like a setter, but it is a bit special. */
974extern void wset_buffer (struct window *, Lisp_Object);
1000extern void init_window_once (void); 975extern void init_window_once (void);
1001extern void init_window (void); 976extern void init_window (void);
1002extern void syms_of_window (void); 977extern void syms_of_window (void);