0
|
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.
|
|
7
|
|
8 This file is part of XEmacs.
|
|
9
|
|
10 XEmacs is free software; you can redistribute it and/or modify it
|
|
11 under the terms of the GNU General Public License as published by the
|
|
12 Free Software Foundation; either version 2, or (at your option) any
|
|
13 later version.
|
|
14
|
|
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
18 for more details.
|
|
19
|
|
20 You should have received a copy of the GNU General Public License
|
|
21 along with XEmacs; see the file COPYING. If not, write to
|
|
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 Boston, MA 02111-1307, USA. */
|
|
24
|
|
25 /* Synched up with: Not in FSF. */
|
|
26
|
|
27 /* Author: Chuck Thompson */
|
|
28
|
|
29 /* Fixed up by Ben Wing for Mule */
|
|
30
|
|
31 /* This file has been Mule-ized. */
|
|
32
|
|
33 /*****************************************************************************
|
|
34 The Golden Rules of Redisplay
|
|
35
|
|
36 First: It Is Better To Be Correct Than Fast
|
|
37 Second: Thou Shalt Not Run Elisp From Within Redisplay
|
|
38 Third: It Is Better To Be Fast Than Not To Be
|
|
39 ****************************************************************************/
|
|
40
|
|
41 #include <config.h>
|
|
42 #include "lisp.h"
|
|
43
|
|
44 #include "buffer.h"
|
|
45 #include "commands.h"
|
|
46 #include "debug.h"
|
|
47 #include "device.h"
|
|
48 #include "extents.h"
|
|
49 #include "faces.h"
|
|
50 #include "frame.h"
|
|
51 #include "glyphs.h"
|
|
52 #include "insdel.h"
|
|
53 #include "menubar.h"
|
|
54 #include "objects.h"
|
|
55 #include "process.h"
|
|
56 #include "redisplay.h"
|
|
57 #include "toolbar.h"
|
|
58 #include "window.h"
|
|
59
|
70
|
60 #ifdef MULE
|
|
61 #include "mule-coding.h"
|
|
62 #endif
|
16
|
63
|
0
|
64 /* Note: We have to be careful throughout this code to properly handle
|
|
65 and differentiate between Bufbytes and Emchars.
|
|
66
|
|
67 Since strings are generally composed of Bufbytes, I've taken the tack
|
|
68 that any contiguous set of Bufbytes is called a "string", while
|
|
69 any contiguous set of Emchars is called an "array". */
|
|
70
|
|
71 /* Return value to indicate a failure by an add_*_rune routine to add
|
|
72 a rune, but no propagation information needs to be returned. */
|
|
73 #define ADD_FAILED (prop_block_dynarr *) 1
|
|
74
|
|
75 #define BEGIN_GLYPHS 0
|
|
76 #define END_GLYPHS 1
|
|
77 #define LEFT_GLYPHS 2
|
|
78 #define RIGHT_GLYPHS 3
|
|
79
|
|
80 /* Set the vertical clip to 0 if we are currently updating the line
|
|
81 start cache. Otherwise for buffers of line height 1 it may fail to
|
|
82 be able to work properly because regenerate_window will not layout
|
|
83 a single line. */
|
|
84 #define VERTICAL_CLIP(w, display) \
|
|
85 (updating_line_start_cache \
|
|
86 ? 0 \
|
|
87 : ((WINDOW_TTY_P (w) | (!display && scroll_on_clipped_lines)) \
|
|
88 ? INT_MAX \
|
|
89 : vertical_clip))
|
|
90
|
|
91 /* The following structures are completely private to redisplay.c so
|
|
92 we put them here instead of in a header file, for modularity. */
|
|
93
|
|
94 /* NOTE: Bytinds not Bufpos's in this structure. */
|
|
95
|
|
96 typedef struct position_redisplay_data_type
|
|
97 {
|
|
98 /* This information is normally filled in by the create_*_block
|
|
99 routines and is used by the add_*_rune routines. */
|
|
100 Lisp_Object window;
|
|
101 struct device *d;
|
|
102 struct display_block *db;
|
|
103 struct display_line *dl;
|
|
104 Emchar ch; /* Character that is to be added. This is
|
|
105 used to communicate this information to
|
|
106 add_emchar_rune(). */
|
|
107 Lisp_Object last_charset; /* The charset of the previous character.
|
|
108 Used to optimize some lookups -- we
|
|
109 only have to do some things when
|
|
110 the charset changes. */
|
|
111 int last_char_width; /* The width of the previous character. */
|
|
112 int font_is_bogus; /* If true, it means we couldn't instantiate
|
|
113 the font for this charset, so we substitute
|
|
114 ~'s from the ASCII charset. */
|
|
115 Bytind bi_bufpos;
|
|
116 Bytind bi_endpos;
|
|
117 int pixpos;
|
|
118 int max_pixpos;
|
|
119 int blank_width; /* Width of the blank that is to be added.
|
|
120 This is used to communicate this information
|
|
121 to add_blank_rune().
|
|
122
|
|
123 This is also used rather cheesily to
|
|
124 communicate the width of the eol-cursor-size
|
|
125 blank that exists at the end of the line.
|
|
126 add_emchar_rune() is called cheesily with
|
|
127 the non-printing char '\n', which is stuck
|
|
128 in the output routines with its width being
|
|
129 BLANK_WIDTH. */
|
|
130 Bytind bi_cursor_bufpos;/* This stores the buffer position of the cursor. */
|
|
131 unsigned int cursor_type :3;
|
|
132 int cursor_x; /* rune block cursor is at */
|
|
133 int start_col; /* Number of character columns (each column has
|
|
134 a width of the default char width) that still
|
|
135 need to be skipped. This is used for horizontal
|
|
136 scrolling, where a certain number of columns
|
|
137 (those off the left side of the screen) need
|
|
138 to be skipped before anything is displayed. */
|
|
139 Bytind bi_start_col_enabled;
|
|
140
|
|
141 /* Information about the face the text should be displayed in and
|
|
142 any begin-glyphs and end-glyphs. */
|
|
143 struct extent_fragment *ef;
|
|
144 face_index findex;
|
|
145
|
|
146 /* The height of a pixmap may either be predetermined if the user
|
2
|
147 has set a baseline value, or it may be dependent on whatever the
|
|
148 line ascent and descent values end up being, based just on font
|
0
|
149 information. In the first case we can immediately update the
|
|
150 values, thus their inclusion here. In the last case we cannot
|
|
151 determine the actual contribution to the line height until we
|
|
152 have finished laying out all text on the line. Thus we propagate
|
|
153 the max height of such pixmaps and do a final calculation after
|
|
154 all text has been added to the line. */
|
|
155 int new_ascent;
|
|
156 int new_descent;
|
|
157 int max_pixmap_height;
|
|
158
|
|
159 Lisp_Object result_str; /* String where we put the result of
|
|
160 generating a formatted string in the modeline. */
|
|
161 int is_modeline; /* Non-zero if we're generating the modeline. */
|
|
162 Charcount modeline_charpos; /* Number of chars used in result_str so far;
|
|
163 corresponds to bytepos. */
|
|
164 Bytecount bytepos; /* Number of bytes used in result_str so far.
|
|
165 We don't actually copy the bytes into result_str
|
|
166 until the end because we don't know how big the
|
|
167 string is going to be until then. */
|
|
168 } pos_data;
|
|
169
|
|
170 enum prop_type
|
|
171 {
|
|
172 PROP_STRING,
|
|
173 PROP_CHAR,
|
|
174 PROP_MINIBUF_PROMPT,
|
|
175 PROP_BLANK
|
|
176 };
|
|
177
|
|
178 /* Data that should be propagated to the next line. Either a single
|
|
179 Emchar or a string of Bufbyte's.
|
|
180
|
|
181 The actual data that is propagated ends up as a Dynarr of these
|
|
182 blocks.
|
|
183
|
|
184 #### It's unclean that both Emchars and Bufbytes are here.
|
|
185 */
|
|
186
|
|
187 struct prop_block
|
|
188 {
|
|
189 enum prop_type type;
|
|
190
|
|
191 union data
|
|
192 {
|
|
193 struct
|
|
194 {
|
|
195 Bufbyte *str;
|
|
196 Bytecount len; /* length of the string. */
|
|
197 } p_string;
|
|
198
|
|
199 struct
|
|
200 {
|
|
201 Emchar ch;
|
|
202 Bytind bi_cursor_bufpos; /* NOTE: is in Bytinds */
|
|
203 unsigned int cursor_type :3;
|
|
204 } p_char;
|
|
205
|
|
206 struct
|
|
207 {
|
|
208 int width;
|
|
209 face_index findex;
|
|
210 } p_blank;
|
|
211 } data;
|
|
212 };
|
|
213
|
|
214 typedef struct prop_block_dynarr_type
|
|
215 {
|
|
216 Dynarr_declare (struct prop_block);
|
|
217 } prop_block_dynarr;
|
|
218
|
|
219
|
|
220 /*
|
|
221 * Prototypes for all functions defined in redisplay.c.
|
|
222 */
|
|
223 struct display_block *get_display_block_from_line (struct display_line *dl,
|
|
224 enum display_type type);
|
|
225 layout_bounds calculate_display_line_boundaries (struct window *w,
|
|
226 int modeline);
|
|
227 static Bufpos generate_display_line (struct window *w, struct display_line *dl,
|
|
228 int bounds, Bufpos start_pos,
|
|
229 int start_col, prop_block_dynarr **prop,
|
|
230 int type);
|
|
231 static void generate_modeline (struct window *w, struct display_line *dl,
|
|
232 int type);
|
|
233 static int ensure_modeline_generated (struct window *w, int type);
|
|
234 static void generate_formatted_string_db (Lisp_Object format_str,
|
|
235 Lisp_Object result_str,
|
|
236 struct window *w,
|
|
237 struct display_line *dl,
|
|
238 struct display_block *db,
|
|
239 face_index findex, int min_pixpos,
|
|
240 int max_pixpos, int type);
|
|
241 static Charcount generate_fstring_runes (struct window *w, pos_data *data,
|
|
242 Charcount pos, Charcount min_pos,
|
|
243 Charcount max_pos, Lisp_Object elt,
|
|
244 int depth, int max_pixsize,
|
|
245 face_index findex, int type);
|
|
246 static prop_block_dynarr *add_emchar_rune (pos_data *data);
|
|
247 static prop_block_dynarr *add_bufbyte_string_runes (pos_data *data,
|
|
248 Bufbyte *c_string,
|
|
249 Bytecount c_length,
|
|
250 int no_prop);
|
|
251 static prop_block_dynarr *add_blank_rune (pos_data *data, struct window *w,
|
|
252 int char_tab_width);
|
|
253 static prop_block_dynarr *add_octal_runes (pos_data *data);
|
|
254 static prop_block_dynarr *add_control_char_runes (pos_data *data,
|
|
255 struct buffer *b);
|
|
256 static prop_block_dynarr *add_disp_table_entry_runes (pos_data *data,
|
|
257 Lisp_Object entry);
|
|
258 static prop_block_dynarr *add_propagation_runes (prop_block_dynarr **prop,
|
|
259 pos_data *data);
|
|
260 static prop_block_dynarr *add_glyph_rune (pos_data *data,
|
|
261 struct glyph_block *gb,
|
|
262 int pos_type, int allow_cursor,
|
|
263 struct glyph_cachel *cachel);
|
|
264 static prop_block_dynarr *add_glyph_runes (pos_data *data,
|
|
265 int pos_type);
|
|
266 /* NOTE: Bytinds not Bufpos's here. */
|
|
267 static Bytind create_text_block (struct window *w, struct display_line *dl,
|
|
268 Bytind bi_start_pos, int start_col,
|
|
269 prop_block_dynarr **prop, int type);
|
|
270 static int create_overlay_glyph_block (struct window *w,
|
|
271 struct display_line *dl);
|
|
272 static void create_left_glyph_block (struct window *w,
|
|
273 struct display_line *dl,
|
|
274 int overlay_width);
|
|
275 static void create_right_glyph_block (struct window *w,
|
|
276 struct display_line *dl);
|
|
277 static void regenerate_window (struct window *w, Bufpos start_pos,
|
|
278 Bufpos point, int type);
|
70
|
279 static void regenerate_window_point_center (struct window *w, Bufpos point,
|
|
280 int type);
|
0
|
281 int window_half_pixpos (struct window *w);
|
|
282 int line_at_center (struct window *w, int type, Bufpos start, Bufpos point);
|
|
283 Bufpos point_at_center (struct window *w, int type, Bufpos start,
|
|
284 Bufpos point);
|
|
285 static void redisplay_window (Lisp_Object window, int skip_selected);
|
|
286 static void redisplay_windows (Lisp_Object window, int skip_selected);
|
|
287 static int redisplay_frame (struct frame *f, int preemption_check);
|
|
288 void redisplay (void);
|
|
289 static void decode_mode_spec (struct window *w, Emchar spec, int type);
|
|
290 static void free_display_line (struct display_line *dl);
|
|
291 void free_display_structs (struct window_mirror *mir);
|
|
292 static int point_visible (struct window *w, Bufpos point, int type);
|
|
293 static void update_line_start_cache (struct window *w, Bufpos from, Bufpos to,
|
|
294 Bufpos point, int no_regen);
|
|
295 static Bufpos line_start_cache_start (struct window *w);
|
|
296 static Bufpos line_start_cache_end (struct window *w);
|
|
297
|
|
298 /* This used to be 10 but 30 seems to give much better performance. */
|
|
299 #define INIT_MAX_PREEMPTS 30
|
|
300 static int max_preempts;
|
|
301
|
|
302 #define REDISPLAY_PREEMPTION_CHECK \
|
|
303 do { \
|
|
304 preempted = 0; \
|
|
305 if (!disable_preemption && \
|
|
306 ((preemption_count < max_preempts) || !NILP (Vexecuting_macro))) \
|
|
307 if (!INTERACTIVE || detect_input_pending ()) { \
|
|
308 preempted = 1; \
|
|
309 } \
|
|
310 } while (0)
|
|
311
|
|
312 /*
|
|
313 * Redisplay global variables.
|
|
314 */
|
|
315
|
|
316 /* We need a third set of display structures for the cursor motion
|
|
317 routines. We used to just give each window a third set. However,
|
|
318 we always fully regenerate the structures when needed so there
|
|
319 isn't any reason we need more than a single set. */
|
|
320 display_line_dynarr *cmotion_display_lines;
|
|
321
|
|
322 /* Used by generate_formatted_string. Global because they get used so
|
|
323 much that the dynamic allocation time adds up. */
|
|
324 emchar_dynarr *formatted_string_emchar_dynarr;
|
|
325 struct display_line formatted_string_display_line;
|
|
326 /* We store the extents that we need to generate in a Dynarr and then
|
|
327 frob them all on at the end of generating the string. We do it
|
|
328 this way rather than adding them as we generate the string because
|
|
329 we don't store the text into the resulting string until we're done
|
|
330 (to avoid having to resize the string multiple times), and we don't
|
|
331 want to go around adding extents to a string when the extents might
|
|
332 stretch off the end of the string. */
|
|
333 extent_dynarr *formatted_string_extent_dynarr;
|
|
334 bytecount_dynarr *formatted_string_extent_start_dynarr;
|
|
335 bytecount_dynarr *formatted_string_extent_end_dynarr;
|
|
336
|
|
337
|
|
338 /* #### probably temporary */
|
|
339 int cache_adjustment;
|
|
340
|
|
341 /* This holds a string representing the text corresponding to a single
|
|
342 modeline % spec. */
|
|
343 static bufbyte_dynarr *mode_spec_bufbyte_string;
|
|
344
|
|
345 int in_display; /* 1 if in redisplay. */
|
|
346
|
|
347 int disable_preemption; /* Used for debugging redisplay and for
|
|
348 force-redisplay. */
|
|
349
|
|
350 /* We only allow max_preempts preemptions before we force a redisplay. */
|
|
351 static int preemption_count;
|
|
352
|
|
353 /* Minimum pixel height of clipped bottom display line. */
|
|
354 int vertical_clip;
|
|
355
|
|
356 /* Minimum visible pixel width of clipped glyphs at right margin. */
|
|
357 int horizontal_clip;
|
|
358
|
|
359 /* Set if currently inside update_line_start_cache. */
|
|
360 int updating_line_start_cache;
|
|
361
|
|
362 /* Nonzero means reading single-character input with prompt
|
|
363 so put cursor on minibuffer after the prompt. */
|
|
364 int cursor_in_echo_area;
|
|
365 Lisp_Object Qcursor_in_echo_area;
|
|
366
|
|
367 /* Nonzero means truncate lines in all windows less wide than the frame */
|
|
368 int truncate_partial_width_windows;
|
|
369
|
|
370 /* non-nil if a buffer has changed since the last time redisplay completed */
|
|
371 int buffers_changed;
|
|
372 int buffers_changed_set;
|
|
373
|
|
374 /* non-nil if hscroll has changed somewhere or a buffer has been
|
|
375 narrowed or widened */
|
|
376 int clip_changed;
|
|
377 int clip_changed_set;
|
|
378
|
|
379 /* non-nil if any extent has changed since the last time redisplay completed */
|
|
380 int extents_changed;
|
|
381 int extents_changed_set;
|
|
382
|
|
383 /* non-nil if any face has changed since the last time redisplay completed */
|
|
384 int faces_changed;
|
|
385
|
|
386 /* Nonzero means some frames have been marked as garbaged */
|
|
387 int frame_changed;
|
|
388
|
|
389 /* This variable is 1 if the icon has to be updated.
|
|
390 It is set to 1 when `frame-icon-glyph' changes. */
|
|
391 int icon_changed;
|
|
392 int icon_changed_set;
|
|
393
|
|
394 /* This variable is 1 if the menubar widget has to be updated.
|
|
395 It is set to 1 by set-menubar-dirty-flag and cleared when the widget
|
|
396 has been indapted. */
|
|
397 /* indapted???? */
|
|
398 int menubar_changed;
|
|
399 int menubar_changed_set;
|
|
400
|
|
401 /* true iff we should redraw the modelines on the next redisplay */
|
|
402 int modeline_changed;
|
|
403 int modeline_changed_set;
|
|
404
|
|
405 /* non-nil if point has changed in some buffer since the last time
|
|
406 redisplay completed */
|
|
407 int point_changed;
|
|
408 int point_changed_set;
|
|
409
|
|
410 /* non-nil if some frame has changed its size */
|
|
411 int size_changed;
|
|
412
|
|
413 /* non-nil if some device has signaled that it wants to change size */
|
|
414 int asynch_device_change_pending;
|
|
415
|
|
416 /* non-nil if any toolbar has changed */
|
|
417 int toolbar_changed;
|
|
418 int toolbar_changed_set;
|
|
419
|
|
420 /* non-nil if any window has changed since the last time redisplay completed */
|
|
421 int windows_changed;
|
|
422
|
2
|
423 /* non-nil if any frame's window structure has changed since the last
|
0
|
424 time redisplay completed */
|
|
425 int windows_structure_changed;
|
|
426
|
|
427 /* If non-nil, use vertical bar cursor. */
|
|
428 Lisp_Object Vbar_cursor;
|
|
429 Lisp_Object Qbar_cursor;
|
|
430
|
|
431
|
|
432 int visible_bell; /* If true and the terminal will support it
|
|
433 then the frame will flash instead of
|
|
434 beeping when an error occurs */
|
|
435
|
|
436 /* Nonzero means no need to redraw the entire frame on resuming
|
|
437 a suspended Emacs. This is useful on terminals with multiple pages,
|
|
438 where one page is used for Emacs and another for all else. */
|
|
439 int no_redraw_on_reenter;
|
|
440
|
|
441 Lisp_Object Vwindow_system; /* nil or a symbol naming the window system
|
|
442 under which emacs is running
|
|
443 ('x is the only current possibility) */
|
|
444 Lisp_Object Vinitial_window_system;
|
|
445
|
|
446 Lisp_Object Vglobal_mode_string;
|
|
447
|
|
448 /* The number of lines to try scrolling a
|
|
449 window by when point leaves the window; if
|
|
450 it is <=0 then point is centered in the window */
|
|
451 int scroll_step;
|
|
452
|
|
453 /* Marker for where to display an arrow on top of the buffer text. */
|
|
454 Lisp_Object Voverlay_arrow_position;
|
|
455 /* String to display for the arrow. */
|
|
456 Lisp_Object Voverlay_arrow_string;
|
|
457
|
|
458 Lisp_Object Vwindow_size_change_functions;
|
|
459 Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
|
|
460 Lisp_Object Qredisplay_end_trigger_functions, Vredisplay_end_trigger_functions;
|
|
461
|
|
462 #define INHIBIT_REDISPLAY_HOOKS /* #### Until we've thought about
|
|
463 this more. */
|
|
464 #ifndef INHIBIT_REDISPLAY_HOOKS
|
|
465 /* #### Chuck says: I think this needs more thought.
|
|
466 Think about this for 19.14. */
|
|
467 Lisp_Object Vpre_redisplay_hook, Vpost_redisplay_hook;
|
|
468 Lisp_Object Qpre_redisplay_hook, Qpost_redisplay_hook;
|
|
469 #endif
|
|
470
|
|
471 int last_display_warning_tick, display_warning_tick;
|
|
472 Lisp_Object Qdisplay_warning_buffer;
|
|
473 int inhibit_warning_display;
|
|
474
|
|
475 Lisp_Object Vleft_margin_width, Vright_margin_width;
|
|
476 Lisp_Object Vminimum_line_ascent, Vminimum_line_descent;
|
|
477 Lisp_Object Vuse_left_overflow, Vuse_right_overflow;
|
|
478 Lisp_Object Vtext_cursor_visible_p;
|
|
479
|
72
|
480 int column_number_start_at_one;
|
0
|
481
|
|
482 /***************************************************************************/
|
|
483 /* */
|
|
484 /* low-level interfaces onto device routines */
|
|
485 /* */
|
|
486 /***************************************************************************/
|
|
487
|
|
488 static int
|
|
489 redisplay_text_width_emchar_string (struct window *w, int findex,
|
|
490 Emchar *str, Charcount len)
|
|
491 {
|
|
492 unsigned char charsets[NUM_LEADING_BYTES];
|
|
493 Lisp_Object window = Qnil;
|
|
494
|
|
495 find_charsets_in_emchar_string (charsets, str, len);
|
|
496 XSETWINDOW (window, w);
|
|
497 ensure_face_cachel_complete (WINDOW_FACE_CACHEL (w, findex), window,
|
|
498 charsets);
|
|
499 return DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (WINDOW_FRAME (w)))),
|
|
500 text_width, (WINDOW_FACE_CACHEL (w, findex),
|
|
501 str, len));
|
|
502 }
|
|
503
|
|
504 static emchar_dynarr *rtw_emchar_dynarr;
|
|
505
|
|
506 int
|
|
507 redisplay_text_width_string (struct window *w, int findex,
|
|
508 Bufbyte *nonreloc, Lisp_Object reloc,
|
|
509 Bytecount offset, Bytecount len)
|
|
510 {
|
|
511 if (!rtw_emchar_dynarr)
|
|
512 rtw_emchar_dynarr = Dynarr_new (Emchar);
|
|
513 Dynarr_reset (rtw_emchar_dynarr);
|
|
514
|
|
515 fixup_internal_substring (nonreloc, reloc, offset, &len);
|
|
516 if (STRINGP (reloc))
|
16
|
517 nonreloc = XSTRING_DATA (reloc);
|
0
|
518 convert_bufbyte_string_into_emchar_dynarr (nonreloc, len, rtw_emchar_dynarr);
|
|
519 return redisplay_text_width_emchar_string
|
|
520 (w, findex, Dynarr_atp (rtw_emchar_dynarr, 0),
|
|
521 Dynarr_length (rtw_emchar_dynarr));
|
|
522 }
|
|
523
|
|
524 int
|
|
525 redisplay_frame_text_width_string (struct frame *f, Lisp_Object face,
|
|
526 Bufbyte *nonreloc, Lisp_Object reloc,
|
|
527 Bytecount offset, Bytecount len)
|
|
528 {
|
|
529 unsigned char charsets[NUM_LEADING_BYTES];
|
|
530 Lisp_Object frame = Qnil;
|
|
531 struct face_cachel cachel;
|
|
532
|
|
533 if (!rtw_emchar_dynarr)
|
|
534 rtw_emchar_dynarr = Dynarr_new (Emchar);
|
|
535 Dynarr_reset (rtw_emchar_dynarr);
|
|
536
|
|
537 fixup_internal_substring (nonreloc, reloc, offset, &len);
|
|
538 if (STRINGP (reloc))
|
16
|
539 nonreloc = XSTRING_DATA (reloc);
|
0
|
540 convert_bufbyte_string_into_emchar_dynarr (nonreloc, len, rtw_emchar_dynarr);
|
|
541 find_charsets_in_bufbyte_string (charsets, nonreloc, len);
|
|
542 reset_face_cachel (&cachel);
|
|
543 cachel.face = face;
|
|
544 XSETFRAME (frame, f);
|
|
545 ensure_face_cachel_complete (&cachel, frame, charsets);
|
|
546 return DEVMETH (XDEVICE (FRAME_DEVICE (f)),
|
|
547 text_width, (&cachel, Dynarr_atp (rtw_emchar_dynarr, 0),
|
|
548 Dynarr_length (rtw_emchar_dynarr)));
|
|
549 }
|
|
550
|
|
551 /* Return the display block from DL of the given TYPE. A display line
|
|
552 can have only one display block of each possible type. If DL does
|
|
553 not have a block of type TYPE, one will be created and added to DL. */
|
|
554
|
|
555 struct display_block *
|
|
556 get_display_block_from_line (struct display_line *dl, enum display_type type)
|
|
557 {
|
|
558 int elt;
|
|
559 struct display_block db;
|
|
560
|
|
561 /* Check if this display line already has a block of the desired type and
|
|
562 if so, return it. */
|
|
563 if (dl->display_blocks)
|
|
564 {
|
|
565 for (elt = 0; elt < Dynarr_length (dl->display_blocks); elt++)
|
|
566 {
|
|
567 if (Dynarr_at (dl->display_blocks, elt).type == type)
|
|
568 return (Dynarr_atp (dl->display_blocks, elt));
|
|
569 }
|
|
570
|
|
571 /* There isn't an active block of the desired type, but there
|
|
572 might still be allocated blocks we need to reuse. */
|
|
573 if (elt < Dynarr_largest (dl->display_blocks))
|
|
574 {
|
|
575 struct display_block *dbp = Dynarr_atp (dl->display_blocks, elt);
|
|
576
|
|
577 /* 'add' the block to the list */
|
|
578 Dynarr_increment (dl->display_blocks);
|
|
579
|
|
580 /* initialize and return */
|
|
581 dbp->type = type;
|
|
582 return dbp;
|
|
583 }
|
|
584 }
|
|
585 else
|
|
586 {
|
|
587 /* This line doesn't have any display blocks, so initialize the display
|
|
588 bock array. */
|
|
589 dl->display_blocks = Dynarr_new (struct display_block);
|
|
590 }
|
|
591
|
|
592 /* The line doesn't have a block of the desired type so go ahead and create
|
|
593 one and add it to the line. */
|
|
594 memset (&db, 0, sizeof (struct display_block));
|
|
595 db.type = type;
|
|
596 db.runes = Dynarr_new (struct rune);
|
|
597 Dynarr_add (dl->display_blocks, db);
|
|
598
|
|
599 /* Return the newly added display block. */
|
|
600 elt = Dynarr_length (dl->display_blocks) - 1;
|
|
601
|
|
602 return Dynarr_atp (dl->display_blocks, elt);
|
|
603 }
|
|
604
|
|
605 static int
|
|
606 tab_char_width (struct window *w)
|
|
607 {
|
|
608 struct buffer *b = XBUFFER (w->buffer);
|
|
609 int char_tab_width = XINT (b->tab_width);
|
|
610
|
|
611 if (char_tab_width <= 0 || char_tab_width > 1000) char_tab_width = 8;
|
|
612
|
|
613 return char_tab_width;
|
|
614 }
|
|
615
|
|
616 static int
|
|
617 space_width (struct window *w)
|
|
618 {
|
|
619 /* While tabs are traditional composed of spaces, for variable-width
|
|
620 fonts the space character tends to give too narrow a value. So
|
|
621 we use 'n' instead. Except that we don't. We use the default
|
|
622 character width for the default face. If this is actually
|
|
623 defined by the font then it is probably the best thing to
|
|
624 actually use. If it isn't, we have assumed it is 'n' and have
|
|
625 already calculated its width. Thus we can avoid a call to
|
|
626 XTextWidth on X frames by just querying the default width. */
|
|
627 return XFONT_INSTANCE
|
|
628 (WINDOW_FACE_CACHEL_FONT (w, DEFAULT_INDEX, Vcharset_ascii))->width;
|
|
629 }
|
|
630
|
|
631 static int
|
|
632 tab_pix_width (struct window *w)
|
|
633 {
|
|
634 return (space_width (w) * tab_char_width (w));
|
|
635 }
|
|
636
|
|
637 /* Given a pixel position in a window, return the pixel location of
|
|
638 the next tabstop. Tabs are calculated from the left window edge in
|
|
639 terms of spaces displayed in the default face. Formerly the space
|
|
640 width was determined using the currently active face. That method
|
|
641 leads to tabstops which do not line up. */
|
|
642
|
|
643 static int
|
|
644 next_tab_position (struct window *w, int start_pixpos, int left_pixpos)
|
|
645 {
|
|
646 int n_pos = left_pixpos;
|
|
647 int pix_tab_width = tab_pix_width (w);
|
|
648
|
|
649 /* Adjust n_pos for any hscrolling which has happened. */
|
|
650 if (w->hscroll > 1)
|
|
651 n_pos -= space_width (w) * (w->hscroll - 1);
|
|
652
|
|
653 while (n_pos <= start_pixpos)
|
|
654 n_pos += pix_tab_width;
|
|
655
|
|
656 return n_pos;
|
|
657 }
|
|
658
|
|
659 /* For the given window, calculate the outside and margin boundaries for a
|
|
660 display line. The whitespace boundaries must be calculated by the text
|
|
661 layout routines. */
|
|
662
|
|
663 layout_bounds
|
|
664 calculate_display_line_boundaries (struct window *w, int modeline)
|
|
665 {
|
|
666 layout_bounds bounds;
|
|
667
|
|
668 /* Set the outermost boundaries which are the boundaries of the
|
|
669 window itself minus the gutters (and minus the scrollbars if this
|
|
670 is for the modeline). */
|
|
671 if (!modeline)
|
|
672 {
|
|
673 bounds.left_out = WINDOW_TEXT_LEFT (w);
|
|
674 bounds.right_out = WINDOW_TEXT_RIGHT (w);
|
|
675 }
|
|
676 else
|
|
677 {
|
|
678 bounds.left_out = WINDOW_MODELINE_LEFT (w);
|
|
679 bounds.right_out = WINDOW_MODELINE_RIGHT (w);
|
|
680 }
|
|
681
|
|
682 /* The inner boundaries mark where the glyph margins are located. */
|
|
683 bounds.left_in = bounds.left_out + window_left_margin_width (w);
|
|
684 bounds.right_in = bounds.right_out - window_right_margin_width (w);
|
|
685
|
|
686 /* We cannot fully calculate the whitespace boundaries as they
|
|
687 depend on the contents of the line being displayed. */
|
|
688 bounds.left_white = bounds.left_in;
|
|
689 bounds.right_white = bounds.right_in;
|
|
690
|
|
691 return bounds;
|
|
692 }
|
|
693
|
|
694 /* Given a display line and a starting position, ensure that the
|
|
695 contents of the display line accurately represent the visual
|
|
696 representation of the buffer contents starting from the given
|
|
697 position when displayed in the given window. The display line ends
|
|
698 when the contents of the line reach the right boundary of the given
|
|
699 window. */
|
|
700
|
|
701 static Bufpos
|
|
702 generate_display_line (struct window *w, struct display_line *dl, int bounds,
|
|
703 Bufpos start_pos, int start_col,
|
|
704 prop_block_dynarr **prop, int type)
|
|
705 {
|
|
706 Bufpos ret_bufpos;
|
|
707 int overlay_width;
|
|
708 struct buffer *b = XBUFFER (WINDOW_BUFFER (w));
|
|
709
|
|
710 /* If our caller hasn't already set the boundaries, then do so now. */
|
|
711 if (!bounds)
|
|
712 dl->bounds = calculate_display_line_boundaries (w, 0);
|
|
713
|
|
714 /* Reset what this line is using. */
|
|
715 if (dl->display_blocks)
|
|
716 Dynarr_reset (dl->display_blocks);
|
|
717 if (dl->left_glyphs)
|
|
718 {
|
|
719 Dynarr_free (dl->left_glyphs);
|
|
720 dl->left_glyphs = 0;
|
|
721 }
|
|
722 if (dl->right_glyphs)
|
|
723 {
|
|
724 Dynarr_free (dl->right_glyphs);
|
|
725 dl->right_glyphs = 0;
|
|
726 }
|
|
727
|
|
728 /* We aren't generating a modeline at the moment. */
|
|
729 dl->modeline = 0;
|
|
730
|
|
731 /* Create a display block for the text region of the line. */
|
|
732 {
|
|
733 /* #### urk urk urk!!! Chuck fix this shit! */
|
|
734 Bytind hacked_up_bytind =
|
|
735 create_text_block (w, dl, bufpos_to_bytind (b, start_pos),
|
|
736 start_col, prop, type);
|
|
737 if (hacked_up_bytind > BI_BUF_ZV (b))
|
|
738 ret_bufpos = BUF_ZV (b) + 1;
|
|
739 else
|
|
740 ret_bufpos = bytind_to_bufpos (b, hacked_up_bytind);
|
|
741 }
|
|
742 dl->bufpos = start_pos;
|
|
743 if (dl->end_bufpos < dl->bufpos)
|
|
744 dl->end_bufpos = dl->bufpos;
|
|
745
|
|
746 if (MARKERP (Voverlay_arrow_position)
|
|
747 && EQ (w->buffer, Fmarker_buffer (Voverlay_arrow_position))
|
|
748 && start_pos == marker_position (Voverlay_arrow_position)
|
|
749 && (STRINGP (Voverlay_arrow_string)
|
|
750 || GLYPHP (Voverlay_arrow_string)))
|
|
751 {
|
|
752 overlay_width = create_overlay_glyph_block (w, dl);
|
|
753 }
|
|
754 else
|
|
755 overlay_width = 0;
|
|
756
|
|
757 /* If there are left glyphs associated with any character in the
|
|
758 text block, then create a display block to handle them. */
|
|
759 if (dl->left_glyphs != NULL && Dynarr_length (dl->left_glyphs))
|
|
760 create_left_glyph_block (w, dl, overlay_width);
|
|
761
|
|
762 /* If there are right glyphs associated with any character in the
|
|
763 text block, then create a display block to handle them. */
|
|
764 if (dl->right_glyphs != NULL && Dynarr_length (dl->right_glyphs))
|
|
765 create_right_glyph_block (w, dl);
|
|
766
|
|
767 /* In the future additional types of display blocks may be generated
|
|
768 here. */
|
|
769
|
|
770 w->last_redisplay_pos = ret_bufpos;
|
|
771
|
|
772 return ret_bufpos;
|
|
773 }
|
|
774
|
|
775 /* Adds an hscroll glyph to a display block. If this is called, then
|
|
776 the block had better be empty.
|
|
777
|
|
778 Yes, there are multiple places where this function is called but
|
|
779 that is the way it has to be. Each calling function has to deal
|
|
780 with bi_start_col_enabled a little differently depending on the
|
|
781 object being worked with. */
|
|
782
|
|
783 static prop_block_dynarr *
|
|
784 add_hscroll_rune (pos_data *data)
|
|
785 {
|
|
786 struct glyph_block gb;
|
|
787 prop_block_dynarr *retval;
|
|
788 Bytind bi_old_cursor_bufpos = data->bi_cursor_bufpos;
|
|
789 unsigned int old_cursor_type = data->cursor_type;
|
|
790 Bytind bi_old_bufpos = data->bi_bufpos;
|
|
791
|
|
792 if (data->cursor_type == CURSOR_ON
|
|
793 && data->bi_cursor_bufpos >= data->bi_start_col_enabled
|
|
794 && data->bi_cursor_bufpos <= data->bi_bufpos)
|
|
795 {
|
|
796 data->bi_cursor_bufpos = data->bi_start_col_enabled;
|
|
797 }
|
|
798 else
|
|
799 {
|
|
800 data->cursor_type = NO_CURSOR;
|
|
801 }
|
|
802
|
|
803 data->bi_endpos = data->bi_bufpos;
|
|
804 data->bi_bufpos = data->bi_start_col_enabled;
|
|
805
|
|
806 gb.extent = Qnil;
|
|
807 gb.glyph = Vhscroll_glyph;
|
|
808 retval = add_glyph_rune (data, &gb, BEGIN_GLYPHS, 1,
|
|
809 GLYPH_CACHEL (XWINDOW (data->window),
|
|
810 HSCROLL_GLYPH_INDEX));
|
|
811
|
|
812 data->bi_endpos = 0;
|
|
813 data->bi_cursor_bufpos = bi_old_cursor_bufpos;
|
|
814 data->cursor_type = old_cursor_type;
|
|
815 data->bi_bufpos = bi_old_bufpos;
|
|
816
|
|
817 data->bi_start_col_enabled = 0;
|
|
818 return retval;
|
|
819 }
|
|
820
|
|
821 /* Adds a character rune to a display block. If there is not enough
|
|
822 room to fit the rune on the display block (as determined by the
|
|
823 MAX_PIXPOS) then it adds nothing and returns ADD_FAILED. */
|
|
824
|
|
825 static prop_block_dynarr *
|
|
826 add_emchar_rune (pos_data *data)
|
|
827 {
|
|
828 struct rune rb, *crb;
|
|
829 int width, local;
|
|
830
|
|
831 if (data->start_col)
|
|
832 {
|
|
833 data->start_col--;
|
|
834
|
|
835 if (data->start_col)
|
|
836 return NULL;
|
|
837 }
|
|
838
|
|
839 if (data->bi_start_col_enabled)
|
|
840 {
|
|
841 return add_hscroll_rune (data);
|
|
842 }
|
|
843
|
|
844 if (data->ch == '\n')
|
|
845 {
|
|
846 data->font_is_bogus = 0;
|
|
847 /* Cheesy end-of-line pseudo-character. */
|
|
848 width = data->blank_width;
|
|
849 }
|
|
850 else
|
|
851 {
|
|
852 Lisp_Object charset = CHAR_CHARSET (data->ch);
|
70
|
853 if (!EQ (charset, data->last_charset))
|
0
|
854 {
|
|
855 /* OK, we need to do things the hard way. */
|
|
856 struct window *w = XWINDOW (data->window);
|
|
857 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, data->findex);
|
|
858 Lisp_Object font_instance =
|
|
859 ensure_face_cachel_contains_charset (cachel, data->window,
|
|
860 charset);
|
|
861 struct Lisp_Font_Instance *fi;
|
|
862
|
|
863 if (EQ (font_instance, Vthe_null_font_instance))
|
|
864 {
|
|
865 font_instance = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
|
|
866 data->font_is_bogus = 1;
|
|
867 }
|
|
868 else
|
|
869 data->font_is_bogus = 0;
|
|
870
|
|
871 fi = XFONT_INSTANCE (font_instance);
|
|
872 if (!fi->proportional_p)
|
|
873 /* sweetness and light. */
|
|
874 data->last_char_width = fi->width;
|
|
875 else
|
|
876 data->last_char_width = -1;
|
2
|
877 data->new_ascent = max (data->new_ascent, (int) fi->ascent);
|
0
|
878 data->new_descent = max (data->new_descent, (int) fi->descent);
|
86
|
879 /* The following line causes display goobers and I don't know why */
|
|
880 /*data->last_charset = charset;*/
|
0
|
881 }
|
|
882
|
|
883 width = data->last_char_width;
|
|
884 if (width < 0)
|
|
885 {
|
|
886 /* bummer. Proportional fonts. */
|
|
887 width = redisplay_text_width_emchar_string (XWINDOW (data->window),
|
|
888 data->findex,
|
|
889 &data->ch, 1);
|
|
890 }
|
|
891 }
|
|
892
|
|
893 if (data->max_pixpos != -1 && (data->pixpos + width > data->max_pixpos))
|
|
894 {
|
|
895 return ADD_FAILED;
|
|
896 }
|
|
897
|
|
898 if (Dynarr_length (data->db->runes) < Dynarr_largest (data->db->runes))
|
|
899 {
|
|
900 crb = Dynarr_atp (data->db->runes, Dynarr_length (data->db->runes));
|
|
901 local = 0;
|
|
902 }
|
|
903 else
|
|
904 {
|
|
905 crb = &rb;
|
|
906 local = 1;
|
|
907 }
|
|
908
|
|
909 crb->findex = data->findex;
|
|
910 crb->xpos = data->pixpos;
|
|
911 crb->width = width;
|
|
912 if (data->bi_bufpos)
|
|
913 {
|
|
914 struct buffer *buf = XBUFFER (WINDOW_BUFFER (XWINDOW (data->window)));
|
|
915 crb->bufpos = bytind_to_bufpos (buf, data->bi_bufpos);
|
|
916 }
|
|
917 else if (data->is_modeline)
|
|
918 crb->bufpos = data->modeline_charpos;
|
|
919 else
|
|
920 /* fuckme if this shouldn't be an abort. */
|
|
921 /* abort (); fuckme harder, this abort gets tripped quite often,
|
|
922 in propagation and whatnot. #### fixme */
|
|
923 crb->bufpos = 0;
|
|
924 crb->type = RUNE_CHAR;
|
|
925 crb->object.chr.ch = data->font_is_bogus ? '~' : data->ch;
|
|
926 crb->endpos = 0;
|
|
927
|
|
928 if (data->cursor_type == CURSOR_ON)
|
|
929 {
|
|
930 if (data->bi_bufpos == data->bi_cursor_bufpos)
|
|
931 {
|
|
932 crb->cursor_type = CURSOR_ON;
|
|
933 data->cursor_x = Dynarr_length (data->db->runes);
|
|
934 }
|
|
935 else
|
|
936 crb->cursor_type = CURSOR_OFF;
|
|
937 }
|
|
938 else if (data->cursor_type == NEXT_CURSOR)
|
|
939 {
|
|
940 crb->cursor_type = CURSOR_ON;
|
|
941 data->cursor_x = Dynarr_length (data->db->runes);
|
|
942 data->cursor_type = NO_CURSOR;
|
|
943 }
|
|
944 else if (data->cursor_type == IGNORE_CURSOR)
|
|
945 crb->cursor_type = IGNORE_CURSOR;
|
|
946 else
|
|
947 crb->cursor_type = CURSOR_OFF;
|
|
948
|
|
949 if (local)
|
|
950 Dynarr_add (data->db->runes, *crb);
|
|
951 else
|
|
952 Dynarr_increment (data->db->runes);
|
|
953
|
|
954 data->pixpos += width;
|
|
955
|
|
956 return NULL;
|
|
957 }
|
|
958
|
|
959 /* Given a string C_STRING of length C_LENGTH, call add_emchar_rune
|
|
960 for each character in the string. Propagate any left-over data
|
|
961 unless NO_PROP is non-zero. */
|
|
962
|
|
963 static prop_block_dynarr *
|
|
964 add_bufbyte_string_runes (pos_data *data, Bufbyte *c_string,
|
|
965 Bytecount c_length, int no_prop)
|
|
966 {
|
|
967 Bufbyte *pos, *end = c_string + c_length;
|
|
968 prop_block_dynarr *prop;
|
|
969
|
|
970 /* #### This function is too simplistic. It needs to do the same
|
|
971 sort of character interpretation (display-table lookup,
|
|
972 ctl-arrow checking), etc. that create_text_block() does.
|
|
973 The functionality to do this in that routine needs to be
|
|
974 modularized. */
|
|
975
|
|
976 for (pos = c_string; pos < end;)
|
|
977 {
|
|
978 data->ch = charptr_emchar (pos);
|
|
979
|
|
980 prop = add_emchar_rune (data);
|
|
981
|
|
982 if (prop)
|
|
983 {
|
|
984 if (no_prop)
|
|
985 return ADD_FAILED;
|
|
986 else
|
|
987 {
|
|
988 struct prop_block pb;
|
|
989 Bytecount len = end - pos;
|
|
990 prop = Dynarr_new (struct prop_block);
|
|
991
|
|
992 pb.type = PROP_STRING;
|
|
993 pb.data.p_string.str =
|
|
994 (Bufbyte *) xmalloc (sizeof (Bufbyte) * len);
|
|
995 strncpy ((char *) pb.data.p_string.str, (char *) pos, len);
|
|
996 pb.data.p_string.len = len;
|
|
997
|
|
998 Dynarr_add (prop, pb);
|
|
999 return prop;
|
|
1000 }
|
|
1001 }
|
|
1002 INC_CHARPTR (pos);
|
|
1003 assert (pos <= end);
|
|
1004 }
|
|
1005
|
|
1006 return NULL;
|
|
1007 }
|
|
1008
|
|
1009 /* Add a single rune of the specified width. The area covered by this
|
|
1010 rune will be displayed in the foreground color of the associated
|
|
1011 face. */
|
|
1012
|
|
1013 static prop_block_dynarr *
|
|
1014 add_blank_rune (pos_data *data, struct window *w, int char_tab_width)
|
|
1015 {
|
|
1016 struct rune rb;
|
|
1017
|
|
1018 /* If data->start_col is not 0 then this call to add_blank_rune must have
|
|
1019 been to add it as a tab. */
|
|
1020 if (data->start_col)
|
|
1021 {
|
|
1022 /* assert (w != NULL) */
|
|
1023 prop_block_dynarr *retval;
|
|
1024
|
|
1025 /* If we have still not fully scrolled horizontally, subtract
|
|
1026 the width of this tab and return. */
|
|
1027 if (char_tab_width < data->start_col)
|
|
1028 {
|
|
1029 data->start_col -= char_tab_width;
|
|
1030 return NULL;
|
|
1031 }
|
|
1032 else if (char_tab_width == data->start_col)
|
|
1033 data->blank_width = 0;
|
|
1034 else
|
|
1035 {
|
|
1036 int spcwid = space_width (w);
|
|
1037
|
|
1038 if (spcwid >= data->blank_width)
|
|
1039 data->blank_width = 0;
|
|
1040 else
|
|
1041 data->blank_width -= spcwid;
|
|
1042 }
|
|
1043
|
|
1044 data->start_col = 0;
|
|
1045 retval = add_hscroll_rune (data);
|
|
1046
|
|
1047 /* Could be caused by the handling of the hscroll rune. */
|
|
1048 if (retval != NULL || !data->blank_width)
|
|
1049 return retval;
|
|
1050 }
|
|
1051
|
|
1052 /* Blank runes are always calculated to fit. */
|
|
1053 assert (data->pixpos + data->blank_width <= data->max_pixpos);
|
|
1054
|
|
1055 rb.findex = data->findex;
|
|
1056 rb.xpos = data->pixpos;
|
|
1057 rb.width = data->blank_width;
|
|
1058 if (data->bi_bufpos)
|
|
1059 {
|
|
1060 struct buffer *buf = XBUFFER (WINDOW_BUFFER (XWINDOW (data->window)));
|
|
1061 rb.bufpos = bytind_to_bufpos (buf, data->bi_bufpos);
|
|
1062 }
|
|
1063 else
|
|
1064 /* #### and this is really correct too? */
|
|
1065 rb.bufpos = 0;
|
|
1066 rb.endpos = 0;
|
|
1067 rb.type = RUNE_BLANK;
|
|
1068
|
|
1069 if (data->cursor_type == CURSOR_ON)
|
|
1070 {
|
|
1071 if (data->bi_bufpos == data->bi_cursor_bufpos)
|
|
1072 {
|
|
1073 rb.cursor_type = CURSOR_ON;
|
|
1074 data->cursor_x = Dynarr_length (data->db->runes);
|
|
1075 }
|
|
1076 else
|
|
1077 rb.cursor_type = CURSOR_OFF;
|
|
1078 }
|
|
1079 else if (data->cursor_type == NEXT_CURSOR)
|
|
1080 {
|
|
1081 rb.cursor_type = CURSOR_ON;
|
|
1082 data->cursor_x = Dynarr_length (data->db->runes);
|
|
1083 data->cursor_type = NO_CURSOR;
|
|
1084 }
|
|
1085 else
|
|
1086 rb.cursor_type = CURSOR_OFF;
|
|
1087
|
|
1088 Dynarr_add (data->db->runes, rb);
|
|
1089 data->pixpos += data->blank_width;
|
|
1090
|
|
1091 return NULL;
|
|
1092 }
|
|
1093
|
|
1094 /* Add runes representing a character in octal. */
|
|
1095
|
|
1096 #define ADD_NEXT_OCTAL_RUNE_CHAR do \
|
|
1097 { \
|
|
1098 if (add_failed || (add_failed = add_emchar_rune (data))) \
|
|
1099 { \
|
|
1100 struct prop_block pb; \
|
|
1101 if (!prop) \
|
|
1102 prop = Dynarr_new (struct prop_block); \
|
|
1103 \
|
|
1104 pb.type = PROP_CHAR; \
|
|
1105 pb.data.p_char.ch = data->ch; \
|
|
1106 pb.data.p_char.cursor_type = data->cursor_type; \
|
|
1107 Dynarr_add (prop, pb); \
|
|
1108 } \
|
|
1109 } while (0)
|
|
1110
|
|
1111 static prop_block_dynarr *
|
|
1112 add_octal_runes (pos_data *data)
|
|
1113 {
|
|
1114 prop_block_dynarr *prop, *add_failed;
|
|
1115 Emchar orig_char = data->ch;
|
|
1116 unsigned int orig_cursor_type = data->cursor_type;
|
|
1117
|
|
1118 /* Initialize */
|
|
1119 prop = NULL;
|
|
1120 add_failed = NULL;
|
|
1121
|
|
1122 if (data->start_col)
|
|
1123 data->start_col--;
|
|
1124
|
|
1125 if (!data->start_col)
|
|
1126 {
|
|
1127 if (data->bi_start_col_enabled)
|
|
1128 {
|
|
1129 add_failed = add_hscroll_rune (data);
|
|
1130 }
|
|
1131 else
|
|
1132 {
|
|
1133 struct glyph_block gb;
|
|
1134 struct window *w = XWINDOW (data->window);
|
|
1135
|
|
1136 gb.extent = Qnil;
|
|
1137 gb.glyph = Voctal_escape_glyph;
|
|
1138 add_failed =
|
|
1139 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 1,
|
|
1140 GLYPH_CACHEL (w, OCT_ESC_GLYPH_INDEX));
|
|
1141 }
|
|
1142 }
|
|
1143
|
|
1144 /* We only propagate information if the glyph was partially
|
|
1145 added. */
|
|
1146 if (add_failed)
|
|
1147 return add_failed;
|
|
1148
|
|
1149 data->cursor_type = IGNORE_CURSOR;
|
|
1150
|
|
1151 if (data->ch >= 0x100)
|
|
1152 {
|
|
1153 /* If the character is an extended Mule character, it could have
|
|
1154 up to 19 bits. For the moment, we treat it as a seven-digit
|
|
1155 octal number. This is not that pretty, but whatever. */
|
|
1156 data->ch = (7 & (orig_char >> 18)) + '0';
|
|
1157 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1158
|
|
1159 data->ch = (7 & (orig_char >> 15)) + '0';
|
|
1160 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1161
|
|
1162 data->ch = (7 & (orig_char >> 12)) + '0';
|
|
1163 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1164
|
|
1165 data->ch = (7 & (orig_char >> 9)) + '0';
|
|
1166 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1167 }
|
|
1168
|
|
1169 data->ch = (7 & (orig_char >> 6)) + '0';
|
|
1170 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1171
|
|
1172 data->ch = (7 & (orig_char >> 3)) + '0';
|
|
1173 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1174
|
|
1175 data->ch = (7 & orig_char) + '0';
|
|
1176 ADD_NEXT_OCTAL_RUNE_CHAR;
|
|
1177
|
|
1178 data->cursor_type = orig_cursor_type;
|
|
1179 return prop;
|
|
1180 }
|
|
1181
|
|
1182 #undef ADD_NEXT_OCTAL_RUNE_CHAR
|
|
1183
|
|
1184 /* Add runes representing a control character to a display block. */
|
|
1185
|
|
1186 static prop_block_dynarr *
|
|
1187 add_control_char_runes (pos_data *data, struct buffer *b)
|
|
1188 {
|
|
1189 if (!NILP (b->ctl_arrow))
|
|
1190 {
|
|
1191 prop_block_dynarr *prop;
|
|
1192 Emchar orig_char = data->ch;
|
|
1193 unsigned int old_cursor_type = data->cursor_type;
|
|
1194
|
|
1195 /* Initialize */
|
|
1196 prop = NULL;
|
|
1197
|
|
1198 if (data->start_col)
|
|
1199 data->start_col--;
|
|
1200
|
|
1201 if (!data->start_col)
|
|
1202 {
|
|
1203 if (data->bi_start_col_enabled)
|
|
1204 {
|
|
1205 prop_block_dynarr *retval;
|
|
1206
|
|
1207 retval = add_hscroll_rune (data);
|
|
1208 if (retval)
|
|
1209 return retval;
|
|
1210 }
|
|
1211 else
|
|
1212 {
|
|
1213 struct glyph_block gb;
|
|
1214 struct window *w = XWINDOW (data->window);
|
|
1215
|
|
1216 gb.extent = Qnil;
|
|
1217 gb.glyph = Vcontrol_arrow_glyph;
|
|
1218
|
|
1219 /* We only propagate information if the glyph was partially
|
|
1220 added. */
|
|
1221 if (add_glyph_rune (data, &gb, BEGIN_GLYPHS, 1,
|
|
1222 GLYPH_CACHEL (w, CONTROL_GLYPH_INDEX)))
|
|
1223 return ADD_FAILED;
|
|
1224 }
|
|
1225 }
|
|
1226
|
|
1227 if (orig_char == 0177)
|
|
1228 data->ch = '?';
|
|
1229 else
|
|
1230 data->ch = orig_char ^ 0100;
|
|
1231 data->cursor_type = IGNORE_CURSOR;
|
|
1232
|
|
1233 if (add_emchar_rune (data))
|
|
1234 {
|
|
1235 struct prop_block pb;
|
|
1236 if (!prop)
|
|
1237 prop = Dynarr_new (struct prop_block);
|
|
1238
|
|
1239 pb.type = PROP_CHAR;
|
|
1240 pb.data.p_char.ch = data->ch;
|
|
1241 pb.data.p_char.cursor_type = data->cursor_type;
|
|
1242 Dynarr_add (prop, pb);
|
|
1243 }
|
|
1244
|
|
1245 data->cursor_type = old_cursor_type;
|
|
1246 return prop;
|
|
1247 }
|
|
1248 else
|
|
1249 {
|
|
1250 return add_octal_runes (data);
|
|
1251 }
|
|
1252 }
|
|
1253
|
|
1254 /* Given a display table entry, call the appropriate functions to
|
|
1255 display each element of the entry. */
|
|
1256
|
|
1257 static prop_block_dynarr *
|
|
1258 add_disp_table_entry_runes (pos_data *data, Lisp_Object entry)
|
|
1259 {
|
|
1260 prop_block_dynarr *prop = NULL;
|
|
1261
|
|
1262 if (VECTORP (entry))
|
|
1263 {
|
|
1264 struct Lisp_Vector *de = XVECTOR (entry);
|
|
1265 long len = vector_length (de);
|
|
1266 int elt;
|
|
1267
|
|
1268 for (elt = 0; elt < len; elt++)
|
|
1269 {
|
|
1270 if (NILP (de->contents[elt]))
|
|
1271 continue;
|
|
1272 else if (STRINGP (de->contents[elt]))
|
|
1273 {
|
|
1274 prop =
|
|
1275 add_bufbyte_string_runes
|
|
1276 (data,
|
16
|
1277 XSTRING_DATA (de->contents[elt]),
|
|
1278 XSTRING_LENGTH (de->contents[elt]),
|
0
|
1279 0);
|
|
1280 }
|
|
1281 else if (GLYPHP (de->contents[elt]))
|
|
1282 {
|
|
1283 if (data->start_col)
|
|
1284 data->start_col--;
|
|
1285
|
|
1286 if (!data->start_col && data->bi_start_col_enabled)
|
|
1287 {
|
|
1288 prop = add_hscroll_rune (data);
|
|
1289 }
|
|
1290 else
|
|
1291 {
|
|
1292 struct glyph_block gb;
|
|
1293
|
|
1294 gb.glyph = de->contents[elt];
|
|
1295 gb.extent = Qnil;
|
|
1296 prop = add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0);
|
|
1297 }
|
|
1298 }
|
|
1299 else if (CHAR_OR_CHAR_INTP (de->contents[elt]))
|
|
1300 {
|
|
1301 data->ch = XCHAR_OR_CHAR_INT (de->contents[elt]);
|
|
1302 prop = add_emchar_rune (data);
|
|
1303 }
|
|
1304 /* Else blow it off because someone added a bad entry and we
|
|
1305 don't have any safe way of signaling an error. */
|
|
1306
|
|
1307 /* #### Still need to add any remaining elements to the
|
|
1308 propagation information. */
|
|
1309 if (prop)
|
|
1310 return prop;
|
|
1311 }
|
|
1312 }
|
|
1313 else if (STRINGP (entry))
|
|
1314 {
|
|
1315 prop = add_bufbyte_string_runes (data,
|
16
|
1316 XSTRING_DATA (entry),
|
|
1317 XSTRING_LENGTH (entry),
|
0
|
1318 0);
|
|
1319 }
|
|
1320 else if (GLYPHP (entry))
|
|
1321 {
|
|
1322 if (data->start_col)
|
|
1323 data->start_col--;
|
|
1324
|
|
1325 if (!data->start_col && data->bi_start_col_enabled)
|
|
1326 {
|
|
1327 prop = add_hscroll_rune (data);
|
|
1328 }
|
|
1329 else
|
|
1330 {
|
|
1331 struct glyph_block gb;
|
|
1332
|
|
1333 gb.glyph = entry;
|
|
1334 gb.extent = Qnil;
|
|
1335 prop = add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0);
|
|
1336 }
|
|
1337 }
|
|
1338 else if (CHAR_OR_CHAR_INTP (entry))
|
|
1339 {
|
|
1340 data->ch = XCHAR_OR_CHAR_INT (entry);
|
|
1341 prop = add_emchar_rune (data);
|
|
1342 }
|
|
1343
|
|
1344 /* Else blow it off because someone added a bad entry and we don't
|
|
1345 have any safe way of signaling an error. Hey, this comment
|
|
1346 sounds familiar. */
|
|
1347 return prop;
|
|
1348 }
|
|
1349
|
|
1350 /* Add runes which were propagated from the previous line. */
|
|
1351
|
|
1352 static prop_block_dynarr *
|
|
1353 add_propagation_runes (prop_block_dynarr **prop, pos_data *data)
|
|
1354 {
|
|
1355 /* #### Remember to handle start_col parameter of data when the rest of
|
|
1356 this is finished. */
|
|
1357 /* #### Chuck -- I've redone this function a bit. It looked like the
|
|
1358 case of not all the propagation blocks being added was not handled
|
|
1359 well. */
|
|
1360 /* #### Chuck -- I also think the double indirection of PROP is kind
|
|
1361 of bogus. A cleaner solution is just to check for
|
|
1362 Dynarr_length (prop) > 0. */
|
|
1363 /* #### This function also doesn't even pay attention to ADD_FAILED!
|
|
1364 This is seriously fucked! Seven ####'s in 130 lines -- is that a
|
|
1365 record? */
|
|
1366 int elt;
|
|
1367 prop_block_dynarr *add_failed;
|
|
1368 Bytind bi_old_cursor_bufpos = data->bi_cursor_bufpos;
|
|
1369 unsigned int old_cursor_type = data->cursor_type;
|
|
1370
|
|
1371 for (elt = 0; elt < Dynarr_length (*prop); elt++)
|
|
1372 {
|
|
1373 struct prop_block *pb = Dynarr_atp (*prop, elt);
|
|
1374
|
|
1375 switch (pb->type)
|
|
1376 {
|
|
1377 case PROP_CHAR:
|
|
1378 data->ch = pb->data.p_char.ch;
|
|
1379 data->bi_cursor_bufpos = pb->data.p_char.bi_cursor_bufpos;
|
|
1380 data->cursor_type = pb->data.p_char.cursor_type;
|
|
1381 add_failed = add_emchar_rune (data);
|
|
1382
|
|
1383 if (add_failed)
|
|
1384 goto oops_no_more_space;
|
|
1385 break;
|
|
1386 case PROP_STRING:
|
|
1387 if (pb->data.p_string.str)
|
|
1388 xfree (pb->data.p_string.str);
|
|
1389 /* #### bogus bogus -- this doesn't do anything!
|
|
1390 Should probably call add_bufbyte_string_runes(),
|
|
1391 once that function is fixed. */
|
|
1392 break;
|
|
1393 case PROP_MINIBUF_PROMPT:
|
|
1394 {
|
|
1395 face_index old_findex = data->findex;
|
|
1396 Bytind bi_old_bufpos = data->bi_bufpos;
|
|
1397
|
|
1398 data->findex = DEFAULT_INDEX;
|
|
1399 data->bi_bufpos = 0;
|
|
1400 data->cursor_type = NO_CURSOR;
|
|
1401
|
|
1402 while (pb->data.p_string.len > 0)
|
|
1403 {
|
|
1404 data->ch = charptr_emchar (pb->data.p_string.str);
|
|
1405 add_failed = add_emchar_rune (data);
|
|
1406
|
|
1407 if (add_failed)
|
|
1408 {
|
|
1409 data->findex = old_findex;
|
|
1410 data->bi_bufpos = bi_old_bufpos;
|
|
1411 goto oops_no_more_space;
|
|
1412 }
|
|
1413 else
|
|
1414 {
|
|
1415 /* Complicated equivalent of ptr++, len-- */
|
|
1416 Bufbyte *oldpos = pb->data.p_string.str;
|
|
1417 INC_CHARPTR (pb->data.p_string.str);
|
|
1418 pb->data.p_string.len -= pb->data.p_string.str - oldpos;
|
|
1419 }
|
|
1420 }
|
|
1421
|
|
1422 data->findex = old_findex;
|
|
1423 /* ##### FIXME FIXME FIXME -- Upon successful return from
|
|
1424 this function, data->bi_bufpos is automatically incremented.
|
|
1425 However, we don't want that to happen if we were adding
|
|
1426 the minibuffer prompt. */
|
|
1427 {
|
|
1428 struct buffer *buf =
|
|
1429 XBUFFER (WINDOW_BUFFER (XWINDOW (data->window)));
|
|
1430 /* #### Chuck fix this shit or I'm gonna scream! */
|
|
1431 if (bi_old_bufpos > BI_BUF_BEGV (buf))
|
|
1432 data->bi_bufpos = prev_bytind (buf, bi_old_bufpos);
|
|
1433 else
|
|
1434 /* #### is this correct? Does anyone know?
|
|
1435 Does anyone care? Is this a cheesy hack or what? */
|
|
1436 data->bi_bufpos = BI_BUF_BEGV (buf) - 1;
|
|
1437 }
|
|
1438 }
|
|
1439 break;
|
|
1440 case PROP_BLANK:
|
|
1441 {
|
|
1442 /* #### I think it's unnecessary and misleading to preserve
|
|
1443 the blank_width, as it implies that the value carries
|
|
1444 over from one rune to the next, which is wrong. */
|
|
1445 int old_width = data->blank_width;
|
|
1446 face_index old_findex = data->findex;
|
|
1447
|
|
1448 data->findex = pb->data.p_blank.findex;
|
|
1449 data->blank_width = pb->data.p_blank.width;
|
|
1450 data->bi_cursor_bufpos = 0;
|
|
1451 data->cursor_type = IGNORE_CURSOR;
|
|
1452
|
|
1453 if (data->pixpos + data->blank_width > data->max_pixpos)
|
|
1454 data->blank_width = data->max_pixpos - data->pixpos;
|
|
1455
|
|
1456 /* We pass a bogus value of char_tab_width. It shouldn't
|
|
1457 matter because unless something is really screwed up
|
|
1458 this call won't cause that arg to be used. */
|
|
1459 add_failed = add_blank_rune (data, XWINDOW (data->window), 0);
|
|
1460
|
|
1461 /* This can happen in the case where we have a tab which
|
|
1462 is wider than the window. */
|
|
1463 if (data->blank_width != pb->data.p_blank.width)
|
|
1464 {
|
|
1465 pb->data.p_blank.width -= data->blank_width;
|
|
1466 add_failed = ADD_FAILED;
|
|
1467 }
|
|
1468
|
|
1469 data->findex = old_findex;
|
|
1470 data->blank_width = old_width;
|
|
1471
|
|
1472 if (add_failed)
|
|
1473 goto oops_no_more_space;
|
|
1474 }
|
|
1475 break;
|
|
1476 default:
|
|
1477 abort ();
|
|
1478 }
|
|
1479 }
|
|
1480
|
|
1481 oops_no_more_space:
|
|
1482
|
|
1483 data->bi_cursor_bufpos = bi_old_cursor_bufpos;
|
|
1484 data->cursor_type = old_cursor_type;
|
|
1485 if (elt < Dynarr_length (*prop))
|
|
1486 {
|
|
1487 Dynarr_delete_many (*prop, 0, elt);
|
|
1488 return *prop;
|
|
1489 }
|
|
1490 else
|
|
1491 {
|
|
1492 Dynarr_free (*prop);
|
|
1493 return NULL;
|
|
1494 }
|
|
1495 }
|
|
1496
|
|
1497 /* Add 'text layout glyphs at position POS_TYPE that are contained to
|
|
1498 the display block, but add all other types to the appropriate list
|
|
1499 of the display line. They will be added later by different
|
|
1500 routines. */
|
|
1501
|
|
1502 static prop_block_dynarr *
|
|
1503 add_glyph_rune (pos_data *data, struct glyph_block *gb, int pos_type,
|
|
1504 int allow_cursor, struct glyph_cachel *cachel)
|
|
1505 {
|
|
1506 struct window *w = XWINDOW (data->window);
|
|
1507
|
|
1508 /* A nil extent indicates a special glyph (ex. truncator). */
|
|
1509 if (NILP (gb->extent)
|
|
1510 || (pos_type == BEGIN_GLYPHS &&
|
|
1511 extent_begin_glyph_layout (XEXTENT (gb->extent)) == GL_TEXT)
|
|
1512 || (pos_type == END_GLYPHS &&
|
|
1513 extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_TEXT))
|
|
1514 {
|
|
1515 struct rune rb;
|
|
1516 int width;
|
|
1517 int xoffset = 0;
|
|
1518 int ascent, descent;
|
|
1519 Lisp_Object baseline;
|
|
1520 Lisp_Object face;
|
|
1521
|
|
1522 if (cachel)
|
|
1523 width = cachel->width;
|
|
1524 else
|
|
1525 width = glyph_width (gb->glyph, Qnil, data->findex, data->window);
|
|
1526
|
|
1527 if (!width)
|
|
1528 return NULL;
|
|
1529
|
|
1530 if (data->start_col)
|
|
1531 {
|
|
1532 prop_block_dynarr *retval;
|
|
1533 int glyph_char_width = width / space_width (w);
|
|
1534
|
|
1535 /* If we still have not fully scrolled horizontally after
|
|
1536 taking into account the width of the glyph, subtract its
|
|
1537 width and return. */
|
|
1538 if (glyph_char_width < data->start_col)
|
|
1539 {
|
|
1540 data->start_col -= glyph_char_width;
|
|
1541 return NULL;
|
|
1542 }
|
|
1543 else if (glyph_char_width == data->start_col)
|
|
1544 width = 0;
|
|
1545 else
|
|
1546 {
|
|
1547 xoffset = space_width (w) * data->start_col;
|
|
1548 width -= xoffset;
|
|
1549
|
|
1550 /* #### Can this happen? */
|
|
1551 if (width < 0)
|
|
1552 width = 0;
|
|
1553 }
|
|
1554
|
|
1555 data->start_col = 0;
|
|
1556 retval = add_hscroll_rune (data);
|
|
1557
|
|
1558 /* Could be caused by the handling of the hscroll rune. */
|
|
1559 if (retval != NULL || !width)
|
|
1560 return retval;
|
|
1561 }
|
|
1562 else
|
|
1563 xoffset = 0;
|
|
1564
|
|
1565 if (data->pixpos + width > data->max_pixpos)
|
|
1566 {
|
|
1567 /* If this is the first object we are attempting to add to
|
|
1568 the line then we ignore the horizontal_clip threshold.
|
|
1569 Otherwise we will loop until the bottom of the window
|
|
1570 continually failing to add this glyph because it is wider
|
|
1571 than the window. We could alternatively just completely
|
|
1572 ignore the glyph and proceed from there but I think that
|
|
1573 this is a better solution. */
|
|
1574 if (Dynarr_length (data->db->runes)
|
|
1575 && data->max_pixpos - data->pixpos < horizontal_clip)
|
|
1576 return ADD_FAILED;
|
|
1577 else
|
|
1578 width = data->max_pixpos - data->pixpos;
|
|
1579 }
|
|
1580
|
|
1581 if (cachel)
|
|
1582 {
|
|
1583 ascent = cachel->ascent;
|
|
1584 descent = cachel->descent;
|
|
1585 }
|
|
1586 else
|
|
1587 {
|
|
1588 ascent = glyph_ascent (gb->glyph, Qnil, data->findex, data->window);
|
|
1589 descent = glyph_descent (gb->glyph, Qnil, data->findex,
|
|
1590 data->window);
|
|
1591 }
|
|
1592
|
|
1593 baseline = glyph_baseline (gb->glyph, data->window);
|
|
1594
|
|
1595 if (glyph_contrib_p (gb->glyph, data->window))
|
|
1596 {
|
|
1597 /* A pixmap that has not had a baseline explicitly set. Its
|
|
1598 contribution will be determined later. */
|
|
1599 if (NILP (baseline))
|
|
1600 {
|
|
1601 int height = ascent + descent;
|
|
1602 data->max_pixmap_height = max (data->max_pixmap_height, height);
|
|
1603 }
|
|
1604
|
|
1605 /* A string so determine contribution normally. */
|
|
1606 else if (EQ (baseline, Qt))
|
|
1607 {
|
|
1608 data->new_ascent = max (data->new_ascent, ascent);
|
|
1609 data->new_descent = max (data->new_descent, descent);
|
|
1610 }
|
|
1611
|
|
1612 /* A pixmap with an explicitly set baseline. We determine the
|
|
1613 contribution here. */
|
|
1614 else if (INTP (baseline))
|
|
1615 {
|
|
1616 int height = ascent + descent;
|
|
1617 int pix_ascent, pix_descent;
|
|
1618
|
|
1619 pix_ascent = height * XINT (baseline) / 100;
|
|
1620 pix_descent = height - pix_ascent;
|
|
1621
|
|
1622 data->new_ascent = max (data->new_ascent, pix_ascent);
|
|
1623 data->new_descent = max (data->new_descent, pix_descent);
|
|
1624 }
|
|
1625
|
|
1626 /* Otherwise something is screwed up. */
|
|
1627 else
|
|
1628 abort ();
|
|
1629 }
|
|
1630
|
|
1631 face = glyph_face (gb->glyph, data->window);
|
|
1632 if (NILP (face))
|
|
1633 rb.findex = data->findex;
|
|
1634 else
|
|
1635 rb.findex = get_builtin_face_cache_index (w, face);
|
|
1636
|
|
1637 rb.xpos = data->pixpos;
|
|
1638 rb.width = width;
|
|
1639 rb.bufpos = 0; /* glyphs are never "at" anywhere */
|
|
1640 if (data->bi_endpos)
|
|
1641 {
|
|
1642 /* #### is this necessary at all? */
|
|
1643 struct buffer *buf = XBUFFER (WINDOW_BUFFER (w));
|
|
1644 rb.endpos = bytind_to_bufpos (buf, data->bi_endpos);
|
|
1645 }
|
|
1646 else
|
|
1647 rb.endpos = 0;
|
|
1648 rb.type = RUNE_DGLYPH;
|
|
1649 /* #### Ben sez: this is way bogus if the glyph is a string.
|
|
1650 You should not make the output routines have to cope with
|
|
1651 this. The string could contain Mule characters, or non-
|
|
1652 printable characters, or characters to be passed through
|
|
1653 the display table, or non-character objects (when this gets
|
|
1654 implemented), etc. Instead, this routine here should parse
|
|
1655 the string into a series of runes. */
|
|
1656 rb.object.dglyph.glyph = gb->glyph;
|
|
1657 rb.object.dglyph.extent = gb->extent;
|
|
1658 rb.object.dglyph.xoffset = xoffset;
|
|
1659
|
|
1660 if (allow_cursor)
|
|
1661 {
|
|
1662 {
|
|
1663 struct buffer *buf = XBUFFER (WINDOW_BUFFER (w));
|
|
1664 rb.bufpos = bytind_to_bufpos (buf, data->bi_bufpos);
|
|
1665 }
|
|
1666
|
|
1667 if (data->cursor_type == CURSOR_ON)
|
|
1668 {
|
|
1669 if (data->bi_bufpos == data->bi_cursor_bufpos)
|
|
1670 {
|
|
1671 rb.cursor_type = CURSOR_ON;
|
|
1672 data->cursor_x = Dynarr_length (data->db->runes);
|
|
1673 }
|
|
1674 else
|
|
1675 rb.cursor_type = CURSOR_OFF;
|
|
1676 }
|
|
1677 else if (data->cursor_type == NEXT_CURSOR)
|
|
1678 {
|
|
1679 rb.cursor_type = CURSOR_ON;
|
|
1680 data->cursor_x = Dynarr_length (data->db->runes);
|
|
1681 data->cursor_type = NO_CURSOR;
|
|
1682 }
|
|
1683 else if (data->cursor_type == IGNORE_CURSOR)
|
|
1684 rb.cursor_type = IGNORE_CURSOR;
|
|
1685 else if (data->cursor_type == NO_CURSOR)
|
|
1686 rb.cursor_type = NO_CURSOR;
|
|
1687 else
|
|
1688 rb.cursor_type = CURSOR_OFF;
|
|
1689 }
|
|
1690 else
|
|
1691 rb.cursor_type = CURSOR_OFF;
|
|
1692
|
|
1693 Dynarr_add (data->db->runes, rb);
|
|
1694 data->pixpos += width;
|
|
1695
|
|
1696 return NULL;
|
|
1697 }
|
|
1698 else
|
|
1699 {
|
|
1700 if (!NILP (glyph_face (gb->glyph, data->window)))
|
|
1701 gb->findex =
|
|
1702 get_builtin_face_cache_index (w, glyph_face (gb->glyph,
|
|
1703 data->window));
|
|
1704 else
|
|
1705 gb->findex = data->findex;
|
|
1706
|
|
1707 if (pos_type == BEGIN_GLYPHS)
|
|
1708 {
|
|
1709 if (!data->dl->left_glyphs)
|
|
1710 data->dl->left_glyphs = Dynarr_new (struct glyph_block);
|
|
1711 Dynarr_add (data->dl->left_glyphs, *gb);
|
|
1712 return NULL;
|
|
1713 }
|
|
1714 else if (pos_type == END_GLYPHS)
|
|
1715 {
|
|
1716 if (!data->dl->right_glyphs)
|
|
1717 data->dl->right_glyphs = Dynarr_new (struct glyph_block);
|
|
1718 Dynarr_add (data->dl->right_glyphs, *gb);
|
|
1719 return NULL;
|
|
1720 }
|
|
1721 else
|
|
1722 abort (); /* there are no unknown types */
|
|
1723 }
|
|
1724
|
|
1725 return NULL; /* shut up compiler */
|
|
1726 }
|
|
1727
|
|
1728 /* Add all glyphs at position POS_TYPE that are contained in the given
|
|
1729 data. */
|
|
1730
|
|
1731 static prop_block_dynarr *
|
|
1732 add_glyph_runes (pos_data *data, int pos_type)
|
|
1733 {
|
|
1734 /* #### This still needs to handle the start_col parameter. Duh, Chuck,
|
|
1735 why didn't you just modify add_glyph_rune in the first place? */
|
|
1736 int elt;
|
|
1737 glyph_block_dynarr *glyph_arr = (pos_type == BEGIN_GLYPHS
|
|
1738 ? data->ef->begin_glyphs
|
|
1739 : data->ef->end_glyphs);
|
|
1740 prop_block_dynarr *prop;
|
|
1741
|
|
1742 for (elt = 0; elt < Dynarr_length (glyph_arr); elt++)
|
|
1743 {
|
|
1744 prop = add_glyph_rune (data, Dynarr_atp (glyph_arr, elt), pos_type, 0,
|
|
1745 0);
|
|
1746
|
|
1747 if (prop)
|
|
1748 {
|
|
1749 /* #### Add some propagation information. */
|
|
1750 return prop;
|
|
1751 }
|
|
1752 }
|
|
1753
|
|
1754 Dynarr_reset (glyph_arr);
|
|
1755
|
|
1756 return NULL;
|
|
1757 }
|
|
1758
|
|
1759 /* Given a position for a buffer in a window, ensure that the given
|
|
1760 display line DL accurately represents the text on a line starting
|
|
1761 at the given position.
|
|
1762
|
|
1763 NOTE NOTE NOTE NOTE: This function works with and returns Bytinds.
|
|
1764 You must do appropriate conversion. */
|
|
1765
|
|
1766 static Bytind
|
|
1767 create_text_block (struct window *w, struct display_line *dl,
|
|
1768 Bytind bi_start_pos, int start_col,
|
|
1769 prop_block_dynarr **prop, int type)
|
|
1770 {
|
|
1771 struct frame *f = XFRAME (w->frame);
|
|
1772 struct buffer *b = XBUFFER (w->buffer);
|
|
1773 struct device *d = XDEVICE (f->device);
|
|
1774
|
|
1775 pos_data data;
|
|
1776 struct Lisp_Vector *dt = 0;
|
|
1777
|
|
1778 /* Don't display anything in the minibuffer if this window is not on
|
|
1779 a selected frame. We consider all other windows to be active
|
|
1780 minibuffers as it simplifies the coding. */
|
|
1781 int active_minibuffer = (!MINI_WINDOW_P (w) ||
|
|
1782 (f == device_selected_frame (d)) ||
|
|
1783 is_surrogate_for_selected_frame (f));
|
|
1784
|
|
1785 int truncate_win = window_truncation_on (w);
|
|
1786 int end_glyph_width;
|
|
1787
|
|
1788 /* If the buffer's value of selective_display is an integer then
|
|
1789 only lines that start with less than selective_display columns of
|
|
1790 space will be displayed. If selective_display is t then all text
|
|
1791 after a ^M is invisible. */
|
|
1792 int selective = (INTP (b->selective_display)
|
|
1793 ? XINT (b->selective_display)
|
|
1794 : ((!NILP (b->selective_display) ? -1 : 0)));
|
|
1795
|
|
1796 /* The variable ctl-arrow allows the user to specify what characters
|
|
1797 can actually be displayed and which octal should be used for.
|
|
1798 #### This variable should probably have some rethought done to
|
|
1799 it.
|
|
1800
|
|
1801 #### It would also be really nice if you could specify that
|
|
1802 the characters come out in hex instead of in octal. Mule
|
|
1803 does that by adding a ctl-hexa variable similar to ctl-arrow,
|
|
1804 but that's bogus -- we need a more general solution. I
|
|
1805 think you need to extend the concept of display tables
|
|
1806 into a more general conversion mechanism. Ideally you
|
|
1807 could specify a Lisp function that converts characters,
|
|
1808 but this violates the Second Golden Rule and besides would
|
|
1809 make things way way way way slow. An idea I like is to
|
|
1810 be able to specify multiple display tables instead of just
|
|
1811 one. Each display table can specify conversions for some
|
|
1812 characters and leave others unchanged. The way the
|
|
1813 character gets displayed is determined by the first display
|
|
1814 table with a binding for that character. This way, you
|
|
1815 could call a function `enable-hex-display' that adds a
|
|
1816 pre-defined hex display-table (or maybe computes one if
|
|
1817 you give weird parameters to the function) and adds it
|
|
1818 to the list of display tables for the current buffer.
|
|
1819
|
|
1820 Unfortunately there are still problems dealing with Mule
|
|
1821 characters. For example, maybe I want to specify that
|
|
1822 all extended characters (i.e. >= 256) are displayed in hex.
|
|
1823 It's not reasonable to create a mapping for all possible
|
|
1824 such characters, because there are about 2^19 of them.
|
|
1825 One way of dealing with this is to extend the concept
|
|
1826 of what a display table is. Currently it's only allowed
|
|
1827 to be a 256-entry vector. Instead, it should be something
|
|
1828 like:
|
|
1829
|
|
1830 a) A 256-entry vector, for backward compatibility
|
|
1831 b) Some sort of hashtable, mapping characters to values
|
|
1832 c) A list that specifies a range of values and the
|
|
1833 mapping to provide for those values.
|
|
1834
|
|
1835 Also, extend the concept of "mapping" to include a
|
|
1836 printf-like spec. Then, you could make all extended
|
|
1837 characters show up as hex with a display table like
|
|
1838
|
|
1839 ((256 . 524288) . "%x")
|
|
1840
|
|
1841 Since more than one display table is possible, you have
|
|
1842 great flexibility in mapping ranges of characters.
|
|
1843 */
|
|
1844 Emchar printable_min = (CHAR_OR_CHAR_INTP (b->ctl_arrow)
|
|
1845 ? XCHAR_OR_CHAR_INT (b->ctl_arrow)
|
|
1846 : ((EQ (b->ctl_arrow, Qt) || EQ (b->ctl_arrow, Qnil))
|
|
1847 ? 255 : 160));
|
|
1848
|
|
1849 /* The text display block for this display line. */
|
|
1850 struct display_block *db = get_display_block_from_line (dl, TEXT);
|
|
1851
|
|
1852 /* The first time through the main loop we need to force the glyph
|
|
1853 data to be updated. */
|
|
1854 int initial = 1;
|
|
1855
|
|
1856 /* Apparently the new extent_fragment_update returns an end position
|
|
1857 equal to the position passed in if there are no more runs to be
|
|
1858 displayed. */
|
|
1859 int no_more_frags = 0;
|
|
1860
|
|
1861 Lisp_Object synch_minibuffers_value =
|
|
1862 symbol_value_in_buffer (Qsynchronize_minibuffers, w->buffer);
|
|
1863
|
|
1864 dl->used_prop_data = 0;
|
|
1865 dl->num_chars = 0;
|
|
1866
|
|
1867 memset (&data, 0, sizeof (data));
|
|
1868 data.ef = extent_fragment_new (w->buffer, f);
|
|
1869
|
|
1870 /* These values are used by all of the rune addition routines. We add
|
|
1871 them to this structure for ease of passing. */
|
|
1872 data.d = d;
|
|
1873 XSETWINDOW (data.window, w);
|
|
1874 data.db = db;
|
|
1875 data.dl = dl;
|
|
1876
|
|
1877 data.bi_bufpos = bi_start_pos;
|
|
1878 data.pixpos = dl->bounds.left_in;
|
|
1879 data.last_charset = Qunbound;
|
|
1880 data.result_str = Qnil;
|
|
1881
|
|
1882 /* Set the right boundary adjusting it to take into account any end
|
|
1883 glyph. Save the width of the end glyph for later use. */
|
|
1884 data.max_pixpos = dl->bounds.right_in;
|
|
1885 if (truncate_win)
|
|
1886 end_glyph_width = GLYPH_CACHEL_WIDTH (w, TRUN_GLYPH_INDEX);
|
|
1887 else
|
|
1888 end_glyph_width = GLYPH_CACHEL_WIDTH (w, CONT_GLYPH_INDEX);
|
|
1889 data.max_pixpos -= end_glyph_width;
|
|
1890
|
|
1891 if (cursor_in_echo_area)
|
|
1892 {
|
|
1893 if (MINI_WINDOW_P (w) && echo_area_active (f))
|
|
1894 {
|
|
1895 data.bi_cursor_bufpos = BI_BUF_ZV (b);
|
|
1896 data.cursor_type = CURSOR_ON;
|
|
1897 }
|
|
1898 else
|
|
1899 data.cursor_type = NO_CURSOR;
|
|
1900 }
|
|
1901 else if (MINI_WINDOW_P (w) && !active_minibuffer)
|
|
1902 data.cursor_type = NO_CURSOR;
|
70
|
1903 else if (w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))))
|
0
|
1904 {
|
|
1905 data.bi_cursor_bufpos = BI_BUF_PT (b);
|
|
1906 data.cursor_type = CURSOR_ON;
|
|
1907 }
|
|
1908 else if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
|
1909 {
|
|
1910 data.bi_cursor_bufpos = bi_marker_position (w->pointm[type]);
|
|
1911 data.cursor_type = CURSOR_ON;
|
|
1912 }
|
|
1913 else
|
|
1914 data.cursor_type = NO_CURSOR;
|
|
1915 data.cursor_x = -1;
|
|
1916
|
|
1917 data.start_col = w->hscroll;
|
|
1918 data.bi_start_col_enabled = (w->hscroll ? bi_start_pos : 0);
|
|
1919
|
|
1920 /* We regenerate the line from the very beginning. */
|
|
1921 Dynarr_reset (db->runes);
|
|
1922
|
|
1923 /* Why is this less than or equal and not just less than? If the
|
|
1924 starting position is already equal to the maximum we can't add
|
|
1925 anything else, right? Wrong. We might still have a newline to
|
|
1926 add. A newline can use the room allocated for an end glyph since
|
|
1927 if we add it we know we aren't going to be adding any end
|
|
1928 glyph. */
|
|
1929
|
|
1930 /* #### Chuck -- I think this condition should be while (1).
|
|
1931 Otherwise if (e.g.) there is one begin-glyph and one end-glyph
|
|
1932 and the begin-glyph ends exactly at the end of the window, the
|
|
1933 end-glyph and text might not be displayed. while (1) ensures
|
|
1934 that the loop terminates only when either (a) there is
|
|
1935 propagation data or (b) the end-of-line or end-of-buffer is hit.
|
|
1936
|
|
1937 #### Also I think you need to ensure that the operation
|
|
1938 "add begin glyphs; add end glyphs; add text" is atomic and
|
|
1939 can't get interrupted in the middle. If you run off the end
|
|
1940 of the line during that operation, then you keep accumulating
|
|
1941 propagation data until you're done. Otherwise, if the (e.g.)
|
|
1942 there's a begin glyph at a particular position and attempting
|
|
1943 to display that glyph results in window-end being hit and
|
|
1944 propagation data being generated, then the character at that
|
|
1945 position won't be displayed.
|
|
1946
|
|
1947 #### See also the comment after the end of this loop, below.
|
|
1948 */
|
|
1949 while (data.pixpos <= data.max_pixpos
|
|
1950 && (active_minibuffer || !NILP (synch_minibuffers_value)))
|
|
1951 {
|
|
1952 /* #### This check probably should not be necessary. */
|
|
1953 if (data.bi_bufpos > BI_BUF_ZV (b))
|
|
1954 {
|
|
1955 /* #### urk! More of this lossage! */
|
|
1956 data.bi_bufpos--;
|
|
1957 goto done;
|
|
1958 }
|
|
1959
|
|
1960 /* If selective display was an integer and we aren't working on
|
|
1961 a continuation line then find the next line we are actually
|
|
1962 supposed to display. */
|
|
1963 if (selective > 0
|
|
1964 && (data.bi_bufpos == BI_BUF_BEGV (b)
|
|
1965 || BUF_FETCH_CHAR (b, prev_bytind (b, data.bi_bufpos)) == '\n'))
|
|
1966 {
|
|
1967 while (bi_spaces_at_point (b, data.bi_bufpos) >= selective)
|
|
1968 {
|
|
1969 data.bi_bufpos =
|
|
1970 bi_find_next_newline_no_quit (b, data.bi_bufpos, 1);
|
|
1971 if (data.bi_bufpos >= BI_BUF_ZV (b))
|
|
1972 {
|
|
1973 data.bi_bufpos = BI_BUF_ZV (b);
|
|
1974 goto done;
|
|
1975 }
|
|
1976 }
|
|
1977 }
|
|
1978
|
|
1979 /* Check for face changes. */
|
|
1980 if (initial || (!no_more_frags && data.bi_bufpos == data.ef->end))
|
|
1981 {
|
|
1982 /* Now compute the face and begin/end-glyph information. */
|
|
1983 data.findex =
|
|
1984 /* Remember that the extent-fragment routines deal in Bytind's. */
|
|
1985 extent_fragment_update (w, data.ef, data.bi_bufpos);
|
|
1986
|
|
1987 if (data.bi_bufpos == data.ef->end)
|
|
1988 no_more_frags = 1;
|
|
1989
|
|
1990 dt = get_display_table (w, data.findex);
|
|
1991 }
|
|
1992 initial = 0;
|
|
1993
|
|
1994 /* Determine what is next to be displayed. We first handle any
|
|
1995 glyphs returned by glyphs_at_bufpos. If there are no glyphs to
|
|
1996 display then we determine what to do based on the character at the
|
|
1997 current buffer position. */
|
|
1998
|
|
1999 /* If the current position is covered by an invisible extent, do
|
|
2000 nothing (except maybe add some ellipses).
|
|
2001
|
|
2002 #### The behavior of begin and end-glyphs at the edge of an
|
|
2003 invisible extent should be investigated further. This is
|
|
2004 fairly low priority though. */
|
|
2005 if (data.ef->invisible)
|
|
2006 {
|
|
2007 /* #### Chuck, perhaps you could look at this code? I don't
|
|
2008 really know what I'm doing. */
|
|
2009 if (*prop)
|
|
2010 {
|
|
2011 Dynarr_free (*prop);
|
|
2012 *prop = 0;
|
|
2013 }
|
|
2014
|
|
2015 /* The extent fragment code only sets this when we should
|
|
2016 really display the ellipses. It makes sure the ellipses
|
|
2017 don't get displayed more than once in a row. */
|
|
2018 if (data.ef->invisible_ellipses)
|
|
2019 {
|
|
2020 struct glyph_block gb;
|
|
2021
|
|
2022 data.ef->invisible_ellipses_already_displayed = 1;
|
|
2023 data.ef->invisible_ellipses = 0;
|
|
2024 gb.extent = Qnil;
|
|
2025 gb.glyph = Vinvisible_text_glyph;
|
|
2026 *prop = add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0,
|
|
2027 GLYPH_CACHEL (w, INVIS_GLYPH_INDEX));
|
|
2028 /* Perhaps they shouldn't propagate if the very next thing
|
|
2029 is to display a newline (for compatibility with
|
|
2030 selective-display-ellipses)? Maybe that's too
|
|
2031 abstruse. */
|
|
2032 if (*prop)
|
|
2033 goto done;
|
|
2034 }
|
|
2035
|
|
2036 /* If point is in an invisible region we place it on the
|
|
2037 next visible character. */
|
|
2038 if (data.cursor_type == CURSOR_ON
|
|
2039 && data.bi_bufpos == data.bi_cursor_bufpos)
|
|
2040 {
|
|
2041 data.cursor_type = NEXT_CURSOR;
|
|
2042 }
|
|
2043
|
|
2044 /* #### What if we we're dealing with a display table? */
|
|
2045 if (data.start_col)
|
|
2046 data.start_col--;
|
|
2047
|
|
2048 if (data.bi_bufpos == BI_BUF_ZV (b))
|
|
2049 goto done;
|
|
2050 else
|
|
2051 INC_BYTIND (b, data.bi_bufpos);
|
|
2052 }
|
|
2053
|
|
2054 /* If there is propagation data, then it represents the current
|
|
2055 buffer position being displayed. Add them and advance the
|
|
2056 position counter. This might also add the minibuffer
|
|
2057 prompt. */
|
|
2058 else if (*prop)
|
|
2059 {
|
|
2060 dl->used_prop_data = 1;
|
|
2061 *prop = add_propagation_runes (prop, &data);
|
|
2062
|
|
2063 if (*prop)
|
|
2064 goto done; /* gee, a really narrow window */
|
|
2065 else if (data.bi_bufpos == BI_BUF_ZV (b))
|
|
2066 goto done;
|
|
2067 else if (data.bi_bufpos < BI_BUF_BEGV (b))
|
|
2068 /* #### urk urk urk! Aborts are not very fun! Fix this please! */
|
|
2069 data.bi_bufpos = BI_BUF_BEGV (b);
|
|
2070 else
|
|
2071 INC_BYTIND (b, data.bi_bufpos);
|
|
2072 }
|
|
2073
|
|
2074 /* If there are end glyphs, add them to the line. These are
|
|
2075 the end glyphs for the previous run of text. We add them
|
|
2076 here rather than doing them at the end of handling the
|
|
2077 previous run so that glyphs at the beginning and end of
|
|
2078 a line are handled correctly. */
|
|
2079 else if (Dynarr_length (data.ef->end_glyphs) > 0)
|
|
2080 {
|
|
2081 *prop = add_glyph_runes (&data, END_GLYPHS);
|
|
2082 if (*prop)
|
|
2083 goto done;
|
|
2084 }
|
|
2085
|
|
2086 /* If there are begin glyphs, add them to the line. */
|
|
2087 else if (Dynarr_length (data.ef->begin_glyphs) > 0)
|
|
2088 {
|
|
2089 *prop = add_glyph_runes (&data, BEGIN_GLYPHS);
|
|
2090 if (*prop)
|
|
2091 goto done;
|
|
2092 }
|
|
2093
|
|
2094 /* If at end-of-buffer, we've already processed begin and
|
|
2095 end-glyphs at this point and there's no text to process,
|
|
2096 so we're done. */
|
|
2097 else if (data.bi_bufpos == BI_BUF_ZV (b))
|
|
2098 goto done;
|
|
2099
|
|
2100 else
|
|
2101 {
|
|
2102 /* Get the character at the current buffer position. */
|
|
2103 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_bufpos);
|
|
2104
|
|
2105 /* If there is a display table entry for it, hand it off to
|
|
2106 add_disp_table_entry_runes and let it worry about it. */
|
|
2107 if (dt && !NILP (DISP_CHAR_ENTRY (dt, data.ch)))
|
|
2108 {
|
|
2109 *prop =
|
|
2110 add_disp_table_entry_runes (&data,
|
|
2111 DISP_CHAR_ENTRY (dt, data.ch));
|
|
2112
|
|
2113 if (*prop)
|
|
2114 goto done;
|
|
2115 }
|
|
2116
|
|
2117 /* Check if we have hit a newline character. If so, add a marker
|
|
2118 to the line and end this loop. */
|
|
2119 else if (data.ch == '\n')
|
|
2120 {
|
|
2121 /* We aren't going to be adding an end glyph so give its
|
|
2122 space back in order to make sure that the cursor can
|
|
2123 fit. */
|
|
2124 data.max_pixpos += end_glyph_width;
|
|
2125
|
|
2126 if (selective > 0
|
|
2127 && (bi_spaces_at_point
|
|
2128 (b, next_bytind (b, data.bi_bufpos))
|
|
2129 >= selective))
|
|
2130 {
|
|
2131 if (!NILP (b->selective_display_ellipses))
|
|
2132 {
|
|
2133 struct glyph_block gb;
|
|
2134
|
|
2135 gb.extent = Qnil;
|
|
2136 gb.glyph = Vinvisible_text_glyph;
|
|
2137 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0,
|
|
2138 GLYPH_CACHEL (w, INVIS_GLYPH_INDEX));
|
|
2139 }
|
|
2140 else
|
|
2141 {
|
|
2142 /* Cheesy, cheesy, cheesy. We mark the end of the
|
|
2143 line with a special "character rune" whose width
|
|
2144 is the EOL cursor width and whose character is
|
|
2145 the non-printing character '\n'. */
|
|
2146 data.blank_width = DEVMETH (d, eol_cursor_width, ());
|
|
2147 *prop = add_emchar_rune (&data);
|
|
2148 }
|
|
2149
|
|
2150 /* We need to set data.bi_bufpos to the start of the
|
|
2151 next visible region in order to make this line
|
|
2152 appear to contain all of the invisible area.
|
|
2153 Otherwise, the line cache won't work
|
|
2154 correctly. */
|
|
2155 INC_BYTIND (b, data.bi_bufpos);
|
|
2156 while (bi_spaces_at_point (b, data.bi_bufpos) >= selective)
|
|
2157 {
|
|
2158 data.bi_bufpos =
|
|
2159 bi_find_next_newline_no_quit (b, data.bi_bufpos, 1);
|
|
2160 if (data.bi_bufpos >= BI_BUF_ZV (b))
|
|
2161 {
|
|
2162 data.bi_bufpos = BI_BUF_ZV (b);
|
|
2163 break;
|
|
2164 }
|
|
2165 }
|
|
2166 if (BI_BUF_FETCH_CHAR
|
|
2167 (b, prev_bytind (b, data.bi_bufpos)) == '\n')
|
|
2168 DEC_BYTIND (b, data.bi_bufpos);
|
|
2169 }
|
|
2170 else
|
|
2171 {
|
|
2172 data.blank_width = DEVMETH (d, eol_cursor_width, ());
|
|
2173 *prop = add_emchar_rune (&data);
|
|
2174 }
|
|
2175
|
|
2176 goto done;
|
|
2177 }
|
|
2178
|
|
2179 /* If the current character is ^M, and selective display is
|
|
2180 enabled, then add the invisible-text-glyph if
|
|
2181 selective-display-ellipses is set. In any case, this
|
|
2182 line is done. */
|
|
2183 else if (data.ch == (('M' & 037)) && selective == -1)
|
|
2184 {
|
|
2185 Bytind bi_next_bufpos;
|
|
2186
|
|
2187 /* Find the buffer position at the end of the line. */
|
|
2188 bi_next_bufpos =
|
|
2189 bi_find_next_newline_no_quit (b, data.bi_bufpos, 1);
|
|
2190 if (BI_BUF_FETCH_CHAR (b, prev_bytind (b, bi_next_bufpos))
|
|
2191 == '\n')
|
|
2192 DEC_BYTIND (b, bi_next_bufpos);
|
|
2193
|
|
2194 /* If the cursor is somewhere in the elided text make
|
|
2195 sure that the cursor gets drawn appropriately. */
|
|
2196 if (data.cursor_type == CURSOR_ON
|
|
2197 && (data.bi_cursor_bufpos >= data.bi_bufpos &&
|
|
2198 data.bi_cursor_bufpos < bi_next_bufpos))
|
|
2199 {
|
|
2200 data.cursor_type = NEXT_CURSOR;
|
|
2201 }
|
|
2202
|
|
2203 /* We won't be adding a truncation or continuation glyph
|
|
2204 so give up the room allocated for them. */
|
|
2205 data.max_pixpos += end_glyph_width;
|
|
2206
|
|
2207 if (!NILP (b->selective_display_ellipses))
|
|
2208 {
|
|
2209 /* We don't propagate anything from the invisible
|
|
2210 text glyph if it fails to fit. This is
|
|
2211 intentional. */
|
|
2212 struct glyph_block gb;
|
|
2213
|
|
2214 gb.extent = Qnil;
|
|
2215 gb.glyph = Vinvisible_text_glyph;
|
|
2216 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 1,
|
|
2217 GLYPH_CACHEL (w, INVIS_GLYPH_INDEX));
|
|
2218 }
|
|
2219
|
|
2220 /* Set the buffer position to the end of the line. We
|
|
2221 need to do this before potentially adding a newline
|
|
2222 so that the cursor flag will get set correctly (if
|
|
2223 needed). */
|
|
2224 data.bi_bufpos = bi_next_bufpos;
|
|
2225
|
|
2226 if (NILP (b->selective_display_ellipses)
|
|
2227 || data.bi_cursor_bufpos == bi_next_bufpos)
|
|
2228 {
|
|
2229 /* We have to at least add a newline character so
|
|
2230 that the cursor shows up properly. */
|
|
2231 data.ch = '\n';
|
|
2232 data.blank_width = DEVMETH (d, eol_cursor_width, ());
|
|
2233 data.findex = DEFAULT_INDEX;
|
|
2234 data.start_col = 0;
|
|
2235 data.bi_start_col_enabled = 0;
|
|
2236
|
|
2237 add_emchar_rune (&data);
|
|
2238 }
|
|
2239
|
|
2240 /* This had better be a newline but doing it this way
|
|
2241 we'll see obvious incorrect results if it isn't. No
|
|
2242 need to abort here. */
|
|
2243 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_bufpos);
|
|
2244
|
|
2245 goto done;
|
|
2246 }
|
|
2247
|
|
2248 /* If the current character is considered to be printable, then
|
|
2249 just add it. */
|
|
2250 else if (data.ch >= printable_min)
|
|
2251 {
|
|
2252 *prop = add_emchar_rune (&data);
|
|
2253 if (*prop)
|
|
2254 goto done;
|
|
2255 }
|
|
2256
|
|
2257 /* If the current character is a tab, determine the next tab
|
|
2258 starting position and add a blank rune which extends from the
|
|
2259 current pixel position to that starting position. */
|
|
2260 else if (data.ch == '\t')
|
|
2261 {
|
|
2262 int tab_start_pixpos = data.pixpos;
|
|
2263 int next_tab_start;
|
|
2264 int char_tab_width;
|
|
2265 int prop_width = 0;
|
|
2266
|
|
2267 if (data.start_col > 1)
|
|
2268 tab_start_pixpos -= (space_width (w) * (data.start_col - 1));
|
|
2269
|
|
2270 next_tab_start = next_tab_position (w, tab_start_pixpos,
|
|
2271 dl->bounds.left_in);
|
|
2272 if (next_tab_start > data.max_pixpos)
|
|
2273 {
|
|
2274 prop_width = next_tab_start - data.max_pixpos;
|
|
2275 next_tab_start = data.max_pixpos;
|
|
2276 }
|
|
2277 data.blank_width = next_tab_start - data.pixpos;
|
|
2278 char_tab_width =
|
|
2279 (next_tab_start - tab_start_pixpos) / space_width (w);
|
|
2280
|
|
2281 *prop = add_blank_rune (&data, w, char_tab_width);
|
|
2282
|
|
2283 /* add_blank_rune is only supposed to be called with
|
|
2284 sizes guaranteed to fit in the available space. */
|
|
2285 assert (!(*prop));
|
|
2286
|
|
2287 if (prop_width)
|
|
2288 {
|
|
2289 struct prop_block pb;
|
|
2290 *prop = Dynarr_new (struct prop_block);
|
|
2291
|
|
2292 pb.type = PROP_BLANK;
|
|
2293 pb.data.p_blank.width = prop_width;
|
|
2294 pb.data.p_blank.findex = data.findex;
|
|
2295 Dynarr_add (*prop, pb);
|
|
2296
|
|
2297 goto done;
|
|
2298 }
|
|
2299 }
|
|
2300
|
|
2301 /* If character is a control character, pass it off to
|
|
2302 add_control_char_runes.
|
|
2303
|
|
2304 The is_*() routines have undefined results on
|
|
2305 arguments outside of the range [-1, 255]. (This
|
|
2306 often bites people who carelessly use `char' instead
|
|
2307 of `unsigned char'.)
|
|
2308 */
|
|
2309 else if (data.ch < 0x100 && iscntrl ((Bufbyte) data.ch))
|
|
2310 {
|
|
2311 *prop = add_control_char_runes (&data, b);
|
|
2312
|
|
2313 if (*prop)
|
|
2314 goto done;
|
|
2315 }
|
|
2316
|
|
2317 /* If the character is above the ASCII range and we have not
|
|
2318 already handled it, then print it as an octal number. */
|
|
2319 else if (data.ch >= 0200)
|
|
2320 {
|
|
2321 *prop = add_octal_runes (&data);
|
|
2322
|
|
2323 if (*prop)
|
|
2324 goto done;
|
|
2325 }
|
|
2326
|
|
2327 /* Assume the current character is considered to be printable,
|
|
2328 then just add it. */
|
|
2329 else
|
|
2330 {
|
|
2331 *prop = add_emchar_rune (&data);
|
|
2332 if (*prop)
|
|
2333 goto done;
|
|
2334 }
|
|
2335
|
|
2336 INC_BYTIND (b, data.bi_bufpos);
|
|
2337 }
|
|
2338 }
|
|
2339
|
|
2340 done:
|
|
2341
|
|
2342 /* Determine the starting point of the next line if we did not hit the
|
|
2343 end of the buffer. */
|
|
2344 if (data.bi_bufpos < BI_BUF_ZV (b)
|
|
2345 && (active_minibuffer || !NILP (synch_minibuffers_value)))
|
|
2346 {
|
|
2347 /* #### This check is not correct. If the line terminated
|
|
2348 due to a begin-glyph or end-glyph hitting window-end, then
|
|
2349 data.ch will not point to the character at data.bi_bufpos. If
|
|
2350 you make the two changes mentioned at the top of this loop,
|
|
2351 you should be able to say '(if (*prop))'. That should also
|
|
2352 make it possible to eliminate the data.bi_bufpos < BI_BUF_ZV (b)
|
|
2353 check. */
|
|
2354
|
|
2355 /* The common case is that the line ended because we hit a newline.
|
|
2356 In that case, the next character is just the next buffer
|
|
2357 position. */
|
|
2358 if (data.ch == '\n')
|
|
2359 {
|
|
2360 /* If data.start_col_enabled is still true, then the window is
|
|
2361 scrolled far enough so that nothing on this line is visible.
|
|
2362 We need to stick a trunctation glyph at the beginning of the
|
|
2363 line in that case unless the line is completely blank. */
|
|
2364 if (data.bi_start_col_enabled)
|
|
2365 {
|
|
2366 if (data.cursor_type == CURSOR_ON)
|
|
2367 {
|
|
2368 if (data.bi_cursor_bufpos >= bi_start_pos
|
|
2369 && data.bi_cursor_bufpos <= data.bi_bufpos)
|
|
2370 data.bi_cursor_bufpos = data.bi_bufpos;
|
|
2371 }
|
|
2372 data.findex = DEFAULT_INDEX;
|
|
2373 data.start_col = 0;
|
|
2374 data.bi_start_col_enabled = 0;
|
|
2375
|
|
2376 if (data.bi_bufpos != bi_start_pos)
|
|
2377 {
|
|
2378 struct glyph_block gb;
|
|
2379
|
|
2380 gb.extent = Qnil;
|
|
2381 gb.glyph = Vhscroll_glyph;
|
|
2382 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0,
|
|
2383 GLYPH_CACHEL (w, HSCROLL_GLYPH_INDEX));
|
|
2384 }
|
|
2385 else
|
|
2386 {
|
|
2387 /* This duplicates code down below to add a newline to
|
|
2388 the end of an otherwise empty line.*/
|
|
2389 data.ch = '\n';
|
|
2390 data.blank_width = DEVMETH (d, eol_cursor_width, ());
|
|
2391
|
|
2392 add_emchar_rune (&data);
|
|
2393 }
|
|
2394 }
|
|
2395
|
|
2396 INC_BYTIND (b, data.bi_bufpos);
|
|
2397 }
|
|
2398
|
|
2399 /* Otherwise we have a buffer line which cannot fit on one display
|
|
2400 line. */
|
|
2401 else
|
|
2402 {
|
|
2403 struct glyph_block gb;
|
|
2404 struct glyph_cachel *cachel;
|
|
2405
|
|
2406 /* If the line is to be truncated then we actually have to look
|
|
2407 for the next newline. We also add the end-of-line glyph which
|
|
2408 we know will fit because we adjusted the right border before
|
|
2409 we starting laying out the line. */
|
|
2410 data.max_pixpos += end_glyph_width;
|
|
2411 data.findex = DEFAULT_INDEX;
|
|
2412 gb.extent = Qnil;
|
|
2413
|
|
2414 if (truncate_win)
|
|
2415 {
|
|
2416 Bytind bi_pos;
|
|
2417
|
|
2418 /* Now find the start of the next line. */
|
|
2419 bi_pos = bi_find_next_newline_no_quit (b, data.bi_bufpos, 1);
|
|
2420
|
|
2421 /* If the cursor is past the truncation line then we
|
|
2422 make it appear on the truncation glyph. If we've hit
|
|
2423 the end of the buffer then we also make the cursor
|
70
|
2424 appear unless eob is immediately preceeded by a
|
0
|
2425 newline. In that case the cursor should actually
|
|
2426 appear on the next line. */
|
|
2427 if (data.cursor_type == CURSOR_ON
|
|
2428 && data.bi_cursor_bufpos >= data.bi_bufpos
|
|
2429 && (data.bi_cursor_bufpos < bi_pos ||
|
|
2430 (bi_pos == BI_BUF_ZV (b)
|
|
2431 && (bi_pos == BI_BUF_BEGV (b)
|
|
2432 || (BI_BUF_FETCH_CHAR (b, prev_bytind (b, bi_pos))
|
|
2433 != '\n')))))
|
|
2434 data.bi_cursor_bufpos = bi_pos;
|
|
2435 else
|
|
2436 data.cursor_type = NO_CURSOR;
|
|
2437
|
|
2438 data.bi_bufpos = bi_pos;
|
|
2439 gb.glyph = Vtruncation_glyph;
|
|
2440 cachel = GLYPH_CACHEL (w, TRUN_GLYPH_INDEX);
|
|
2441 }
|
|
2442 else
|
|
2443 {
|
|
2444 /* The cursor can never be on the continuation glyph. */
|
|
2445 data.cursor_type = NO_CURSOR;
|
|
2446
|
|
2447 /* data.bi_bufpos is already at the start of the next line. */
|
|
2448
|
|
2449 gb.glyph = Vcontinuation_glyph;
|
|
2450 cachel = GLYPH_CACHEL (w, CONT_GLYPH_INDEX);
|
|
2451 }
|
|
2452
|
|
2453 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 1, cachel);
|
|
2454
|
|
2455 if (truncate_win && data.bi_bufpos == BI_BUF_ZV (b)
|
|
2456 && BI_BUF_FETCH_CHAR (b, prev_bytind (b, BI_BUF_ZV (b))) != '\n')
|
|
2457 /* #### Damn this losing shit. */
|
|
2458 data.bi_bufpos++;
|
|
2459 }
|
|
2460 }
|
|
2461 else if ((active_minibuffer || !NILP (synch_minibuffers_value))
|
|
2462 && (!echo_area_active (f) || data.bi_bufpos == BI_BUF_ZV (b)))
|
|
2463 {
|
|
2464 /* We need to add a marker to the end of the line since there is no
|
|
2465 newline character in order for the cursor to get drawn. We label
|
|
2466 it as a newline so that it gets handled correctly by the
|
|
2467 whitespace routines below. */
|
|
2468
|
|
2469 data.ch = '\n';
|
|
2470 data.blank_width = DEVMETH (d, eol_cursor_width, ());
|
|
2471 data.findex = DEFAULT_INDEX;
|
|
2472 data.start_col = 0;
|
|
2473 data.bi_start_col_enabled = 0;
|
|
2474
|
|
2475 data.max_pixpos += data.blank_width;
|
|
2476 add_emchar_rune (&data);
|
|
2477 data.max_pixpos -= data.blank_width;
|
|
2478
|
|
2479 /* #### urk! Chuck, this shit is bad news. Going around
|
|
2480 manipulating invalid positions is guaranteed to result in
|
|
2481 trouble sooner or later. */
|
|
2482 data.bi_bufpos = BI_BUF_ZV (b) + 1;
|
|
2483 }
|
|
2484
|
|
2485 /* Calculate left whitespace boundary. */
|
|
2486 {
|
|
2487 int elt = 0;
|
|
2488
|
|
2489 /* Whitespace past a newline is considered right whitespace. */
|
|
2490 while (elt < Dynarr_length (db->runes))
|
|
2491 {
|
|
2492 struct rune *rb = Dynarr_atp (db->runes, elt);
|
|
2493
|
|
2494 if ((rb->type == RUNE_CHAR && rb->object.chr.ch == ' ')
|
|
2495 || rb->type == RUNE_BLANK)
|
|
2496 {
|
|
2497 dl->bounds.left_white += rb->width;
|
|
2498 elt++;
|
|
2499 }
|
|
2500 else
|
|
2501 elt = Dynarr_length (db->runes);
|
|
2502 }
|
|
2503 }
|
|
2504
|
|
2505 /* Calculate right whitespace boundary. */
|
|
2506 {
|
|
2507 int elt = Dynarr_length (db->runes) - 1;
|
|
2508 int done = 0;
|
|
2509
|
|
2510 while (!done && elt >= 0)
|
|
2511 {
|
|
2512 struct rune *rb = Dynarr_atp (db->runes, elt);
|
|
2513
|
|
2514 if (!(rb->type == RUNE_CHAR && rb->object.chr.ch < 0x100
|
|
2515 && isspace (rb->object.chr.ch))
|
|
2516 && !rb->type == RUNE_BLANK)
|
|
2517 {
|
|
2518 dl->bounds.right_white = rb->xpos + rb->width;
|
|
2519 done = 1;
|
|
2520 }
|
|
2521
|
|
2522 elt--;
|
|
2523
|
|
2524 }
|
|
2525
|
|
2526 /* The line is blank so everything is considered to be right
|
|
2527 whitespace. */
|
|
2528 if (!done)
|
|
2529 dl->bounds.right_white = dl->bounds.left_in;
|
|
2530 }
|
|
2531
|
|
2532 /* Set the display blocks bounds. */
|
|
2533 db->start_pos = dl->bounds.left_in;
|
|
2534 if (Dynarr_length (db->runes))
|
|
2535 {
|
|
2536 struct rune *rb = Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
|
|
2537
|
|
2538 db->end_pos = rb->xpos + rb->width;
|
|
2539 }
|
|
2540 else
|
|
2541 db->end_pos = dl->bounds.right_white;
|
|
2542
|
|
2543 /* update line height parameters */
|
|
2544 if (!data.new_ascent && !data.new_descent)
|
|
2545 {
|
|
2546 /* We've got a blank line so initialize these values from the default
|
|
2547 face. */
|
|
2548 default_face_font_info (data.window, &data.new_ascent,
|
|
2549 &data.new_descent, 0, 0, 0);
|
|
2550 }
|
|
2551
|
|
2552 if (data.max_pixmap_height)
|
|
2553 {
|
|
2554 int height = data.new_ascent + data.new_descent;
|
|
2555 int pix_ascent, pix_descent;
|
|
2556
|
|
2557 pix_descent = data.max_pixmap_height * data.new_descent / height;
|
|
2558 pix_ascent = data.max_pixmap_height - pix_descent;
|
|
2559
|
|
2560 data.new_ascent = max (data.new_ascent, pix_ascent);
|
|
2561 data.new_descent = max (data.new_descent, pix_descent);
|
|
2562 }
|
|
2563
|
|
2564 dl->ascent = data.new_ascent;
|
|
2565 dl->descent = data.new_descent;
|
|
2566
|
|
2567 {
|
|
2568 unsigned short ascent = (unsigned short) XINT (w->minimum_line_ascent);
|
|
2569
|
|
2570 if (dl->ascent < ascent)
|
|
2571 dl->ascent = ascent;
|
|
2572 }
|
|
2573 {
|
|
2574 unsigned short descent = (unsigned short) XINT (w->minimum_line_descent);
|
|
2575
|
|
2576 if (dl->descent < descent)
|
|
2577 dl->descent = descent;
|
|
2578 }
|
|
2579
|
|
2580 dl->cursor_elt = data.cursor_x;
|
|
2581 /* #### lossage lossage lossage! Fix this shit! */
|
|
2582 if (data.bi_bufpos > BI_BUF_ZV (b))
|
|
2583 dl->end_bufpos = BUF_ZV (b);
|
|
2584 else
|
|
2585 dl->end_bufpos = bytind_to_bufpos (b, data.bi_bufpos) - 1;
|
|
2586 if (truncate_win)
|
|
2587 data.dl->num_chars = column_at_point (b, dl->end_bufpos, 0);
|
|
2588 else
|
|
2589 /* This doesn't correctly take into account tabs and control
|
|
2590 characters but if the window isn't being truncated then this
|
|
2591 value isn't going to end up being used anyhow. */
|
|
2592 data.dl->num_chars = dl->end_bufpos - dl->bufpos;
|
|
2593
|
|
2594 /* #### handle horizontally scrolled line with text none of which
|
|
2595 was actually laid out. */
|
|
2596
|
|
2597 /* #### handle any remainder of overlay arrow */
|
|
2598
|
|
2599 if (*prop == ADD_FAILED)
|
|
2600 *prop = NULL;
|
|
2601
|
|
2602 if (truncate_win && *prop)
|
|
2603 {
|
|
2604 Dynarr_free (*prop);
|
|
2605 *prop = NULL;
|
|
2606 }
|
|
2607
|
|
2608 extent_fragment_delete (data.ef);
|
|
2609
|
|
2610 /* #### If we started at EOB, then make sure we return a value past
|
|
2611 it so that regenerate_window will exit properly. This is bogus.
|
|
2612 The main loop should get fixed so that it isn't necessary to call
|
|
2613 this function if we are already at EOB. */
|
|
2614
|
|
2615 if (data.bi_bufpos == BI_BUF_ZV (b) && bi_start_pos == BI_BUF_ZV (b))
|
|
2616 return (data.bi_bufpos + 1); /* Yuck! */
|
|
2617 else
|
|
2618 return data.bi_bufpos;
|
|
2619 }
|
|
2620
|
|
2621 /* Display the overlay arrow at the beginning of the given line. */
|
|
2622
|
|
2623 static int
|
|
2624 create_overlay_glyph_block (struct window *w, struct display_line *dl)
|
|
2625 {
|
|
2626 struct frame *f = XFRAME (w->frame);
|
|
2627 struct device *d = XDEVICE (f->device);
|
|
2628 pos_data data;
|
|
2629
|
|
2630 /* If Voverlay_arrow_string isn't valid then just fail silently. */
|
|
2631 if (!STRINGP (Voverlay_arrow_string) && !GLYPHP (Voverlay_arrow_string))
|
|
2632 return 0;
|
|
2633
|
|
2634 memset (&data, 0, sizeof (data));
|
|
2635 data.ef = NULL;
|
|
2636 data.d = d;
|
|
2637 XSETWINDOW (data.window, w);
|
|
2638 data.db = get_display_block_from_line (dl, OVERWRITE);
|
|
2639 data.dl = dl;
|
|
2640 data.pixpos = dl->bounds.left_in;
|
|
2641 data.max_pixpos = dl->bounds.right_in;
|
|
2642 data.cursor_type = NO_CURSOR;
|
|
2643 data.cursor_x = -1;
|
|
2644 data.findex = DEFAULT_INDEX;
|
|
2645 data.last_charset = Qunbound;
|
|
2646 data.result_str = Qnil;
|
|
2647
|
|
2648 Dynarr_reset (data.db->runes);
|
|
2649
|
|
2650 if (STRINGP (Voverlay_arrow_string))
|
|
2651 {
|
|
2652 add_bufbyte_string_runes
|
|
2653 (&data,
|
16
|
2654 XSTRING_DATA (Voverlay_arrow_string),
|
|
2655 XSTRING_LENGTH (Voverlay_arrow_string),
|
0
|
2656 1);
|
|
2657 }
|
|
2658 else if (GLYPHP (Voverlay_arrow_string))
|
|
2659 {
|
|
2660 struct glyph_block gb;
|
|
2661
|
|
2662 gb.glyph = Voverlay_arrow_string;
|
|
2663 gb.extent = Qnil;
|
|
2664 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0, 0);
|
|
2665 }
|
|
2666
|
|
2667 if (data.max_pixmap_height)
|
|
2668 {
|
|
2669 int height = data.new_ascent + data.new_descent;
|
|
2670 int pix_ascent, pix_descent;
|
|
2671
|
|
2672 pix_descent = data.max_pixmap_height * data.new_descent / height;
|
|
2673 pix_ascent = data.max_pixmap_height - pix_descent;
|
|
2674
|
|
2675 data.new_ascent = max (data.new_ascent, pix_ascent);
|
|
2676 data.new_descent = max (data.new_descent, pix_descent);
|
|
2677 }
|
|
2678
|
|
2679 dl->ascent = data.new_ascent;
|
|
2680 dl->descent = data.new_descent;
|
|
2681
|
|
2682 data.db->start_pos = dl->bounds.left_in;
|
|
2683 data.db->end_pos = data.pixpos;
|
|
2684
|
|
2685 return (data.pixpos - dl->bounds.left_in);
|
|
2686 }
|
|
2687
|
|
2688 /* Add a type of glyph to a margin display block. */
|
|
2689
|
|
2690 static int
|
|
2691 add_margin_runes (struct display_line *dl, struct display_block *db, int start,
|
|
2692 int count, int glyph_type, int side, Lisp_Object window)
|
|
2693 {
|
|
2694 glyph_block_dynarr *gbd = (side == LEFT_GLYPHS
|
|
2695 ? dl->left_glyphs
|
|
2696 : dl->right_glyphs);
|
|
2697 int elt, end;
|
|
2698 int xpos = start;
|
|
2699 int reverse;
|
|
2700
|
|
2701 if ((glyph_type == GL_WHITESPACE && side == LEFT_GLYPHS)
|
|
2702 || (glyph_type == GL_INSIDE_MARGIN && side == RIGHT_GLYPHS))
|
|
2703 {
|
|
2704 reverse = 1;
|
|
2705 elt = Dynarr_length (gbd) - 1;
|
|
2706 end = 0;
|
|
2707 }
|
|
2708 else
|
|
2709 {
|
|
2710 reverse = 0;
|
|
2711 elt = 0;
|
|
2712 end = Dynarr_length (gbd);
|
|
2713 }
|
|
2714
|
|
2715 while (count && ((!reverse && elt < end) || (reverse && elt >= end)))
|
|
2716 {
|
|
2717 struct glyph_block *gb = Dynarr_atp (gbd, elt);
|
|
2718
|
|
2719 if (NILP (gb->extent))
|
|
2720 abort (); /* these should have been handled in add_glyph_rune */
|
|
2721
|
|
2722 if (gb->active &&
|
|
2723 ((side == LEFT_GLYPHS &&
|
|
2724 extent_begin_glyph_layout (XEXTENT (gb->extent)) == glyph_type)
|
|
2725 || (side == RIGHT_GLYPHS &&
|
|
2726 extent_end_glyph_layout (XEXTENT (gb->extent)) == glyph_type)))
|
|
2727 {
|
|
2728 struct rune rb;
|
|
2729
|
|
2730 rb.width = gb->width;
|
|
2731 rb.findex = gb->findex;
|
|
2732 rb.xpos = xpos;
|
|
2733 rb.bufpos = -1;
|
|
2734 rb.endpos = 0;
|
|
2735 rb.type = RUNE_DGLYPH;
|
|
2736 rb.object.dglyph.glyph = gb->glyph;
|
|
2737 rb.object.dglyph.extent = gb->extent;
|
|
2738 rb.object.dglyph.xoffset = 0;
|
|
2739 rb.cursor_type = CURSOR_OFF;
|
|
2740
|
|
2741 Dynarr_add (db->runes, rb);
|
|
2742 xpos += rb.width;
|
|
2743 count--;
|
|
2744 gb->active = 0;
|
|
2745
|
|
2746 if (glyph_contrib_p (gb->glyph, window))
|
|
2747 {
|
|
2748 unsigned short ascent, descent;
|
|
2749 Lisp_Object baseline = glyph_baseline (gb->glyph, window);
|
|
2750
|
|
2751 ascent = glyph_ascent (gb->glyph, Qnil, gb->findex, window);
|
|
2752 descent = glyph_descent (gb->glyph, Qnil, gb->findex, window);
|
|
2753
|
|
2754 /* A pixmap that has not had a baseline explicitly set.
|
|
2755 We use the existing ascent / descent ratio of the
|
|
2756 line. */
|
|
2757 if (NILP (baseline))
|
|
2758 {
|
|
2759 int gheight = ascent + descent;
|
|
2760 int line_height = dl->ascent + dl->descent;
|
|
2761 int pix_ascent, pix_descent;
|
|
2762
|
|
2763 pix_descent = (int) (gheight * dl->descent) / line_height;
|
|
2764 pix_ascent = gheight - pix_descent;
|
|
2765
|
|
2766 dl->ascent = max ((int) dl->ascent, pix_ascent);
|
|
2767 dl->descent = max ((int) dl->descent, pix_descent);
|
|
2768 }
|
|
2769
|
|
2770 /* A string so determine contribution normally. */
|
|
2771 else if (EQ (baseline, Qt))
|
|
2772 {
|
|
2773 dl->ascent = max (dl->ascent, ascent);
|
|
2774 dl->descent = max (dl->descent, descent);
|
|
2775 }
|
|
2776
|
|
2777 /* A pixmap with an explicitly set baseline. We determine the
|
|
2778 contribution here. */
|
|
2779 else if (INTP (baseline))
|
|
2780 {
|
|
2781 int height = ascent + descent;
|
|
2782 int pix_ascent, pix_descent;
|
|
2783
|
|
2784 pix_ascent = height * XINT (baseline) / 100;
|
|
2785 pix_descent = height - pix_ascent;
|
|
2786
|
|
2787 dl->ascent = max ((int) dl->ascent, pix_ascent);
|
|
2788 dl->descent = max ((int) dl->descent, pix_descent);
|
|
2789 }
|
|
2790
|
|
2791 /* Otherwise something is screwed up. */
|
|
2792 else
|
|
2793 abort ();
|
|
2794 }
|
|
2795 }
|
|
2796
|
|
2797 (reverse ? elt-- : elt++);
|
|
2798 }
|
|
2799
|
|
2800 return xpos;
|
|
2801 }
|
|
2802
|
|
2803 /* Add a blank to a margin display block. */
|
|
2804
|
|
2805 static void
|
|
2806 add_margin_blank (struct display_line *dl, struct display_block *db,
|
|
2807 struct window *w, int xpos, int width, int side)
|
|
2808 {
|
|
2809 struct rune rb;
|
|
2810
|
|
2811 rb.findex = (side == LEFT_GLYPHS
|
|
2812 ? get_builtin_face_cache_index (w, Vleft_margin_face)
|
|
2813 : get_builtin_face_cache_index (w, Vright_margin_face));
|
|
2814 rb.xpos = xpos;
|
|
2815 rb.width = width;
|
|
2816 rb.bufpos = -1;
|
|
2817 rb.endpos = 0;
|
|
2818 rb.type = RUNE_BLANK;
|
|
2819 rb.cursor_type = CURSOR_OFF;
|
|
2820
|
|
2821 Dynarr_add (db->runes, rb);
|
|
2822 }
|
|
2823
|
|
2824 /* Display glyphs in the left outside margin, left inside margin and
|
|
2825 left whitespace area. */
|
|
2826
|
|
2827 static void
|
|
2828 create_left_glyph_block (struct window *w, struct display_line *dl,
|
|
2829 int overlay_width)
|
|
2830 {
|
|
2831 Lisp_Object window;
|
|
2832
|
|
2833 int use_overflow = (NILP (w->use_left_overflow) ? 0 : 1);
|
|
2834 int elt, end_xpos;
|
|
2835 int out_end, in_out_start, in_in_end, white_out_start, white_in_start;
|
|
2836 int out_cnt, in_out_cnt, in_in_cnt, white_out_cnt, white_in_cnt;
|
|
2837 int left_in_start = dl->bounds.left_in;
|
|
2838 int left_in_end = dl->bounds.left_in + overlay_width;
|
|
2839
|
|
2840 struct display_block *odb, *idb;
|
|
2841
|
|
2842 XSETWINDOW (window, w);
|
|
2843
|
|
2844 /* We have to add the glyphs to the line in the order outside,
|
|
2845 inside, whitespace. However the precedence dictates that we
|
|
2846 determine how many will fit in the reverse order. */
|
|
2847
|
|
2848 /* Determine how many whitespace glyphs we can display and where
|
|
2849 they should start. */
|
|
2850 white_in_start = dl->bounds.left_white;
|
|
2851 white_out_start = left_in_start;
|
|
2852 white_out_cnt = white_in_cnt = 0;
|
|
2853 elt = 0;
|
|
2854
|
|
2855 while (elt < Dynarr_length (dl->left_glyphs))
|
|
2856 {
|
|
2857 struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
|
|
2858
|
|
2859 if (NILP (gb->extent))
|
|
2860 abort (); /* these should have been handled in add_glyph_rune */
|
|
2861
|
|
2862 if (extent_begin_glyph_layout (XEXTENT (gb->extent)) == GL_WHITESPACE)
|
|
2863 {
|
|
2864 int width;
|
|
2865
|
|
2866 width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
2867
|
|
2868 if (white_in_start - width >= left_in_end)
|
|
2869 {
|
|
2870 white_in_cnt++;
|
|
2871 white_in_start -= width;
|
|
2872 gb->width = width;
|
|
2873 gb->active = 1;
|
|
2874 }
|
|
2875 else if (use_overflow
|
|
2876 && (white_out_start - width > dl->bounds.left_out))
|
|
2877 {
|
|
2878 white_out_cnt++;
|
|
2879 white_out_start -= width;
|
|
2880 gb->width = width;
|
|
2881 gb->active = 1;
|
|
2882 }
|
|
2883 else
|
|
2884 gb->active = 0;
|
|
2885 }
|
|
2886
|
|
2887 elt++;
|
|
2888 }
|
|
2889
|
|
2890 /* Determine how many inside margin glyphs we can display and where
|
|
2891 they should start. The inside margin glyphs get whatever space
|
|
2892 is left after the whitespace glyphs have been displayed. These
|
|
2893 are tricky to calculate since if we decide to use the overflow
|
|
2894 area we basicaly have to start over. So for these we build up a
|
|
2895 list of just the inside margin glyphs and manipulate it to
|
|
2896 determine the needed info. */
|
|
2897 {
|
|
2898 glyph_block_dynarr *ib;
|
|
2899 int avail_in, avail_out;
|
|
2900 int done = 0;
|
|
2901 int marker = 0;
|
|
2902 int used_in, used_out;
|
|
2903
|
|
2904 elt = 0;
|
|
2905 used_in = used_out = 0;
|
|
2906 ib = Dynarr_new (struct glyph_block);
|
|
2907 while (elt < Dynarr_length (dl->left_glyphs))
|
|
2908 {
|
|
2909 struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
|
|
2910
|
|
2911 if (NILP (gb->extent))
|
|
2912 abort (); /* these should have been handled in add_glyph_rune */
|
|
2913
|
|
2914 if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
|
|
2915 GL_INSIDE_MARGIN)
|
|
2916 {
|
|
2917 gb->width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
2918 used_in += gb->width;
|
|
2919 Dynarr_add (ib, *gb);
|
|
2920 }
|
|
2921
|
|
2922 elt++;
|
|
2923 }
|
|
2924
|
|
2925 if (white_out_cnt)
|
|
2926 avail_in = 0;
|
|
2927 else
|
|
2928 {
|
|
2929 avail_in = white_in_start - left_in_end;
|
|
2930 if (avail_in < 0)
|
|
2931 avail_in = 0;
|
|
2932 }
|
|
2933
|
|
2934 if (!use_overflow)
|
|
2935 avail_out = 0;
|
|
2936 else
|
|
2937 avail_out = white_out_start - dl->bounds.left_out;
|
|
2938
|
|
2939 marker = 0;
|
|
2940 while (!done && marker < Dynarr_length (ib))
|
|
2941 {
|
|
2942 int width = Dynarr_atp (ib, marker)->width;
|
|
2943
|
|
2944 /* If everything now fits in the available inside margin
|
|
2945 space, we're done. */
|
|
2946 if (used_in <= avail_in)
|
|
2947 done = 1;
|
|
2948 else
|
|
2949 {
|
|
2950 /* Otherwise see if we have room to move a glyph to the
|
|
2951 outside. */
|
|
2952 if (used_out + width <= avail_out)
|
|
2953 {
|
|
2954 used_out += width;
|
|
2955 used_in -= width;
|
|
2956 }
|
|
2957 else
|
|
2958 done = 1;
|
|
2959 }
|
|
2960
|
|
2961 if (!done)
|
|
2962 marker++;
|
|
2963 }
|
|
2964
|
|
2965 /* At this point we now know that everything from marker on goes in
|
|
2966 the inside margin and everything before it goes in the outside
|
|
2967 margin. The stuff going into the outside margin is guaranteed
|
|
2968 to fit, but we may have to trim some stuff from the inside. */
|
|
2969
|
|
2970 in_in_end = left_in_end;
|
|
2971 in_out_start = white_out_start;
|
|
2972 in_out_cnt = in_in_cnt = 0;
|
|
2973
|
|
2974 Dynarr_free (ib);
|
|
2975 elt = 0;
|
|
2976 while (elt < Dynarr_length (dl->left_glyphs))
|
|
2977 {
|
|
2978 struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
|
|
2979
|
|
2980 if (NILP (gb->extent))
|
|
2981 abort (); /* these should have been handled in add_glyph_rune */
|
|
2982
|
|
2983 if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
|
|
2984 GL_INSIDE_MARGIN)
|
|
2985 {
|
|
2986 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
2987
|
|
2988 if (used_out)
|
|
2989 {
|
|
2990 in_out_cnt++;
|
|
2991 in_out_start -= width;
|
|
2992 gb->width = width;
|
|
2993 gb->active = 1;
|
|
2994 used_out -= width;
|
|
2995 }
|
|
2996 else if (in_in_end + width < white_in_start)
|
|
2997 {
|
|
2998 in_in_cnt++;
|
|
2999 in_in_end += width;
|
|
3000 gb->width = width;
|
|
3001 gb->active = 1;
|
|
3002 }
|
|
3003 else
|
|
3004 gb->active = 0;
|
|
3005 }
|
|
3006
|
|
3007 elt++;
|
|
3008 }
|
|
3009 }
|
|
3010
|
|
3011 /* Determine how many outside margin glyphs we can display. They
|
|
3012 always start at the left outside margin and can only use the
|
|
3013 outside margin space. */
|
|
3014 out_end = dl->bounds.left_out;
|
|
3015 out_cnt = 0;
|
|
3016 elt = 0;
|
|
3017
|
|
3018 while (elt < Dynarr_length (dl->left_glyphs))
|
|
3019 {
|
|
3020 struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
|
|
3021
|
|
3022 if (NILP (gb->extent))
|
|
3023 abort (); /* these should have beeb handled in add_glyph_rune */
|
|
3024
|
|
3025 if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
|
|
3026 GL_OUTSIDE_MARGIN)
|
|
3027 {
|
|
3028 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
3029
|
|
3030 if (out_end + width <= in_out_start)
|
|
3031 {
|
|
3032 out_cnt++;
|
|
3033 out_end += width;
|
|
3034 gb->width = width;
|
|
3035 gb->active = 1;
|
|
3036 }
|
|
3037 else
|
|
3038 gb->active = 0;
|
|
3039 }
|
|
3040
|
|
3041 elt++;
|
|
3042 }
|
|
3043
|
|
3044 /* Now that we now where everything goes, we add the glyphs as runes
|
|
3045 to the appropriate display blocks. */
|
|
3046 if (out_cnt || in_out_cnt || white_out_cnt)
|
|
3047 {
|
|
3048 odb = get_display_block_from_line (dl, LEFT_OUTSIDE_MARGIN);
|
|
3049 odb->start_pos = dl->bounds.left_out;
|
|
3050 /* #### We should stop adding a blank to account for the space
|
|
3051 between the end of the glyphs and the margin and instead set
|
|
3052 this accordingly. */
|
|
3053 odb->end_pos = dl->bounds.left_in;
|
|
3054 Dynarr_reset (odb->runes);
|
|
3055 }
|
|
3056 else
|
|
3057 odb = 0;
|
|
3058
|
|
3059 if (in_in_cnt || white_in_cnt)
|
|
3060 {
|
|
3061 idb = get_display_block_from_line (dl, LEFT_INSIDE_MARGIN);
|
|
3062 idb->start_pos = dl->bounds.left_in;
|
|
3063 /* #### See above comment for odb->end_pos */
|
|
3064 idb->end_pos = dl->bounds.left_white;
|
|
3065 Dynarr_reset (idb->runes);
|
|
3066 }
|
|
3067 else
|
|
3068 idb = 0;
|
|
3069
|
|
3070 /* First add the outside margin glyphs. */
|
|
3071 if (out_cnt)
|
|
3072 end_xpos = add_margin_runes (dl, odb, dl->bounds.left_out, out_cnt,
|
|
3073 GL_OUTSIDE_MARGIN, LEFT_GLYPHS, window);
|
|
3074 else
|
|
3075 end_xpos = dl->bounds.left_out;
|
|
3076
|
|
3077 /* There may be blank space between the outside margin glyphs and
|
|
3078 the inside margin glyphs. If so, add a blank. */
|
|
3079 if (in_out_cnt && (in_out_start - end_xpos))
|
|
3080 {
|
|
3081 add_margin_blank (dl, odb, w, end_xpos, in_out_start - end_xpos,
|
|
3082 LEFT_GLYPHS);
|
|
3083 }
|
|
3084
|
|
3085 /* Next add the inside margin glyphs which are actually in the
|
|
3086 outside margin. */
|
|
3087 if (in_out_cnt)
|
|
3088 {
|
|
3089 end_xpos = add_margin_runes (dl, odb, in_out_start, in_out_cnt,
|
|
3090 GL_INSIDE_MARGIN, LEFT_GLYPHS, window);
|
|
3091 }
|
|
3092
|
|
3093 /* If we didn't add any inside margin glyphs to the outside margin,
|
|
3094 but are adding whitespace glyphs, then we need to add a blank
|
|
3095 here. */
|
|
3096 if (!in_out_cnt && white_out_cnt && (white_out_start - end_xpos))
|
|
3097 {
|
|
3098 add_margin_blank (dl, odb, w, end_xpos, white_out_start - end_xpos,
|
|
3099 LEFT_GLYPHS);
|
|
3100 }
|
|
3101
|
|
3102 /* Next add the whitespace margin glyphs which are actually in the
|
|
3103 outside margin. */
|
|
3104 if (white_out_cnt)
|
|
3105 {
|
|
3106 end_xpos = add_margin_runes (dl, odb, white_out_start, white_out_cnt,
|
|
3107 GL_WHITESPACE, LEFT_GLYPHS, window);
|
|
3108 }
|
|
3109
|
|
3110 /* We take care of clearing between the end of the glyphs and the
|
|
3111 start of the inside margin for lines which have glyphs. */
|
|
3112 if (odb && (left_in_start - end_xpos))
|
|
3113 {
|
|
3114 add_margin_blank (dl, odb, w, end_xpos, left_in_start - end_xpos,
|
|
3115 LEFT_GLYPHS);
|
|
3116 }
|
|
3117
|
|
3118 /* Next add the inside margin glyphs which are actually in the
|
|
3119 inside margin. */
|
|
3120 if (in_in_cnt)
|
|
3121 {
|
|
3122 end_xpos = add_margin_runes (dl, idb, left_in_end, in_in_cnt,
|
|
3123 GL_INSIDE_MARGIN, LEFT_GLYPHS, window);
|
|
3124 }
|
|
3125 else
|
|
3126 end_xpos = left_in_end;
|
|
3127
|
|
3128 /* Make sure that the area between the end of the inside margin
|
|
3129 glyphs and the whitespace glyphs is cleared. */
|
|
3130 if (idb && (white_in_start - end_xpos > 0))
|
|
3131 {
|
|
3132 add_margin_blank (dl, idb, w, end_xpos, white_in_start - end_xpos,
|
|
3133 LEFT_GLYPHS);
|
|
3134 }
|
|
3135
|
|
3136 /* Next add the whitespace margin glyphs which are actually in the
|
|
3137 inside margin. */
|
|
3138 if (white_in_cnt)
|
|
3139 {
|
|
3140 add_margin_runes (dl, idb, white_in_start, white_in_cnt, GL_WHITESPACE,
|
|
3141 LEFT_GLYPHS, window);
|
|
3142 }
|
|
3143
|
|
3144 /* Whitespace glyphs always end right next to the text block so
|
|
3145 there is nothing we have to make sure is cleared after them. */
|
|
3146 }
|
|
3147
|
|
3148 /* Display glyphs in the right outside margin, right inside margin and
|
|
3149 right whitespace area. */
|
|
3150
|
|
3151 static void
|
|
3152 create_right_glyph_block (struct window *w, struct display_line *dl)
|
|
3153 {
|
|
3154 Lisp_Object window;
|
|
3155
|
|
3156 int use_overflow = (NILP (w->use_right_overflow) ? 0 : 1);
|
|
3157 int elt, end_xpos;
|
|
3158 int out_start, in_out_end, in_in_start, white_out_end, white_in_end;
|
|
3159 int out_cnt, in_out_cnt, in_in_cnt, white_out_cnt, white_in_cnt;
|
|
3160
|
|
3161 struct display_block *odb, *idb;
|
|
3162
|
|
3163 XSETWINDOW (window, w);
|
|
3164
|
|
3165 /* We have to add the glyphs to the line in the order outside,
|
|
3166 inside, whitespace. However the precedence dictates that we
|
|
3167 determine how many will fit in the reverse order. */
|
|
3168
|
|
3169 /* Determine how many whitespace glyphs we can display and where
|
|
3170 they should start. */
|
|
3171 white_in_end = dl->bounds.right_white;
|
|
3172 white_out_end = dl->bounds.right_in;
|
|
3173 white_out_cnt = white_in_cnt = 0;
|
|
3174 elt = 0;
|
|
3175
|
|
3176 while (elt < Dynarr_length (dl->right_glyphs))
|
|
3177 {
|
|
3178 struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
|
|
3179
|
|
3180 if (NILP (gb->extent))
|
|
3181 abort (); /* these should have been handled in add_glyph_rune */
|
|
3182
|
|
3183 if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_WHITESPACE)
|
|
3184 {
|
|
3185 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
3186
|
|
3187 if (white_in_end + width <= dl->bounds.right_in)
|
|
3188 {
|
|
3189 white_in_cnt++;
|
|
3190 white_in_end += width;
|
|
3191 gb->width = width;
|
|
3192 gb->active = 1;
|
|
3193 }
|
|
3194 else if (use_overflow
|
|
3195 && (white_out_end + width <= dl->bounds.right_out))
|
|
3196 {
|
|
3197 white_out_cnt++;
|
|
3198 white_out_end += width;
|
|
3199 gb->width = width;
|
|
3200 gb->active = 1;
|
|
3201 }
|
|
3202 else
|
|
3203 gb->active = 0;
|
|
3204 }
|
|
3205
|
|
3206 elt++;
|
|
3207 }
|
|
3208
|
|
3209 /* Determine how many inside margin glyphs we can display and where
|
|
3210 they should start. The inside margin glyphs get whatever space
|
|
3211 is left after the whitespace glyphs have been displayed. These
|
|
3212 are tricky to calculate since if we decide to use the overflow
|
|
3213 area we basicaly have to start over. So for these we build up a
|
|
3214 list of just the inside margin glyphs and manipulate it to
|
|
3215 determine the needed info. */
|
|
3216 {
|
|
3217 glyph_block_dynarr *ib;
|
|
3218 int avail_in, avail_out;
|
|
3219 int done = 0;
|
|
3220 int marker = 0;
|
|
3221 int used_in, used_out;
|
|
3222
|
|
3223 elt = 0;
|
|
3224 used_in = used_out = 0;
|
|
3225 ib = Dynarr_new (struct glyph_block);
|
|
3226 while (elt < Dynarr_length (dl->right_glyphs))
|
|
3227 {
|
|
3228 struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
|
|
3229
|
|
3230 if (NILP (gb->extent))
|
|
3231 abort (); /* these should have been handled in add_glyph_rune */
|
|
3232
|
|
3233 if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_INSIDE_MARGIN)
|
|
3234 {
|
|
3235 gb->width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
3236 used_in += gb->width;
|
|
3237 Dynarr_add (ib, *gb);
|
|
3238 }
|
|
3239
|
|
3240 elt++;
|
|
3241 }
|
|
3242
|
|
3243 if (white_out_cnt)
|
|
3244 avail_in = 0;
|
|
3245 else
|
|
3246 avail_in = dl->bounds.right_in - white_in_end;
|
|
3247
|
|
3248 if (!use_overflow)
|
|
3249 avail_out = 0;
|
|
3250 else
|
|
3251 avail_out = dl->bounds.right_out - white_out_end;
|
|
3252
|
|
3253 marker = 0;
|
|
3254 while (!done && marker < Dynarr_length (ib))
|
|
3255 {
|
|
3256 int width = Dynarr_atp (ib, marker)->width;
|
|
3257
|
|
3258 /* If everything now fits in the available inside margin
|
|
3259 space, we're done. */
|
|
3260 if (used_in <= avail_in)
|
|
3261 done = 1;
|
|
3262 else
|
|
3263 {
|
|
3264 /* Otherwise see if we have room to move a glyph to the
|
|
3265 outside. */
|
|
3266 if (used_out + width <= avail_out)
|
|
3267 {
|
|
3268 used_out += width;
|
|
3269 used_in -= width;
|
|
3270 }
|
|
3271 else
|
|
3272 done = 1;
|
|
3273 }
|
|
3274
|
|
3275 if (!done)
|
|
3276 marker++;
|
|
3277 }
|
|
3278
|
|
3279 /* At this point we now know that everything from marker on goes in
|
|
3280 the inside margin and everything before it goes in the outside
|
|
3281 margin. The stuff going into the outside margin is guaranteed
|
|
3282 to fit, but we may have to trim some stuff from the inside. */
|
|
3283
|
|
3284 in_in_start = dl->bounds.right_in;
|
|
3285 in_out_end = dl->bounds.right_in;
|
|
3286 in_out_cnt = in_in_cnt = 0;
|
|
3287
|
|
3288 Dynarr_free (ib);
|
|
3289 elt = 0;
|
|
3290 while (elt < Dynarr_length (dl->right_glyphs))
|
|
3291 {
|
|
3292 struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
|
|
3293
|
|
3294 if (NILP (gb->extent))
|
|
3295 abort (); /* these should have been handled in add_glyph_rune */
|
|
3296
|
|
3297 if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_INSIDE_MARGIN)
|
|
3298 {
|
|
3299 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
3300
|
|
3301 if (used_out)
|
|
3302 {
|
|
3303 in_out_cnt++;
|
|
3304 in_out_end += width;
|
|
3305 gb->width = width;
|
|
3306 gb->active = 1;
|
|
3307 used_out -= width;
|
|
3308 }
|
|
3309 else if (in_in_start - width >= white_in_end)
|
|
3310 {
|
|
3311 in_in_cnt++;
|
|
3312 in_in_start -= width;
|
|
3313 gb->width = width;
|
|
3314 gb->active = 1;
|
|
3315 }
|
|
3316 else
|
|
3317 gb->active = 0;
|
|
3318 }
|
|
3319
|
|
3320 elt++;
|
|
3321 }
|
|
3322 }
|
|
3323
|
|
3324 /* Determine how many outside margin glyphs we can display. They
|
|
3325 always start at the right outside margin and can only use the
|
|
3326 outside margin space. */
|
|
3327 out_start = dl->bounds.right_out;
|
|
3328 out_cnt = 0;
|
|
3329 elt = 0;
|
|
3330
|
|
3331 while (elt < Dynarr_length (dl->right_glyphs))
|
|
3332 {
|
|
3333 struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
|
|
3334
|
|
3335 if (NILP (gb->extent))
|
|
3336 abort (); /* these should have beeb handled in add_glyph_rune */
|
|
3337
|
|
3338 if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_OUTSIDE_MARGIN)
|
|
3339 {
|
|
3340 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
|
|
3341
|
|
3342 if (out_start - width >= in_out_end)
|
|
3343 {
|
|
3344 out_cnt++;
|
|
3345 out_start -= width;
|
|
3346 gb->width = width;
|
|
3347 gb->active = 1;
|
|
3348 }
|
|
3349 else
|
|
3350 gb->active = 0;
|
|
3351 }
|
|
3352
|
|
3353 elt++;
|
|
3354 }
|
|
3355
|
|
3356 /* Now that we now where everything goes, we add the glyphs as runes
|
|
3357 to the appropriate display blocks. */
|
|
3358 if (out_cnt || in_out_cnt || white_out_cnt)
|
|
3359 {
|
|
3360 odb = get_display_block_from_line (dl, RIGHT_OUTSIDE_MARGIN);
|
|
3361 /* #### See comments before odb->start_pos init in
|
|
3362 create_left_glyph_block */
|
|
3363 odb->start_pos = dl->bounds.right_in;
|
|
3364 odb->end_pos = dl->bounds.right_out;
|
|
3365 Dynarr_reset (odb->runes);
|
|
3366 }
|
|
3367 else
|
|
3368 odb = 0;
|
|
3369
|
|
3370 if (in_in_cnt || white_in_cnt)
|
|
3371 {
|
|
3372 idb = get_display_block_from_line (dl, RIGHT_INSIDE_MARGIN);
|
|
3373 idb->start_pos = dl->bounds.right_white;
|
|
3374 /* #### See comments before odb->start_pos init in
|
|
3375 create_left_glyph_block */
|
|
3376 idb->end_pos = dl->bounds.right_in;
|
|
3377 Dynarr_reset (idb->runes);
|
|
3378 }
|
|
3379 else
|
|
3380 idb = 0;
|
|
3381
|
|
3382 /* First add the whitespace margin glyphs which are actually in the
|
|
3383 inside margin. */
|
|
3384 if (white_in_cnt)
|
|
3385 {
|
|
3386 end_xpos = add_margin_runes (dl, idb, dl->bounds.right_white,
|
|
3387 white_in_cnt, GL_WHITESPACE, RIGHT_GLYPHS,
|
|
3388 window);
|
|
3389 }
|
|
3390 else
|
|
3391 end_xpos = dl->bounds.right_white;
|
|
3392
|
|
3393 /* Make sure that the area between the end of the whitespace glyphs
|
|
3394 and the inside margin glyphs is cleared. */
|
|
3395 if (in_in_cnt && (in_in_start - end_xpos))
|
|
3396 {
|
|
3397 add_margin_blank (dl, idb, w, end_xpos, in_in_start - end_xpos,
|
|
3398 RIGHT_GLYPHS);
|
|
3399 }
|
|
3400
|
|
3401 /* Next add the inside margin glyphs which are actually in the
|
|
3402 inside margin. */
|
|
3403 if (in_in_cnt)
|
|
3404 {
|
|
3405 end_xpos = add_margin_runes (dl, idb, in_in_start, in_in_cnt,
|
|
3406 GL_INSIDE_MARGIN, RIGHT_GLYPHS, window);
|
|
3407 }
|
|
3408
|
|
3409 /* If we didn't add any inside margin glyphs then make sure the rest
|
|
3410 of the inside margin area gets cleared. */
|
|
3411 if (idb && (dl->bounds.right_in - end_xpos))
|
|
3412 {
|
|
3413 add_margin_blank (dl, idb, w, end_xpos, dl->bounds.right_in - end_xpos,
|
|
3414 RIGHT_GLYPHS);
|
|
3415 }
|
|
3416
|
|
3417 /* Next add any whitespace glyphs in the outside margin. */
|
|
3418 if (white_out_cnt)
|
|
3419 {
|
|
3420 end_xpos = add_margin_runes (dl, odb, dl->bounds.right_in, white_out_cnt,
|
|
3421 GL_WHITESPACE, RIGHT_GLYPHS, window);
|
|
3422 }
|
|
3423 else
|
|
3424 end_xpos = dl->bounds.right_in;
|
|
3425
|
|
3426 /* Next add any inside margin glyphs in the outside margin. */
|
|
3427 if (in_out_cnt)
|
|
3428 {
|
|
3429 end_xpos = add_margin_runes (dl, odb, end_xpos, in_out_cnt,
|
|
3430 GL_INSIDE_MARGIN, RIGHT_GLYPHS, window);
|
|
3431 }
|
|
3432
|
|
3433 /* There may be space between any whitespace or inside margin glyphs
|
|
3434 in the outside margin and the actual outside margin glyphs. */
|
|
3435 if (odb && (out_start - end_xpos))
|
|
3436 {
|
|
3437 add_margin_blank (dl, odb, w, end_xpos, out_start - end_xpos,
|
|
3438 RIGHT_GLYPHS);
|
|
3439 }
|
|
3440
|
|
3441 /* Finally, add the outside margin glyphs. */
|
|
3442 if (out_cnt)
|
|
3443 {
|
|
3444 add_margin_runes (dl, odb, out_start, out_cnt, GL_OUTSIDE_MARGIN,
|
|
3445 RIGHT_GLYPHS, window);
|
|
3446 }
|
|
3447 }
|
|
3448
|
|
3449
|
|
3450 /***************************************************************************/
|
|
3451 /* */
|
|
3452 /* modeline routines */
|
|
3453 /* */
|
|
3454 /***************************************************************************/
|
|
3455
|
|
3456 /* Ensure that the given display line DL accurately represents the
|
|
3457 modeline for the given window. */
|
|
3458
|
|
3459 static void
|
|
3460 generate_modeline (struct window *w, struct display_line *dl, int type)
|
|
3461 {
|
|
3462 struct buffer *b = XBUFFER (w->buffer);
|
|
3463 struct frame *f = XFRAME (w->frame);
|
|
3464 struct device *d = XDEVICE (f->device);
|
|
3465
|
|
3466 /* Unlike display line and rune pointers, this one can't change underneath
|
|
3467 our feet. */
|
|
3468 struct display_block *db = get_display_block_from_line (dl, TEXT);
|
|
3469 int max_pixpos, min_pixpos, ypos_adj;
|
|
3470 Lisp_Object font_inst;
|
|
3471
|
|
3472 /* This will actually determine incorrect inside boundaries for the
|
|
3473 modeline since it ignores the margins. However being aware of this fact
|
|
3474 we never use those values anywhere so it doesn't matter. */
|
|
3475 dl->bounds = calculate_display_line_boundaries (w, 1);
|
|
3476
|
|
3477 /* We are generating a modeline. */
|
|
3478 dl->modeline = 1;
|
|
3479 dl->cursor_elt = -1;
|
|
3480
|
|
3481 /* Reset the runes on the modeline. */
|
|
3482 Dynarr_reset (db->runes);
|
|
3483
|
|
3484 if (!WINDOW_HAS_MODELINE_P (w))
|
|
3485 {
|
|
3486 struct rune rb;
|
|
3487
|
|
3488 /* If there is a horizontal scrollbar, don't add anything. */
|
|
3489 if (window_scrollbar_height (w))
|
|
3490 return;
|
|
3491
|
|
3492 dl->ascent = DEVMETH (d, divider_height, ());
|
|
3493 dl->descent = 0;
|
|
3494 /* The modeline is at the bottom of the gutters. */
|
|
3495 dl->ypos = WINDOW_BOTTOM (w);
|
|
3496
|
|
3497 rb.findex = MODELINE_INDEX;
|
|
3498 rb.xpos = dl->bounds.left_out;
|
|
3499 rb.width = dl->bounds.right_out - dl->bounds.left_out;
|
|
3500 rb.bufpos = 0;
|
|
3501 rb.endpos = 0;
|
|
3502 rb.type = RUNE_HLINE;
|
|
3503 rb.object.hline.thickness = 1;
|
|
3504 rb.object.hline.yoffset = 0;
|
|
3505 rb.cursor_type = NO_CURSOR;
|
|
3506
|
|
3507 if (!EQ (Qzero, w->modeline_shadow_thickness)
|
|
3508 && FRAME_WIN_P (f))
|
|
3509 {
|
|
3510 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
3511
|
|
3512 dl->ypos -= shadow_thickness;
|
|
3513 rb.xpos += shadow_thickness;
|
|
3514 rb.width -= 2 * shadow_thickness;
|
|
3515 }
|
|
3516
|
|
3517 Dynarr_add (db->runes, rb);
|
|
3518 return;
|
|
3519 }
|
|
3520
|
|
3521 /* !!#### not right; needs to compute the max height of
|
|
3522 all the charsets */
|
|
3523 font_inst = WINDOW_FACE_CACHEL_FONT (w, MODELINE_INDEX, Vcharset_ascii);
|
|
3524
|
|
3525 dl->ascent = XFONT_INSTANCE (font_inst)->ascent;
|
|
3526 dl->descent = XFONT_INSTANCE (font_inst)->descent;
|
|
3527
|
|
3528 min_pixpos = dl->bounds.left_out;
|
|
3529 max_pixpos = dl->bounds.right_out;
|
|
3530
|
|
3531 if (!EQ (Qzero, w->modeline_shadow_thickness) && FRAME_WIN_P (f))
|
|
3532 {
|
|
3533 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
3534
|
|
3535 ypos_adj = shadow_thickness;
|
|
3536 min_pixpos += shadow_thickness;
|
|
3537 max_pixpos -= shadow_thickness;
|
|
3538 }
|
|
3539 else
|
|
3540 ypos_adj = 0;
|
|
3541
|
|
3542 generate_formatted_string_db (b->modeline_format,
|
|
3543 b->generated_modeline_string, w, dl, db,
|
|
3544 MODELINE_INDEX, min_pixpos, max_pixpos, type);
|
|
3545
|
|
3546 /* The modeline is at the bottom of the gutters. We have to wait to
|
|
3547 set this until we've generated teh modeline in order to account
|
|
3548 for any embedded faces. */
|
|
3549 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj;
|
|
3550 }
|
|
3551
|
|
3552 static void
|
|
3553 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str,
|
|
3554 struct window *w, struct display_line *dl,
|
|
3555 struct display_block *db, face_index findex,
|
|
3556 int min_pixpos, int max_pixpos, int type)
|
|
3557 {
|
|
3558 struct frame *f = XFRAME (w->frame);
|
|
3559 struct device *d = XDEVICE (f->device);
|
|
3560
|
|
3561 pos_data data;
|
|
3562 int c_pixpos;
|
|
3563
|
|
3564 memset (&data, 0, sizeof (data));
|
|
3565 data.d = d;
|
|
3566 data.db = db;
|
|
3567 data.dl = dl;
|
|
3568 data.findex = findex;
|
|
3569 data.pixpos = min_pixpos;
|
|
3570 data.max_pixpos = max_pixpos;
|
|
3571 data.cursor_type = NO_CURSOR;
|
|
3572 data.last_charset = Qunbound;
|
|
3573 data.result_str = result_str;
|
|
3574 data.is_modeline = 1;
|
|
3575 XSETWINDOW (data.window, w);
|
|
3576
|
|
3577 Dynarr_reset (formatted_string_extent_dynarr);
|
|
3578 Dynarr_reset (formatted_string_extent_start_dynarr);
|
|
3579 Dynarr_reset (formatted_string_extent_end_dynarr);
|
|
3580
|
|
3581 /* This recursively builds up the modeline. */
|
|
3582 generate_fstring_runes (w, &data, 0, 0, -1, format_str, 0,
|
|
3583 max_pixpos - min_pixpos, findex, type);
|
|
3584
|
|
3585 if (Dynarr_length (db->runes))
|
|
3586 {
|
|
3587 struct rune *rb =
|
|
3588 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
|
|
3589 c_pixpos = rb->xpos + rb->width;
|
|
3590 }
|
|
3591 else
|
|
3592 c_pixpos = min_pixpos;
|
|
3593
|
|
3594 /* If we don't reach the right side of the window, add a blank rune
|
|
3595 to make up the difference. This usually only occurs if the
|
|
3596 modeline face is using a proportional width font or a fixed width
|
|
3597 font of a different size from the default face font. */
|
|
3598
|
|
3599 if (c_pixpos < max_pixpos)
|
|
3600 {
|
|
3601 data.pixpos = c_pixpos;
|
|
3602 data.blank_width = max_pixpos - data.pixpos;
|
|
3603
|
|
3604 add_blank_rune (&data, NULL, 0);
|
|
3605 }
|
|
3606
|
|
3607 /* Now create the result string and frob the extents into it. */
|
|
3608 if (!NILP (result_str))
|
|
3609 {
|
|
3610 int elt;
|
|
3611 Bytecount len;
|
|
3612 Bufbyte *strdata;
|
|
3613 struct buffer *buf = XBUFFER (WINDOW_BUFFER (w));
|
|
3614
|
|
3615 detach_all_extents (result_str);
|
|
3616 resize_string (XSTRING (result_str), -1,
|
16
|
3617 data.bytepos - XSTRING_LENGTH (result_str));
|
|
3618
|
|
3619 strdata = XSTRING_DATA (result_str);
|
0
|
3620
|
|
3621 for (elt = 0, len = 0; elt < Dynarr_length (db->runes); elt++)
|
|
3622 {
|
|
3623 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)
|
|
3624 {
|
|
3625 len += (set_charptr_emchar
|
|
3626 (strdata + len, Dynarr_atp (db->runes,
|
|
3627 elt)->object.chr.ch));
|
|
3628 }
|
|
3629 }
|
|
3630
|
|
3631 for (elt = 0; elt < Dynarr_length (formatted_string_extent_dynarr);
|
|
3632 elt++)
|
|
3633 {
|
|
3634 Lisp_Object extent = Qnil;
|
|
3635 Lisp_Object child;
|
|
3636
|
|
3637 XSETEXTENT (extent, Dynarr_at (formatted_string_extent_dynarr, elt));
|
|
3638 child = Fgethash (extent, buf->modeline_extent_table, Qnil);
|
|
3639 if (NILP (child))
|
|
3640 {
|
|
3641 child = Fmake_extent (Qnil, Qnil, result_str);
|
|
3642 Fputhash (extent, child, buf->modeline_extent_table);
|
|
3643 }
|
|
3644 Fset_extent_parent (child, extent);
|
|
3645 set_extent_endpoints
|
|
3646 (XEXTENT (child),
|
|
3647 Dynarr_at (formatted_string_extent_start_dynarr, elt),
|
|
3648 Dynarr_at (formatted_string_extent_end_dynarr, elt),
|
|
3649 result_str);
|
|
3650 }
|
|
3651 }
|
|
3652 }
|
|
3653
|
|
3654 static Charcount
|
|
3655 add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str,
|
|
3656 Charcount pos, Charcount min, Charcount max)
|
|
3657 {
|
|
3658 /* This function has been Mule-ized. */
|
|
3659 Charcount end;
|
|
3660 CONST Bufbyte *cur_pos = str;
|
|
3661 struct display_block *db = data->db;
|
|
3662
|
|
3663 data->blank_width = space_width (XWINDOW (data->window));
|
|
3664 while (Dynarr_length (db->runes) < pos)
|
|
3665 add_blank_rune (data, NULL, 0);
|
|
3666
|
|
3667 end = (Dynarr_length (db->runes) +
|
|
3668 bytecount_to_charcount (str, strlen ((CONST char *) str)));
|
|
3669 if (max != -1)
|
|
3670 end = min (max, end);
|
|
3671
|
|
3672 while (pos < end && *cur_pos)
|
|
3673 {
|
|
3674 CONST Bufbyte *old_cur_pos = cur_pos;
|
|
3675 int succeeded;
|
|
3676
|
|
3677 data->ch = charptr_emchar (cur_pos);
|
|
3678 succeeded = (add_emchar_rune (data) != ADD_FAILED);
|
|
3679 INC_CHARPTR (cur_pos);
|
|
3680 if (succeeded)
|
|
3681 {
|
|
3682 pos++;
|
|
3683 data->modeline_charpos++;
|
|
3684 data->bytepos += cur_pos - old_cur_pos;
|
|
3685 }
|
|
3686 }
|
|
3687
|
|
3688 while (Dynarr_length (db->runes) < min &&
|
|
3689 (data->pixpos + data->blank_width <= data->max_pixpos))
|
|
3690 add_blank_rune (data, NULL, 0);
|
|
3691
|
|
3692 return Dynarr_length (db->runes);
|
|
3693 }
|
|
3694
|
|
3695 /* #### Urk! Should also handle begin-glyphs and end-glyphs in
|
|
3696 modeline extents. */
|
|
3697 static Charcount
|
|
3698 add_glyph_to_fstring_db_runes (pos_data *data, Lisp_Object glyph,
|
|
3699 Charcount pos, Charcount min, Charcount max)
|
|
3700 {
|
|
3701 /* This function has been Mule-ized. */
|
|
3702 Charcount end;
|
|
3703 struct display_block *db = data->db;
|
|
3704 struct glyph_block gb;
|
|
3705
|
|
3706 data->blank_width = space_width (XWINDOW (data->window));
|
|
3707 while (Dynarr_length (db->runes) < pos)
|
|
3708 add_blank_rune (data, NULL, 0);
|
|
3709
|
|
3710 end = Dynarr_length (db->runes) + 1;
|
|
3711 if (max != -1)
|
|
3712 end = min (max, end);
|
|
3713
|
|
3714 gb.glyph = glyph;
|
|
3715 gb.extent = Qnil;
|
|
3716 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0);
|
|
3717 pos++;
|
|
3718
|
|
3719 while (Dynarr_length (db->runes) < pos &&
|
|
3720 (data->pixpos + data->blank_width <= data->max_pixpos))
|
|
3721 add_blank_rune (data, NULL, 0);
|
|
3722
|
|
3723 return Dynarr_length (db->runes);
|
|
3724 }
|
|
3725
|
|
3726 /* If max_pos is == -1, it is considered to be infinite. The same is
|
|
3727 true of max_pixsize. */
|
|
3728 #define SET_CURRENT_MODE_CHARS_PIXSIZE \
|
|
3729 if (Dynarr_length (data->db->runes)) \
|
|
3730 cur_pixsize = data->pixpos - Dynarr_atp (data->db->runes, 0)->xpos; \
|
|
3731 else \
|
|
3732 cur_pixsize = 0;
|
|
3733
|
|
3734 /* Note that this function does "positions" in terms of characters and
|
|
3735 not in terms of columns. This is necessary to make the formatting
|
|
3736 work correctly when proportional width fonts are used in the
|
|
3737 modeline. */
|
|
3738 static Charcount
|
|
3739 generate_fstring_runes (struct window *w, pos_data *data, Charcount pos,
|
|
3740 Charcount min_pos, Charcount max_pos,
|
|
3741 Lisp_Object elt, int depth, int max_pixsize,
|
|
3742 face_index findex, int type)
|
|
3743 {
|
|
3744 /* This function has been Mule-ized. */
|
|
3745 /* #### The other losing things in this function are:
|
|
3746
|
|
3747 -- C zero-terminated-string lossage.
|
|
3748 -- Non-printable characters should be converted into something
|
|
3749 appropriate (e.g. ^F) instead of blindly being printed anyway.
|
|
3750 */
|
|
3751
|
|
3752 tail_recurse:
|
|
3753 if (depth > 10)
|
|
3754 goto invalid;
|
|
3755
|
|
3756 depth++;
|
|
3757
|
|
3758 if (STRINGP (elt))
|
|
3759 {
|
|
3760 /* A string. Add to the display line and check for %-constructs
|
|
3761 within it. */
|
|
3762
|
16
|
3763 Bufbyte *this = XSTRING_DATA (elt);
|
0
|
3764
|
|
3765 while ((pos < max_pos || max_pos == -1) && *this)
|
|
3766 {
|
|
3767 Bufbyte *last = this;
|
|
3768
|
|
3769 while (*this && *this != '%')
|
|
3770 this++;
|
|
3771
|
|
3772 if (this != last)
|
|
3773 {
|
|
3774 /* The string is just a string. */
|
|
3775 Charcount size =
|
|
3776 bytecount_to_charcount (last, this - last) + pos;
|
|
3777 Charcount tmp_max = (max_pos == -1 ? size : min (size, max_pos));
|
|
3778
|
|
3779 pos = add_string_to_fstring_db_runes (data, last, pos, pos,
|
|
3780 tmp_max);
|
|
3781 }
|
|
3782 else /* *this == '%' */
|
|
3783 {
|
|
3784 Charcount spec_width = 0;
|
|
3785
|
|
3786 this++; /* skip over '%' */
|
|
3787
|
|
3788 /* We can't allow -ve args due to the "%-" construct.
|
|
3789 * Argument specifies minwidth but not maxwidth
|
|
3790 * (maxwidth can be specified by
|
|
3791 * (<negative-number> . <stuff>) modeline elements)
|
|
3792 */
|
|
3793 while (isdigit (*this))
|
|
3794 {
|
|
3795 spec_width = spec_width * 10 + (*this - '0');
|
|
3796 this++;
|
|
3797 }
|
|
3798 spec_width += pos;
|
|
3799
|
|
3800 if (*this == 'M')
|
|
3801 {
|
|
3802 pos = generate_fstring_runes (w, data, pos, spec_width,
|
|
3803 max_pos, Vglobal_mode_string,
|
|
3804 depth, max_pixsize, findex,
|
|
3805 type);
|
|
3806 }
|
|
3807 else if (*this == '-')
|
|
3808 {
|
|
3809 Charcount num_to_add;
|
|
3810
|
|
3811 if (max_pixsize < 0)
|
|
3812 num_to_add = 0;
|
|
3813 else if (max_pos != -1)
|
|
3814 num_to_add = max_pos - pos;
|
|
3815 else
|
|
3816 {
|
|
3817 int cur_pixsize;
|
|
3818 int dash_pixsize;
|
|
3819 Bufbyte ch = '-';
|
|
3820 SET_CURRENT_MODE_CHARS_PIXSIZE;
|
|
3821
|
|
3822 dash_pixsize =
|
|
3823 redisplay_text_width_string (w, findex, &ch, Qnil, 0,
|
|
3824 1);
|
|
3825
|
|
3826 num_to_add = (max_pixsize - cur_pixsize) / dash_pixsize;
|
|
3827 num_to_add++;
|
|
3828 }
|
|
3829
|
|
3830 while (num_to_add--)
|
|
3831 pos = add_string_to_fstring_db_runes
|
|
3832 (data, (CONST Bufbyte *) "-", pos, pos, max_pos);
|
|
3833 }
|
|
3834 else if (*this != 0)
|
|
3835 {
|
|
3836 Bufbyte *str;
|
|
3837 Emchar ch = charptr_emchar (this);
|
|
3838 decode_mode_spec (w, ch, type);
|
|
3839
|
|
3840 str = Dynarr_atp (mode_spec_bufbyte_string, 0);
|
|
3841 pos = add_string_to_fstring_db_runes (data,str, pos, pos,
|
|
3842 max_pos);
|
|
3843 }
|
|
3844
|
|
3845 /* NOT this++. There could be any sort of character at
|
|
3846 the current position. */
|
|
3847 INC_CHARPTR (this);
|
|
3848 }
|
|
3849
|
|
3850 if (max_pixsize > 0)
|
|
3851 {
|
|
3852 int cur_pixsize;
|
|
3853 SET_CURRENT_MODE_CHARS_PIXSIZE;
|
|
3854
|
|
3855 if (cur_pixsize >= max_pixsize)
|
|
3856 break;
|
|
3857 }
|
|
3858 }
|
|
3859 }
|
|
3860 else if (SYMBOLP (elt))
|
|
3861 {
|
|
3862 /* A symbol: process the value of the symbol recursively
|
|
3863 as if it appeared here directly. */
|
|
3864 Lisp_Object tem = symbol_value_in_buffer (elt, w->buffer);
|
|
3865
|
|
3866 if (!UNBOUNDP (tem))
|
|
3867 {
|
|
3868 /* If value is a string, output that string literally:
|
|
3869 don't check for % within it. */
|
|
3870 if (STRINGP (tem))
|
|
3871 {
|
|
3872 pos =
|
|
3873 add_string_to_fstring_db_runes
|
16
|
3874 (data, XSTRING_DATA (tem), pos, min_pos, max_pos);
|
0
|
3875 }
|
|
3876 /* Give up right away for nil or t. */
|
|
3877 else if (!EQ (tem, elt))
|
|
3878 {
|
|
3879 elt = tem;
|
|
3880 goto tail_recurse;
|
|
3881 }
|
|
3882 }
|
|
3883 }
|
|
3884 else if (CONSP (elt))
|
|
3885 {
|
|
3886 /* A cons cell: four distinct cases.
|
|
3887 * If first element is a string or a cons, process all the elements
|
|
3888 * and effectively concatenate them.
|
|
3889 * If first element is a negative number, truncate displaying cdr to
|
|
3890 * at most that many characters. If positive, pad (with spaces)
|
|
3891 * to at least that many characters.
|
|
3892 * If first element is a symbol, process the cadr or caddr recursively
|
|
3893 * according to whether the symbol's value is non-nil or nil.
|
|
3894 * If first element is a face, process the cdr recursively
|
|
3895 * without altering the depth.
|
|
3896 */
|
|
3897 Lisp_Object car, tem;
|
|
3898
|
|
3899 car = XCAR (elt);
|
|
3900 if (SYMBOLP (car))
|
|
3901 {
|
|
3902 elt = XCDR (elt);
|
|
3903 if (!CONSP (elt))
|
|
3904 goto invalid;
|
|
3905 tem = symbol_value_in_buffer (car, w->buffer);
|
|
3906 /* elt is now the cdr, and we know it is a cons cell.
|
|
3907 Use its car if CAR has a non-nil value. */
|
|
3908 if (!UNBOUNDP (tem))
|
|
3909 {
|
|
3910 if (!NILP (tem))
|
|
3911 {
|
|
3912 elt = XCAR (elt);
|
|
3913 goto tail_recurse;
|
|
3914 }
|
|
3915 }
|
|
3916 /* Symbol's value is nil (or symbol is unbound)
|
|
3917 * Get the cddr of the original list
|
|
3918 * and if possible find the caddr and use that.
|
|
3919 */
|
|
3920 elt = XCDR (elt);
|
|
3921 if (NILP (elt))
|
|
3922 ;
|
|
3923 else if (!CONSP (elt))
|
|
3924 goto invalid;
|
|
3925 else
|
|
3926 {
|
|
3927 elt = XCAR (elt);
|
|
3928 goto tail_recurse;
|
|
3929 }
|
|
3930 }
|
|
3931 else if (INTP (car))
|
|
3932 {
|
|
3933 Charcount lim = XINT (car);
|
|
3934
|
|
3935 elt = XCDR (elt);
|
|
3936
|
|
3937 if (lim < 0)
|
|
3938 {
|
|
3939 /* Negative int means reduce maximum width.
|
|
3940 * DO NOT change MIN_PIXPOS here!
|
|
3941 * (20 -10 . foo) should truncate foo to 10 col
|
|
3942 * and then pad to 20.
|
|
3943 */
|
|
3944 if (max_pos == -1)
|
|
3945 max_pos = pos - lim;
|
|
3946 else
|
|
3947 max_pos = min (max_pos, pos - lim);
|
|
3948 }
|
|
3949 else if (lim > 0)
|
|
3950 {
|
|
3951 /* Padding specified. Don't let it be more than
|
|
3952 * current maximum.
|
|
3953 */
|
|
3954 lim += pos;
|
|
3955 if (max_pos != -1 && lim > max_pos)
|
|
3956 lim = max_pos;
|
|
3957 /* If that's more padding than already wanted, queue it.
|
|
3958 * But don't reduce padding already specified even if
|
|
3959 * that is beyond the current truncation point.
|
|
3960 */
|
|
3961 if (lim > min_pos)
|
|
3962 min_pos = lim;
|
|
3963 }
|
|
3964 goto tail_recurse;
|
|
3965 }
|
|
3966 else if (STRINGP (car) || CONSP (car))
|
|
3967 {
|
|
3968 int limit = 50;
|
|
3969 /* LIMIT is to protect against circular lists. */
|
|
3970 while (CONSP (elt) && --limit > 0
|
|
3971 && (pos < max_pos || max_pos == -1))
|
|
3972 {
|
|
3973 pos = generate_fstring_runes (w, data, pos, pos, max_pos,
|
|
3974 XCAR (elt), depth,
|
|
3975 max_pixsize, findex, type);
|
|
3976 elt = XCDR (elt);
|
|
3977 }
|
|
3978 }
|
|
3979 else if (EXTENTP (car))
|
|
3980 {
|
|
3981 struct extent *ext = XEXTENT (car);
|
|
3982
|
|
3983 if (EXTENT_LIVE_P (ext))
|
|
3984 {
|
|
3985 face_index old_findex = data->findex;
|
|
3986 Lisp_Object face;
|
|
3987 Lisp_Object font_inst;
|
|
3988 face_index new_findex;
|
|
3989 Bytecount start = data->bytepos;
|
|
3990
|
|
3991 face = extent_face (ext);
|
|
3992 if (FACEP (face))
|
|
3993 {
|
|
3994 /* #### needs to merge faces, sigh */
|
|
3995 /* #### needs to handle list of faces */
|
|
3996 new_findex = get_builtin_face_cache_index (w, face);
|
|
3997 /* !!#### not right; needs to compute the max height of
|
|
3998 all the charsets */
|
|
3999 font_inst = WINDOW_FACE_CACHEL_FONT (w, new_findex,
|
|
4000 Vcharset_ascii);
|
|
4001
|
|
4002 data->dl->ascent = max (data->dl->ascent,
|
|
4003 XFONT_INSTANCE (font_inst)->ascent);
|
|
4004 data->dl->descent = max (data->dl->descent,
|
|
4005 XFONT_INSTANCE (font_inst)->
|
|
4006 descent);
|
|
4007 }
|
|
4008 else
|
|
4009 new_findex = old_findex;
|
|
4010
|
|
4011 data->findex = new_findex;
|
|
4012 pos = generate_fstring_runes (w, data, pos, pos, max_pos,
|
|
4013 XCDR (elt), depth - 1,
|
|
4014 max_pixsize, new_findex, type);
|
|
4015 data->findex = old_findex;
|
|
4016 Dynarr_add (formatted_string_extent_dynarr, ext);
|
|
4017 Dynarr_add (formatted_string_extent_start_dynarr, start);
|
|
4018 Dynarr_add (formatted_string_extent_end_dynarr, data->bytepos);
|
|
4019 }
|
|
4020 }
|
|
4021 }
|
|
4022 else if (GLYPHP (elt))
|
|
4023 {
|
|
4024 pos = add_glyph_to_fstring_db_runes (data, elt, pos, pos, max_pos);
|
|
4025 }
|
|
4026 else
|
|
4027 {
|
|
4028 invalid:
|
|
4029 pos =
|
|
4030 add_string_to_fstring_db_runes
|
|
4031 (data, (CONST Bufbyte *) GETTEXT ("*invalid*"), pos, min_pos,
|
|
4032 max_pos);
|
|
4033 }
|
|
4034
|
|
4035 if (min_pos > pos)
|
|
4036 {
|
|
4037 add_string_to_fstring_db_runes (data, (CONST Bufbyte *) "", pos, min_pos,
|
|
4038 -1);
|
|
4039 }
|
|
4040
|
|
4041 return pos;
|
|
4042 }
|
|
4043
|
|
4044 /* The caller is responsible for freeing the returned string. */
|
2
|
4045 Bufbyte *
|
0
|
4046 generate_formatted_string (struct window *w, Lisp_Object format_str,
|
|
4047 Lisp_Object result_str, face_index findex, int type)
|
|
4048 {
|
|
4049 struct display_line *dl;
|
|
4050 struct display_block *db;
|
|
4051 int elt = 0;
|
|
4052
|
|
4053 dl = &formatted_string_display_line;
|
|
4054 db = get_display_block_from_line (dl, TEXT);
|
|
4055 Dynarr_reset (db->runes);
|
|
4056
|
|
4057 generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0,
|
|
4058 -1, type);
|
|
4059
|
|
4060 Dynarr_reset (formatted_string_emchar_dynarr);
|
|
4061 while (elt < Dynarr_length (db->runes))
|
|
4062 {
|
|
4063 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)
|
|
4064 Dynarr_add (formatted_string_emchar_dynarr,
|
|
4065 Dynarr_atp (db->runes, elt)->object.chr.ch);
|
|
4066 elt++;
|
|
4067 }
|
|
4068
|
2
|
4069 return
|
|
4070 convert_emchar_string_into_malloced_string
|
|
4071 ( Dynarr_atp (formatted_string_emchar_dynarr, 0),
|
|
4072 Dynarr_length (formatted_string_emchar_dynarr), 0);
|
0
|
4073 }
|
|
4074
|
|
4075 /* Update just the modeline. Assumes the desired display structs. If
|
|
4076 they do not have a modeline block, it does nothing. */
|
|
4077 static void
|
|
4078 regenerate_modeline (struct window *w)
|
|
4079 {
|
|
4080 display_line_dynarr *dla = window_display_lines (w, DESIRED_DISP);
|
|
4081
|
|
4082 if (!Dynarr_length (dla) || !Dynarr_atp (dla, 0)->modeline)
|
|
4083 return;
|
|
4084 else
|
|
4085 {
|
|
4086 generate_modeline (w, Dynarr_atp (dla, 0), DESIRED_DISP);
|
|
4087 redisplay_update_line (w, 0, 0, 0);
|
|
4088 }
|
|
4089 }
|
|
4090
|
|
4091 /* Make sure that modeline display line is present in the given
|
|
4092 display structs if the window has a modeline and update that
|
|
4093 line. Returns true if a modeline was needed. */
|
|
4094 static int
|
|
4095 ensure_modeline_generated (struct window *w, int type)
|
|
4096 {
|
|
4097 int need_modeline;
|
|
4098
|
|
4099 /* minibuffer windows don't have modelines */
|
|
4100 if (MINI_WINDOW_P (w))
|
|
4101 need_modeline = 0;
|
|
4102 /* windows which haven't had it turned off do */
|
|
4103 else if (WINDOW_HAS_MODELINE_P (w))
|
|
4104 need_modeline = 1;
|
|
4105 /* windows which have it turned off don't have a divider if there is
|
|
4106 a horizontal scrollbar */
|
|
4107 else if (window_scrollbar_height (w))
|
|
4108 need_modeline = 0;
|
|
4109 /* and in this case there is none */
|
|
4110 else
|
|
4111 need_modeline = 1;
|
|
4112
|
|
4113 if (need_modeline)
|
|
4114 {
|
|
4115 display_line_dynarr *dla;
|
|
4116
|
|
4117 dla = window_display_lines (w, type);
|
|
4118
|
|
4119 /* We don't care if there is a display line which is not
|
|
4120 currently a modeline because it is definitely going to become
|
|
4121 one if we have gotten to this point. */
|
|
4122 if (Dynarr_length (dla) == 0)
|
|
4123 {
|
|
4124 if (Dynarr_largest (dla) > 0)
|
|
4125 {
|
|
4126 struct display_line *mlp = Dynarr_atp (dla, 0);
|
|
4127 Dynarr_add (dla, *mlp);
|
|
4128 }
|
|
4129 else
|
|
4130 {
|
|
4131 struct display_line modeline;
|
|
4132 memset (&modeline, 0, sizeof (struct display_line));
|
|
4133 Dynarr_add (dla, modeline);
|
|
4134 }
|
|
4135 }
|
|
4136
|
|
4137 /* If we're adding a new place marker go ahead and generate the
|
|
4138 modeline so that it is available for use by
|
|
4139 window_modeline_height. */
|
|
4140 generate_modeline (w, Dynarr_atp (dla, 0), type);
|
|
4141 }
|
|
4142
|
|
4143 return need_modeline;
|
|
4144 }
|
|
4145
|
|
4146 /* #### Kludge or not a kludge. I tend towards the former. */
|
|
4147 int
|
|
4148 real_current_modeline_height (struct window *w)
|
|
4149 {
|
|
4150 Fset_marker (w->start[CMOTION_DISP], w->start[CURRENT_DISP], w->buffer);
|
2
|
4151 Fset_marker (w->pointm[CMOTION_DISP], w->pointm[CURRENT_DISP], w->buffer);
|
0
|
4152
|
|
4153 if (ensure_modeline_generated (w, CMOTION_DISP))
|
|
4154 {
|
|
4155 display_line_dynarr *dla;
|
|
4156
|
|
4157 dla = window_display_lines (w, CMOTION_DISP);
|
|
4158
|
|
4159 if (Dynarr_length (dla))
|
|
4160 {
|
|
4161 if (Dynarr_atp (dla, 0)->modeline)
|
|
4162 return (Dynarr_atp (dla, 0)->ascent +
|
|
4163 Dynarr_atp (dla, 0)->descent);
|
|
4164 else
|
|
4165 return 0;
|
|
4166 }
|
|
4167 else
|
|
4168 return 0;
|
|
4169 }
|
|
4170 else
|
|
4171 return 0;
|
|
4172 }
|
|
4173
|
|
4174
|
|
4175 /***************************************************************************/
|
|
4176 /* */
|
|
4177 /* window-regeneration routines */
|
|
4178 /* */
|
|
4179 /***************************************************************************/
|
|
4180
|
|
4181 /* For a given window and starting position in the buffer it contains,
|
|
4182 ensure that the TYPE display lines accurately represent the
|
|
4183 presentation of the window. We pass the buffer instead of getting
|
|
4184 it from the window since redisplay_window may have temporarily
|
|
4185 changed it to the echo area buffer. */
|
|
4186
|
|
4187 static void
|
|
4188 regenerate_window (struct window *w, Bufpos start_pos, Bufpos point, int type)
|
|
4189 {
|
|
4190 struct frame *f = XFRAME (w->frame);
|
|
4191 struct buffer *b = XBUFFER (w->buffer);
|
|
4192 int ypos = WINDOW_TEXT_TOP (w);
|
|
4193 int yend; /* set farther down */
|
|
4194
|
|
4195 prop_block_dynarr *prop;
|
|
4196 layout_bounds bounds;
|
|
4197 display_line_dynarr *dla;
|
|
4198 int need_modeline;
|
|
4199
|
|
4200 /* The lines had better exist by this point. */
|
|
4201 if (!(dla = window_display_lines (w, type)))
|
|
4202 abort ();
|
|
4203 Dynarr_reset (dla);
|
|
4204 w->max_line_len = 0;
|
|
4205
|
|
4206 /* Normally these get updated in redisplay_window but it is possible
|
|
4207 for this function to get called from some other points where that
|
|
4208 update may not have occurred. This acts as a safety check. */
|
|
4209 if (!Dynarr_length (w->face_cachels))
|
|
4210 reset_face_cachels (w);
|
|
4211 if (!Dynarr_length (w->glyph_cachels))
|
|
4212 reset_glyph_cachels (w);
|
|
4213
|
|
4214 Fset_marker (w->start[type], make_int (start_pos), w->buffer);
|
|
4215 Fset_marker (w->pointm[type], make_int (point), w->buffer);
|
|
4216 w->last_point_x[type] = -1;
|
|
4217 w->last_point_y[type] = -1;
|
|
4218
|
|
4219 /* Make sure a modeline is in the structs if needed. */
|
|
4220 need_modeline = ensure_modeline_generated (w, type);
|
|
4221
|
|
4222 /* Wait until here to set this so that the structs have a modeline
|
|
4223 generated in the case where one didn't exist. */
|
|
4224 yend = WINDOW_TEXT_BOTTOM (w);
|
|
4225
|
|
4226 bounds = calculate_display_line_boundaries (w, 0);
|
|
4227
|
|
4228 if (MINI_WINDOW_P (w)
|
|
4229 && !NILP (Vminibuf_prompt)
|
|
4230 && !echo_area_active (f)
|
|
4231 && start_pos == BUF_BEGV (b))
|
|
4232 {
|
|
4233 struct prop_block pb;
|
|
4234 prop = Dynarr_new (struct prop_block);
|
|
4235
|
|
4236 pb.type = PROP_MINIBUF_PROMPT;
|
16
|
4237 pb.data.p_string.str = XSTRING_DATA (Vminibuf_prompt);
|
|
4238 pb.data.p_string.len = XSTRING_LENGTH (Vminibuf_prompt);
|
0
|
4239 Dynarr_add (prop, pb);
|
|
4240 }
|
|
4241 else
|
|
4242 prop = 0;
|
|
4243
|
|
4244 while (ypos < yend)
|
|
4245 {
|
|
4246 struct display_line dl;
|
|
4247 struct display_line *dlp;
|
|
4248 int local;
|
|
4249
|
|
4250 if (Dynarr_length (dla) < Dynarr_largest (dla))
|
|
4251 {
|
|
4252 dlp = Dynarr_atp (dla, Dynarr_length (dla));
|
|
4253 local = 0;
|
|
4254 }
|
|
4255 else
|
|
4256 {
|
|
4257 dlp = &dl;
|
|
4258 memset (dlp, 0, sizeof (struct display_line));
|
|
4259 local = 1;
|
|
4260 }
|
|
4261
|
|
4262 dlp->bounds = bounds;
|
|
4263 dlp->offset = 0;
|
|
4264 start_pos = generate_display_line (w, dlp, 1, start_pos,
|
|
4265 w->hscroll, &prop, type);
|
|
4266 dlp->ypos = ypos + dlp->ascent;
|
|
4267 ypos = dlp->ypos + dlp->descent;
|
|
4268
|
|
4269 if (ypos > yend)
|
|
4270 {
|
|
4271 int visible_height = dlp->ascent + dlp->descent;
|
|
4272
|
|
4273 dlp->clip = (ypos - yend);
|
|
4274 visible_height -= dlp->clip;
|
|
4275
|
|
4276 if (visible_height < VERTICAL_CLIP (w, 1))
|
|
4277 {
|
|
4278 if (local)
|
|
4279 free_display_line (dlp);
|
|
4280 break;
|
|
4281 }
|
|
4282 }
|
|
4283 else
|
|
4284 dlp->clip = 0;
|
|
4285
|
|
4286 if (dlp->cursor_elt != -1)
|
|
4287 {
|
|
4288 /* #### This check is steaming crap. Have to get things
|
|
4289 fixed so when create_text_block hits EOB, we're done,
|
|
4290 period. */
|
|
4291 if (w->last_point_x[type] == -1)
|
|
4292 {
|
|
4293 w->last_point_x[type] = dlp->cursor_elt;
|
|
4294 w->last_point_y[type] = Dynarr_length (dla);
|
|
4295 }
|
|
4296 else
|
|
4297 {
|
|
4298 /* #### This means that we've added a cursor at EOB
|
|
4299 twice. Yuck oh yuck. */
|
|
4300 struct display_block *db =
|
|
4301 get_display_block_from_line (dlp, TEXT);
|
|
4302
|
|
4303 Dynarr_atp (db->runes, dlp->cursor_elt)->cursor_type = NO_CURSOR;
|
|
4304 dlp->cursor_elt = -1;
|
|
4305 }
|
|
4306 }
|
|
4307
|
|
4308 if (dlp->num_chars > w->max_line_len)
|
|
4309 w->max_line_len = dlp->num_chars;
|
|
4310
|
|
4311 Dynarr_add (dla, *dlp);
|
|
4312
|
|
4313 /* #### This isn't right, but it is close enough for now. */
|
|
4314 w->window_end_pos[type] = start_pos;
|
|
4315
|
|
4316 /* #### This type of check needs to be done down in the
|
|
4317 generate_display_line call. */
|
|
4318 if (start_pos > BUF_ZV (b))
|
|
4319 break;
|
|
4320 }
|
|
4321
|
|
4322 if (prop)
|
|
4323 Dynarr_free (prop);
|
|
4324
|
|
4325 /* #### More not quite right, but close enough. */
|
|
4326 /* #### Ben sez: apparently window_end_pos[] is measured
|
|
4327 as the number of characters between the window end and the
|
|
4328 end of the buffer? This seems rather weirdo. What's
|
|
4329 the justification for this? */
|
|
4330 w->window_end_pos[type] = BUF_Z (b) - w->window_end_pos[type];
|
|
4331
|
|
4332 if (need_modeline)
|
|
4333 {
|
|
4334 /* We know that this is the right thing to use because we put it
|
|
4335 there when we first started working in this function. */
|
|
4336 generate_modeline (w, Dynarr_atp (dla, 0), type);
|
|
4337 }
|
|
4338 }
|
|
4339
|
|
4340 #define REGEN_INC_FIND_START_END \
|
|
4341 do { \
|
|
4342 /* Determine start and end of lines. */ \
|
|
4343 if (!Dynarr_length (cdla)) \
|
|
4344 return 0; \
|
|
4345 else \
|
|
4346 { \
|
|
4347 if (Dynarr_atp (cdla, 0)->modeline && Dynarr_atp (ddla, 0)->modeline) \
|
|
4348 { \
|
|
4349 dla_start = 1; \
|
|
4350 } \
|
|
4351 else if (!Dynarr_atp (cdla, 0)->modeline \
|
|
4352 && !Dynarr_atp (ddla, 0)->modeline) \
|
|
4353 { \
|
|
4354 dla_start = 0; \
|
|
4355 } \
|
|
4356 else \
|
|
4357 abort (); /* structs differ */ \
|
|
4358 \
|
|
4359 dla_end = Dynarr_length (cdla) - 1; \
|
|
4360 } \
|
|
4361 \
|
|
4362 start_pos = (Dynarr_atp (cdla, dla_start)->bufpos \
|
|
4363 + Dynarr_atp (cdla, dla_start)->offset); \
|
|
4364 /* If this isn't true, then startp has changed and we need to do a \
|
|
4365 full regen. */ \
|
|
4366 if (startp != start_pos) \
|
|
4367 return 0; \
|
|
4368 \
|
|
4369 /* Point is outside the visible region so give up. */ \
|
|
4370 if (pointm < start_pos) \
|
|
4371 return 0; \
|
|
4372 \
|
|
4373 } while (0)
|
|
4374
|
|
4375 /* This attempts to incrementally update the display structures. It
|
|
4376 returns a boolean indicating success or failure. This function is
|
|
4377 very similar to regenerate_window_incrementally and is in fact only
|
|
4378 called from that function. However, because of the nature of the
|
|
4379 changes it deals with it sometimes makes different assumptions
|
|
4380 which can lead to success which are much more difficult to make
|
|
4381 when dealing with buffer changes. */
|
|
4382
|
|
4383 static int
|
|
4384 regenerate_window_extents_only_changed (struct window *w, Bufpos startp,
|
|
4385 Bufpos pointm,
|
|
4386 Charcount beg_unchanged,
|
|
4387 Charcount end_unchanged)
|
|
4388 {
|
|
4389 struct buffer *b = XBUFFER (w->buffer);
|
|
4390 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
4391 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
4392
|
|
4393 int dla_start = 0;
|
|
4394 int dla_end, line;
|
|
4395 int first_line, last_line;
|
|
4396 Bufpos start_pos;
|
|
4397 /* Don't define this in the loop where it is used because we
|
|
4398 definitely want its value to survive between passes. */
|
|
4399 prop_block_dynarr *prop = NULL;
|
|
4400
|
|
4401 /* If we don't have any buffer change recorded but the modiff flag has
|
|
4402 been incremented, then fail. I'm not sure of the exact circumstances
|
|
4403 under which this can happen, but I believe that it is probably a
|
|
4404 reasonable happening. */
|
|
4405 if (!point_visible (w, pointm, CURRENT_DISP)
|
|
4406 || XINT (w->last_modified[CURRENT_DISP]) < BUF_MODIFF (b))
|
|
4407 return 0;
|
|
4408
|
|
4409 /* If the cursor is moved we attempt to update it. If we succeed we
|
|
4410 go ahead and proceed with the optimization attempt. */
|
|
4411 if (!EQ (Fmarker_buffer (w->last_point[CURRENT_DISP]), w->buffer)
|
|
4412 || pointm != marker_position (w->last_point[CURRENT_DISP]))
|
|
4413 {
|
|
4414 struct frame *f = XFRAME (w->frame);
|
|
4415 struct device *d = XDEVICE (f->device);
|
|
4416 struct frame *sel_f = device_selected_frame (d);
|
|
4417 int success = 0;
|
|
4418
|
|
4419 if (w->last_point_x[CURRENT_DISP] != -1
|
|
4420 && w->last_point_y[CURRENT_DISP] != -1)
|
|
4421 {
|
|
4422
|
|
4423 if (redisplay_move_cursor (w, pointm, WINDOW_TTY_P (w)))
|
|
4424 {
|
|
4425 /* Always regenerate the modeline in case it is
|
|
4426 displaying the current line or column. */
|
|
4427 regenerate_modeline (w);
|
|
4428 success = 1;
|
|
4429 }
|
|
4430 }
|
|
4431 else if (w != XWINDOW (FRAME_SELECTED_WINDOW (sel_f)))
|
|
4432 {
|
|
4433 if (f->modeline_changed)
|
|
4434 regenerate_modeline (w);
|
|
4435 success = 1;
|
|
4436 }
|
|
4437
|
|
4438 if (!success)
|
|
4439 return 0;
|
|
4440 }
|
|
4441
|
|
4442 if (beg_unchanged == -1 && end_unchanged == -1)
|
|
4443 return 1;
|
|
4444
|
|
4445 /* assert: There are no buffer modifications or they are all below the
|
|
4446 visible region. We assume that regenerate_window_incrementally has
|
|
4447 not called us unless this is true. */
|
|
4448
|
|
4449 REGEN_INC_FIND_START_END;
|
|
4450
|
|
4451 /* If the changed are starts before the visible area, give up. */
|
|
4452 if (beg_unchanged < startp)
|
|
4453 return 0;
|
|
4454
|
|
4455 /* Find what display line the extent changes first affect. */
|
|
4456 line = dla_start;
|
|
4457 while (line <= dla_end)
|
|
4458 {
|
|
4459 struct display_line *dl = Dynarr_atp (cdla, line);
|
|
4460 Bufpos lstart = dl->bufpos + dl->offset;
|
|
4461 Bufpos lend = dl->end_bufpos + dl->offset;
|
|
4462
|
|
4463 if (beg_unchanged >= lstart && beg_unchanged <= lend)
|
|
4464 break;
|
|
4465
|
|
4466 line++;
|
|
4467 }
|
|
4468
|
|
4469 /* If the changes are below the visible area then if point hasn't
|
|
4470 moved return success otherwise fail in order to be safe. */
|
|
4471 if (line > dla_end)
|
|
4472 {
|
|
4473 if (EQ (Fmarker_buffer (w->last_point[CURRENT_DISP]), w->buffer)
|
|
4474 && pointm == marker_position (w->last_point[CURRENT_DISP]))
|
|
4475 return 1;
|
|
4476 else
|
|
4477 return 0;
|
|
4478 }
|
|
4479
|
|
4480 /* At this point we know what line the changes first affect. We now
|
|
4481 begin redrawing lines as long as we are still in the affected
|
|
4482 region and the line's size and positioning don't change.
|
|
4483 Otherwise we fail. If we fail we will have altered the desired
|
|
4484 structs which could lead to an assertion failure. However, if we
|
|
4485 fail the next thing that is going to happen is a full regen so we
|
|
4486 will actually end up being safe. */
|
|
4487 w->last_modified[DESIRED_DISP] = make_int (BUF_MODIFF (b));
|
|
4488 w->last_facechange[DESIRED_DISP] = make_int (BUF_FACECHANGE (b));
|
|
4489 Fset_marker (w->last_start[DESIRED_DISP], make_int (startp), w->buffer);
|
|
4490 Fset_marker (w->last_point[DESIRED_DISP], make_int (pointm), w->buffer);
|
|
4491
|
|
4492 first_line = last_line = line;
|
|
4493 while (line <= dla_end)
|
|
4494 {
|
|
4495 Bufpos old_start, old_end, new_start;
|
|
4496 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
4497 struct display_line *ddl = Dynarr_atp (ddla, line);
|
|
4498 struct display_block *db;
|
|
4499 int initial_size;
|
|
4500
|
|
4501 assert (cdl->bufpos == ddl->bufpos);
|
|
4502 assert (cdl->end_bufpos == ddl->end_bufpos);
|
|
4503 assert (cdl->offset == ddl->offset);
|
|
4504
|
|
4505 db = get_display_block_from_line (ddl, TEXT);
|
|
4506 initial_size = Dynarr_length (db->runes);
|
|
4507 old_start = ddl->bufpos + ddl->offset;
|
|
4508 old_end = ddl->end_bufpos + ddl->offset;
|
|
4509
|
|
4510 /* If this is the first line being updated and it used
|
|
4511 propagation data, fail. Otherwise we'll be okay because
|
|
4512 we'll have the necessary propagation data. */
|
|
4513 if (line == first_line && ddl->used_prop_data)
|
|
4514 return 0;
|
|
4515
|
|
4516 new_start = generate_display_line (w, ddl, 0, ddl->bufpos + ddl->offset,
|
|
4517 w->hscroll, &prop, DESIRED_DISP);
|
|
4518 ddl->offset = 0;
|
|
4519
|
|
4520 /* #### If there is propagated stuff the fail. We could
|
|
4521 probably actually deal with this if the line had propagated
|
|
4522 information when originally created by a full
|
|
4523 regeneration. */
|
|
4524 if (prop)
|
|
4525 {
|
|
4526 Dynarr_free (prop);
|
|
4527 return 0;
|
|
4528 }
|
|
4529
|
|
4530 /* If any line position parameters have changed or a
|
|
4531 cursor has disappeared or disappeared, fail. */
|
|
4532 db = get_display_block_from_line (ddl, TEXT);
|
|
4533 if (cdl->ypos != ddl->ypos
|
|
4534 || cdl->ascent != ddl->ascent
|
|
4535 || cdl->descent != ddl->descent
|
|
4536 || (cdl->cursor_elt != -1 && ddl->cursor_elt == -1)
|
|
4537 || (cdl->cursor_elt == -1 && ddl->cursor_elt != -1)
|
|
4538 || old_start != ddl->bufpos
|
|
4539 || old_end != ddl->end_bufpos
|
|
4540 || initial_size != Dynarr_length (db->runes))
|
|
4541 {
|
|
4542 return 0;
|
|
4543 }
|
|
4544
|
|
4545 if (ddl->cursor_elt != -1)
|
|
4546 {
|
|
4547 w->last_point_x[DESIRED_DISP] = ddl->cursor_elt;
|
|
4548 w->last_point_y[DESIRED_DISP] = line;
|
|
4549 }
|
|
4550
|
|
4551 last_line = line;
|
|
4552
|
|
4553 /* If the extent changes end on the line we just updated then
|
|
4554 we're done. Otherwise go on to the next line. */
|
|
4555 if (end_unchanged <= ddl->end_bufpos)
|
|
4556 break;
|
|
4557 else
|
|
4558 line++;
|
|
4559 }
|
|
4560
|
|
4561 redisplay_update_line (w, first_line, last_line, 1);
|
|
4562 return 1;
|
|
4563 }
|
|
4564
|
|
4565 /* Attempt to update the display data structures based on knowledge of
|
|
4566 the changed region in the buffer. Returns a boolean indicating
|
|
4567 success or failure. If this function returns a failure then a
|
|
4568 regenerate_window _must_ be performed next in order to maintain
|
|
4569 invariants located here. */
|
|
4570
|
|
4571 static int
|
|
4572 regenerate_window_incrementally (struct window *w, Bufpos startp,
|
|
4573 Bufpos pointm)
|
|
4574 {
|
|
4575 struct buffer *b = XBUFFER (w->buffer);
|
|
4576 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
4577 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
4578 Charcount beg_unchanged, end_unchanged;
|
|
4579 Charcount extent_beg_unchanged, extent_end_unchanged;
|
|
4580
|
|
4581 int dla_start = 0;
|
|
4582 int dla_end, line;
|
|
4583 Bufpos start_pos;
|
|
4584
|
|
4585 /* If this function is called, the current and desired structures
|
|
4586 had better be identical. If they are not, then that is a bug. */
|
|
4587 assert (Dynarr_length (cdla) == Dynarr_length (ddla));
|
|
4588
|
|
4589 /* We don't handle minibuffer windows yet. The minibuffer prompt
|
|
4590 screws us up. */
|
|
4591 if (MINI_WINDOW_P (w))
|
|
4592 return 0;
|
|
4593
|
|
4594 extent_beg_unchanged = BUF_EXTENT_BEGIN_UNCHANGED (b);
|
|
4595 extent_end_unchanged = (BUF_EXTENT_END_UNCHANGED (b) == -1
|
|
4596 ? -1
|
|
4597 : BUF_Z (b) - BUF_EXTENT_END_UNCHANGED (b));
|
|
4598
|
|
4599 /* If nothing has changed in the buffer, then make sure point is ok
|
|
4600 and succeed. */
|
|
4601 if (BUF_BEGIN_UNCHANGED (b) == -1 && BUF_END_UNCHANGED (b) == -1)
|
|
4602 return regenerate_window_extents_only_changed (w, startp, pointm,
|
|
4603 extent_beg_unchanged,
|
|
4604 extent_end_unchanged);
|
|
4605
|
|
4606 /* We can't deal with deleted newlines. */
|
|
4607 if (BUF_NEWLINE_WAS_DELETED (b))
|
|
4608 return 0;
|
|
4609
|
|
4610 beg_unchanged = BUF_BEGIN_UNCHANGED (b);
|
|
4611 end_unchanged = (BUF_END_UNCHANGED (b) == -1
|
|
4612 ? -1
|
|
4613 : BUF_Z (b) - BUF_END_UNCHANGED (b));
|
|
4614
|
|
4615 REGEN_INC_FIND_START_END;
|
|
4616
|
|
4617 /* If the changed area starts before the visible area, give up. */
|
|
4618 if (beg_unchanged < startp)
|
|
4619 return 0;
|
|
4620
|
|
4621 /* Find what display line the buffer changes first affect. */
|
|
4622 line = dla_start;
|
|
4623 while (line <= dla_end)
|
|
4624 {
|
|
4625 struct display_line *dl = Dynarr_atp (cdla, line);
|
|
4626 Bufpos lstart = dl->bufpos + dl->offset;
|
|
4627 Bufpos lend = dl->end_bufpos + dl->offset;
|
|
4628
|
|
4629 if (beg_unchanged >= lstart && beg_unchanged <= lend)
|
|
4630 break;
|
|
4631
|
|
4632 line++;
|
|
4633 }
|
|
4634
|
|
4635 /* If the changes are below the visible area then if point hasn't
|
|
4636 moved return success otherwise fail in order to be safe. */
|
|
4637 if (line > dla_end)
|
|
4638 {
|
|
4639 return regenerate_window_extents_only_changed (w, startp, pointm,
|
|
4640 extent_beg_unchanged,
|
|
4641 extent_end_unchanged);
|
|
4642 }
|
|
4643 else
|
|
4644 /* At this point we know what line the changes first affect. We
|
|
4645 now redraw that line. If the changes are contained within it
|
|
4646 we are going to succeed and can update just that one line.
|
|
4647 Otherwise we fail. If we fail we will have altered the desired
|
|
4648 structs which could lead to an assertion failure. However, if
|
|
4649 we fail the next thing that is going to happen is a full regen
|
|
4650 so we will actually end up being safe. */
|
|
4651 {
|
|
4652 Bufpos new_start;
|
|
4653 prop_block_dynarr *prop = NULL;
|
|
4654 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
4655 struct display_line *ddl = Dynarr_atp (ddla, line);
|
|
4656
|
|
4657 assert (cdl->bufpos == ddl->bufpos);
|
|
4658 assert (cdl->end_bufpos == ddl->end_bufpos);
|
|
4659 assert (cdl->offset == ddl->offset);
|
|
4660
|
|
4661 /* If the last rune is already a continuation glyph, fail.
|
|
4662 #### We should be able to handle this better. */
|
|
4663 {
|
|
4664 struct display_block *db = get_display_block_from_line (ddl, TEXT);
|
|
4665 if (Dynarr_length (db->runes))
|
|
4666 {
|
|
4667 struct rune *rb =
|
|
4668 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
|
|
4669
|
|
4670 if (rb->type == RUNE_DGLYPH
|
|
4671 && EQ (rb->object.dglyph.glyph, Vcontinuation_glyph))
|
|
4672 return 0;
|
|
4673 }
|
|
4674 }
|
|
4675
|
|
4676 /* If the line was generated using propagation data, fail. */
|
|
4677 if (ddl->used_prop_data)
|
|
4678 return 0;
|
|
4679
|
|
4680 new_start = generate_display_line (w, ddl, 0, ddl->bufpos + ddl->offset,
|
|
4681 w->hscroll, &prop, DESIRED_DISP);
|
|
4682 ddl->offset = 0;
|
|
4683
|
|
4684 /* If there is propagated stuff then it is pretty much a
|
|
4685 guarantee that more than just the one line is affected. */
|
|
4686 if (prop)
|
|
4687 {
|
|
4688 Dynarr_free (prop);
|
|
4689 return 0;
|
|
4690 }
|
|
4691
|
|
4692 /* If the last rune is now a continuation glyph, fail. */
|
|
4693 {
|
|
4694 struct display_block *db = get_display_block_from_line (ddl, TEXT);
|
|
4695 if (Dynarr_length (db->runes))
|
|
4696 {
|
|
4697 struct rune *rb =
|
|
4698 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
|
|
4699
|
|
4700 if (rb->type == RUNE_DGLYPH
|
|
4701 && EQ (rb->object.dglyph.glyph, Vcontinuation_glyph))
|
|
4702 return 0;
|
|
4703 }
|
|
4704 }
|
|
4705
|
|
4706 /* If any line position parameters have changed or a
|
|
4707 cursor has disappeared or disappeared, fail. */
|
|
4708 if (cdl->ypos != ddl->ypos
|
|
4709 || cdl->ascent != ddl->ascent
|
|
4710 || cdl->descent != ddl->descent
|
|
4711 || (cdl->cursor_elt != -1 && ddl->cursor_elt == -1)
|
|
4712 || (cdl->cursor_elt == -1 && ddl->cursor_elt != -1))
|
|
4713 {
|
|
4714 return 0;
|
|
4715 }
|
|
4716
|
|
4717 /* If the changed area also ends on this line, then we may be in
|
|
4718 business. Update everything and return success. */
|
|
4719 if (end_unchanged >= ddl->bufpos && end_unchanged <= ddl->end_bufpos)
|
|
4720 {
|
|
4721 w->last_modified[DESIRED_DISP] = make_int (BUF_MODIFF (b));
|
|
4722 w->last_facechange[DESIRED_DISP] = make_int (BUF_FACECHANGE (b));
|
|
4723 Fset_marker (w->last_start[DESIRED_DISP], make_int (startp),
|
|
4724 w->buffer);
|
|
4725 Fset_marker (w->last_point[DESIRED_DISP], make_int (pointm),
|
|
4726 w->buffer);
|
|
4727
|
|
4728 if (ddl->cursor_elt != -1)
|
|
4729 {
|
|
4730 w->last_point_x[DESIRED_DISP] = ddl->cursor_elt;
|
|
4731 w->last_point_y[DESIRED_DISP] = line;
|
|
4732 }
|
|
4733
|
|
4734 redisplay_update_line (w, line, line, 1);
|
|
4735 regenerate_modeline (w);
|
|
4736
|
|
4737 /* #### For now we just flush the cache until this has been
|
|
4738 tested. After that is done, this should correct the
|
|
4739 cache directly. */
|
|
4740 Dynarr_reset (w->line_start_cache);
|
|
4741
|
|
4742 /* Adjust the extent changed boundaries to remove any
|
|
4743 overlap with the buffer changes since we've just
|
|
4744 successfully updated that area. */
|
|
4745 if (extent_beg_unchanged != -1
|
|
4746 && extent_beg_unchanged >= beg_unchanged
|
|
4747 && extent_beg_unchanged < end_unchanged)
|
|
4748 extent_beg_unchanged = end_unchanged;
|
|
4749
|
|
4750 if (extent_end_unchanged != -1
|
|
4751 && extent_end_unchanged >= beg_unchanged
|
|
4752 && extent_end_unchanged < end_unchanged)
|
|
4753 extent_end_unchanged = beg_unchanged - 1;
|
|
4754
|
|
4755 if (extent_end_unchanged <= extent_beg_unchanged)
|
|
4756 extent_beg_unchanged = extent_end_unchanged = -1;
|
|
4757
|
|
4758 /* This could lead to odd results if it fails, but since the
|
|
4759 buffer changes update succeeded this probably will to.
|
|
4760 We already know that the extent changes start at or after
|
|
4761 the line because we checked before entering the loop. */
|
|
4762 if (extent_beg_unchanged != -1
|
|
4763 && extent_end_unchanged != -1
|
|
4764 && ((extent_beg_unchanged < ddl->bufpos)
|
|
4765 || (extent_end_unchanged > ddl->end_bufpos)))
|
|
4766 {
|
|
4767 return
|
|
4768 regenerate_window_extents_only_changed (w, startp, pointm,
|
|
4769 extent_beg_unchanged,
|
|
4770 extent_end_unchanged);
|
|
4771 }
|
|
4772 else
|
|
4773 return 1;
|
|
4774 }
|
|
4775 }
|
|
4776
|
|
4777 /* Oh, well. */
|
|
4778 return 0;
|
|
4779 }
|
|
4780
|
|
4781 /* Given a window and a point, update the given display lines such
|
70
|
4782 that point is displayed in the middle of the window. */
|
|
4783
|
|
4784 static void
|
0
|
4785 regenerate_window_point_center (struct window *w, Bufpos point, int type)
|
|
4786 {
|
|
4787 Bufpos startp;
|
|
4788
|
|
4789 /* We need to make sure that the modeline is generated so that the
|
|
4790 window height can be calculated correctly. */
|
|
4791 ensure_modeline_generated (w, type);
|
|
4792
|
|
4793 startp = start_with_line_at_pixpos (w, point, window_half_pixpos (w));
|
|
4794 regenerate_window (w, startp, point, type);
|
|
4795 Fset_marker (w->start[type], make_int (startp), w->buffer);
|
|
4796
|
70
|
4797 return;
|
0
|
4798 }
|
|
4799
|
|
4800 /* Given a window and a set of display lines, return a boolean
|
|
4801 indicating whether the given point is contained within. */
|
|
4802
|
|
4803 static int
|
|
4804 point_visible (struct window *w, Bufpos point, int type)
|
|
4805 {
|
|
4806 struct buffer *b = XBUFFER (w->buffer);
|
|
4807 display_line_dynarr *dla = window_display_lines (w, type);
|
|
4808 int first_line;
|
|
4809
|
|
4810 if (Dynarr_length (dla) && Dynarr_atp (dla, 0)->modeline)
|
|
4811 first_line = 1;
|
|
4812 else
|
|
4813 first_line = 0;
|
|
4814
|
|
4815 if (Dynarr_length (dla) > first_line)
|
|
4816 {
|
|
4817 Bufpos start, end;
|
|
4818 struct display_line *dl = Dynarr_atp (dla, first_line);
|
|
4819
|
|
4820 start = dl->bufpos;
|
|
4821 end = BUF_Z (b) - w->window_end_pos[type] - 1;
|
|
4822
|
|
4823 if (point >= start && point <= end)
|
|
4824 {
|
|
4825 if (!MINI_WINDOW_P (w) && scroll_on_clipped_lines)
|
|
4826 {
|
|
4827 dl = Dynarr_atp (dla, Dynarr_length (dla) - 1);
|
|
4828
|
|
4829 if (point >= (dl->bufpos + dl->offset)
|
|
4830 && point <= (dl->end_bufpos + dl->offset))
|
|
4831 return (!dl->clip);
|
|
4832 else
|
|
4833 return 1;
|
|
4834 }
|
|
4835 else
|
|
4836 return 1;
|
|
4837 }
|
|
4838 else
|
|
4839 return 0;
|
|
4840 }
|
|
4841 else
|
|
4842 return 0;
|
|
4843 }
|
|
4844
|
|
4845 /* Return pixel position the middle of the window, not including the
|
|
4846 modeline and any potential horizontal scrollbar. */
|
|
4847
|
|
4848 int
|
|
4849 window_half_pixpos (struct window *w)
|
|
4850 {
|
|
4851 return (WINDOW_TEXT_TOP (w) + (WINDOW_TEXT_HEIGHT (w) >> 1));
|
|
4852 }
|
|
4853
|
|
4854 /* Return the display line which is currently in the middle of the
|
|
4855 window W for display lines TYPE. */
|
|
4856
|
|
4857 int
|
|
4858 line_at_center (struct window *w, int type, Bufpos start, Bufpos point)
|
|
4859 {
|
|
4860 display_line_dynarr *dla;
|
|
4861 int half;
|
|
4862 int elt;
|
|
4863 int first_elt = (MINI_WINDOW_P (w) ? 0 : 1);
|
|
4864
|
|
4865 if (type == CMOTION_DISP)
|
|
4866 regenerate_window (w, start, point, type);
|
|
4867
|
|
4868 dla = window_display_lines (w, type);
|
|
4869 half = window_half_pixpos (w);
|
|
4870
|
|
4871 for (elt = first_elt; elt < Dynarr_length (dla); elt++)
|
|
4872 {
|
|
4873 struct display_line *dl = Dynarr_atp (dla, elt);
|
|
4874 int line_bot = dl->ypos + dl->descent;
|
|
4875
|
|
4876 if (line_bot > half)
|
|
4877 return elt;
|
|
4878 }
|
|
4879
|
|
4880 /* We may not have a line at the middle if the end of the buffer is
|
|
4881 being displayed. */
|
|
4882 return -1;
|
|
4883 }
|
|
4884
|
|
4885 /* Return a value for point that would place it at the beginning of
|
|
4886 the line which is in the middle of the window. */
|
|
4887
|
|
4888 Bufpos
|
|
4889 point_at_center (struct window *w, int type, Bufpos start, Bufpos point)
|
|
4890 {
|
|
4891 /* line_at_center will regenerate the display structures, if necessary. */
|
|
4892 int line = line_at_center (w, type, start, point);
|
|
4893
|
|
4894 if (line == -1)
|
|
4895 return BUF_ZV (XBUFFER (w->buffer));
|
|
4896 else
|
|
4897 {
|
|
4898 display_line_dynarr *dla = window_display_lines (w, type);
|
|
4899 struct display_line *dl = Dynarr_atp (dla, line);
|
|
4900
|
|
4901 return dl->bufpos;
|
|
4902 }
|
|
4903 }
|
|
4904
|
|
4905 /* For a given window, ensure that the current visual representation
|
|
4906 is accurate. */
|
|
4907
|
|
4908 static void
|
|
4909 redisplay_window (Lisp_Object window, int skip_selected)
|
|
4910 {
|
|
4911 struct window *w = XWINDOW (window);
|
|
4912 struct frame *f = XFRAME (w->frame);
|
|
4913 struct device *d = XDEVICE (f->device);
|
|
4914 Lisp_Object old_buffer = w->buffer;
|
|
4915 struct buffer *b;
|
|
4916 int echo_active = 0;
|
|
4917 int startp = 1;
|
|
4918 int pointm;
|
70
|
4919 int selected;
|
0
|
4920 int skip_output = 0;
|
|
4921 int truncation_changed;
|
|
4922 int inactive_minibuffer =
|
|
4923 (MINI_WINDOW_P (w) &&
|
|
4924 (f != device_selected_frame (d)) &&
|
|
4925 !is_surrogate_for_selected_frame (f));
|
|
4926
|
|
4927 /* #### In the new world this function actually does a bunch of
|
|
4928 optimizations such as buffer-based scrolling, but none of that is
|
|
4929 implemented yet. */
|
|
4930
|
|
4931 /* If this is a combination window, do its children; that's all.
|
|
4932 The selected window is always a leaf so we don't check for
|
|
4933 skip_selected here. */
|
|
4934 if (!NILP (w->vchild))
|
|
4935 {
|
|
4936 redisplay_windows (w->vchild, skip_selected);
|
|
4937 return;
|
|
4938 }
|
|
4939 if (!NILP (w->hchild))
|
|
4940 {
|
|
4941 redisplay_windows (w->hchild, skip_selected);
|
|
4942 return;
|
|
4943 }
|
|
4944
|
|
4945 /* Is this window the selected window on its frame? */
|
70
|
4946 selected =
|
|
4947 (w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))));
|
|
4948 if (skip_selected && selected)
|
0
|
4949 return;
|
|
4950
|
|
4951 /* It is possible that the window is not fully initialized yet. */
|
|
4952 if (NILP (w->buffer))
|
|
4953 return;
|
|
4954
|
|
4955 if (MINI_WINDOW_P (w) && echo_area_active (f))
|
|
4956 {
|
|
4957 w->buffer = Vecho_area_buffer;
|
|
4958 echo_active = 1;
|
|
4959 }
|
|
4960
|
|
4961 b = XBUFFER (w->buffer);
|
|
4962
|
|
4963 if (echo_active)
|
|
4964 pointm = 1;
|
|
4965 else
|
|
4966 {
|
70
|
4967 if (selected)
|
0
|
4968 {
|
|
4969 pointm = BUF_PT (b);
|
|
4970 }
|
|
4971 else
|
|
4972 {
|
|
4973 pointm = marker_position (w->pointm[CURRENT_DISP]);
|
|
4974
|
|
4975 if (pointm < BUF_BEGV (b))
|
|
4976 pointm = BUF_BEGV (b);
|
|
4977 else if (pointm > BUF_ZV (b))
|
|
4978 pointm = BUF_ZV (b);
|
|
4979 }
|
|
4980 }
|
|
4981 Fset_marker (w->pointm[DESIRED_DISP], make_int (pointm), old_buffer);
|
|
4982
|
|
4983 /* If the buffer has changed we have to invalid all of our face
|
|
4984 cache elements. */
|
|
4985 if ((!echo_active && b != window_display_buffer (w))
|
|
4986 || !Dynarr_length (w->face_cachels)
|
|
4987 || f->faces_changed)
|
|
4988 reset_face_cachels (w);
|
|
4989 else
|
|
4990 mark_face_cachels_as_not_updated (w);
|
|
4991
|
|
4992 /* Ditto the glyph cache elements. */
|
|
4993 if ((!echo_active && b != window_display_buffer (w))
|
|
4994 || !Dynarr_length (w->glyph_cachels))
|
|
4995 reset_glyph_cachels (w);
|
|
4996 else
|
|
4997 mark_glyph_cachels_as_not_updated (w);
|
|
4998
|
|
4999 /* If the marker's buffer is not the window's buffer, then we need
|
|
5000 to find a new starting position. */
|
|
5001 if (!MINI_WINDOW_P (w)
|
|
5002 && !EQ (Fmarker_buffer (w->start[CURRENT_DISP]), w->buffer))
|
|
5003 {
|
70
|
5004 regenerate_window_point_center (w, pointm, DESIRED_DISP);
|
0
|
5005
|
|
5006 goto regeneration_done;
|
|
5007 }
|
|
5008
|
|
5009 if (echo_active)
|
|
5010 startp = 1;
|
|
5011 else
|
|
5012 {
|
|
5013 startp = marker_position (w->start[CURRENT_DISP]);
|
|
5014 if (startp < BUF_BEGV (b))
|
|
5015 startp = BUF_BEGV (b);
|
|
5016 else if (startp > BUF_ZV (b))
|
|
5017 startp = BUF_ZV (b);
|
|
5018 }
|
|
5019 Fset_marker (w->start[DESIRED_DISP], make_int (startp), old_buffer);
|
|
5020
|
|
5021 truncation_changed = (find_window_mirror (w)->truncate_win !=
|
|
5022 window_truncation_on (w));
|
|
5023
|
|
5024 /* If w->force_start is set, then some function set w->start and we
|
|
5025 should display from there and change point, if necessary, to
|
|
5026 ensure that it is visible. */
|
|
5027 if (w->force_start || inactive_minibuffer)
|
|
5028 {
|
|
5029 w->force_start = 0;
|
|
5030 w->last_modified[DESIRED_DISP] = Qzero;
|
|
5031 w->last_facechange[DESIRED_DISP] = Qzero;
|
|
5032
|
|
5033 regenerate_window (w, startp, pointm, DESIRED_DISP);
|
|
5034
|
|
5035 if (!point_visible (w, pointm, DESIRED_DISP) && !inactive_minibuffer)
|
|
5036 {
|
|
5037 pointm = point_at_center (w, DESIRED_DISP, 0, 0);
|
|
5038
|
70
|
5039 if (selected)
|
0
|
5040 BUF_SET_PT (b, pointm);
|
|
5041
|
|
5042 Fset_marker (w->pointm[DESIRED_DISP], make_int (pointm),
|
|
5043 old_buffer);
|
|
5044
|
|
5045 /* #### BUFU amounts of overkil just to get the cursor
|
|
5046 location marked properly. FIX ME FIX ME FIX ME */
|
|
5047 regenerate_window (w, startp, pointm, DESIRED_DISP);
|
|
5048 }
|
|
5049
|
|
5050 goto regeneration_done;
|
|
5051 }
|
|
5052
|
|
5053 /* If nothing has changed since the last redisplay, then we just
|
|
5054 need to make sure that point is still visible. */
|
|
5055 if (XINT (w->last_modified[CURRENT_DISP]) >= BUF_MODIFF (b)
|
|
5056 && XINT (w->last_facechange[CURRENT_DISP]) >= BUF_FACECHANGE (b)
|
|
5057 && pointm >= startp
|
|
5058 /* This check is to make sure we restore the minibuffer after a
|
|
5059 temporary change to the echo area. */
|
|
5060 && !(MINI_WINDOW_P (w) && f->buffers_changed)
|
|
5061 && !f->frame_changed
|
|
5062 && !truncation_changed)
|
|
5063 {
|
|
5064 /* Check if the cursor has actually moved. */
|
|
5065 if (EQ (Fmarker_buffer (w->last_point[CURRENT_DISP]), w->buffer)
|
|
5066 && pointm == marker_position (w->last_point[CURRENT_DISP])
|
70
|
5067 && selected
|
0
|
5068 && !w->windows_changed
|
|
5069 && !f->clip_changed
|
|
5070 && !f->extents_changed
|
|
5071 && !f->faces_changed
|
|
5072 && !f->point_changed
|
|
5073 && !f->windows_structure_changed)
|
|
5074 {
|
|
5075 /* If not, we're done. */
|
|
5076 if (f->modeline_changed)
|
|
5077 regenerate_modeline (w);
|
|
5078
|
|
5079 skip_output = 1;
|
|
5080 goto regeneration_done;
|
|
5081 }
|
|
5082 else
|
|
5083 {
|
|
5084 /* If the new point is visible in the redisplay structures,
|
|
5085 then let the output update routines handle it, otherwise
|
|
5086 do things the hard way. */
|
|
5087 if (!w->windows_changed
|
|
5088 && !f->clip_changed
|
|
5089 && !f->extents_changed
|
|
5090 && !f->faces_changed
|
|
5091 && !f->windows_structure_changed)
|
|
5092 {
|
|
5093 if (point_visible (w, pointm, CURRENT_DISP)
|
|
5094 && w->last_point_x[CURRENT_DISP] != -1
|
|
5095 && w->last_point_y[CURRENT_DISP] != -1)
|
|
5096 {
|
|
5097 if (redisplay_move_cursor (w, pointm, FRAME_TTY_P (f)))
|
|
5098 {
|
|
5099 /* Always regenerate in case it is displaying
|
|
5100 the current line or column. */
|
|
5101 regenerate_modeline (w);
|
|
5102
|
|
5103 skip_output = 1;
|
|
5104 goto regeneration_done;
|
|
5105 }
|
|
5106 }
|
70
|
5107 else if (!selected && !f->point_changed)
|
0
|
5108 {
|
|
5109 if (f->modeline_changed)
|
|
5110 regenerate_modeline (w);
|
|
5111
|
|
5112 skip_output = 1;
|
|
5113 goto regeneration_done;
|
|
5114 }
|
|
5115 }
|
|
5116
|
|
5117 /* If we weren't able to take the shortcut method, then use
|
|
5118 the brute force method. */
|
|
5119 regenerate_window (w, startp, pointm, DESIRED_DISP);
|
|
5120
|
|
5121 if (point_visible (w, pointm, DESIRED_DISP))
|
|
5122 goto regeneration_done;
|
|
5123 }
|
|
5124 }
|
|
5125
|
|
5126 /* Check if the starting point is no longer at the beginning of a
|
|
5127 line, in which case find a new starting point. We also recenter
|
|
5128 if our start position is equal to point-max. Otherwise we'll end
|
|
5129 up with a blank window. */
|
|
5130 else if (((w->start_at_line_beg || MINI_WINDOW_P (w))
|
|
5131 && !(startp == BUF_BEGV (b)
|
|
5132 || BUF_FETCH_CHAR (b, startp - 1) == '\n'))
|
|
5133 || (pointm == startp &&
|
|
5134 EQ (Fmarker_buffer (w->last_start[CURRENT_DISP]), w->buffer) &&
|
|
5135 startp < marker_position (w->last_start[CURRENT_DISP]))
|
|
5136 || (startp == BUF_ZV (b)))
|
|
5137 {
|
70
|
5138 regenerate_window_point_center (w, pointm, DESIRED_DISP);
|
0
|
5139
|
|
5140 goto regeneration_done;
|
|
5141 }
|
|
5142 /* See if we can update the data structures locally based on
|
|
5143 knowledge of what changed in the buffer. */
|
|
5144 else if (!w->windows_changed
|
|
5145 && !f->clip_changed
|
|
5146 && !f->faces_changed
|
|
5147 && !f->windows_structure_changed
|
|
5148 && !f->frame_changed
|
|
5149 && !truncation_changed
|
|
5150 && pointm >= startp
|
|
5151 && regenerate_window_incrementally (w, startp, pointm))
|
|
5152 {
|
|
5153 if (f->modeline_changed
|
|
5154 || XINT (w->last_modified[CURRENT_DISP]) < BUF_MODIFF (b)
|
|
5155 || XINT (w->last_facechange[CURRENT_DISP]) < BUF_FACECHANGE (b))
|
|
5156 regenerate_modeline (w);
|
|
5157
|
|
5158 skip_output = 1;
|
|
5159 goto regeneration_done;
|
|
5160 }
|
|
5161 /* #### This is where a check for structure based scrolling would go. */
|
|
5162 /* If all else fails, try just regenerating and see what happens. */
|
|
5163 else
|
|
5164 {
|
|
5165 regenerate_window (w, startp, pointm, DESIRED_DISP);
|
|
5166
|
|
5167 if (point_visible (w, pointm, DESIRED_DISP))
|
|
5168 goto regeneration_done;
|
|
5169 }
|
|
5170
|
|
5171 /* We still haven't gotten the window regenerated with point
|
|
5172 visible. Next we try scrolling a little and see if point comes
|
|
5173 back onto the screen. */
|
|
5174 if (scroll_step)
|
|
5175 {
|
70
|
5176 Bufpos bufpos;
|
|
5177
|
|
5178 bufpos = vmotion (w, startp,
|
0
|
5179 (pointm < startp) ? -scroll_step : scroll_step, 0);
|
70
|
5180 regenerate_window (w, bufpos, pointm, DESIRED_DISP);
|
0
|
5181
|
|
5182 if (point_visible (w, pointm, DESIRED_DISP))
|
|
5183 goto regeneration_done;
|
|
5184 }
|
|
5185
|
|
5186 /* We still haven't managed to get the screen drawn with point on
|
|
5187 the screen, so just center it and be done with it. */
|
70
|
5188 regenerate_window_point_center (w, pointm, DESIRED_DISP);
|
0
|
5189
|
|
5190
|
|
5191 regeneration_done:
|
|
5192
|
|
5193 /* If the window's frame is changed then reset the current display
|
|
5194 lines in order to force a full repaint. */
|
|
5195 if (f->frame_changed)
|
|
5196 {
|
|
5197 display_line_dynarr *cla = window_display_lines (w, CURRENT_DISP);
|
|
5198
|
|
5199 Dynarr_reset (cla);
|
|
5200 }
|
|
5201
|
|
5202 /* Must do this before calling redisplay_output_window because it
|
|
5203 sets some markers on the window. */
|
|
5204 if (MINI_WINDOW_P (w) && echo_area_active (f))
|
|
5205 w->buffer = old_buffer;
|
|
5206
|
|
5207 /* These also have to be set before calling redisplay_output_window
|
|
5208 since it sets the CURRENT_DISP values based on them. */
|
|
5209 w->last_modified[DESIRED_DISP] = make_int (BUF_MODIFF (b));
|
|
5210 w->last_facechange[DESIRED_DISP] = make_int (BUF_FACECHANGE (b));
|
|
5211 Fset_marker (w->last_start[DESIRED_DISP], make_int (startp), w->buffer);
|
|
5212 Fset_marker (w->last_point[DESIRED_DISP], make_int (pointm), w->buffer);
|
|
5213
|
|
5214 if (!skip_output)
|
|
5215 {
|
|
5216 Bufpos start = marker_position (w->start[DESIRED_DISP]);
|
|
5217 Bufpos end = (w->window_end_pos[DESIRED_DISP] == -1
|
|
5218 ? BUF_ZV (b)
|
|
5219 : BUF_Z (b) - w->window_end_pos[DESIRED_DISP] - 1);
|
|
5220
|
|
5221 update_line_start_cache (w, start, end, pointm, 1);
|
|
5222 redisplay_output_window (w);
|
|
5223 }
|
|
5224
|
|
5225 /* #### This should be dependent on face changes and will need to be
|
|
5226 somewhere else once tty updates occur on a per-frame basis. */
|
|
5227 mark_face_cachels_as_clean (w);
|
|
5228
|
|
5229 w->windows_changed = 0;
|
|
5230 }
|
|
5231
|
|
5232 /* Call buffer_reset_changes for all buffers present in any window
|
|
5233 currently visible in all frames on all devices. #### There has to
|
|
5234 be a better way to do this. */
|
|
5235
|
|
5236 static int
|
|
5237 reset_buffer_changes_mapfun (struct window *w, void *ignored_closure)
|
|
5238 {
|
|
5239 buffer_reset_changes (XBUFFER (w->buffer));
|
|
5240 return 0;
|
|
5241 }
|
|
5242
|
|
5243 static void
|
|
5244 reset_buffer_changes (void)
|
|
5245 {
|
|
5246 Lisp_Object frmcons, devcons, concons;
|
|
5247
|
|
5248 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
|
|
5249 {
|
|
5250 struct frame *f = XFRAME (XCAR (frmcons));
|
|
5251
|
70
|
5252 if (FRAME_VISIBLE_P (f))
|
0
|
5253 map_windows (f, reset_buffer_changes_mapfun, 0);
|
|
5254 }
|
|
5255 }
|
|
5256
|
|
5257 /* Ensure that all windows underneath the given window in the window
|
|
5258 hierarchy are correctly displayed. */
|
|
5259
|
|
5260 static void
|
|
5261 redisplay_windows (Lisp_Object window, int skip_selected)
|
|
5262 {
|
|
5263 for (; !NILP (window) ; window = XWINDOW (window)->next)
|
|
5264 {
|
|
5265 redisplay_window (window, skip_selected);
|
|
5266 }
|
|
5267 }
|
|
5268
|
|
5269 static int
|
|
5270 call_redisplay_end_triggers (struct window *w, void *closure)
|
|
5271 {
|
|
5272 Bufpos lrpos = w->last_redisplay_pos;
|
|
5273 w->last_redisplay_pos = 0;
|
|
5274 if (!NILP (w->buffer)
|
|
5275 && !NILP (w->redisplay_end_trigger)
|
|
5276 && lrpos > 0)
|
|
5277 {
|
|
5278 Bufpos pos;
|
|
5279
|
|
5280 if (MARKERP (w->redisplay_end_trigger)
|
|
5281 && XMARKER (w->redisplay_end_trigger)->buffer != 0)
|
|
5282 pos = marker_position (w->redisplay_end_trigger);
|
|
5283 else if (INTP (w->redisplay_end_trigger))
|
|
5284 pos = XINT (w->redisplay_end_trigger);
|
|
5285 else
|
|
5286 {
|
|
5287 w->redisplay_end_trigger = Qnil;
|
|
5288 return 0;
|
|
5289 }
|
|
5290
|
|
5291 if (lrpos >= pos)
|
|
5292 {
|
|
5293 Lisp_Object window = Qnil;
|
|
5294 XSETWINDOW (window, w);
|
|
5295 va_run_hook_with_args_in_buffer (XBUFFER (w->buffer),
|
|
5296 Qredisplay_end_trigger_functions,
|
|
5297 2, window,
|
|
5298 w->redisplay_end_trigger);
|
|
5299 w->redisplay_end_trigger = Qnil;
|
|
5300 }
|
|
5301 }
|
|
5302
|
|
5303 return 0;
|
|
5304 }
|
|
5305
|
|
5306 /* Ensure that all windows on the given frame are correctly displayed. */
|
|
5307
|
|
5308 static int
|
|
5309 redisplay_frame (struct frame *f, int preemption_check)
|
|
5310 {
|
|
5311 struct device *d = XDEVICE (f->device);
|
|
5312
|
|
5313 if (preemption_check)
|
|
5314 {
|
|
5315 /* The preemption check itself takes a lot of time,
|
|
5316 so normally don't do it here. We do it if called
|
|
5317 from Lisp, though (`redisplay-frame'). */
|
|
5318 int preempted;
|
|
5319
|
|
5320 REDISPLAY_PREEMPTION_CHECK;
|
|
5321 if (preempted)
|
|
5322 return 1;
|
|
5323 }
|
|
5324
|
|
5325 /* Before we put a hold on frame size changes, attempt to process
|
|
5326 any which are already pending. */
|
|
5327 if (f->size_change_pending)
|
|
5328 change_frame_size (f, f->new_height, f->new_width, 0);
|
|
5329
|
|
5330 /* The menubar, toolbar, and icon updates must be done before
|
|
5331 hold_frame_size_changes is called and we are officially
|
|
5332 'in_display'. They may eval lisp code which may call Fsignal.
|
|
5333 If in_display is set Fsignal will abort. */
|
|
5334
|
|
5335 #ifdef HAVE_MENUBARS
|
|
5336 /* Update the menubar. It is done first since it could change
|
|
5337 the menubar's visibility. This way we avoid having flashing
|
|
5338 caused by an Expose event generated by the visibility change
|
|
5339 being handled. */
|
|
5340 update_frame_menubars (f);
|
|
5341 #endif
|
|
5342
|
|
5343 #ifdef HAVE_TOOLBARS
|
|
5344 /* Update the toolbars. */
|
|
5345 update_frame_toolbars (f);
|
|
5346 #endif
|
|
5347
|
|
5348 hold_frame_size_changes ();
|
|
5349
|
|
5350 /* ----------------- BEGIN CRITICAL REDISPLAY SECTION ---------------- */
|
|
5351 /* Within this section, we are defenseless and assume that the
|
|
5352 following cannot happen:
|
|
5353
|
|
5354 1) garbage collection
|
|
5355 2) Lisp code evaluation
|
|
5356 3) frame size changes
|
|
5357
|
|
5358 We ensure (3) by calling hold_frame_size_changes(), which
|
|
5359 will cause any pending frame size changes to get put on hold
|
|
5360 till after the end of the critical section. (1) follows
|
|
5361 automatically if (2) is met. #### Unfortunately, there are
|
|
5362 some places where Lisp code can be called within this section.
|
|
5363 We need to remove them.
|
|
5364
|
|
5365 If Fsignal() is called during this critical section, we
|
|
5366 will abort().
|
|
5367
|
|
5368 If garbage collection is called during this critical section,
|
|
5369 we simply return. #### We should abort instead.
|
|
5370
|
|
5371 #### If a frame-size change does occur we should probably
|
|
5372 actually be preempting redisplay. */
|
|
5373
|
|
5374 /* If we clear the frame we have to force its contents to be redrawn. */
|
|
5375 if (f->clear)
|
|
5376 f->frame_changed = 1;
|
|
5377
|
|
5378 /* Erase the frame before outputting its contents. */
|
|
5379 if (f->clear)
|
|
5380 DEVMETH (d, clear_frame, (f));
|
|
5381
|
|
5382 /* Do the selected window first. */
|
|
5383 redisplay_window (FRAME_SELECTED_WINDOW (f), 0);
|
|
5384
|
|
5385 /* Then do the rest. */
|
|
5386 redisplay_windows (f->root_window, 1);
|
|
5387
|
|
5388 /* We now call the output_end routine for tty frames. We delay
|
|
5389 doing so in order to avoid cursor flicker. So much for 100%
|
|
5390 encapsulation. */
|
|
5391 if (FRAME_TTY_P (f))
|
|
5392 DEVMETH (d, output_end, (d));
|
|
5393
|
|
5394 update_frame_title (f);
|
|
5395
|
|
5396 f->buffers_changed = 0;
|
|
5397 f->clip_changed = 0;
|
|
5398 f->extents_changed = 0;
|
|
5399 f->faces_changed = 0;
|
|
5400 f->frame_changed = 0;
|
|
5401 f->icon_changed = 0;
|
|
5402 f->menubar_changed = 0;
|
|
5403 f->modeline_changed = 0;
|
|
5404 f->point_changed = 0;
|
|
5405 f->toolbar_changed = 0;
|
|
5406 f->windows_changed = 0;
|
|
5407 f->windows_structure_changed = 0;
|
|
5408 f->window_face_cache_reset = 0;
|
|
5409
|
|
5410 f->clear = 0;
|
|
5411
|
|
5412 if (!f->size_change_pending)
|
|
5413 f->size_changed = 0;
|
|
5414
|
|
5415 /* ----------------- END CRITICAL REDISPLAY SECTION ---------------- */
|
|
5416
|
|
5417 /* Allow frame size changes to occur again.
|
|
5418
|
|
5419 #### what happens if changes to other frames happen? */
|
|
5420 unhold_one_frame_size_changes (f);
|
|
5421
|
|
5422 map_windows (f, call_redisplay_end_triggers, 0);
|
|
5423 return 0;
|
|
5424 }
|
|
5425
|
|
5426 /* Ensure that all frames on the given device are correctly displayed. */
|
|
5427
|
|
5428 static int
|
|
5429 redisplay_device (struct device *d)
|
|
5430 {
|
|
5431 Lisp_Object frame, frmcons;
|
|
5432 int preempted = 0;
|
|
5433 int size_change_failed = 0;
|
|
5434 struct frame *f;
|
|
5435
|
|
5436 if (DEVICE_STREAM_P (d)) /* nothing to do */
|
|
5437 return 0;
|
|
5438
|
|
5439 /* It is possible that redisplay has been called before the
|
|
5440 device is fully initialized. If so then continue with the
|
|
5441 next device. */
|
|
5442 if (NILP (DEVICE_SELECTED_FRAME (d)))
|
|
5443 return 0;
|
|
5444
|
|
5445 REDISPLAY_PREEMPTION_CHECK;
|
|
5446 if (preempted)
|
|
5447 return 1;
|
|
5448
|
|
5449 /* Always do the selected frame first. */
|
|
5450 frame = DEVICE_SELECTED_FRAME (d);
|
|
5451
|
|
5452 f = XFRAME (frame);
|
|
5453
|
|
5454 if (f->icon_changed || f->windows_changed)
|
|
5455 update_frame_icon (f);
|
|
5456
|
70
|
5457 if (FRAME_VISIBLE_P (f))
|
0
|
5458 {
|
|
5459 if (f->buffers_changed || f->clip_changed || f->extents_changed
|
|
5460 || f->faces_changed || f->frame_changed || f->menubar_changed
|
|
5461 || f->modeline_changed || f->point_changed || f->size_changed
|
|
5462 || f->toolbar_changed || f->windows_changed
|
|
5463 || f->windows_structure_changed)
|
|
5464 {
|
|
5465 preempted = redisplay_frame (f, 0);
|
|
5466 }
|
|
5467
|
|
5468 if (preempted)
|
|
5469 return 1;
|
|
5470
|
|
5471 /* If the frame redisplay did not get preempted, then this flag
|
|
5472 should have gotten set to 0. It might be possible for that
|
|
5473 not to happen if a size change event were to occur at an odd
|
|
5474 time. To make sure we don't miss anything we simply don't
|
|
5475 reset the top level flags until the condition ends up being
|
|
5476 in the right state. */
|
|
5477 if (f->size_changed)
|
|
5478 size_change_failed = 1;
|
|
5479 }
|
|
5480
|
|
5481 DEVICE_FRAME_LOOP (frmcons, d)
|
|
5482 {
|
|
5483 f = XFRAME (XCAR (frmcons));
|
|
5484
|
|
5485 if (f == XFRAME (DEVICE_SELECTED_FRAME (d)))
|
|
5486 continue;
|
|
5487
|
|
5488 if (f->icon_changed || f->windows_changed)
|
|
5489 update_frame_icon (f);
|
|
5490
|
70
|
5491 if (FRAME_VISIBLE_P (f))
|
0
|
5492 {
|
|
5493 if (f->buffers_changed || f->clip_changed || f->extents_changed
|
|
5494 || f->faces_changed || f->frame_changed || f->menubar_changed
|
|
5495 || f->modeline_changed || f->point_changed || f->size_changed
|
|
5496 || f->toolbar_changed || f->windows_changed
|
|
5497 || f->windows_structure_changed)
|
|
5498 {
|
|
5499 preempted = redisplay_frame (f, 0);
|
|
5500 }
|
|
5501
|
|
5502 if (preempted)
|
|
5503 return 1;
|
|
5504
|
|
5505 if (f->size_change_pending)
|
|
5506 size_change_failed = 1;
|
|
5507 }
|
|
5508 }
|
|
5509
|
|
5510 /* If we get here then we redisplayed all of our frames without
|
|
5511 getting preempted so mark ourselves as clean. */
|
|
5512 d->buffers_changed = 0;
|
|
5513 d->clip_changed = 0;
|
|
5514 d->extents_changed = 0;
|
|
5515 d->faces_changed = 0;
|
|
5516 d->frame_changed = 0;
|
|
5517 d->icon_changed = 0;
|
|
5518 d->menubar_changed = 0;
|
|
5519 d->modeline_changed = 0;
|
|
5520 d->point_changed = 0;
|
|
5521 d->toolbar_changed = 0;
|
|
5522 d->windows_changed = 0;
|
|
5523 d->windows_structure_changed = 0;
|
|
5524
|
|
5525 if (!size_change_failed)
|
|
5526 d->size_changed = 0;
|
|
5527
|
|
5528 return 0;
|
|
5529 }
|
|
5530
|
|
5531 static Lisp_Object
|
|
5532 restore_profiling_redisplay_flag (Lisp_Object val)
|
|
5533 {
|
|
5534 profiling_redisplay_flag = XINT (val);
|
|
5535 return Qnil;
|
|
5536 }
|
|
5537
|
|
5538 /* Ensure that all windows on all frames on all devices are displaying
|
|
5539 the current contents of their respective buffers. */
|
|
5540
|
|
5541 static void
|
|
5542 redisplay_without_hooks (void)
|
|
5543 {
|
|
5544 Lisp_Object devcons, concons;
|
|
5545 int size_change_failed = 0;
|
|
5546 int count = specpdl_depth ();
|
|
5547
|
|
5548 if (profiling_active)
|
|
5549 {
|
|
5550 record_unwind_protect (restore_profiling_redisplay_flag,
|
|
5551 make_int (profiling_redisplay_flag));
|
|
5552 profiling_redisplay_flag = 1;
|
|
5553 }
|
|
5554
|
|
5555 if (asynch_device_change_pending)
|
|
5556 handle_asynch_device_change ();
|
|
5557
|
|
5558 if (!buffers_changed && !clip_changed && !extents_changed && !faces_changed
|
|
5559 && !frame_changed && !icon_changed && !menubar_changed
|
|
5560 && !modeline_changed && !point_changed && !size_changed
|
|
5561 && !toolbar_changed && !windows_changed && !windows_structure_changed
|
|
5562 && !disable_preemption && preemption_count < max_preempts)
|
|
5563 goto done;
|
|
5564
|
|
5565 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
5566 {
|
|
5567 struct device *d = XDEVICE (XCAR (devcons));
|
|
5568 int preempted;
|
|
5569
|
|
5570 if (d->buffers_changed || d->clip_changed || d->extents_changed
|
|
5571 || d->faces_changed || d->frame_changed
|
|
5572 || d->icon_changed || d->menubar_changed
|
|
5573 || d->modeline_changed || d->point_changed || d->size_changed
|
|
5574 || d->toolbar_changed || d->windows_changed
|
|
5575 || d->windows_structure_changed)
|
|
5576 {
|
|
5577 preempted = redisplay_device (d);
|
|
5578
|
|
5579 if (preempted)
|
|
5580 {
|
|
5581 preemption_count++;
|
|
5582 RESET_CHANGED_SET_FLAGS;
|
|
5583 goto done;
|
|
5584 }
|
|
5585
|
|
5586 /* See comment in redisplay_device. */
|
|
5587 if (d->size_changed)
|
|
5588 size_change_failed = 1;
|
|
5589 }
|
|
5590 }
|
|
5591 preemption_count = 0;
|
|
5592
|
|
5593 /* Mark redisplay as accurate */
|
|
5594 buffers_changed = 0;
|
|
5595 clip_changed = 0;
|
|
5596 extents_changed = 0;
|
|
5597 frame_changed = 0;
|
|
5598 icon_changed = 0;
|
|
5599 menubar_changed = 0;
|
|
5600 modeline_changed = 0;
|
|
5601 point_changed = 0;
|
|
5602 toolbar_changed = 0;
|
|
5603 windows_changed = 0;
|
|
5604 windows_structure_changed = 0;
|
|
5605 RESET_CHANGED_SET_FLAGS;
|
|
5606
|
|
5607 if (faces_changed)
|
|
5608 {
|
|
5609 mark_all_faces_as_clean ();
|
|
5610 faces_changed = 0;
|
|
5611 }
|
|
5612
|
|
5613 if (!size_change_failed)
|
|
5614 size_changed = 0;
|
|
5615
|
|
5616 reset_buffer_changes ();
|
|
5617
|
|
5618 done:
|
|
5619 unbind_to (count, Qnil);
|
|
5620 }
|
|
5621
|
|
5622 void
|
|
5623 redisplay (void)
|
|
5624 {
|
|
5625 if (last_display_warning_tick != display_warning_tick &&
|
|
5626 !inhibit_warning_display)
|
|
5627 {
|
|
5628 /* If an error occurs during this function, oh well.
|
|
5629 If we report another warning, we could get stuck in an
|
|
5630 infinite loop reporting warnings. */
|
|
5631 call0_trapping_errors (0, Qdisplay_warning_buffer);
|
|
5632 last_display_warning_tick = display_warning_tick;
|
|
5633 }
|
|
5634 /* The run_hook_trapping_errors functions are smart enough not
|
|
5635 to do any evalling if the hook function is empty, so there
|
|
5636 should not be any significant time loss. All places in the
|
|
5637 C code that call redisplay() are prepared to handle GCing,
|
|
5638 so we should be OK. */
|
|
5639 #ifndef INHIBIT_REDISPLAY_HOOKS
|
|
5640 run_hook_trapping_errors ("Error in pre-redisplay-hook",
|
|
5641 Qpre_redisplay_hook);
|
|
5642 #endif
|
|
5643
|
|
5644 redisplay_without_hooks ();
|
|
5645
|
|
5646 #ifndef INHIBIT_REDISPLAY_HOOKS
|
|
5647 run_hook_trapping_errors ("Error in post-redisplay-hook",
|
|
5648 Qpost_redisplay_hook);
|
|
5649 #endif
|
|
5650 }
|
|
5651
|
|
5652 /* Inefficiently determine the line number of the line point is on and
|
|
5653 return it as a string. Always do this regardless of whether
|
|
5654 line_number_mode is true. */
|
|
5655
|
|
5656 static char window_line_number_buf[100];
|
|
5657 static char *
|
|
5658 window_line_number (struct window *w, int type)
|
|
5659 {
|
|
5660 struct device *d = XDEVICE (XFRAME (w->frame)->device);
|
|
5661 struct buffer *b = XBUFFER (w->buffer);
|
|
5662 Bufpos end =
|
70
|
5663 ((w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))))
|
0
|
5664 ? BUF_PT (b)
|
|
5665 : marker_position (w->pointm[type]));
|
|
5666 int lots = 999999999;
|
|
5667 int shortage, line;
|
|
5668
|
|
5669 scan_buffer (b, '\n', end, 0, -lots, &shortage, 0);
|
|
5670 line = lots - shortage + 1;
|
|
5671
|
|
5672 sprintf (window_line_number_buf, "%d", line);
|
|
5673
|
|
5674 return (window_line_number_buf);
|
|
5675 }
|
|
5676
|
|
5677 /* Given a character representing an object in a modeline
|
|
5678 specification, return a string (stored into the global array
|
|
5679 `mode_spec_bufbyte_string') with the information that object
|
|
5680 represents.
|
|
5681
|
|
5682 This function is largely unchanged from previous versions of the
|
|
5683 redisplay engine. */
|
|
5684
|
|
5685 static void
|
|
5686 decode_mode_spec (struct window *w, Emchar spec, int type)
|
|
5687 {
|
|
5688 Lisp_Object obj = Qnil;
|
|
5689 CONST char *str = NULL;
|
|
5690 struct buffer *b = XBUFFER (w->buffer);
|
|
5691
|
|
5692 Dynarr_reset (mode_spec_bufbyte_string);
|
|
5693
|
|
5694 switch (spec)
|
|
5695 {
|
|
5696 /* print buffer name */
|
|
5697 case 'b':
|
|
5698 obj = b->name;
|
|
5699 break;
|
|
5700
|
|
5701 /* print visited file name */
|
|
5702 case 'f':
|
|
5703 obj = b->filename;
|
|
5704 break;
|
|
5705
|
|
5706 /* print the current column */
|
|
5707 case 'c':
|
|
5708 {
|
72
|
5709 int col = current_column (b) + (column_number_start_at_one != 0);
|
0
|
5710 int temp = col;
|
|
5711 int size = 2;
|
|
5712 char *buf;
|
|
5713
|
|
5714 while (temp >= 10)
|
|
5715 {
|
|
5716 temp /= 10;
|
|
5717 size++;
|
|
5718 }
|
|
5719
|
|
5720 buf = (char *) alloca (size * sizeof (char));
|
|
5721 sprintf (buf, "%d", col);
|
|
5722
|
|
5723 Dynarr_add_many (mode_spec_bufbyte_string,
|
|
5724 (CONST Bufbyte *) buf, strlen (buf));
|
|
5725
|
|
5726 goto decode_mode_spec_done;
|
|
5727 }
|
|
5728
|
70
|
5729 #ifdef MULE
|
|
5730 /* print the file coding system */
|
|
5731 case 'C':
|
|
5732 {
|
|
5733 Lisp_Object codesys = b->file_coding_system;
|
|
5734 /* Be very careful here not to get an error. */
|
|
5735 if (NILP (codesys) || SYMBOLP (codesys) || CODING_SYSTEMP (codesys))
|
|
5736 {
|
|
5737 codesys = Ffind_coding_system (codesys);
|
|
5738 if (CODING_SYSTEMP (codesys))
|
|
5739 obj = Fcoding_system_property (codesys, Qmnemonic);
|
|
5740 }
|
|
5741 }
|
|
5742 break;
|
|
5743 #endif
|
16
|
5744
|
0
|
5745 /* print the current line number */
|
|
5746 case 'l':
|
|
5747 str = window_line_number (w, type);
|
|
5748 break;
|
|
5749
|
|
5750 /* print value of mode-name (obsolete) */
|
|
5751 case 'm':
|
|
5752 obj = b->mode_name;
|
|
5753 break;
|
|
5754
|
|
5755 /* print Narrow if appropriate */
|
|
5756 case 'n':
|
|
5757 if (BUF_BEGV (b) > BUF_BEG (b)
|
|
5758 || BUF_ZV (b) < BUF_Z (b))
|
|
5759 str = " Narrow";
|
|
5760 break;
|
|
5761
|
|
5762 /* print %, * or hyphen, if buffer is read-only, modified or neither */
|
|
5763 case '*':
|
|
5764 str = (!NILP (b->read_only)
|
|
5765 ? "%"
|
|
5766 : ((BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
|
|
5767 ? "*"
|
|
5768 : "-"));
|
|
5769 break;
|
|
5770
|
|
5771 /* print * or hyphen -- XEmacs change to allow a buffer to be
|
|
5772 read-only but still indicate whether it is modified. */
|
|
5773 case '+':
|
|
5774 str = ((BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
|
|
5775 ? "*"
|
|
5776 : (!NILP (b->read_only)
|
|
5777 ? "%"
|
|
5778 : "-"));
|
|
5779 break;
|
|
5780
|
|
5781 /* #### defined in 19.29 decode_mode_spec, but not in
|
|
5782 modeline-format doc string. */
|
|
5783 /* This differs from %* in that it ignores read-only-ness. */
|
|
5784 case '&':
|
|
5785 str = ((BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
|
|
5786 ? "*"
|
|
5787 : "-");
|
|
5788 break;
|
|
5789
|
|
5790 /* print process status */
|
|
5791 case 's':
|
|
5792 obj = Fget_buffer_process (w->buffer);
|
|
5793 if (NILP (obj))
|
|
5794 str = GETTEXT ("no process");
|
|
5795 else
|
|
5796 obj = Fsymbol_name (Fprocess_status (obj));
|
|
5797 break;
|
|
5798
|
|
5799 /* print name of selected frame (only meaningful under X Windows) */
|
|
5800 case 'S':
|
|
5801 obj = XFRAME (w->frame)->name;
|
|
5802 break;
|
|
5803
|
|
5804 /* indicate TEXT or BINARY */
|
|
5805 case 't':
|
|
5806 #ifdef MSDOS
|
|
5807 str = NILP (b->buffer_file_type) ? "T" : "B";
|
|
5808 #else /* not MSDOS */
|
|
5809 str = "T";
|
|
5810 #endif /* not MSDOS */
|
10
|
5811 break;
|
0
|
5812
|
|
5813 /* print percent of buffer above top of window, or Top, Bot or All */
|
|
5814 case 'p':
|
|
5815 {
|
|
5816 Bufpos pos = marker_position (w->start[type]);
|
|
5817 Charcount total = BUF_ZV (b) - BUF_BEGV (b);
|
|
5818
|
|
5819 /* This had better be while the desired lines are being done. */
|
|
5820 if (w->window_end_pos[type] <= BUF_Z (b) - BUF_ZV (b))
|
|
5821 {
|
|
5822 if (pos <= BUF_BEGV (b))
|
|
5823 str = "All";
|
|
5824 else
|
|
5825 str = "Bottom";
|
|
5826 }
|
|
5827 else if (pos <= BUF_BEGV (b))
|
|
5828 str = "Top";
|
|
5829 else
|
|
5830 {
|
|
5831 /* This hard limit is ok since the string it will hold has a
|
|
5832 fixed maximum length of 3. But just to be safe... */
|
|
5833 char buf[10];
|
|
5834
|
|
5835 total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total;
|
|
5836
|
|
5837 /* We can't normally display a 3-digit number, so get us a
|
|
5838 2-digit number that is close. */
|
|
5839 if (total == 100)
|
|
5840 total = 99;
|
|
5841
|
|
5842 sprintf (buf, "%2d%%", total);
|
|
5843 Dynarr_add_many (mode_spec_bufbyte_string, (Bufbyte *) buf,
|
|
5844 strlen (buf));
|
|
5845
|
|
5846 goto decode_mode_spec_done;
|
|
5847 }
|
|
5848 break;
|
|
5849 }
|
|
5850
|
|
5851 /* print percent of buffer above bottom of window, perhaps plus
|
|
5852 Top, or print Bottom or All */
|
|
5853 case 'P':
|
|
5854 {
|
|
5855 Bufpos toppos = marker_position (w->start[type]);
|
|
5856 Bufpos botpos = BUF_Z (b) - w->window_end_pos[type];
|
|
5857 Charcount total = BUF_ZV (b) - BUF_BEGV (b);
|
|
5858
|
10
|
5859 /* botpos is only accurate as of the last redisplay, so we can
|
16
|
5860 only treat it as a hint. In particular, after erase-buffer,
|
|
5861 botpos may be negative. */
|
10
|
5862 if (botpos < toppos)
|
|
5863 botpos = toppos;
|
16
|
5864
|
0
|
5865 if (botpos >= BUF_ZV (b))
|
|
5866 {
|
|
5867 if (toppos <= BUF_BEGV (b))
|
|
5868 str = "All";
|
|
5869 else
|
|
5870 str = "Bottom";
|
|
5871 }
|
|
5872 else
|
|
5873 {
|
|
5874 /* This hard limit is ok since the string it will hold has a
|
|
5875 fixed maximum length of around 6. But just to be safe... */
|
|
5876 char buf[10];
|
|
5877
|
|
5878 total = ((botpos - BUF_BEGV (b)) * 100 + total - 1) / total;
|
|
5879
|
|
5880 /* We can't normally display a 3-digit number, so get us a
|
|
5881 2-digit number that is close. */
|
|
5882 if (total == 100)
|
|
5883 total = 99;
|
|
5884
|
|
5885 if (toppos <= BUF_BEGV (b))
|
|
5886 sprintf (buf, "Top%2d%%", total);
|
|
5887 else
|
|
5888 sprintf (buf, "%2d%%", total);
|
|
5889
|
|
5890 Dynarr_add_many (mode_spec_bufbyte_string, (Bufbyte *) buf,
|
|
5891 strlen (buf));
|
|
5892
|
|
5893 goto decode_mode_spec_done;
|
|
5894 }
|
|
5895 break;
|
|
5896 }
|
|
5897
|
|
5898 /* print % */
|
|
5899 case '%':
|
|
5900 str = "%";
|
|
5901 break;
|
|
5902
|
|
5903 /* print one [ for each recursive editing level. */
|
|
5904 case '[':
|
|
5905 {
|
|
5906 int i;
|
|
5907
|
|
5908 if (command_loop_level > 5)
|
|
5909 {
|
|
5910 str = "[[[... ";
|
|
5911 break;
|
|
5912 }
|
|
5913
|
|
5914 for (i = 0; i < command_loop_level; i++)
|
|
5915 Dynarr_add (mode_spec_bufbyte_string, '[');
|
|
5916
|
|
5917 goto decode_mode_spec_done;
|
|
5918 }
|
|
5919
|
|
5920 /* print one ] for each recursive editing level. */
|
|
5921 case ']':
|
|
5922 {
|
|
5923 int i;
|
|
5924
|
|
5925 if (command_loop_level > 5)
|
|
5926 {
|
|
5927 str = "...]]]";
|
|
5928 break;
|
|
5929 }
|
|
5930
|
|
5931 for (i = 0; i < command_loop_level; i++)
|
|
5932 Dynarr_add (mode_spec_bufbyte_string, ']');
|
|
5933
|
|
5934 goto decode_mode_spec_done;
|
|
5935 }
|
|
5936
|
|
5937 /* print infinitely many dashes -- handle at top level now */
|
|
5938 case '-':
|
|
5939 break;
|
|
5940
|
|
5941 }
|
|
5942
|
|
5943 if (STRINGP (obj))
|
16
|
5944 Dynarr_add_many (mode_spec_bufbyte_string,
|
|
5945 XSTRING_DATA (obj),
|
|
5946 XSTRING_LENGTH (obj));
|
0
|
5947 else if (str)
|
|
5948 Dynarr_add_many (mode_spec_bufbyte_string, (Bufbyte *) str, strlen (str));
|
|
5949
|
|
5950 decode_mode_spec_done:
|
|
5951 Dynarr_add (mode_spec_bufbyte_string, '\0');
|
|
5952 }
|
|
5953
|
16
|
5954 /* Given a display line, free all of its data structures. */
|
0
|
5955
|
|
5956 static void
|
|
5957 free_display_line (struct display_line *dl)
|
|
5958 {
|
|
5959 int block;
|
|
5960
|
|
5961 if (dl->display_blocks)
|
|
5962 {
|
|
5963 for (block = 0; block < Dynarr_largest (dl->display_blocks); block++)
|
|
5964 {
|
|
5965 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
5966
|
|
5967 Dynarr_free (db->runes);
|
|
5968 }
|
|
5969
|
|
5970 Dynarr_free (dl->display_blocks);
|
|
5971 dl->display_blocks = 0;
|
|
5972 }
|
|
5973
|
|
5974 if (dl->left_glyphs)
|
|
5975 {
|
|
5976 Dynarr_free (dl->left_glyphs);
|
|
5977 dl->left_glyphs = 0;
|
|
5978 }
|
|
5979
|
|
5980 if (dl->right_glyphs)
|
|
5981 {
|
|
5982 Dynarr_free (dl->right_glyphs);
|
|
5983 dl->right_glyphs = 0;
|
|
5984 }
|
|
5985 }
|
|
5986
|
|
5987
|
|
5988 /* Given an array of display lines, free them and all data structures
|
|
5989 contained within them. */
|
|
5990
|
|
5991 static void
|
|
5992 free_display_lines (display_line_dynarr *dla)
|
|
5993 {
|
|
5994 int line;
|
|
5995
|
|
5996 for (line = 0; line < Dynarr_largest (dla); line++)
|
|
5997 {
|
|
5998 free_display_line (Dynarr_atp (dla, line));
|
|
5999 }
|
|
6000
|
|
6001 Dynarr_free (dla);
|
|
6002 }
|
|
6003
|
|
6004 /* Call internal free routine for each set of display lines. */
|
|
6005
|
|
6006 void
|
|
6007 free_display_structs (struct window_mirror *mir)
|
|
6008 {
|
|
6009 if (mir->current_display_lines)
|
|
6010 {
|
|
6011 free_display_lines (mir->current_display_lines);
|
|
6012 mir->current_display_lines = 0;
|
|
6013 }
|
|
6014
|
|
6015 if (mir->desired_display_lines)
|
|
6016 {
|
|
6017 free_display_lines (mir->desired_display_lines);
|
|
6018 mir->desired_display_lines = 0;
|
|
6019 }
|
|
6020 }
|
|
6021
|
|
6022
|
|
6023 static void
|
|
6024 mark_redisplay_structs (display_line_dynarr *dla,
|
|
6025 void (*markobj) (Lisp_Object))
|
|
6026 {
|
|
6027 int line;
|
|
6028
|
|
6029 for (line = 0; line < Dynarr_length (dla); line++)
|
|
6030 {
|
|
6031 int block, loop;
|
|
6032 struct display_line *dl = Dynarr_atp (dla, line);
|
|
6033
|
|
6034 for (block = 0; block < Dynarr_length (dl->display_blocks); block++)
|
|
6035 {
|
|
6036 int rune;
|
|
6037 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
6038
|
|
6039 for (rune = 0; rune < Dynarr_length (db->runes); rune++)
|
|
6040 {
|
|
6041 struct rune *rb = Dynarr_atp (db->runes, rune);
|
|
6042
|
|
6043 if (rb->type == RUNE_DGLYPH)
|
|
6044 {
|
|
6045 if (!NILP (rb->object.dglyph.glyph))
|
|
6046 ((markobj) (rb->object.dglyph.glyph));
|
|
6047 if (!NILP (rb->object.dglyph.extent))
|
|
6048 ((markobj) (rb->object.dglyph.extent));
|
|
6049 }
|
|
6050 }
|
|
6051 }
|
|
6052
|
|
6053 for (loop = 0; loop < 2; loop++)
|
|
6054 {
|
|
6055 glyph_block_dynarr *gba = (loop
|
|
6056 ? dl->right_glyphs
|
|
6057 : dl->left_glyphs);
|
|
6058
|
|
6059 if (gba != NULL)
|
|
6060 {
|
|
6061 for (block = 0; block < Dynarr_length (gba); block++)
|
|
6062 {
|
|
6063 struct glyph_block *gb = Dynarr_atp (gba, block);
|
|
6064
|
|
6065 if (!NILP (gb->glyph))
|
|
6066 ((markobj) (gb->glyph));
|
|
6067 if (!NILP (gb->extent))
|
|
6068 ((markobj) (gb->extent));
|
|
6069 }
|
|
6070 }
|
|
6071 }
|
|
6072 }
|
|
6073 }
|
|
6074
|
|
6075 static void
|
|
6076 mark_window_mirror (struct window_mirror *mir, void (*markobj)(Lisp_Object))
|
|
6077 {
|
|
6078 mark_redisplay_structs (mir->current_display_lines, markobj);
|
|
6079 mark_redisplay_structs (mir->desired_display_lines, markobj);
|
|
6080
|
|
6081 if (mir->next)
|
|
6082 mark_window_mirror (mir->next, markobj);
|
|
6083
|
|
6084 if (mir->hchild)
|
|
6085 mark_window_mirror (mir->hchild, markobj);
|
|
6086 else if (mir->vchild)
|
|
6087 mark_window_mirror (mir->vchild, markobj);
|
|
6088 }
|
|
6089
|
|
6090 void
|
|
6091 mark_redisplay (void (*markobj)(Lisp_Object))
|
|
6092 {
|
|
6093 Lisp_Object frmcons, devcons, concons;
|
|
6094
|
|
6095 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
|
|
6096 {
|
|
6097 struct frame *f = XFRAME (XCAR (frmcons));
|
|
6098 update_frame_window_mirror (f);
|
|
6099 mark_window_mirror (f->root_mirror, markobj);
|
|
6100 }
|
|
6101 }
|
|
6102
|
|
6103 /*****************************************************************************
|
|
6104 Line Start Cache Description and Rationale
|
|
6105
|
|
6106 The traditional scrolling code in Emacs breaks in a variable height world.
|
|
6107 It depends on the key assumption that the number of lines that can be
|
|
6108 displayed at any given time is fixed. This led to a complete separation
|
|
6109 of the scrolling code from the redisplay code. In order to fully support
|
|
6110 variable height lines, the scrolling code must actually be tightly
|
|
6111 integrated with redisplay. Only redisplay can determine how many lines
|
|
6112 will be displayed on a screen for any given starting point.
|
|
6113
|
|
6114 What is ideally wanted is a complete list of the starting buffer position
|
|
6115 for every possible display line of a buffer along with the height of that
|
|
6116 display line. Maintaining such a full list would be very expensive. We
|
|
6117 settle for having it include information for all areas which we happen to
|
|
6118 generate anyhow (i.e. the region currently being displayed) and for those
|
|
6119 areas we need to work with.
|
|
6120
|
|
6121 In order to ensure that the cache accurately represents what redisplay
|
|
6122 would actually show, it is necessary to invalidate it in many situations.
|
|
6123 If the buffer changes, the starting positions may no longer be correct.
|
|
6124 If a face or an extent has changed then the line heights may have altered.
|
|
6125 These events happen frequently enough that the cache can end up being
|
|
6126 constantly disabled. With this potentially constant invalidation when is
|
|
6127 the cache ever useful?
|
|
6128
|
|
6129 Even if the cache is invalidated before every single usage, it is
|
|
6130 necessary. Scrolling often requires knowledge about display lines which
|
|
6131 are actually above or below the visible region. The cache provides a
|
|
6132 convenient light-weight method of storing this information for multiple
|
|
6133 display regions. This knowledge is necessary for the scrolling code to
|
|
6134 always obey the First Golden Rule of Redisplay.
|
|
6135
|
|
6136 If the cache already contains all of the information that the scrolling
|
|
6137 routines happen to need so that it doesn't have to go generate it, then we
|
|
6138 are able to obey the Third Golden Rule of Redisplay. The first thing we
|
|
6139 do to help out the cache is to always add the displayed region. This
|
|
6140 region had to be generated anyway, so the cache ends up getting the
|
|
6141 information basically for free. In those cases where a user is simply
|
|
6142 scrolling around viewing a buffer there is a high probability that this is
|
|
6143 sufficient to always provide the needed information. The second thing we
|
|
6144 can do is be smart about invalidating the cache.
|
|
6145
|
|
6146 TODO -- Be smart about invalidating the cache. Potential places:
|
|
6147
|
|
6148 + Insertions at end-of-line which don't cause line-wraps do not alter the
|
|
6149 starting positions of any display lines. These types of buffer
|
|
6150 modifications should not invalidate the cache. This is actually a large
|
|
6151 optimization for redisplay speed as well.
|
|
6152
|
|
6153 + Buffer modifications frequently only affect the display of lines at and
|
|
6154 below where they occur. In these situations we should only invalidate
|
|
6155 the part of the cache starting at where the modification occurs.
|
|
6156
|
|
6157 In case you're wondering, the Second Golden Rule of Redisplay is not
|
|
6158 applicable.
|
|
6159 ****************************************************************************/
|
|
6160
|
|
6161 /* This will get used quite a bit so we don't want to be constantly
|
|
6162 allocating and freeing it. */
|
|
6163 line_start_cache_dynarr *internal_cache;
|
|
6164
|
|
6165 /* Makes internal_cache represent the TYPE display structs and only
|
|
6166 the TYPE display structs. */
|
|
6167
|
|
6168 static void
|
|
6169 update_internal_cache_list (struct window *w, int type)
|
|
6170 {
|
|
6171 int line;
|
|
6172 display_line_dynarr *dla = window_display_lines (w, type);
|
|
6173
|
|
6174 Dynarr_reset (internal_cache);
|
|
6175 for (line = 0; line < Dynarr_length (dla); line++)
|
|
6176 {
|
|
6177 struct display_line *dl = Dynarr_atp (dla, line);
|
|
6178
|
|
6179 if (dl->modeline)
|
|
6180 continue;
|
|
6181 else
|
|
6182 {
|
|
6183 struct line_start_cache lsc;
|
|
6184
|
|
6185 lsc.start = dl->bufpos;
|
|
6186 lsc.end = dl->end_bufpos;
|
|
6187 lsc.height = dl->ascent + dl->descent;
|
|
6188
|
|
6189 Dynarr_add (internal_cache, lsc);
|
|
6190 }
|
|
6191 }
|
|
6192 }
|
|
6193
|
|
6194 /* Reset the line cache if necessary. This should be run at the
|
|
6195 beginning of any function which access the cache. */
|
|
6196
|
|
6197 static void
|
|
6198 validate_line_start_cache (struct window *w)
|
|
6199 {
|
|
6200 struct buffer *b = XBUFFER (w->buffer);
|
|
6201 struct frame *f = XFRAME (w->frame);
|
|
6202
|
|
6203 if (!w->line_cache_validation_override)
|
|
6204 {
|
|
6205 /* f->extents_changed used to be in here because extent face and
|
|
6206 size changes can cause text shifting. However, the extent
|
|
6207 covering the region is constantly having its face set and
|
|
6208 priority altered by the mouse code. This means that the line
|
|
6209 start cache is constanty being invalidated. This is bad
|
|
6210 since the mouse code also triggers heavy usage of the cache.
|
|
6211 Since it is an unlikely that f->extents being changed
|
|
6212 indicates that the cache really needs to be updated and if it
|
|
6213 does redisplay will catch it pretty quickly we no longer
|
|
6214 invalidate the cache if it is set. This greatly speeds up
|
|
6215 dragging out regions with the mouse. */
|
|
6216 if (XINT (w->line_cache_last_updated) < BUF_MODIFF (b)
|
|
6217 || f->faces_changed
|
|
6218 || f->clip_changed)
|
|
6219 {
|
|
6220 Dynarr_reset (w->line_start_cache);
|
|
6221 }
|
|
6222 }
|
|
6223 }
|
|
6224
|
|
6225 /* Return the very first buffer position contained in the given
|
|
6226 window's cache, or -1 if the cache is empty. Assumes that the
|
|
6227 cache is valid. */
|
|
6228
|
|
6229 static Bufpos
|
|
6230 line_start_cache_start (struct window *w)
|
|
6231 {
|
|
6232 line_start_cache_dynarr *cache = w->line_start_cache;
|
|
6233
|
|
6234 if (!Dynarr_length (cache))
|
|
6235 return -1;
|
|
6236 else
|
|
6237 return (Dynarr_atp (cache, 0)->start);
|
|
6238 }
|
|
6239
|
|
6240 /* Return the very last buffer position contained in the given
|
|
6241 window's cache, or -1 if the cache is empty. Assumes that the
|
|
6242 cache is valid. */
|
|
6243
|
|
6244 static Bufpos
|
|
6245 line_start_cache_end (struct window *w)
|
|
6246 {
|
|
6247 line_start_cache_dynarr *cache = w->line_start_cache;
|
|
6248
|
|
6249 if (!Dynarr_length (cache))
|
|
6250 return -1;
|
|
6251 else
|
|
6252 return (Dynarr_atp (cache, Dynarr_length (cache) - 1)->end);
|
|
6253 }
|
|
6254
|
|
6255 /* Return the index of the line POINT is contained within in window
|
|
6256 W's line start cache. It will enlarge the cache or move the cache
|
|
6257 window in order to have POINT be present in the cache. MIN_PAST is
|
|
6258 a guarantee of the number of entries in the cache present on either
|
|
6259 side of POINT (unless a buffer boundary is hit). If MIN_PAST is -1
|
|
6260 then it will be treated as 0, but the cache window will not be
|
|
6261 allowed to shift. Returns -1 if POINT cannot be found in the cache
|
|
6262 for any reason. */
|
|
6263
|
|
6264 int
|
|
6265 point_in_line_start_cache (struct window *w, Bufpos point, int min_past)
|
|
6266 {
|
|
6267 struct buffer *b = XBUFFER (w->buffer);
|
|
6268 line_start_cache_dynarr *cache = w->line_start_cache;
|
|
6269 unsigned int top, bottom, pos;
|
|
6270
|
|
6271 validate_line_start_cache (w);
|
|
6272 w->line_cache_validation_override++;
|
|
6273
|
|
6274 /* Let functions pass in negative values, but we still treat -1
|
|
6275 specially. */
|
|
6276 /* #### bogosity alert */
|
|
6277 if (min_past < 0 && min_past != -1)
|
|
6278 min_past = -min_past;
|
|
6279
|
|
6280 if (!Dynarr_length (cache) || line_start_cache_start (w) > point
|
|
6281 || line_start_cache_end (w) < point)
|
|
6282 {
|
|
6283 int loop;
|
|
6284 int win_char_height = window_char_height (w, 1);
|
|
6285
|
|
6286 /* Occasionally we get here with a 0 height
|
|
6287 window. find_next_newline_no_quit will abort if we pass it a
|
|
6288 count of 0 so handle that case. */
|
|
6289 if (!win_char_height)
|
|
6290 win_char_height = 1;
|
|
6291
|
|
6292 if (!Dynarr_length (cache))
|
|
6293 {
|
|
6294 Bufpos from = find_next_newline_no_quit (b, point, -1);
|
|
6295 Bufpos to = find_next_newline_no_quit (b, from, win_char_height);
|
|
6296
|
|
6297 update_line_start_cache (w, from, to, point, 0);
|
|
6298
|
|
6299 if (!Dynarr_length (cache))
|
|
6300 {
|
|
6301 w->line_cache_validation_override--;
|
|
6302 return -1;
|
|
6303 }
|
|
6304 }
|
|
6305
|
|
6306 assert (Dynarr_length (cache));
|
|
6307
|
|
6308 loop = 0;
|
|
6309 while (line_start_cache_start (w) > point
|
|
6310 && (loop < cache_adjustment || min_past == -1))
|
|
6311 {
|
|
6312 Bufpos from, to;
|
|
6313
|
|
6314 from = line_start_cache_start (w);
|
|
6315 if (from <= BUF_BEGV (b))
|
|
6316 break;
|
|
6317
|
|
6318 from = find_next_newline_no_quit (b, from, -win_char_height);
|
|
6319 to = line_start_cache_end (w);
|
|
6320
|
|
6321 update_line_start_cache (w, from, to, point, 0);
|
|
6322 loop++;
|
|
6323 }
|
|
6324
|
|
6325 if (line_start_cache_start (w) > point)
|
|
6326 {
|
|
6327 Bufpos from, to;
|
|
6328
|
|
6329 from = find_next_newline_no_quit (b, point, -1);
|
|
6330 if (from >= BUF_ZV (b))
|
|
6331 {
|
|
6332 to = find_next_newline_no_quit (b, from, -win_char_height);
|
|
6333 from = to;
|
|
6334 to = BUF_ZV (b);
|
|
6335 }
|
|
6336 else
|
|
6337 to = find_next_newline_no_quit (b, from, win_char_height);
|
|
6338
|
|
6339 update_line_start_cache (w, from, to, point, 0);
|
|
6340 }
|
|
6341
|
|
6342 loop = 0;
|
|
6343 while (line_start_cache_end (w) < point
|
|
6344 && (loop < cache_adjustment || min_past == -1))
|
|
6345 {
|
|
6346 Bufpos from, to;
|
|
6347
|
|
6348 to = line_start_cache_end (w);
|
|
6349 if (to >= BUF_ZV (b))
|
|
6350 break;
|
|
6351
|
|
6352 from = line_start_cache_end (w);
|
|
6353 to = find_next_newline_no_quit (b, from, win_char_height);
|
|
6354
|
|
6355 update_line_start_cache (w, from, to, point, 0);
|
|
6356 loop++;
|
|
6357 }
|
|
6358
|
|
6359 if (line_start_cache_end (w) < point)
|
|
6360 {
|
|
6361 Bufpos from, to;
|
|
6362
|
|
6363 from = find_next_newline_no_quit (b, point, -1);
|
|
6364 if (from >= BUF_ZV (b))
|
|
6365 {
|
|
6366 to = find_next_newline_no_quit (b, from, -win_char_height);
|
|
6367 from = to;
|
|
6368 to = BUF_ZV (b);
|
|
6369 }
|
|
6370 else
|
|
6371 to = find_next_newline_no_quit (b, from, win_char_height);
|
|
6372
|
|
6373 update_line_start_cache (w, from, to, point, 0);
|
|
6374 }
|
|
6375 }
|
|
6376
|
|
6377 assert (Dynarr_length (cache));
|
|
6378
|
|
6379 if (min_past == -1)
|
|
6380 min_past = 0;
|
|
6381
|
|
6382 /* This could happen if the buffer is narrowed. */
|
|
6383 if (line_start_cache_start (w) > point
|
|
6384 || line_start_cache_end (w) < point)
|
|
6385 {
|
|
6386 w->line_cache_validation_override--;
|
|
6387 return -1;
|
|
6388 }
|
|
6389
|
|
6390 find_point_loop:
|
|
6391
|
|
6392 top = Dynarr_length (cache) - 1;
|
|
6393 bottom = 0;
|
|
6394
|
|
6395 while (1)
|
|
6396 {
|
|
6397 unsigned int new_pos;
|
|
6398 Bufpos start, end;
|
|
6399
|
|
6400 pos = (bottom + top + 1) >> 1;
|
|
6401 start = Dynarr_atp (cache, pos)->start;
|
|
6402 end = Dynarr_atp (cache, pos)->end;
|
|
6403
|
|
6404 if (point >= start && point <= end)
|
|
6405 {
|
|
6406 if (pos < min_past && line_start_cache_start (w) > BUF_BEGV (b))
|
|
6407 {
|
|
6408 Bufpos from =
|
|
6409 find_next_newline_no_quit (b, line_start_cache_start (w),
|
|
6410 -min_past - 1);
|
|
6411 Bufpos to = line_start_cache_end (w);
|
|
6412
|
|
6413 update_line_start_cache (w, from, to, point, 0);
|
|
6414 goto find_point_loop;
|
|
6415 }
|
|
6416 else if ((Dynarr_length (cache) - pos - 1) < min_past
|
|
6417 && line_start_cache_end (w) < BUF_ZV (b))
|
|
6418 {
|
|
6419 Bufpos from = line_start_cache_end (w);
|
|
6420 Bufpos to = find_next_newline_no_quit (b, from,
|
|
6421 (min_past
|
|
6422 ? min_past
|
|
6423 : 1));
|
|
6424
|
|
6425 update_line_start_cache (w, from, to, point, 0);
|
|
6426 goto find_point_loop;
|
|
6427 }
|
|
6428 else
|
|
6429 {
|
|
6430 w->line_cache_validation_override--;
|
|
6431 return pos;
|
|
6432 }
|
|
6433 }
|
|
6434 else if (point > end)
|
|
6435 bottom = pos + 1;
|
|
6436 else if (point < start)
|
|
6437 top = pos - 1;
|
|
6438 else
|
|
6439 abort ();
|
|
6440
|
|
6441 new_pos = (bottom + top + 1) >> 1;
|
|
6442 if (pos == new_pos)
|
|
6443 {
|
|
6444 w->line_cache_validation_override--;
|
|
6445 return -1;
|
|
6446 }
|
|
6447 }
|
|
6448 }
|
|
6449
|
|
6450 /* Return a boolean indicating if POINT would be visible in window W
|
|
6451 if display of the window was to begin at STARTP. */
|
|
6452
|
|
6453 int
|
|
6454 point_would_be_visible (struct window *w, Bufpos startp, Bufpos point)
|
|
6455 {
|
|
6456 struct buffer *b = XBUFFER (w->buffer);
|
|
6457 int pixpos = 0;
|
|
6458 int bottom = WINDOW_TEXT_HEIGHT (w);
|
|
6459 int start_elt;
|
|
6460
|
|
6461 /* If point is before the intended start it obviously can't be visible. */
|
|
6462 if (point < startp)
|
|
6463 return 0;
|
|
6464
|
|
6465 /* If point or start are not in the accessible buffer range, then
|
|
6466 fail. */
|
|
6467 if (startp < BUF_BEGV (b) || startp > BUF_ZV (b)
|
|
6468 || point < BUF_BEGV (b) || point > BUF_ZV (b))
|
|
6469 {
|
|
6470 w->line_cache_validation_override--;
|
|
6471 return 0;
|
|
6472 }
|
|
6473
|
|
6474 validate_line_start_cache (w);
|
|
6475 w->line_cache_validation_override++;
|
|
6476
|
|
6477 start_elt = point_in_line_start_cache (w, startp, 0);
|
|
6478 if (start_elt == -1)
|
|
6479 {
|
|
6480 w->line_cache_validation_override--;
|
|
6481 return 0;
|
|
6482 }
|
|
6483
|
|
6484 assert (line_start_cache_start (w) <= startp
|
|
6485 && line_start_cache_end (w) >= startp);
|
|
6486
|
|
6487 while (1)
|
|
6488 {
|
|
6489 int height;
|
|
6490
|
|
6491 /* Expand the cache if necessary. */
|
|
6492 if (start_elt == Dynarr_length (w->line_start_cache))
|
|
6493 {
|
|
6494 Bufpos old_startp =
|
|
6495 Dynarr_atp (w->line_start_cache, start_elt - 1)->start;
|
|
6496
|
|
6497 start_elt = point_in_line_start_cache (w, old_startp,
|
|
6498 window_char_height (w, 0));
|
|
6499
|
|
6500 /* We've already actually processed old_startp, so increment
|
|
6501 immediately. */
|
|
6502 start_elt++;
|
|
6503
|
|
6504 /* If this happens we didn't add any extra elements. Bummer. */
|
|
6505 if (start_elt == Dynarr_length (w->line_start_cache))
|
|
6506 {
|
|
6507 w->line_cache_validation_override--;
|
|
6508 return 0;
|
|
6509 }
|
|
6510 }
|
|
6511
|
|
6512 height = Dynarr_atp (w->line_start_cache, start_elt)->height;
|
|
6513
|
|
6514 if (pixpos + height > bottom)
|
|
6515 {
|
|
6516 if (bottom - pixpos < VERTICAL_CLIP (w, 0))
|
|
6517 {
|
|
6518 w->line_cache_validation_override--;
|
|
6519 return 0;
|
|
6520 }
|
|
6521 }
|
|
6522
|
|
6523 pixpos += height;
|
|
6524 if (point <= Dynarr_atp (w->line_start_cache, start_elt)->end)
|
|
6525 {
|
|
6526 w->line_cache_validation_override--;
|
|
6527 return 1;
|
|
6528 }
|
|
6529
|
|
6530 start_elt++;
|
|
6531 }
|
|
6532 }
|
|
6533
|
|
6534 /* For the given window W, if display starts at STARTP, what will be
|
|
6535 the buffer position at the beginning or end of the last line
|
|
6536 displayed. The end of the last line is also know as the window end
|
|
6537 position.
|
|
6538
|
|
6539 #### With a little work this could probably be reworked as just a
|
|
6540 call to start_with_line_at_pixpos. */
|
|
6541
|
|
6542 static Bufpos
|
|
6543 start_end_of_last_line (struct window *w, Bufpos startp, int end)
|
|
6544 {
|
|
6545 struct buffer *b = XBUFFER (w->buffer);
|
|
6546 line_start_cache_dynarr *cache = w->line_start_cache;
|
|
6547 int pixpos = 0;
|
|
6548 int bottom = WINDOW_TEXT_HEIGHT (w);
|
|
6549 Bufpos cur_start;
|
|
6550 int start_elt;
|
|
6551
|
|
6552 validate_line_start_cache (w);
|
|
6553 w->line_cache_validation_override++;
|
|
6554
|
|
6555 if (startp < BUF_BEGV (b))
|
|
6556 startp = BUF_BEGV (b);
|
|
6557 else if (startp > BUF_ZV (b))
|
|
6558 startp = BUF_ZV (b);
|
|
6559 cur_start = startp;
|
|
6560
|
|
6561 start_elt = point_in_line_start_cache (w, cur_start, 0);
|
|
6562 if (start_elt == -1)
|
|
6563 abort (); /* this had better never happen */
|
|
6564
|
|
6565 while (1)
|
|
6566 {
|
|
6567 int height = Dynarr_atp (cache, start_elt)->height;
|
|
6568
|
|
6569 cur_start = Dynarr_atp (cache, start_elt)->start;
|
|
6570
|
|
6571 if (pixpos + height > bottom)
|
|
6572 {
|
|
6573 /* Adjust for any possible clip. */
|
|
6574 if (bottom - pixpos < VERTICAL_CLIP (w, 0))
|
|
6575 start_elt--;
|
|
6576
|
|
6577 if (start_elt < 0)
|
|
6578 {
|
|
6579 w->line_cache_validation_override--;
|
|
6580 if (end)
|
|
6581 return (BUF_ZV (b));
|
|
6582 else
|
|
6583 return (BUF_BEGV (b));
|
|
6584 }
|
|
6585 else
|
|
6586 {
|
|
6587 w->line_cache_validation_override--;
|
|
6588 if (end)
|
|
6589 return Dynarr_atp (cache, start_elt)->end;
|
|
6590 else
|
|
6591 return Dynarr_atp (cache, start_elt)->start;
|
|
6592 }
|
|
6593 }
|
|
6594
|
|
6595 pixpos += height;
|
|
6596 start_elt++;
|
|
6597 if (start_elt == Dynarr_length (cache))
|
|
6598 {
|
|
6599 Bufpos from = line_start_cache_end (w);
|
|
6600 int win_char_height = window_char_height (w, 0);
|
|
6601 Bufpos to = find_next_newline_no_quit (b, from,
|
|
6602 (win_char_height
|
|
6603 ? win_char_height
|
|
6604 : 1));
|
|
6605
|
|
6606 /* We've hit the end of the bottom so that's what it is. */
|
|
6607 if (from >= BUF_ZV (b))
|
|
6608 {
|
|
6609 w->line_cache_validation_override--;
|
|
6610 return (BUF_ZV (b));
|
|
6611 }
|
|
6612
|
|
6613 update_line_start_cache (w, from, to, BUF_PT (b), 0);
|
|
6614
|
|
6615 /* Updating the cache invalidates any current indexes. */
|
|
6616 start_elt = point_in_line_start_cache (w, cur_start, -1) + 1;
|
|
6617 }
|
|
6618 }
|
|
6619 }
|
|
6620
|
|
6621 /* For the given window W, if display starts at STARTP, what will be
|
|
6622 the buffer position at the beginning of the last line displayed. */
|
|
6623
|
|
6624 Bufpos
|
|
6625 start_of_last_line (struct window *w, Bufpos startp)
|
|
6626 {
|
|
6627 return start_end_of_last_line (w, startp, 0);
|
|
6628 }
|
|
6629
|
|
6630 /* For the given window W, if display starts at STARTP, what will be
|
|
6631 the buffer position at the end of the last line displayed. This is
|
|
6632 also know as the window end position. */
|
|
6633
|
|
6634 Bufpos
|
|
6635 end_of_last_line (struct window *w, Bufpos startp)
|
|
6636 {
|
|
6637 return start_end_of_last_line (w, startp, 1);
|
|
6638 }
|
|
6639
|
|
6640 /* For window W, what does the starting position have to be so that
|
|
6641 the line containing POINT will cover pixel position PIXPOS. */
|
|
6642
|
|
6643 Bufpos
|
|
6644 start_with_line_at_pixpos (struct window *w, Bufpos point, int pixpos)
|
|
6645 {
|
|
6646 struct buffer *b = XBUFFER (w->buffer);
|
|
6647 int cur_elt;
|
70
|
6648 Bufpos cur_pos;
|
0
|
6649 int pixheight = pixpos - WINDOW_TEXT_TOP (w);
|
|
6650
|
|
6651 validate_line_start_cache (w);
|
|
6652 w->line_cache_validation_override++;
|
|
6653
|
|
6654 cur_elt = point_in_line_start_cache (w, point, 0);
|
|
6655 /* #### See comment in update_line_start_cache about big minibuffers. */
|
|
6656 if (cur_elt < 0)
|
|
6657 return point;
|
|
6658 while (1)
|
|
6659 {
|
|
6660 cur_pos = Dynarr_atp (w->line_start_cache, cur_elt)->start;
|
|
6661
|
|
6662 pixheight -= Dynarr_atp (w->line_start_cache, cur_elt)->height;
|
|
6663
|
|
6664 /* Do not take into account the value of vertical_clip here.
|
|
6665 That is the responsibility of the calling functions. */
|
|
6666 if (pixheight < 0)
|
|
6667 {
|
|
6668 w->line_cache_validation_override--;
|
70
|
6669 return cur_pos;
|
0
|
6670 }
|
|
6671
|
|
6672 cur_elt--;
|
|
6673 if (cur_elt < 0)
|
|
6674 {
|
|
6675 Bufpos from, to;
|
|
6676 int win_char_height;
|
|
6677
|
|
6678 if (cur_pos <= BUF_BEGV (b))
|
|
6679 {
|
|
6680 w->line_cache_validation_override--;
|
|
6681 return (BUF_BEGV (b));
|
|
6682 }
|
|
6683
|
|
6684 win_char_height = window_char_height (w, 0);
|
|
6685 if (!win_char_height)
|
|
6686 win_char_height = 1;
|
|
6687
|
|
6688 from = find_next_newline_no_quit (b, cur_pos, -win_char_height);
|
|
6689 to = line_start_cache_end (w);
|
|
6690 update_line_start_cache (w, from, to, point, 0);
|
|
6691
|
|
6692 cur_elt = point_in_line_start_cache (w, cur_pos, 2) - 1;
|
|
6693 assert (cur_elt >= 0);
|
|
6694 }
|
|
6695 }
|
|
6696 }
|
|
6697
|
|
6698 /* For window W, what does the starting position have to be so that
|
|
6699 the line containing point is on display line LINE. If LINE is
|
|
6700 positive it is considered to be the number of lines from the top of
|
|
6701 the window (0 is the top line). If it is negative the number is
|
|
6702 considered to be the number of lines from the bottom (-1 is the
|
|
6703 bottom line). */
|
|
6704
|
|
6705 Bufpos
|
|
6706 start_with_point_on_display_line (struct window *w, Bufpos point, int line)
|
|
6707 {
|
|
6708 validate_line_start_cache (w);
|
|
6709 w->line_cache_validation_override++;
|
|
6710
|
|
6711 if (line >= 0)
|
|
6712 {
|
|
6713 int cur_elt = point_in_line_start_cache (w, point, line);
|
|
6714
|
|
6715 if (cur_elt - line < 0)
|
|
6716 cur_elt = 0; /* Hit the top */
|
|
6717 else
|
|
6718 cur_elt -= line;
|
|
6719
|
|
6720 w->line_cache_validation_override--;
|
|
6721 return (Dynarr_atp (w->line_start_cache, cur_elt)->start);
|
|
6722 }
|
|
6723 else
|
|
6724 {
|
|
6725 /* The calculated value of pixpos is correct for the bottom line
|
|
6726 or what we want when line is -1. Therefore we subtract one
|
|
6727 because we have already handled one line. */
|
|
6728 int new_line = -line - 1;
|
|
6729 int cur_elt = point_in_line_start_cache (w, point, new_line);
|
|
6730 int pixpos = WINDOW_TEXT_BOTTOM (w);
|
|
6731 Bufpos retval, search_point;
|
|
6732
|
|
6733 /* If scroll_on_clipped_lines is false, the last "visible" line of
|
|
6734 the window covers the pixel at WINDOW_TEXT_BOTTOM (w) - 1.
|
|
6735 If s_o_c_l is true, then we don't want to count a clipped
|
|
6736 line, so back up from the bottom by the height of the line
|
|
6737 containing point. */
|
|
6738 if (scroll_on_clipped_lines)
|
|
6739 pixpos -= Dynarr_atp (w->line_start_cache, cur_elt)->height;
|
|
6740 else
|
|
6741 pixpos -= 1;
|
|
6742
|
|
6743 if (cur_elt + new_line >= Dynarr_length (w->line_start_cache))
|
|
6744 {
|
|
6745 /* Hit the bottom of the buffer. */
|
|
6746 int adjustment =
|
|
6747 (cur_elt + new_line) - Dynarr_length (w->line_start_cache) + 1;
|
|
6748 Lisp_Object window = Qnil;
|
|
6749 int defheight;
|
|
6750
|
|
6751 XSETWINDOW (window, w);
|
|
6752 default_face_height_and_width (window, &defheight, 0);
|
|
6753
|
|
6754 cur_elt = Dynarr_length (w->line_start_cache) - 1;
|
|
6755
|
|
6756 pixpos -= (adjustment * defheight);
|
|
6757 if (pixpos < WINDOW_TEXT_TOP (w))
|
|
6758 pixpos = WINDOW_TEXT_TOP (w);
|
|
6759 }
|
|
6760 else
|
|
6761 cur_elt = cur_elt + new_line;
|
|
6762
|
|
6763 search_point = Dynarr_atp (w->line_start_cache, cur_elt)->start;
|
|
6764
|
|
6765 retval = start_with_line_at_pixpos (w, search_point, pixpos);
|
|
6766 w->line_cache_validation_override--;
|
|
6767 return retval;
|
|
6768 }
|
|
6769 }
|
|
6770
|
|
6771 /* This is used to speed up vertical scrolling by caching the known
|
|
6772 buffer starting positions for display lines. This allows the
|
|
6773 scrolling routines to avoid costly calls to regenerate_window. If
|
|
6774 NO_REGEN is true then it will only add the values in the DESIRED
|
|
6775 display structs which are in the given range.
|
|
6776
|
|
6777 Note also that the FROM/TO values are minimums. It is possible
|
|
6778 that this function will actually add information outside of the
|
|
6779 lines containing those positions. This can't hurt but it could
|
|
6780 possibly help.
|
|
6781
|
|
6782 #### We currently force the cache to have only 1 contiguous region.
|
|
6783 It might help to make the cache a dynarr of caches so that we can
|
|
6784 cover more areas. This might, however, turn out to be a lot of
|
|
6785 overhead for too little gain. */
|
|
6786
|
|
6787 static void
|
|
6788 update_line_start_cache (struct window *w, Bufpos from, Bufpos to,
|
|
6789 Bufpos point, int no_regen)
|
|
6790 {
|
|
6791 struct buffer *b = XBUFFER (w->buffer);
|
|
6792 line_start_cache_dynarr *cache = w->line_start_cache;
|
|
6793 Bufpos low_bound, high_bound;
|
|
6794
|
|
6795 validate_line_start_cache (w);
|
|
6796 w->line_cache_validation_override++;
|
|
6797 updating_line_start_cache = 1;
|
|
6798
|
|
6799 if (from < BUF_BEGV (b))
|
|
6800 from = BUF_BEGV (b);
|
|
6801 if (to > BUF_ZV (b))
|
|
6802 to = BUF_ZV (b);
|
|
6803
|
|
6804 if (from > to)
|
|
6805 {
|
|
6806 updating_line_start_cache = 0;
|
|
6807 w->line_cache_validation_override--;
|
|
6808 return;
|
|
6809 }
|
|
6810
|
|
6811 if (Dynarr_length (cache))
|
|
6812 {
|
|
6813 low_bound = line_start_cache_start (w);
|
|
6814 high_bound = line_start_cache_end (w);
|
|
6815
|
|
6816 /* Check to see if the desired range is already in the cache. */
|
|
6817 if (from >= low_bound && to <= high_bound)
|
|
6818 {
|
|
6819 updating_line_start_cache = 0;
|
|
6820 w->line_cache_validation_override--;
|
|
6821 return;
|
|
6822 }
|
|
6823
|
|
6824 /* Check to make sure that the desired range is adjacent to the
|
|
6825 current cache. If not, invalidate the cache. */
|
|
6826 if (to < low_bound || from > high_bound)
|
|
6827 {
|
|
6828 Dynarr_reset (cache);
|
|
6829 low_bound = high_bound = -1;
|
|
6830 }
|
|
6831 }
|
|
6832 else
|
|
6833 {
|
|
6834 low_bound = high_bound = -1;
|
|
6835 }
|
|
6836
|
|
6837 w->line_cache_last_updated = make_int (BUF_MODIFF (b));
|
|
6838
|
|
6839 /* This could be integrated into the next two sections, but it is easier
|
|
6840 to follow what's going on by having it separate. */
|
|
6841 if (no_regen)
|
|
6842 {
|
|
6843 Bufpos start, end;
|
|
6844
|
|
6845 update_internal_cache_list (w, DESIRED_DISP);
|
|
6846 if (!Dynarr_length (internal_cache))
|
|
6847 {
|
|
6848 updating_line_start_cache = 0;
|
|
6849 w->line_cache_validation_override--;
|
|
6850 return;
|
|
6851 }
|
|
6852
|
|
6853 start = Dynarr_atp (internal_cache, 0)->start;
|
|
6854 end =
|
|
6855 Dynarr_atp (internal_cache, Dynarr_length (internal_cache) - 1)->end;
|
|
6856
|
|
6857 /* We aren't allowed to generate additional information to fill in
|
|
6858 gaps, so if the DESIRED structs don't overlap the cache, reset the
|
|
6859 cache. */
|
|
6860 if (Dynarr_length (cache))
|
|
6861 {
|
|
6862 if (end < low_bound || start > high_bound)
|
|
6863 Dynarr_reset (cache);
|
|
6864
|
|
6865 /* #### What should really happen if what we are doing is
|
|
6866 extending a line (the last line)? */
|
|
6867 if (Dynarr_length (cache) == 1
|
|
6868 && Dynarr_length (internal_cache) == 1)
|
|
6869 Dynarr_reset (cache);
|
|
6870 }
|
|
6871
|
|
6872 if (!Dynarr_length (cache))
|
|
6873 {
|
|
6874 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
|
|
6875 Dynarr_length (internal_cache));
|
|
6876 updating_line_start_cache = 0;
|
|
6877 w->line_cache_validation_override--;
|
|
6878 return;
|
|
6879 }
|
|
6880
|
|
6881 /* An extra check just in case the calling function didn't pass in
|
|
6882 the bounds of the DESIRED structs in the first place. */
|
|
6883 if (start >= low_bound && end <= high_bound)
|
|
6884 {
|
|
6885 updating_line_start_cache = 0;
|
|
6886 w->line_cache_validation_override--;
|
|
6887 return;
|
|
6888 }
|
|
6889
|
|
6890 /* At this point we know that the internal cache partially overlaps
|
|
6891 the main cache. */
|
|
6892 if (start < low_bound)
|
|
6893 {
|
|
6894 int ic_elt = Dynarr_length (internal_cache) - 1;
|
|
6895 while (ic_elt >= 0)
|
|
6896 {
|
|
6897 if (Dynarr_atp (internal_cache, ic_elt)->start < low_bound)
|
|
6898 break;
|
|
6899 else
|
|
6900 ic_elt--;
|
|
6901 }
|
|
6902
|
|
6903 if (!(ic_elt >= 0))
|
|
6904 {
|
|
6905 Dynarr_reset (cache);
|
|
6906 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
|
|
6907 Dynarr_length (internal_cache));
|
|
6908 updating_line_start_cache = 0;
|
|
6909 w->line_cache_validation_override--;
|
|
6910 return;
|
|
6911 }
|
|
6912
|
|
6913 Dynarr_insert_many_at_start (cache, Dynarr_atp (internal_cache, 0),
|
|
6914 ic_elt + 1);
|
|
6915 }
|
|
6916
|
|
6917 if (end > high_bound)
|
|
6918 {
|
|
6919 int ic_elt = 0;
|
|
6920
|
|
6921 while (ic_elt < Dynarr_length (internal_cache))
|
|
6922 {
|
|
6923 if (Dynarr_atp (internal_cache, ic_elt)->start > high_bound)
|
|
6924 break;
|
|
6925 else
|
|
6926 ic_elt++;
|
|
6927 }
|
|
6928
|
|
6929 if (!(ic_elt < Dynarr_length (internal_cache)))
|
|
6930 {
|
|
6931 Dynarr_reset (cache);
|
|
6932 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
|
|
6933 Dynarr_length (internal_cache));
|
|
6934 updating_line_start_cache = 0;
|
|
6935 w->line_cache_validation_override--;
|
|
6936 return;
|
|
6937 }
|
|
6938
|
|
6939 Dynarr_add_many (cache, Dynarr_atp (internal_cache, ic_elt),
|
|
6940 Dynarr_length (internal_cache) - ic_elt);
|
|
6941 }
|
|
6942
|
|
6943 updating_line_start_cache = 0;
|
|
6944 w->line_cache_validation_override--;
|
|
6945 return;
|
|
6946 }
|
|
6947
|
|
6948 if (!Dynarr_length (cache) || from < low_bound)
|
|
6949 {
|
|
6950 Bufpos startp = find_next_newline_no_quit (b, from, -1);
|
|
6951 int marker = 0;
|
|
6952 int old_lb = low_bound;
|
|
6953
|
|
6954 while (startp < old_lb || low_bound == -1)
|
|
6955 {
|
|
6956 int ic_elt;
|
|
6957
|
|
6958 regenerate_window (w, startp, point, CMOTION_DISP);
|
|
6959 update_internal_cache_list (w, CMOTION_DISP);
|
|
6960
|
|
6961 /* If this assert is triggered then regenerate_window failed
|
|
6962 to layout a single line. That is not supposed to be
|
|
6963 possible because we impose a minimum height on the buffer
|
|
6964 and override vertical clip when we are in here. */
|
|
6965 /* #### Ah, but it is because the window may temporarily
|
|
6966 exist but not have any lines at all if the minibuffer is
|
|
6967 real big. Look into that situation better. */
|
|
6968 if (!Dynarr_length (internal_cache))
|
|
6969 {
|
|
6970 if (old_lb == -1 && low_bound == -1)
|
|
6971 {
|
|
6972 updating_line_start_cache = 0;
|
|
6973 w->line_cache_validation_override--;
|
|
6974 return;
|
|
6975 }
|
|
6976
|
|
6977 assert (Dynarr_length (internal_cache));
|
|
6978 }
|
|
6979 assert (startp == Dynarr_atp (internal_cache, 0)->start);
|
|
6980
|
|
6981 ic_elt = Dynarr_length (internal_cache) - 1;
|
|
6982 if (low_bound != -1)
|
|
6983 {
|
|
6984 while (ic_elt >= 0)
|
|
6985 {
|
|
6986 if (Dynarr_atp (internal_cache, ic_elt)->start < old_lb)
|
|
6987 break;
|
|
6988 else
|
|
6989 ic_elt--;
|
|
6990 }
|
|
6991 }
|
|
6992 assert (ic_elt >= 0);
|
|
6993
|
|
6994 Dynarr_insert_many (cache, Dynarr_atp (internal_cache, 0),
|
|
6995 ic_elt + 1, marker);
|
|
6996 marker += (ic_elt + 1);
|
|
6997
|
|
6998 if (startp < low_bound || low_bound == -1)
|
|
6999 low_bound = startp;
|
|
7000 startp = Dynarr_atp (internal_cache, ic_elt)->end + 1;
|
|
7001 if (startp > BUF_ZV (b))
|
|
7002 {
|
|
7003 updating_line_start_cache = 0;
|
|
7004 w->line_cache_validation_override--;
|
|
7005 return;
|
|
7006 }
|
|
7007 }
|
|
7008 }
|
|
7009
|
|
7010 assert (Dynarr_length (cache));
|
|
7011 assert (from >= low_bound);
|
|
7012
|
|
7013 /* Readjust the high_bound to account for any changes made while
|
|
7014 correcting the low_bound. */
|
|
7015 high_bound = Dynarr_atp (cache, Dynarr_length (cache) - 1)->end;
|
|
7016
|
|
7017 if (to > high_bound)
|
|
7018 {
|
|
7019 Bufpos startp = Dynarr_atp (cache, Dynarr_length (cache) - 1)->end + 1;
|
|
7020
|
|
7021 do
|
|
7022 {
|
|
7023 regenerate_window (w, startp, point, CMOTION_DISP);
|
|
7024 update_internal_cache_list (w, CMOTION_DISP);
|
|
7025
|
|
7026 /* See comment above about regenerate_window failing. */
|
|
7027 assert (Dynarr_length (internal_cache));
|
|
7028
|
|
7029 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
|
|
7030 Dynarr_length (internal_cache));
|
|
7031 high_bound = Dynarr_atp (cache, Dynarr_length (cache) - 1)->end;
|
|
7032 startp = high_bound + 1;
|
|
7033 }
|
|
7034 while (to > high_bound);
|
|
7035 }
|
|
7036
|
|
7037 updating_line_start_cache = 0;
|
|
7038 w->line_cache_validation_override--;
|
|
7039 assert (to <= high_bound);
|
|
7040 }
|
|
7041
|
|
7042
|
|
7043 /* Given x and y coordinates in characters, relative to a window,
|
|
7044 return the pixel location corresponding to those coordinates. The
|
|
7045 pixel location returned is the center of the given character
|
|
7046 position. The pixel values are generated relative to the window,
|
|
7047 not the frame.
|
|
7048
|
|
7049 The modeline is considered to be part of the window. */
|
|
7050
|
|
7051 void
|
|
7052 glyph_to_pixel_translation (struct window *w, int char_x, int char_y,
|
|
7053 int *pix_x, int *pix_y)
|
|
7054 {
|
|
7055 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
7056 int num_disp_lines, modeline;
|
|
7057 Lisp_Object window = Qnil;
|
|
7058 int defheight, defwidth;
|
|
7059
|
|
7060 XSETWINDOW (window, w);
|
|
7061 default_face_height_and_width (window, &defheight, &defwidth);
|
|
7062
|
|
7063 /* If we get a bogus value indicating somewhere above or to the left of
|
|
7064 the window, use the first window line or character position
|
|
7065 instead. */
|
|
7066 if (char_y < 0)
|
|
7067 char_y = 0;
|
|
7068 if (char_x < 0)
|
|
7069 char_x = 0;
|
|
7070
|
|
7071 num_disp_lines = Dynarr_length (dla);
|
|
7072 modeline = 0;
|
|
7073 if (num_disp_lines)
|
|
7074 {
|
|
7075 if (Dynarr_atp (dla, 0)->modeline)
|
|
7076 {
|
|
7077 num_disp_lines--;
|
|
7078 modeline = 1;
|
|
7079 }
|
|
7080 }
|
|
7081
|
|
7082 /* First check if the y position intersects the display lines. */
|
|
7083 if (char_y < num_disp_lines)
|
|
7084 {
|
|
7085 struct display_line *dl = Dynarr_atp (dla, char_y + modeline);
|
|
7086 struct display_block *db = get_display_block_from_line (dl, TEXT);
|
|
7087
|
|
7088 *pix_y = (dl->ypos - dl->ascent +
|
|
7089 ((unsigned int) (dl->ascent + dl->descent - dl->clip) >> 1));
|
|
7090
|
|
7091 if (char_x < Dynarr_length (db->runes))
|
|
7092 {
|
|
7093 struct rune *rb = Dynarr_atp (db->runes, char_x);
|
|
7094
|
|
7095 *pix_x = rb->xpos + (rb->width >> 1);
|
|
7096 }
|
|
7097 else
|
|
7098 {
|
|
7099 int last_rune = Dynarr_length (db->runes) - 1;
|
|
7100 struct rune *rb = Dynarr_atp (db->runes, last_rune);
|
|
7101
|
|
7102 char_x -= last_rune;
|
|
7103
|
|
7104 *pix_x = rb->xpos + rb->width;
|
|
7105 *pix_x += ((char_x - 1) * defwidth);
|
|
7106 *pix_x += (defwidth >> 1);
|
|
7107 }
|
|
7108 }
|
|
7109 else
|
|
7110 {
|
|
7111 /* It didn't intersect, so extrapolate. #### For now, we include the
|
|
7112 modeline in this since we don't have true character positions in
|
|
7113 it. */
|
|
7114
|
|
7115 if (!Dynarr_length (w->face_cachels))
|
|
7116 reset_face_cachels (w);
|
|
7117
|
|
7118 char_y -= num_disp_lines;
|
|
7119
|
|
7120 if (Dynarr_length (dla))
|
|
7121 {
|
|
7122 struct display_line *dl = Dynarr_atp (dla, Dynarr_length (dla) - 1);
|
|
7123 *pix_y = dl->ypos + dl->descent - dl->clip;
|
|
7124 }
|
|
7125 else
|
|
7126 *pix_y = WINDOW_TEXT_TOP (w);
|
|
7127
|
|
7128 *pix_y += (char_y * defheight);
|
|
7129 *pix_y += (defheight >> 1);
|
|
7130
|
|
7131 *pix_x = WINDOW_TEXT_LEFT (w);
|
|
7132 /* Don't adjust by one because this is still the unadjusted value. */
|
|
7133 *pix_x += (char_x * defwidth);
|
|
7134 *pix_x += (defwidth >> 1);
|
|
7135 }
|
|
7136
|
|
7137 if (*pix_x > w->pixel_left + w->pixel_width)
|
|
7138 *pix_x = w->pixel_left + w->pixel_width;
|
|
7139 if (*pix_y > w->pixel_top + w->pixel_height)
|
|
7140 *pix_y = w->pixel_top + w->pixel_height;
|
|
7141
|
|
7142 *pix_x -= w->pixel_left;
|
|
7143 *pix_y -= w->pixel_top;
|
|
7144 }
|
|
7145
|
|
7146 /* Given a display line and a position, determine if there is a glyph
|
|
7147 there and return information about it if there is. */
|
|
7148
|
|
7149 static void
|
|
7150 get_position_object (struct display_line *dl, Lisp_Object *obj1,
|
|
7151 Lisp_Object *obj2, int x_coord, int *low_x_coord,
|
|
7152 int *high_x_coord)
|
|
7153 {
|
|
7154 struct display_block *db;
|
|
7155 int elt;
|
|
7156 int block =
|
|
7157 get_next_display_block (dl->bounds, dl->display_blocks, x_coord, 0);
|
|
7158
|
|
7159 /* We use get_next_display_block to get the actual display block
|
|
7160 that would be displayed at x_coord. */
|
|
7161
|
|
7162 if (block == NO_BLOCK)
|
|
7163 return;
|
|
7164 else
|
|
7165 db = Dynarr_atp (dl->display_blocks, block);
|
|
7166
|
|
7167 for (elt = 0; elt < Dynarr_length (db->runes); elt++)
|
|
7168 {
|
|
7169 struct rune *rb = Dynarr_atp (db->runes, elt);
|
|
7170
|
|
7171 if (rb->xpos <= x_coord && x_coord < (rb->xpos + rb->width))
|
|
7172 {
|
|
7173 if (rb->type == RUNE_DGLYPH)
|
|
7174 {
|
|
7175 *obj1 = rb->object.dglyph.glyph;
|
|
7176 *obj2 = rb->object.dglyph.extent;
|
|
7177 }
|
|
7178 else
|
|
7179 {
|
|
7180 *obj1 = Qnil;
|
|
7181 *obj2 = Qnil;
|
|
7182 }
|
|
7183
|
|
7184 if (low_x_coord)
|
|
7185 *low_x_coord = rb->xpos;
|
|
7186 if (high_x_coord)
|
|
7187 *high_x_coord = rb->xpos + rb->width;
|
|
7188
|
|
7189 return;
|
|
7190 }
|
|
7191 }
|
|
7192 }
|
|
7193
|
|
7194 #define UPDATE_CACHE_RETURN \
|
|
7195 do { \
|
|
7196 d->pixel_to_glyph_cache.valid = 1; \
|
|
7197 d->pixel_to_glyph_cache.low_x_coord = low_x_coord; \
|
|
7198 d->pixel_to_glyph_cache.high_x_coord = high_x_coord; \
|
|
7199 d->pixel_to_glyph_cache.low_y_coord = low_y_coord; \
|
|
7200 d->pixel_to_glyph_cache.high_y_coord = high_y_coord; \
|
|
7201 d->pixel_to_glyph_cache.frame = f; \
|
|
7202 d->pixel_to_glyph_cache.col = *col; \
|
|
7203 d->pixel_to_glyph_cache.row = *row; \
|
|
7204 d->pixel_to_glyph_cache.obj_x = *obj_x; \
|
|
7205 d->pixel_to_glyph_cache.obj_y = *obj_y; \
|
|
7206 d->pixel_to_glyph_cache.w = *w; \
|
|
7207 d->pixel_to_glyph_cache.bufpos = *bufpos; \
|
|
7208 d->pixel_to_glyph_cache.closest = *closest; \
|
|
7209 d->pixel_to_glyph_cache.modeline_closest = *modeline_closest; \
|
|
7210 d->pixel_to_glyph_cache.obj1 = *obj1; \
|
|
7211 d->pixel_to_glyph_cache.obj2 = *obj2; \
|
|
7212 d->pixel_to_glyph_cache.retval = position; \
|
|
7213 RETURN__ position; \
|
|
7214 } while (0)
|
|
7215
|
|
7216 /* Given x and y coordinates in pixels relative to a frame, return
|
|
7217 information about what is located under those coordinates.
|
|
7218
|
|
7219 The return value will be one of:
|
|
7220
|
|
7221 OVER_TOOLBAR: over one of the 4 frame toolbars
|
|
7222 OVER_MODELINE: over a modeline
|
|
7223 OVER_BORDER: over an internal border
|
|
7224 OVER_NOTHING: over the text area, but not over text
|
|
7225 OVER_OUTSIDE: outside of the frame border
|
|
7226 OVER_TEXT: over text in the text area
|
|
7227
|
|
7228 OBJ1 is one of
|
|
7229
|
|
7230 -- a toolbar button
|
|
7231 -- a glyph
|
|
7232 -- nil if the coordinates are not over a glyph or a toolbar button.
|
|
7233
|
|
7234 OBJ2 is one of
|
|
7235
|
|
7236 -- an extent, if the coordinates are over a glyph in the text area
|
|
7237 -- nil otherwise.
|
|
7238
|
|
7239 If the coordinates are over a glyph, OBJ_X and OBJ_Y give the
|
|
7240 equivalent coordinates relative to the upper-left corner of the glyph.
|
|
7241
|
|
7242 If the coordinates are over a character, OBJ_X and OBJ_Y give the
|
|
7243 equivalent coordinates relative to the upper-left corner of the character.
|
|
7244
|
|
7245 Otherwise, OBJ_X and OBJ_Y are undefined.
|
|
7246 */
|
|
7247
|
|
7248 int
|
|
7249 pixel_to_glyph_translation (struct frame *f, int x_coord, int y_coord,
|
|
7250 int *col, int *row, int *obj_x, int *obj_y,
|
|
7251 struct window **w, Bufpos *bufpos,
|
|
7252 Bufpos *closest, Charcount *modeline_closest,
|
|
7253 Lisp_Object *obj1, Lisp_Object *obj2)
|
|
7254 {
|
|
7255 struct device *d;
|
|
7256 struct pixel_to_glyph_translation_cache *cache;
|
|
7257 Lisp_Object window;
|
|
7258 int frm_left, frm_right, frm_top, frm_bottom;
|
|
7259 int low_x_coord, high_x_coord, low_y_coord, high_y_coord;
|
|
7260 int position = OVER_NOTHING;
|
|
7261 int device_check_failed = 0;
|
|
7262 display_line_dynarr *dla;
|
|
7263
|
|
7264 /* This is a safety valve in case this got called with a frame in
|
|
7265 the middle of being deleted. */
|
|
7266 if (!DEVICEP (f->device) || !DEVICE_LIVE_P (XDEVICE (f->device)))
|
|
7267 device_check_failed = 1;
|
|
7268 else
|
|
7269 {
|
|
7270 d = XDEVICE (f->device);
|
|
7271 cache = &d->pixel_to_glyph_cache;
|
|
7272 }
|
|
7273
|
|
7274 if (!device_check_failed
|
|
7275 && cache->valid
|
|
7276 && cache->frame == f
|
|
7277 && cache->low_x_coord <= x_coord
|
|
7278 && cache->high_x_coord > x_coord
|
|
7279 && cache->low_y_coord <= y_coord
|
|
7280 && cache->high_y_coord > y_coord)
|
|
7281 {
|
|
7282 *col = cache->col;
|
|
7283 *row = cache->row;
|
|
7284 *obj_x = cache->obj_x;
|
|
7285 *obj_y = cache->obj_y;
|
|
7286 *w = cache->w;
|
|
7287 *bufpos = cache->bufpos;
|
|
7288 *closest = cache->closest;
|
|
7289 *modeline_closest = cache->modeline_closest;
|
|
7290 *obj1 = cache->obj1;
|
|
7291 *obj2 = cache->obj2;
|
|
7292
|
|
7293 return cache->retval;
|
|
7294 }
|
|
7295 else
|
|
7296 {
|
|
7297 *col = 0;
|
|
7298 *row = 0;
|
|
7299 *obj_x = 0;
|
|
7300 *obj_y = 0;
|
|
7301 *w = 0;
|
|
7302 *bufpos = 0;
|
|
7303 *closest = 0;
|
|
7304 *modeline_closest = -1;
|
|
7305 *obj1 = Qnil;
|
|
7306 *obj2 = Qnil;
|
|
7307
|
|
7308 low_x_coord = x_coord;
|
|
7309 high_x_coord = x_coord + 1;
|
|
7310 low_y_coord = y_coord;
|
|
7311 high_y_coord = y_coord + 1;
|
|
7312 }
|
|
7313
|
|
7314 if (device_check_failed)
|
|
7315 return OVER_NOTHING;
|
|
7316
|
|
7317 frm_left = FRAME_LEFT_BORDER_END (f);
|
|
7318 frm_right = FRAME_RIGHT_BORDER_START (f);
|
|
7319 frm_top = FRAME_TOP_BORDER_END (f);
|
|
7320 frm_bottom = FRAME_BOTTOM_BORDER_START (f);
|
|
7321
|
|
7322 /* Check if the mouse is outside of the text area actually used by
|
|
7323 redisplay. */
|
|
7324 if (y_coord < frm_top)
|
|
7325 {
|
|
7326 if (y_coord >= FRAME_TOP_BORDER_START (f))
|
|
7327 {
|
|
7328 low_y_coord = FRAME_TOP_BORDER_START (f);
|
|
7329 high_y_coord = frm_top;
|
|
7330 position = OVER_BORDER;
|
|
7331 }
|
|
7332 else if (y_coord >= 0)
|
|
7333 {
|
|
7334 low_y_coord = 0;
|
|
7335 high_y_coord = FRAME_TOP_BORDER_START (f);
|
|
7336 position = OVER_TOOLBAR;
|
|
7337 }
|
|
7338 else
|
|
7339 {
|
|
7340 low_y_coord = y_coord;
|
|
7341 high_y_coord = 0;
|
|
7342 position = OVER_OUTSIDE;
|
|
7343 }
|
|
7344 }
|
|
7345 else if (y_coord >= frm_bottom)
|
|
7346 {
|
|
7347 if (y_coord < FRAME_BOTTOM_BORDER_END (f))
|
|
7348 {
|
|
7349 low_y_coord = frm_bottom;
|
|
7350 high_y_coord = FRAME_BOTTOM_BORDER_END (f);
|
|
7351 position = OVER_BORDER;
|
|
7352 }
|
|
7353 else if (y_coord < FRAME_PIXHEIGHT (f))
|
|
7354 {
|
|
7355 low_y_coord = FRAME_BOTTOM_BORDER_END (f);
|
|
7356 high_y_coord = FRAME_PIXHEIGHT (f);
|
|
7357 position = OVER_TOOLBAR;
|
|
7358 }
|
|
7359 else
|
|
7360 {
|
|
7361 low_y_coord = FRAME_PIXHEIGHT (f);
|
|
7362 high_y_coord = y_coord;
|
|
7363 position = OVER_OUTSIDE;
|
|
7364 }
|
|
7365 }
|
|
7366
|
|
7367 if (position != OVER_TOOLBAR && position != OVER_BORDER)
|
|
7368 {
|
|
7369 if (x_coord < frm_left)
|
|
7370 {
|
|
7371 if (x_coord >= FRAME_LEFT_BORDER_START (f))
|
|
7372 {
|
|
7373 low_x_coord = FRAME_LEFT_BORDER_START (f);
|
|
7374 high_x_coord = frm_left;
|
|
7375 position = OVER_BORDER;
|
|
7376 }
|
|
7377 else if (x_coord >= 0)
|
|
7378 {
|
|
7379 low_x_coord = 0;
|
|
7380 high_x_coord = FRAME_LEFT_BORDER_START (f);
|
|
7381 position = OVER_TOOLBAR;
|
|
7382 }
|
|
7383 else
|
|
7384 {
|
|
7385 low_x_coord = x_coord;
|
|
7386 high_x_coord = 0;
|
|
7387 position = OVER_OUTSIDE;
|
|
7388 }
|
|
7389 }
|
|
7390 else if (x_coord >= frm_right)
|
|
7391 {
|
|
7392 if (x_coord < FRAME_RIGHT_BORDER_END (f))
|
|
7393 {
|
|
7394 low_x_coord = frm_right;
|
|
7395 high_x_coord = FRAME_RIGHT_BORDER_END (f);
|
|
7396 position = OVER_BORDER;
|
|
7397 }
|
|
7398 else if (x_coord < FRAME_PIXWIDTH (f))
|
|
7399 {
|
|
7400 low_x_coord = FRAME_RIGHT_BORDER_END (f);
|
|
7401 high_x_coord = FRAME_PIXWIDTH (f);
|
|
7402 position = OVER_TOOLBAR;
|
|
7403 }
|
|
7404 else
|
|
7405 {
|
|
7406 low_x_coord = FRAME_PIXWIDTH (f);
|
|
7407 high_x_coord = x_coord;
|
|
7408 position = OVER_OUTSIDE;
|
|
7409 }
|
|
7410 }
|
|
7411 }
|
|
7412
|
|
7413 #ifdef HAVE_TOOLBARS
|
|
7414 if (position == OVER_TOOLBAR)
|
|
7415 {
|
|
7416 *obj1 = toolbar_button_at_pixpos (f, x_coord, y_coord);
|
|
7417 *obj2 = Qnil;
|
|
7418 *w = 0;
|
|
7419 UPDATE_CACHE_RETURN;
|
|
7420 }
|
|
7421 #endif
|
|
7422
|
|
7423 /* We still have to return the window the pointer is next to and its
|
|
7424 relative y position even if it is outside the x boundary. */
|
|
7425 if (x_coord < frm_left)
|
|
7426 x_coord = frm_left;
|
|
7427 else if (x_coord > frm_right)
|
|
7428 x_coord = frm_right;
|
|
7429
|
|
7430 /* Same in reverse. */
|
|
7431 if (y_coord < frm_top)
|
|
7432 y_coord = frm_top;
|
|
7433 else if (y_coord > frm_bottom)
|
|
7434 y_coord = frm_bottom;
|
|
7435
|
|
7436 /* Find what window the given coordinates are actually in. */
|
|
7437 window = f->root_window;
|
|
7438 *w = find_window_by_pixel_pos (x_coord, y_coord, window);
|
|
7439
|
|
7440 /* If we didn't find a window, we're done. */
|
|
7441 if (!*w)
|
|
7442 {
|
|
7443 UPDATE_CACHE_RETURN;
|
|
7444 }
|
|
7445 else if (position != OVER_NOTHING)
|
|
7446 {
|
|
7447 *closest = 0;
|
|
7448 *modeline_closest = -1;
|
|
7449
|
|
7450 if (high_y_coord <= frm_top || high_y_coord >= frm_bottom)
|
|
7451 {
|
|
7452 *w = 0;
|
|
7453 UPDATE_CACHE_RETURN;
|
|
7454 }
|
|
7455 }
|
|
7456
|
|
7457 /* Check if the window is a minibuffer but isn't active. */
|
|
7458 if (MINI_WINDOW_P (*w) && !minibuf_level)
|
|
7459 {
|
|
7460 /* Must reset the window value since some callers will ignore
|
|
7461 the return value if it is set. */
|
|
7462 *w = 0;
|
|
7463 UPDATE_CACHE_RETURN;
|
|
7464 }
|
|
7465
|
|
7466 dla = window_display_lines (*w, CURRENT_DISP);
|
|
7467
|
|
7468 for (*row = 0; *row < Dynarr_length (dla); (*row)++)
|
|
7469 {
|
|
7470 int really_over_nothing = 0;
|
|
7471 struct display_line *dl = Dynarr_atp (dla, *row);
|
|
7472
|
|
7473 if ((int) (dl->ypos - dl->ascent) <= y_coord
|
|
7474 && y_coord <= (int) (dl->ypos + dl->descent))
|
|
7475 {
|
|
7476 int check_margin_glyphs = 0;
|
|
7477 struct display_block *db = get_display_block_from_line (dl, TEXT);
|
|
7478 struct rune *rb = 0;
|
|
7479
|
|
7480 if (x_coord < dl->bounds.left_white
|
|
7481 || x_coord >= dl->bounds.right_white)
|
|
7482 check_margin_glyphs = 1;
|
|
7483
|
|
7484 low_y_coord = dl->ypos - dl->ascent;
|
|
7485 high_y_coord = dl->ypos + dl->descent + 1;
|
|
7486
|
|
7487 if (position == OVER_BORDER
|
|
7488 || position == OVER_OUTSIDE
|
|
7489 || check_margin_glyphs)
|
|
7490 {
|
|
7491 int x_check, left_bound;
|
|
7492
|
|
7493 if (check_margin_glyphs)
|
|
7494 {
|
|
7495 x_check = x_coord;
|
|
7496 left_bound = dl->bounds.left_white;
|
|
7497 }
|
|
7498 else
|
|
7499 {
|
|
7500 x_check = high_x_coord;
|
|
7501 left_bound = frm_left;
|
|
7502 }
|
|
7503
|
|
7504 if (Dynarr_length (db->runes))
|
|
7505 {
|
|
7506 if (x_check <= left_bound)
|
|
7507 {
|
|
7508 if (dl->modeline)
|
|
7509 *modeline_closest = Dynarr_atp (db->runes, 0)->bufpos;
|
|
7510 else
|
|
7511 *closest = Dynarr_atp (db->runes, 0)->bufpos;
|
|
7512 }
|
|
7513 else
|
|
7514 {
|
|
7515 if (dl->modeline)
|
|
7516 *modeline_closest =
|
|
7517 Dynarr_atp (db->runes,
|
|
7518 Dynarr_length (db->runes) - 1)->bufpos;
|
|
7519 else
|
|
7520 *closest =
|
|
7521 Dynarr_atp (db->runes,
|
70
|
7522 Dynarr_length (db->runes) - 1)->bufpos;
|
0
|
7523 }
|
|
7524
|
|
7525 if (dl->modeline)
|
|
7526 *modeline_closest += dl->offset;
|
|
7527 else
|
|
7528 *closest += dl->offset;
|
|
7529 }
|
|
7530 else
|
|
7531 {
|
|
7532 /* #### What should be here. */
|
|
7533 if (dl->modeline)
|
|
7534 *modeline_closest = 0;
|
|
7535 else
|
|
7536 *closest = 0;
|
|
7537 }
|
|
7538
|
|
7539 if (check_margin_glyphs)
|
|
7540 {
|
|
7541 if (x_coord < dl->bounds.left_in
|
|
7542 || x_coord >= dl->bounds.right_in)
|
|
7543 {
|
|
7544 /* If we are over the outside margins then we
|
|
7545 know the loop over the text block isn't going
|
|
7546 to accomplish anything. So we go ahead and
|
|
7547 set what information we can right here and
|
|
7548 return. */
|
|
7549 (*row)--;
|
|
7550 *obj_y = y_coord - (dl->ypos - dl->ascent);
|
|
7551 get_position_object (dl, obj1, obj2, x_coord,
|
|
7552 &low_x_coord, &high_x_coord);
|
|
7553
|
|
7554 UPDATE_CACHE_RETURN;
|
|
7555 }
|
|
7556 }
|
|
7557 else
|
|
7558 UPDATE_CACHE_RETURN;
|
|
7559 }
|
|
7560
|
|
7561 for (*col = 0; *col <= Dynarr_length (db->runes); (*col)++)
|
|
7562 {
|
|
7563 int past_end = (*col == Dynarr_length (db->runes));
|
|
7564
|
|
7565 if (!past_end)
|
|
7566 rb = Dynarr_atp (db->runes, *col);
|
|
7567
|
|
7568 if (past_end ||
|
|
7569 (rb->xpos <= x_coord && x_coord < rb->xpos + rb->width))
|
|
7570 {
|
|
7571 if (past_end)
|
|
7572 {
|
|
7573 (*col)--;
|
|
7574 rb = Dynarr_atp (db->runes, *col);
|
|
7575 }
|
|
7576
|
|
7577 *bufpos = rb->bufpos + dl->offset;
|
|
7578 low_x_coord = rb->xpos;
|
|
7579 high_x_coord = rb->xpos + rb->width;
|
|
7580
|
|
7581 if (rb->type == RUNE_DGLYPH)
|
|
7582 {
|
|
7583 int elt = *col + 1;
|
|
7584
|
|
7585 /* Find the first character after the glyph. */
|
|
7586 while (elt < Dynarr_length (db->runes))
|
|
7587 {
|
|
7588 if (Dynarr_atp (db->runes, elt)->type != RUNE_DGLYPH)
|
|
7589 {
|
|
7590 if (dl->modeline)
|
|
7591 *modeline_closest =
|
|
7592 (Dynarr_atp (db->runes, elt)->bufpos +
|
|
7593 dl->offset);
|
|
7594 else
|
|
7595 *closest =
|
|
7596 (Dynarr_atp (db->runes, elt)->bufpos +
|
|
7597 dl->offset);
|
|
7598 break;
|
|
7599 }
|
|
7600
|
|
7601 elt++;
|
|
7602 }
|
|
7603
|
|
7604 /* In this case we failed to find a non-glyph
|
|
7605 character so we return the last position
|
|
7606 displayed on the line. */
|
|
7607 if (elt == Dynarr_length (db->runes))
|
|
7608 {
|
|
7609 if (dl->modeline)
|
|
7610 *modeline_closest = dl->end_bufpos + dl->offset;
|
|
7611 else
|
|
7612 *closest = dl->end_bufpos + dl->offset;
|
|
7613 really_over_nothing = 1;
|
|
7614 }
|
|
7615 }
|
|
7616 else
|
|
7617 {
|
|
7618 if (dl->modeline)
|
|
7619 *modeline_closest = rb->bufpos + dl->offset;
|
|
7620 else
|
|
7621 *closest = rb->bufpos + dl->offset;
|
|
7622 }
|
|
7623
|
|
7624 if (dl->modeline)
|
|
7625 {
|
|
7626 *row = window_displayed_height (*w);
|
|
7627
|
|
7628 if (position == OVER_NOTHING)
|
|
7629 position = OVER_MODELINE;
|
|
7630
|
|
7631 if (rb->type == RUNE_DGLYPH)
|
|
7632 {
|
|
7633 *obj1 = rb->object.dglyph.glyph;
|
|
7634 *obj2 = rb->object.dglyph.extent;
|
|
7635 }
|
|
7636 else if (rb->type == RUNE_CHAR)
|
|
7637 {
|
|
7638 *obj1 = Qnil;
|
|
7639 *obj2 = Qnil;
|
|
7640 }
|
|
7641 else
|
|
7642 {
|
|
7643 *obj1 = Qnil;
|
|
7644 *obj2 = Qnil;
|
|
7645 }
|
|
7646
|
|
7647 UPDATE_CACHE_RETURN;
|
|
7648 }
|
|
7649 else if (past_end
|
|
7650 || (rb->type == RUNE_CHAR
|
|
7651 && rb->object.chr.ch == '\n'))
|
|
7652 {
|
|
7653 (*row)--;
|
|
7654 /* At this point we may have glyphs in the right
|
|
7655 inside margin. */
|
|
7656 if (check_margin_glyphs)
|
|
7657 get_position_object (dl, obj1, obj2, x_coord,
|
|
7658 &low_x_coord, &high_x_coord);
|
|
7659 UPDATE_CACHE_RETURN;
|
|
7660 }
|
|
7661 else
|
|
7662 {
|
|
7663 (*row)--;
|
|
7664 if (rb->type == RUNE_DGLYPH)
|
|
7665 {
|
|
7666 *obj1 = rb->object.dglyph.glyph;
|
|
7667 *obj2 = rb->object.dglyph.extent;
|
|
7668 }
|
|
7669 else if (rb->type == RUNE_CHAR)
|
|
7670 {
|
|
7671 *obj1 = Qnil;
|
|
7672 *obj2 = Qnil;
|
|
7673 }
|
|
7674 else
|
|
7675 {
|
|
7676 *obj1 = Qnil;
|
|
7677 *obj2 = Qnil;
|
|
7678 }
|
|
7679
|
|
7680 *obj_x = x_coord - rb->xpos;
|
|
7681 *obj_y = y_coord - (dl->ypos - dl->ascent);
|
|
7682
|
|
7683 /* At this point we may have glyphs in the left
|
|
7684 inside margin. */
|
|
7685 if (check_margin_glyphs)
|
|
7686 get_position_object (dl, obj1, obj2, x_coord, 0, 0);
|
|
7687
|
|
7688 if (position == OVER_NOTHING && !really_over_nothing)
|
|
7689 position = OVER_TEXT;
|
|
7690
|
|
7691 UPDATE_CACHE_RETURN;
|
|
7692 }
|
|
7693 }
|
|
7694 }
|
|
7695 }
|
|
7696 }
|
|
7697
|
|
7698 *row = Dynarr_length (dla) - 1;
|
|
7699 if (FRAME_WIN_P (f))
|
|
7700 {
|
|
7701 int bot_elt = Dynarr_length (dla) - 1;
|
|
7702
|
|
7703 if (bot_elt >= 0)
|
|
7704 {
|
|
7705 struct display_line *dl = Dynarr_atp (dla, bot_elt);
|
|
7706 int adj_area = y_coord - (dl->ypos + dl->descent);
|
|
7707 Lisp_Object lwin = Qnil;
|
|
7708 int defheight;
|
|
7709
|
|
7710 XSETWINDOW (lwin, *w);
|
|
7711 default_face_height_and_width (lwin, 0, &defheight);
|
|
7712
|
|
7713 *row += (adj_area / defheight);
|
|
7714 }
|
|
7715 }
|
|
7716
|
|
7717 /* #### This should be checked out some more to determine what
|
|
7718 should really be going on. */
|
|
7719 if (!MARKERP ((*w)->start[CURRENT_DISP]))
|
|
7720 *closest = 0;
|
|
7721 else
|
|
7722 *closest = end_of_last_line (*w,
|
|
7723 marker_position ((*w)->start[CURRENT_DISP]));
|
|
7724 *col = 0;
|
|
7725 UPDATE_CACHE_RETURN;
|
|
7726 }
|
|
7727 #undef UPDATE_CACHE_RETURN
|
|
7728
|
|
7729
|
|
7730 /***************************************************************************/
|
|
7731 /* */
|
|
7732 /* Lisp functions */
|
|
7733 /* */
|
|
7734 /***************************************************************************/
|
|
7735
|
20
|
7736 DEFUN ("redisplay-echo-area", Fredisplay_echo_area, 0, 0, 0, /*
|
0
|
7737 Ensure that all minibuffers are correctly showing the echo area.
|
20
|
7738 */
|
|
7739 ())
|
0
|
7740 {
|
|
7741 Lisp_Object devcons, concons;
|
|
7742
|
|
7743 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
7744 {
|
|
7745 struct device *d = XDEVICE (XCAR (devcons));
|
|
7746 Lisp_Object frmcons;
|
|
7747
|
|
7748 DEVICE_FRAME_LOOP (frmcons, d)
|
|
7749 {
|
|
7750 struct frame *f = XFRAME (XCAR (frmcons));
|
|
7751
|
70
|
7752 if (FRAME_VISIBLE_P (f) && FRAME_HAS_MINIBUF_P (f))
|
0
|
7753 {
|
|
7754 Lisp_Object window = FRAME_MINIBUF_WINDOW (f);
|
|
7755 redisplay_window (window, 0);
|
|
7756 call_redisplay_end_triggers (XWINDOW (window), 0);
|
|
7757 }
|
|
7758 }
|
|
7759
|
|
7760 /* We now call the output_end routine for tty frames. We delay
|
|
7761 doing so in order to avoid cursor flicker. So much for 100%
|
|
7762 encapsulation. */
|
|
7763 if (DEVICE_TTY_P (d))
|
|
7764 DEVMETH (d, output_end, (d));
|
|
7765 }
|
|
7766
|
|
7767 return Qnil;
|
|
7768 }
|
|
7769
|
|
7770 static Lisp_Object
|
|
7771 restore_disable_preemption_value (Lisp_Object value)
|
|
7772 {
|
|
7773 disable_preemption = XINT (value);
|
|
7774 return Qnil;
|
|
7775 }
|
|
7776
|
20
|
7777 DEFUN ("redraw-frame", Fredraw_frame, 0, 2, 0, /*
|
0
|
7778 Clear frame FRAME and output again what is supposed to appear on it.
|
|
7779 FRAME defaults to the selected frame if omitted.
|
|
7780 Normally, redisplay is preempted as normal if input arrives. However,
|
|
7781 if optional second arg NO-PREEMPT is non-nil, redisplay will not stop for
|
|
7782 input and is guaranteed to proceed to completion.
|
20
|
7783 */
|
|
7784 (frame, no_preempt))
|
0
|
7785 {
|
|
7786 struct frame *f = decode_frame (frame);
|
|
7787 int count = specpdl_depth ();
|
|
7788
|
|
7789 if (!NILP (no_preempt))
|
|
7790 {
|
|
7791 record_unwind_protect (restore_disable_preemption_value,
|
|
7792 make_int (disable_preemption));
|
|
7793 disable_preemption++;
|
|
7794 }
|
|
7795
|
|
7796 f->clear = 1;
|
|
7797 redisplay_frame (f, 1);
|
|
7798
|
|
7799 return unbind_to (count, Qnil);
|
|
7800 }
|
|
7801
|
20
|
7802 DEFUN ("redisplay-frame", Fredisplay_frame, 0, 2, 0, /*
|
0
|
7803 Ensure that FRAME's contents are correctly displayed.
|
|
7804 This differs from `redraw-frame' in that it only redraws what needs to
|
|
7805 be updated, as opposed to unconditionally clearing and redrawing
|
|
7806 the frame.
|
|
7807 FRAME defaults to the selected frame if omitted.
|
|
7808 Normally, redisplay is preempted as normal if input arrives. However,
|
|
7809 if optional second arg NO-PREEMPT is non-nil, redisplay will not stop for
|
|
7810 input and is guaranteed to proceed to completion.
|
20
|
7811 */
|
|
7812 (frame, no_preempt))
|
0
|
7813 {
|
|
7814 struct frame *f = decode_frame (frame);
|
|
7815 int count = specpdl_depth ();
|
|
7816
|
|
7817 if (!NILP (no_preempt))
|
|
7818 {
|
|
7819 record_unwind_protect (restore_disable_preemption_value,
|
|
7820 make_int (disable_preemption));
|
|
7821 disable_preemption++;
|
|
7822 }
|
|
7823
|
|
7824 redisplay_frame (f, 1);
|
|
7825
|
|
7826 return unbind_to (count, Qnil);
|
|
7827 }
|
|
7828
|
20
|
7829 DEFUN ("redraw-device", Fredraw_device, 0, 2, 0, /*
|
0
|
7830 Clear device DEVICE and output again what is supposed to appear on it.
|
|
7831 DEVICE defaults to the selected device if omitted.
|
|
7832 Normally, redisplay is preempted as normal if input arrives. However,
|
|
7833 if optional second arg NO-PREEMPT is non-nil, redisplay will not stop for
|
|
7834 input and is guaranteed to proceed to completion.
|
20
|
7835 */
|
70
|
7836 (device, no_preempt))
|
0
|
7837 {
|
|
7838 struct device *d = decode_device (device);
|
|
7839 Lisp_Object frmcons;
|
|
7840 int count = specpdl_depth ();
|
|
7841
|
|
7842 if (!NILP (no_preempt))
|
|
7843 {
|
|
7844 record_unwind_protect (restore_disable_preemption_value,
|
|
7845 make_int (disable_preemption));
|
|
7846 disable_preemption++;
|
|
7847 }
|
|
7848
|
|
7849 DEVICE_FRAME_LOOP (frmcons, d)
|
|
7850 {
|
|
7851 XFRAME (XCAR (frmcons))->clear = 1;
|
|
7852 }
|
|
7853 redisplay_device (d);
|
|
7854
|
|
7855 return unbind_to (count, Qnil);
|
|
7856 }
|
|
7857
|
20
|
7858 DEFUN ("redisplay-device", Fredisplay_device, 0, 2, 0, /*
|
0
|
7859 Ensure that DEVICE's contents are correctly displayed.
|
|
7860 This differs from `redraw-device' in that it only redraws what needs to
|
|
7861 be updated, as opposed to unconditionally clearing and redrawing
|
|
7862 the device.
|
|
7863 DEVICE defaults to the selected device if omitted.
|
|
7864 Normally, redisplay is preempted as normal if input arrives. However,
|
|
7865 if optional second arg NO-PREEMPT is non-nil, redisplay will not stop for
|
|
7866 input and is guaranteed to proceed to completion.
|
20
|
7867 */
|
|
7868 (device, no_preempt))
|
0
|
7869 {
|
|
7870 struct device *d = decode_device (device);
|
|
7871 int count = specpdl_depth ();
|
|
7872
|
|
7873 if (!NILP (no_preempt))
|
|
7874 {
|
|
7875 record_unwind_protect (restore_disable_preemption_value,
|
|
7876 make_int (disable_preemption));
|
|
7877 disable_preemption++;
|
|
7878 }
|
|
7879
|
|
7880 redisplay_device (d);
|
|
7881
|
|
7882 return unbind_to (count, Qnil);
|
|
7883 }
|
|
7884
|
|
7885 /* Big lie. Big lie. This will force all modelines to be updated
|
|
7886 regardless if the all flag is set or not. It remains in existence
|
|
7887 solely for backwards compatibility. */
|
20
|
7888 DEFUN ("redraw-modeline", Fredraw_modeline, 0, 1, 0, /*
|
0
|
7889 Force the modeline of the current buffer to be redisplayed.
|
|
7890 With optional non-nil ALL, force redisplay of all modelines.
|
20
|
7891 */
|
|
7892 (all))
|
0
|
7893 {
|
|
7894 MARK_MODELINE_CHANGED;
|
|
7895 return Qnil;
|
|
7896 }
|
|
7897
|
20
|
7898 DEFUN ("force-cursor-redisplay", Fforce_cursor_redisplay, 0, 1, 0, /*
|
0
|
7899 Force an immediate update of the cursor on FRAME.
|
|
7900 FRAME defaults to the selected frame if omitted.
|
20
|
7901 */
|
70
|
7902 (frame))
|
0
|
7903 {
|
|
7904 redisplay_redraw_cursor (decode_frame (frame), 1);
|
|
7905 return Qnil;
|
|
7906 }
|
|
7907
|
|
7908
|
|
7909 /***************************************************************************/
|
|
7910 /* */
|
|
7911 /* Lisp-variable change triggers */
|
|
7912 /* */
|
|
7913 /***************************************************************************/
|
|
7914
|
|
7915 static void
|
|
7916 margin_width_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
7917 Lisp_Object oldval)
|
|
7918 {
|
|
7919 /* Nothing to be done? */
|
|
7920 }
|
|
7921
|
|
7922 int
|
|
7923 redisplay_variable_changed (Lisp_Object sym, Lisp_Object *val,
|
|
7924 Lisp_Object in_object, int flags)
|
|
7925 {
|
|
7926 /* #### clip_changed should really be renamed something like
|
|
7927 global_redisplay_change. */
|
|
7928 MARK_CLIP_CHANGED;
|
|
7929 return 0;
|
|
7930 }
|
|
7931
|
|
7932 void
|
|
7933 redisplay_glyph_changed (Lisp_Object glyph, Lisp_Object property,
|
|
7934 Lisp_Object locale)
|
|
7935 {
|
|
7936 MARK_CLIP_CHANGED;
|
|
7937 }
|
|
7938
|
|
7939 static void
|
|
7940 text_cursor_visible_p_changed (Lisp_Object specifier, struct window *w,
|
|
7941 Lisp_Object oldval)
|
|
7942 {
|
|
7943 if (XFRAME (w->frame)->init_finished)
|
|
7944 Fforce_cursor_redisplay (w->frame);
|
|
7945 }
|
|
7946
|
|
7947 #ifdef MEMORY_USAGE_STATS
|
|
7948
|
|
7949
|
|
7950 /***************************************************************************/
|
|
7951 /* */
|
|
7952 /* memory usage computation */
|
|
7953 /* */
|
|
7954 /***************************************************************************/
|
|
7955
|
|
7956 static int
|
|
7957 compute_rune_dynarr_usage (rune_dynarr *dyn, struct overhead_stats *ovstats)
|
|
7958 {
|
|
7959 int total = 0;
|
|
7960
|
|
7961 if (dyn)
|
|
7962 total += Dynarr_memory_usage (dyn, ovstats);
|
|
7963
|
|
7964 return total;
|
|
7965 }
|
|
7966
|
|
7967 static int
|
|
7968 compute_display_block_dynarr_usage (display_block_dynarr *dyn,
|
|
7969 struct overhead_stats *ovstats)
|
|
7970 {
|
|
7971 int total = 0;
|
|
7972
|
|
7973 if (dyn)
|
|
7974 {
|
|
7975 int i;
|
|
7976
|
|
7977 total += Dynarr_memory_usage (dyn, ovstats);
|
|
7978 for (i = 0; i < Dynarr_largest (dyn); i++)
|
|
7979 total += compute_rune_dynarr_usage (Dynarr_at (dyn, i).runes, ovstats);
|
|
7980 }
|
|
7981
|
|
7982 return total;
|
|
7983 }
|
|
7984
|
|
7985 static int
|
|
7986 compute_glyph_block_dynarr_usage (glyph_block_dynarr *dyn,
|
|
7987 struct overhead_stats *ovstats)
|
|
7988 {
|
|
7989 int total = 0;
|
|
7990
|
|
7991 if (dyn)
|
|
7992 total += Dynarr_memory_usage (dyn, ovstats);
|
|
7993
|
|
7994 return total;
|
|
7995 }
|
|
7996
|
|
7997 int
|
|
7998 compute_display_line_dynarr_usage (display_line_dynarr *dyn,
|
|
7999 struct overhead_stats *ovstats)
|
|
8000 {
|
|
8001 int total = 0;
|
|
8002
|
|
8003 if (dyn)
|
|
8004 {
|
|
8005 int i;
|
|
8006
|
|
8007 total += Dynarr_memory_usage (dyn, ovstats);
|
|
8008 for (i = 0; i < Dynarr_largest (dyn); i++)
|
|
8009 {
|
|
8010 total +=
|
|
8011 compute_display_block_dynarr_usage (Dynarr_at (dyn, i).
|
|
8012 display_blocks, ovstats);
|
|
8013 total +=
|
|
8014 compute_glyph_block_dynarr_usage (Dynarr_at (dyn, i).
|
|
8015 left_glyphs, ovstats);
|
|
8016 total +=
|
|
8017 compute_glyph_block_dynarr_usage (Dynarr_at (dyn, i).
|
|
8018 right_glyphs, ovstats);
|
|
8019 }
|
|
8020 }
|
|
8021
|
|
8022 return total;
|
|
8023 }
|
|
8024
|
|
8025 int
|
|
8026 compute_line_start_cache_dynarr_usage (line_start_cache_dynarr *dyn,
|
|
8027 struct overhead_stats *ovstats)
|
|
8028 {
|
|
8029 int total = 0;
|
|
8030
|
|
8031 if (dyn)
|
|
8032 total += Dynarr_memory_usage (dyn, ovstats);
|
|
8033
|
|
8034 return total;
|
|
8035 }
|
|
8036
|
|
8037 #endif /* MEMORY_USAGE_STATS */
|
|
8038
|
|
8039
|
|
8040 /***************************************************************************/
|
|
8041 /* */
|
|
8042 /* initialization */
|
|
8043 /* */
|
|
8044 /***************************************************************************/
|
|
8045
|
|
8046 void
|
|
8047 init_redisplay (void)
|
|
8048 {
|
|
8049 disable_preemption = 0;
|
|
8050 preemption_count = 0;
|
|
8051 max_preempts = INIT_MAX_PREEMPTS;
|
|
8052
|
|
8053 if (!initialized)
|
|
8054 {
|
|
8055 cmotion_display_lines = Dynarr_new (struct display_line);
|
|
8056 mode_spec_bufbyte_string = Dynarr_new (Bufbyte);
|
|
8057 formatted_string_emchar_dynarr = Dynarr_new (Emchar);
|
|
8058 formatted_string_extent_dynarr = Dynarr_new (struct extent *);
|
|
8059 formatted_string_extent_start_dynarr = Dynarr_new (Bytecount);
|
|
8060 formatted_string_extent_end_dynarr = Dynarr_new (Bytecount);
|
|
8061 internal_cache = Dynarr_new (struct line_start_cache);
|
|
8062 memset (&formatted_string_display_line, 0, sizeof (struct display_line));
|
|
8063 }
|
|
8064
|
|
8065 /* window system is nil when in -batch mode */
|
|
8066 if (!initialized || noninteractive)
|
|
8067 return;
|
|
8068
|
|
8069 /* If the user wants to use a window system, we shouldn't bother
|
|
8070 initializing the terminal. This is especially important when the
|
|
8071 terminal is so dumb that emacs gives up before and doesn't bother
|
|
8072 using the window system.
|
|
8073
|
|
8074 If the DISPLAY environment variable is set, try to use X, and die
|
|
8075 with an error message if that doesn't work. */
|
|
8076
|
|
8077 #ifdef HAVE_X_WINDOWS
|
|
8078 if (!strcmp (display_use, "x"))
|
|
8079 {
|
|
8080 /* Some stuff checks this way early. */
|
|
8081 Vwindow_system = Qx;
|
|
8082 Vinitial_window_system = Qx;
|
|
8083 return;
|
|
8084 }
|
|
8085 #endif
|
|
8086 #ifdef HAVE_NEXTSTEP
|
|
8087 if (!strcmp (display_use, "ns"))
|
|
8088 {
|
|
8089 Vwindow_system = Qns;
|
|
8090 Vinitial_window_system = Qns;
|
|
8091 return;
|
|
8092 }
|
|
8093 #endif
|
|
8094
|
|
8095 /* If no window system has been specified, try to use the terminal. */
|
|
8096 if (!isatty (0))
|
|
8097 {
|
|
8098 stderr_out ("XEmacs: standard input is not a tty\n");
|
|
8099 exit (1);
|
|
8100 }
|
|
8101
|
|
8102 /* Look at the TERM variable */
|
|
8103 if (!getenv ("TERM"))
|
|
8104 {
|
|
8105 stderr_out ("Please set the environment variable TERM; see tset(1).\n");
|
|
8106 exit (1);
|
|
8107 }
|
|
8108
|
|
8109 Vinitial_window_system = Qtty;
|
|
8110 }
|
|
8111
|
|
8112 void
|
|
8113 syms_of_redisplay (void)
|
|
8114 {
|
|
8115 defsymbol (&Qcursor_in_echo_area, "cursor-in-echo-area");
|
|
8116 #ifndef INHIBIT_REDISPLAY_HOOKS
|
|
8117 defsymbol (&Qpre_redisplay_hook, "pre-redisplay-hook");
|
|
8118 defsymbol (&Qpost_redisplay_hook, "post-redisplay-hook");
|
|
8119 #endif
|
|
8120 defsymbol (&Qdisplay_warning_buffer, "display-warning-buffer");
|
|
8121 defsymbol (&Qbar_cursor, "bar-cursor");
|
|
8122 defsymbol (&Qwindow_scroll_functions, "window-scroll-functions");
|
|
8123 defsymbol (&Qredisplay_end_trigger_functions,
|
|
8124 "redisplay-end-trigger-functions");
|
|
8125
|
20
|
8126 DEFSUBR (Fredisplay_echo_area);
|
|
8127 DEFSUBR (Fredraw_frame);
|
|
8128 DEFSUBR (Fredisplay_frame);
|
|
8129 DEFSUBR (Fredraw_device);
|
|
8130 DEFSUBR (Fredisplay_device);
|
|
8131 DEFSUBR (Fredraw_modeline);
|
|
8132 DEFSUBR (Fforce_cursor_redisplay);
|
0
|
8133 }
|
|
8134
|
|
8135 void
|
|
8136 vars_of_redisplay (void)
|
|
8137 {
|
|
8138 #if 0
|
|
8139 staticpro (&last_arrow_position);
|
|
8140 staticpro (&last_arrow_string);
|
|
8141 last_arrow_position = Qnil;
|
|
8142 last_arrow_string = Qnil;
|
|
8143 #endif
|
|
8144
|
|
8145 updating_line_start_cache = 0;
|
|
8146
|
|
8147 /* #### Probably temporary */
|
|
8148 DEFVAR_INT ("redisplay-cache-adjustment", &cache_adjustment /*
|
|
8149 (Temporary) Setting this will impact the performance of the internal
|
|
8150 line start cache.
|
|
8151 */ );
|
|
8152 cache_adjustment = 2;
|
|
8153
|
|
8154 DEFVAR_INT_MAGIC ("pixel-vertical-clip-threshold", &vertical_clip /*
|
|
8155 Minimum pixel height for clipped bottom display line.
|
|
8156 A clipped line shorter than this won't be displayed.
|
|
8157 */ ,
|
|
8158 redisplay_variable_changed);
|
|
8159 vertical_clip = 5;
|
|
8160
|
|
8161 DEFVAR_INT_MAGIC ("pixel-horizontal-clip-threshold", &horizontal_clip /*
|
|
8162 Minimum visible area for clipped glyphs at right boundary.
|
|
8163 Clipped glyphs shorter than this won't be displayed.
|
|
8164 Only pixmap glyph instances are currently allowed to be clipped.
|
|
8165 */ ,
|
|
8166 redisplay_variable_changed);
|
|
8167 horizontal_clip = 5;
|
|
8168
|
|
8169 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string /*
|
|
8170 String displayed by modeline-format's \"%m\" specification.
|
|
8171 */ );
|
|
8172 Vglobal_mode_string = Qnil;
|
|
8173
|
|
8174 DEFVAR_LISP_MAGIC ("overlay-arrow-position", &Voverlay_arrow_position /*
|
|
8175 Marker for where to display an arrow on top of the buffer text.
|
|
8176 This must be the beginning of a line in order to work.
|
|
8177 See also `overlay-arrow-string'.
|
|
8178 */ , redisplay_variable_changed);
|
|
8179 Voverlay_arrow_position = Qnil;
|
|
8180
|
|
8181 DEFVAR_LISP_MAGIC ("overlay-arrow-string", &Voverlay_arrow_string /*
|
|
8182 String to display as an arrow. See also `overlay-arrow-position'.
|
|
8183 */ ,
|
|
8184 redisplay_variable_changed);
|
|
8185 Voverlay_arrow_string = Qnil;
|
|
8186
|
|
8187 DEFVAR_INT ("scroll-step", &scroll_step /*
|
|
8188 *The number of lines to try scrolling a window by when point moves out.
|
|
8189 If that fails to bring point back on frame, point is centered instead.
|
|
8190 If this is zero, point is always centered after it moves off screen.
|
|
8191 */ );
|
|
8192
|
|
8193 DEFVAR_BOOL_MAGIC ("truncate-partial-width-windows",
|
|
8194 &truncate_partial_width_windows /*
|
|
8195 *Non-nil means truncate lines in all windows less than full frame wide.
|
|
8196 */ ,
|
|
8197 redisplay_variable_changed);
|
|
8198 truncate_partial_width_windows = 1;
|
|
8199
|
|
8200 DEFVAR_BOOL ("visible-bell", &visible_bell /*
|
|
8201 *Non-nil means try to flash the frame to represent a bell.
|
|
8202 */ );
|
|
8203 visible_bell = 0;
|
|
8204
|
|
8205 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter /*
|
|
8206 *Non-nil means no need to redraw entire frame after suspending.
|
|
8207 A non-nil value is useful if the terminal can automatically preserve
|
|
8208 Emacs's frame display when you reenter Emacs.
|
|
8209 It is up to you to set this variable if your terminal can do that.
|
|
8210 */ );
|
|
8211 no_redraw_on_reenter = 0;
|
|
8212
|
70
|
8213 /* #### This should be removed in 19.14 */
|
0
|
8214 DEFVAR_LISP ("window-system", &Vwindow_system /*
|
|
8215 A symbol naming the window-system under which Emacs is running,
|
|
8216 such as `x', or nil if emacs is running on an ordinary terminal.
|
70
|
8217 This variable is OBSOLETE and will be removed in a future version.
|
0
|
8218 */ );
|
|
8219 Vwindow_system = Qnil;
|
|
8220
|
|
8221 /* #### Temporary shit until window-system is eliminated. */
|
|
8222 DEFVAR_LISP ("initial-window-system", &Vinitial_window_system /*
|
|
8223 DON'T TOUCH
|
|
8224 */ );
|
|
8225 Vinitial_window_system = Qnil;
|
|
8226
|
|
8227 DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area /*
|
|
8228 Non-nil means put cursor in minibuffer, at end of any message there.
|
|
8229 */ );
|
|
8230 cursor_in_echo_area = 0;
|
|
8231
|
|
8232 /* #### Shouldn't this be generalized as follows:
|
|
8233
|
|
8234 if nil, use block cursor.
|
|
8235 if a number, use a bar cursor of that width.
|
|
8236 Otherwise, use a 1-pixel bar cursor.
|
|
8237
|
|
8238 #### Or better yet, this variable should be trashed entirely
|
|
8239 (use a Lisp-magic variable to maintain compatibility)
|
|
8240 and a specifier `cursor-shape' added, which allows a block
|
|
8241 cursor, a bar cursor, a flashing block or bar cursor,
|
|
8242 maybe a caret cursor, etc. */
|
|
8243
|
|
8244 DEFVAR_LISP ("bar-cursor", &Vbar_cursor /*
|
|
8245 Use vertical bar cursor if non-nil. If t width is 1 pixel, otherwise 2.
|
|
8246 */ );
|
|
8247 Vbar_cursor = Qnil;
|
|
8248
|
|
8249 #ifndef INHIBIT_REDISPLAY_HOOKS
|
|
8250 xxDEFVAR_LISP ("pre-redisplay-hook", &Vpre_redisplay_hook /*
|
|
8251 Function or functions to run before every redisplay.
|
|
8252 Functions on this hook must be careful to avoid signalling errors!
|
|
8253 */ );
|
|
8254 Vpre_redisplay_hook = Qnil;
|
|
8255
|
|
8256 xxDEFVAR_LISP ("post-redisplay-hook", &Vpost_redisplay_hook /*
|
|
8257 Function or functions to run after every redisplay.
|
|
8258 Functions on this hook must be careful to avoid signalling errors!
|
|
8259 */ );
|
|
8260 Vpost_redisplay_hook = Qnil;
|
|
8261 #endif
|
|
8262
|
|
8263 DEFVAR_INT ("display-warning-tick", &display_warning_tick /*
|
|
8264 Bump this to tell the C code to call `display-warning-buffer'
|
|
8265 at next redisplay. You should not normally change this; the function
|
|
8266 `display-warning' automatically does this at appropriate times.
|
|
8267 */ );
|
|
8268 display_warning_tick = 0;
|
|
8269
|
|
8270 DEFVAR_BOOL ("inhibit-warning-display", &inhibit_warning_display /*
|
|
8271 Non-nil means inhibit display of warning messages.
|
|
8272 You should *bind* this, not set it. Any pending warning messages
|
|
8273 will be displayed when the binding no longer applies.
|
|
8274 */ );
|
|
8275 /* reset to 0 by startup.el after the splash screen has displayed.
|
|
8276 This way, the warnings don't obliterate the splash screen. */
|
|
8277 inhibit_warning_display = 1;
|
|
8278
|
|
8279 DEFVAR_LISP ("window-size-change-functions",
|
|
8280 &Vwindow_size_change_functions /*
|
|
8281 Not currently implemented.
|
|
8282 Functions called before redisplay, if window sizes have changed.
|
|
8283 The value should be a list of functions that take one argument.
|
|
8284 Just before redisplay, for each frame, if any of its windows have changed
|
|
8285 size since the last redisplay, or have been split or deleted,
|
|
8286 all the functions in the list are called, with the frame as argument.
|
|
8287 */ );
|
|
8288 Vwindow_size_change_functions = Qnil;
|
|
8289
|
|
8290 DEFVAR_LISP ("window-scroll-functions", &Vwindow_scroll_functions /*
|
|
8291 Not currently implemented.
|
|
8292 Functions to call before redisplaying a window with scrolling.
|
|
8293 Each function is called with two arguments, the window
|
|
8294 and its new display-start position. Note that the value of `window-end'
|
|
8295 is not valid when these functions are called.
|
|
8296 */ );
|
|
8297 Vwindow_scroll_functions = Qnil;
|
|
8298
|
|
8299 DEFVAR_LISP ("redisplay-end-trigger-functions",
|
|
8300 &Vredisplay_end_trigger_functions /*
|
|
8301 See `set-window-redisplay-end-trigger'.
|
|
8302 */ );
|
|
8303 Vredisplay_end_trigger_functions = Qnil;
|
72
|
8304
|
|
8305 DEFVAR_BOOL ("column-number-start-at-one", &column_number_start_at_one /*
|
|
8306 Non-nil means column display number starts at 1.
|
|
8307 */ );
|
|
8308 column_number_start_at_one = 1;
|
0
|
8309 }
|
|
8310
|
|
8311 void
|
|
8312 specifier_vars_of_redisplay (void)
|
|
8313 {
|
|
8314 DEFVAR_SPECIFIER ("left-margin-width", &Vleft_margin_width /*
|
|
8315 *Width of left margin.
|
|
8316 This is a specifier; use `set-specifier' to change it.
|
|
8317 */ );
|
|
8318 Vleft_margin_width = Fmake_specifier (Qnatnum);
|
|
8319 set_specifier_fallback
|
|
8320 (Vleft_margin_width,
|
|
8321 list1 (Fcons (Qnil, Qzero)));
|
|
8322 set_specifier_caching (Vleft_margin_width,
|
|
8323 slot_offset (struct window, left_margin_width),
|
|
8324 some_window_value_changed,
|
|
8325 slot_offset (struct frame, left_margin_width),
|
|
8326 margin_width_changed_in_frame);
|
|
8327
|
|
8328 DEFVAR_SPECIFIER ("right-margin-width", &Vright_margin_width /*
|
|
8329 *Width of right margin.
|
|
8330 This is a specifier; use `set-specifier' to change it.
|
|
8331 */ );
|
|
8332 Vright_margin_width = Fmake_specifier (Qnatnum);
|
|
8333 set_specifier_fallback
|
|
8334 (Vright_margin_width,
|
|
8335 list1 (Fcons (Qnil, Qzero)));
|
|
8336 set_specifier_caching (Vright_margin_width,
|
|
8337 slot_offset (struct window, right_margin_width),
|
|
8338 some_window_value_changed,
|
|
8339 slot_offset (struct frame, right_margin_width),
|
|
8340 margin_width_changed_in_frame);
|
|
8341
|
|
8342 DEFVAR_SPECIFIER ("minimum-line-ascent", &Vminimum_line_ascent /*
|
|
8343 *Minimum ascent height of lines.
|
|
8344 This is a specifier; use `set-specifier' to change it.
|
|
8345 */ );
|
|
8346 Vminimum_line_ascent = Fmake_specifier (Qnatnum);
|
|
8347 set_specifier_fallback (Vminimum_line_ascent,
|
|
8348 list1 (Fcons (Qnil, Qzero)));
|
|
8349 set_specifier_caching (Vminimum_line_ascent,
|
|
8350 slot_offset (struct window,
|
|
8351 minimum_line_ascent),
|
|
8352 some_window_value_changed,
|
|
8353 0, 0);
|
|
8354
|
|
8355 DEFVAR_SPECIFIER ("minimum-line-descent", &Vminimum_line_descent /*
|
|
8356 *Minimum descent height of lines.
|
|
8357 This is a specifier; use `set-specifier' to change it.
|
|
8358 */ );
|
|
8359 Vminimum_line_descent = Fmake_specifier (Qnatnum);
|
|
8360 set_specifier_fallback (Vminimum_line_descent,
|
|
8361 list1 (Fcons (Qnil, Qzero)));
|
|
8362 set_specifier_caching (Vminimum_line_descent,
|
|
8363 slot_offset (struct window,
|
|
8364 minimum_line_descent),
|
|
8365 some_window_value_changed,
|
|
8366 0, 0);
|
|
8367
|
|
8368 DEFVAR_SPECIFIER ("use-left-overflow", &Vuse_left_overflow /*
|
|
8369 *Non-nil means use the left outside margin as extra whitespace when
|
|
8370 displaying 'whitespace or 'inside-margin glyphs.
|
|
8371 This is a specifier; use `set-specifier' to change it.
|
|
8372 */ );
|
|
8373 Vuse_left_overflow = Fmake_specifier (Qboolean);
|
|
8374 set_specifier_fallback (Vuse_left_overflow,
|
|
8375 list1 (Fcons (Qnil, Qnil)));
|
|
8376 set_specifier_caching (Vuse_left_overflow,
|
|
8377 slot_offset (struct window,
|
|
8378 use_left_overflow),
|
|
8379 some_window_value_changed,
|
|
8380 0, 0);
|
|
8381
|
|
8382 DEFVAR_SPECIFIER ("use-right-overflow", &Vuse_right_overflow /*
|
|
8383 *Non-nil means use the right outside margin as extra whitespace when
|
|
8384 displaying 'whitespace or 'inside-margin glyphs.
|
|
8385 This is a specifier; use `set-specifier' to change it.
|
|
8386 */ );
|
|
8387 Vuse_right_overflow = Fmake_specifier (Qboolean);
|
|
8388 set_specifier_fallback (Vuse_right_overflow,
|
|
8389 list1 (Fcons (Qnil, Qnil)));
|
|
8390 set_specifier_caching (Vuse_right_overflow,
|
|
8391 slot_offset (struct window,
|
|
8392 use_right_overflow),
|
|
8393 some_window_value_changed,
|
|
8394 0, 0);
|
|
8395
|
|
8396 DEFVAR_SPECIFIER ("text-cursor-visible-p", &Vtext_cursor_visible_p /*
|
|
8397 *Non-nil means the text cursor is visible (this is usually the case).
|
|
8398 This is a specifier; use `set-specifier' to change it.
|
|
8399 */ );
|
|
8400 Vtext_cursor_visible_p = Fmake_specifier (Qboolean);
|
|
8401 set_specifier_fallback (Vtext_cursor_visible_p,
|
|
8402 list1 (Fcons (Qnil, Qt)));
|
|
8403 set_specifier_caching (Vtext_cursor_visible_p,
|
|
8404 slot_offset (struct window,
|
|
8405 text_cursor_visible_p),
|
|
8406 text_cursor_visible_p_changed,
|
|
8407 0, 0);
|
72
|
8408
|
0
|
8409 }
|