ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.71 by pcg, Thu Apr 8 20:31:45 2004 UTC vs.
Revision 1.85 by root, Sun Aug 8 16:43:21 2004 UTC

29#include "rxvt.h" /* NECESSARY */ 29#include "rxvt.h" /* NECESSARY */
30#include "screen.intpro" /* PROTOS for internal routines */ 30#include "screen.intpro" /* PROTOS for internal routines */
31 31
32#include <X11/Xmd.h> /* get the typedef for CARD32 */ 32#include <X11/Xmd.h> /* get the typedef for CARD32 */
33 33
34#include <stdint.h> 34#include <inttypes.h>
35#include <wchar.h> 35#include <wchar.h>
36 36
37#include "salloc.C" // HACK, should be a seperate compile! 37#include "salloc.C" // HACK, should be a seperate compile!
38 38
39inline void fill_text (text_t *start, text_t value, int len) 39inline void fill_text (text_t *start, text_t value, int len)
48 48
49/* ------------------------------------------------------------------------- * 49/* ------------------------------------------------------------------------- *
50 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * 50 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES *
51 * ------------------------------------------------------------------------- */ 51 * ------------------------------------------------------------------------- */
52#define ZERO_SCROLLBACK() \ 52#define ZERO_SCROLLBACK() \
53 if ((Options & Opt_scrollTtyOutput) == Opt_scrollTtyOutput) \ 53 if (Options & Opt_scrollTtyOutput) \
54 TermWin.view_start = 0 54 TermWin.view_start = 0
55#define CLEAR_SELECTION() \ 55#define CLEAR_SELECTION() \
56 selection.beg.row = selection.beg.col \ 56 selection.beg.row = selection.beg.col \
57 = selection.end.row = selection.end.col = 0 57 = selection.end.row = selection.end.col = 0
58#define CLEAR_ALL_SELECTION() \ 58#define CLEAR_ALL_SELECTION() \
59 selection.beg.row = selection.beg.col \ 59 selection.beg.row = selection.beg.col \
60 = selection.mark.row = selection.mark.col \ 60 = selection.mark.row = selection.mark.col \
61 = selection.end.row = selection.end.col = 0 61 = selection.end.row = selection.end.col = 0
62 62
63#define ROW_AND_COL_IS_AFTER(A, B, C, D) \ 63#define ROW_AND_COL_IS_AFTER(A, B, C, D) \
64 (((A) > (C)) || (((A) == (C)) && ((B) > (D)))) 64 (((A) > (C)) || (((A) == (C)) && ((B) > (D))))
65#define ROW_AND_COL_IS_BEFORE(A, B, C, D) \ 65#define ROW_AND_COL_IS_BEFORE(A, B, C, D) \
66 (((A) < (C)) || (((A) == (C)) && ((B) < (D)))) 66 (((A) < (C)) || (((A) == (C)) && ((B) < (D))))
67#define ROW_AND_COL_IN_ROW_AFTER(A, B, C, D) \ 67#define ROW_AND_COL_IN_ROW_AFTER(A, B, C, D) \
68 (((A) == (C)) && ((B) > (D))) 68 (((A) == (C)) && ((B) > (D)))
69#define ROW_AND_COL_IN_ROW_AT_OR_AFTER(A, B, C, D) \ 69#define ROW_AND_COL_IN_ROW_AT_OR_AFTER(A, B, C, D) \
70 (((A) == (C)) && ((B) >= (D))) 70 (((A) == (C)) && ((B) >= (D)))
71#define ROW_AND_COL_IN_ROW_BEFORE(A, B, C, D) \ 71#define ROW_AND_COL_IN_ROW_BEFORE(A, B, C, D) \
72 (((A) == (C)) && ((B) < (D))) 72 (((A) == (C)) && ((B) < (D)))
73#define ROW_AND_COL_IN_ROW_AT_OR_BEFORE(A, B, C, D) \ 73#define ROW_AND_COL_IN_ROW_AT_OR_BEFORE(A, B, C, D) \
74 (((A) == (C)) && ((B) <= (D))) 74 (((A) == (C)) && ((B) <= (D)))
75 75
76/* these must be row_col_t */ 76/* these must be row_col_t */
77#define ROWCOL_IS_AFTER(X, Y) \ 77#define ROWCOL_IS_AFTER(X, Y) \
78 ROW_AND_COL_IS_AFTER ((X).row, (X).col, (Y).row, (Y).col) 78 ROW_AND_COL_IS_AFTER ((X).row, (X).col, (Y).row, (Y).col)
79#define ROWCOL_IS_BEFORE(X, Y) \ 79#define ROWCOL_IS_BEFORE(X, Y) \
80 ROW_AND_COL_IS_BEFORE ((X).row, (X).col, (Y).row, (Y).col) 80 ROW_AND_COL_IS_BEFORE ((X).row, (X).col, (Y).row, (Y).col)
81#define ROWCOL_IN_ROW_AFTER(X, Y) \ 81#define ROWCOL_IN_ROW_AFTER(X, Y) \
82 ROW_AND_COL_IN_ROW_AFTER ((X).row, (X).col, (Y).row, (Y).col) 82 ROW_AND_COL_IN_ROW_AFTER ((X).row, (X).col, (Y).row, (Y).col)
83#define ROWCOL_IN_ROW_BEFORE(X, Y) \ 83#define ROWCOL_IN_ROW_BEFORE(X, Y) \
84 ROW_AND_COL_IN_ROW_BEFORE ((X).row, (X).col, (Y).row, (Y).col) 84 ROW_AND_COL_IN_ROW_BEFORE ((X).row, (X).col, (Y).row, (Y).col)
85#define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ 85#define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \
86 ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) 86 ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col)
87#define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ 87#define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \
88 ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) 88 ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col)
89 89
90/* 90/*
91 * CLEAR_ROWS : clear <num> rows starting from row <row> 91 * CLEAR_ROWS : clear <num> rows starting from row <row>
92 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> 92 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y>
93 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour 93 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour
94 */ 94 */
95#define drawBuffer TermWin.vt 95#define drawBuffer TermWin.vt
96 96
97#define CLEAR_ROWS(row, num) \ 97#define CLEAR_ROWS(row, num) \
98 if (TermWin.mapped) \ 98 if (TermWin.mapped) \
99 XClearArea (display->display, drawBuffer, TermWin.int_bwidth, \ 99 XClearArea (display->display, drawBuffer, 0, \
100 Row2Pixel (row), (unsigned int)TermWin.width, \ 100 Row2Pixel (row), (unsigned int)TermWin.width, \
101 (unsigned int)Height2Pixel (num), False) 101 (unsigned int)Height2Pixel (num), False)
102 102
103#define CLEAR_CHARS(x, y, num) \ 103#define CLEAR_CHARS(x, y, num) \
104 if (TermWin.mapped) \ 104 if (TermWin.mapped) \
105 XClearArea (display->display, drawBuffer, x, y, \ 105 XClearArea (display->display, drawBuffer, x, y, \
106 (unsigned int)Width2Pixel (num), \ 106 (unsigned int)Width2Pixel (num), \
107 (unsigned int)Height2Pixel (1), False) 107 (unsigned int)Height2Pixel (1), False)
108 108
109#define ERASE_ROWS(row, num) \ 109#define ERASE_ROWS(row, num) \
110 XFillRectangle (display->display, drawBuffer, TermWin.gc, \ 110 XFillRectangle (display->display, drawBuffer, TermWin.gc, \
111 TermWin.int_bwidth, Row2Pixel (row), \ 111 0, Row2Pixel (row), \
112 (unsigned int)TermWin.width, \ 112 (unsigned int)TermWin.width, \
113 (unsigned int)Height2Pixel (num)) 113 (unsigned int)Height2Pixel (num))
114 114
115/* ------------------------------------------------------------------------- * 115/* ------------------------------------------------------------------------- *
116 * SCREEN `COMMON' ROUTINES * 116 * SCREEN `COMMON' ROUTINES *
117 * ------------------------------------------------------------------------- */ 117 * ------------------------------------------------------------------------- */
118/* Fill part/all of a line with blanks. */ 118/* Fill part/all of a line with blanks. */
119void 119void
120rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) 120rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs)
121{ 121{
122 efs &= ~RS_baseattrMask; 122 efs &= ~RS_baseattrMask;
123 efs = SET_FONT (efs, TermWin.fontset->find_font (' ')); 123 efs = SET_FONT (efs, TermWin.ascii_map [' ' - 0x20]);
124 124
125 while (width--) 125 while (width--)
126 { 126 {
127 *et++ = ' '; 127 *et++ = ' ';
128 *er++ = efs; 128 *er++ = efs;
189 } 189 }
190 190
191 if (prev_nrow == 0) 191 if (prev_nrow == 0)
192 { 192 {
193 /* 193 /*
194 * first time called so just malloc everything : don't rely on realloc 194 * first time called so just malloc everything: don't rely on realloc
195 * Note: this is still needed so that all the scrollback lines are NULL 195 * Note: this is still needed so that all the scrollback lines are NULL
196 */ 196 */
197 screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); 197 screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *));
198 buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); 198 buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *));
199 drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); 199 drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *));
256 scr_scroll_text (0, (int)prev_nrow - 1, k, 1); 256 scr_scroll_text (0, (int)prev_nrow - 1, k, 1);
257 257
258 for (p = nrow; p < prev_nrow; p++) 258 for (p = nrow; p < prev_nrow; p++)
259 { 259 {
260 q = p + TermWin.saveLines; 260 q = p + TermWin.saveLines;
261
261 if (screen.text[q]) 262 if (screen.text[q])
262 { 263 {
263#ifdef DEBUG_STRICT 264#ifdef DEBUG_STRICT
264 assert (screen.rend[q]); 265 assert (screen.rend[q]);
265#endif 266#endif
266 talloc->free (screen.text[q]); 267 talloc->free (screen.text[q]);
267 ralloc->free (screen.rend[q]); 268 ralloc->free (screen.rend[q]);
268 } 269 }
270
269 if (swap.text[p]) 271 if (swap.text[p])
270 { 272 {
271#ifdef DEBUG_STRICT 273#ifdef DEBUG_STRICT
272 assert (swap.rend[p]); 274 assert (swap.rend[p]);
273#endif 275#endif
274 talloc->free (swap.text[p]); 276 talloc->free (swap.text[p]);
275 ralloc->free (swap.rend[p]); 277 ralloc->free (swap.rend[p]);
276 } 278 }
279
277#ifdef DEBUG_STRICT 280#ifdef DEBUG_STRICT
278 assert (drawn_text[p] && drawn_rend[p]); 281 assert (drawn_text[p] && drawn_rend[p]);
279#endif 282#endif
280 talloc->free (drawn_text[p]); 283 talloc->free (drawn_text[p]);
281 ralloc->free (drawn_rend[p]); 284 ralloc->free (drawn_rend[p]);
311 swap.tlen[p] = 0; 314 swap.tlen[p] = 0;
312 swap.text[p] = NULL; 315 swap.text[p] = NULL;
313 swap.rend[p] = NULL; 316 swap.rend[p] = NULL;
314 drawn_text[p] = NULL; 317 drawn_text[p] = NULL;
315 drawn_rend[p] = NULL; 318 drawn_rend[p] = NULL;
316 scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); 319 scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle);
317 scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); 320 scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle);
318 } 321 }
319 322
320 if (k > 0) 323 if (k > 0)
321 { 324 {
336 } 339 }
337 340
338 /* resize columns */ 341 /* resize columns */
339 if (ncol != prev_ncol) 342 if (ncol != prev_ncol)
340 { 343 {
341 int common = min (prev_ncol, ncol);
342 rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); 344 rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t));
343 rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); 345 rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t));
344 346
345 for (p = 0; p < total_rows; p++) 347 for (p = 0; p < total_rows; p++)
346 { 348 {
347 if (screen.text[p]) 349 if (screen.text[p])
348 { 350 {
349 text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; 351 screen.text[p] = (text_t *)ta->alloc (screen.text[p], prev_ncol * sizeof (text_t));
350 rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; 352 screen.rend[p] = (rend_t *)ra->alloc (screen.rend[p], prev_ncol * sizeof (rend_t));
351 353
352 MIN_IT (screen.tlen[p], (int16_t)ncol); 354 MIN_IT (screen.tlen[p], (int16_t)ncol);
353 355
354 if (ncol > prev_ncol) 356 if (ncol > prev_ncol)
355 scr_blank_line (& (screen.text[p][prev_ncol]), 357 scr_blank_line (&screen.text[p][prev_ncol],
356 & (screen.rend[p][prev_ncol]), 358 &screen.rend[p][prev_ncol],
357 ncol - prev_ncol, 359 ncol - prev_ncol, setrstyle);
358 setrstyle);
359 } 360 }
360 } 361 }
361 362
362 for (p = 0; p < nrow; p++) 363 for (p = 0; p < nrow; p++)
363 { 364 {
364 text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; 365 drawn_text[p] = (text_t *)ta->alloc (drawn_text[p], prev_ncol * sizeof (text_t));
365 rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; 366 drawn_rend[p] = (rend_t *)ra->alloc (drawn_rend[p], prev_ncol * sizeof (rend_t));
366 367
367 if (ncol > prev_ncol) 368 if (ncol > prev_ncol)
368 scr_blank_line (& (drawn_text[p][prev_ncol]), 369 scr_blank_line (&drawn_text[p][prev_ncol],
369 & (drawn_rend[p][prev_ncol]), 370 &drawn_rend[p][prev_ncol],
370 ncol - prev_ncol, setrstyle); 371 ncol - prev_ncol, setrstyle);
371 372
372 if (swap.text[p]) 373 if (swap.text[p])
373 { 374 {
374 text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; 375 swap.text[p] = (text_t *)ta->alloc (swap.text[p], prev_ncol * sizeof (text_t));
375 rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; 376 swap.rend[p] = (rend_t *)ra->alloc (swap.rend[p], prev_ncol * sizeof (rend_t));
376 377
377 MIN_IT (swap.tlen[p], (int16_t)ncol); 378 MIN_IT (swap.tlen[p], (int16_t)ncol);
378 379
379 if (ncol > prev_ncol) 380 if (ncol > prev_ncol)
380 scr_blank_line (& (swap.text[p][prev_ncol]), 381 scr_blank_line (&swap.text[p][prev_ncol],
381 & (swap.rend[p][prev_ncol]), 382 &swap.rend[p][prev_ncol],
382 ncol - prev_ncol, setrstyle); 383 ncol - prev_ncol, setrstyle);
383 } 384 }
384 385
385 } 386 }
386 387
476 477
477 scr_release (); 478 scr_release ();
478 prev_nrow = prev_ncol = 0; 479 prev_nrow = prev_ncol = 0;
479 scr_reset (); 480 scr_reset ();
480 481
481 scr_clear (); 482 scr_clear (true);
482 scr_refresh (SLOW_REFRESH); 483 scr_refresh (SLOW_REFRESH);
483} 484}
484 485
485/* ------------------------------------------------------------------------- * 486/* ------------------------------------------------------------------------- *
486 * PROCESS SCREEN COMMANDS * 487 * PROCESS SCREEN COMMANDS *
704 if (j > 0) 705 if (j > 0)
705 { 706 {
706 /* A: scroll up */ 707 /* A: scroll up */
707 708
708 /* A1: Copy lines that will get clobbered by the rotation */ 709 /* A1: Copy lines that will get clobbered by the rotation */
710 memcpy (buf_text, screen.text + row1, count * sizeof (text_t *));
711 memcpy (buf_rend, screen.rend + row1, count * sizeof (rend_t *));
712
713 /* A2: Rotate lines */
714 i = row2 - row1 - count + 1;
715 memmove (screen.tlen + row1, screen.tlen + row1 + count, i * sizeof (int16_t));
716 memmove (screen.text + row1, screen.text + row1 + count, i * sizeof (text_t *));
717 memmove (screen.rend + row1, screen.rend + row1 + count, i * sizeof (rend_t *));
718
719 j = row2 - count + 1, i = count;
720 }
721 else /* if (j < 0) */
722 {
723 /* B: scroll down */
724
725 /* B1: Copy lines that will get clobbered by the rotation */
709 for (i = 0, j = row1; i < count; i++, j++) 726 for (i = 0, j = row2; i < count; i++, j--)
710 { 727 {
711 buf_text[i] = screen.text[j]; 728 buf_text[i] = screen.text[j];
712 buf_rend[i] = screen.rend[j]; 729 buf_rend[i] = screen.rend[j];
713 } 730 }
731
714 /* A2: Rotate lines */ 732 /* B2: Rotate lines */
715 for (j = row1, i = j + count; i <= row2; i++, j++) 733 for (j = row2, i = j - count; i >= row1; i--, j--)
716 { 734 {
717 screen.tlen[j] = screen.tlen[i]; 735 screen.tlen[j] = screen.tlen[i];
718 screen.text[j] = screen.text[i]; 736 screen.text[j] = screen.text[i];
719 screen.rend[j] = screen.rend[i]; 737 screen.rend[j] = screen.rend[i];
720 } 738 }
721 j = row2 - count + 1, i = count;
722 }
723 else /* if (j < 0) */
724 {
725 /* B: scroll down */
726 739
727 /* B1: Copy lines that will get clobbered by the rotation */
728 for (i = 0, j = row2; i < count; i++, j--)
729 {
730 buf_text[i] = screen.text[j];
731 buf_rend[i] = screen.rend[j];
732 }
733 /* B2: Rotate lines */
734 for (j = row2, i = j - count; i >= row1; i--, j--)
735 {
736 screen.tlen[j] = screen.tlen[i];
737 screen.text[j] = screen.text[i];
738 screen.rend[j] = screen.rend[i];
739 }
740 j = row1, i = count; 740 j = row1, i = count;
741 count = -count; 741 count = -count;
742 } 742 }
743 743
744 /* C: Resurrect lines */ 744 /* C: Resurrect lines */
745 memset (screen.tlen + j, 0, i * sizeof (int16_t));
746 memcpy (screen.text + j, buf_text, i * sizeof (text_t *));
747 memcpy (screen.rend + j, buf_rend, i * sizeof (text_t *));
748 if (!spec) /* line length may not equal TermWin.ncol */
745 for (; i--; j++) 749 for (; i--; j++)
746 {
747 screen.tlen[j] = 0;
748 screen.text[j] = buf_text[i];
749 screen.rend[j] = buf_rend[i];
750
751 if (!spec) /* line length may not equal TermWin.ncol */
752 scr_blank_screen_mem (screen.text, screen.rend, 750 scr_blank_screen_mem (screen.text, screen.rend, (unsigned int)j, rstyle);
753 (unsigned int)j, rstyle);
754 }
755 751
756 return count; 752 return count;
757} 753}
758 754
759/* ------------------------------------------------------------------------- */ 755/* ------------------------------------------------------------------------- */
777 773
778 D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len)); 774 D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len));
779 ZERO_SCROLLBACK (); 775 ZERO_SCROLLBACK ();
780 if (nlines > 0) 776 if (nlines > 0)
781 { 777 {
782 nlines += (screen.cur.row - screen.bscroll); 778 nlines += screen.cur.row - screen.bscroll;
783 if ((nlines > 0) 779 if ((nlines > 0)
784 && (screen.tscroll == 0) 780 && (screen.tscroll == 0)
785 && (screen.bscroll == (TermWin.nrow - 1))) 781 && (screen.bscroll == (TermWin.nrow - 1)))
786 { 782 {
787 /* _at least_ this many lines need to be scrolled */ 783 /* _at least_ this many lines need to be scrolled */
790 } 786 }
791 } 787 }
792#ifdef DEBUG_STRICT 788#ifdef DEBUG_STRICT
793 assert (screen.cur.col < last_col); 789 assert (screen.cur.col < last_col);
794 assert ((screen.cur.row < TermWin.nrow) 790 assert ((screen.cur.row < TermWin.nrow)
795 && (screen.cur.row >= - (int32_t)TermWin.nscrolled)); 791 && (screen.cur.row >= - (int32_t)TermWin.nscrolled));
796#else /* drive with your eyes closed */ 792#else /* drive with your eyes closed */
797 MIN_IT (screen.cur.col, last_col - 1); 793 MIN_IT (screen.cur.col, last_col - 1);
798 MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); 794 MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1);
799 MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled); 795 MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled);
800#endif 796#endif
867 scr_insdel_chars (1, INSERT); 863 scr_insdel_chars (1, INSERT);
868 864
869 // rely on wcwidth to tell us the character width, at least for non-latin1 865 // rely on wcwidth to tell us the character width, at least for non-latin1
870 // do wcwidth before further replacements, as wcwidth says that line-drawing 866 // do wcwidth before further replacements, as wcwidth says that line-drawing
871 // characters have width -1 (DOH!) on GNU/Linux sometimes. 867 // characters have width -1 (DOH!) on GNU/Linux sometimes.
872 int width = c < 256 ? 1 : wcwidth (c); 868 int width = c < 0x100 ? 1 : wcwidth (c);
873 869
874 if (charsets[screen.charset] == '0') // DEC SPECIAL 870 if (charsets[screen.charset] == '0') // DEC SPECIAL
875 { 871 {
876 // vt100 special graphics and line drawing 872 // vt100 special graphics and line drawing
877 static uint16_t vt100_0[32] = { // 5f .. 7e 873 static uint16_t vt100_0[32] = { // 5f .. 7e
886 c = vt100_0[c - 0x5f]; 882 c = vt100_0[c - 0x5f];
887 width = 1; 883 width = 1;
888 } 884 }
889 } 885 }
890 886
891 if (width > 0) 887 if (width != 0)
892 { 888 {
893#if !UNICODE_3 && ENABLE_COMBINING 889#if !UNICODE_3 && ENABLE_COMBINING
894 // trim characters we can't store directly :( 890 // trim characters we can't store directly :(
895 if (c >= 0x10000) 891 if (c >= 0x10000)
896 c = rxvt_composite.compose (c); // map to lower 16 bits 892 c = rxvt_composite.compose (c); // map to lower 16 bits
897#endif 893#endif
898 rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); 894 bool bold = (Options & Opt_realBold) && ((rstyle & RS_Bold) != 0);
895 rend_t rend = SET_FONT (rstyle,
896 c > 0x7f || bold || c < 0x20
897 ? TermWin.fontset->find_font (c, bold)
898 : TermWin.ascii_map [c - 0x20]);
899 899
900 do 900 do
901 { 901 {
902 stp[screen.cur.col] = c; 902 stp[screen.cur.col] = c;
903 srp[screen.cur.col] = rend; 903 srp[screen.cur.col] = rend;
1236 default: 1236 default:
1237 return; 1237 return;
1238 } 1238 }
1239 1239
1240 if (screen.text[row]) 1240 if (screen.text[row])
1241 scr_blank_line (& (screen.text[row][col]), 1241 scr_blank_line (&screen.text[row][col], &screen.rend[row][col], num, rstyle);
1242 & (screen.rend[row][col]), num, rstyle);
1243 else 1242 else
1244 scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); 1243 scr_blank_screen_mem (screen.text, screen.rend, row, rstyle);
1245} 1244}
1246 1245
1247/* ------------------------------------------------------------------------- */ 1246/* ------------------------------------------------------------------------- */
1285 break; 1284 break;
1286 default: 1285 default:
1287 return; 1286 return;
1288 } 1287 }
1289 1288
1290 refresh_type |= REFRESH_BOUNDS;
1291
1292 if (selection.op && current_screen == selection.screen 1289 if (selection.op && current_screen == selection.screen
1293 && ((selection.beg.row >= row && selection.beg.row <= row + num) 1290 && ((selection.beg.row >= row && selection.beg.row <= row + num)
1294 || (selection.end.row >= row 1291 || (selection.end.row >= row
1295 && selection.end.row <= row + num))) 1292 && selection.end.row <= row + num)))
1296 CLEAR_SELECTION (); 1293 CLEAR_SELECTION ();
1743 row_col_t rc[RC_COUNT]; 1740 row_col_t rc[RC_COUNT];
1744 1741
1745 if (drawn_text == NULL) /* sanity check */ 1742 if (drawn_text == NULL) /* sanity check */
1746 return; 1743 return;
1747 1744
1745#ifndef NO_SLOW_LINK_SUPPORT
1746 if (refresh_type == FAST_REFRESH && !display->is_local)
1747 {
1748 y = 0;
1749 height = TermWin.height;
1750 }
1751#endif
1752
1748#ifdef DEBUG_STRICT 1753#ifdef DEBUG_STRICT
1749 x = max (x, (int)TermWin.int_bwidth); 1754 x = max (x, 0);
1750 x = min (x, (int)TermWin.width); 1755 x = min (x, (int)TermWin.width);
1751 y = max (y, (int)TermWin.int_bwidth); 1756 y = max (y, 0);
1752 y = min (y, (int)TermWin.height); 1757 y = min (y, (int)TermWin.height);
1753#endif 1758#endif
1754 1759
1755 /* round down */ 1760 /* round down */
1756 rc[PART_BEG].col = Pixel2Col (x); 1761 rc[PART_BEG].col = Pixel2Col (x);
1767 } 1772 }
1768 1773
1769 D_SCREEN ((stderr, "rxvt_scr_expose (x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)- (c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); 1774 D_SCREEN ((stderr, "rxvt_scr_expose (x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)- (c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row));
1770 1775
1771 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1776 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1772 fill_text (& (drawn_text[i][rc[PART_BEG].col]), 0, 1777 fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1773 (rc[PART_END].col - rc[PART_BEG].col + 1));
1774 1778
1775 if (refresh) 1779 if (refresh)
1776 scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); 1780 scr_refresh (SLOW_REFRESH);
1777} 1781}
1778 1782
1779/* ------------------------------------------------------------------------- */ 1783/* ------------------------------------------------------------------------- */
1780/* 1784/*
1781 * Refresh the entire screen 1785 * Refresh the entire screen
1816 * direction should be UP or DN 1820 * direction should be UP or DN
1817 */ 1821 */
1818int 1822int
1819rxvt_term::scr_page (enum page_dirn direction, int nlines) 1823rxvt_term::scr_page (enum page_dirn direction, int nlines)
1820{ 1824{
1821 int n; 1825 int n;
1822 uint16_t oldviewstart; 1826 uint16_t oldviewstart;
1823 1827
1824 D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start)); 1828 D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start));
1825#ifdef DEBUG_STRICT 1829#ifdef DEBUG_STRICT
1826 assert ((nlines >= 0) && (nlines <= TermWin.nrow)); 1830 assert ((nlines >= 0) && (nlines <= TermWin.nrow));
1827#endif 1831#endif
1923 ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) 1927 ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2)
1924 1928
1925void 1929void
1926rxvt_term::scr_refresh (unsigned char refresh_type) 1930rxvt_term::scr_refresh (unsigned char refresh_type)
1927{ 1931{
1928 unsigned char clearfirst, /* first character writes before cell */
1929 clearlast, /* last character writes beyond cell */
1930 must_clear, /* use draw_string not draw_image_string */ 1932 unsigned char must_clear, /* use draw_string not draw_image_string */
1931 rvid, /* reverse video this position */ 1933 rvid, /* reverse video this position */
1932 showcursor; /* show the cursor */ 1934 showcursor; /* show the cursor */
1933 int16_t col, row, /* column/row we're processing */ 1935 int16_t col, row, /* column/row we're processing */
1934 ocrow; /* old cursor row */ 1936 ocrow; /* old cursor row */
1935 int i, /* tmp */ 1937 int i, /* tmp */
1944 return; 1946 return;
1945 1947
1946 /* 1948 /*
1947 * A: set up vars 1949 * A: set up vars
1948 */ 1950 */
1949 clearfirst = clearlast = must_clear = 0; 1951 must_clear = 0;
1950 1952
1951 refresh_count = 0; 1953 refresh_count = 0;
1952 1954
1953 row_offset = TermWin.saveLines - TermWin.view_start; 1955 row_offset = TermWin.saveLines - TermWin.view_start;
1954
1955 if ((refresh_type & REFRESH_BOUNDS))
1956 {
1957 clearfirst = clearlast = 1;
1958 refresh_type &= ~REFRESH_BOUNDS;
1959 }
1960 1956
1961#ifdef XPM_BACKGROUND 1957#ifdef XPM_BACKGROUND
1962 must_clear |= (bgPixmap.pixmap != None); 1958 must_clear |= (bgPixmap.pixmap != None);
1963#endif 1959#endif
1964#ifdef TRANSPARENT 1960#ifdef TRANSPARENT
2052 /* 2048 /*
2053 * D: CopyArea pass - very useful for slower links 2049 * D: CopyArea pass - very useful for slower links
2054 * This has been deliberately kept simple. 2050 * This has been deliberately kept simple.
2055 */ 2051 */
2056 i = num_scr; 2052 i = num_scr;
2053 if (!display->is_local
2057 if (refresh_type == FAST_REFRESH && num_scr_allow && i 2054 && refresh_type == FAST_REFRESH && num_scr_allow && i
2058 && abs (i) < TermWin.nrow && !must_clear) 2055 && abs (i) < TermWin.nrow && !must_clear)
2059 { 2056 {
2060 int16_t nits; 2057 int16_t nits;
2061 int j; 2058 int j;
2062 rend_t *drp2; 2059 rend_t *drp2;
2204 rend = GET_ATTR (rend); 2201 rend = GET_ATTR (rend);
2205 2202
2206 rvid = !!(rend & RS_RVid); 2203 rvid = !!(rend & RS_RVid);
2207 2204
2208#ifndef NO_BOLD_UNDERLINE_REVERSE 2205#ifndef NO_BOLD_UNDERLINE_REVERSE
2209 if (rend & RS_Bold && fore == Color_fg) 2206 if (rend & RS_Bold && fore == Color_fg && !(Options & Opt_realBold))
2210 { 2207 {
2211 if (ISSET_PIXCOLOR (Color_BD)) 2208 if (ISSET_PIXCOLOR (Color_BD))
2212 fore = Color_BD; 2209 fore = Color_BD;
2213 else 2210 else
2214 rvid = !rvid; 2211 rvid = !rvid;
2232 back = Color_RV; 2229 back = Color_RV;
2233#endif 2230#endif
2234 } 2231 }
2235 2232
2236#ifdef TEXT_BLINK 2233#ifdef TEXT_BLINK
2237 if (rend & RS_Blink && back == Color_bg) 2234 if (rend & RS_Blink && (back == Color_bg || fore == Color_bg))
2238 { 2235 {
2239 if (!text_blink_ev.active) 2236 if (!text_blink_ev.active)
2240 { 2237 {
2241 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 2238 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
2242 hidden_text = 0; 2239 hidden_text = 0;
2272 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, Color_bg); 2269 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, Color_bg);
2273 } 2270 }
2274 else 2271 else
2275 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); 2272 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back);
2276 2273
2277 if ((rend & RS_Uline) && (font->descent > 1)) 2274 if (rend & RS_Uline && font->descent > 1 && fore != back)
2278 XDrawLine (display->display, drawBuffer, TermWin.gc, 2275 XDrawLine (display->display, drawBuffer, TermWin.gc,
2279 xpixel, ypixel + font->ascent + 1, 2276 xpixel, ypixel + font->ascent + 1,
2280 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2277 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2281 } /* for (col....) */ 2278 } /* for (col....) */
2282 } /* for (row....) */ 2279 } /* for (row....) */
2317 /* 2314 /*
2318 * H: cleanup selection 2315 * H: cleanup selection
2319 */ 2316 */
2320 scr_reverse_selection (); 2317 scr_reverse_selection ();
2321 2318
2322 /*
2323 * I: other general cleanup
2324 */
2325 if (clearfirst && TermWin.int_bwidth)
2326 /*
2327 * clear the whole screen height, note that width == 0 is treated
2328 * specially by XClearArea
2329 */
2330 XClearArea (display->display, TermWin.vt, 0, 0,
2331 (unsigned int)TermWin.int_bwidth,
2332 (unsigned int)TermWin_TotalHeight (), False);
2333
2334 if (clearlast && TermWin.int_bwidth)
2335 /*
2336 * clear the whole screen height, note that width == 0 is treated
2337 * specially by XClearArea
2338 */
2339 XClearArea (display->display, TermWin.vt,
2340 TermWin.width + TermWin.int_bwidth, 0,
2341 (unsigned int)TermWin.int_bwidth,
2342 (unsigned int)TermWin_TotalHeight (), False);
2343
2344 if (refresh_type & SMOOTH_REFRESH) 2319 if (refresh_type & SMOOTH_REFRESH)
2345 XSync (display->display, False); 2320 XFlush (display->display);
2346 2321
2347 num_scr = 0; 2322 num_scr = 0;
2348 num_scr_allow = 1; 2323 num_scr_allow = 1;
2349 want_refresh = 0; /* screen is current */ 2324 want_refresh = 0; /* screen is current */
2350} 2325}
2613 2588
2614 nread += ct.nitems; 2589 nread += ct.nitems;
2615 2590
2616 char **cl; 2591 char **cl;
2617 int cr; 2592 int cr;
2618 if (XmbTextPropertyToTextList (display->display, &ct, &cl, 2593 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl)
2619 &cr) >= 0 && cl)
2620 { 2594 {
2621 for (int i = 0; i < cr; i++) 2595 for (int i = 0; i < cr; i++)
2622 paste ((unsigned char *)cl[i], STRLEN (cl[i])); 2596 paste ((unsigned char *)cl[i], STRLEN (cl[i]));
2623 2597
2624 XFreeStringList (cl); 2598 XFreeStringList (cl);
3519 pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; 3493 pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace;
3520} 3494}
3521 3495
3522#endif 3496#endif
3523/* ------------------------------------------------------------------------- */ 3497/* ------------------------------------------------------------------------- */
3524
3525/* ------------------------------------------------------------------------- *
3526 * DEBUG ROUTINES *
3527 * ------------------------------------------------------------------------- */
3528#if 0
3529void
3530rxvt_debug_colors (void)
3531{
3532 int color;
3533 const char *name[] =
3534 {
3535 "fg", "bg",
3536 "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"
3537 };
3538
3539 fprintf (stderr, "Color ( ");
3540 if (rstyle & RS_RVid)
3541 fprintf (stderr, "rvid ");
3542 if (rstyle & RS_Bold)
3543 fprintf (stderr, "bold ");
3544 if (rstyle & RS_Blink)
3545 fprintf (stderr, "blink ");
3546 if (rstyle & RS_Uline)
3547 fprintf (stderr, "uline ");
3548 fprintf (stderr, "): ");
3549
3550 color = GET_FGCOLOR (rstyle);
3551#ifndef NO_BRIGHTCOLOR
3552 if (color >= minBrightCOLOR && color <= maxBrightCOLOR)
3553 {
3554 color -= (minBrightCOLOR - minCOLOR);
3555 fprintf (stderr, "bright ");
3556 }
3557#endif
3558 fprintf (stderr, "%s on ", name[color]);
3559
3560 color = GET_BGCOLOR (rstyle);
3561#ifndef NO_BRIGHTCOLOR
3562 if (color >= minBrightCOLOR && color <= maxBrightCOLOR)
3563 {
3564 color -= (minBrightCOLOR - minCOLOR);
3565 fprintf (stderr, "bright ");
3566 }
3567#endif
3568 fprintf (stderr, "%s\n", name[color]);
3569}
3570#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines