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 ||
|
|
357 cdl->ypos != ddl->ypos ||
|
|
358 cdl->ascent != ddl->ascent ||
|
|
359 cdl->descent != ddl->descent ||
|
|
360 cdl->clip != ddl->clip ||
|
|
361 force)
|
|
362 {
|
|
363 start_pos = 0;
|
|
364 force = 1;
|
|
365 }
|
|
366 else
|
|
367 {
|
|
368 int elt = 0;
|
|
369
|
|
370 while (start_pos < 0 && elt < stop_pos)
|
|
371 {
|
|
372 if (!compare_runes (w, Dynarr_atp (cdb->runes, elt),
|
|
373 Dynarr_atp (ddb->runes, elt)))
|
|
374 {
|
|
375 start_pos = elt;
|
|
376 }
|
|
377 else
|
|
378 {
|
|
379 elt++;
|
|
380 }
|
|
381 }
|
|
382
|
|
383 /* If nothing has changed in the area where the blocks overlap, but
|
|
384 there are new blocks in the desired block, then adjust the start
|
|
385 point accordingly. */
|
|
386 if (elt == stop_pos && stop_pos < Dynarr_length (ddb->runes))
|
|
387 start_pos = stop_pos;
|
|
388 }
|
|
389
|
|
390 if (start_pos >= 0)
|
|
391 {
|
|
392 if ((Dynarr_length (ddb->runes) != Dynarr_length (cdb->runes))
|
|
393 || force)
|
|
394 {
|
|
395 stop_pos = Dynarr_length (ddb->runes);
|
|
396 }
|
|
397 else
|
|
398 {
|
|
399 /* If the lines have the same number of runes and we are not
|
|
400 forcing a full redraw because the display line has
|
|
401 changed position then we try and optimize how much of the
|
|
402 line we actually redraw by scanning backwards from the
|
|
403 end for the first changed rune. This optimization is
|
|
404 almost always triggered by face changes. */
|
|
405
|
|
406 int elt = Dynarr_length (ddb->runes) - 1;
|
|
407
|
|
408 while (elt > start_pos)
|
|
409 {
|
|
410 if (!compare_runes (w, Dynarr_atp (cdb->runes, elt),
|
|
411 Dynarr_atp (ddb->runes, elt)))
|
|
412 break;
|
|
413 else
|
|
414 elt--;
|
|
415 }
|
|
416 stop_pos = elt + 1;
|
|
417 }
|
|
418
|
|
419 DEVMETH (d, output_display_block, (w, ddl, d_block, start_pos,
|
|
420 stop_pos, start_pixpos,
|
|
421 cursor_start, cursor_width,
|
|
422 cursor_height));
|
|
423 return 1;
|
|
424 }
|
|
425
|
|
426 return 0;
|
|
427 }
|
|
428
|
|
429 /*****************************************************************************
|
|
430 clear_left_border
|
|
431
|
|
432 Clear the lefthand outside border.
|
|
433 ****************************************************************************/
|
|
434 static void
|
|
435 clear_left_border (struct window *w, int y, int height)
|
|
436 {
|
|
437 struct frame *f = XFRAME (w->frame);
|
|
438 struct device *d = XDEVICE (f->device);
|
|
439 Lisp_Object window;
|
|
440
|
|
441 XSETWINDOW (window, w);
|
|
442 DEVMETH (d, clear_region, (window, DEFAULT_INDEX,
|
|
443 FRAME_LEFT_BORDER_START (f), y,
|
|
444 FRAME_BORDER_WIDTH (f), height));
|
|
445 }
|
|
446
|
|
447 /*****************************************************************************
|
|
448 clear_right_border
|
|
449
|
|
450 Clear the righthand outside border.
|
|
451 ****************************************************************************/
|
|
452 static void
|
|
453 clear_right_border (struct window *w, int y, int height)
|
|
454 {
|
|
455 struct frame *f = XFRAME (w->frame);
|
|
456 struct device *d = XDEVICE (f->device);
|
|
457 Lisp_Object window;
|
|
458
|
|
459 XSETWINDOW (window, w);
|
|
460 DEVMETH (d, clear_region, (window, DEFAULT_INDEX,
|
|
461 FRAME_RIGHT_BORDER_START (f),
|
|
462 y, FRAME_BORDER_WIDTH (f), height));
|
|
463 }
|
|
464
|
|
465 /*****************************************************************************
|
|
466 output_display_line
|
|
467
|
|
468 Ensure that the contents of the given display line is correct
|
|
469 on-screen. The force_ parameters are used by redisplay_move_cursor
|
|
470 to correctly update cursor locations and only cursor locations.
|
|
471 ****************************************************************************/
|
|
472 void
|
|
473 output_display_line (struct window *w, display_line_dynarr *cdla,
|
|
474 display_line_dynarr *ddla, int line, int force_start,
|
|
475 int force_end)
|
|
476
|
|
477 {
|
|
478 struct frame *f = XFRAME (w->frame);
|
|
479 struct device *d = XDEVICE (f->device);
|
|
480 struct buffer *b = XBUFFER (w->buffer);
|
|
481 struct buffer *old_b = window_display_buffer (w);
|
|
482 struct display_line *cdl, *ddl;
|
|
483 display_block_dynarr *cdba, *ddba;
|
|
484 int start_pixpos, end_pixpos;
|
|
485 int cursor_start, cursor_width, cursor_height;
|
|
486
|
|
487 int force = (force_start >= 0 || force_end >= 0);
|
|
488 int clear_border = 0;
|
|
489 int must_sync = 0;
|
|
490
|
|
491 if (cdla && line < Dynarr_length (cdla))
|
|
492 {
|
|
493 cdl = Dynarr_atp (cdla, line);
|
|
494 cdba = cdl->display_blocks;
|
|
495 }
|
|
496 else
|
|
497 {
|
|
498 cdl = NULL;
|
|
499 cdba = NULL;
|
|
500 }
|
|
501
|
|
502 ddl = Dynarr_atp (ddla, line); /* assert line < Dynarr_length (ddla) */
|
|
503 ddba = ddl->display_blocks;
|
|
504
|
|
505 if (force_start >= 0 && force_start >= ddl->bounds.left_out)
|
|
506 start_pixpos = force_start;
|
|
507 else
|
|
508 start_pixpos = ddl->bounds.left_out;
|
|
509
|
|
510 if (force_end >= 0 && force_end < ddl->bounds.right_out)
|
|
511 end_pixpos = force_end;
|
|
512 else
|
|
513 end_pixpos = ddl->bounds.right_out;
|
|
514
|
|
515 /* Get the cursor parameters. */
|
|
516 if (ddl->cursor_elt != -1)
|
|
517 {
|
|
518 struct display_block *db;
|
|
519
|
|
520 /* If the lines cursor parameter is not -1 then it indicates
|
|
521 which rune in the TEXT block contains the cursor. This means
|
|
522 that there must be at least one display block. The TEXT
|
|
523 block, if present, must always be the first display block. */
|
|
524 assert (Dynarr_length (ddba) != 0);
|
|
525
|
|
526 db = Dynarr_atp (ddba, 0);
|
|
527 assert (db->type == TEXT);
|
|
528
|
|
529 get_cursor_size_and_location (w, db, ddl->cursor_elt, &cursor_start,
|
|
530 &cursor_width, &cursor_height);
|
|
531 }
|
|
532 else
|
|
533 {
|
|
534 cursor_start = cursor_width = cursor_height = 0;
|
|
535 }
|
|
536
|
|
537 /* The modeline should only have a single block and it had better be
|
|
538 a TEXT block. */
|
|
539 if (ddl->modeline)
|
|
540 {
|
|
541 /* The shadow thickness check is necesssary if only the sign of
|
|
542 the size changed. */
|
|
543 if (cdba && !w->shadow_thickness_changed)
|
|
544 {
|
|
545 must_sync |= compare_display_blocks (w, cdl, ddl, 0, 0,
|
|
546 start_pixpos, 0, 0, 0);
|
|
547 }
|
|
548 else
|
|
549 {
|
|
550 DEVMETH (d, output_display_block, (w, ddl, 0, 0, -1, start_pixpos,
|
|
551 0, 0, 0));
|
|
552 must_sync = 1;
|
|
553 }
|
|
554
|
|
555 if (must_sync)
|
|
556 clear_border = 1;
|
|
557 }
|
|
558
|
|
559 while (!ddl->modeline && start_pixpos < end_pixpos)
|
|
560 {
|
|
561 int block;
|
|
562 int next_start_pixpos;
|
|
563
|
|
564 block = get_next_display_block (ddl->bounds, ddba, start_pixpos,
|
|
565 &next_start_pixpos);
|
|
566
|
|
567 /* If we didn't find a block then we should blank the area
|
|
568 between start_pos and next_start if necessary. */
|
|
569 if (block == NO_BLOCK)
|
|
570 {
|
|
571 /* We only erase those areas which were actually previously
|
|
572 covered by a display block unless the window structure
|
|
573 changed. In that case we clear all areas since the current
|
|
574 structures may actually represent a different buffer. */
|
|
575 while (start_pixpos < next_start_pixpos)
|
|
576 {
|
|
577 int block_end;
|
|
578 int old_block;
|
|
579
|
|
580 if (cdba)
|
|
581 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
582 start_pixpos, &block_end);
|
|
583 else
|
|
584 {
|
|
585 old_block = NO_BLOCK;
|
|
586 block_end = next_start_pixpos;
|
|
587 }
|
|
588
|
|
589 if (!cdba || old_block != NO_BLOCK || b != old_b ||
|
|
590 f->windows_structure_changed ||
|
|
591 f->faces_changed ||
|
|
592 force ||
|
|
593 (cdl && (cdl->ypos != ddl->ypos ||
|
|
594 cdl->ascent != ddl->ascent ||
|
|
595 cdl->descent != ddl->descent ||
|
|
596 cdl->clip != ddl->clip)))
|
|
597 {
|
|
598 int x, y, width, height;
|
|
599 Lisp_Object face;
|
|
600
|
|
601 must_sync = 1;
|
|
602 x = start_pixpos;
|
|
603 y = ddl->ypos - ddl->ascent;
|
|
604 width = min (next_start_pixpos, block_end) - x;
|
|
605 height = ddl->ascent + ddl->descent - ddl->clip;
|
|
606
|
|
607 if (x < ddl->bounds.left_in)
|
|
608 face = Vleft_margin_face;
|
|
609 else if (x < ddl->bounds.right_in)
|
|
610 face = Vdefault_face;
|
|
611 else if (x < ddl->bounds.right_out)
|
|
612 face = Vright_margin_face;
|
|
613 else
|
|
614 face = Qnil;
|
|
615
|
|
616 if (!NILP (face))
|
|
617 {
|
|
618 Lisp_Object window;
|
|
619
|
|
620 XSETWINDOW (window, w);
|
|
621
|
|
622 /* Clear the empty area. */
|
|
623 DEVMETH (d, clear_region,
|
|
624 (window, get_builtin_face_cache_index (w,
|
|
625 face),
|
|
626 x, y, width, height));
|
|
627
|
|
628 /* Mark that we should clear the border. This is
|
|
629 necessary because italic fonts may leave
|
|
630 droppings in the border. */
|
|
631 clear_border = 1;
|
|
632 }
|
|
633 }
|
|
634
|
|
635 start_pixpos = min (next_start_pixpos, block_end);
|
|
636 }
|
|
637 }
|
|
638 else
|
|
639 {
|
|
640 struct display_block *cdb, *ddb;
|
|
641 int block_end;
|
|
642 int old_block;
|
|
643
|
|
644 if (cdba)
|
|
645 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
646 start_pixpos, &block_end);
|
|
647 else
|
|
648 old_block = NO_BLOCK;
|
|
649
|
|
650 ddb = Dynarr_atp (ddba, block);
|
|
651 cdb = (old_block != NO_BLOCK ? Dynarr_atp (cdba, old_block) : 0);
|
|
652
|
|
653 /* If there was formerly no block over the current
|
|
654 region or if it was a block of a different type, then
|
|
655 output the entire ddb. Otherwise, compare cdb and
|
|
656 ddb and output only the changed region. */
|
|
657 if (!force && cdb && ddb->type == cdb->type && b == old_b)
|
|
658 {
|
|
659 must_sync |= compare_display_blocks (w, cdl, ddl, old_block,
|
|
660 block, start_pixpos,
|
|
661 cursor_start, cursor_width,
|
|
662 cursor_height);
|
|
663 }
|
|
664 else
|
|
665 {
|
|
666 int elt;
|
|
667 int first_elt = 0;
|
|
668 int last_elt = -1;
|
|
669
|
|
670 for (elt = 0; elt < Dynarr_length (ddb->runes); elt++)
|
|
671 {
|
|
672 struct rune *rb = Dynarr_atp (ddb->runes, elt);
|
|
673
|
|
674 if (start_pixpos >= rb->xpos
|
|
675 && start_pixpos < rb->xpos + rb->width)
|
|
676 first_elt = elt;
|
|
677
|
|
678 if (end_pixpos > rb->xpos
|
|
679 && end_pixpos <= rb->xpos + rb->width)
|
|
680 {
|
|
681 last_elt = elt + 1;
|
|
682 if (last_elt > Dynarr_length (ddb->runes))
|
|
683 last_elt = Dynarr_length (ddb->runes);
|
|
684 break;
|
|
685 }
|
|
686 }
|
|
687
|
|
688 must_sync = 1;
|
|
689 DEVMETH (d, output_display_block, (w, ddl, block, first_elt,
|
|
690 last_elt,
|
|
691 start_pixpos,
|
|
692 cursor_start, cursor_width,
|
|
693 cursor_height));
|
|
694 }
|
|
695
|
|
696 start_pixpos = next_start_pixpos;
|
|
697 }
|
|
698 }
|
|
699
|
|
700 /* Clear the internal border if we are next to it and the window
|
|
701 structure or frame size has changed or if something caused
|
|
702 clear_border to be tripped. */
|
|
703 /* #### Doing this on f->clear sucks but is necessary because of
|
|
704 window-local background values. */
|
|
705 if (f->windows_structure_changed || f->faces_changed || clear_border
|
|
706 || f->clear)
|
|
707 {
|
|
708 int y = ddl->ypos - ddl->ascent;
|
|
709 int height = ddl->ascent + ddl->descent - ddl->clip;
|
|
710
|
|
711 if (ddl->modeline)
|
|
712 {
|
|
713 y -= MODELINE_SHADOW_THICKNESS (w);
|
|
714 height += (2 * MODELINE_SHADOW_THICKNESS (w));
|
|
715 }
|
|
716
|
|
717 if (window_is_leftmost (w))
|
|
718 clear_left_border (w, y, height);
|
|
719 if (window_is_rightmost (w))
|
|
720 clear_right_border (w, y, height);
|
|
721 }
|
|
722
|
|
723 if (cdla)
|
|
724 sync_display_line_structs (w, line, must_sync, cdla, ddla);
|
|
725 }
|
|
726
|
|
727 /*****************************************************************************
|
|
728 redisplay_move_cursor
|
|
729
|
|
730 For the given window W, move the cursor to NEW_POINT. Returns a
|
|
731 boolean indicating success or failure.
|
|
732 ****************************************************************************/
|
|
733
|
|
734 #define ADJ_BUFPOS (rb->bufpos + dl->offset)
|
|
735 #define ADJ_ENDPOS (rb->endpos + dl->offset)
|
|
736
|
|
737 int
|
|
738 redisplay_move_cursor (struct window *w, Bufpos new_point, int no_output_end)
|
|
739 {
|
|
740 struct frame *f = XFRAME (w->frame);
|
|
741 struct device *d = XDEVICE (f->device);
|
|
742
|
|
743 display_line_dynarr *cla = window_display_lines (w, CURRENT_DISP);
|
|
744 struct display_line *dl;
|
|
745 struct display_block *db;
|
|
746 struct rune *rb;
|
|
747 int x = w->last_point_x[CURRENT_DISP];
|
|
748 int y = w->last_point_y[CURRENT_DISP];
|
|
749
|
263
|
750 extern int cursor_in_echo_area;
|
|
751
|
|
752 /*
|
265
|
753 * Bail if cursor_in_echo_area is non-zero and we're fiddling with
|
|
754 * the cursor in a non-active minibuffer window, since that is a
|
|
755 * special case that is handled elsewhere and this function need
|
|
756 * not handle it. Return 1 so the caller will assume we
|
263
|
757 * succeeded.
|
|
758 */
|
265
|
759 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
760 w != XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
263
|
761 return 1;
|
|
762
|
0
|
763 if (y < 0 || y >= Dynarr_length (cla))
|
|
764 return 0;
|
|
765
|
|
766 dl = Dynarr_atp (cla, y);
|
|
767 db = get_display_block_from_line (dl, TEXT);
|
|
768
|
|
769 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
770 return 0;
|
|
771
|
|
772 rb = Dynarr_atp (db->runes, x);
|
|
773
|
|
774 if (rb->cursor_type == CURSOR_OFF)
|
|
775 return 0;
|
|
776 else if (ADJ_BUFPOS == new_point
|
|
777 || (ADJ_ENDPOS && (new_point >= ADJ_BUFPOS)
|
|
778 && (new_point <= ADJ_ENDPOS)))
|
|
779 {
|
|
780 w->last_point_x[CURRENT_DISP] = x;
|
|
781 w->last_point_y[CURRENT_DISP] = y;
|
|
782 Fset_marker (w->last_point[CURRENT_DISP], make_int (ADJ_BUFPOS),
|
|
783 w->buffer);
|
|
784 dl->cursor_elt = x;
|
|
785 return 1;
|
|
786 }
|
|
787 else
|
|
788 {
|
|
789 DEVMETH (d, output_begin, (d));
|
|
790
|
|
791 /* #### This is a gross kludge. Cursor handling is such a royal
|
|
792 pain in the ass. */
|
|
793 if (rb->type == RUNE_DGLYPH &&
|
|
794 (EQ (rb->object.dglyph.glyph, Vtruncation_glyph) ||
|
|
795 EQ (rb->object.dglyph.glyph, Vcontinuation_glyph)))
|
|
796 rb->cursor_type = NO_CURSOR;
|
|
797 else
|
|
798 rb->cursor_type = CURSOR_OFF;
|
|
799 dl->cursor_elt = -1;
|
|
800 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
801 }
|
|
802
|
|
803 w->last_point_x[CURRENT_DISP] = -1;
|
|
804 w->last_point_y[CURRENT_DISP] = -1;
|
|
805 Fset_marker (w->last_point[CURRENT_DISP], Qnil, w->buffer);
|
|
806
|
|
807 /* If this isn't the selected frame, then erasing the old cursor is
|
|
808 all we actually had to do. */
|
|
809 if (w != XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))))
|
|
810 {
|
|
811 if (!no_output_end)
|
|
812 DEVMETH (d, output_end, (d));
|
|
813
|
|
814 return 1;
|
|
815 }
|
|
816
|
|
817 /* This should only occur in the minibuffer. */
|
|
818 if (new_point == 0)
|
|
819 {
|
|
820 w->last_point_x[CURRENT_DISP] = 0;
|
|
821 w->last_point_y[CURRENT_DISP] = y;
|
|
822 Fset_marker (w->last_point[CURRENT_DISP], Qzero, w->buffer);
|
|
823
|
|
824 rb = Dynarr_atp (db->runes, 0);
|
|
825 rb->cursor_type = CURSOR_ON;
|
|
826 dl->cursor_elt = 0;
|
|
827
|
|
828 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
829
|
|
830 if (!no_output_end)
|
|
831 DEVMETH (d, output_end, (d));
|
|
832 return 1;
|
|
833 }
|
|
834 else
|
|
835 {
|
|
836 int cur_rb = 0;
|
|
837 int first = 0;
|
|
838 int cur_dl, up;
|
|
839
|
|
840 if (ADJ_BUFPOS < new_point)
|
|
841 {
|
|
842 up = 1;
|
|
843 cur_rb = x + 1;
|
|
844 cur_dl = y;
|
|
845 }
|
|
846 else /* (rb->bufpos + dl->offset) > new_point */
|
|
847 {
|
|
848 up = 0;
|
|
849
|
|
850 if (!x)
|
|
851 {
|
|
852 cur_dl = y - 1;
|
|
853 first = 0;
|
|
854 }
|
|
855 else
|
|
856 {
|
|
857 cur_rb = x - 1;
|
|
858 cur_dl = y;
|
|
859 first = 1;
|
|
860 }
|
|
861 }
|
|
862
|
|
863 while ((up ? (cur_dl < Dynarr_length (cla)) : (cur_dl >= 0)))
|
|
864 {
|
|
865 dl = Dynarr_atp (cla, cur_dl);
|
|
866 db = get_display_block_from_line (dl, TEXT);
|
|
867
|
|
868 if (!up && !first)
|
|
869 cur_rb = Dynarr_length (db->runes) - 1;
|
|
870
|
|
871 while ((!scroll_on_clipped_lines || !dl->clip) &&
|
|
872 (up ? (cur_rb < Dynarr_length (db->runes)) : (cur_rb >= 0)))
|
|
873 {
|
|
874 rb = Dynarr_atp (db->runes, cur_rb);
|
|
875
|
|
876 if (rb->cursor_type != IGNORE_CURSOR
|
|
877 && rb->cursor_type != NO_CURSOR &&
|
|
878 (ADJ_BUFPOS == new_point
|
|
879 || (ADJ_ENDPOS && (new_point >= ADJ_BUFPOS)
|
|
880 && (new_point <= ADJ_BUFPOS))))
|
|
881 {
|
|
882 rb->cursor_type = CURSOR_ON;
|
|
883 dl->cursor_elt = cur_rb;
|
185
|
884
|
0
|
885
|
|
886 output_display_line (w, 0, cla, cur_dl, rb->xpos,
|
|
887 rb->xpos + rb->width);
|
|
888
|
|
889 w->last_point_x[CURRENT_DISP] = cur_rb;
|
|
890 w->last_point_y[CURRENT_DISP] = cur_dl;
|
|
891 Fset_marker (w->last_point[CURRENT_DISP],
|
|
892 make_int (ADJ_BUFPOS), w->buffer);
|
|
893
|
|
894 if (!no_output_end)
|
|
895 DEVMETH (d, output_end, (d));
|
|
896 return 1;
|
|
897 }
|
|
898
|
|
899 (up ? cur_rb++ : cur_rb--);
|
|
900 }
|
|
901
|
|
902 (up ? (cur_rb = 0) : (first = 0));
|
|
903 (up ? cur_dl++ : cur_dl--);
|
|
904 }
|
|
905 }
|
|
906
|
|
907 if (!no_output_end)
|
|
908 DEVMETH (d, output_end, (d));
|
|
909 return 0;
|
|
910 }
|
|
911 #undef ADJ_BUFPOS
|
|
912 #undef ADJ_ENDPOS
|
|
913
|
|
914 /*****************************************************************************
|
|
915 redraw_cursor_in_window
|
|
916
|
|
917 For the given window W, redraw the cursor if it is contained within
|
|
918 the window.
|
|
919 ****************************************************************************/
|
|
920 static void
|
|
921 redraw_cursor_in_window (struct window *w, int run_end_begin_meths)
|
|
922 {
|
|
923 struct frame *f = XFRAME (w->frame);
|
|
924 struct device *d = XDEVICE (f->device);
|
|
925
|
|
926 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
927 struct display_line *dl;
|
|
928 struct display_block *db;
|
|
929 struct rune *rb;
|
265
|
930 extern int cursor_in_echo_area;
|
0
|
931
|
|
932 int x = w->last_point_x[CURRENT_DISP];
|
|
933 int y = w->last_point_y[CURRENT_DISP];
|
|
934
|
265
|
935 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
936 !echo_area_active (f) && minibuf_level == 0)
|
|
937 {
|
|
938 MAYBE_DEVMETH (d, set_final_cursor_coords, (f, w->pixel_top, 0));
|
|
939 }
|
|
940
|
0
|
941 if (y < 0 || y >= Dynarr_length (dla))
|
|
942 return;
|
|
943
|
|
944 if (MINI_WINDOW_P (w) && f != device_selected_frame (d) &&
|
|
945 !is_surrogate_for_selected_frame (f))
|
|
946 return;
|
|
947
|
|
948 dl = Dynarr_atp (dla, y);
|
|
949 db = get_display_block_from_line (dl, TEXT);
|
|
950
|
|
951 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
952 return;
|
|
953
|
|
954 rb = Dynarr_atp (db->runes, x);
|
|
955
|
|
956 /* Don't call the output routine if the block isn't actually the
|
|
957 cursor. */
|
|
958 if (rb->cursor_type == CURSOR_ON)
|
|
959 {
|
265
|
960 MAYBE_DEVMETH (d, set_final_cursor_coords,
|
|
961 (f, dl->ypos - 1, rb->xpos));
|
|
962
|
0
|
963 if (run_end_begin_meths)
|
|
964 DEVMETH (d, output_begin, (d));
|
|
965
|
|
966 output_display_line (w, 0, dla, y, rb->xpos, rb->xpos + rb->width);
|
|
967
|
|
968 if (run_end_begin_meths)
|
|
969 DEVMETH (d, output_end, (d));
|
|
970 }
|
|
971 }
|
|
972
|
|
973 /*****************************************************************************
|
|
974 redisplay_redraw_cursor
|
|
975
|
|
976 For the given frame F, redraw the cursor on the selected window.
|
|
977 This is used to update the cursor after focus changes.
|
|
978 ****************************************************************************/
|
|
979 void
|
|
980 redisplay_redraw_cursor (struct frame *f, int run_end_begin_meths)
|
|
981 {
|
|
982 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
|
263
|
983 extern int cursor_in_echo_area;
|
|
984
|
|
985 if (cursor_in_echo_area)
|
267
|
986 {
|
263
|
987 if (FRAME_HAS_MINIBUF_P (f))
|
|
988 {
|
|
989 w = XWINDOW (FRAME_MINIBUF_WINDOW (f));
|
|
990 }
|
|
991 else
|
267
|
992 {
|
263
|
993 return;
|
267
|
994 }
|
|
995 }
|
0
|
996 redraw_cursor_in_window (w, run_end_begin_meths);
|
|
997 }
|
|
998
|
|
999 /*****************************************************************************
|
|
1000 redisplay_clear_top_of_window
|
|
1001
|
|
1002 If window is topmost, clear the internal border above it.
|
|
1003 ****************************************************************************/
|
|
1004 static void
|
|
1005 redisplay_clear_top_of_window (struct window *w)
|
|
1006 {
|
|
1007 Lisp_Object window;
|
|
1008 XSETWINDOW (window, w);
|
|
1009
|
|
1010 if (!NILP (Fwindow_highest_p (window)))
|
|
1011 {
|
|
1012 struct frame *f = XFRAME (w->frame);
|
|
1013 struct device *d = XDEVICE (f->device);
|
|
1014 int x, y, width, height;
|
|
1015
|
|
1016 x = w->pixel_left;
|
|
1017 width = w->pixel_width;
|
|
1018
|
|
1019 if (window_is_leftmost (w))
|
|
1020 {
|
|
1021 x -= FRAME_BORDER_WIDTH (f);
|
|
1022 width += FRAME_BORDER_WIDTH (f);
|
|
1023 }
|
|
1024 if (window_is_rightmost (w))
|
|
1025 width += FRAME_BORDER_WIDTH (f);
|
185
|
1026
|
0
|
1027 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
1028 height = FRAME_BORDER_HEIGHT (f) + 1;
|
|
1029
|
|
1030 DEVMETH (d, clear_region, (window, DEFAULT_INDEX, x, y, width, height));
|
|
1031 }
|
|
1032 }
|
|
1033
|
|
1034 /*****************************************************************************
|
|
1035 redisplay_clear_bottom_of_window
|
|
1036
|
|
1037 Clear window from right below the last display line to right above
|
|
1038 the modeline. The calling function can limit the area actually
|
|
1039 erased by setting min_start and/or max_end to positive values.
|
|
1040 ****************************************************************************/
|
|
1041 void
|
|
1042 redisplay_clear_bottom_of_window (struct window *w, display_line_dynarr *ddla,
|
|
1043 int min_start, int max_end)
|
|
1044 {
|
|
1045 struct frame *f = XFRAME (w->frame);
|
|
1046 struct device *d = XDEVICE (f->device);
|
|
1047 int ypos1, ypos2;
|
|
1048 int ddla_len = Dynarr_length (ddla);
|
|
1049
|
|
1050 ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
1051 #ifdef HAVE_SCROLLBARS
|
|
1052 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
1053 if (f->windows_structure_changed && !f->scrollbar_on_top)
|
|
1054 ypos2 += window_scrollbar_height (w);
|
|
1055 #endif
|
|
1056
|
|
1057 if (ddla_len)
|
|
1058 {
|
|
1059 if (ddla_len == 1 && Dynarr_atp (ddla, 0)->modeline)
|
|
1060 {
|
|
1061 ypos1 = WINDOW_TEXT_TOP (w);
|
|
1062 #ifdef HAVE_SCROLLBARS
|
|
1063 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
1064 if (f->windows_structure_changed && f->scrollbar_on_top)
|
|
1065 ypos1 -= window_scrollbar_height (w);
|
|
1066 #endif
|
|
1067 }
|
|
1068 else
|
|
1069 {
|
|
1070 struct display_line *dl = Dynarr_atp (ddla, ddla_len - 1);
|
|
1071 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
1072 }
|
|
1073 }
|
|
1074 else
|
|
1075 ypos1 = WINDOW_TEXT_TOP (w);
|
|
1076
|
|
1077 /* #### See if this can be made conditional on the frame
|
|
1078 changing size. */
|
|
1079 if (MINI_WINDOW_P (w))
|
|
1080 ypos2 += FRAME_BORDER_HEIGHT (f);
|
|
1081
|
|
1082 if (min_start >= 0 && ypos1 < min_start)
|
|
1083 ypos1 = min_start;
|
|
1084 if (max_end >= 0 && ypos2 > max_end)
|
|
1085 ypos2 = max_end;
|
|
1086
|
|
1087 if (ypos2 <= ypos1)
|
|
1088 return;
|
|
1089
|
|
1090 DEVMETH (d, clear_to_window_end, (w, ypos1, ypos2));
|
|
1091 }
|
|
1092
|
|
1093 /*****************************************************************************
|
|
1094 redisplay_update_line
|
|
1095
|
|
1096 This is used during incremental updates to update a single line and
|
|
1097 correct the offsets on all lines below it. At the moment
|
|
1098 update_values is false if we are only updating the modeline.
|
|
1099 ****************************************************************************/
|
|
1100 void
|
|
1101 redisplay_update_line (struct window *w, int first_line, int last_line,
|
|
1102 int update_values)
|
|
1103 {
|
|
1104 struct frame *f = XFRAME (w->frame);
|
|
1105 struct device *d = XDEVICE (f->device);
|
|
1106
|
|
1107 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
1108 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
1109
|
|
1110 DEVMETH (d, output_begin, (d));
|
|
1111
|
|
1112 while (first_line <= last_line)
|
|
1113 {
|
|
1114 Charcount old_len = (Dynarr_atp (cdla, first_line)->end_bufpos -
|
|
1115 Dynarr_atp (cdla, first_line)->bufpos);
|
|
1116 Charcount new_len = (Dynarr_atp (ddla, first_line)->end_bufpos -
|
|
1117 Dynarr_atp (ddla, first_line)->bufpos);
|
|
1118
|
|
1119 assert (Dynarr_length (cdla) == Dynarr_length (ddla));
|
|
1120
|
|
1121 /* Output the changes. */
|
|
1122 output_display_line (w, cdla, ddla, first_line, -1, -1);
|
|
1123
|
|
1124 /* Update the offsets. */
|
|
1125 if (update_values)
|
|
1126 {
|
|
1127 int cur_line = first_line + 1;
|
|
1128 while (cur_line < Dynarr_length (cdla))
|
|
1129 {
|
|
1130 Dynarr_atp (cdla, cur_line)->offset += (new_len - old_len);
|
|
1131 Dynarr_atp (ddla, cur_line)->offset += (new_len - old_len);
|
|
1132 cur_line++;
|
|
1133 }
|
|
1134 }
|
|
1135
|
|
1136 /* Update the window_end_pos and other settings. */
|
|
1137 if (update_values)
|
|
1138 {
|
|
1139 w->window_end_pos[CURRENT_DISP] -= (new_len - old_len);
|
|
1140
|
|
1141 if (Dynarr_atp (ddla, first_line)->cursor_elt != -1)
|
|
1142 {
|
|
1143 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
1144 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
1145 }
|
|
1146 }
|
|
1147
|
|
1148 first_line++;
|
|
1149 }
|
|
1150
|
|
1151 /* Update the window max line length. We have to scan the entire
|
|
1152 set of display lines otherwise we might not detect if the max is
|
|
1153 supposed to shrink. */
|
|
1154 if (update_values)
|
|
1155 {
|
|
1156 int line = 0;
|
|
1157
|
|
1158 w->max_line_len = 0;
|
|
1159 while (line < Dynarr_length (ddla))
|
|
1160 {
|
|
1161 struct display_line *dl = Dynarr_atp (ddla, line);
|
|
1162
|
|
1163 if (!dl->modeline)
|
|
1164 w->max_line_len = max (dl->num_chars, w->max_line_len);
|
|
1165
|
|
1166 line++;
|
|
1167 }
|
|
1168 }
|
|
1169
|
|
1170 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
1171 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
1172 Fset_marker (w->last_point[CURRENT_DISP],
|
|
1173 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
1174 Fset_marker (w->last_start[CURRENT_DISP],
|
|
1175 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
1176
|
|
1177 /* We don't bother updating the vertical scrollbars here. This
|
|
1178 gives us a performance increase while having minimal loss of
|
|
1179 quality to the scrollbar slider size and position since when this
|
|
1180 function is called we know that the changes to the buffer were
|
|
1181 very localized. We have to update the horizontal scrollbars,
|
|
1182 though, because this routine could cause a change which has a
|
|
1183 larger impact on their sizing. */
|
|
1184 /* #### See if we can get away with only calling this if
|
|
1185 max_line_len is greater than the window_char_width. */
|
209
|
1186 #if defined(HAVE_SCROLLBARS) && defined(HAVE_X_WINDOWS)
|
82
|
1187 {
|
|
1188 extern int stupid_vertical_scrollbar_drag_hack;
|
|
1189
|
|
1190 update_window_scrollbars (w, NULL, 1, stupid_vertical_scrollbar_drag_hack);
|
|
1191 stupid_vertical_scrollbar_drag_hack = 1;
|
|
1192 }
|
0
|
1193 #endif
|
|
1194
|
|
1195 /* This has to be done after we've updated the values. We don't
|
|
1196 call output_end for tty frames. Redisplay will do this after all
|
|
1197 tty windows have been updated. This cuts down on cursor
|
|
1198 flicker. */
|
|
1199 if (FRAME_TTY_P (f))
|
|
1200 redisplay_redraw_cursor (f, 0);
|
|
1201 else
|
|
1202 DEVMETH (d, output_end, (d));
|
|
1203 }
|
|
1204
|
|
1205 /*****************************************************************************
|
|
1206 redisplay_output_window
|
|
1207
|
|
1208 For the given window W, ensure that the current display lines are
|
|
1209 equal to the desired display lines, outputing changes as necessary.
|
|
1210
|
|
1211 #### Fuck me. This just isn't going to cut it for tty's. The output
|
|
1212 decisions for them must be based on the contents of the entire frame
|
|
1213 because that is how the available output capabilities think. The
|
|
1214 solution is relatively simple. Create redisplay_output_frame. This
|
|
1215 will basically merge all of the separate window display structs into
|
|
1216 a single one for the frame. This combination structure will be able
|
|
1217 to be passed to the same output_display_line which works for windows
|
|
1218 on X frames and the right things will happen. It just takes time to
|
|
1219 do.
|
|
1220 ****************************************************************************/
|
|
1221 void
|
|
1222 redisplay_output_window (struct window *w)
|
|
1223 {
|
|
1224 struct frame *f = XFRAME (w->frame);
|
|
1225 struct device *d = XDEVICE (f->device);
|
|
1226
|
|
1227 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
1228 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
1229
|
|
1230 int cdla_len = Dynarr_length (cdla);
|
|
1231 int ddla_len = Dynarr_length (ddla);
|
|
1232
|
|
1233 int line;
|
|
1234 int need_to_clear_bottom = 0;
|
|
1235 int need_to_clear_start = -1;
|
|
1236 int need_to_clear_end = -1;
|
|
1237
|
|
1238 /* Backgrounds may have changed or windows may have gone away
|
|
1239 leaving dividers lying around. */
|
|
1240 if (f->faces_changed
|
|
1241 || f->windows_structure_changed
|
|
1242 || w->shadow_thickness_changed)
|
|
1243 need_to_clear_bottom = 1;
|
|
1244
|
|
1245 /* The first thing we do is determine if we are going to need to
|
|
1246 clear the bottom of the window. We only need to do this if the
|
|
1247 bottom of the current display lines is below the bottom of the
|
|
1248 desired display lines. Note that the number of lines is
|
|
1249 irrelevant. Only the position matters. We also clear to the
|
|
1250 bottom of the window if the modeline has shifted position. */
|
|
1251 /* #### We can't blindly not clear the bottom if f->clear is true
|
|
1252 since there might be a window-local background. However, for
|
|
1253 those cases where there isn't, clearing the end of the window in
|
|
1254 this case sucks. */
|
|
1255 if (!need_to_clear_bottom)
|
|
1256 {
|
|
1257 struct display_line *cdl, *ddl;
|
|
1258
|
|
1259 /* If the modeline has changed position or size, clear the bottom
|
|
1260 of the window. */
|
|
1261 if (!need_to_clear_bottom)
|
|
1262 {
|
|
1263 cdl = ddl = 0;
|
|
1264
|
|
1265 if (cdla_len)
|
|
1266 cdl = Dynarr_atp (cdla, 0);
|
|
1267 if (ddla_len)
|
|
1268 ddl = Dynarr_atp (ddla, 0);
|
|
1269
|
|
1270 if (!cdl || !ddl)
|
|
1271 need_to_clear_bottom = 1;
|
|
1272 else if ((!cdl->modeline && ddl->modeline)
|
|
1273 || (cdl->modeline && !ddl->modeline))
|
|
1274 need_to_clear_bottom = 1;
|
|
1275 else if (cdl->ypos != ddl->ypos ||
|
|
1276 cdl->ascent != ddl->ascent ||
|
|
1277 cdl->descent != ddl->descent ||
|
|
1278 cdl->clip != ddl->clip)
|
|
1279 need_to_clear_bottom = 1;
|
|
1280
|
|
1281 /* #### This kludge is to make sure the modeline shadows get
|
|
1282 redrawn if the modeline position shifts. */
|
|
1283 if (need_to_clear_bottom)
|
|
1284 w->shadow_thickness_changed = 1;
|
|
1285 }
|
|
1286
|
|
1287 if (!need_to_clear_bottom)
|
|
1288 {
|
|
1289 cdl = ddl = 0;
|
|
1290
|
|
1291 if (cdla_len)
|
|
1292 cdl = Dynarr_atp (cdla, cdla_len - 1);
|
|
1293 if (ddla_len)
|
|
1294 ddl = Dynarr_atp (ddla, ddla_len - 1);
|
|
1295
|
|
1296 if (!cdl || !ddl)
|
|
1297 need_to_clear_bottom = 1;
|
|
1298 else
|
|
1299 {
|
|
1300 int cdl_bottom, ddl_bottom;
|
|
1301
|
|
1302 cdl_bottom = cdl->ypos + cdl->descent;
|
|
1303 ddl_bottom = ddl->ypos + ddl->descent;
|
|
1304
|
|
1305 if (cdl_bottom > ddl_bottom)
|
|
1306 {
|
|
1307 need_to_clear_bottom = 1;
|
|
1308 need_to_clear_start = ddl_bottom;
|
|
1309 need_to_clear_end = cdl_bottom;
|
|
1310 }
|
|
1311 }
|
|
1312 }
|
|
1313 }
|
|
1314
|
|
1315 /* Perform any output initialization. */
|
|
1316 DEVMETH (d, output_begin, (d));
|
|
1317
|
|
1318 /* If the window's structure has changed clear the internal border
|
|
1319 above it if it is topmost (the function will check). */
|
|
1320 if (f->windows_structure_changed)
|
|
1321 redisplay_clear_top_of_window (w);
|
|
1322
|
|
1323 /* Output each line. */
|
|
1324 for (line = 0; line < Dynarr_length (ddla); line++)
|
|
1325 {
|
|
1326 output_display_line (w, cdla, ddla, line, -1, -1);
|
|
1327 }
|
|
1328
|
|
1329 /* If the number of display lines has shrunk, adjust. */
|
|
1330 if (cdla_len > ddla_len)
|
|
1331 {
|
|
1332 Dynarr_length (cdla) = ddla_len;
|
|
1333 }
|
|
1334
|
|
1335 /* Output a vertical divider between windows, if necessary. */
|
|
1336 if (window_needs_vertical_divider (w)
|
|
1337 && (f->windows_structure_changed || f->clear))
|
|
1338 {
|
|
1339 DEVMETH (d, output_vertical_divider, (w, f->windows_structure_changed));
|
|
1340 }
|
|
1341
|
|
1342 /* Clear the rest of the window, if necessary. */
|
|
1343 if (need_to_clear_bottom)
|
|
1344 {
|
|
1345 redisplay_clear_bottom_of_window (w, ddla, need_to_clear_start,
|
|
1346 need_to_clear_end);
|
|
1347 }
|
|
1348
|
|
1349 w->window_end_pos[CURRENT_DISP] = w->window_end_pos[DESIRED_DISP];
|
|
1350 Fset_marker (w->start[CURRENT_DISP],
|
|
1351 make_int (marker_position (w->start[DESIRED_DISP])),
|
|
1352 w->buffer);
|
|
1353 Fset_marker (w->pointm[CURRENT_DISP],
|
|
1354 make_int (marker_position (w->pointm[DESIRED_DISP])),
|
|
1355 w->buffer);
|
|
1356 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
1357 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
1358 Fset_marker (w->last_start[CURRENT_DISP],
|
|
1359 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
1360 Fset_marker (w->last_point[CURRENT_DISP],
|
|
1361 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
1362 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
1363 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
1364 w->shadow_thickness_changed = 0;
|
|
1365
|
|
1366 set_window_display_buffer (w, XBUFFER (w->buffer));
|
|
1367 find_window_mirror (w)->truncate_win = window_truncation_on (w);
|
|
1368
|
|
1369 /* Overkill on invalidating the cache. It is very bad for it to not
|
|
1370 get invalidated when it should be. */
|
|
1371 INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE (d);
|
|
1372
|
|
1373 /* We don't call output_end for tty frames. Redisplay will do this
|
|
1374 after all tty windows have been updated. This cuts down on
|
|
1375 cursor flicker. */
|
|
1376 if (FRAME_TTY_P (f))
|
|
1377 redisplay_redraw_cursor (f, 0);
|
|
1378 else
|
|
1379 DEVMETH (d, output_end, (d));
|
|
1380
|
|
1381 #ifdef HAVE_SCROLLBARS
|
|
1382 update_window_scrollbars (w, NULL, !MINI_WINDOW_P (w), 0);
|
|
1383 #endif
|
|
1384 }
|