0
|
1 /* Synchronize redisplay structures and output changes.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
4 Copyright (C) 1996 Chuck Thompson.
|
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
|
25 /* This file has been Mule-ized. */
|
|
26
|
|
27 /* Author: Chuck Thompson */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31 #include "debug.h"
|
|
32
|
|
33 #include "buffer.h"
|
|
34 #include "window.h"
|
|
35 #include "frame.h"
|
|
36 #include "device.h"
|
|
37 #include "glyphs.h"
|
|
38 #include "redisplay.h"
|
|
39 #include "faces.h"
|
|
40
|
|
41 #include "sysdep.h"
|
|
42
|
|
43 static int compare_runes (struct window *w, struct rune *crb,
|
|
44 struct rune *drb);
|
|
45 static void redraw_cursor_in_window (struct window *w,
|
|
46 int run_end_begin_glyphs);
|
|
47 void redisplay_output_window (struct window *w);
|
|
48
|
|
49 /*****************************************************************************
|
|
50 sync_rune_structs
|
|
51
|
|
52 Synchronize the given rune blocks.
|
|
53 ****************************************************************************/
|
|
54 static void
|
|
55 sync_rune_structs (struct window *w, rune_dynarr *cra, rune_dynarr *dra)
|
|
56 {
|
|
57 int rune_elt;
|
|
58 int max_move = ((Dynarr_length (dra) > Dynarr_largest (cra))
|
|
59 ? Dynarr_largest (cra)
|
|
60 : Dynarr_length (dra));
|
|
61
|
|
62 if (max_move)
|
|
63 {
|
|
64 /* #### Doing this directly breaks the encapsulation. But, the
|
|
65 running time of this function has a measurable impact on
|
|
66 redisplay performance so avoiding all excess overhead is a
|
|
67 good thing. Is all of this true? */
|
|
68 memcpy (cra->base, dra->base, sizeof (struct rune) * max_move);
|
|
69 Dynarr_set_size (cra, max_move);
|
|
70 }
|
|
71 else
|
|
72 Dynarr_reset (cra);
|
|
73
|
|
74 for (rune_elt = max_move; rune_elt < Dynarr_length (dra); rune_elt++)
|
|
75 {
|
|
76 struct rune rb, *crb;
|
|
77 struct rune *drb = Dynarr_atp (dra, rune_elt);
|
|
78
|
|
79 crb = &rb;
|
|
80 memcpy (crb, drb, sizeof (struct rune));
|
|
81 Dynarr_add (cra, *crb);
|
|
82 }
|
|
83 }
|
|
84
|
|
85 /*****************************************************************************
|
|
86 sync_display_line_structs
|
|
87
|
|
88 For the given LINE in window W, make the current display line equal
|
|
89 the desired display line.
|
|
90 ****************************************************************************/
|
|
91 static void
|
|
92 sync_display_line_structs (struct window *w, int line, int do_blocks,
|
|
93 display_line_dynarr *cdla,
|
|
94 display_line_dynarr *ddla)
|
|
95 {
|
|
96 int cdla_len = Dynarr_length (cdla);
|
|
97
|
|
98 struct display_line dl, *clp, *dlp;
|
|
99 int db_elt;
|
|
100
|
|
101 dlp = Dynarr_atp (ddla, line);
|
|
102 if (line >= Dynarr_largest (cdla))
|
|
103 {
|
|
104 clp = &dl;
|
185
|
105 clp->display_blocks = Dynarr_new (display_block);
|
0
|
106 }
|
|
107 else
|
|
108 {
|
|
109 clp = Dynarr_atp (cdla, line);
|
|
110 if (clp->display_blocks)
|
|
111 Dynarr_reset (clp->display_blocks);
|
|
112 if (clp->left_glyphs)
|
|
113 {
|
|
114 Dynarr_free (clp->left_glyphs);
|
|
115 clp->left_glyphs = 0;
|
|
116 }
|
|
117 if (clp->right_glyphs)
|
|
118 {
|
|
119 Dynarr_free (clp->right_glyphs);
|
|
120 clp->right_glyphs = 0;
|
|
121 }
|
|
122 }
|
|
123 {
|
|
124 display_block_dynarr *tdb = clp->display_blocks;
|
|
125
|
|
126 memcpy (clp, dlp, sizeof (struct display_line));
|
|
127 clp->display_blocks = tdb;
|
|
128 clp->left_glyphs = 0;
|
|
129 clp->right_glyphs = 0;
|
|
130 }
|
|
131
|
|
132 if (!do_blocks && line >= cdla_len)
|
|
133 {
|
|
134 Dynarr_add (cdla, *clp);
|
|
135 return;
|
|
136 }
|
|
137
|
|
138 for (db_elt = 0; db_elt < Dynarr_length (dlp->display_blocks); db_elt++)
|
|
139 {
|
|
140 struct display_block db, *cdb;
|
|
141 struct display_block *ddb = Dynarr_atp (dlp->display_blocks, db_elt);
|
|
142
|
|
143 if (db_elt >= Dynarr_largest (clp->display_blocks))
|
|
144 {
|
|
145 cdb = &db;
|
|
146 memcpy (cdb, ddb, sizeof (struct display_block));
|
185
|
147 cdb->runes = Dynarr_new (rune);
|
0
|
148 Dynarr_add (clp->display_blocks, *cdb);
|
|
149 }
|
|
150 else
|
|
151 {
|
|
152 rune_dynarr *tr;
|
|
153
|
|
154 cdb = Dynarr_atp (clp->display_blocks, db_elt);
|
|
155 tr = cdb->runes;
|
|
156 memcpy (cdb, ddb, sizeof (struct display_block));
|
|
157 cdb->runes = tr;
|
|
158 Dynarr_increment (clp->display_blocks);
|
|
159 }
|
|
160
|
|
161 sync_rune_structs (w, cdb->runes, ddb->runes);
|
|
162 }
|
|
163
|
|
164 if (line >= cdla_len)
|
|
165 Dynarr_add (cdla, *clp);
|
|
166 }
|
|
167
|
|
168 /*****************************************************************************
|
|
169 compare_runes
|
|
170
|
|
171 Compare to runes to see if each of their fields is equal. If so,
|
|
172 return true otherwise return false.
|
|
173 ****************************************************************************/
|
|
174 static int
|
|
175 compare_runes (struct window *w, struct rune *crb, struct rune *drb)
|
|
176 {
|
|
177 /* Do not compare the values of bufpos and endpos. They do not
|
|
178 affect the display characteristics. */
|
|
179
|
|
180 if ((crb->findex != drb->findex) ||
|
|
181 (WINDOW_FACE_CACHEL_DIRTY (w, drb->findex)))
|
|
182 return 0;
|
|
183 else if (crb->xpos != drb->xpos)
|
|
184 return 0;
|
|
185 else if (crb->width != drb->width)
|
|
186 return 0;
|
|
187 else if (crb->cursor_type != drb->cursor_type)
|
|
188 return 0;
|
|
189 else if (crb->type != drb->type)
|
|
190 return 0;
|
|
191 else if (crb->type == RUNE_CHAR &&
|
|
192 (crb->object.chr.ch != drb->object.chr.ch))
|
|
193 return 0;
|
|
194 else if (crb->type == RUNE_DGLYPH &&
|
|
195 (!EQ (crb->object.dglyph.glyph, drb->object.dglyph.glyph) ||
|
|
196 !EQ (crb->object.dglyph.extent, drb->object.dglyph.extent) ||
|
|
197 crb->object.dglyph.xoffset != drb->object.dglyph.xoffset))
|
|
198 return 0;
|
|
199 else if (crb->type == RUNE_HLINE &&
|
|
200 (crb->object.hline.thickness != drb->object.hline.thickness ||
|
|
201 crb->object.hline.yoffset != drb->object.hline.yoffset))
|
|
202 return 0;
|
|
203 else
|
|
204 return 1;
|
|
205 }
|
|
206
|
|
207 /*****************************************************************************
|
|
208 get_next_display_block
|
|
209
|
|
210 Return the next display starting at or overlapping START_POS. Return
|
|
211 the start of the next region in NEXT_START.
|
|
212 ****************************************************************************/
|
|
213 int
|
|
214 get_next_display_block (layout_bounds bounds, display_block_dynarr *dba,
|
|
215 int start_pos, int *next_start)
|
|
216 {
|
|
217 int next_display_block = NO_BLOCK;
|
|
218 int priority = -1;
|
|
219 int block;
|
|
220
|
|
221 /* If we don't find a display block covering or starting at
|
|
222 start_pos, then we return the starting point of the next display
|
|
223 block or the next division boundary, whichever is closer to
|
|
224 start_pos. */
|
|
225 if (next_start)
|
|
226 {
|
|
227 if (start_pos >= bounds.left_out && start_pos < bounds.left_in)
|
|
228 *next_start = bounds.left_in;
|
|
229 else if (start_pos < bounds.left_white)
|
|
230 *next_start = bounds.left_white;
|
|
231 else if (start_pos < bounds.right_white)
|
|
232 *next_start = bounds.right_white;
|
|
233 else if (start_pos < bounds.right_in)
|
|
234 *next_start = bounds.right_in;
|
|
235 else if (start_pos <= bounds.right_out)
|
|
236 *next_start = bounds.right_out;
|
|
237 else
|
|
238 abort ();
|
|
239 }
|
|
240
|
|
241 for (block = 0; block < Dynarr_length (dba); block++)
|
|
242 {
|
|
243 struct display_block *db = Dynarr_atp (dba, block);
|
|
244
|
|
245 if (db->start_pos <= start_pos && db->end_pos > start_pos)
|
|
246 {
|
|
247 if ((int) db->type > priority)
|
|
248 {
|
|
249 priority = db->type;
|
|
250 next_display_block = block;
|
|
251 if (next_start)
|
|
252 *next_start = db->end_pos;
|
|
253 }
|
|
254 }
|
|
255 else if (next_start && db->start_pos > start_pos)
|
|
256 {
|
|
257 if (db->start_pos < *next_start)
|
|
258 *next_start = db->start_pos;
|
|
259 }
|
|
260 }
|
|
261
|
|
262 return next_display_block;
|
|
263 }
|
|
264
|
|
265 /*****************************************************************************
|
|
266 get_cursor_size_and_location
|
|
267
|
|
268 Return the information defining the pixel location of the cursor.
|
|
269 ****************************************************************************/
|
|
270 static void
|
|
271 get_cursor_size_and_location (struct window *w, struct display_block *db,
|
|
272 int cursor_location,
|
|
273 int *cursor_start, int *cursor_width,
|
|
274 int *cursor_height)
|
|
275 {
|
|
276 struct rune *rb;
|
|
277 Lisp_Object window = Qnil;
|
|
278 int defheight, defwidth;
|
|
279
|
|
280 if (Dynarr_length (db->runes) <= cursor_location)
|
|
281 abort ();
|
|
282
|
|
283 XSETWINDOW (window, w);
|
|
284
|
|
285 rb = Dynarr_atp (db->runes, cursor_location);
|
|
286 *cursor_start = rb->xpos;
|
|
287
|
|
288 default_face_height_and_width (window, &defheight, &defwidth);
|
|
289 *cursor_height = defheight;
|
|
290
|
|
291 if (rb->type == RUNE_BLANK)
|
|
292 *cursor_width = defwidth;
|
|
293 else
|
|
294 *cursor_width = rb->width;
|
|
295 }
|
|
296
|
|
297 /*****************************************************************************
|
|
298 compare_display_blocks
|
|
299
|
|
300 Given two display blocks, output only those areas where they differ.
|
|
301 ****************************************************************************/
|
|
302 static int
|
|
303 compare_display_blocks (struct window *w, struct display_line *cdl,
|
|
304 struct display_line *ddl, int c_block, int d_block,
|
|
305 int start_pixpos, int cursor_start, int cursor_width,
|
|
306 int cursor_height)
|
|
307 {
|
|
308 struct frame *f = XFRAME (w->frame);
|
|
309 struct device *d = XDEVICE (f->device);
|
|
310
|
|
311 struct display_block *cdb, *ddb;
|
|
312 int start_pos;
|
|
313 int stop_pos;
|
|
314 int force = 0;
|
|
315 int block_end;
|
|
316
|
|
317 cdb = Dynarr_atp (cdl->display_blocks, c_block);
|
|
318 ddb = Dynarr_atp (ddl->display_blocks, d_block);
|
|
319
|
|
320 assert (cdb->type == ddb->type);
|
|
321
|
|
322 start_pos = -1;
|
|
323 stop_pos = min (Dynarr_length (cdb->runes), Dynarr_length (ddb->runes));
|
|
324
|
|
325 block_end =
|
|
326 (!Dynarr_length (ddb->runes)
|
|
327 ? 0
|
|
328 : (Dynarr_atp (ddb->runes, Dynarr_length (ddb->runes) - 1)->xpos +
|
|
329 Dynarr_atp (ddb->runes, Dynarr_length (ddb->runes) - 1)->width));
|
|
330
|
|
331 /* If the new block type is not text and the cursor status is
|
|
332 changing and it overlaps the position of this block then force a
|
|
333 full redraw of the block in order to make sure that the cursor is
|
|
334 updated properly. */
|
|
335 if (ddb->type != TEXT
|
116
|
336 #if 0
|
|
337 /* I'm not sure exactly what this code wants to do, but it's
|
|
338 * not right--it doesn't update when cursor_elt changes from, e.g.,
|
|
339 * 0 to 8, and the new or old cursor loc overlaps this block.
|
|
340 * I've replaced it with the more conservative test below.
|
|
341 * -dkindred@cs.cmu.edu 23-Mar-1997 */
|
0
|
342 && ((cdl->cursor_elt == -1 && ddl->cursor_elt != -1)
|
|
343 || (cdl->cursor_elt != -1 && ddl->cursor_elt == -1))
|
|
344 && (ddl->cursor_elt == -1 ||
|
|
345 (cursor_start
|
|
346 && cursor_width
|
|
347 && (cursor_start + cursor_width) >= start_pixpos
|
116
|
348 && cursor_start <= block_end))
|
|
349 #else
|
|
350 && (cdl->cursor_elt != ddl->cursor_elt)
|
|
351 #endif
|
|
352 )
|
0
|
353 force = 1;
|
|
354
|
|
355 if (f->windows_structure_changed ||
|
|
356 f->faces_changed ||
|
269
|
357 f->glyphs_changed ||
|
0
|
358 cdl->ypos != ddl->ypos ||
|
|
359 cdl->ascent != ddl->ascent ||
|
|
360 cdl->descent != ddl->descent ||
|
|
361 cdl->clip != ddl->clip ||
|
|
362 force)
|
|
363 {
|
|
364 start_pos = 0;
|
|
365 force = 1;
|
|
366 }
|
|
367 else
|
|
368 {
|
|
369 int elt = 0;
|
|
370
|
|
371 while (start_pos < 0 && elt < stop_pos)
|
|
372 {
|
|
373 if (!compare_runes (w, Dynarr_atp (cdb->runes, elt),
|
|
374 Dynarr_atp (ddb->runes, elt)))
|
|
375 {
|
|
376 start_pos = elt;
|
|
377 }
|
|
378 else
|
|
379 {
|
|
380 elt++;
|
|
381 }
|
|
382 }
|
|
383
|
|
384 /* If nothing has changed in the area where the blocks overlap, but
|
|
385 there are new blocks in the desired block, then adjust the start
|
|
386 point accordingly. */
|
|
387 if (elt == stop_pos && stop_pos < Dynarr_length (ddb->runes))
|
|
388 start_pos = stop_pos;
|
|
389 }
|
|
390
|
|
391 if (start_pos >= 0)
|
|
392 {
|
|
393 if ((Dynarr_length (ddb->runes) != Dynarr_length (cdb->runes))
|
|
394 || force)
|
|
395 {
|
|
396 stop_pos = Dynarr_length (ddb->runes);
|
|
397 }
|
|
398 else
|
|
399 {
|
|
400 /* If the lines have the same number of runes and we are not
|
|
401 forcing a full redraw because the display line has
|
|
402 changed position then we try and optimize how much of the
|
|
403 line we actually redraw by scanning backwards from the
|
|
404 end for the first changed rune. This optimization is
|
|
405 almost always triggered by face changes. */
|
|
406
|
|
407 int elt = Dynarr_length (ddb->runes) - 1;
|
|
408
|
|
409 while (elt > start_pos)
|
|
410 {
|
|
411 if (!compare_runes (w, Dynarr_atp (cdb->runes, elt),
|
|
412 Dynarr_atp (ddb->runes, elt)))
|
|
413 break;
|
|
414 else
|
|
415 elt--;
|
|
416 }
|
|
417 stop_pos = elt + 1;
|
|
418 }
|
|
419
|
|
420 DEVMETH (d, output_display_block, (w, ddl, d_block, start_pos,
|
|
421 stop_pos, start_pixpos,
|
|
422 cursor_start, cursor_width,
|
|
423 cursor_height));
|
|
424 return 1;
|
|
425 }
|
|
426
|
|
427 return 0;
|
|
428 }
|
|
429
|
|
430 /*****************************************************************************
|
|
431 clear_left_border
|
|
432
|
|
433 Clear the lefthand outside border.
|
|
434 ****************************************************************************/
|
|
435 static void
|
|
436 clear_left_border (struct window *w, int y, int height)
|
|
437 {
|
|
438 struct frame *f = XFRAME (w->frame);
|
|
439 struct device *d = XDEVICE (f->device);
|
|
440 Lisp_Object window;
|
|
441
|
|
442 XSETWINDOW (window, w);
|
|
443 DEVMETH (d, clear_region, (window, DEFAULT_INDEX,
|
|
444 FRAME_LEFT_BORDER_START (f), y,
|
|
445 FRAME_BORDER_WIDTH (f), height));
|
|
446 }
|
|
447
|
|
448 /*****************************************************************************
|
|
449 clear_right_border
|
|
450
|
|
451 Clear the righthand outside border.
|
|
452 ****************************************************************************/
|
|
453 static void
|
|
454 clear_right_border (struct window *w, int y, int height)
|
|
455 {
|
|
456 struct frame *f = XFRAME (w->frame);
|
|
457 struct device *d = XDEVICE (f->device);
|
|
458 Lisp_Object window;
|
|
459
|
|
460 XSETWINDOW (window, w);
|
|
461 DEVMETH (d, clear_region, (window, DEFAULT_INDEX,
|
|
462 FRAME_RIGHT_BORDER_START (f),
|
|
463 y, FRAME_BORDER_WIDTH (f), height));
|
|
464 }
|
|
465
|
|
466 /*****************************************************************************
|
|
467 output_display_line
|
|
468
|
|
469 Ensure that the contents of the given display line is correct
|
|
470 on-screen. The force_ parameters are used by redisplay_move_cursor
|
|
471 to correctly update cursor locations and only cursor locations.
|
|
472 ****************************************************************************/
|
|
473 void
|
|
474 output_display_line (struct window *w, display_line_dynarr *cdla,
|
|
475 display_line_dynarr *ddla, int line, int force_start,
|
|
476 int force_end)
|
|
477
|
|
478 {
|
|
479 struct frame *f = XFRAME (w->frame);
|
|
480 struct device *d = XDEVICE (f->device);
|
|
481 struct buffer *b = XBUFFER (w->buffer);
|
|
482 struct buffer *old_b = window_display_buffer (w);
|
|
483 struct display_line *cdl, *ddl;
|
|
484 display_block_dynarr *cdba, *ddba;
|
|
485 int start_pixpos, end_pixpos;
|
|
486 int cursor_start, cursor_width, cursor_height;
|
|
487
|
|
488 int force = (force_start >= 0 || force_end >= 0);
|
|
489 int clear_border = 0;
|
|
490 int must_sync = 0;
|
|
491
|
|
492 if (cdla && line < Dynarr_length (cdla))
|
|
493 {
|
|
494 cdl = Dynarr_atp (cdla, line);
|
|
495 cdba = cdl->display_blocks;
|
|
496 }
|
|
497 else
|
|
498 {
|
|
499 cdl = NULL;
|
|
500 cdba = NULL;
|
|
501 }
|
|
502
|
|
503 ddl = Dynarr_atp (ddla, line); /* assert line < Dynarr_length (ddla) */
|
|
504 ddba = ddl->display_blocks;
|
|
505
|
|
506 if (force_start >= 0 && force_start >= ddl->bounds.left_out)
|
|
507 start_pixpos = force_start;
|
|
508 else
|
|
509 start_pixpos = ddl->bounds.left_out;
|
|
510
|
|
511 if (force_end >= 0 && force_end < ddl->bounds.right_out)
|
|
512 end_pixpos = force_end;
|
|
513 else
|
|
514 end_pixpos = ddl->bounds.right_out;
|
|
515
|
|
516 /* Get the cursor parameters. */
|
|
517 if (ddl->cursor_elt != -1)
|
|
518 {
|
|
519 struct display_block *db;
|
|
520
|
|
521 /* If the lines cursor parameter is not -1 then it indicates
|
|
522 which rune in the TEXT block contains the cursor. This means
|
|
523 that there must be at least one display block. The TEXT
|
|
524 block, if present, must always be the first display block. */
|
|
525 assert (Dynarr_length (ddba) != 0);
|
|
526
|
|
527 db = Dynarr_atp (ddba, 0);
|
|
528 assert (db->type == TEXT);
|
|
529
|
|
530 get_cursor_size_and_location (w, db, ddl->cursor_elt, &cursor_start,
|
|
531 &cursor_width, &cursor_height);
|
|
532 }
|
|
533 else
|
|
534 {
|
|
535 cursor_start = cursor_width = cursor_height = 0;
|
|
536 }
|
|
537
|
|
538 /* The modeline should only have a single block and it had better be
|
|
539 a TEXT block. */
|
|
540 if (ddl->modeline)
|
|
541 {
|
|
542 /* The shadow thickness check is necesssary if only the sign of
|
|
543 the size changed. */
|
|
544 if (cdba && !w->shadow_thickness_changed)
|
|
545 {
|
|
546 must_sync |= compare_display_blocks (w, cdl, ddl, 0, 0,
|
|
547 start_pixpos, 0, 0, 0);
|
|
548 }
|
|
549 else
|
|
550 {
|
|
551 DEVMETH (d, output_display_block, (w, ddl, 0, 0, -1, start_pixpos,
|
|
552 0, 0, 0));
|
|
553 must_sync = 1;
|
|
554 }
|
|
555
|
|
556 if (must_sync)
|
|
557 clear_border = 1;
|
|
558 }
|
|
559
|
|
560 while (!ddl->modeline && start_pixpos < end_pixpos)
|
|
561 {
|
|
562 int block;
|
|
563 int next_start_pixpos;
|
|
564
|
|
565 block = get_next_display_block (ddl->bounds, ddba, start_pixpos,
|
|
566 &next_start_pixpos);
|
|
567
|
|
568 /* If we didn't find a block then we should blank the area
|
|
569 between start_pos and next_start if necessary. */
|
|
570 if (block == NO_BLOCK)
|
|
571 {
|
|
572 /* We only erase those areas which were actually previously
|
|
573 covered by a display block unless the window structure
|
|
574 changed. In that case we clear all areas since the current
|
|
575 structures may actually represent a different buffer. */
|
|
576 while (start_pixpos < next_start_pixpos)
|
|
577 {
|
|
578 int block_end;
|
|
579 int old_block;
|
|
580
|
|
581 if (cdba)
|
|
582 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
583 start_pixpos, &block_end);
|
|
584 else
|
|
585 {
|
|
586 old_block = NO_BLOCK;
|
|
587 block_end = next_start_pixpos;
|
|
588 }
|
|
589
|
|
590 if (!cdba || old_block != NO_BLOCK || b != old_b ||
|
|
591 f->windows_structure_changed ||
|
|
592 f->faces_changed ||
|
|
593 force ||
|
|
594 (cdl && (cdl->ypos != ddl->ypos ||
|
|
595 cdl->ascent != ddl->ascent ||
|
|
596 cdl->descent != ddl->descent ||
|
|
597 cdl->clip != ddl->clip)))
|
|
598 {
|
|
599 int x, y, width, height;
|
|
600 Lisp_Object face;
|
|
601
|
|
602 must_sync = 1;
|
|
603 x = start_pixpos;
|
|
604 y = ddl->ypos - ddl->ascent;
|
|
605 width = min (next_start_pixpos, block_end) - x;
|
|
606 height = ddl->ascent + ddl->descent - ddl->clip;
|
|
607
|
|
608 if (x < ddl->bounds.left_in)
|
|
609 face = Vleft_margin_face;
|
|
610 else if (x < ddl->bounds.right_in)
|
|
611 face = Vdefault_face;
|
|
612 else if (x < ddl->bounds.right_out)
|
|
613 face = Vright_margin_face;
|
|
614 else
|
|
615 face = Qnil;
|
|
616
|
|
617 if (!NILP (face))
|
|
618 {
|
|
619 Lisp_Object window;
|
|
620
|
|
621 XSETWINDOW (window, w);
|
|
622
|
|
623 /* Clear the empty area. */
|
|
624 DEVMETH (d, clear_region,
|
|
625 (window, get_builtin_face_cache_index (w,
|
|
626 face),
|
|
627 x, y, width, height));
|
|
628
|
|
629 /* Mark that we should clear the border. This is
|
|
630 necessary because italic fonts may leave
|
|
631 droppings in the border. */
|
|
632 clear_border = 1;
|
|
633 }
|
|
634 }
|
|
635
|
|
636 start_pixpos = min (next_start_pixpos, block_end);
|
|
637 }
|
|
638 }
|
|
639 else
|
|
640 {
|
|
641 struct display_block *cdb, *ddb;
|
|
642 int block_end;
|
|
643 int old_block;
|
|
644
|
|
645 if (cdba)
|
|
646 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
647 start_pixpos, &block_end);
|
|
648 else
|
|
649 old_block = NO_BLOCK;
|
|
650
|
|
651 ddb = Dynarr_atp (ddba, block);
|
|
652 cdb = (old_block != NO_BLOCK ? Dynarr_atp (cdba, old_block) : 0);
|
|
653
|
|
654 /* If there was formerly no block over the current
|
|
655 region or if it was a block of a different type, then
|
|
656 output the entire ddb. Otherwise, compare cdb and
|
|
657 ddb and output only the changed region. */
|
|
658 if (!force && cdb && ddb->type == cdb->type && b == old_b)
|
|
659 {
|
|
660 must_sync |= compare_display_blocks (w, cdl, ddl, old_block,
|
|
661 block, start_pixpos,
|
|
662 cursor_start, cursor_width,
|
|
663 cursor_height);
|
|
664 }
|
|
665 else
|
|
666 {
|
|
667 int elt;
|
|
668 int first_elt = 0;
|
|
669 int last_elt = -1;
|
|
670
|
|
671 for (elt = 0; elt < Dynarr_length (ddb->runes); elt++)
|
|
672 {
|
|
673 struct rune *rb = Dynarr_atp (ddb->runes, elt);
|
|
674
|
|
675 if (start_pixpos >= rb->xpos
|
|
676 && start_pixpos < rb->xpos + rb->width)
|
|
677 first_elt = elt;
|
|
678
|
|
679 if (end_pixpos > rb->xpos
|
|
680 && end_pixpos <= rb->xpos + rb->width)
|
|
681 {
|
|
682 last_elt = elt + 1;
|
|
683 if (last_elt > Dynarr_length (ddb->runes))
|
|
684 last_elt = Dynarr_length (ddb->runes);
|
|
685 break;
|
|
686 }
|
|
687 }
|
|
688
|
|
689 must_sync = 1;
|
|
690 DEVMETH (d, output_display_block, (w, ddl, block, first_elt,
|
|
691 last_elt,
|
|
692 start_pixpos,
|
|
693 cursor_start, cursor_width,
|
|
694 cursor_height));
|
|
695 }
|
|
696
|
|
697 start_pixpos = next_start_pixpos;
|
|
698 }
|
|
699 }
|
|
700
|
|
701 /* Clear the internal border if we are next to it and the window
|
|
702 structure or frame size has changed or if something caused
|
|
703 clear_border to be tripped. */
|
|
704 /* #### Doing this on f->clear sucks but is necessary because of
|
|
705 window-local background values. */
|
|
706 if (f->windows_structure_changed || f->faces_changed || clear_border
|
|
707 || f->clear)
|
|
708 {
|
|
709 int y = ddl->ypos - ddl->ascent;
|
|
710 int height = ddl->ascent + ddl->descent - ddl->clip;
|
|
711
|
|
712 if (ddl->modeline)
|
|
713 {
|
|
714 y -= MODELINE_SHADOW_THICKNESS (w);
|
|
715 height += (2 * MODELINE_SHADOW_THICKNESS (w));
|
|
716 }
|
|
717
|
|
718 if (window_is_leftmost (w))
|
|
719 clear_left_border (w, y, height);
|
|
720 if (window_is_rightmost (w))
|
|
721 clear_right_border (w, y, height);
|
|
722 }
|
|
723
|
|
724 if (cdla)
|
|
725 sync_display_line_structs (w, line, must_sync, cdla, ddla);
|
|
726 }
|
|
727
|
|
728 /*****************************************************************************
|
|
729 redisplay_move_cursor
|
|
730
|
|
731 For the given window W, move the cursor to NEW_POINT. Returns a
|
|
732 boolean indicating success or failure.
|
|
733 ****************************************************************************/
|
|
734
|
|
735 #define ADJ_BUFPOS (rb->bufpos + dl->offset)
|
|
736 #define ADJ_ENDPOS (rb->endpos + dl->offset)
|
|
737
|
|
738 int
|
|
739 redisplay_move_cursor (struct window *w, Bufpos new_point, int no_output_end)
|
|
740 {
|
|
741 struct frame *f = XFRAME (w->frame);
|
|
742 struct device *d = XDEVICE (f->device);
|
|
743
|
|
744 display_line_dynarr *cla = window_display_lines (w, CURRENT_DISP);
|
|
745 struct display_line *dl;
|
|
746 struct display_block *db;
|
|
747 struct rune *rb;
|
|
748 int x = w->last_point_x[CURRENT_DISP];
|
|
749 int y = w->last_point_y[CURRENT_DISP];
|
|
750
|
263
|
751 extern int cursor_in_echo_area;
|
|
752
|
|
753 /*
|
265
|
754 * Bail if cursor_in_echo_area is non-zero and we're fiddling with
|
|
755 * the cursor in a non-active minibuffer window, since that is a
|
|
756 * special case that is handled elsewhere and this function need
|
|
757 * not handle it. Return 1 so the caller will assume we
|
263
|
758 * succeeded.
|
|
759 */
|
265
|
760 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
761 w != XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
263
|
762 return 1;
|
|
763
|
0
|
764 if (y < 0 || y >= Dynarr_length (cla))
|
|
765 return 0;
|
|
766
|
|
767 dl = Dynarr_atp (cla, y);
|
|
768 db = get_display_block_from_line (dl, TEXT);
|
|
769
|
|
770 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
771 return 0;
|
|
772
|
|
773 rb = Dynarr_atp (db->runes, x);
|
|
774
|
|
775 if (rb->cursor_type == CURSOR_OFF)
|
|
776 return 0;
|
|
777 else if (ADJ_BUFPOS == new_point
|
|
778 || (ADJ_ENDPOS && (new_point >= ADJ_BUFPOS)
|
|
779 && (new_point <= ADJ_ENDPOS)))
|
|
780 {
|
|
781 w->last_point_x[CURRENT_DISP] = x;
|
|
782 w->last_point_y[CURRENT_DISP] = y;
|
|
783 Fset_marker (w->last_point[CURRENT_DISP], make_int (ADJ_BUFPOS),
|
|
784 w->buffer);
|
|
785 dl->cursor_elt = x;
|
|
786 return 1;
|
|
787 }
|
|
788 else
|
|
789 {
|
|
790 DEVMETH (d, output_begin, (d));
|
|
791
|
|
792 /* #### This is a gross kludge. Cursor handling is such a royal
|
|
793 pain in the ass. */
|
|
794 if (rb->type == RUNE_DGLYPH &&
|
|
795 (EQ (rb->object.dglyph.glyph, Vtruncation_glyph) ||
|
|
796 EQ (rb->object.dglyph.glyph, Vcontinuation_glyph)))
|
|
797 rb->cursor_type = NO_CURSOR;
|
|
798 else
|
|
799 rb->cursor_type = CURSOR_OFF;
|
|
800 dl->cursor_elt = -1;
|
|
801 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
802 }
|
|
803
|
|
804 w->last_point_x[CURRENT_DISP] = -1;
|
|
805 w->last_point_y[CURRENT_DISP] = -1;
|
|
806 Fset_marker (w->last_point[CURRENT_DISP], Qnil, w->buffer);
|
|
807
|
|
808 /* If this isn't the selected frame, then erasing the old cursor is
|
|
809 all we actually had to do. */
|
|
810 if (w != XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))))
|
|
811 {
|
|
812 if (!no_output_end)
|
|
813 DEVMETH (d, output_end, (d));
|
|
814
|
|
815 return 1;
|
|
816 }
|
|
817
|
|
818 /* This should only occur in the minibuffer. */
|
|
819 if (new_point == 0)
|
|
820 {
|
|
821 w->last_point_x[CURRENT_DISP] = 0;
|
|
822 w->last_point_y[CURRENT_DISP] = y;
|
|
823 Fset_marker (w->last_point[CURRENT_DISP], Qzero, w->buffer);
|
|
824
|
|
825 rb = Dynarr_atp (db->runes, 0);
|
|
826 rb->cursor_type = CURSOR_ON;
|
|
827 dl->cursor_elt = 0;
|
|
828
|
|
829 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
830
|
|
831 if (!no_output_end)
|
|
832 DEVMETH (d, output_end, (d));
|
|
833 return 1;
|
|
834 }
|
|
835 else
|
|
836 {
|
|
837 int cur_rb = 0;
|
|
838 int first = 0;
|
|
839 int cur_dl, up;
|
|
840
|
|
841 if (ADJ_BUFPOS < new_point)
|
|
842 {
|
|
843 up = 1;
|
|
844 cur_rb = x + 1;
|
|
845 cur_dl = y;
|
|
846 }
|
|
847 else /* (rb->bufpos + dl->offset) > new_point */
|
|
848 {
|
|
849 up = 0;
|
|
850
|
|
851 if (!x)
|
|
852 {
|
|
853 cur_dl = y - 1;
|
|
854 first = 0;
|
|
855 }
|
|
856 else
|
|
857 {
|
|
858 cur_rb = x - 1;
|
|
859 cur_dl = y;
|
|
860 first = 1;
|
|
861 }
|
|
862 }
|
|
863
|
|
864 while ((up ? (cur_dl < Dynarr_length (cla)) : (cur_dl >= 0)))
|
|
865 {
|
|
866 dl = Dynarr_atp (cla, cur_dl);
|
|
867 db = get_display_block_from_line (dl, TEXT);
|
|
868
|
|
869 if (!up && !first)
|
|
870 cur_rb = Dynarr_length (db->runes) - 1;
|
|
871
|
|
872 while ((!scroll_on_clipped_lines || !dl->clip) &&
|
|
873 (up ? (cur_rb < Dynarr_length (db->runes)) : (cur_rb >= 0)))
|
|
874 {
|
|
875 rb = Dynarr_atp (db->runes, cur_rb);
|
|
876
|
|
877 if (rb->cursor_type != IGNORE_CURSOR
|
|
878 && rb->cursor_type != NO_CURSOR &&
|
|
879 (ADJ_BUFPOS == new_point
|
|
880 || (ADJ_ENDPOS && (new_point >= ADJ_BUFPOS)
|
|
881 && (new_point <= ADJ_BUFPOS))))
|
|
882 {
|
|
883 rb->cursor_type = CURSOR_ON;
|
|
884 dl->cursor_elt = cur_rb;
|
185
|
885
|
0
|
886
|
|
887 output_display_line (w, 0, cla, cur_dl, rb->xpos,
|
|
888 rb->xpos + rb->width);
|
|
889
|
|
890 w->last_point_x[CURRENT_DISP] = cur_rb;
|
|
891 w->last_point_y[CURRENT_DISP] = cur_dl;
|
|
892 Fset_marker (w->last_point[CURRENT_DISP],
|
|
893 make_int (ADJ_BUFPOS), w->buffer);
|
|
894
|
|
895 if (!no_output_end)
|
|
896 DEVMETH (d, output_end, (d));
|
|
897 return 1;
|
|
898 }
|
|
899
|
|
900 (up ? cur_rb++ : cur_rb--);
|
|
901 }
|
|
902
|
|
903 (up ? (cur_rb = 0) : (first = 0));
|
|
904 (up ? cur_dl++ : cur_dl--);
|
|
905 }
|
|
906 }
|
|
907
|
|
908 if (!no_output_end)
|
|
909 DEVMETH (d, output_end, (d));
|
|
910 return 0;
|
|
911 }
|
|
912 #undef ADJ_BUFPOS
|
|
913 #undef ADJ_ENDPOS
|
|
914
|
|
915 /*****************************************************************************
|
|
916 redraw_cursor_in_window
|
|
917
|
|
918 For the given window W, redraw the cursor if it is contained within
|
|
919 the window.
|
|
920 ****************************************************************************/
|
|
921 static void
|
|
922 redraw_cursor_in_window (struct window *w, int run_end_begin_meths)
|
|
923 {
|
|
924 struct frame *f = XFRAME (w->frame);
|
|
925 struct device *d = XDEVICE (f->device);
|
|
926
|
|
927 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
928 struct display_line *dl;
|
|
929 struct display_block *db;
|
|
930 struct rune *rb;
|
265
|
931 extern int cursor_in_echo_area;
|
0
|
932
|
|
933 int x = w->last_point_x[CURRENT_DISP];
|
|
934 int y = w->last_point_y[CURRENT_DISP];
|
|
935
|
265
|
936 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
937 !echo_area_active (f) && minibuf_level == 0)
|
|
938 {
|
|
939 MAYBE_DEVMETH (d, set_final_cursor_coords, (f, w->pixel_top, 0));
|
|
940 }
|
|
941
|
0
|
942 if (y < 0 || y >= Dynarr_length (dla))
|
|
943 return;
|
|
944
|
|
945 if (MINI_WINDOW_P (w) && f != device_selected_frame (d) &&
|
|
946 !is_surrogate_for_selected_frame (f))
|
|
947 return;
|
|
948
|
|
949 dl = Dynarr_atp (dla, y);
|
|
950 db = get_display_block_from_line (dl, TEXT);
|
|
951
|
|
952 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
953 return;
|
|
954
|
|
955 rb = Dynarr_atp (db->runes, x);
|
|
956
|
|
957 /* Don't call the output routine if the block isn't actually the
|
|
958 cursor. */
|
|
959 if (rb->cursor_type == CURSOR_ON)
|
|
960 {
|
265
|
961 MAYBE_DEVMETH (d, set_final_cursor_coords,
|
|
962 (f, dl->ypos - 1, rb->xpos));
|
|
963
|
0
|
964 if (run_end_begin_meths)
|
|
965 DEVMETH (d, output_begin, (d));
|
|
966
|
|
967 output_display_line (w, 0, dla, y, rb->xpos, rb->xpos + rb->width);
|
|
968
|
|
969 if (run_end_begin_meths)
|
|
970 DEVMETH (d, output_end, (d));
|
|
971 }
|
|
972 }
|
|
973
|
|
974 /*****************************************************************************
|
|
975 redisplay_redraw_cursor
|
|
976
|
|
977 For the given frame F, redraw the cursor on the selected window.
|
|
978 This is used to update the cursor after focus changes.
|
|
979 ****************************************************************************/
|
|
980 void
|
|
981 redisplay_redraw_cursor (struct frame *f, int run_end_begin_meths)
|
|
982 {
|
|
983 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
|
263
|
984 extern int cursor_in_echo_area;
|
|
985
|
|
986 if (cursor_in_echo_area)
|
267
|
987 {
|
263
|
988 if (FRAME_HAS_MINIBUF_P (f))
|
|
989 {
|
|
990 w = XWINDOW (FRAME_MINIBUF_WINDOW (f));
|
|
991 }
|
|
992 else
|
267
|
993 {
|
263
|
994 return;
|
267
|
995 }
|
|
996 }
|
0
|
997 redraw_cursor_in_window (w, run_end_begin_meths);
|
|
998 }
|
|
999
|
|
1000 /*****************************************************************************
|
|
1001 redisplay_clear_top_of_window
|
|
1002
|
|
1003 If window is topmost, clear the internal border above it.
|
|
1004 ****************************************************************************/
|
|
1005 static void
|
|
1006 redisplay_clear_top_of_window (struct window *w)
|
|
1007 {
|
|
1008 Lisp_Object window;
|
|
1009 XSETWINDOW (window, w);
|
|
1010
|
|
1011 if (!NILP (Fwindow_highest_p (window)))
|
|
1012 {
|
|
1013 struct frame *f = XFRAME (w->frame);
|
|
1014 struct device *d = XDEVICE (f->device);
|
|
1015 int x, y, width, height;
|
|
1016
|
|
1017 x = w->pixel_left;
|
|
1018 width = w->pixel_width;
|
|
1019
|
|
1020 if (window_is_leftmost (w))
|
|
1021 {
|
|
1022 x -= FRAME_BORDER_WIDTH (f);
|
|
1023 width += FRAME_BORDER_WIDTH (f);
|
|
1024 }
|
|
1025 if (window_is_rightmost (w))
|
|
1026 width += FRAME_BORDER_WIDTH (f);
|
185
|
1027
|
0
|
1028 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
1029 height = FRAME_BORDER_HEIGHT (f) + 1;
|
|
1030
|
|
1031 DEVMETH (d, clear_region, (window, DEFAULT_INDEX, x, y, width, height));
|
|
1032 }
|
|
1033 }
|
|
1034
|
|
1035 /*****************************************************************************
|
|
1036 redisplay_clear_bottom_of_window
|
|
1037
|
|
1038 Clear window from right below the last display line to right above
|
|
1039 the modeline. The calling function can limit the area actually
|
|
1040 erased by setting min_start and/or max_end to positive values.
|
|
1041 ****************************************************************************/
|
|
1042 void
|
|
1043 redisplay_clear_bottom_of_window (struct window *w, display_line_dynarr *ddla,
|
|
1044 int min_start, int max_end)
|
|
1045 {
|
|
1046 struct frame *f = XFRAME (w->frame);
|
|
1047 struct device *d = XDEVICE (f->device);
|
|
1048 int ypos1, ypos2;
|
|
1049 int ddla_len = Dynarr_length (ddla);
|
|
1050
|
|
1051 ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
1052 #ifdef HAVE_SCROLLBARS
|
|
1053 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
1054 if (f->windows_structure_changed && !f->scrollbar_on_top)
|
|
1055 ypos2 += window_scrollbar_height (w);
|
|
1056 #endif
|
|
1057
|
|
1058 if (ddla_len)
|
|
1059 {
|
|
1060 if (ddla_len == 1 && Dynarr_atp (ddla, 0)->modeline)
|
|
1061 {
|
|
1062 ypos1 = WINDOW_TEXT_TOP (w);
|
|
1063 #ifdef HAVE_SCROLLBARS
|
|
1064 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
1065 if (f->windows_structure_changed && f->scrollbar_on_top)
|
|
1066 ypos1 -= window_scrollbar_height (w);
|
|
1067 #endif
|
|
1068 }
|
|
1069 else
|
|
1070 {
|
|
1071 struct display_line *dl = Dynarr_atp (ddla, ddla_len - 1);
|
|
1072 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
1073 }
|
|
1074 }
|
|
1075 else
|
|
1076 ypos1 = WINDOW_TEXT_TOP (w);
|
|
1077
|
|
1078 /* #### See if this can be made conditional on the frame
|
|
1079 changing size. */
|
|
1080 if (MINI_WINDOW_P (w))
|
|
1081 ypos2 += FRAME_BORDER_HEIGHT (f);
|
|
1082
|
|
1083 if (min_start >= 0 && ypos1 < min_start)
|
|
1084 ypos1 = min_start;
|
|
1085 if (max_end >= 0 && ypos2 > max_end)
|
|
1086 ypos2 = max_end;
|
|
1087
|
|
1088 if (ypos2 <= ypos1)
|
|
1089 return;
|
|
1090
|
|
1091 DEVMETH (d, clear_to_window_end, (w, ypos1, ypos2));
|
|
1092 }
|
|
1093
|
|
1094 /*****************************************************************************
|
|
1095 redisplay_update_line
|
|
1096
|
|
1097 This is used during incremental updates to update a single line and
|
|
1098 correct the offsets on all lines below it. At the moment
|
|
1099 update_values is false if we are only updating the modeline.
|
|
1100 ****************************************************************************/
|
|
1101 void
|
|
1102 redisplay_update_line (struct window *w, int first_line, int last_line,
|
|
1103 int update_values)
|
|
1104 {
|
|
1105 struct frame *f = XFRAME (w->frame);
|
|
1106 struct device *d = XDEVICE (f->device);
|
|
1107
|
|
1108 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
1109 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
1110
|
|
1111 DEVMETH (d, output_begin, (d));
|
|
1112
|
|
1113 while (first_line <= last_line)
|
|
1114 {
|
|
1115 Charcount old_len = (Dynarr_atp (cdla, first_line)->end_bufpos -
|
|
1116 Dynarr_atp (cdla, first_line)->bufpos);
|
|
1117 Charcount new_len = (Dynarr_atp (ddla, first_line)->end_bufpos -
|
|
1118 Dynarr_atp (ddla, first_line)->bufpos);
|
|
1119
|
|
1120 assert (Dynarr_length (cdla) == Dynarr_length (ddla));
|
|
1121
|
|
1122 /* Output the changes. */
|
|
1123 output_display_line (w, cdla, ddla, first_line, -1, -1);
|
|
1124
|
|
1125 /* Update the offsets. */
|
|
1126 if (update_values)
|
|
1127 {
|
|
1128 int cur_line = first_line + 1;
|
|
1129 while (cur_line < Dynarr_length (cdla))
|
|
1130 {
|
|
1131 Dynarr_atp (cdla, cur_line)->offset += (new_len - old_len);
|
|
1132 Dynarr_atp (ddla, cur_line)->offset += (new_len - old_len);
|
|
1133 cur_line++;
|
|
1134 }
|
|
1135 }
|
|
1136
|
|
1137 /* Update the window_end_pos and other settings. */
|
|
1138 if (update_values)
|
|
1139 {
|
|
1140 w->window_end_pos[CURRENT_DISP] -= (new_len - old_len);
|
|
1141
|
|
1142 if (Dynarr_atp (ddla, first_line)->cursor_elt != -1)
|
|
1143 {
|
|
1144 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
1145 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
1146 }
|
|
1147 }
|
|
1148
|
|
1149 first_line++;
|
|
1150 }
|
|
1151
|
|
1152 /* Update the window max line length. We have to scan the entire
|
|
1153 set of display lines otherwise we might not detect if the max is
|
|
1154 supposed to shrink. */
|
|
1155 if (update_values)
|
|
1156 {
|
|
1157 int line = 0;
|
|
1158
|
|
1159 w->max_line_len = 0;
|
|
1160 while (line < Dynarr_length (ddla))
|
|
1161 {
|
|
1162 struct display_line *dl = Dynarr_atp (ddla, line);
|
|
1163
|
|
1164 if (!dl->modeline)
|
|
1165 w->max_line_len = max (dl->num_chars, w->max_line_len);
|
|
1166
|
|
1167 line++;
|
|
1168 }
|
|
1169 }
|
|
1170
|
|
1171 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
1172 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
1173 Fset_marker (w->last_point[CURRENT_DISP],
|
|
1174 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
1175 Fset_marker (w->last_start[CURRENT_DISP],
|
|
1176 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
1177
|
|
1178 /* We don't bother updating the vertical scrollbars here. This
|
|
1179 gives us a performance increase while having minimal loss of
|
|
1180 quality to the scrollbar slider size and position since when this
|
|
1181 function is called we know that the changes to the buffer were
|
|
1182 very localized. We have to update the horizontal scrollbars,
|
|
1183 though, because this routine could cause a change which has a
|
|
1184 larger impact on their sizing. */
|
|
1185 /* #### See if we can get away with only calling this if
|
|
1186 max_line_len is greater than the window_char_width. */
|
209
|
1187 #if defined(HAVE_SCROLLBARS) && defined(HAVE_X_WINDOWS)
|
82
|
1188 {
|
|
1189 extern int stupid_vertical_scrollbar_drag_hack;
|
|
1190
|
|
1191 update_window_scrollbars (w, NULL, 1, stupid_vertical_scrollbar_drag_hack);
|
|
1192 stupid_vertical_scrollbar_drag_hack = 1;
|
|
1193 }
|
0
|
1194 #endif
|
|
1195
|
|
1196 /* This has to be done after we've updated the values. We don't
|
|
1197 call output_end for tty frames. Redisplay will do this after all
|
|
1198 tty windows have been updated. This cuts down on cursor
|
|
1199 flicker. */
|
|
1200 if (FRAME_TTY_P (f))
|
|
1201 redisplay_redraw_cursor (f, 0);
|
|
1202 else
|
|
1203 DEVMETH (d, output_end, (d));
|
|
1204 }
|
|
1205
|
|
1206 /*****************************************************************************
|
|
1207 redisplay_output_window
|
|
1208
|
|
1209 For the given window W, ensure that the current display lines are
|
|
1210 equal to the desired display lines, outputing changes as necessary.
|
|
1211
|
|
1212 #### Fuck me. This just isn't going to cut it for tty's. The output
|
|
1213 decisions for them must be based on the contents of the entire frame
|
|
1214 because that is how the available output capabilities think. The
|
|
1215 solution is relatively simple. Create redisplay_output_frame. This
|
|
1216 will basically merge all of the separate window display structs into
|
|
1217 a single one for the frame. This combination structure will be able
|
|
1218 to be passed to the same output_display_line which works for windows
|
|
1219 on X frames and the right things will happen. It just takes time to
|
|
1220 do.
|
|
1221 ****************************************************************************/
|
|
1222 void
|
|
1223 redisplay_output_window (struct window *w)
|
|
1224 {
|
|
1225 struct frame *f = XFRAME (w->frame);
|
|
1226 struct device *d = XDEVICE (f->device);
|
|
1227
|
|
1228 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
1229 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
1230
|
|
1231 int cdla_len = Dynarr_length (cdla);
|
|
1232 int ddla_len = Dynarr_length (ddla);
|
|
1233
|
|
1234 int line;
|
|
1235 int need_to_clear_bottom = 0;
|
|
1236 int need_to_clear_start = -1;
|
|
1237 int need_to_clear_end = -1;
|
|
1238
|
|
1239 /* Backgrounds may have changed or windows may have gone away
|
|
1240 leaving dividers lying around. */
|
|
1241 if (f->faces_changed
|
|
1242 || f->windows_structure_changed
|
|
1243 || w->shadow_thickness_changed)
|
|
1244 need_to_clear_bottom = 1;
|
|
1245
|
|
1246 /* The first thing we do is determine if we are going to need to
|
|
1247 clear the bottom of the window. We only need to do this if the
|
|
1248 bottom of the current display lines is below the bottom of the
|
|
1249 desired display lines. Note that the number of lines is
|
|
1250 irrelevant. Only the position matters. We also clear to the
|
|
1251 bottom of the window if the modeline has shifted position. */
|
|
1252 /* #### We can't blindly not clear the bottom if f->clear is true
|
|
1253 since there might be a window-local background. However, for
|
|
1254 those cases where there isn't, clearing the end of the window in
|
|
1255 this case sucks. */
|
|
1256 if (!need_to_clear_bottom)
|
|
1257 {
|
|
1258 struct display_line *cdl, *ddl;
|
|
1259
|
|
1260 /* If the modeline has changed position or size, clear the bottom
|
|
1261 of the window. */
|
|
1262 if (!need_to_clear_bottom)
|
|
1263 {
|
|
1264 cdl = ddl = 0;
|
|
1265
|
|
1266 if (cdla_len)
|
|
1267 cdl = Dynarr_atp (cdla, 0);
|
|
1268 if (ddla_len)
|
|
1269 ddl = Dynarr_atp (ddla, 0);
|
|
1270
|
|
1271 if (!cdl || !ddl)
|
|
1272 need_to_clear_bottom = 1;
|
|
1273 else if ((!cdl->modeline && ddl->modeline)
|
|
1274 || (cdl->modeline && !ddl->modeline))
|
|
1275 need_to_clear_bottom = 1;
|
|
1276 else if (cdl->ypos != ddl->ypos ||
|
|
1277 cdl->ascent != ddl->ascent ||
|
|
1278 cdl->descent != ddl->descent ||
|
|
1279 cdl->clip != ddl->clip)
|
|
1280 need_to_clear_bottom = 1;
|
|
1281
|
|
1282 /* #### This kludge is to make sure the modeline shadows get
|
|
1283 redrawn if the modeline position shifts. */
|
|
1284 if (need_to_clear_bottom)
|
|
1285 w->shadow_thickness_changed = 1;
|
|
1286 }
|
|
1287
|
|
1288 if (!need_to_clear_bottom)
|
|
1289 {
|
|
1290 cdl = ddl = 0;
|
|
1291
|
|
1292 if (cdla_len)
|
|
1293 cdl = Dynarr_atp (cdla, cdla_len - 1);
|
|
1294 if (ddla_len)
|
|
1295 ddl = Dynarr_atp (ddla, ddla_len - 1);
|
|
1296
|
|
1297 if (!cdl || !ddl)
|
|
1298 need_to_clear_bottom = 1;
|
|
1299 else
|
|
1300 {
|
|
1301 int cdl_bottom, ddl_bottom;
|
|
1302
|
|
1303 cdl_bottom = cdl->ypos + cdl->descent;
|
|
1304 ddl_bottom = ddl->ypos + ddl->descent;
|
|
1305
|
|
1306 if (cdl_bottom > ddl_bottom)
|
|
1307 {
|
|
1308 need_to_clear_bottom = 1;
|
|
1309 need_to_clear_start = ddl_bottom;
|
|
1310 need_to_clear_end = cdl_bottom;
|
|
1311 }
|
|
1312 }
|
|
1313 }
|
|
1314 }
|
|
1315
|
|
1316 /* Perform any output initialization. */
|
|
1317 DEVMETH (d, output_begin, (d));
|
|
1318
|
|
1319 /* If the window's structure has changed clear the internal border
|
|
1320 above it if it is topmost (the function will check). */
|
|
1321 if (f->windows_structure_changed)
|
|
1322 redisplay_clear_top_of_window (w);
|
|
1323
|
|
1324 /* Output each line. */
|
|
1325 for (line = 0; line < Dynarr_length (ddla); line++)
|
|
1326 {
|
|
1327 output_display_line (w, cdla, ddla, line, -1, -1);
|
|
1328 }
|
|
1329
|
|
1330 /* If the number of display lines has shrunk, adjust. */
|
|
1331 if (cdla_len > ddla_len)
|
|
1332 {
|
|
1333 Dynarr_length (cdla) = ddla_len;
|
|
1334 }
|
|
1335
|
|
1336 /* Output a vertical divider between windows, if necessary. */
|
|
1337 if (window_needs_vertical_divider (w)
|
|
1338 && (f->windows_structure_changed || f->clear))
|
|
1339 {
|
|
1340 DEVMETH (d, output_vertical_divider, (w, f->windows_structure_changed));
|
|
1341 }
|
|
1342
|
|
1343 /* Clear the rest of the window, if necessary. */
|
|
1344 if (need_to_clear_bottom)
|
|
1345 {
|
|
1346 redisplay_clear_bottom_of_window (w, ddla, need_to_clear_start,
|
|
1347 need_to_clear_end);
|
|
1348 }
|
|
1349
|
|
1350 w->window_end_pos[CURRENT_DISP] = w->window_end_pos[DESIRED_DISP];
|
|
1351 Fset_marker (w->start[CURRENT_DISP],
|
|
1352 make_int (marker_position (w->start[DESIRED_DISP])),
|
|
1353 w->buffer);
|
|
1354 Fset_marker (w->pointm[CURRENT_DISP],
|
|
1355 make_int (marker_position (w->pointm[DESIRED_DISP])),
|
|
1356 w->buffer);
|
|
1357 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
1358 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
1359 Fset_marker (w->last_start[CURRENT_DISP],
|
|
1360 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
1361 Fset_marker (w->last_point[CURRENT_DISP],
|
|
1362 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
1363 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
1364 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
1365 w->shadow_thickness_changed = 0;
|
|
1366
|
|
1367 set_window_display_buffer (w, XBUFFER (w->buffer));
|
|
1368 find_window_mirror (w)->truncate_win = window_truncation_on (w);
|
|
1369
|
|
1370 /* Overkill on invalidating the cache. It is very bad for it to not
|
|
1371 get invalidated when it should be. */
|
|
1372 INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE (d);
|
|
1373
|
|
1374 /* We don't call output_end for tty frames. Redisplay will do this
|
|
1375 after all tty windows have been updated. This cuts down on
|
|
1376 cursor flicker. */
|
|
1377 if (FRAME_TTY_P (f))
|
|
1378 redisplay_redraw_cursor (f, 0);
|
|
1379 else
|
|
1380 DEVMETH (d, output_end, (d));
|
|
1381
|
|
1382 #ifdef HAVE_SCROLLBARS
|
|
1383 update_window_scrollbars (w, NULL, !MINI_WINDOW_P (w), 0);
|
|
1384 #endif
|
|
1385 }
|