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