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