1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1994, 1995, 1996 Board of Trustees, University of Illinois.
3 Copyright (C) 1995 Free Software Foundation, Inc.
4 Copyright (C) 1995, 1996 Ben Wing.
5 Copyright (C) 1995 Sun Microsystems, Inc.
6 Copyright (C) 1996 Chuck Thompson.
8 This file is part of SXEmacs
10 SXEmacs is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 SXEmacs is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 /* Synched up with: Not in FSF. */
26 /* Author: Chuck Thompson */
28 /* Fixed up by Ben Wing for Mule */
30 /* This file has been Mule-ized. */
32 /*****************************************************************************
33 The Golden Rules of Redisplay
35 First: It Is Better To Be Correct Than Fast
36 Second: Thou Shalt Not Run Elisp From Within Redisplay
37 Third: It Is Better To Be Fast Than Not To Be
38 ****************************************************************************/
57 #include "redisplay.h"
60 #include "line-number.h"
62 #include "mule/file-coding.h"
67 /* Note: We have to be careful throughout this code to properly handle
68 and differentiate between Bufbytes and Emchars.
70 Since strings are generally composed of Bufbytes, I've taken the tack
71 that any contiguous set of Bufbytes is called a "string", while
72 any contiguous set of Emchars is called an "array". */
74 /* Return value to indicate a failure by an add_*_rune routine to add
75 a rune, but no propagation information needs to be returned. */
76 #define ADD_FAILED (prop_block_dynarr *) 1
78 #define BEGIN_GLYPHS 0
81 #define RIGHT_GLYPHS 3
83 #define VERTICAL_CLIP(w, display) \
84 ((WINDOW_TTY_P (w) | (!display && scroll_on_clipped_lines)) \
88 /* The following structures are completely private to redisplay.c so
89 we put them here instead of in a header file, for modularity. */
91 /* NOTE: Bytinds not Bufpos's in this structure. */
93 typedef struct position_redisplay_data_type {
94 /* This information is normally filled in by the create_*_block
95 routines and is used by the add_*_rune routines. */
97 /* if we are working with strings rather than buffers we need a
98 handle to the string */
101 struct display_block *db;
102 struct display_line *dl;
103 Emchar ch; /* Character that is to be added. This is
104 used to communicate this information to
105 add_emchar_rune(). */
106 Lisp_Object last_charset; /* The charset of the previous character.
107 Used to optimize some lookups -- we
108 only have to do some things when
109 the charset changes. */
110 face_index last_findex; /* The face index of the previous character.
111 Needed to ensure the validity of the
112 last_charset optimization. */
114 int last_char_width; /* The width of the previous character. */
115 int font_is_bogus; /* If true, it means we couldn't instantiate
116 the font for this charset, so we substitute
117 ~'s from the ASCII charset. */
122 int blank_width; /* Width of the blank that is to be added.
123 This is used to communicate this information
126 This is also used rather cheesily to
127 communicate the width of the eol-cursor-size
128 blank that exists at the end of the line.
129 add_emchar_rune() is called cheesily with
130 the non-printing char '\n', which is stuck
131 in the output routines with its width being
133 Bytind bi_cursor_bufpos; /* This stores the buffer position of the cursor. */
134 unsigned int cursor_type:3;
135 int cursor_x; /* rune block cursor is at */
136 int start_col; /* Number of character columns (each column has
137 a width of the default char width) that still
138 need to be skipped. This is used for horizontal
139 scrolling, where a certain number of columns
140 (those off the left side of the screen) need
141 to be skipped before anything is displayed. */
142 Bytind bi_start_col_enabled;
143 int start_col_xoffset; /* Number of pixels that still need to
144 be skipped. This is used for
145 horizontal scrolling of glyphs, where we want
146 to be able to scroll over part of the glyph. */
148 int hscroll_glyph_width_adjust; /* how much the width of the hscroll
149 glyph differs from space_width (w).
150 0 if no hscroll glyph was used,
151 i.e. the window is not scrolled
152 horizontally. Used in tab
155 /* Information about the face the text should be displayed in and
156 any begin-glyphs and end-glyphs. */
157 struct extent_fragment *ef;
160 /* The height of a pixmap may either be predetermined if the user has set a
161 baseline value, or it may be dependent on whatever the line ascent and
162 descent values end up being, based just on font and pixmap-ascent
163 information. In the first case we can immediately update the values, thus
164 their inclusion here. In the last case we cannot determine the actual
165 contribution to the line height until we have finished laying out all text
166 on the line. Thus we propagate the max height of such pixmaps and do a
167 final calculation (in calculate_baseline()) after all text has been added
171 int max_pixmap_height;
172 int need_baseline_computation;
173 int end_glyph_width; /* Well, it is the kitchen sink after all ... */
175 Lisp_Object result_str; /* String where we put the result of
176 generating a formatted string in the modeline. */
177 int is_modeline; /* Non-zero if we're generating the modeline. */
178 Charcount modeline_charpos; /* Number of chars used in result_str so far;
179 corresponds to bytepos. */
180 Bytecount bytepos; /* Number of bytes used in result_str so far.
181 We don't actually copy the bytes into result_str
182 until the end because we don't know how big the
183 string is going to be until then. */
194 /* Data that should be propagated to the next line. Either a single
195 Emchar, a string of Bufbyte's or a glyph.
197 The actual data that is propagated ends up as a Dynarr of these
200 prop_blocks are used to indicate that data that was supposed to go
201 on the previous line couldn't actually be displayed. Generally this
202 shouldn't happen if we are clipping the end of lines. If we are
203 wrapping then we need to display the propagation data before moving
204 on. Its questionable whether we should wrap or clip glyphs in this
205 instance. Most e-lisp relies on clipping so we preserve this
208 #### It's unclean that both Emchars and Bufbytes are here.
211 typedef struct prop_block prop_block;
218 Bytecount len; /* length of the string. */
223 Bytind bi_cursor_bufpos; /* NOTE: is in Bytinds */
224 unsigned int cursor_type:3;