Retrospective commit from 2009-10-17.
[emacs.git] / src / dispextern.h
blob5f18b7f3a4a00b1f48bc2de95da517e330648c90
1 /* Interface definitions for display code.
2 Copyright (C) 1985, 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 Free Software Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 /* New redisplay written by Gerd Moellmann <gerd@gnu.org>. */
23 #ifndef DISPEXTERN_H_INCLUDED
24 #define DISPEXTERN_H_INCLUDED
26 #ifdef HAVE_X_WINDOWS
28 #include <X11/Xlib.h>
29 #ifdef USE_X_TOOLKIT
30 #include <X11/Intrinsic.h>
31 #endif /* USE_X_TOOLKIT */
33 #else /* !HAVE_X_WINDOWS */
35 /* X-related stuff used by non-X gui code. */
37 typedef struct {
38 unsigned long pixel;
39 unsigned short red, green, blue;
40 char flags;
41 char pad;
42 } XColor;
44 #endif /* HAVE_X_WINDOWS */
46 #ifdef MSDOS
47 #include "msdos.h"
48 #endif
50 #ifdef HAVE_X_WINDOWS
51 typedef struct x_display_info Display_Info;
52 typedef XImage * XImagePtr;
53 typedef XImagePtr XImagePtr_or_DC;
54 #define NativeRectangle XRectangle
55 #endif
57 #ifdef HAVE_NTGUI
58 #include "w32gui.h"
59 typedef struct w32_display_info Display_Info;
60 typedef XImage *XImagePtr;
61 typedef HDC XImagePtr_or_DC;
62 #endif
64 #ifdef HAVE_NS
65 #include "nsgui.h"
66 /* following typedef needed to accomodate the MSDOS port, believe it or not */
67 typedef struct ns_display_info Display_Info;
68 typedef Pixmap XImagePtr;
69 typedef XImagePtr XImagePtr_or_DC;
70 #endif
72 #ifndef NativeRectangle
73 #define NativeRectangle int
74 #endif
76 /* Structure forward declarations. Some are here because function
77 prototypes below reference structure types before their definition
78 in this file. Some are here because not every file including
79 dispextern.h also includes frame.h and windows.h. */
81 struct glyph;
82 struct glyph_row;
83 struct glyph_matrix;
84 struct glyph_pool;
85 struct frame;
86 struct window;
89 /* Values returned from coordinates_in_window. */
91 enum window_part
93 ON_NOTHING,
94 ON_TEXT,
95 ON_MODE_LINE,
96 ON_VERTICAL_BORDER,
97 ON_HEADER_LINE,
98 ON_LEFT_FRINGE,
99 ON_RIGHT_FRINGE,
100 ON_LEFT_MARGIN,
101 ON_RIGHT_MARGIN,
102 ON_SCROLL_BAR
105 /* Number of bits allocated to store fringe bitmap numbers. */
106 #define FRINGE_ID_BITS 16
110 /***********************************************************************
111 Debugging
112 ***********************************************************************/
114 /* If GLYPH_DEBUG is non-zero, additional checks are activated. Turn
115 it off by defining the macro GLYPH_DEBUG to zero. */
117 #ifndef GLYPH_DEBUG
118 #define GLYPH_DEBUG 0
119 #endif
121 /* If XASSERTS is non-zero, additional consistency checks are activated.
122 Turn it off by defining the macro XASSERTS to zero. */
124 #ifndef XASSERTS
125 #define XASSERTS 0
126 #endif
128 /* Macros to include code only if GLYPH_DEBUG != 0. */
130 #if GLYPH_DEBUG
131 #define IF_DEBUG(X) X
132 #else
133 #define IF_DEBUG(X) (void) 0
134 #endif
136 #if XASSERTS
137 #define xassert(X) do {if (!(X)) abort ();} while (0)
138 #else
139 #define xassert(X) (void) 0
140 #endif
142 /* Macro for displaying traces of redisplay. If Emacs was compiled
143 with GLYPH_DEBUG != 0, the variable trace_redisplay_p can be set to
144 a non-zero value in debugging sessions to activate traces. */
146 #if GLYPH_DEBUG
148 extern int trace_redisplay_p;
149 #include <stdio.h>
151 #define TRACE(X) \
152 if (trace_redisplay_p) \
153 fprintf X; \
154 else \
155 (void) 0
157 #else /* GLYPH_DEBUG == 0 */
159 #define TRACE(X) (void) 0
161 #endif /* GLYPH_DEBUG == 0 */
165 /***********************************************************************
166 Text positions
167 ***********************************************************************/
169 /* Starting with Emacs 20.3, characters from strings and buffers have
170 both a character and a byte position associated with them. The
171 following structure holds such a pair of positions. */
173 struct text_pos
175 /* Character position. */
176 EMACS_INT charpos;
178 /* Corresponding byte position. */
179 EMACS_INT bytepos;
182 /* Access character and byte position of POS in a functional form. */
184 #define BYTEPOS(POS) (POS).bytepos
185 #define CHARPOS(POS) (POS).charpos
187 /* Set character position of POS to CHARPOS, byte position to BYTEPOS. */
189 #define SET_TEXT_POS(POS, CHARPOS, BYTEPOS) \
190 ((POS).charpos = (CHARPOS), (POS).bytepos = BYTEPOS)
192 /* Increment text position POS. */
194 #define INC_TEXT_POS(POS, MULTIBYTE_P) \
195 do \
197 ++(POS).charpos; \
198 if (MULTIBYTE_P) \
199 INC_POS ((POS).bytepos); \
200 else \
201 ++(POS).bytepos; \
203 while (0)
205 /* Decrement text position POS. */
207 #define DEC_TEXT_POS(POS, MULTIBYTE_P) \
208 do \
210 --(POS).charpos; \
211 if (MULTIBYTE_P) \
212 DEC_POS ((POS).bytepos); \
213 else \
214 --(POS).bytepos; \
216 while (0)
218 /* Set text position POS from marker MARKER. */
220 #define SET_TEXT_POS_FROM_MARKER(POS, MARKER) \
221 (CHARPOS (POS) = marker_position ((MARKER)), \
222 BYTEPOS (POS) = marker_byte_position ((MARKER)))
224 /* Set marker MARKER from text position POS. */
226 #define SET_MARKER_FROM_TEXT_POS(MARKER, POS) \
227 set_marker_both ((MARKER), Qnil, CHARPOS ((POS)), BYTEPOS ((POS)))
229 /* Value is non-zero if character and byte positions of POS1 and POS2
230 are equal. */
232 #define TEXT_POS_EQUAL_P(POS1, POS2) \
233 ((POS1).charpos == (POS2).charpos \
234 && (POS1).bytepos == (POS2).bytepos)
236 /* When rendering glyphs, redisplay scans string or buffer text,
237 overlay strings in that text, and does display table or control
238 character translations. The following structure captures a
239 position taking all this into account. */
241 struct display_pos
243 /* Buffer or string position. */
244 struct text_pos pos;
246 /* If this is a position in an overlay string, overlay_string_index
247 is the index of that overlay string in the sequence of overlay
248 strings at `pos' in the order redisplay processes them. A value
249 < 0 means that this is not a position in an overlay string. */
250 int overlay_string_index;
252 /* If this is a position in an overlay string, string_pos is the
253 position within that string. */
254 struct text_pos string_pos;
256 /* If the character at the position above is a control character or
257 has a display table entry, dpvec_index is an index in the display
258 table or control character translation of that character. A
259 value < 0 means this is not a position in such a translation. */
260 int dpvec_index;
265 /***********************************************************************
266 Glyphs
267 ***********************************************************************/
269 /* Enumeration of glyph types. Glyph structures contain a type field
270 containing one of the enumerators defined here. */
272 enum glyph_type
274 /* Glyph describes a character. */
275 CHAR_GLYPH,
277 /* Glyph describes a static composition. */
278 COMPOSITE_GLYPH,
280 /* Glyph describes an image. */
281 IMAGE_GLYPH,
283 /* Glyph is a space of fractional width and/or height. */
284 STRETCH_GLYPH
288 /* Structure describing how to use partial glyphs (images slicing) */
290 struct glyph_slice
292 unsigned x : 16;
293 unsigned y : 16;
294 unsigned width : 16;
295 unsigned height : 16;
299 /* Glyphs.
301 Be extra careful when changing this structure! Esp. make sure that
302 functions producing glyphs, like append_glyph, fill ALL of the
303 glyph structure, and that GLYPH_EQUAL_P compares all
304 display-relevant members of glyphs (not to imply that these are the
305 only things to check when you add a member). */
307 struct glyph
309 /* Position from which this glyph was drawn. If `object' below is a
310 Lisp string, this is a position in that string. If it is a
311 buffer, this is a position in that buffer. A value of -1
312 together with a null object means glyph is a truncation glyph at
313 the start of a row. */
314 EMACS_INT charpos;
316 /* Lisp object source of this glyph. Currently either a buffer or
317 a string, if the glyph was produced from characters which came from
318 a buffer or a string; or 0 if the glyph was inserted by redisplay
319 for its own purposes such as padding. */
320 Lisp_Object object;
322 /* Width in pixels. */
323 short pixel_width;
325 /* Ascent and descent in pixels. */
326 short ascent, descent;
328 /* Vertical offset. If < 0, the glyph is displayed raised, if > 0
329 the glyph is displayed lowered. */
330 short voffset;
332 /* Which kind of glyph this is---character, image etc. Value
333 should be an enumerator of type enum glyph_type. */
334 unsigned type : 2;
336 /* 1 means this glyph was produced from multibyte text. Zero
337 means it was produced from unibyte text, i.e. charsets aren't
338 applicable, and encoding is not performed. */
339 unsigned multibyte_p : 1;
341 /* Non-zero means draw a box line at the left or right side of this
342 glyph. This is part of the implementation of the face attribute
343 `:box'. */
344 unsigned left_box_line_p : 1;
345 unsigned right_box_line_p : 1;
347 /* Non-zero means this glyph's physical ascent or descent is greater
348 than its logical ascent/descent, i.e. it may potentially overlap
349 glyphs above or below it. */
350 unsigned overlaps_vertically_p : 1;
352 /* For terminal frames, 1 means glyph is a padding glyph. Padding
353 glyphs are used for characters whose visual shape consists of
354 more than one glyph (e.g. Asian characters). All but the first
355 glyph of such a glyph sequence have the padding_p flag set. This
356 flag is used only to minimize code changes. A better way would
357 probably be to use the width field of glyphs to express padding.
359 For graphic frames, 1 means the pixel width of the glyph in a
360 font is 0, but 1-pixel is padded on displaying for correct cursor
361 displaying. The member `pixel_width' above is set to 1. */
362 unsigned padding_p : 1;
364 /* 1 means the actual glyph is not available, draw a box instead.
365 This can happen when a font couldn't be loaded, or a character
366 doesn't have a glyph in a font. */
367 unsigned glyph_not_available_p : 1;
370 /* Non-zero means don't display cursor here. */
371 unsigned avoid_cursor_p : 1;
373 /* Resolved bidirection level of the characters [0..63]. */
374 unsigned resolved_level : 6;
376 /* Resolved bidirectional type of this character, see enum
377 bidi_type_t below. */
378 unsigned bidi_type : 5;
380 #define FACE_ID_BITS 20
382 /* Face of the glyph. This is a realized face ID,
383 an index in the face cache of the frame. */
384 unsigned face_id : FACE_ID_BITS;
386 /* Type of font used to display the character glyph. May be used to
387 determine which set of functions to use to obtain font metrics
388 for the glyph. On W32, value should be an enumerator of the type
389 w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */
390 unsigned font_type : 3;
392 struct glyph_slice slice;
394 /* A union of sub-structures for different glyph types. */
395 union
397 /* Character code for character glyphs (type == CHAR_GLYPH). */
398 unsigned ch;
400 /* Sub-structures for type == COMPOSITION_GLYPH. */
401 struct
403 /* Flag to tell if the composition is automatic or not. */
404 unsigned automatic : 1;
405 /* ID of the composition. */
406 unsigned id : 23;
407 /* Start and end indices of glyphs of the composition. */
408 unsigned from : 4;
409 unsigned to : 4;
410 } cmp;
412 /* Image ID for image glyphs (type == IMAGE_GLYPH). */
413 unsigned img_id;
415 /* Sub-structure for type == STRETCH_GLYPH. */
416 struct
418 /* The height of the glyph. */
419 unsigned height : 16;
421 /* The ascent of the glyph. */
422 unsigned ascent : 16;
424 stretch;
426 /* Used to compare all bit-fields above in one step. */
427 unsigned val;
428 } u;
432 /* Default value of the glyph font_type field. */
434 #define FONT_TYPE_UNKNOWN 0
436 /* Is GLYPH a space? */
438 #define CHAR_GLYPH_SPACE_P(GLYPH) \
439 ((GLYPH).u.ch == SPACEGLYPH && (GLYPH).face_id == DEFAULT_FACE_ID)
441 /* Are glyph slices of glyphs *X and *Y equal */
443 #define GLYPH_SLICE_EQUAL_P(X, Y) \
444 ((X)->slice.x == (Y)->slice.x \
445 && (X)->slice.y == (Y)->slice.y \
446 && (X)->slice.width == (Y)->slice.width \
447 && (X)->slice.height == (Y)->slice.height)
449 /* Are glyphs *X and *Y displayed equal? */
451 #define GLYPH_EQUAL_P(X, Y) \
452 ((X)->type == (Y)->type \
453 && (X)->u.val == (Y)->u.val \
454 && GLYPH_SLICE_EQUAL_P (X, Y) \
455 && (X)->face_id == (Y)->face_id \
456 && (X)->padding_p == (Y)->padding_p \
457 && (X)->left_box_line_p == (Y)->left_box_line_p \
458 && (X)->right_box_line_p == (Y)->right_box_line_p \
459 && (X)->voffset == (Y)->voffset \
460 && (X)->pixel_width == (Y)->pixel_width)
462 /* Are character codes, faces, padding_ps of glyphs *X and *Y equal? */
464 #define GLYPH_CHAR_AND_FACE_EQUAL_P(X, Y) \
465 ((X)->u.ch == (Y)->u.ch \
466 && (X)->face_id == (Y)->face_id \
467 && (X)->padding_p == (Y)->padding_p)
469 /* Fill a character glyph GLYPH. CODE, FACE_ID, PADDING_P correspond
470 to the bits defined for the typedef `GLYPH' in lisp.h. */
472 #define SET_CHAR_GLYPH(GLYPH, CODE, FACE_ID, PADDING_P) \
473 do \
475 (GLYPH).u.ch = (CODE); \
476 (GLYPH).face_id = (FACE_ID); \
477 (GLYPH).padding_p = (PADDING_P); \
479 while (0)
481 /* Fill a character type glyph GLYPH from a glyph typedef FROM as
482 defined in lisp.h. */
484 #define SET_CHAR_GLYPH_FROM_GLYPH(GLYPH, FROM) \
485 SET_CHAR_GLYPH ((GLYPH), \
486 GLYPH_CHAR ((FROM)), \
487 GLYPH_FACE ((FROM)), \
490 /* Construct a glyph code from a character glyph GLYPH. If the
491 character is multibyte, return -1 as we can't use glyph table for a
492 multibyte character. */
494 #define SET_GLYPH_FROM_CHAR_GLYPH(G, GLYPH) \
495 do \
497 if ((GLYPH).u.ch < 256) \
498 SET_GLYPH ((G), (GLYPH).u.ch, ((GLYPH).face_id)); \
499 else \
500 SET_GLYPH ((G), -1, 0); \
502 while (0)
504 #define GLYPH_INVALID_P(GLYPH) (GLYPH_CHAR (GLYPH) < 0)
506 /* Is GLYPH a padding glyph? */
508 #define CHAR_GLYPH_PADDING_P(GLYPH) (GLYPH).padding_p
513 /***********************************************************************
514 Glyph Pools
515 ***********************************************************************/
517 /* Glyph Pool.
519 Glyph memory for frame-based redisplay is allocated from the heap
520 in one vector kept in a glyph pool structure which is stored with
521 the frame. The size of the vector is made large enough to cover
522 all windows on the frame.
524 Both frame and window glyph matrices reference memory from a glyph
525 pool in frame-based redisplay.
527 In window-based redisplay, no glyphs pools exist; windows allocate
528 and free their glyph memory themselves. */
530 struct glyph_pool
532 /* Vector of glyphs allocated from the heap. */
533 struct glyph *glyphs;
535 /* Allocated size of `glyphs'. */
536 int nglyphs;
538 /* Number of rows and columns in a matrix. */
539 int nrows, ncolumns;
544 /***********************************************************************
545 Glyph Matrix
546 ***********************************************************************/
548 /* Glyph Matrix.
550 Three kinds of glyph matrices exist:
552 1. Frame glyph matrices. These are used for terminal frames whose
553 redisplay needs a view of the whole screen due to limited terminal
554 capabilities. Frame matrices are used only in the update phase
555 of redisplay. They are built in update_frame and not used after
556 the update has been performed.
558 2. Window glyph matrices on frames having frame glyph matrices.
559 Such matrices are sub-matrices of their corresponding frame matrix,
560 i.e. frame glyph matrices and window glyph matrices share the same
561 glyph memory which is allocated in form of a glyph_pool structure.
562 Glyph rows in such a window matrix are slices of frame matrix rows.
564 2. Free-standing window glyph matrices managing their own glyph
565 storage. This form is used in window-based redisplay which
566 includes variable width and height fonts etc.
568 The size of a window's row vector depends on the height of fonts
569 defined on its frame. It is chosen so that the vector is large
570 enough to describe all lines in a window when it is displayed in
571 the smallest possible character size. When new fonts are loaded,
572 or window sizes change, the row vector is adjusted accordingly. */
574 struct glyph_matrix
576 /* The pool from which glyph memory is allocated, if any. This is
577 null for frame matrices and for window matrices managing their
578 own storage. */
579 struct glyph_pool *pool;
581 /* Vector of glyph row structures. The row at nrows - 1 is reserved
582 for the mode line. */
583 struct glyph_row *rows;
585 /* Number of elements allocated for the vector rows above. */
586 int rows_allocated;
588 /* The number of rows used by the window if all lines were displayed
589 with the smallest possible character height. */
590 int nrows;
592 /* Origin within the frame matrix if this is a window matrix on a
593 frame having a frame matrix. Both values are zero for
594 window-based redisplay. */
595 int matrix_x, matrix_y;
597 /* Width and height of the matrix in columns and rows. */
598 int matrix_w, matrix_h;
600 /* If this structure describes a window matrix of window W,
601 window_left_col is the value of W->left_col, window_top_line the
602 value of W->top_line, window_height and window_width are width and
603 height of W, as returned by window_box, and window_vscroll is the
604 value of W->vscroll at the time the matrix was last adjusted.
605 Only set for window-based redisplay. */
606 int window_left_col, window_top_line;
607 int window_height, window_width;
608 int window_vscroll;
610 /* Number of glyphs reserved for left and right marginal areas when
611 the matrix was last adjusted. */
612 int left_margin_glyphs, right_margin_glyphs;
614 /* Flag indicating that scrolling should not be tried in
615 update_window. This flag is set by functions like try_window_id
616 which do their own scrolling. */
617 unsigned no_scrolling_p : 1;
619 /* Non-zero means window displayed in this matrix has a top mode
620 line. */
621 unsigned header_line_p : 1;
623 #ifdef GLYPH_DEBUG
624 /* A string identifying the method used to display the matrix. */
625 char method[512];
626 #endif
628 /* The buffer this matrix displays. Set in
629 mark_window_display_accurate_1. */
630 struct buffer *buffer;
632 /* Values of BEGV and ZV as of last redisplay. Set in
633 mark_window_display_accurate_1. */
634 int begv, zv;
638 /* Check that glyph pointers stored in glyph rows of MATRIX are okay.
639 This aborts if any pointer is found twice. */
641 #if GLYPH_DEBUG
642 void check_matrix_pointer_lossage P_ ((struct glyph_matrix *));
643 #define CHECK_MATRIX(MATRIX) check_matrix_pointer_lossage ((MATRIX))
644 #else
645 #define CHECK_MATRIX(MATRIX) (void) 0
646 #endif
650 /***********************************************************************
651 Glyph Rows
652 ***********************************************************************/
654 /* Area in window glyph matrix. If values are added or removed, the
655 function mark_object in alloc.c has to be changed. */
657 enum glyph_row_area
659 LEFT_MARGIN_AREA,
660 TEXT_AREA,
661 RIGHT_MARGIN_AREA,
662 LAST_AREA
666 /* Rows of glyphs in a windows or frame glyph matrix.
668 Each row is partitioned into three areas. The start and end of
669 each area is recorded in a pointer as shown below.
671 +--------------------+-------------+---------------------+
672 | left margin area | text area | right margin area |
673 +--------------------+-------------+---------------------+
674 | | | |
675 glyphs[LEFT_MARGIN_AREA] glyphs[RIGHT_MARGIN_AREA]
677 glyphs[TEXT_AREA] |
678 glyphs[LAST_AREA]
680 Rows in frame matrices reference glyph memory allocated in a frame
681 glyph pool (see the description of struct glyph_pool). Rows in
682 window matrices on frames having frame matrices reference slices of
683 the glyphs of corresponding rows in the frame matrix.
685 Rows in window matrices on frames having no frame matrices point to
686 glyphs allocated from the heap via xmalloc;
687 glyphs[LEFT_MARGIN_AREA] is the start address of the allocated
688 glyph structure array. */
690 struct glyph_row
692 /* Pointers to beginnings of areas. The end of an area A is found at
693 A + 1 in the vector. The last element of the vector is the end
694 of the whole row.
696 Kludge alert: Even if used[TEXT_AREA] == 0, glyphs[TEXT_AREA][0]'s
697 position field is used. It is -1 if this row does not correspond
698 to any text; it is some buffer position if the row corresponds to
699 an empty display line that displays a line end. This is what old
700 redisplay used to do. (Except in code for terminal frames, this
701 kludge is no longer used, I believe. --gerd).
703 See also start, end, displays_text_p and ends_at_zv_p for cleaner
704 ways to do it. The special meaning of positions 0 and -1 will be
705 removed some day, so don't use it in new code. */
706 struct glyph *glyphs[1 + LAST_AREA];
708 /* Number of glyphs actually filled in areas. */
709 short used[LAST_AREA];
711 /* Window-relative x and y-position of the top-left corner of this
712 row. If y < 0, this means that eabs (y) pixels of the row are
713 invisible because it is partially visible at the top of a window.
714 If x < 0, this means that eabs (x) pixels of the first glyph of
715 the text area of the row are invisible because the glyph is
716 partially visible. */
717 int x, y;
719 /* Width of the row in pixels without taking face extension at the
720 end of the row into account, and without counting truncation
721 and continuation glyphs at the end of a row on ttys. */
722 int pixel_width;
724 /* Logical ascent/height of this line. The value of ascent is zero
725 and height is 1 on terminal frames. */
726 int ascent, height;
728 /* Physical ascent/height of this line. If max_ascent > ascent,
729 this line overlaps the line above it on the display. Otherwise,
730 if max_height > height, this line overlaps the line beneath it. */
731 int phys_ascent, phys_height;
733 /* Portion of row that is visible. Partially visible rows may be
734 found at the top and bottom of a window. This is 1 for tty
735 frames. It may be < 0 in case of completely invisible rows. */
736 int visible_height;
738 /* Extra line spacing added after this row. Do not consider this
739 in last row when checking if row is fully visible. */
740 int extra_line_spacing;
742 /* Hash code. This hash code is available as soon as the row
743 is constructed, i.e. after a call to display_line. */
744 unsigned hash;
746 /* First position in this row. This is the text position, including
747 overlay position information etc, where the display of this row
748 started, and can thus be less the position of the first glyph
749 (e.g. due to invisible text or horizontal scrolling). BIDI Note:
750 This is the smallest character position in the row, i.e. not
751 necessarily the character that is displayed the leftmost. */
752 struct display_pos start;
754 /* Text position at the end of this row. This is the position after
755 the last glyph on this row. It can be greater than the last
756 glyph position + 1, due to truncation, invisible text etc. In an
757 up-to-date display, this should always be equal to the start
758 position of the next row. BIDI Note: this is the character whose
759 buffer position is the largest, not necessarily the one displayed
760 the rightmost. */
761 struct display_pos end;
763 /* Non-zero means the overlay arrow bitmap is on this line.
764 -1 means use default overlay arrow bitmap, else
765 it specifies actual fringe bitmap number. */
766 int overlay_arrow_bitmap;
768 /* Left fringe bitmap number (enum fringe_bitmap_type). */
769 unsigned left_user_fringe_bitmap : FRINGE_ID_BITS;
771 /* Right fringe bitmap number (enum fringe_bitmap_type). */
772 unsigned right_user_fringe_bitmap : FRINGE_ID_BITS;
774 /* Left fringe bitmap number (enum fringe_bitmap_type). */
775 unsigned left_fringe_bitmap : FRINGE_ID_BITS;
777 /* Right fringe bitmap number (enum fringe_bitmap_type). */
778 unsigned right_fringe_bitmap : FRINGE_ID_BITS;
780 /* Face of the left fringe glyph. */
781 unsigned left_user_fringe_face_id : FACE_ID_BITS;
783 /* Face of the right fringe glyph. */
784 unsigned right_user_fringe_face_id : FACE_ID_BITS;
786 /* Face of the left fringe glyph. */
787 unsigned left_fringe_face_id : FACE_ID_BITS;
789 /* Face of the right fringe glyph. */
790 unsigned right_fringe_face_id : FACE_ID_BITS;
792 /* 1 means that we must draw the bitmaps of this row. */
793 unsigned redraw_fringe_bitmaps_p : 1;
795 /* In a desired matrix, 1 means that this row must be updated. In a
796 current matrix, 0 means that the row has been invalidated, i.e.
797 the row's contents do not agree with what is visible on the
798 screen. */
799 unsigned enabled_p : 1;
801 /* 1 means row displays a text line that is truncated on the left or
802 right side. */
803 unsigned truncated_on_left_p : 1;
804 unsigned truncated_on_right_p : 1;
806 /* 1 means that this row displays a continued line, i.e. it has a
807 continuation mark at the right side. */
808 unsigned continued_p : 1;
810 /* 0 means that this row does not contain any text, i.e. it is
811 a blank line at the window and buffer end. */
812 unsigned displays_text_p : 1;
814 /* 1 means that this line ends at ZV. */
815 unsigned ends_at_zv_p : 1;
817 /* 1 means the face of the last glyph in the text area is drawn to
818 the right end of the window. This flag is used in
819 update_text_area to optimize clearing to the end of the area. */
820 unsigned fill_line_p : 1;
822 /* Non-zero means display a bitmap on X frames indicating that this
823 line contains no text and ends in ZV. */
824 unsigned indicate_empty_line_p : 1;
826 /* 1 means this row contains glyphs that overlap each other because
827 of lbearing or rbearing. */
828 unsigned contains_overlapping_glyphs_p : 1;
830 /* 1 means this row is as wide as the window it is displayed in, including
831 scroll bars, fringes, and internal borders. This also
832 implies that the row doesn't have marginal areas. */
833 unsigned full_width_p : 1;
835 /* Non-zero means row is a mode or header-line. */
836 unsigned mode_line_p : 1;
838 /* 1 in a current row means this row is overlapped by another row. */
839 unsigned overlapped_p : 1;
841 /* 1 means this line ends in the middle of a character consisting
842 of more than one glyph. Some glyphs have been put in this row,
843 the rest are put in rows below this one. */
844 unsigned ends_in_middle_of_char_p : 1;
846 /* 1 means this line starts in the middle of a character consisting
847 of more than one glyph. Some glyphs have been put in the
848 previous row, the rest are put in this row. */
849 unsigned starts_in_middle_of_char_p : 1;
851 /* 1 in a current row means this row overlaps others. */
852 unsigned overlapping_p : 1;
854 /* 1 means some glyphs in this row are displayed in mouse-face. */
855 unsigned mouse_face_p : 1;
857 /* 1 means this row was ended by a newline from a string. */
858 unsigned ends_in_newline_from_string_p : 1;
860 /* 1 means this row width is exactly the width of the window, and the
861 final newline character is hidden in the right fringe. */
862 unsigned exact_window_width_line_p : 1;
864 /* 1 means this row currently shows the cursor in the right fringe. */
865 unsigned cursor_in_fringe_p : 1;
867 /* 1 means the last glyph in the row is part of an ellipsis. */
868 unsigned ends_in_ellipsis_p : 1;
870 /* Non-zero means display a bitmap on X frames indicating that this
871 the first line of the buffer. */
872 unsigned indicate_bob_p : 1;
874 /* Non-zero means display a bitmap on X frames indicating that this
875 the top line of the window, but not start of the buffer. */
876 unsigned indicate_top_line_p : 1;
878 /* Non-zero means display a bitmap on X frames indicating that this
879 the last line of the buffer. */
880 unsigned indicate_eob_p : 1;
882 /* Non-zero means display a bitmap on X frames indicating that this
883 the bottom line of the window, but not end of the buffer. */
884 unsigned indicate_bottom_line_p : 1;
886 /* Non-zero means the row was reversed to display text in a
887 right-to-left paragraph. */
888 unsigned reversed_p : 1;
890 /* Continuation lines width at the start of the row. */
891 int continuation_lines_width;
893 #ifdef HAVE_WINDOW_SYSTEM
894 /* Non-NULL means the current clipping area. This is temporarily
895 set while exposing a region. Coordinates are frame-relative. */
896 XRectangle *clip;
897 #endif
901 /* Get a pointer to row number ROW in matrix MATRIX. If GLYPH_DEBUG
902 is defined to a non-zero value, the function matrix_row checks that
903 we don't try to access rows that are out of bounds. */
905 #if GLYPH_DEBUG
906 struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int));
907 #define MATRIX_ROW(MATRIX, ROW) matrix_row ((MATRIX), (ROW))
908 #else
909 #define MATRIX_ROW(MATRIX, ROW) ((MATRIX)->rows + (ROW))
910 #endif
912 /* Return a pointer to the row reserved for the mode line in MATRIX.
913 Row MATRIX->nrows - 1 is always reserved for the mode line. */
915 #define MATRIX_MODE_LINE_ROW(MATRIX) \
916 ((MATRIX)->rows + (MATRIX)->nrows - 1)
918 /* Return a pointer to the row reserved for the header line in MATRIX.
919 This is always the first row in MATRIX because that's the only
920 way that works in frame-based redisplay. */
922 #define MATRIX_HEADER_LINE_ROW(MATRIX) (MATRIX)->rows
924 /* Return a pointer to first row in MATRIX used for text display. */
926 #define MATRIX_FIRST_TEXT_ROW(MATRIX) \
927 ((MATRIX)->rows->mode_line_p ? (MATRIX)->rows + 1 : (MATRIX)->rows)
929 /* Return a pointer to the first glyph in the text area of a row.
930 MATRIX is the glyph matrix accessed, and ROW is the row index in
931 MATRIX. */
933 #define MATRIX_ROW_GLYPH_START(MATRIX, ROW) \
934 (MATRIX_ROW ((MATRIX), (ROW))->glyphs[TEXT_AREA])
936 /* Return the number of used glyphs in the text area of a row. */
938 #define MATRIX_ROW_USED(MATRIX, ROW) \
939 (MATRIX_ROW ((MATRIX), (ROW))->used[TEXT_AREA])
941 /* Return the character/ byte position at which the display of ROW
942 starts. BIDI Note: this is the smallest character/byte position
943 among characters in ROW, i.e. the first logical-order character
944 displayed by ROW, which is not necessarily the smallest horizontal
945 position. */
947 #define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->start.pos.charpos)
948 #define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->start.pos.bytepos)
950 /* Return the character/ byte position at which ROW ends. BIDI Note:
951 this is the largest character/byte position among characters in
952 ROW, i.e. the last logical-order character displayed by ROW, which
953 is not necessarily the largest horizontal position. */
955 #define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->end.pos.charpos)
956 #define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->end.pos.bytepos)
958 /* Return the vertical position of ROW in MATRIX. */
960 #define MATRIX_ROW_VPOS(ROW, MATRIX) ((ROW) - (MATRIX)->rows)
962 /* Return the last glyph row + 1 in MATRIX on window W reserved for
963 text. If W has a mode line, the last row in the matrix is reserved
964 for it. */
966 #define MATRIX_BOTTOM_TEXT_ROW(MATRIX, W) \
967 ((MATRIX)->rows \
968 + (MATRIX)->nrows \
969 - (WINDOW_WANTS_MODELINE_P ((W)) ? 1 : 0))
971 /* Non-zero if the face of the last glyph in ROW's text area has
972 to be drawn to the end of the text area. */
974 #define MATRIX_ROW_EXTENDS_FACE_P(ROW) ((ROW)->fill_line_p)
976 /* Set and query the enabled_p flag of glyph row ROW in MATRIX. */
978 #define SET_MATRIX_ROW_ENABLED_P(MATRIX, ROW, VALUE) \
979 (MATRIX_ROW ((MATRIX), (ROW))->enabled_p = (VALUE) != 0)
981 #define MATRIX_ROW_ENABLED_P(MATRIX, ROW) \
982 (MATRIX_ROW ((MATRIX), (ROW))->enabled_p)
984 /* Non-zero if ROW displays text. Value is non-zero if the row is
985 blank but displays a line end. */
987 #define MATRIX_ROW_DISPLAYS_TEXT_P(ROW) ((ROW)->displays_text_p)
990 /* Helper macros */
992 #define MR_PARTIALLY_VISIBLE(ROW) \
993 ((ROW)->height != (ROW)->visible_height)
995 #define MR_PARTIALLY_VISIBLE_AT_TOP(W, ROW) \
996 ((ROW)->y < WINDOW_HEADER_LINE_HEIGHT ((W)))
998 #define MR_PARTIALLY_VISIBLE_AT_BOTTOM(W, ROW) \
999 (((ROW)->y + (ROW)->height - (ROW)->extra_line_spacing) \
1000 > WINDOW_BOX_HEIGHT_NO_MODE_LINE ((W)))
1002 /* Non-zero if ROW is not completely visible in window W. */
1004 #define MATRIX_ROW_PARTIALLY_VISIBLE_P(W, ROW) \
1005 (MR_PARTIALLY_VISIBLE ((ROW)) \
1006 && (MR_PARTIALLY_VISIBLE_AT_TOP ((W), (ROW)) \
1007 || MR_PARTIALLY_VISIBLE_AT_BOTTOM ((W), (ROW))))
1011 /* Non-zero if ROW is partially visible at the top of window W. */
1013 #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P(W, ROW) \
1014 (MR_PARTIALLY_VISIBLE ((ROW)) \
1015 && MR_PARTIALLY_VISIBLE_AT_TOP ((W), (ROW)))
1017 /* Non-zero if ROW is partially visible at the bottom of window W. */
1019 #define MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P(W, ROW) \
1020 (MR_PARTIALLY_VISIBLE ((ROW)) \
1021 && MR_PARTIALLY_VISIBLE_AT_BOTTOM ((W), (ROW)))
1023 /* Return the bottom Y + 1 of ROW. */
1025 #define MATRIX_ROW_BOTTOM_Y(ROW) ((ROW)->y + (ROW)->height)
1027 /* Is ROW the last visible one in the display described by the
1028 iterator structure pointed to by IT?. */
1030 #define MATRIX_ROW_LAST_VISIBLE_P(ROW, IT) \
1031 (MATRIX_ROW_BOTTOM_Y ((ROW)) >= (IT)->last_visible_y)
1033 /* Non-zero if ROW displays a continuation line. */
1035 #define MATRIX_ROW_CONTINUATION_LINE_P(ROW) \
1036 ((ROW)->continuation_lines_width > 0)
1038 /* Non-zero if ROW ends in the middle of a character. This is the
1039 case for continued lines showing only part of a display table entry
1040 or a control char, or an overlay string. */
1042 #define MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P(ROW) \
1043 ((ROW)->end.dpvec_index > 0 \
1044 || (ROW)->end.overlay_string_index >= 0 \
1045 || (ROW)->ends_in_middle_of_char_p)
1047 /* Non-zero if ROW ends in the middle of an overlay string. */
1049 #define MATRIX_ROW_ENDS_IN_OVERLAY_STRING_P(ROW) \
1050 ((ROW)->end.overlay_string_index >= 0)
1052 /* Non-zero if ROW starts in the middle of a character. See above. */
1054 #define MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P(ROW) \
1055 ((ROW)->start.dpvec_index > 0 \
1056 || (ROW)->starts_in_middle_of_char_p \
1057 || ((ROW)->start.overlay_string_index >= 0 \
1058 && (ROW)->start.string_pos.charpos > 0))
1060 /* Non-zero means ROW overlaps its predecessor. */
1062 #define MATRIX_ROW_OVERLAPS_PRED_P(ROW) \
1063 ((ROW)->phys_ascent > (ROW)->ascent)
1065 /* Non-zero means ROW overlaps its successor. */
1067 #define MATRIX_ROW_OVERLAPS_SUCC_P(ROW) \
1068 ((ROW)->phys_height - (ROW)->phys_ascent \
1069 > (ROW)->height - (ROW)->ascent)
1071 /* Non-zero means that fonts have been loaded since the last glyph
1072 matrix adjustments. The function redisplay_internal adjusts glyph
1073 matrices when this flag is non-zero. */
1075 extern int fonts_changed_p;
1077 /* A glyph for a space. */
1079 extern struct glyph space_glyph;
1081 /* Window being updated by update_window. This is non-null as long as
1082 update_window has not finished, and null otherwise. */
1084 extern struct window *updated_window;
1086 /* Glyph row and area updated by update_window_line. */
1088 extern struct glyph_row *updated_row;
1089 extern int updated_area;
1091 /* Non-zero means reading single-character input with prompt so put
1092 cursor on mini-buffer after the prompt. Positive means at end of
1093 text in echo area; negative means at beginning of line. */
1095 extern int cursor_in_echo_area;
1097 /* Non-zero means last display completed. Zero means it was
1098 preempted. */
1100 extern int display_completed;
1102 /* Non-zero means redisplay has been performed directly (see also
1103 direct_output_for_insert and direct_output_forward_char), so that
1104 no further updating has to be performed. The function
1105 redisplay_internal checks this flag, and does nothing but reset it
1106 to zero if it is non-zero. */
1108 extern int redisplay_performed_directly_p;
1110 /* A temporary storage area, including a row of glyphs. Initialized
1111 in xdisp.c. Used for various purposes, as an example see
1112 direct_output_for_insert. */
1114 extern struct glyph_row scratch_glyph_row;
1118 /************************************************************************
1119 Glyph Strings
1120 ************************************************************************/
1122 /* Enumeration for overriding/changing the face to use for drawing
1123 glyphs in draw_glyphs. */
1125 enum draw_glyphs_face
1127 DRAW_NORMAL_TEXT,
1128 DRAW_INVERSE_VIDEO,
1129 DRAW_CURSOR,
1130 DRAW_MOUSE_FACE,
1131 DRAW_IMAGE_RAISED,
1132 DRAW_IMAGE_SUNKEN
1135 #ifdef HAVE_WINDOW_SYSTEM
1137 /* A sequence of glyphs to be drawn in the same face. */
1139 struct glyph_string
1141 /* X-origin of the string. */
1142 int x;
1144 /* Y-origin and y-position of the base line of this string. */
1145 int y, ybase;
1147 /* The width of the string, not including a face extension. */
1148 int width;
1150 /* The width of the string, including a face extension. */
1151 int background_width;
1153 /* The height of this string. This is the height of the line this
1154 string is drawn in, and can be different from the height of the
1155 font the string is drawn in. */
1156 int height;
1158 /* Number of pixels this string overwrites in front of its x-origin.
1159 This number is zero if the string has an lbearing >= 0; it is
1160 -lbearing, if the string has an lbearing < 0. */
1161 int left_overhang;
1163 /* Number of pixels this string overwrites past its right-most
1164 nominal x-position, i.e. x + width. Zero if the string's
1165 rbearing is <= its nominal width, rbearing - width otherwise. */
1166 int right_overhang;
1168 /* The frame on which the glyph string is drawn. */
1169 struct frame *f;
1171 /* The window on which the glyph string is drawn. */
1172 struct window *w;
1174 /* X display and window for convenience. */
1175 Display *display;
1176 Window window;
1178 /* The glyph row for which this string was built. It determines the
1179 y-origin and height of the string. */
1180 struct glyph_row *row;
1182 /* The area within row. */
1183 enum glyph_row_area area;
1185 /* Characters to be drawn, and number of characters. */
1186 XChar2b *char2b;
1187 int nchars;
1189 /* A face-override for drawing cursors, mouse face and similar. */
1190 enum draw_glyphs_face hl;
1192 /* Face in which this string is to be drawn. */
1193 struct face *face;
1195 /* Font in which this string is to be drawn. */
1196 struct font *font;
1198 /* Non-null means this string describes (part of) a static
1199 composition. */
1200 struct composition *cmp;
1202 /* If not negative, this string describes a compos. */
1203 int cmp_id;
1205 /* Start and end glyph indices in a glyph-string. */
1206 int cmp_from, cmp_to;
1208 /* 1 means this glyph strings face has to be drawn to the right end
1209 of the window's drawing area. */
1210 unsigned extends_to_end_of_line_p : 1;
1212 /* 1 means the background of this string has been drawn. */
1213 unsigned background_filled_p : 1;
1215 /* 1 means glyph string must be drawn with 16-bit functions. */
1216 unsigned two_byte_p : 1;
1218 /* 1 means that the original font determined for drawing this glyph
1219 string could not be loaded. The member `font' has been set to
1220 the frame's default font in this case. */
1221 unsigned font_not_found_p : 1;
1223 /* 1 means that the face in which this glyph string is drawn has a
1224 stipple pattern. */
1225 unsigned stippled_p : 1;
1227 #define OVERLAPS_PRED (1 << 0)
1228 #define OVERLAPS_SUCC (1 << 1)
1229 #define OVERLAPS_BOTH (OVERLAPS_PRED | OVERLAPS_SUCC)
1230 #define OVERLAPS_ERASED_CURSOR (1 << 2)
1231 /* Non-zero means only the foreground of this glyph string must be
1232 drawn, and we should use the physical height of the line this
1233 glyph string appears in as clip rect. If the value is
1234 OVERLAPS_ERASED_CURSOR, the clip rect is restricted to the rect
1235 of the erased cursor. OVERLAPS_PRED and OVERLAPS_SUCC mean we
1236 draw overlaps with the preceding and the succeeding rows,
1237 respectively. */
1238 unsigned for_overlaps : 3;
1240 /* 1 means that all glyphs in this glyph string has the flag
1241 padding_p set, and thus must be drawn one by one to have 1-pixel
1242 width even though the logical width in the font is zero. */
1243 unsigned padding_p : 1;
1245 /* The GC to use for drawing this glyph string. */
1246 #if defined(HAVE_X_WINDOWS)
1247 GC gc;
1248 #endif
1249 #if defined(HAVE_NTGUI)
1250 XGCValues *gc;
1251 HDC hdc;
1252 #endif
1254 /* A pointer to the first glyph in the string. This glyph
1255 corresponds to char2b[0]. Needed to draw rectangles if
1256 font_not_found_p is 1. */
1257 struct glyph *first_glyph;
1259 /* Image, if any. */
1260 struct image *img;
1262 /* Slice */
1263 struct glyph_slice slice;
1265 /* Non-null means the horizontal clipping region starts from the
1266 left edge of *clip_head, and ends with the right edge of
1267 *clip_tail, not including their overhangs. */
1268 struct glyph_string *clip_head, *clip_tail;
1270 /* The current clipping areas. */
1271 NativeRectangle clip[2];
1273 /* Number of clipping areas. */
1274 int num_clips;
1276 int underline_position;
1278 int underline_thickness;
1280 struct glyph_string *next, *prev;
1283 #endif /* HAVE_WINDOW_SYSTEM */
1286 /************************************************************************
1287 Display Dimensions
1288 ************************************************************************/
1290 /* Return the height of the mode line in glyph matrix MATRIX, or zero
1291 if not known. This macro is called under circumstances where
1292 MATRIX might not have been allocated yet. */
1294 #define MATRIX_MODE_LINE_HEIGHT(MATRIX) \
1295 ((MATRIX) && (MATRIX)->rows \
1296 ? MATRIX_MODE_LINE_ROW (MATRIX)->height \
1297 : 0)
1299 /* Return the height of the header line in glyph matrix MATRIX, or zero
1300 if not known. This macro is called under circumstances where
1301 MATRIX might not have been allocated yet. */
1303 #define MATRIX_HEADER_LINE_HEIGHT(MATRIX) \
1304 ((MATRIX) && (MATRIX)->rows \
1305 ? MATRIX_HEADER_LINE_ROW (MATRIX)->height \
1306 : 0)
1308 /* Return the desired face id for the mode line of a window, depending
1309 on whether the window is selected or not, or if the window is the
1310 scrolling window for the currently active minibuffer window.
1312 Due to the way display_mode_lines manipulates with the contents of
1313 selected_window, this macro needs three arguments: SELW which is
1314 compared against the current value of selected_window, MBW which is
1315 compared against minibuf_window (if SELW doesn't match), and SCRW
1316 which is compared against minibuf_selected_window (if MBW matches). */
1318 #define CURRENT_MODE_LINE_FACE_ID_3(SELW, MBW, SCRW) \
1319 ((!mode_line_in_non_selected_windows \
1320 || (SELW) == XWINDOW (selected_window) \
1321 || (minibuf_level > 0 \
1322 && !NILP (minibuf_selected_window) \
1323 && (MBW) == XWINDOW (minibuf_window) \
1324 && (SCRW) == XWINDOW (minibuf_selected_window))) \
1325 ? MODE_LINE_FACE_ID \
1326 : MODE_LINE_INACTIVE_FACE_ID)
1329 /* Return the desired face id for the mode line of window W. */
1331 #define CURRENT_MODE_LINE_FACE_ID(W) \
1332 (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W)))
1334 /* Return the current height of the mode line of window W. If not
1335 known from current_mode_line_height, look at W's current glyph
1336 matrix, or return a default based on the height of the font of the
1337 face `mode-line'. */
1339 #define CURRENT_MODE_LINE_HEIGHT(W) \
1340 (current_mode_line_height >= 0 \
1341 ? current_mode_line_height \
1342 : (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \
1343 ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \
1344 : estimate_mode_line_height (XFRAME ((W)->frame), \
1345 CURRENT_MODE_LINE_FACE_ID (W))))
1347 /* Return the current height of the header line of window W. If not
1348 known from current_header_line_height, look at W's current glyph
1349 matrix, or return an estimation based on the height of the font of
1350 the face `header-line'. */
1352 #define CURRENT_HEADER_LINE_HEIGHT(W) \
1353 (current_header_line_height >= 0 \
1354 ? current_header_line_height \
1355 : (MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \
1356 ? MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \
1357 : estimate_mode_line_height (XFRAME ((W)->frame), \
1358 HEADER_LINE_FACE_ID)))
1360 /* Return the height of the desired mode line of window W. */
1362 #define DESIRED_MODE_LINE_HEIGHT(W) \
1363 MATRIX_MODE_LINE_HEIGHT ((W)->desired_matrix)
1365 /* Return the height of the desired header line of window W. */
1367 #define DESIRED_HEADER_LINE_HEIGHT(W) \
1368 MATRIX_HEADER_LINE_HEIGHT ((W)->desired_matrix)
1370 /* Value is non-zero if window W wants a mode line. */
1372 #define WINDOW_WANTS_MODELINE_P(W) \
1373 (!MINI_WINDOW_P ((W)) \
1374 && !(W)->pseudo_window_p \
1375 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
1376 && BUFFERP ((W)->buffer) \
1377 && !NILP (XBUFFER ((W)->buffer)->mode_line_format) \
1378 && WINDOW_TOTAL_LINES (W) > 1)
1380 /* Value is non-zero if window W wants a header line. */
1382 #define WINDOW_WANTS_HEADER_LINE_P(W) \
1383 (!MINI_WINDOW_P ((W)) \
1384 && !(W)->pseudo_window_p \
1385 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
1386 && BUFFERP ((W)->buffer) \
1387 && !NILP (XBUFFER ((W)->buffer)->header_line_format) \
1388 && WINDOW_TOTAL_LINES (W) > 1 + !NILP (XBUFFER ((W)->buffer)->mode_line_format))
1391 /* Return proper value to be used as baseline offset of font that has
1392 ASCENT and DESCENT to draw characters by the font at the vertical
1393 center of the line of frame F.
1395 Here, our task is to find the value of BOFF in the following figure;
1397 -------------------------+-----------+-
1398 -+-+---------+-+ | |
1399 | | | | | |
1400 | | | | F_ASCENT F_HEIGHT
1401 | | | ASCENT | |
1402 HEIGHT | | | | |
1403 | | |-|-+------+-----------|------- baseline
1404 | | | | BOFF | |
1405 | |---------|-+-+ | |
1406 | | | DESCENT | |
1407 -+-+---------+-+ F_DESCENT |
1408 -------------------------+-----------+-
1410 -BOFF + DESCENT + (F_HEIGHT - HEIGHT) / 2 = F_DESCENT
1411 BOFF = DESCENT + (F_HEIGHT - HEIGHT) / 2 - F_DESCENT
1412 DESCENT = FONT->descent
1413 HEIGHT = FONT_HEIGHT (FONT)
1414 F_DESCENT = (FRAME_FONT (F)->descent
1415 - F->terminal->output_data.x->baseline_offset)
1416 F_HEIGHT = FRAME_LINE_HEIGHT (F)
1419 #define VCENTER_BASELINE_OFFSET(FONT, F) \
1420 (FONT_DESCENT (FONT) \
1421 + (FRAME_LINE_HEIGHT ((F)) - FONT_HEIGHT ((FONT)) \
1422 + (FRAME_LINE_HEIGHT ((F)) > FONT_HEIGHT ((FONT)))) / 2 \
1423 - (FONT_DESCENT (FRAME_FONT (F)) - FRAME_BASELINE_OFFSET (F)))
1426 /***********************************************************************
1427 Faces
1428 ***********************************************************************/
1430 /* Indices of face attributes in Lisp face vectors. Slot zero is the
1431 symbol `face'. */
1433 enum lface_attribute_index
1435 LFACE_FAMILY_INDEX = 1,
1436 LFACE_FOUNDRY_INDEX,
1437 LFACE_SWIDTH_INDEX,
1438 LFACE_HEIGHT_INDEX,
1439 LFACE_WEIGHT_INDEX,
1440 LFACE_SLANT_INDEX,
1441 LFACE_UNDERLINE_INDEX,
1442 LFACE_INVERSE_INDEX,
1443 LFACE_FOREGROUND_INDEX,
1444 LFACE_BACKGROUND_INDEX,
1445 LFACE_STIPPLE_INDEX,
1446 LFACE_OVERLINE_INDEX,
1447 LFACE_STRIKE_THROUGH_INDEX,
1448 LFACE_BOX_INDEX,
1449 LFACE_FONT_INDEX,
1450 LFACE_INHERIT_INDEX,
1451 LFACE_FONTSET_INDEX,
1452 LFACE_VECTOR_SIZE
1456 /* Box types of faces. */
1458 enum face_box_type
1460 /* No box around text. */
1461 FACE_NO_BOX,
1463 /* Simple box of specified width and color. Default width is 1, and
1464 default color is the foreground color of the face. */
1465 FACE_SIMPLE_BOX,
1467 /* Boxes with 3D shadows. Color equals the background color of the
1468 face. Width is specified. */
1469 FACE_RAISED_BOX,
1470 FACE_SUNKEN_BOX
1474 /* Structure describing a realized face.
1476 For each Lisp face, 0..N realized faces can exist for different
1477 frames and different charsets. Realized faces are built from Lisp
1478 faces and text properties/overlays by merging faces and adding
1479 unspecified attributes from the `default' face. */
1481 struct face
1483 /* The id of this face. The id equals the index of this face in the
1484 vector faces_by_id of its face cache. */
1485 int id;
1487 #ifdef HAVE_WINDOW_SYSTEM
1489 /* If non-zero, this is a GC that we can use without modification for
1490 drawing the characters in this face. */
1491 GC gc;
1493 /* Background stipple or bitmap used for this face. This is
1494 an id as returned from load_pixmap. */
1495 int stipple;
1497 #else /* not HAVE_WINDOW_SYSTEM */
1499 /* Dummy. */
1500 int stipple;
1502 #endif /* not HAVE_WINDOW_SYSTEM */
1504 /* Pixel value of foreground color for X frames. Color index
1505 for tty frames. */
1506 unsigned long foreground;
1508 /* Pixel value or color index of background color. */
1509 unsigned long background;
1511 /* Pixel value or color index of underline color. */
1512 unsigned long underline_color;
1514 /* Pixel value or color index of overlined, strike-through, or box
1515 color. */
1516 unsigned long overline_color;
1517 unsigned long strike_through_color;
1518 unsigned long box_color;
1520 struct font *font;
1522 /* Fontset ID if for this face's fontset. Non-ASCII faces derived
1523 from the same ASCII face have the same fontset. */
1524 int fontset;
1526 /* Pixmap width and height. */
1527 unsigned int pixmap_w, pixmap_h;
1529 /* Non-zero means characters in this face have a box that thickness
1530 around them. If it is negative, the absolute value indicates the
1531 thickness, and the horizontal lines of box (top and bottom) are
1532 drawn inside of characters glyph area. The vertical lines of box
1533 (left and right) are drawn as the same way as the case that this
1534 value is positive. */
1535 int box_line_width;
1537 /* Type of box drawn. A value of FACE_NO_BOX means no box is drawn
1538 around text in this face. A value of FACE_SIMPLE_BOX means a box
1539 of width box_line_width is drawn in color box_color. A value of
1540 FACE_RAISED_BOX or FACE_SUNKEN_BOX means a 3D box is drawn with
1541 shadow colors derived from the background color of the face. */
1542 enum face_box_type box;
1544 /* If `box' above specifies a 3D type, 1 means use box_color for
1545 drawing shadows. */
1546 unsigned use_box_color_for_shadows_p : 1;
1548 /* Non-zero if text in this face should be underlined, overlined,
1549 strike-through or have a box drawn around it. */
1550 unsigned underline_p : 1;
1551 unsigned overline_p : 1;
1552 unsigned strike_through_p : 1;
1554 /* 1 means that the colors specified for this face could not be
1555 loaded, and were replaced by default colors, so they shouldn't be
1556 freed. */
1557 unsigned foreground_defaulted_p : 1;
1558 unsigned background_defaulted_p : 1;
1560 /* 1 means that either no color is specified for underlining or that
1561 the specified color couldn't be loaded. Use the foreground
1562 color when drawing in that case. */
1563 unsigned underline_defaulted_p : 1;
1565 /* 1 means that either no color is specified for the corresponding
1566 attribute or that the specified color couldn't be loaded.
1567 Use the foreground color when drawing in that case. */
1568 unsigned overline_color_defaulted_p : 1;
1569 unsigned strike_through_color_defaulted_p : 1;
1570 unsigned box_color_defaulted_p : 1;
1572 /* TTY appearances. Blinking is not yet implemented. Colors are
1573 found in `lface' with empty color string meaning the default
1574 color of the TTY. */
1575 unsigned tty_bold_p : 1;
1576 unsigned tty_dim_p : 1;
1577 unsigned tty_underline_p : 1;
1578 unsigned tty_alt_charset_p : 1;
1579 unsigned tty_reverse_p : 1;
1580 unsigned tty_blinking_p : 1;
1582 /* 1 means that colors of this face may not be freed because they
1583 have been copied bitwise from a base face (see
1584 realize_x_face). */
1585 unsigned colors_copied_bitwise_p : 1;
1587 /* If non-zero, use overstrike (to simulate bold-face). */
1588 unsigned overstrike : 1;
1590 /* NOTE: this is not used yet, but eventually this impl should be done
1591 similarly to overstrike */
1592 #ifdef HAVE_NS
1593 /* If non-zero, use geometric rotation (to simulate italic). */
1594 unsigned synth_ital : 1;
1595 #endif
1597 /* The Lisp face attributes this face realizes. All attributes
1598 in this vector are non-nil. */
1599 Lisp_Object lface[LFACE_VECTOR_SIZE];
1601 /* The hash value of this face. */
1602 unsigned hash;
1604 /* Next and previous face in hash collision list of face cache. */
1605 struct face *next, *prev;
1607 /* If this face is an ASCII face, this points to this face itself.
1608 Otherwise, this points to an ASCII face that has the same
1609 attributes except the font. */
1610 struct face *ascii_face;
1612 /* Extra member that a font-driver uses privately. */
1613 void *extra;
1617 /* Color index indicating that face uses a terminal's default color. */
1619 #define FACE_TTY_DEFAULT_COLOR ((unsigned long) -1)
1621 /* Color index indicating that face uses an unknown foreground color. */
1623 #define FACE_TTY_DEFAULT_FG_COLOR ((unsigned long) -2)
1625 /* Color index indicating that face uses an unknown background color. */
1627 #define FACE_TTY_DEFAULT_BG_COLOR ((unsigned long) -3)
1629 /* Non-zero if FACE was realized for unibyte use. */
1631 #define FACE_UNIBYTE_P(FACE) ((FACE)->charset < 0)
1634 /* IDs of important faces known by the C face code. These are the IDs
1635 of the faces for CHARSET_ASCII. */
1637 enum face_id
1639 DEFAULT_FACE_ID,
1640 MODE_LINE_FACE_ID,
1641 MODE_LINE_INACTIVE_FACE_ID,
1642 TOOL_BAR_FACE_ID,
1643 FRINGE_FACE_ID,
1644 HEADER_LINE_FACE_ID,
1645 SCROLL_BAR_FACE_ID,
1646 BORDER_FACE_ID,
1647 CURSOR_FACE_ID,
1648 MOUSE_FACE_ID,
1649 MENU_FACE_ID,
1650 VERTICAL_BORDER_FACE_ID,
1651 BASIC_FACE_ID_SENTINEL
1654 #define MAX_FACE_ID ((1 << FACE_ID_BITS) - 1)
1656 /* A cache of realized faces. Each frame has its own cache because
1657 Emacs allows different frame-local face definitions. */
1659 struct face_cache
1661 /* Hash table of cached realized faces. */
1662 struct face **buckets;
1664 /* Back-pointer to the frame this cache belongs to. */
1665 struct frame *f;
1667 /* A vector of faces so that faces can be referenced by an ID. */
1668 struct face **faces_by_id;
1670 /* The allocated size, and number of used slots of faces_by_id. */
1671 int size, used;
1673 /* Flag indicating that attributes of the `menu' face have been
1674 changed. */
1675 unsigned menu_face_changed_p : 1;
1679 /* Prepare face FACE for use on frame F. This must be called before
1680 using X resources of FACE. */
1682 #define PREPARE_FACE_FOR_DISPLAY(F, FACE) \
1683 if ((FACE)->gc == 0) \
1684 prepare_face_for_display ((F), (FACE)); \
1685 else \
1686 (void) 0
1688 /* Return a pointer to the face with ID on frame F, or null if such a
1689 face doesn't exist. */
1691 #define FACE_FROM_ID(F, ID) \
1692 (((unsigned) (ID) < FRAME_FACE_CACHE (F)->used) \
1693 ? FRAME_FACE_CACHE (F)->faces_by_id[ID] \
1694 : NULL)
1696 #ifdef HAVE_WINDOW_SYSTEM
1698 /* Non-zero if FACE is suitable for displaying character CHAR. */
1700 #define FACE_SUITABLE_FOR_CHAR_P(FACE, CHAR) \
1701 (ASCII_CHAR_P (CHAR) \
1702 ? (FACE) == (FACE)->ascii_face \
1703 : face_suitable_for_char_p ((FACE), (CHAR)))
1705 /* Return the id of the realized face on frame F that is like the face
1706 with id ID but is suitable for displaying character CHAR.
1707 This macro is only meaningful for multibyte character CHAR. */
1709 #define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) \
1710 (ASCII_CHAR_P (CHAR) \
1711 ? (FACE)->ascii_face->id \
1712 : face_for_char ((F), (FACE), (CHAR), (POS), (OBJECT)))
1714 #else /* not HAVE_WINDOW_SYSTEM */
1716 #define FACE_SUITABLE_FOR_CHAR_P(FACE, CHAR) 1
1717 #define FACE_FOR_CHAR(F, FACE, CHAR, POS, OBJECT) ((FACE)->id)
1719 #endif /* not HAVE_WINDOW_SYSTEM */
1721 /* Non-zero means face attributes have been changed since the last
1722 redisplay. Used in redisplay_internal. */
1724 extern int face_change_count;
1726 /* For BIDI */
1727 #define BIDI_MAXLEVEL 64
1729 /* Data type for describing the bidirectional character types. */
1730 typedef enum {
1731 UNKNOWN_BT,
1732 STRONG_L, /* strong left-to-right */
1733 STRONG_R, /* strong right-to-left */
1734 STRONG_AL, /* arabic right-to-left letter */
1735 LRE, /* left-to-right embedding */
1736 LRO, /* left-to-right override */
1737 RLE, /* right-to-left embedding */
1738 RLO, /* right-to-left override */
1739 PDF, /* pop directional format */
1740 WEAK_EN, /* european number */
1741 WEAK_ES, /* european number separator */
1742 WEAK_ET, /* european number terminator */
1743 WEAK_AN, /* arabic number */
1744 WEAK_CS, /* common separator */
1745 WEAK_NSM, /* non-spacing mark */
1746 WEAK_BN, /* boundary neutral */
1747 NEUTRAL_B, /* paragraph separator */
1748 NEUTRAL_S, /* segment separator */
1749 NEUTRAL_WS, /* whitespace */
1750 NEUTRAL_ON /* other neutrals */
1751 } bidi_type_t;
1753 /* The basic directionality data type. */
1754 typedef enum { NEUTRAL_DIR, L2R, R2L } bidi_dir_t;
1756 /* Data type for storing information about characters we need to
1757 remember. */
1758 struct bidi_saved_info {
1759 int bytepos, charpos; /* character's buffer position */
1760 bidi_type_t type; /* character's resolved bidi type */
1761 bidi_type_t type_after_w1; /* original type of the character, after W1 */
1762 bidi_type_t orig_type; /* type as we found it in the buffer */
1765 /* Data type for keeping track of saved embedding levels and override
1766 status information. */
1767 struct bidi_stack {
1768 int level;
1769 bidi_dir_t override;
1772 /* Data type for iterating over bidi text. */
1773 struct bidi_it {
1774 int first_elt; /* if non-zero, examine current char first */
1775 EMACS_INT bytepos; /* iterator's position in buffer */
1776 EMACS_INT charpos;
1777 int ch; /* character itself */
1778 int ch_len; /* length of its multibyte sequence */
1779 bidi_type_t type; /* bidi type of this character, after
1780 resolving weak and neutral types */
1781 bidi_type_t type_after_w1; /* original type, after overrides and W1 */
1782 bidi_type_t orig_type; /* original type, as found in the buffer */
1783 int resolved_level; /* final resolved level of this character */
1784 int invalid_levels; /* how many PDFs to ignore */
1785 int invalid_rl_levels; /* how many PDFs from RLE/RLO to ignore */
1786 int new_paragraph; /* if non-zero, we expect a new paragraph */
1787 EMACS_INT separator_limit; /* where paragraph separator should end */
1788 bidi_dir_t paragraph_dir; /* current paragraph direction */
1789 int prev_was_pdf; /* if non-zero, previous char was PDF */
1790 struct bidi_saved_info prev; /* info about previous character */
1791 struct bidi_saved_info last_strong; /* last-seen strong directional char */
1792 struct bidi_saved_info next_for_neutral; /* surrounding characters for... */
1793 struct bidi_saved_info prev_for_neutral; /* ...resolving neutrals */
1794 struct bidi_saved_info next_for_ws; /* character after sequence of ws */
1795 EMACS_INT next_en_pos; /* position of next EN char for ET */
1796 EMACS_INT ignore_bn_limit; /* position until which to ignore BNs */
1797 bidi_dir_t sor; /* direction of start-of-run in effect */
1798 int scan_dir; /* direction of text scan */
1799 int stack_idx; /* index of current data on the stack */
1800 struct bidi_stack level_stack[BIDI_MAXLEVEL]; /* stack of embedding levels */
1806 /***********************************************************************
1807 Fringes
1808 ***********************************************************************/
1810 /* Structure used to describe where and how to draw a fringe bitmap.
1811 WHICH is the fringe bitmap to draw. WD and H is the (adjusted)
1812 width and height of the bitmap, DH is the height adjustment (if
1813 bitmap is periodic). X and Y are frame coordinates of the area to
1814 display the bitmap, DY is relative offset of the bitmap into that
1815 area. BX, NX, BY, NY specifies the area to clear if the bitmap
1816 does not fill the entire area. FACE is the fringe face. */
1818 struct draw_fringe_bitmap_params
1820 int which; /* enum fringe_bitmap_type */
1821 unsigned short *bits;
1822 int wd, h, dh;
1823 int x, y;
1824 int bx, nx, by, ny;
1825 unsigned cursor_p : 1;
1826 unsigned overlay_p : 1;
1827 struct face *face;
1830 #define MAX_FRINGE_BITMAPS (1<<FRINGE_ID_BITS)
1833 /***********************************************************************
1834 Display Iterator
1835 ***********************************************************************/
1837 /* Iteration over things to display in current_buffer or in a string.
1839 The iterator handles:
1841 1. Overlay strings (after-string, before-string).
1842 2. Face properties.
1843 3. Invisible text properties.
1844 4. Selective display.
1845 5. Translation of characters via display tables.
1846 6. Translation of control characters to the forms `\003' or `^C'.
1847 7. `glyph' and `space-width' properties.
1849 Iterators are initialized by calling init_iterator or one of the
1850 equivalent functions below. A call to get_next_display_element
1851 loads the iterator structure with information about what next to
1852 display. A call to set_iterator_to_next increments the iterator's
1853 position.
1855 Characters from overlay strings, display table entries or control
1856 character translations are returned one at a time. For example, if
1857 we have a text of `a\x01' where `a' has a display table definition
1858 of `cd' and the control character is displayed with a leading
1859 arrow, then the iterator will return:
1861 Call Return Source Call next
1862 -----------------------------------------------------------------
1863 next c display table move
1864 next d display table move
1865 next ^ control char move
1866 next A control char move
1868 The same mechanism is also used to return characters for ellipses
1869 displayed at the end of invisible text.
1871 CAVEAT: Under some circumstances, move_.* functions can be called
1872 asynchronously, e.g. when computing a buffer position from an x and
1873 y pixel position. This means that these functions and functions
1874 called from them SHOULD NOT USE xmalloc and alike. See also the
1875 comment at the start of xdisp.c. */
1877 /* Enumeration describing what kind of display element an iterator is
1878 loaded with after a call to get_next_display_element. */
1880 enum display_element_type
1882 /* A normal character. */
1883 IT_CHARACTER,
1885 /* A composition (static and automatic). */
1886 IT_COMPOSITION,
1888 /* An image. */
1889 IT_IMAGE,
1891 /* A flexible width and height space. */
1892 IT_STRETCH,
1894 /* End of buffer or string. */
1895 IT_EOB,
1897 /* Truncation glyphs. Never returned by get_next_display_element.
1898 Used to get display information about truncation glyphs via
1899 produce_glyphs. */
1900 IT_TRUNCATION,
1902 /* Continuation glyphs. See the comment for IT_TRUNCATION. */
1903 IT_CONTINUATION
1907 /* An enumerator for each text property that has a meaning for display
1908 purposes. */
1910 enum prop_idx
1912 FONTIFIED_PROP_IDX,
1913 FACE_PROP_IDX,
1914 INVISIBLE_PROP_IDX,
1915 DISPLAY_PROP_IDX,
1916 COMPOSITION_PROP_IDX,
1918 /* Not a property. Used to indicate changes in overlays. */
1919 OVERLAY_PROP_IDX,
1921 /* Sentinel. */
1922 LAST_PROP_IDX
1925 /* An enumerator for the method of wrapping long lines. */
1927 enum line_wrap_method
1929 TRUNCATE,
1930 WORD_WRAP,
1931 WINDOW_WRAP
1934 struct it_slice
1936 Lisp_Object x;
1937 Lisp_Object y;
1938 Lisp_Object width;
1939 Lisp_Object height;
1942 /* Input sources for fetching characters or data to display.
1943 The input source is found in the `method' field. */
1945 enum it_method {
1946 GET_FROM_BUFFER = 0,
1947 GET_FROM_DISPLAY_VECTOR,
1948 GET_FROM_STRING,
1949 GET_FROM_C_STRING,
1950 GET_FROM_IMAGE,
1951 GET_FROM_STRETCH,
1952 NUM_IT_METHODS
1955 #define IT_STACK_SIZE 5
1957 /* Iterator for composition (both for static and automatic). */
1958 struct composition_it
1960 /* Next position at which to check the composition. */
1961 EMACS_INT stop_pos;
1962 /* ID number of the composition or glyph-string. If negative, we
1963 are not iterating over a composition now. */
1964 int id;
1965 /* If non-negative, character that triggers the automatic
1966 composition at `stop_pos', and this is an automatic compositoin.
1967 If negative, this is a static composition. This is set to -2
1968 temporarily if searching of composition reach a limit or a
1969 newline. */
1970 int ch;
1971 /* If this an automatic composition, how many characters to look back
1972 from the position where a character triggering the composition
1973 exists. */
1974 int lookback;
1975 /* If non-negative, number of glyphs of the glyph-string. */
1976 int nglyphs;
1977 /* Number of characters and bytes of the current grapheme cluster. */
1978 int nchars, nbytes;
1979 /* Indices of the glyphs for the current grapheme cluster. */
1980 int from, to;
1981 /* Width of the current grapheme cluster in units of pixels on a
1982 graphic display and in units of canonical characters on a
1983 terminal display. */
1984 int width;
1987 struct it
1989 /* The window in which we iterate over current_buffer (or a string). */
1990 Lisp_Object window;
1991 struct window *w;
1993 /* The window's frame. */
1994 struct frame *f;
1996 /* Method to use to load this structure with the next display element. */
1997 enum it_method method;
1999 /* The next position at which to check for face changes, invisible
2000 text, overlay strings, end of text etc., which see. */
2001 EMACS_INT stop_charpos;
2003 /* Maximum string or buffer position + 1. ZV when iterating over
2004 current_buffer. */
2005 EMACS_INT end_charpos;
2007 /* C string to iterate over. Non-null means get characters from
2008 this string, otherwise characters are read from current_buffer
2009 or it->string. */
2010 unsigned char *s;
2012 /* Number of characters in the string (s, or it->string) we iterate
2013 over. */
2014 int string_nchars;
2016 /* Start and end of a visible region; -1 if the region is not
2017 visible in the window. */
2018 EMACS_INT region_beg_charpos, region_end_charpos;
2020 /* Position at which redisplay end trigger functions should be run. */
2021 EMACS_INT redisplay_end_trigger_charpos;
2023 /* 1 means multibyte characters are enabled. */
2024 unsigned multibyte_p : 1;
2026 /* 1 means window has a mode line at its top. */
2027 unsigned header_line_p : 1;
2029 /* 1 means `string' is the value of a `display' property.
2030 Don't handle some `display' properties in these strings. */
2031 unsigned string_from_display_prop_p : 1;
2033 /* When METHOD == next_element_from_display_vector,
2034 this is 1 if we're doing an ellipsis. Otherwise meaningless. */
2035 unsigned ellipsis_p : 1;
2037 /* True means cursor shouldn't be displayed here. */
2038 unsigned avoid_cursor_p : 1;
2040 /* Display table in effect or null for none. */
2041 struct Lisp_Char_Table *dp;
2043 /* Current display table vector to return characters from and its
2044 end. dpvec null means we are not returning characters from a
2045 display table entry; current.dpvec_index gives the current index
2046 into dpvec. This same mechanism is also used to return
2047 characters from translated control characters, i.e. `\003' or
2048 `^C'. */
2049 Lisp_Object *dpvec, *dpend;
2051 /* Length in bytes of the char that filled dpvec. A value of zero
2052 means that no such character is involved. */
2053 int dpvec_char_len;
2055 /* Face id to use for all characters in display vector. -1 if unused. */
2056 int dpvec_face_id;
2058 /* Face id of the iterator saved in case a glyph from dpvec contains
2059 a face. The face is restored when all glyphs from dpvec have
2060 been delivered. */
2061 int saved_face_id;
2063 /* Vector of glyphs for control character translation. The pointer
2064 dpvec is set to ctl_chars when a control character is translated.
2065 This vector is also used for incomplete multibyte character
2066 translation (e.g \222\244). Such a character is at most 4 bytes,
2067 thus we need at most 16 bytes here. */
2068 Lisp_Object ctl_chars[16];
2070 /* Initial buffer or string position of the iterator, before skipping
2071 over display properties and invisible text. */
2072 struct display_pos start;
2074 /* Current buffer or string position of the iterator, including
2075 position in overlay strings etc. */
2076 struct display_pos current;
2078 /* Total number of overlay strings to process. This can be >
2079 OVERLAY_STRING_CHUNK_SIZE. */
2080 int n_overlay_strings;
2082 /* Vector of overlays to process. Overlay strings are processed
2083 OVERLAY_STRING_CHUNK_SIZE at a time. */
2084 #define OVERLAY_STRING_CHUNK_SIZE 16
2085 Lisp_Object overlay_strings[OVERLAY_STRING_CHUNK_SIZE];
2087 /* For each overlay string, the overlay it came from. */
2088 Lisp_Object string_overlays[OVERLAY_STRING_CHUNK_SIZE];
2090 /* If non-nil, a Lisp string being processed. If
2091 current.overlay_string_index >= 0, this is an overlay string from
2092 pos. */
2093 Lisp_Object string;
2095 /* If non-nil, we are processing a string that came
2096 from a `display' property given by an overlay. */
2097 Lisp_Object from_overlay;
2099 /* Stack of saved values. New entries are pushed when we begin to
2100 process an overlay string or a string from a `glyph' property.
2101 Entries are popped when we return to deliver display elements
2102 from what we previously had. */
2103 struct iterator_stack_entry
2105 Lisp_Object string;
2106 int string_nchars;
2107 EMACS_INT end_charpos;
2108 EMACS_INT stop_charpos;
2109 struct composition_it cmp_it;
2110 int face_id;
2112 /* Save values specific to a given method. */
2113 union {
2114 /* method == GET_FROM_IMAGE */
2115 struct {
2116 Lisp_Object object;
2117 struct it_slice slice;
2118 int image_id;
2119 } image;
2120 /* method == GET_FROM_COMPOSITION */
2121 struct {
2122 Lisp_Object object;
2123 } comp;
2124 /* method == GET_FROM_STRETCH */
2125 struct {
2126 Lisp_Object object;
2127 } stretch;
2128 } u;
2130 /* current text and display positions. */
2131 struct text_pos position;
2132 struct display_pos current;
2133 Lisp_Object from_overlay;
2134 enum glyph_row_area area;
2135 enum it_method method;
2136 unsigned multibyte_p : 1;
2137 unsigned string_from_display_prop_p : 1;
2138 unsigned display_ellipsis_p : 1;
2139 unsigned avoid_cursor_p : 1;
2140 enum line_wrap_method line_wrap;
2142 /* properties from display property that are reset by another display property. */
2143 short voffset;
2144 Lisp_Object space_width;
2145 Lisp_Object font_height;
2147 stack[IT_STACK_SIZE];
2149 /* Stack pointer. */
2150 int sp;
2152 /* -1 means selective display hides everything between a \r and the
2153 next newline; > 0 means hide lines indented more than that value. */
2154 int selective;
2156 /* An enumeration describing what the next display element is
2157 after a call to get_next_display_element. */
2158 enum display_element_type what;
2160 /* Face to use. */
2161 int face_id;
2163 /* Setting of buffer-local variable selective-display-ellipsis. */
2164 unsigned selective_display_ellipsis_p : 1;
2166 /* 1 means control characters are translated into the form `^C'
2167 where the `^' can be replaced by a display table entry. */
2168 unsigned ctl_arrow_p : 1;
2170 /* Non-zero means that the current face has a box. */
2171 unsigned face_box_p : 1;
2173 /* Non-null means that the current character is the first in a run
2174 of characters with box face. */
2175 unsigned start_of_box_run_p : 1;
2177 /* Non-zero means that the current character is the last in a run
2178 of characters with box face. */
2179 unsigned end_of_box_run_p : 1;
2181 /* 1 means overlay strings at end_charpos have been processed. */
2182 unsigned overlay_strings_at_end_processed_p : 1;
2184 /* 1 means to ignore overlay strings at current pos, as they have
2185 already been processed. */
2186 unsigned ignore_overlay_strings_at_pos_p : 1;
2188 /* 1 means the actual glyph is not available in the current
2189 system. */
2190 unsigned glyph_not_available_p : 1;
2192 /* 1 means the next line in display_line continues a character
2193 consisting of more than one glyph, and some glyphs of this
2194 character have been put on the previous line. */
2195 unsigned starts_in_middle_of_char_p : 1;
2197 /* If 1, saved_face_id contains the id of the face in front of text
2198 skipped due to selective display. */
2199 unsigned face_before_selective_p : 1;
2201 /* If 1, adjust current glyph so it does not increase current row
2202 descent/ascent (line-height property). Reset after this glyph. */
2203 unsigned constrain_row_ascent_descent_p : 1;
2205 enum line_wrap_method line_wrap;
2207 /* The ID of the default face to use. One of DEFAULT_FACE_ID,
2208 MODE_LINE_FACE_ID, etc, depending on what we are displaying. */
2209 int base_face_id;
2211 /* If what == IT_CHARACTER, character and length in bytes. This is
2212 a character from a buffer or string. It may be different from
2213 the character displayed in case that
2214 unibyte_display_via_language_environment is set.
2216 If what == IT_COMPOSITION, the first component of a composition
2217 and length in bytes of the composition. */
2218 int c, len;
2220 /* If what == IT_COMPOSITION, iterator substructure for the
2221 composition. */
2222 struct composition_it cmp_it;
2224 /* The character to display, possibly translated to multibyte
2225 if unibyte_display_via_language_environment is set. This
2226 is set after produce_glyphs has been called. */
2227 int char_to_display;
2229 /* If what == IT_IMAGE, the id of the image to display. */
2230 int image_id;
2232 /* Values from `slice' property. */
2233 struct it_slice slice;
2235 /* Value of the `space-width' property, if any; nil if none. */
2236 Lisp_Object space_width;
2238 /* Computed from the value of the `raise' property. */
2239 short voffset;
2241 /* Number of columns per \t. */
2242 short tab_width;
2244 /* Value of the `height' property, if any; nil if none. */
2245 Lisp_Object font_height;
2247 /* Object and position where the current display element came from.
2248 Object can be a Lisp string in case the current display element
2249 comes from an overlay string, or it is buffer. It may also be nil
2250 during mode-line update. Position is a position in object. */
2251 Lisp_Object object;
2252 struct text_pos position;
2254 /* Width in pixels of truncation and continuation glyphs. */
2255 short truncation_pixel_width, continuation_pixel_width;
2257 /* First and last visible x-position in the display area. If window
2258 is hscrolled by n columns, first_visible_x == n * FRAME_COLUMN_WIDTH
2259 (f), and last_visible_x == pixel width of W + first_visible_x. */
2260 int first_visible_x, last_visible_x;
2262 /* Last visible y-position + 1 in the display area without a mode
2263 line, if the window has one. */
2264 int last_visible_y;
2266 /* Default amount of additional space in pixels between lines (for
2267 window systems only.) */
2268 int extra_line_spacing;
2270 /* Max extra line spacing added in this row. */
2271 int max_extra_line_spacing;
2273 /* Override font height information for this glyph.
2274 Used if override_ascent >= 0. Cleared after this glyph. */
2275 int override_ascent, override_descent, override_boff;
2277 /* If non-null, glyphs are produced in glyph_row with each call to
2278 produce_glyphs. */
2279 struct glyph_row *glyph_row;
2281 /* The area of glyph_row to which glyphs are added. */
2282 enum glyph_row_area area;
2284 /* Number of glyphs needed for the last character requested via
2285 produce_glyphs. This is 1 except for tabs. */
2286 int nglyphs;
2288 /* Width of the display element in pixels. Result of
2289 produce_glyphs. */
2290 int pixel_width;
2292 /* Current, maximum logical, and maximum physical line height
2293 information. Result of produce_glyphs. */
2294 int ascent, descent, max_ascent, max_descent;
2295 int phys_ascent, phys_descent, max_phys_ascent, max_phys_descent;
2297 /* Current x pixel position within the display line. This value
2298 does not include the width of continuation lines in front of the
2299 line. The value of current_x is automatically incremented by
2300 pixel_width with each call to produce_glyphs. */
2301 int current_x;
2303 /* Accumulated width of continuation lines. If > 0, this means we
2304 are currently in a continuation line. This is initially zero and
2305 incremented/reset by display_line, move_it_to etc. */
2306 int continuation_lines_width;
2308 /* Current y-position. Automatically incremented by the height of
2309 glyph_row in move_it_to and display_line. */
2310 int current_y;
2312 /* Vertical matrix position of first text line in window. */
2313 int first_vpos;
2315 /* Current vertical matrix position, or line number. Automatically
2316 incremented by move_it_to and display_line. */
2317 int vpos;
2319 /* Horizontal matrix position reached in move_it_in_display_line.
2320 Only set there, not in display_line. */
2321 int hpos;
2323 /* Left fringe bitmap number (enum fringe_bitmap_type). */
2324 unsigned left_user_fringe_bitmap : FRINGE_ID_BITS;
2326 /* Right fringe bitmap number (enum fringe_bitmap_type). */
2327 unsigned right_user_fringe_bitmap : FRINGE_ID_BITS;
2329 /* Face of the left fringe glyph. */
2330 unsigned left_user_fringe_face_id : FACE_ID_BITS;
2332 /* Face of the right fringe glyph. */
2333 unsigned right_user_fringe_face_id : FACE_ID_BITS;
2335 /* Non-zero means we need to reorder bidirectional text for display
2336 in the visual order. */
2337 int bidi_p;
2339 /* For iterating over bidirectional text. */
2340 struct bidi_it bidi_it;
2341 bidi_dir_t paragraph_embedding;
2345 /* Access to positions of iterator IT. */
2347 #define IT_CHARPOS(IT) CHARPOS ((IT).current.pos)
2348 #define IT_BYTEPOS(IT) BYTEPOS ((IT).current.pos)
2349 #define IT_STRING_CHARPOS(IT) CHARPOS ((IT).current.string_pos)
2350 #define IT_STRING_BYTEPOS(IT) BYTEPOS ((IT).current.string_pos)
2352 /* Test if IT has reached the end of its buffer or string. This will
2353 only work after get_next_display_element has been called. */
2355 #define ITERATOR_AT_END_P(IT) ((IT)->what == IT_EOB)
2357 /* Non-zero means IT is at the end of a line. This is the case if it
2358 is either on a newline or on a carriage return and selective
2359 display hides the rest of the line. */
2361 #define ITERATOR_AT_END_OF_LINE_P(IT) \
2362 ((IT)->what == IT_CHARACTER \
2363 && ((IT)->c == '\n' \
2364 || ((IT)->c == '\r' && (IT)->selective)))
2366 /* Call produce_glyphs or produce_glyphs_hook, if set. Shortcut to
2367 avoid the function call overhead. */
2369 #define PRODUCE_GLYPHS(IT) \
2370 do { \
2371 extern int inhibit_free_realized_faces; \
2372 if (FRAME_RIF ((IT)->f) != NULL) \
2373 FRAME_RIF ((IT)->f)->produce_glyphs ((IT)); \
2374 else \
2375 produce_glyphs ((IT)); \
2376 if ((IT)->glyph_row != NULL) \
2377 inhibit_free_realized_faces = 1; \
2378 } while (0)
2380 /* Bit-flags indicating what operation move_it_to should perform. */
2382 enum move_operation_enum
2384 /* Stop if specified x-position is reached. */
2385 MOVE_TO_X = 0x01,
2387 /* Stop if specified y-position is reached. */
2388 MOVE_TO_Y = 0x02,
2390 /* Stop if specified vpos is reached. */
2391 MOVE_TO_VPOS = 0x04,
2393 /* Stop if specified buffer or string position is reached. */
2394 MOVE_TO_POS = 0x08
2399 /***********************************************************************
2400 Window-based redisplay interface
2401 ***********************************************************************/
2403 /* Structure used to describe runs of lines that must be scrolled. */
2405 struct run
2407 /* Source and destination y pixel position. */
2408 int desired_y, current_y;
2410 /* Source and destination vpos in matrix. */
2411 int desired_vpos, current_vpos;
2413 /* Height in pixels, number of glyph rows. */
2414 int height, nrows;
2418 /* Handlers for setting frame parameters. */
2420 typedef void (*frame_parm_handler) P_ ((struct frame *, Lisp_Object, Lisp_Object));
2423 /* Structure holding system-dependent interface functions needed
2424 for window-based redisplay. */
2426 struct redisplay_interface
2428 /* Handlers for setting frame parameters. */
2429 frame_parm_handler *frame_parm_handlers;
2431 /* Produce glyphs/get display metrics for the display element IT is
2432 loaded with. */
2433 void (*produce_glyphs) P_ ((struct it *it));
2435 /* Write or insert LEN glyphs from STRING at the nominal output
2436 position. */
2437 void (*write_glyphs) P_ ((struct glyph *string, int len));
2438 void (*insert_glyphs) P_ ((struct glyph *start, int len));
2440 /* Clear from nominal output position to X. X < 0 means clear
2441 to right end of display. */
2442 void (*clear_end_of_line) P_ ((int x));
2444 /* Function to call to scroll the display as described by RUN on
2445 window W. */
2446 void (*scroll_run_hook) P_ ((struct window *w, struct run *run));
2448 /* Function to call after a line in a display has been completely
2449 updated. Used to draw truncation marks and alike. DESIRED_ROW
2450 is the desired row which has been updated. */
2451 void (*after_update_window_line_hook) P_ ((struct glyph_row *desired_row));
2453 /* Function to call before beginning to update window W in
2454 window-based redisplay. */
2455 void (*update_window_begin_hook) P_ ((struct window *w));
2457 /* Function to call after window W has been updated in window-based
2458 redisplay. CURSOR_ON_P non-zero means switch cursor on.
2459 MOUSE_FACE_OVERWRITTEN_P non-zero means that some lines in W
2460 that contained glyphs in mouse-face were overwritten, so we
2461 have to update the mouse highlight. */
2462 void (*update_window_end_hook) P_ ((struct window *w, int cursor_on_p,
2463 int mouse_face_overwritten_p));
2465 /* Move cursor to row/column position VPOS/HPOS, pixel coordinates
2466 Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y
2467 are window-relative pixel positions. */
2468 void (*cursor_to) P_ ((int vpos, int hpos, int y, int x));
2470 /* Flush the display of frame F. For X, this is XFlush. */
2471 void (*flush_display) P_ ((struct frame *f));
2473 /* Flush the display of frame F if non-NULL. This is called
2474 during redisplay, and should be NULL on systems which flushes
2475 automatically before reading input. */
2476 void (*flush_display_optional) P_ ((struct frame *f));
2478 /* Clear the mouse hightlight in window W, if there is any. */
2479 void (*clear_window_mouse_face) P_ ((struct window *w));
2481 /* Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
2482 frame F. */
2483 void (*get_glyph_overhangs) P_ ((struct glyph *glyph, struct frame *f,
2484 int *left, int *right));
2486 /* Fix the display of AREA of ROW in window W for overlapping rows.
2487 This function is called from redraw_overlapping_rows after
2488 desired rows have been made current. */
2489 void (*fix_overlapping_area) P_ ((struct window *w, struct glyph_row *row,
2490 enum glyph_row_area area, int));
2492 #ifdef HAVE_WINDOW_SYSTEM
2494 /* Draw a fringe bitmap in window W of row ROW using parameters P. */
2495 void (*draw_fringe_bitmap) P_ ((struct window *w, struct glyph_row *row,
2496 struct draw_fringe_bitmap_params *p));
2498 /* Define and destroy fringe bitmap no. WHICH. */
2499 void (*define_fringe_bitmap) P_ ((int which, unsigned short *bits,
2500 int h, int wd));
2501 void (*destroy_fringe_bitmap) P_ ((int which));
2503 /* Compute left and right overhang of glyph string S.
2504 A NULL pointer if platform does not support this. */
2505 void (*compute_glyph_string_overhangs) P_ ((struct glyph_string *s));
2507 /* Draw a glyph string S. */
2508 void (*draw_glyph_string) P_ ((struct glyph_string *s));
2510 /* Define cursor CURSOR on frame F. */
2511 void (*define_frame_cursor) P_ ((struct frame *f, Cursor cursor));
2513 /* Clear the area at (X,Y,WIDTH,HEIGHT) of frame F. */
2514 void (*clear_frame_area) P_ ((struct frame *f, int x, int y,
2515 int width, int height));
2517 /* Draw specified cursor CURSOR_TYPE of width CURSOR_WIDTH
2518 at row GLYPH_ROW on window W if ON_P is 1. If ON_P is
2519 0, don't draw cursor. If ACTIVE_P is 1, system caret
2520 should track this cursor (when applicable). */
2521 void (*draw_window_cursor) P_ ((struct window *w,
2522 struct glyph_row *glyph_row,
2523 int x, int y,
2524 int cursor_type, int cursor_width,
2525 int on_p, int active_p));
2527 /* Draw vertical border for window W from (X,Y0) to (X,Y1). */
2528 void (*draw_vertical_window_border) P_ ((struct window *w,
2529 int x, int y0, int y1));
2531 /* Shift display of frame F to make room for inserted glyphs.
2532 The area at pixel (X,Y) of width WIDTH and height HEIGHT is
2533 shifted right by SHIFT_BY pixels. */
2534 void (*shift_glyphs_for_insert) P_ ((struct frame *f,
2535 int x, int y, int width,
2536 int height, int shift_by));
2538 #endif /* HAVE_WINDOW_SYSTEM */
2542 /***********************************************************************
2543 Images
2544 ***********************************************************************/
2546 #ifdef HAVE_WINDOW_SYSTEM
2548 /* Structure forward declarations. */
2550 struct image;
2553 /* Each image format (JPEG, TIFF, ...) supported is described by
2554 a structure of the type below. */
2556 struct image_type
2558 /* A symbol uniquely identifying the image type, .e.g `jpeg'. */
2559 Lisp_Object *type;
2561 /* Check that SPEC is a valid image specification for the given
2562 image type. Value is non-zero if SPEC is valid. */
2563 int (* valid_p) P_ ((Lisp_Object spec));
2565 /* Load IMG which is used on frame F from information contained in
2566 IMG->spec. Value is non-zero if successful. */
2567 int (* load) P_ ((struct frame *f, struct image *img));
2569 /* Free resources of image IMG which is used on frame F. */
2570 void (* free) P_ ((struct frame *f, struct image *img));
2572 /* Next in list of all supported image types. */
2573 struct image_type *next;
2577 /* Structure describing an image. Specific image formats like XBM are
2578 converted into this form, so that display only has to deal with
2579 this type of image. */
2581 struct image
2583 /* The time in seconds at which the image was last displayed. Set
2584 in prepare_image_for_display. */
2585 unsigned long timestamp;
2587 /* Pixmaps of the image. */
2588 Pixmap pixmap, mask;
2590 /* Colors allocated for this image, if any. Allocated via xmalloc. */
2591 unsigned long *colors;
2592 int ncolors;
2594 /* A single `background color' for this image, for the use of anyone that
2595 cares about such a thing. Only valid if the `background_valid' field
2596 is true. This should generally be accessed by calling the accessor
2597 macro `IMAGE_BACKGROUND', which will heuristically calculate a value
2598 if necessary. */
2599 unsigned long background;
2601 /* Foreground and background colors of the frame on which the image
2602 is created. */
2603 unsigned long frame_foreground, frame_background;
2605 /* True if this image has a `transparent' background -- that is, is
2606 uses an image mask. The accessor macro for this is
2607 `IMAGE_BACKGROUND_TRANSPARENT'. */
2608 unsigned background_transparent : 1;
2610 /* True if the `background' and `background_transparent' fields are
2611 valid, respectively. */
2612 unsigned background_valid : 1, background_transparent_valid : 1;
2614 /* Width and height of the image. */
2615 int width, height;
2617 /* These values are used for the rectangles displayed for images
2618 that can't be loaded. */
2619 #define DEFAULT_IMAGE_WIDTH 30
2620 #define DEFAULT_IMAGE_HEIGHT 30
2622 /* Top/left and bottom/right corner pixel of actual image data.
2623 Used by four_corners_best to consider the real image data,
2624 rather than looking at the optional image margin. */
2625 int corners[4];
2626 #define TOP_CORNER 0
2627 #define LEFT_CORNER 1
2628 #define BOT_CORNER 2
2629 #define RIGHT_CORNER 3
2631 /* Percent of image height used as ascent. A value of
2632 CENTERED_IMAGE_ASCENT means draw the image centered on the
2633 line. */
2634 int ascent;
2635 #define DEFAULT_IMAGE_ASCENT 50
2636 #define CENTERED_IMAGE_ASCENT -1
2638 /* Lisp specification of this image. */
2639 Lisp_Object spec;
2641 /* List of "references" followed to build the image.
2642 Typically will just contain the name of the image file.
2643 Used to allow fine-grained cache flushing. */
2644 Lisp_Object dependencies;
2646 /* Relief to draw around the image. */
2647 int relief;
2649 /* Optional margins around the image. This includes the relief. */
2650 int hmargin, vmargin;
2652 /* Reference to the type of the image. */
2653 struct image_type *type;
2655 /* 1 means that loading the image failed. Don't try again. */
2656 unsigned load_failed_p;
2658 /* A place for image types to store additional data. The member
2659 data.lisp_val is marked during GC, so it's safe to store Lisp data
2660 there. Image types should free this data when their `free'
2661 function is called. */
2662 struct
2664 int int_val;
2665 void *ptr_val;
2666 Lisp_Object lisp_val;
2667 } data;
2669 /* Hash value of image specification to speed up comparisons. */
2670 unsigned hash;
2672 /* Image id of this image. */
2673 int id;
2675 /* Hash collision chain. */
2676 struct image *next, *prev;
2680 /* Cache of images. Each frame has a cache. X frames with the same
2681 x_display_info share their caches. */
2683 struct image_cache
2685 /* Hash table of images. */
2686 struct image **buckets;
2688 /* Vector mapping image ids to images. */
2689 struct image **images;
2691 /* Allocated size of `images'. */
2692 unsigned size;
2694 /* Number of images in the cache. */
2695 unsigned used;
2697 /* Reference count (number of frames sharing this cache). */
2698 int refcount;
2702 /* Value is a pointer to the image with id ID on frame F, or null if
2703 no image with that id exists. */
2705 #define IMAGE_FROM_ID(F, ID) \
2706 (((ID) >= 0 && (ID) < (FRAME_IMAGE_CACHE (F)->used)) \
2707 ? FRAME_IMAGE_CACHE (F)->images[ID] \
2708 : NULL)
2710 /* Size of bucket vector of image caches. Should be prime. */
2712 #define IMAGE_CACHE_BUCKETS_SIZE 1001
2714 #endif /* HAVE_WINDOW_SYSTEM */
2718 /***********************************************************************
2719 Tool-bars
2720 ***********************************************************************/
2722 /* Enumeration defining where to find tool-bar item information in
2723 tool-bar items vectors stored with frames. Each tool-bar item
2724 occupies TOOL_BAR_ITEM_NSLOTS elements in such a vector. */
2726 enum tool_bar_item_idx
2728 /* The key of the tool-bar item. Used to remove items when a binding
2729 for `undefined' is found. */
2730 TOOL_BAR_ITEM_KEY,
2732 /* Non-nil if item is enabled. */
2733 TOOL_BAR_ITEM_ENABLED_P,
2735 /* Non-nil if item is selected (pressed). */
2736 TOOL_BAR_ITEM_SELECTED_P,
2738 /* Caption. */
2739 TOOL_BAR_ITEM_CAPTION,
2741 /* Image(s) to display. This is either a single image specification
2742 or a vector of specifications. */
2743 TOOL_BAR_ITEM_IMAGES,
2745 /* The binding. */
2746 TOOL_BAR_ITEM_BINDING,
2748 /* Button type. One of nil, `:radio' or `:toggle'. */
2749 TOOL_BAR_ITEM_TYPE,
2751 /* Help string. */
2752 TOOL_BAR_ITEM_HELP,
2754 /* Icon file name of right to left image when an RTL locale is used. */
2755 TOOL_BAR_ITEM_RTL_IMAGE,
2757 /* Sentinel = number of slots in tool_bar_items occupied by one
2758 tool-bar item. */
2759 TOOL_BAR_ITEM_NSLOTS
2763 /* An enumeration for the different images that can be specified
2764 for a tool-bar item. */
2766 enum tool_bar_item_image
2768 TOOL_BAR_IMAGE_ENABLED_SELECTED,
2769 TOOL_BAR_IMAGE_ENABLED_DESELECTED,
2770 TOOL_BAR_IMAGE_DISABLED_SELECTED,
2771 TOOL_BAR_IMAGE_DISABLED_DESELECTED
2774 /* Margin around tool-bar buttons in pixels. */
2776 extern Lisp_Object Vtool_bar_button_margin;
2778 /* Thickness of relief to draw around tool-bar buttons. */
2780 extern EMACS_INT tool_bar_button_relief;
2782 /* Default values of the above variables. */
2784 #define DEFAULT_TOOL_BAR_BUTTON_MARGIN 4
2785 #define DEFAULT_TOOL_BAR_BUTTON_RELIEF 1
2787 /* The height in pixels of the default tool-bar images. */
2789 #define DEFAULT_TOOL_BAR_IMAGE_HEIGHT 24
2792 /***********************************************************************
2793 Terminal Capabilities
2794 ***********************************************************************/
2796 /* Each of these is a bit representing a terminal `capability' (bold,
2797 inverse, etc). They are or'd together to specify the set of
2798 capabilities being queried for when calling `tty_capable_p' (which
2799 returns true if the terminal supports all of them). */
2801 #define TTY_CAP_INVERSE 0x01
2802 #define TTY_CAP_UNDERLINE 0x02
2803 #define TTY_CAP_BOLD 0x04
2804 #define TTY_CAP_DIM 0x08
2805 #define TTY_CAP_BLINK 0x10
2806 #define TTY_CAP_ALT_CHARSET 0x20
2809 /***********************************************************************
2810 Function Prototypes
2811 ***********************************************************************/
2813 /* Defined in bidi.c */
2815 extern void bidi_init_it P_ ((EMACS_INT, EMACS_INT, struct bidi_it *));
2816 extern void bidi_get_next_char_visually P_ ((struct bidi_it *));
2817 extern void bidi_paragraph_init P_ ((bidi_dir_t, struct bidi_it *));
2818 extern int bidi_mirror_char P_ ((int));
2820 /* Defined in xdisp.c */
2822 struct glyph_row *row_containing_pos P_ ((struct window *, int,
2823 struct glyph_row *,
2824 struct glyph_row *, int));
2825 EMACS_INT string_buffer_position P_ ((struct window *, Lisp_Object,
2826 EMACS_INT));
2827 int line_bottom_y P_ ((struct it *));
2828 int display_prop_intangible_p P_ ((Lisp_Object));
2829 void resize_echo_area_exactly P_ ((void));
2830 int resize_mini_window P_ ((struct window *, int));
2831 int try_window P_ ((Lisp_Object, struct text_pos, int));
2832 void window_box P_ ((struct window *, int, int *, int *, int *, int *));
2833 int window_box_height P_ ((struct window *));
2834 int window_text_bottom_y P_ ((struct window *));
2835 int window_box_width P_ ((struct window *, int));
2836 int window_box_left P_ ((struct window *, int));
2837 int window_box_left_offset P_ ((struct window *, int));
2838 int window_box_right P_ ((struct window *, int));
2839 int window_box_right_offset P_ ((struct window *, int));
2840 void window_box_edges P_ ((struct window *, int, int *, int *, int *, int *));
2841 int estimate_mode_line_height P_ ((struct frame *, enum face_id));
2842 void pixel_to_glyph_coords P_ ((struct frame *, int, int, int *, int *,
2843 NativeRectangle *, int));
2844 int glyph_to_pixel_coords P_ ((struct window *, int, int, int *, int *));
2845 void remember_mouse_glyph P_ ((struct frame *, int, int, NativeRectangle *));
2847 void mark_window_display_accurate P_ ((Lisp_Object, int));
2848 void redisplay_preserve_echo_area P_ ((int));
2849 int set_cursor_from_row P_ ((struct window *, struct glyph_row *,
2850 struct glyph_matrix *, int, int, int, int));
2851 void init_iterator P_ ((struct it *, struct window *, int,
2852 int, struct glyph_row *, enum face_id));
2853 void init_iterator_to_row_start P_ ((struct it *, struct window *,
2854 struct glyph_row *));
2855 int get_next_display_element P_ ((struct it *));
2856 void set_iterator_to_next P_ ((struct it *, int));
2857 void start_display P_ ((struct it *, struct window *, struct text_pos));
2858 void move_it_to P_ ((struct it *, int, int, int, int, int));
2859 void move_it_vertically P_ ((struct it *, int));
2860 void move_it_vertically_backward P_ ((struct it *, int));
2861 void move_it_by_lines P_ ((struct it *, int, int));
2862 void move_it_past_eol P_ ((struct it *));
2863 void move_it_in_display_line (struct it *it,
2864 EMACS_INT to_charpos, int to_x,
2865 enum move_operation_enum op);
2866 int in_display_vector_p P_ ((struct it *));
2867 int frame_mode_line_height P_ ((struct frame *));
2868 void highlight_trailing_whitespace P_ ((struct frame *, struct glyph_row *));
2869 extern Lisp_Object Qtool_bar;
2870 extern Lisp_Object Vshow_trailing_whitespace;
2871 extern int mode_line_in_non_selected_windows;
2872 extern int redisplaying_p;
2873 extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object));
2874 extern int help_echo_showing_p;
2875 extern int current_mode_line_height, current_header_line_height;
2876 extern Lisp_Object help_echo_string, help_echo_window;
2877 extern Lisp_Object help_echo_object, previous_help_echo_string;
2878 extern int help_echo_pos;
2879 extern struct frame *last_mouse_frame;
2880 extern int last_tool_bar_item;
2881 extern Lisp_Object Vmouse_autoselect_window;
2882 extern int unibyte_display_via_language_environment;
2883 extern EMACS_INT underline_minimum_offset;
2885 extern void reseat_at_previous_visible_line_start P_ ((struct it *));
2887 extern int calc_pixel_width_or_height P_ ((double *, struct it *, Lisp_Object,
2888 struct font *, int, int *));
2890 #ifdef HAVE_WINDOW_SYSTEM
2892 #if GLYPH_DEBUG
2893 extern void dump_glyph_string P_ ((struct glyph_string *));
2894 #endif
2896 extern void x_get_glyph_overhangs P_ ((struct glyph *, struct frame *,
2897 int *, int *));
2898 extern void x_produce_glyphs P_ ((struct it *));
2900 extern void x_write_glyphs P_ ((struct glyph *, int));
2901 extern void x_insert_glyphs P_ ((struct glyph *, int len));
2902 extern void x_clear_end_of_line P_ ((int));
2904 extern int x_stretch_cursor_p;
2905 extern struct cursor_pos output_cursor;
2907 extern void x_fix_overlapping_area P_ ((struct window *, struct glyph_row *,
2908 enum glyph_row_area, int));
2909 extern void draw_phys_cursor_glyph P_ ((struct window *,
2910 struct glyph_row *,
2911 enum draw_glyphs_face));
2912 extern void get_phys_cursor_geometry P_ ((struct window *, struct glyph_row *,
2913 struct glyph *, int *, int *, int *));
2914 extern void erase_phys_cursor P_ ((struct window *));
2915 extern void display_and_set_cursor P_ ((struct window *,
2916 int, int, int, int, int));
2918 extern void set_output_cursor P_ ((struct cursor_pos *));
2919 extern void x_cursor_to P_ ((int, int, int, int));
2921 extern void x_update_cursor P_ ((struct frame *, int));
2922 extern void x_clear_cursor P_ ((struct window *));
2923 extern void x_draw_vertical_border P_ ((struct window *w));
2925 extern void frame_to_window_pixel_xy P_ ((struct window *, int *, int *));
2926 extern int get_glyph_string_clip_rects P_ ((struct glyph_string *,
2927 NativeRectangle *, int));
2928 extern void get_glyph_string_clip_rect P_ ((struct glyph_string *,
2929 NativeRectangle *nr));
2930 extern Lisp_Object find_hot_spot P_ ((Lisp_Object, int, int));
2931 extern void note_mouse_highlight P_ ((struct frame *, int, int));
2932 extern void x_clear_window_mouse_face P_ ((struct window *));
2933 extern void cancel_mouse_face P_ ((struct frame *));
2935 extern void handle_tool_bar_click P_ ((struct frame *,
2936 int, int, int, unsigned int));
2938 /* msdos.c defines its own versions of these functions. */
2939 extern int clear_mouse_face P_ ((Display_Info *));
2940 extern void show_mouse_face P_ ((Display_Info *, enum draw_glyphs_face));
2941 extern int cursor_in_mouse_face_p P_ ((struct window *w));
2943 extern void expose_frame P_ ((struct frame *, int, int, int, int));
2944 extern int x_intersect_rectangles P_ ((XRectangle *, XRectangle *,
2945 XRectangle *));
2946 #endif
2948 /* Defined in fringe.c */
2950 int lookup_fringe_bitmap (Lisp_Object);
2951 void draw_fringe_bitmap P_ ((struct window *, struct glyph_row *, int));
2952 void draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *));
2953 int draw_window_fringes P_ ((struct window *, int));
2954 int update_window_fringes P_ ((struct window *, int));
2955 void compute_fringe_widths P_ ((struct frame *, int));
2957 #ifdef WINDOWSNT
2958 void w32_init_fringe P_ ((struct redisplay_interface *));
2959 void w32_reset_fringes P_ ((void));
2960 #endif
2961 /* Defined in image.c */
2963 #ifdef HAVE_WINDOW_SYSTEM
2965 extern int x_bitmap_height P_ ((struct frame *, int));
2966 extern int x_bitmap_width P_ ((struct frame *, int));
2967 extern int x_bitmap_pixmap P_ ((struct frame *, int));
2968 extern void x_reference_bitmap P_ ((struct frame *, int));
2969 extern int x_create_bitmap_from_data P_ ((struct frame *, char *,
2970 unsigned int, unsigned int));
2971 extern int x_create_bitmap_from_file P_ ((struct frame *, Lisp_Object));
2972 #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
2973 extern int x_create_bitmap_from_xpm_data P_ ((struct frame *f, char **bits));
2974 #endif
2975 #ifndef x_destroy_bitmap
2976 extern void x_destroy_bitmap P_ ((struct frame *, int));
2977 #endif
2978 extern void x_destroy_all_bitmaps P_ ((Display_Info *));
2979 extern int x_create_bitmap_mask P_ ((struct frame * , int));
2980 extern Lisp_Object x_find_image_file P_ ((Lisp_Object));
2982 void x_kill_gs_process P_ ((Pixmap, struct frame *));
2983 struct image_cache *make_image_cache P_ ((void));
2984 void free_image_cache P_ ((struct frame *));
2985 void clear_image_caches P_ ((Lisp_Object));
2986 void mark_image_cache P_ ((struct image_cache *));
2987 int valid_image_p P_ ((Lisp_Object));
2988 void prepare_image_for_display P_ ((struct frame *, struct image *));
2989 int lookup_image P_ ((struct frame *, Lisp_Object));
2991 unsigned long image_background P_ ((struct image *, struct frame *,
2992 XImagePtr_or_DC ximg));
2993 int image_background_transparent P_ ((struct image *, struct frame *,
2994 XImagePtr_or_DC mask));
2996 int image_ascent P_ ((struct image *, struct face *, struct glyph_slice *));
2998 #endif
3000 /* Defined in sysdep.c */
3002 void get_tty_size P_ ((int, int *, int *));
3003 void request_sigio P_ ((void));
3004 void unrequest_sigio P_ ((void));
3005 int tabs_safe_p P_ ((int));
3006 void init_baud_rate P_ ((int));
3007 void init_sigio P_ ((int));
3009 /* Defined in xfaces.c */
3011 #ifdef HAVE_X_WINDOWS
3012 void x_free_colors P_ ((struct frame *, unsigned long *, int));
3013 #endif
3015 void update_face_from_frame_parameter P_ ((struct frame *, Lisp_Object,
3016 Lisp_Object));
3017 Lisp_Object tty_color_name P_ ((struct frame *, int));
3018 void clear_face_cache P_ ((int));
3019 unsigned long load_color P_ ((struct frame *, struct face *, Lisp_Object,
3020 enum lface_attribute_index));
3021 void unload_color P_ ((struct frame *, unsigned long));
3022 char *choose_face_font P_ ((struct frame *, Lisp_Object *, Lisp_Object,
3023 int *));
3024 int ascii_face_of_lisp_face P_ ((struct frame *, int));
3025 void prepare_face_for_display P_ ((struct frame *, struct face *));
3026 int xstrcasecmp P_ ((const unsigned char *, const unsigned char *));
3027 int lookup_face P_ ((struct frame *, Lisp_Object *));
3028 int lookup_named_face P_ ((struct frame *, Lisp_Object, int));
3029 int lookup_basic_face P_ ((struct frame *, int));
3030 int smaller_face P_ ((struct frame *, int, int));
3031 int face_with_height P_ ((struct frame *, int, int));
3032 int lookup_derived_face P_ ((struct frame *, Lisp_Object, int, int));
3033 void init_frame_faces P_ ((struct frame *));
3034 void free_frame_faces P_ ((struct frame *));
3035 void recompute_basic_faces P_ ((struct frame *));
3036 int face_at_buffer_position P_ ((struct window *w, EMACS_INT pos,
3037 EMACS_INT region_beg, EMACS_INT region_end,
3038 EMACS_INT *endptr, EMACS_INT limit,
3039 int mouse, int base_face_id));
3040 int face_for_overlay_string P_ ((struct window *w, EMACS_INT pos,
3041 EMACS_INT region_beg, EMACS_INT region_end,
3042 EMACS_INT *endptr, EMACS_INT limit,
3043 int mouse, Lisp_Object overlay));
3044 int face_at_string_position P_ ((struct window *w, Lisp_Object string,
3045 EMACS_INT pos, EMACS_INT bufpos,
3046 EMACS_INT region_beg, EMACS_INT region_end,
3047 EMACS_INT *endptr, enum face_id, int mouse));
3048 int merge_faces P_ ((struct frame *, Lisp_Object, int, int));
3049 int compute_char_face P_ ((struct frame *, int, Lisp_Object));
3050 void free_all_realized_faces P_ ((Lisp_Object));
3051 void free_realized_face P_ ((struct frame *, struct face *));
3052 extern Lisp_Object Qforeground_color, Qbackground_color;
3053 extern Lisp_Object Qframe_set_background_mode;
3054 extern char unspecified_fg[], unspecified_bg[];
3056 extern Lisp_Object Vface_remapping_alist;
3058 /* Defined in xfns.c */
3060 #ifdef HAVE_X_WINDOWS
3061 void gamma_correct P_ ((struct frame *, XColor *));
3062 #endif
3063 #ifdef WINDOWSNT
3064 void gamma_correct P_ ((struct frame *, COLORREF *));
3065 #endif
3067 #ifdef HAVE_WINDOW_SYSTEM
3069 int x_screen_planes P_ ((struct frame *));
3070 void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
3072 extern Lisp_Object tip_frame;
3073 extern Window tip_window;
3074 EXFUN (Fx_show_tip, 6);
3075 EXFUN (Fx_hide_tip, 0);
3076 extern void start_hourglass P_ ((void));
3077 extern void cancel_hourglass P_ ((void));
3078 extern int hourglass_started P_ ((void));
3079 extern int display_hourglass_p;
3080 extern int hourglass_shown_p;
3081 struct atimer; /* Defined in atimer.h. */
3082 /* If non-null, an asynchronous timer that, when it expires, displays
3083 an hourglass cursor on all frames. */
3084 extern struct atimer *hourglass_atimer;
3086 /* Each GUI implements these. FIXME: move into RIF. */
3087 extern void show_hourglass P_ ((struct atimer *));
3088 extern void hide_hourglass P_ ((void));
3090 /* Returns the background color of IMG, calculating one heuristically if
3091 necessary. If non-zero, XIMG is an existing XImage object to use for
3092 the heuristic. */
3094 #define IMAGE_BACKGROUND(img, f, ximg) \
3095 ((img)->background_valid \
3096 ? (img)->background \
3097 : image_background (img, f, ximg))
3099 /* Returns true if IMG has a `transparent' background, using heuristics
3100 to decide if necessary. If non-zero, MASK is an existing XImage
3101 object to use for the heuristic. */
3103 #define IMAGE_BACKGROUND_TRANSPARENT(img, f, mask) \
3104 ((img)->background_transparent_valid \
3105 ? (img)->background_transparent \
3106 : image_background_transparent (img, f, mask))
3108 #endif /* HAVE_WINDOW_SYSTEM */
3111 /* Defined in xmenu.c */
3113 int popup_activated P_ ((void));
3115 /* Defined in dispnew.c */
3117 extern int inverse_video;
3118 extern int required_matrix_width P_ ((struct window *));
3119 extern int required_matrix_height P_ ((struct window *));
3120 extern Lisp_Object buffer_posn_from_coords P_ ((struct window *,
3121 int *, int *,
3122 struct display_pos *,
3123 Lisp_Object *,
3124 int *, int *, int *, int *));
3125 extern Lisp_Object mode_line_string P_ ((struct window *, enum window_part,
3126 int *, int *, int *,
3127 Lisp_Object *,
3128 int *, int *, int *, int *));
3129 extern Lisp_Object marginal_area_string P_ ((struct window *, enum window_part,
3130 int *, int *, int *,
3131 Lisp_Object *,
3132 int *, int *, int *, int *));
3133 extern void redraw_frame P_ ((struct frame *));
3134 extern void redraw_garbaged_frames P_ ((void));
3135 extern void cancel_line P_ ((int, struct frame *));
3136 extern void init_desired_glyphs P_ ((struct frame *));
3137 extern int scroll_frame_lines P_ ((struct frame *, int, int, int, int));
3138 extern int direct_output_for_insert P_ ((int));
3139 extern int direct_output_forward_char P_ ((int));
3140 extern int update_frame P_ ((struct frame *, int, int));
3141 extern int scrolling P_ ((struct frame *));
3142 extern void bitch_at_user P_ ((void));
3143 void adjust_glyphs P_ ((struct frame *));
3144 void free_glyphs P_ ((struct frame *));
3145 void free_window_matrices P_ ((struct window *));
3146 void check_glyph_memory P_ ((void));
3147 void mirrored_line_dance P_ ((struct glyph_matrix *, int, int, int *, char *));
3148 void clear_glyph_matrix P_ ((struct glyph_matrix *));
3149 void clear_current_matrices P_ ((struct frame *f));
3150 void clear_desired_matrices P_ ((struct frame *));
3151 void shift_glyph_matrix P_ ((struct window *, struct glyph_matrix *,
3152 int, int, int));
3153 void rotate_matrix P_ ((struct glyph_matrix *, int, int, int));
3154 void increment_matrix_positions P_ ((struct glyph_matrix *,
3155 int, int, int, int));
3156 void blank_row P_ ((struct window *, struct glyph_row *, int));
3157 void increment_row_positions P_ ((struct glyph_row *, int, int));
3158 void enable_glyph_matrix_rows P_ ((struct glyph_matrix *, int, int, int));
3159 void clear_glyph_row P_ ((struct glyph_row *));
3160 void prepare_desired_row P_ ((struct glyph_row *));
3161 int line_hash_code P_ ((struct glyph_row *));
3162 void set_window_update_flags P_ ((struct window *, int));
3163 void redraw_frame P_ ((struct frame *));
3164 void redraw_garbaged_frames P_ ((void));
3165 int scroll_cost P_ ((struct frame *, int, int, int));
3166 int direct_output_for_insert P_ ((int));
3167 int direct_output_forward_char P_ ((int));
3168 int update_frame P_ ((struct frame *, int, int));
3169 void update_single_window P_ ((struct window *, int));
3170 int scrolling P_ ((struct frame *));
3171 void do_pending_window_change P_ ((int));
3172 void change_frame_size P_ ((struct frame *, int, int, int, int, int));
3173 void bitch_at_user P_ ((void));
3174 void init_display P_ ((void));
3175 void syms_of_display P_ ((void));
3176 extern Lisp_Object Qredisplay_dont_pause;
3177 void spec_glyph_lookup_face P_ ((struct window *, GLYPH *));
3179 /* Defined in terminal.c */
3181 extern void ring_bell P_ ((struct frame *));
3182 extern void update_begin P_ ((struct frame *));
3183 extern void update_end P_ ((struct frame *));
3184 extern void set_terminal_window P_ ((struct frame *, int));
3185 extern void cursor_to P_ ((struct frame *, int, int));
3186 extern void raw_cursor_to P_ ((struct frame *, int, int));
3187 extern void clear_to_end P_ ((struct frame *));
3188 extern void clear_frame P_ ((struct frame *));
3189 extern void clear_end_of_line P_ ((struct frame *, int));
3190 extern void write_glyphs P_ ((struct frame *, struct glyph *, int));
3191 extern void insert_glyphs P_ ((struct frame *, struct glyph *, int));
3192 extern void delete_glyphs P_ ((struct frame *, int));
3193 extern void ins_del_lines P_ ((struct frame *, int, int));
3195 extern struct terminal *init_initial_terminal P_ ((void));
3198 /* Defined in term.c */
3200 extern void tty_set_terminal_modes P_ ((struct terminal *));
3201 extern void tty_reset_terminal_modes P_ ((struct terminal *));
3202 extern void tty_turn_off_insert P_ ((struct tty_display_info *));
3203 extern void tty_turn_off_highlight P_ ((struct tty_display_info *));
3204 extern int string_cost P_ ((char *));
3205 extern int per_line_cost P_ ((char *));
3206 extern void calculate_costs P_ ((struct frame *));
3207 extern void produce_glyphs P_ ((struct it *));
3208 extern void produce_special_glyphs P_ ((struct it *, enum display_element_type));
3209 extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
3210 extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
3211 extern struct terminal *get_tty_terminal P_ ((Lisp_Object, int));
3212 extern struct terminal *get_named_tty P_ ((char *));
3213 EXFUN (Ftty_type, 1);
3214 extern void create_tty_output P_ ((struct frame *));
3215 extern struct terminal *init_tty P_ ((char *, char *, int));
3218 /* Defined in scroll.c */
3220 extern int scrolling_max_lines_saved P_ ((int, int, int *, int *, int *));
3221 extern int scroll_cost P_ ((struct frame *, int, int, int));
3222 extern void do_line_insertion_deletion_costs P_ ((struct frame *, char *,
3223 char *, char *, char *,
3224 char *, char *, int));
3225 void scrolling_1 P_ ((struct frame *, int, int, int, int *, int *, int *,
3226 int *, int));
3228 /* Defined in frame.c */
3230 #ifdef HAVE_WINDOW_SYSTEM
3232 /* Types we might convert a resource string into. */
3233 enum resource_types
3235 RES_TYPE_NUMBER,
3236 RES_TYPE_FLOAT,
3237 RES_TYPE_BOOLEAN,
3238 RES_TYPE_STRING,
3239 RES_TYPE_SYMBOL
3242 extern Lisp_Object x_get_arg P_ ((Display_Info *, Lisp_Object,
3243 Lisp_Object, char *, char *class,
3244 enum resource_types));
3245 extern Lisp_Object x_frame_get_arg P_ ((struct frame *, Lisp_Object,
3246 Lisp_Object, char *, char *,
3247 enum resource_types));
3248 extern Lisp_Object x_frame_get_and_record_arg P_ ((
3249 struct frame *, Lisp_Object,
3250 Lisp_Object, char *, char *,
3251 enum resource_types));
3252 extern Lisp_Object x_default_parameter P_ ((struct frame *, Lisp_Object,
3253 Lisp_Object, Lisp_Object,
3254 char *, char *,
3255 enum resource_types));
3257 #endif /* HAVE_WINDOW_SYSTEM */
3259 #endif /* not DISPEXTERN_H_INCLUDED */
3261 /* arch-tag: c65c475f-1c1e-4534-8795-990b8509fd65
3262 (do not change this comment) */