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.253 by root, Fri Jan 27 18:36:43 2006 UTC vs.
Revision 1.349 by root, Thu Oct 14 23:12:11 2010 UTC

1/*--------------------------------*-C-*--------------------------------------* 1/*---------------------------------------------------------------------------*
2 * File: screen.C 2 * File: screen.C
3 *---------------------------------------------------------------------------* 3 *---------------------------------------------------------------------------*
4 * 4 *
5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
6 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
26 26
27#include "../config.h" /* NECESSARY */ 27#include "../config.h" /* NECESSARY */
28#include "rxvt.h" /* NECESSARY */ 28#include "rxvt.h" /* NECESSARY */
29#include "rxvtperl.h" /* NECESSARY */ 29#include "rxvtperl.h" /* NECESSARY */
30 30
31#include <X11/Xmd.h> /* get the typedef for CARD32 */
32
33#include <inttypes.h> 31#include <inttypes.h>
34 32
35#include "salloc.C" // HACK, should be a seperate compile! 33#include "salloc.C" // HACK, should be a separate compile!
36 34
35static inline void
37inline void fill_text (text_t *start, text_t value, int len) 36fill_text (text_t *start, text_t value, int len)
38{ 37{
39 while (len--) 38 while (len--)
40 *start++ = value; 39 *start++ = value;
41} 40}
42 41
47 46
48/* ------------------------------------------------------------------------- * 47/* ------------------------------------------------------------------------- *
49 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * 48 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES *
50 * ------------------------------------------------------------------------- */ 49 * ------------------------------------------------------------------------- */
51#define ZERO_SCROLLBACK() \ 50#define ZERO_SCROLLBACK() \
52 if (OPTION (Opt_scrollTtyOutput)) \ 51 if (option (Opt_scrollTtyOutput)) \
53 view_start = 0 52 view_start = 0
54#define CLEAR_SELECTION() \ 53#define CLEAR_SELECTION() \
55 selection.beg.row = selection.beg.col \ 54 selection.beg.row = selection.beg.col \
56 = selection.end.row = selection.end.col = 0 55 = selection.end.row = selection.end.col = 0
57#define CLEAR_ALL_SELECTION() \ 56#define CLEAR_ALL_SELECTION() \
85 ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) 84 ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col)
86#define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ 85#define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \
87 ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) 86 ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col)
88 87
89/* 88/*
90 * CLEAR_ROWS : clear <num> rows starting from row <row>
91 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> 89 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y>
92 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour
93 */ 90 */
94#define drawBuffer vt
95
96#define CLEAR_ROWS(row, num) \
97 if (mapped) \
98 XClearArea (xdisp, drawBuffer, 0, \
99 Row2Pixel (row), (unsigned int)width, \
100 (unsigned int)Height2Pixel (num), False)
101
102#define CLEAR_CHARS(x, y, num) \ 91#define CLEAR_CHARS(x, y, num) \
103 if (mapped) \ 92 if (mapped) \
104 XClearArea (xdisp, drawBuffer, x, y, \ 93 XClearArea (dpy, vt, x, y, \
105 (unsigned int)Width2Pixel (num), \ 94 (unsigned int)Width2Pixel (num), \
106 (unsigned int)Height2Pixel (1), False) 95 (unsigned int)Height2Pixel (1), False)
107
108#define ERASE_ROWS(row, num) \
109 XFillRectangle (xdisp, drawBuffer, gc, \
110 0, Row2Pixel (row), \
111 (unsigned int)width, \
112 (unsigned int)Height2Pixel (num))
113 96
114/* ------------------------------------------------------------------------- * 97/* ------------------------------------------------------------------------- *
115 * SCREEN `COMMON' ROUTINES * 98 * SCREEN `COMMON' ROUTINES *
116 * ------------------------------------------------------------------------- */ 99 * ------------------------------------------------------------------------- */
117 100
126 width = ncol; 109 width = ncol;
127 } 110 }
128 111
129 l.touch (); 112 l.touch ();
130 113
131 efs &= ~RS_baseattrMask; 114 efs &= ~RS_baseattrMask; // remove italic etc. fontstyles
132 efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); 115 efs = SET_FONT (efs, FONTSET (efs)->find_font (' '));
133 116
134 text_t *et = l.t + col; 117 text_t *et = l.t + col;
135 rend_t *er = l.r + col; 118 rend_t *er = l.r + col;
136 119
148{ 131{
149 scr_blank_line (l, 0, ncol, efs); 132 scr_blank_line (l, 0, ncol, efs);
150 133
151 l.l = 0; 134 l.l = 0;
152 l.f = 0; 135 l.f = 0;
136}
137
138// nuke a single wide character at the given column
139void
140rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW
141{
142 // find begin
143 while (col > 0 && l.t[col] == NOCHAR)
144 col--;
145
146 rend_t rend = l.r[col] & ~RS_baseattrMask;
147 rend = SET_FONT (rend, FONTSET (rend)->find_font (' '));
148
149 // found start, nuke
150 do {
151 l.t[col] = ' ';
152 l.r[col] = rend;
153 col++;
154 } while (col < ncol && l.t[col] == NOCHAR);
153} 155}
154 156
155/* ------------------------------------------------------------------------- * 157/* ------------------------------------------------------------------------- *
156 * SCREEN INITIALISATION * 158 * SCREEN INITIALISATION *
157 * ------------------------------------------------------------------------- */ 159 * ------------------------------------------------------------------------- */
158 160
159void 161void
160rxvt_term::scr_reset () 162rxvt_term::scr_reset ()
161{ 163{
162#if ENABLE_OVERLAY
163 scr_overlay_off ();
164#endif
165
166 view_start = 0; 164 view_start = 0;
167 num_scr = 0; 165 num_scr = 0;
168 166
169 if (ncol == 0) 167 if (ncol == 0)
170 ncol = 80; 168 ncol = 80;
172 if (nrow == 0) 170 if (nrow == 0)
173 nrow = 24; 171 nrow = 24;
174 172
175 if (ncol == prev_ncol && nrow == prev_nrow) 173 if (ncol == prev_ncol && nrow == prev_nrow)
176 return; 174 return;
177
178 if (current_screen != PRIMARY)
179 scr_swap_screen ();
180 175
181 // we need at least two lines for wrapping to work correctly 176 // we need at least two lines for wrapping to work correctly
182 while (nrow + saveLines < 2) 177 while (nrow + saveLines < 2)
183 { 178 {
184 //TODO//FIXME 179 //TODO//FIXME
237 selection.text = NULL; 232 selection.text = NULL;
238 selection.len = 0; 233 selection.len = 0;
239 selection.op = SELECTION_CLEAR; 234 selection.op = SELECTION_CLEAR;
240 selection.screen = PRIMARY; 235 selection.screen = PRIMARY;
241 selection.clicks = 0; 236 selection.clicks = 0;
242 rvideo_state = rvideo_mode = false; 237 selection.clip_text = NULL;
238 selection.clip_len = 0;
243 } 239 }
244 else 240 else
245 { 241 {
246 /* 242 /*
247 * add or delete rows as appropriate 243 * add or delete rows as appropriate
276 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); 272 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE);
277 } 273 }
278 274
279 line_t *old_buf = row_buf; 275 line_t *old_buf = row_buf;
280 row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); 276 row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t));
281 277
282 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 278 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
283 int pend = MOD (term_start + top_row , prev_total_rows); 279 int pend = MOD (term_start + top_row , prev_total_rows);
284 int q = total_rows; // rewrapped row 280 int q = total_rows; // rewrapped row
285 281
286 if (top_row) 282 if (top_row)
287 { 283 {
288 // Re-wrap lines. This is rather ugly, possibly because I am too dumb 284 // Re-wrap lines. This is rather ugly, possibly because I am too dumb
289 // to come up with a lean and mean algorithm. 285 // to come up with a lean and mean algorithm.
286 // TODO: maybe optimise when width didn't change
290 287
291 row_col_t ocur = screen.cur; 288 row_col_t ocur = screen.cur;
292 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 289 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
293 290
294 do 291 do
295 { 292 {
296 p = MOD (p - 1, prev_total_rows); 293 p = MOD (p - 1, prev_total_rows);
297#ifdef DEBUG_STRICT
298 assert (old_buf [MOD (p, prev_total_rows)].t); 294 assert (old_buf [MOD (p, prev_total_rows)].t);
299#endif
300 int plines = 1; 295 int plines = 1;
301 int llen = old_buf [MOD (p, prev_total_rows)].l; 296 int llen = old_buf [MOD (p, prev_total_rows)].l;
302 297
303 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) 298 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
304 { 299 {
330 int qcol = 0; 325 int qcol = 0;
331 326
332 // see below for cursor adjustment rationale 327 // see below for cursor adjustment rationale
333 if (p == ocur.row) 328 if (p == ocur.row)
334 screen.cur.row = q - (total_rows - nrow); 329 screen.cur.row = q - (total_rows - nrow);
335 330
336 // fill a single destination line 331 // fill a single destination line
337 while (lofs < llen && qcol < ncol) 332 while (lofs < llen && qcol < ncol)
338 { 333 {
339 int prow = lofs / prev_ncol; 334 int prow = lofs / prev_ncol;
340 int pcol = lofs % prev_ncol; 335 int pcol = lofs % prev_ncol;
366 } 361 }
367 while (p != pend && q > 0); 362 while (p != pend && q > 0);
368 363
369 term_start = total_rows - nrow; 364 term_start = total_rows - nrow;
370 top_row = q - term_start; 365 top_row = q - term_start;
371 366
372 // make sure all terminal lines exist 367 // make sure all terminal lines exist
373 while (top_row > 0) 368 while (top_row > 0)
374 scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); 369 scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE);
375 } 370 }
376 else 371 else
377 { 372 {
378 // if no scrollback exists (yet), wing, instead of wrap 373 // if no scrollback exists (yet), wing, instead of wrap
379 374
380 for (int row = min (nrow, prev_nrow); row--; ) 375 for (int row = min (nrow, prev_nrow); row--; )
381 { 376 {
382 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; 377 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)];
383 line_t &qline = row_buf [row]; 378 line_t &qline = row_buf [row];
384 379
398 delete old_ta; 393 delete old_ta;
399 delete old_ra; 394 delete old_ra;
400 395
401 clamp_it (screen.cur.row, 0, nrow - 1); 396 clamp_it (screen.cur.row, 0, nrow - 1);
402 clamp_it (screen.cur.col, 0, ncol - 1); 397 clamp_it (screen.cur.col, 0, ncol - 1);
398 }
403 399
404 free (tabs); 400 free (tabs);
405 } 401 tabs = (char *)rxvt_malloc (ncol);
402
403 for (int col = ncol; --col; )
404 tabs [col] = col % TABSIZE == 0;
406 405
407 CLEAR_ALL_SELECTION (); 406 CLEAR_ALL_SELECTION ();
408 407
409 prev_nrow = nrow; 408 prev_nrow = nrow;
410 prev_ncol = ncol; 409 prev_ncol = ncol;
411
412 tabs = (char *)rxvt_malloc (ncol * sizeof (char));
413
414 for (int col = ncol; col--; )
415 tabs [col] = col % TABSIZE == 0;
416
417 if (current_screen != PRIMARY)
418 scr_swap_screen ();
419 410
420 tt_winch (); 411 tt_winch ();
421 412
422 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 413 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
423} 414}
435 delete ralloc; ralloc = 0; 426 delete ralloc; ralloc = 0;
436 427
437 free (row_buf); 428 free (row_buf);
438 free (swap_buf); 429 free (swap_buf);
439 free (drawn_buf); 430 free (drawn_buf);
431 row_buf = 0; // signal that we freed all the arrays above
432
440 free (tabs); 433 free (tabs);
441 434 tabs = 0;
442 row_buf = 0; // signal that we freed all the arrays
443 } 435 }
444} 436}
445 437
446/* ------------------------------------------------------------------------- */ 438/* ------------------------------------------------------------------------- */
447/* 439/*
448 * Hard reset 440 * Hard/Soft reset
449 */ 441 */
450void 442void
451rxvt_term::scr_poweron () 443rxvt_term::scr_poweron ()
452{ 444{
453 scr_release (); 445 scr_release ();
454 prev_nrow = prev_ncol = 0; 446 prev_nrow = prev_ncol = 0;
447 rvideo_mode = false;
448 scr_soft_reset ();
455 scr_reset (); 449 scr_reset ();
456 450
457 scr_clear (true); 451 scr_clear (true);
458 scr_refresh (); 452 scr_refresh ();
453}
454
455void
456rxvt_term::scr_soft_reset ()
457{
458 /* only affects modes, nothing drastic such as clearing the screen */
459#if ENABLE_OVERLAY
460 scr_overlay_off ();
461#endif
462
463 if (current_screen != PRIMARY)
464 scr_swap_screen ();
465
466 scr_scroll_region (0, MAX_ROWS - 1);
467 scr_rendition (0, ~RS_None);
468 scr_insert_mode (0);
459} 469}
460 470
461/* ------------------------------------------------------------------------- * 471/* ------------------------------------------------------------------------- *
462 * PROCESS SCREEN COMMANDS * 472 * PROCESS SCREEN COMMANDS *
463 * ------------------------------------------------------------------------- */ 473 * ------------------------------------------------------------------------- */
501 } 511 }
502 512
503 /* boundary check in case screen size changed between SAVE and RESTORE */ 513 /* boundary check in case screen size changed between SAVE and RESTORE */
504 min_it (s->cur.row, nrow - 1); 514 min_it (s->cur.row, nrow - 1);
505 min_it (s->cur.col, ncol - 1); 515 min_it (s->cur.col, ncol - 1);
506#ifdef DEBUG_STRICT
507 assert (s->cur.row >= 0); 516 assert (s->cur.row >= 0);
508 assert (s->cur.col >= 0); 517 assert (s->cur.col >= 0);
509#endif
510} 518}
511 519
512void 520void
513rxvt_term::scr_swap_screen () 521rxvt_term::scr_swap_screen ()
514{ 522{
515 if (!OPTION (Opt_secondaryScreen)) 523 if (!option (Opt_secondaryScreen))
516 return; 524 return;
517 525
518 for (int i = prev_nrow; i--; ) 526 for (int i = prev_nrow; i--; )
519 ::swap (ROW(i), swap_buf [i]); 527 ::swap (ROW(i), swap_buf [i]);
520 528
539 want_refresh = 1; 547 want_refresh = 1;
540 view_start = 0; 548 view_start = 0;
541 549
542 selection_check (2); /* check for boundary cross */ 550 selection_check (2); /* check for boundary cross */
543 551
544 int i = current_screen; current_screen = scrn; scrn = i; 552 current_screen = scrn;
545 553
546#if NSCREENS 554#if NSCREENS
547 if (OPTION (Opt_secondaryScreen)) 555 if (option (Opt_secondaryScreen))
548 { 556 {
549 num_scr = 0; 557 num_scr = 0;
550 558
551 scr_swap_screen (); 559 scr_swap_screen ();
552 560
555 screen.flags |= Screen_VisibleCursor; 563 screen.flags |= Screen_VisibleCursor;
556 swap.flags |= Screen_VisibleCursor; 564 swap.flags |= Screen_VisibleCursor;
557 } 565 }
558 else 566 else
559#endif 567#endif
560 if (OPTION (Opt_secondaryScroll)) 568 if (option (Opt_secondaryScroll))
561 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 569 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
562} 570}
563 571
564// clear WrapNext indicator, solidifying position on next line 572// clear WrapNext indicator, solidifying position on next line
565void 573void
598/* 606/*
599 * Change the rendition style for following text 607 * Change the rendition style for following text
600 */ 608 */
601void 609void
602rxvt_term::scr_rendition (int set, int style) NOTHROW 610rxvt_term::scr_rendition (int set, int style) NOTHROW
603 { 611{
604 if (set) 612 if (set)
605 rstyle |= style; 613 rstyle |= style;
606 else if (style == ~RS_None) 614 else if (style == ~RS_None)
607 rstyle = DEFAULT_RSTYLE; 615 rstyle = DEFAULT_RSTYLE;
608 else 616 else
609 rstyle &= ~style; 617 rstyle &= ~style;
610 } 618}
611 619
612/* ------------------------------------------------------------------------- */ 620/* ------------------------------------------------------------------------- */
613/* 621/*
614 * Scroll text between <row1> and <row2> inclusive, by <count> lines 622 * Scroll text between <row1> and <row2> inclusive, by <count> lines
615 * count positive ==> scroll up 623 * count positive ==> scroll up
624 want_refresh = 1; 632 want_refresh = 1;
625 num_scr += count; 633 num_scr += count;
626 634
627 if (count > 0 635 if (count > 0
628 && row1 == 0 636 && row1 == 0
629 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) 637 && (current_screen == PRIMARY || option (Opt_secondaryScroll)))
630 { 638 {
631 top_row = max (top_row - count, -saveLines); 639 top_row = max (top_row - count, -saveLines);
632 640
633 // scroll everything up 'count' lines 641 // scroll everything up 'count' lines
634 term_start = (term_start + count) % total_rows; 642 term_start = (term_start + count) % total_rows;
640 l.touch (); 648 l.touch ();
641 } 649 }
642 650
643 // erase newly scrolled-in lines 651 // erase newly scrolled-in lines
644 for (int i = count; i--; ) 652 for (int i = count; i--; )
653 {
654 line_t &l = ROW(nrow - 1 - i);
655
656 // optimize if already cleared, can be significant on slow machines
657 // could be rolled into scr_blank_screen_mem
658 if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask)))
659 {
660 scr_blank_line (l, 0, l.l, rstyle);
661 l.l = 0;
662 l.f = 0;
663 }
664 else
645 scr_blank_screen_mem (ROW(nrow - 1 - i), rstyle); 665 scr_blank_screen_mem (l, rstyle);
666 }
646 667
647 // now copy lines below the scroll region bottom to the 668 // now copy lines below the scroll region bottom to the
648 // bottom of the screen again, so they look as if they 669 // bottom of the screen again, so they look as if they
649 // hadn't moved. 670 // hadn't moved.
650 for (int i = nrow; --i > row2; ) 671 for (int i = nrow; --i > row2; )
653 line_t &l2 = ROW(i); 674 line_t &l2 = ROW(i);
654 675
655 ::swap (l1, l2); 676 ::swap (l1, l2);
656 l2.touch (); 677 l2.touch ();
657 } 678 }
658 679
659 // move and/or clear selection, if any 680 // move and/or clear selection, if any
660 if (selection.op && current_screen == selection.screen) 681 if (selection.op && current_screen == selection.screen)
661 { 682 {
662 selection.beg.row -= count; 683 selection.beg.row -= count;
663 selection.end.row -= count; 684 selection.end.row -= count;
671 selection.op = SELECTION_CLEAR; 692 selection.op = SELECTION_CLEAR;
672 } 693 }
673 } 694 }
674 695
675 // finally move the view window, if desired 696 // finally move the view window, if desired
676 if (OPTION (Opt_scrollWithBuffer) 697 if (option (Opt_scrollWithBuffer)
677 && view_start != 0 698 && view_start != 0
678 && view_start != -saveLines) 699 && view_start != -saveLines)
679 scr_page (UP, count); 700 scr_page (UP, count);
680 701
681 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 702 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
699 { 720 {
700 /* move selected region too */ 721 /* move selected region too */
701 selection.beg.row -= count; 722 selection.beg.row -= count;
702 selection.end.row -= count; 723 selection.end.row -= count;
703 selection.mark.row -= count; 724 selection.mark.row -= count;
704 725
705 selection_check (0); 726 selection_check (0);
706 } 727 }
707 } 728 }
708 729
709 // use a simple and robust scrolling algorithm, this 730 // use a simple and robust scrolling algorithm, this
761 scr_scroll_text (screen.tscroll, screen.bscroll, minlines); 782 scr_scroll_text (screen.tscroll, screen.bscroll, minlines);
762 screen.cur.row -= minlines; 783 screen.cur.row -= minlines;
763 } 784 }
764 } 785 }
765 786
766#ifdef DEBUG_STRICT
767 assert (screen.cur.col < ncol); 787 assert (screen.cur.col < ncol);
768 assert (screen.cur.row < nrow 788 assert (screen.cur.row < nrow
769 && screen.cur.row >= top_row); 789 && screen.cur.row >= top_row);
770#endif
771 int row = screen.cur.row; 790 int row = screen.cur.row;
772 791
773 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 792 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
774 793
775 line_t *line = &ROW(row); 794 line_t *line = &ROW(row);
776 795
777 while (str < strend) 796 while (str < strend)
778 { 797 {
779 c = (unicode_t)*str++; // convert to rxvt-unicodes representation 798 c = (unicode_t)*str++; // convert to rxvt-unicodes representation
780 799
781 if (c < 0x20) 800 if (expect_false (c < 0x20))
782 if (c == C0_LF) 801 if (c == C0_LF)
783 { 802 {
784 max_it (line->l, screen.cur.col); 803 max_it (line->l, screen.cur.col);
785 804
786 screen.flags &= ~Screen_WrapNext; 805 screen.flags &= ~Screen_WrapNext;
805 { 824 {
806 scr_tab (1, true); 825 scr_tab (1, true);
807 continue; 826 continue;
808 } 827 }
809 828
829 if (expect_false (
810 if (checksel /* see if we're writing within selection */ 830 checksel /* see if we're writing within selection */
811 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 831 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
812 && ROWCOL_IS_BEFORE (screen.cur, selection.end)) 832 && ROWCOL_IS_BEFORE (screen.cur, selection.end)
833 ))
813 { 834 {
814 checksel = 0; 835 checksel = 0;
815 /* 836 /*
816 * If we wrote anywhere in the selected area, kill the selection 837 * If we wrote anywhere in the selected area, kill the selection
817 * XXX: should we kill the mark too? Possibly, but maybe that 838 * XXX: should we kill the mark too? Possibly, but maybe that
818 * should be a similar check. 839 * should be a similar check.
819 */ 840 */
820 CLEAR_SELECTION (); 841 CLEAR_SELECTION ();
821 } 842 }
822 843
823 if (screen.flags & Screen_WrapNext) 844 if (expect_false (screen.flags & Screen_WrapNext))
824 { 845 {
825 scr_do_wrap (); 846 scr_do_wrap ();
826 847
827 line->l = ncol; 848 line->l = ncol;
828 line->is_longer (1); 849 line->is_longer (1);
829 850
830 row = screen.cur.row; 851 row = screen.cur.row;
831 line = &ROW(row); /* _must_ refresh */ 852 line = &ROW(row); /* _must_ refresh */
832 } 853 }
833 854
834 // some utf-8 decoders "decode" surrogate characters: let's fix this. 855 // some utf-8 decoders "decode" surrogate characters: let's fix this.
835 if (IN_RANGE_INC (c, 0xd800, 0xdfff)) 856 if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff)))
836 c = 0xfffd; 857 c = 0xfffd;
837 858
838 // rely on wcwidth to tell us the character width, do wcwidth before 859 // rely on wcwidth to tell us the character width, do wcwidth before
839 // further replacements, as wcwidth might return -1 for the line 860 // further replacements, as wcwidth might return -1 for the line
840 // drawing characters below as they might be invalid in the current 861 // drawing characters below as they might be invalid in the current
841 // locale. 862 // locale.
842 int width = WCWIDTH (c); 863 int width = WCWIDTH (c);
843 864
844 if (charsets [screen.charset] == '0') // DEC SPECIAL 865 if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL
845 { 866 {
846 // vt100 special graphics and line drawing 867 // vt100 special graphics and line drawing
847 // 5f-7e standard vt100 868 // 5f-7e standard vt100
848 // 40-5e rxvt extension for extra curses acs chars 869 // 40-5e rxvt extension for extra curses acs chars
849 static uint16_t vt100_0[62] = { // 41 .. 7e 870 static uint16_t vt100_0[62] = { // 41 .. 7e
862 c = vt100_0[c - 0x41]; 883 c = vt100_0[c - 0x41];
863 width = 1; // vt100 line drawing characters are always single-width 884 width = 1; // vt100 line drawing characters are always single-width
864 } 885 }
865 } 886 }
866 887
867 if (screen.flags & Screen_Insert) 888 if (expect_false (screen.flags & Screen_Insert))
868 scr_insdel_chars (width, INSERT); 889 scr_insdel_chars (width, INSERT);
869 890
870 if (width != 0) 891 if (width != 0)
871 { 892 {
872#if !UNICODE_3 893#if !UNICODE_3
878 c = 0xfffd; 899 c = 0xfffd;
879# endif 900# endif
880#endif 901#endif
881 902
882 // nuke the character at this position, if required 903 // nuke the character at this position, if required
904 if (expect_false (
883 if (line->t[screen.cur.col] == NOCHAR 905 line->t[screen.cur.col] == NOCHAR
884 || (screen.cur.col < ncol - 1 906 || (screen.cur.col < ncol - 1
885 && line->t[screen.cur.col + 1] == NOCHAR)) 907 && line->t[screen.cur.col + 1] == NOCHAR)
908 ))
909 scr_kill_char (*line, screen.cur.col);
910
911 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
912
913 // if the character doesn't fit into the remaining columns...
914 if (expect_false (screen.cur.col > ncol - width && ncol >= width))
886 { 915 {
887 int col = screen.cur.col; 916 if (screen.flags & Screen_Autowrap)
888
889 // find begin
890 while (col > 0 && line->t[col] == NOCHAR)
891 col--;
892
893 rend_t rend = SET_FONT (line->r[col], FONTSET (line->r[col])->find_font (' '));
894
895 // found begin, nuke
896 do { 917 {
897 line->t[col] = ' '; 918 // ... artificially enlargen the previous one
898 line->r[col] = rend; 919 c = NOCHAR;
899 col++;
900 } while (col < ncol && line->t[col] == NOCHAR);
901 }
902
903 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
904
905 // if the character doesn't fit into the remaining columns...
906 if (screen.cur.col > ncol - width && ncol >= width)
907 {
908 // ...output spaces
909 c = ' ';
910 // and try the same character next loop iteration 920 // and try the same character next loop iteration
911 --str; 921 --str;
922 }
923 else
924 screen.cur.col = ncol - width;
912 } 925 }
913 926
914 line->touch (); 927 line->touch ();
915 928
916 do 929 do
917 { 930 {
918 line->t[screen.cur.col] = c; 931 line->t[screen.cur.col] = c;
919 line->r[screen.cur.col] = rend; 932 line->r[screen.cur.col] = rend;
920 933
921 if (screen.cur.col < ncol - 1) 934 if (expect_true (screen.cur.col < ncol - 1))
922 screen.cur.col++; 935 screen.cur.col++;
923 else 936 else
924 { 937 {
925 line->l = ncol; 938 line->l = ncol;
926 if (screen.flags & Screen_Autowrap) 939 if (screen.flags & Screen_Autowrap)
928 break; 941 break;
929 } 942 }
930 943
931 c = NOCHAR; 944 c = NOCHAR;
932 } 945 }
933 while (--width > 0); 946 while (expect_false (--width > 0));
934 947
935 // pad with spaces when overwriting wide character with smaller one 948 // pad with spaces when overwriting wide character with smaller one
936 if (!width) 949 if (expect_false (!width))
937 { 950 {
938 line->touch (); 951 line->touch ();
939 952
940 for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) 953 for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++)
941 { 954 {
942 line->t[c] = ' '; 955 line->t[c] = ' ';
943 line->r[c] = rend; 956 line->r[c] = rend;
944 } 957 }
945 } 958 }
946 } 959 }
960#if ENABLE_COMBINING
947 else // width == 0 961 else // width == 0
948 { 962 {
949#if ENABLE_COMBINING 963 if (c != 0xfeff) // ignore BOM
950 // handle combining characters
951 // we just tag the accent on the previous on-screen character.
952 // this is arguably not correct, but also arguably not wrong.
953 // we don't handle double-width characters nicely yet.
954 line_t *linep;
955 text_t *tp;
956 rend_t *rp;
957
958 if (screen.cur.col > 0)
959 { 964 {
965 // handle combining characters
966 // we just tag the accent on the previous on-screen character.
967 // this is arguably not correct, but also arguably not wrong.
968 // we don't handle double-width characters nicely yet.
969 line_t *linep;
970 text_t *tp;
971 rend_t *rp;
972
973 if (screen.cur.col > 0)
974 {
960 linep = line; 975 linep = line;
961 tp = line->t + screen.cur.col - 1; 976 tp = line->t + screen.cur.col - 1;
962 rp = line->r + screen.cur.col - 1; 977 rp = line->r + screen.cur.col - 1;
978 }
979 else if (screen.cur.row > 0
980 && ROW(screen.cur.row - 1).is_longer ())
981 {
982 linep = &ROW(screen.cur.row - 1);
983 tp = line->t + ncol - 1;
984 rp = line->r + ncol - 1;
985 }
986 else
987 continue;
988
989 linep->touch ();
990
991 while (*tp == NOCHAR && tp > linep->t)
992 tp--, rp--;
993
994 // first try to find a precomposed character
995 unicode_t n = rxvt_compose (*tp, c);
996 if (n == NOCHAR)
997 n = rxvt_composite.compose (*tp, c);
998
999 *tp = n;
1000 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
963 } 1001 }
964 else if (screen.cur.row > 0
965 && ROW(screen.cur.row - 1).is_longer ())
966 {
967 linep = &ROW(screen.cur.row - 1);
968 tp = line->t + ncol - 1;
969 rp = line->r + ncol - 1;
970 } 1002 }
971 else
972 continue;
973
974 linep->touch ();
975
976 while (*tp == NOCHAR && tp > linep->t)
977 tp--, rp--;
978
979 // first try to find a precomposed character
980 unicode_t n = rxvt_compose (*tp, c);
981 if (n == NOCHAR)
982 n = rxvt_composite.compose (*tp, c);
983
984 *tp = n;
985 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
986#endif 1003#endif
987 }
988 } 1004 }
989 1005
990 max_it (line->l, screen.cur.col); 1006 max_it (line->l, screen.cur.col);
991 1007
992#ifdef DEBUG_STRICT
993 assert (screen.cur.row >= 0); 1008 assert (screen.cur.row >= 0);
994#endif
995} 1009}
996 1010
997/* ------------------------------------------------------------------------- */ 1011/* ------------------------------------------------------------------------- */
998/* 1012/*
999 * Process Backspace. Move back the cursor back a position, wrap if have to 1013 * Process Backspace. Move back the cursor back a position, wrap if have to
1000 * XTERM_SEQ: CTRL-H 1014 * XTERM_SEQ: CTRL-H
1001 */ 1015 */
1002void 1016void
1003rxvt_term::scr_backspace () NOTHROW 1017rxvt_term::scr_backspace () NOTHROW
1004{ 1018{
1005 want_refresh = 1;
1006
1007 if (screen.cur.col == 0) 1019 if (screen.cur.col == 0)
1008 { 1020 {
1009 if (screen.cur.row > 0) 1021 if (screen.cur.row > 0)
1010 { 1022 {
1011#ifdef TERMCAP_HAS_BW 1023#ifdef TERMCAP_HAS_BW
1012 screen.cur.col = ncol - 1; 1024 screen.cur.col = ncol - 1;
1013 screen.cur.row--; 1025 --screen.cur.row;
1014 return; 1026
1027 want_refresh = 1;
1015#endif 1028#endif
1016 } 1029 }
1017 } 1030 }
1031#ifdef TERMCAP_HAS_BW
1018 else if (!(screen.flags & Screen_WrapNext)) 1032 else if (screen.flags & Screen_WrapNext)
1033 screen.flags &= ~Screen_WrapNext;
1034#endif
1035 else
1019 scr_gotorc (0, -1, RELATIVE); 1036 scr_gotorc (0, -1, RELATIVE);
1020
1021 screen.flags &= ~Screen_WrapNext;
1022} 1037}
1023 1038
1024/* ------------------------------------------------------------------------- */ 1039/* ------------------------------------------------------------------------- */
1025/* 1040/*
1026 * Process Horizontal Tab 1041 * Process Horizontal Tab
1049 x = i; 1064 x = i;
1050 1065
1051 if (!--count) 1066 if (!--count)
1052 break; 1067 break;
1053 } 1068 }
1054 else 1069 else
1055 ht &= l.t[i] == ' ' 1070 ht &= l.t[i] == ' '
1056 && RS_SAME (l.r[i], base_rend); 1071 && RS_SAME (l.r[i], base_rend);
1057 1072
1058 if (count) 1073 if (count)
1059 x = ncol - 1; 1074 x = ncol - 1;
1060 1075
1061 // store horizontal tab commands as characters inside the text 1076 // store horizontal tab commands as characters inside the text
1062 // buffer so they can be selected and pasted. 1077 // buffer so they can be selected and pasted.
1063 if (ht && OPTION (Opt_pastableTabs)) 1078 if (ht && option (Opt_pastableTabs))
1064 { 1079 {
1065 base_rend = SET_FONT (base_rend, 0); 1080 base_rend = SET_FONT (base_rend, 0);
1066 1081
1067 l.touch (x); 1082 l.touch (x);
1068 1083
1101 * Process DEC Back Index 1116 * Process DEC Back Index
1102 * XTERM_SEQ: ESC 6 1117 * XTERM_SEQ: ESC 6
1103 * Move cursor left in row. If we're at the left boundary, shift everything 1118 * Move cursor left in row. If we're at the left boundary, shift everything
1104 * in that row right. Clear left column. 1119 * in that row right. Clear left column.
1105 */ 1120 */
1106#if ENABLE_FRILLS 1121#if !ENABLE_MINIMAL
1107void 1122void
1108rxvt_term::scr_backindex () NOTHROW 1123rxvt_term::scr_backindex () NOTHROW
1109{ 1124{
1110 if (screen.cur.col > 0) 1125 if (screen.cur.col > 0)
1111 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1126 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1118 * Process DEC Forward Index 1133 * Process DEC Forward Index
1119 * XTERM_SEQ: ESC 9 1134 * XTERM_SEQ: ESC 9
1120 * Move cursor right in row. If we're at the right boundary, shift everything 1135 * Move cursor right in row. If we're at the right boundary, shift everything
1121 * in that row left. Clear right column. 1136 * in that row left. Clear right column.
1122 */ 1137 */
1123#if ENABLE_FRILLS 1138#if !ENABLE_MINIMAL
1124void 1139void
1125rxvt_term::scr_forwardindex () NOTHROW 1140rxvt_term::scr_forwardindex () NOTHROW
1126{ 1141{
1127 if (screen.cur.col < ncol - 1) 1142 if (screen.cur.col < ncol - 1)
1128 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1143 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1175 } 1190 }
1176 } 1191 }
1177 else 1192 else
1178 { 1193 {
1179 if (screen.flags & Screen_Relative) 1194 if (screen.flags & Screen_Relative)
1195 {
1180 { /* relative origin mode */ 1196 /* relative origin mode */
1181 screen.cur.row = row + screen.tscroll; 1197 screen.cur.row = row + screen.tscroll;
1182 min_it (screen.cur.row, screen.bscroll); 1198 min_it (screen.cur.row, screen.bscroll);
1183 } 1199 }
1184 else 1200 else
1185 screen.cur.row = row; 1201 screen.cur.row = row;
1218/* 1234/*
1219 * Erase part or whole of a line 1235 * Erase part or whole of a line
1220 * XTERM_SEQ: Clear line to right: ESC [ 0 K 1236 * XTERM_SEQ: Clear line to right: ESC [ 0 K
1221 * XTERM_SEQ: Clear line to left : ESC [ 1 K 1237 * XTERM_SEQ: Clear line to left : ESC [ 1 K
1222 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1238 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1239 * extension: clear to right unless wrapped: ESC [ 3 K
1223 */ 1240 */
1224void 1241void
1225rxvt_term::scr_erase_line (int mode) NOTHROW 1242rxvt_term::scr_erase_line (int mode) NOTHROW
1226{ 1243{
1227 unsigned int col, num; 1244 unsigned int col, num;
1236 line.touch (); 1253 line.touch ();
1237 line.is_longer (0); 1254 line.is_longer (0);
1238 1255
1239 switch (mode) 1256 switch (mode)
1240 { 1257 {
1258 case 3:
1259 if (screen.flags & Screen_WrapNext)
1260 return;
1261
1262 /* fall through */
1263
1241 case 0: /* erase to end of line */ 1264 case 0: /* erase to end of line */
1242 col = screen.cur.col; 1265 col = screen.cur.col;
1243 num = ncol - col; 1266 num = ncol - col;
1244 min_it (line.l, col); 1267 min_it (line.l, col);
1268
1245 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1269 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1246 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1270 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1247 CLEAR_SELECTION (); 1271 CLEAR_SELECTION ();
1248 break; 1272 break;
1273
1249 case 1: /* erase to beginning of line */ 1274 case 1: /* erase to beginning of line */
1250 col = 0; 1275 col = 0;
1251 num = screen.cur.col + 1; 1276 num = screen.cur.col + 1;
1277
1252 if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) 1278 if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur)
1253 || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) 1279 || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur))
1254 CLEAR_SELECTION (); 1280 CLEAR_SELECTION ();
1255 break; 1281 break;
1282
1256 case 2: /* erase whole line */ 1283 case 2: /* erase whole line */
1257 col = 0; 1284 col = 0;
1258 num = ncol; 1285 num = ncol;
1259 line.l = 0; 1286 line.l = 0;
1260 if (selection.beg.row <= screen.cur.row 1287 if (selection.beg.row <= screen.cur.row
1318 if (row >= nrow) /* Out Of Bounds */ 1345 if (row >= nrow) /* Out Of Bounds */
1319 return; 1346 return;
1320 1347
1321 min_it (num, nrow - row); 1348 min_it (num, nrow - row);
1322 1349
1323 if (rstyle & (RS_RVid | RS_Uline)) 1350 if (rstyle & (RS_Blink | RS_RVid | RS_Uline))
1324 ren = (rend_t) ~RS_None; 1351 ren = (rend_t) ~RS_None;
1325 else if (GET_BASEBG (rstyle) == Color_bg) 1352 else if (GET_BASEBG (rstyle) == Color_bg)
1326 { 1353 {
1327 ren = DEFAULT_RSTYLE; 1354 ren = DEFAULT_RSTYLE;
1328 CLEAR_ROWS (row, num); 1355
1356 if (mapped)
1357 XClearArea (dpy, vt, 0,
1358 Row2Pixel (row - view_start), (unsigned int)width,
1359 (unsigned int)Height2Pixel (num), False);
1329 } 1360 }
1330 else 1361 else
1331 { 1362 {
1332 ren = rstyle & (RS_fgMask | RS_bgMask); 1363 ren = rstyle & (RS_fgMask | RS_bgMask);
1364
1365 if (mapped)
1366 {
1333 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1367 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1334 XChangeGC (xdisp, gc, GCForeground, &gcvalue); 1368 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1335 ERASE_ROWS (row, num); 1369 XFillRectangle (dpy, vt, gc,
1370 0, Row2Pixel (row - view_start),
1371 (unsigned int)width,
1372 (unsigned int)Height2Pixel (num));
1336 gcvalue.foreground = pix_colors[Color_fg]; 1373 gcvalue.foreground = pix_colors[Color_fg];
1337 XChangeGC (xdisp, gc, GCForeground, &gcvalue); 1374 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1375 }
1338 } 1376 }
1339 1377
1340 for (; num--; row++) 1378 for (; num--; row++)
1341 { 1379 {
1342 scr_blank_screen_mem (ROW(row), rstyle); 1380 scr_blank_screen_mem (ROW(row), rstyle);
1381
1382 if (row - view_start < nrow)
1343 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1383 scr_blank_line (drawn_buf [row - view_start], 0, ncol, ren);
1344 } 1384 }
1345} 1385}
1346 1386
1347#if ENABLE_FRILLS 1387#if !ENABLE_MINIMAL
1348void 1388void
1349rxvt_term::scr_erase_savelines () NOTHROW 1389rxvt_term::scr_erase_savelines () NOTHROW
1350{ 1390{
1351 want_refresh = 1; 1391 want_refresh = 1;
1352 ZERO_SCROLLBACK (); 1392 ZERO_SCROLLBACK ();
1422 * Insert/Delete <count> characters from the current position 1462 * Insert/Delete <count> characters from the current position
1423 */ 1463 */
1424void 1464void
1425rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW 1465rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW
1426{ 1466{
1427 int col, row;
1428 rend_t tr;
1429
1430 want_refresh = 1; 1467 want_refresh = 1;
1431 ZERO_SCROLLBACK (); 1468 ZERO_SCROLLBACK ();
1432 1469
1433 if (count <= 0) 1470 if (count <= 0)
1434 return; 1471 return;
1436 scr_do_wrap (); 1473 scr_do_wrap ();
1437 1474
1438 selection_check (1); 1475 selection_check (1);
1439 min_it (count, ncol - screen.cur.col); 1476 min_it (count, ncol - screen.cur.col);
1440 1477
1441 row = screen.cur.row; 1478 int row = screen.cur.row;
1442 1479
1443 line_t *line = &ROW(row); 1480 line_t *line = &ROW(row);
1444 1481
1445 line->touch (); 1482 line->touch ();
1446 line->is_longer (0); 1483 line->is_longer (0);
1447 1484
1485 // nuke wide spanning the start
1486 if (line->t[screen.cur.col] == NOCHAR)
1487 scr_kill_char (*line, screen.cur.col);
1488
1448 switch (insdel) 1489 switch (insdel)
1449 { 1490 {
1450 case INSERT: 1491 case INSERT:
1451 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1492 line->l = min (line->l + count, ncol);
1493
1494 if (line->t[screen.cur.col] == NOCHAR)
1495 scr_kill_char (*line, screen.cur.col);
1496
1497 for (int col = ncol - 1; (col - count) >= screen.cur.col; col--)
1452 { 1498 {
1453 line->t[col] = line->t[col - count]; 1499 line->t[col] = line->t[col - count];
1454 line->r[col] = line->r[col - count]; 1500 line->r[col] = line->r[col - count];
1455 } 1501 }
1456
1457 line->l = min (line->l + count, ncol);
1458 1502
1459 if (selection.op && current_screen == selection.screen 1503 if (selection.op && current_screen == selection.screen
1460 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1504 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1461 { 1505 {
1462 if (selection.end.row != screen.cur.row 1506 if (selection.end.row != screen.cur.row
1463 || (selection.end.col + count >= ncol)) 1507 || (selection.end.col + count >= ncol))
1464 CLEAR_SELECTION (); 1508 CLEAR_SELECTION ();
1465 else 1509 else
1510 {
1466 { /* shift selection */ 1511 /* shift selection */
1467 selection.beg.col += count; 1512 selection.beg.col += count;
1468 selection.mark.col += count; /* XXX: yes? */ 1513 selection.mark.col += count; /* XXX: yes? */
1469 selection.end.col += count; 1514 selection.end.col += count;
1470 } 1515 }
1471 } 1516 }
1476 case ERASE: 1521 case ERASE:
1477 screen.cur.col += count; /* don't worry if > ncol */ 1522 screen.cur.col += count; /* don't worry if > ncol */
1478 selection_check (1); 1523 selection_check (1);
1479 screen.cur.col -= count; 1524 screen.cur.col -= count;
1480 1525
1481 line->l = max (line->l - count, 0); 1526 // nuke wide char after the end
1527 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1528 scr_kill_char (*line, screen.cur.col + count);
1529
1482 scr_blank_line (*line, screen.cur.col, count, rstyle); 1530 scr_blank_line (*line, screen.cur.col, count, rstyle);
1483 break; 1531 break;
1484 1532
1485 case DELETE: 1533 case DELETE:
1486 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1534 line->l = max (line->l - count, 0);
1487 1535
1536 // nuke wide char spanning the end
1537 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1538 scr_kill_char (*line, screen.cur.col + count);
1539
1488 for (col = screen.cur.col; (col + count) < ncol; col++) 1540 for (int col = screen.cur.col; (col + count) < ncol; col++)
1489 { 1541 {
1490 line->t[col] = line->t[col + count]; 1542 line->t[col] = line->t[col + count];
1491 line->r[col] = line->r[col + count]; 1543 line->r[col] = line->r[col + count];
1492 } 1544 }
1493 1545
1494 line->l = max (line->l - count, 0);
1495 scr_blank_line (*line, ncol - count, count, tr); 1546 scr_blank_line (*line, ncol - count, count, rstyle);
1496 1547
1497 if (selection.op && current_screen == selection.screen 1548 if (selection.op && current_screen == selection.screen
1498 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1549 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1499 { 1550 {
1500 if (selection.end.row != screen.cur.row 1551 if (selection.end.row != screen.cur.row
1610 */ 1661 */
1611void 1662void
1612rxvt_term::scr_set_tab (int mode) NOTHROW 1663rxvt_term::scr_set_tab (int mode) NOTHROW
1613{ 1664{
1614 if (mode < 0) 1665 if (mode < 0)
1615 memset (tabs, 0, ncol * sizeof (char)); 1666 memset (tabs, 0, ncol);
1616 else if (screen.cur.col < ncol) 1667 else if (screen.cur.col < ncol)
1617 tabs [screen.cur.col] = !!mode; 1668 tabs [screen.cur.col] = !!mode;
1618} 1669}
1619 1670
1620/* ------------------------------------------------------------------------- */ 1671/* ------------------------------------------------------------------------- */
1635 if (rvideo_state != on) 1686 if (rvideo_state != on)
1636 { 1687 {
1637 rvideo_state = on; 1688 rvideo_state = on;
1638 1689
1639 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1690 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1640#if XPM_BACKGROUND 1691#ifdef HAVE_BG_PIXMAP
1641 if (bgPixmap.pixmap == None) 1692 if (bgPixmap.pixmap == None)
1642#endif 1693#endif
1643#if TRANSPARENT
1644 if (!OPTION (Opt_transparent) || am_transparent == 0)
1645#endif
1646 XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]); 1694 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1647 1695
1648 XGCValues gcvalue; 1696 XGCValues gcvalue;
1649 gcvalue.foreground = pix_colors[Color_fg]; 1697 gcvalue.foreground = pix_colors[Color_fg];
1650 gcvalue.background = pix_colors[Color_bg]; 1698 gcvalue.background = pix_colors[Color_bg];
1651 XChangeGC (xdisp, gc, GCBackground | GCForeground, &gcvalue); 1699 XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue);
1652 1700
1653 scr_clear (); 1701 scr_clear ();
1654 scr_touch (true); 1702 scr_touch (true);
1655 } 1703 }
1656} 1704}
1741{ 1789{
1742 bool found = false; 1790 bool found = false;
1743 1791
1744 for (int i = 0; i < nrow; i++) 1792 for (int i = 0; i < nrow; i++)
1745 { 1793 {
1746 int col = 0;
1747 rend_t *drp = drawn_buf[i].r; 1794 rend_t *drp = drawn_buf[i].r;
1748 1795
1749 for (; col < ncol; col++, drp++) 1796 for (int col = 0; col < ncol; col++, drp++)
1750 if ((*drp & mask) == value) 1797 if ((*drp & mask) == value)
1751 { 1798 {
1752 found = true; 1799 found = true;
1753 *drp = ~value; 1800 *drp = ~value;
1754 } 1801 }
1859 return true; 1906 return true;
1860} 1907}
1861 1908
1862#ifndef NO_BELL 1909#ifndef NO_BELL
1863void 1910void
1864rxvt_term::bell_cb (time_watcher &w) 1911rxvt_term::bell_cb (ev::timer &w, int revents)
1865{ 1912{
1866 rvideo_bell = false; 1913 rvideo_bell = false;
1867 scr_rvideo_mode (rvideo_mode); 1914 scr_rvideo_mode (rvideo_mode);
1915 refresh_check ();
1868} 1916}
1869#endif 1917#endif
1870 1918
1871/* ------------------------------------------------------------------------- */ 1919/* ------------------------------------------------------------------------- */
1872void 1920void
1874{ 1922{
1875#ifndef NO_BELL 1923#ifndef NO_BELL
1876 1924
1877# ifndef NO_MAPALERT 1925# ifndef NO_MAPALERT
1878# ifdef MAPALERT_OPTION 1926# ifdef MAPALERT_OPTION
1879 if (OPTION (Opt_mapAlert)) 1927 if (option (Opt_mapAlert))
1880# endif 1928# endif
1881 XMapWindow (xdisp, parent[0]); 1929 XMapWindow (dpy, parent[0]);
1882# endif 1930# endif
1883 1931
1932# if ENABLE_FRILLS
1933 if (option (Opt_urgentOnBell))
1934 set_urgency (1);
1935# endif
1936
1884 if (OPTION (Opt_visualBell)) 1937 if (option (Opt_visualBell))
1885 { 1938 {
1886 rvideo_bell = true; 1939 rvideo_bell = true;
1887 scr_rvideo_mode (rvideo_mode); 1940 scr_rvideo_mode (rvideo_mode);
1888 display->flush (); 1941 flush ();
1889 1942
1890 bell_ev.start (NOW + VISUAL_BELL_DURATION); 1943 bell_ev.start (VISUAL_BELL_DURATION);
1891 } 1944 }
1892 else 1945 else
1893 XBell (xdisp, 0); 1946 XBell (dpy, 0);
1894 1947 HOOK_INVOKE ((this, HOOK_BELL, DT_END));
1895#endif 1948#endif
1896} 1949}
1897 1950
1898/* ------------------------------------------------------------------------- */ 1951/* ------------------------------------------------------------------------- */
1899/* ARGSUSED */ 1952/* ARGSUSED */
1900void 1953void
1901rxvt_term::scr_printscreen (int fullhist) NOTHROW 1954rxvt_term::scr_printscreen (int fullhist) NOTHROW
1902{ 1955{
1903#ifdef PRINTPIPE 1956#ifdef PRINTPIPE
1904 int nrows, row_start; 1957 int nrows, row_start;
1905 FILE *fd; 1958 FILE *fd = popen_printer ();
1906 1959
1907 if ((fd = popen_printer ()) == NULL) 1960 if (!fd)
1908 return; 1961 return;
1909 1962
1910 if (fullhist) 1963 if (fullhist)
1911 { 1964 {
1912 nrows = nrow - top_row; 1965 nrows = nrow - top_row;
1918 row_start = view_start; 1971 row_start = view_start;
1919 } 1972 }
1920 1973
1921 wctomb (0, 0); 1974 wctomb (0, 0);
1922 1975
1923 for (int r1 = 0; r1 < nrows; r1++) 1976 for (int r1 = row_start; r1 < row_start + nrows; r1++)
1924 { 1977 {
1925 text_t *tp = ROW(r1).t; 1978 text_t *tp = ROW(r1).t;
1926 int len = ROW(r1).l; 1979 int len = ROW(r1).l;
1927 1980
1928 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN 1981 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN
1957 * screen.text/screen.rend contain what the screen will change to. 2010 * screen.text/screen.rend contain what the screen will change to.
1958 */ 2011 */
1959void 2012void
1960rxvt_term::scr_refresh () NOTHROW 2013rxvt_term::scr_refresh () NOTHROW
1961{ 2014{
1962 unsigned char must_clear, /* use draw_string not draw_image_string */
1963 showcursor; /* show the cursor */
1964 int16_t col, row, /* column/row we're processing */ 2015 int16_t col, row, /* column/row we're processing */
1965 ocrow; /* old cursor row */ 2016 ocrow; /* old cursor row */
1966 int i; /* tmp */ 2017 int i; /* tmp */
1967#ifndef NO_CURSORCOLOR 2018#ifndef NO_CURSORCOLOR
1968 rend_t cc1; /* store colours at cursor position (s) */ 2019 rend_t cc1; /* store colours at cursor position (s) */
1969#endif 2020#endif
1970 rend_t *crp; // cursor rendition pointer 2021 rend_t *crp; // cursor rendition pointer
2022 rend_t ccol1, /* Cursor colour */
2023 ccol2; /* Cursor colour2 */
1971 2024
1972 want_refresh = 0; /* screen is current */ 2025 want_refresh = 0; /* screen is current */
1973 2026
1974 if (refresh_type == NO_REFRESH || !mapped) 2027 if (refresh_type == NO_REFRESH || !mapped)
1975 return; 2028 return;
1976 2029
1977 /* 2030 /*
1978 * A: set up vars 2031 * A: set up vars
1979 */ 2032 */
1980 must_clear = 0;
1981 refresh_count = 0; 2033 refresh_count = 0;
1982 2034
1983#if XPM_BACKGROUND 2035 unsigned int old_screen_flags = screen.flags;
2036 char have_bg = 0;
2037#ifdef HAVE_BG_PIXMAP
1984 must_clear |= bgPixmap.pixmap != None; 2038 have_bg = bgPixmap.pixmap != None;
1985#endif
1986#if TRANSPARENT
1987 must_clear |= OPTION (Opt_transparent) && am_transparent;
1988#endif 2039#endif
1989 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2040 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1990 2041
1991 /* 2042 /*
1992 * B: reverse any characters which are selected 2043 * B: reverse any characters which are selected
1993 */ 2044 */
1994 scr_reverse_selection (); 2045 scr_reverse_selection ();
2046
2047 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2048#if ENABLE_OVERLAY
2049 scr_swap_overlay ();
2050#endif
2051
2052 char showcursor = screen.flags & Screen_VisibleCursor;
1995 2053
1996 /* 2054 /*
1997 * C: set the cursor character (s) 2055 * C: set the cursor character (s)
1998 */ 2056 */
1999 { 2057 {
2000 unsigned char setoldcursor; 2058 unsigned char setoldcursor;
2001 rend_t ccol1, /* Cursor colour */
2002 ccol2; /* Cursor colour2 */
2003 2059
2004 showcursor = (screen.flags & Screen_VisibleCursor);
2005#ifdef CURSOR_BLINK 2060#ifdef CURSOR_BLINK
2006 if (hidden_cursor) 2061 if (hidden_cursor)
2007 showcursor = 0; 2062 showcursor = 0;
2008#endif 2063#endif
2009 2064
2014 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2069 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2015 col--; 2070 col--;
2016 2071
2017 crp = &ROW(screen.cur.row).r[col]; 2072 crp = &ROW(screen.cur.row).r[col];
2018 2073
2019 if (showcursor && focus) 2074#ifndef NO_CURSORCOLOR
2075 cc1 = *crp & (RS_fgMask | RS_bgMask);
2076 if (ISSET_PIXCOLOR (Color_cursor))
2077 ccol1 = Color_cursor;
2078 else
2079#endif
2080#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2081 ccol1 = fgcolor_of (rstyle);
2082#else
2083 ccol1 = Color_fg;
2084#endif
2085
2086#ifndef NO_CURSORCOLOR
2087 if (ISSET_PIXCOLOR (Color_cursor2))
2088 ccol2 = Color_cursor2;
2089 else
2090#endif
2091#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2092 ccol2 = bgcolor_of (rstyle);
2093#else
2094 ccol2 = Color_bg;
2095#endif
2096
2097 if (focus)
2020 { 2098 {
2021 if (OPTION (Opt_cursorUnderline)) 2099 if (option (Opt_cursorUnderline))
2022 *crp ^= RS_Uline; 2100 *crp ^= RS_Uline;
2023 else 2101 else
2024 { 2102 {
2025 *crp ^= RS_RVid; 2103 *crp ^= RS_RVid;
2026
2027#ifndef NO_CURSORCOLOR
2028 cc1 = *crp & (RS_fgMask | RS_bgMask);
2029 if (ISSET_PIXCOLOR (Color_cursor))
2030 ccol1 = Color_cursor;
2031 else
2032#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2033 ccol1 = fgcolor_of (rstyle);
2034#else
2035 ccol1 = Color_fg;
2036#endif
2037 if (ISSET_PIXCOLOR (Color_cursor2))
2038 ccol2 = Color_cursor2;
2039 else
2040#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2041 ccol2 = bgcolor_of (rstyle);
2042#else
2043 ccol2 = Color_bg;
2044#endif
2045 *crp = SET_FGCOLOR (*crp, ccol1); 2104 *crp = SET_FGCOLOR (*crp, ccol1);
2046 *crp = SET_BGCOLOR (*crp, ccol2); 2105 *crp = SET_BGCOLOR (*crp, ccol2);
2047#endif
2048 } 2106 }
2049 } 2107 }
2050 } 2108 }
2051 2109
2052 /* make sure no outline cursor is left around */ 2110 /* make sure no outline cursor is left around */
2079 oldcursor.col = screen.cur.col; 2137 oldcursor.col = screen.cur.col;
2080 } 2138 }
2081 } 2139 }
2082 } 2140 }
2083 2141
2084 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2085#if ENABLE_OVERLAY
2086 scr_swap_overlay ();
2087#endif
2088
2089#ifndef NO_SLOW_LINK_SUPPORT 2142#ifndef NO_SLOW_LINK_SUPPORT
2090 /* 2143 /*
2091 * D: CopyArea pass - very useful for slower links 2144 * D: CopyArea pass - very useful for slower links
2092 * This has been deliberately kept simple. 2145 * This has been deliberately kept simple.
2093 */ 2146 */
2094 if (!display->is_local 2147 if (!display->is_local
2095 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr 2148 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr
2096 && abs (num_scr) < nrow && !must_clear) 2149 && abs (num_scr) < nrow && !have_bg)
2097 { 2150 {
2098 int16_t nits; 2151 int16_t nits;
2152 int i = num_scr;
2099 int j; 2153 int j;
2100 int len, wlen; 2154 int len, wlen;
2101 dLocal (int, num_scr); 2155 dLocal (int, num_scr);
2102 2156
2103 j = nrow; 2157 j = nrow;
2104 wlen = len = -1; 2158 wlen = len = -1;
2105 row = i > 0 ? 0 : j - 1; 2159 row = i > 0 ? 0 : j - 1;
2160
2106 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2161 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
2107 { 2162 {
2108 if (row + i >= 0 && row + i < nrow && row + i != ocrow) 2163 if (row + i >= 0 && row + i < nrow && row + i != ocrow)
2109 { 2164 {
2110 line_t s = ROW(view_start + row); 2165 line_t s = ROW(view_start + row);
2131 wlen = row; 2186 wlen = row;
2132 continue; 2187 continue;
2133 } 2188 }
2134 } 2189 }
2135 2190
2136 if (len != -1) 2191 if (len >= 0)
2137 { 2192 {
2138 /* also comes here at end if needed because of >= above */ 2193 /* also comes here at end if needed because of >= above */
2139 if (wlen < len) 2194 if (wlen < len)
2140 ::swap (wlen, len); 2195 ::swap (wlen, len);
2141 2196
2197 XGCValues gcv;
2198
2199 gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv);
2142 XCopyArea (xdisp, vt, vt, 2200 XCopyArea (dpy, vt, vt,
2143 gc, 0, Row2Pixel (len + i), 2201 gc, 0, Row2Pixel (len + i),
2144 (unsigned int)this->width, 2202 (unsigned int)this->width,
2145 (unsigned int)Height2Pixel (wlen - len + 1), 2203 (unsigned int)Height2Pixel (wlen - len + 1),
2146 0, Row2Pixel (len)); 2204 0, Row2Pixel (len));
2205 gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv);
2206
2147 len = -1; 2207 len = -1;
2148 } 2208 }
2149 } 2209 }
2150 } 2210 }
2151#endif 2211#endif
2175 continue; 2235 continue;
2176 2236
2177 // redraw one or more characters 2237 // redraw one or more characters
2178 2238
2179 // seek to the beginning of wide characters 2239 // seek to the beginning of wide characters
2180 while (stp[col] == NOCHAR && col > 0) 2240 while (expect_false (stp[col] == NOCHAR && col > 0))
2181 --col; 2241 --col;
2182 2242
2183 rend_t rend = srp[col]; /* screen rendition (target rendtion) */ 2243 rend_t rend = srp[col]; /* screen rendition (target rendition) */
2184 text_t *text = stp + col; 2244 text_t *text = stp + col;
2185 int count = 1; 2245 int count = 1;
2186 2246
2187 dtp[col] = stp[col]; 2247 dtp[col] = stp[col];
2188 drp[col] = rend; 2248 drp[col] = rend;
2192 for (i = 0; ++col < ncol; ) 2252 for (i = 0; ++col < ncol; )
2193 { 2253 {
2194 if (stp[col] == NOCHAR) 2254 if (stp[col] == NOCHAR)
2195 { 2255 {
2196 dtp[col] = stp[col]; 2256 dtp[col] = stp[col];
2197 drp[col] = rend; 2257 drp[col] = srp[col];
2258
2198 count++; 2259 count++;
2199 i++; 2260 i++;
2200 2261
2201 continue; 2262 continue;
2202 } 2263 }
2207 count++; 2268 count++;
2208 2269
2209 if (stp[col] != dtp[col] 2270 if (stp[col] != dtp[col]
2210 || !RS_SAME (srp[col], drp[col])) 2271 || !RS_SAME (srp[col], drp[col]))
2211 { 2272 {
2212 if (must_clear && (i++ > count / 2)) 2273 if (have_bg && (i++ > count / 2))
2213 break; 2274 break;
2214 2275
2215 dtp[col] = stp[col]; 2276 dtp[col] = stp[col];
2216 drp[col] = rend; 2277 drp[col] = rend;
2217 i = 0; 2278 i = 0;
2218 } 2279 }
2219 else if (must_clear || (stp[col] != ' ' && ++i >= 16)) 2280 else if (have_bg || (stp[col] != ' ' && ++i >= 16))
2220 break; 2281 break;
2221 } 2282 }
2222 2283
2223 col--; /* went one too far. move back */ 2284 col--; /* went one too far. move back */
2224 count -= i; /* dump any matching trailing chars */ 2285 count -= i; /* dump any matching trailing chars */
2225 2286
2226 // sometimes we optimize away the trailing NOCHAR's, add them back 2287 // sometimes we optimize away the trailing NOCHAR's, add them back
2227 while (i && text[count] == NOCHAR) 2288 while (expect_false (i && text[count] == NOCHAR))
2228 count++, i--; 2289 count++, i--;
2229 2290
2230 /* 2291 /*
2231 * Determine the attributes for the string 2292 * Determine the attributes for the string
2232 */ 2293 */
2233 int fore = fgcolor_of (rend); // desired foreground 2294 int fore = fgcolor_of (rend); // desired foreground
2234 int back = bgcolor_of (rend); // desired background 2295 int back = bgcolor_of (rend); // desired background
2235 2296
2236 // only do special processing if any attributes are set, which is unlikely 2297 // only do special processing if any attributes are set, which is unlikely
2237 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2298 if (expect_false (rend & (RS_baseattrMask | RS_Careful | RS_Sel)))
2238 { 2299 {
2239#if ENABLE_STYLES
2240 // "careful" (too wide) character handling
2241
2242 // include previous careful character(s) if possible, looks nicer (best effort...)
2243 while (text > stp
2244 && srp[text - stp - 1] & RS_Careful
2245 && RS_SAME (rend, srp[text - stp - 1]))
2246 text--, count++, xpixel -= fwidth;
2247
2248 // force redraw after "careful" characters to avoid pixel droppings
2249 for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
2250 drp[col + i + 1] = ~srp[col + i + 1];
2251
2252 // force redraw before "careful" characters to avoid pixel droppings
2253 for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++)
2254 drp[text - stp - i - 1] = ~srp[text - stp - i - 1];
2255#endif
2256
2257 bool invert = rend & RS_RVid; 2300 bool invert = rend & RS_RVid;
2258 2301
2259#ifndef NO_BOLD_UNDERLINE_REVERSE 2302#ifndef NO_BOLD_UNDERLINE_REVERSE
2260 if (rend & RS_Bold
2261 && fore == Color_fg) 2303 if (rend & RS_Bold && fore == Color_fg)
2262 { 2304 {
2263 if (ISSET_PIXCOLOR (Color_BD)) 2305 if (ISSET_PIXCOLOR (Color_BD))
2264 fore = Color_BD; 2306 fore = Color_BD;
2265# if !ENABLE_STYLES 2307# if !ENABLE_STYLES
2266 else 2308 else
2267 invert = !invert; 2309 invert = !invert;
2268# endif 2310# endif
2269 } 2311 }
2270 2312
2271 if (rend & RS_Italic 2313 if (rend & RS_Italic && fore == Color_fg)
2272 && fore == Color_fg)
2273 { 2314 {
2274 if (ISSET_PIXCOLOR (Color_IT)) 2315 if (ISSET_PIXCOLOR (Color_IT))
2275 fore = Color_IT; 2316 fore = Color_IT;
2276# if !ENABLE_STYLES 2317# if !ENABLE_STYLES
2277 else 2318 else
2278 invert = !invert; 2319 invert = !invert;
2279# endif 2320# endif
2280 } 2321 }
2281 2322
2282 if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) 2323 if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL))
2283 fore = Color_UL; 2324 fore = Color_UL;
2325#endif
2326
2327#ifdef OPTION_HC
2328 if (rend & RS_Sel)
2329 {
2330 /* invert the column if no highlightColor is set or it is the
2331 * current cursor column */
2332 if (!(showcursor && row == screen.cur.row && text - stp == screen.cur.col)
2333 && ISSET_PIXCOLOR (Color_HC))
2334 {
2335 if (ISSET_PIXCOLOR (Color_HTC))
2336 fore = Color_HTC;
2337 // if invert is 0 reverse video is set so we use bg color as fg color
2338 else if (!invert)
2339 fore = back;
2340
2341 back = Color_HC;
2342 invert = 0;
2343 }
2344 }
2284#endif 2345#endif
2285 2346
2286 if (invert) 2347 if (invert)
2287 { 2348 {
2288 ::swap (fore, back); 2349 ::swap (fore, back);
2289 2350
2290#ifndef NO_BOLD_UNDERLINE_REVERSE 2351#ifndef NO_BOLD_UNDERLINE_REVERSE
2291 if (ISSET_PIXCOLOR (Color_RV))
2292 back = Color_RV;
2293
2294 if (fore == back) 2352 if (fore == back)
2295 { 2353 {
2296 fore = Color_bg; 2354 fore = Color_bg;
2297 back = Color_fg; 2355 back = Color_fg;
2298 } 2356 }
2300 } 2358 }
2301 2359
2302#ifdef TEXT_BLINK 2360#ifdef TEXT_BLINK
2303 if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) 2361 if (rend & RS_Blink && (back == Color_bg || fore == Color_bg))
2304 { 2362 {
2305 if (!text_blink_ev.active) 2363 if (!text_blink_ev.is_active ())
2306 { 2364 {
2307 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 2365 text_blink_ev.again ();
2308 hidden_text = 0; 2366 hidden_text = 0;
2309 } 2367 }
2310 else if (hidden_text) 2368 else if (hidden_text)
2311 fore = back; 2369 fore = back;
2312 } 2370 }
2313#endif 2371#endif
2372
2373#if ENABLE_STYLES
2374 // "careful" (too wide) character handling
2375
2376 // include previous careful character(s) if possible, looks nicer (best effort...)
2377 while (text > stp
2378 && srp[text - stp - 1] & RS_Careful
2379 && RS_SAME (rend, srp[text - stp - 1]))
2380 text--, count++, xpixel -= fwidth;
2381
2382 // force redraw after "careful" characters to avoid pixel droppings
2383 for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
2384 drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw;
2385
2386 // force redraw before "careful" characters to avoid pixel droppings
2387 for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++)
2388 drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw;
2389#endif
2314 } 2390 }
2315 2391
2316 /* 2392 /*
2317 * Actually do the drawing of the string here 2393 * Actually do the drawing of the string here
2318 */ 2394 */
2319 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; 2395 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];
2320 2396
2321 if (back == fore) 2397 if (expect_true (have_bg && back == Color_bg))
2322 font->clear_rect (*drawable, xpixel, ypixel,
2323 fwidth * count, fheight,
2324 back);
2325 else if (back == Color_bg)
2326 { 2398 {
2327 if (must_clear) 2399 // this is very ugly, maybe push it into ->draw?
2328 {
2329 CLEAR_CHARS (xpixel, ypixel, count);
2330 2400
2331 for (i = 0; i < count; i++) /* don't draw empty strings */ 2401 for (i = 0; i < count; i++) /* don't draw empty strings */
2332 if (text[i] != ' ') 2402 if (text[i] != ' ')
2333 { 2403 {
2334 font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); 2404 font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_transparent);
2335 break; 2405 goto did_clear;
2336 }
2337 } 2406 }
2338 else 2407
2339 font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); 2408 CLEAR_CHARS (xpixel, ypixel, count);
2409 did_clear: ;
2340 } 2410 }
2341 else 2411 else
2342 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2412 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2343 2413
2344 if (rend & RS_Uline && font->descent > 1 && fore != back) 2414 if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back))
2345 { 2415 {
2346#if ENABLE_FRILLS 2416#if ENABLE_FRILLS
2347 if (ISSET_PIXCOLOR (Color_underline)) 2417 if (ISSET_PIXCOLOR (Color_underline))
2348 XSetForeground (xdisp, gc, pix_colors[Color_underline]); 2418 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2349 else 2419 else
2350#endif 2420#endif
2351 XSetForeground (xdisp, gc, pix_colors[fore]); 2421 XSetForeground (dpy, gc, pix_colors[fore]);
2352 2422
2353 XDrawLine (xdisp, drawBuffer, gc, 2423 XDrawLine (dpy, vt, gc,
2354 xpixel, ypixel + font->ascent + 1, 2424 xpixel, ypixel + font->ascent + 1,
2355 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2425 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2356 } 2426 }
2357 } /* for (col....) */ 2427 } /* for (col....) */
2358 } /* for (row....) */ 2428 } /* for (row....) */
2359 2429
2360#if ENABLE_OVERLAY
2361 scr_swap_overlay ();
2362#endif
2363 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2364
2365 /* 2430 /*
2366 * G: cleanup cursor and display outline cursor if necessary 2431 * G: cleanup cursor and display outline cursor if necessary
2367 */ 2432 */
2368 if (showcursor) 2433 if (showcursor)
2369 { 2434 {
2370 if (focus) 2435 if (focus)
2371 { 2436 {
2372 if (OPTION (Opt_cursorUnderline)) 2437 if (option (Opt_cursorUnderline))
2373 *crp ^= RS_Uline; 2438 *crp ^= RS_Uline;
2374 else 2439 else
2375 { 2440 {
2376 *crp ^= RS_RVid; 2441 *crp ^= RS_RVid;
2377#ifndef NO_CURSORCOLOR 2442#ifndef NO_CURSORCOLOR
2391 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) 2456 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2392 cursorwidth++; 2457 cursorwidth++;
2393 2458
2394#ifndef NO_CURSORCOLOR 2459#ifndef NO_CURSORCOLOR
2395 if (ISSET_PIXCOLOR (Color_cursor)) 2460 if (ISSET_PIXCOLOR (Color_cursor))
2396 XSetForeground (xdisp, gc, pix_colors[Color_cursor]); 2461 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2462 else
2397#endif 2463#endif
2464 XSetForeground (dpy, gc, pix_colors[ccol1]);
2398 2465
2399 XDrawRectangle (xdisp, drawBuffer, gc, 2466 XDrawRectangle (dpy, vt, gc,
2400 Col2Pixel (col), 2467 Col2Pixel (col),
2401 Row2Pixel (oldcursor.row), 2468 Row2Pixel (oldcursor.row),
2402 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2469 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2403 (unsigned int) (Height2Pixel (1) - lineSpace - 1)); 2470 (unsigned int) (Height2Pixel (1) - lineSpace - 1));
2404 } 2471 }
2405 } 2472 }
2406 2473
2407 /* 2474 /*
2408 * H: cleanup selection 2475 * H: cleanup selection
2409 */ 2476 */
2477#if ENABLE_OVERLAY
2478 scr_swap_overlay ();
2479#endif
2480 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2481
2410 scr_reverse_selection (); 2482 scr_reverse_selection ();
2411 2483
2484 screen.flags = old_screen_flags;
2412 num_scr = 0; 2485 num_scr = 0;
2413 num_scr_allow = 1; 2486 num_scr_allow = 1;
2414} 2487}
2415 2488
2416void 2489void
2439} 2512}
2440 2513
2441void 2514void
2442rxvt_term::scr_recolour () NOTHROW 2515rxvt_term::scr_recolour () NOTHROW
2443{ 2516{
2444 if (1 2517#ifdef HAVE_BG_PIXMAP
2445#if TRANSPARENT 2518 bgPixmap.apply ();
2446 && !am_transparent 2519#else
2447#endif 2520
2448#if XPM_BACKGROUND
2449 && !bgPixmap.pixmap
2450#endif
2451 )
2452 {
2453 XSetWindowBackground (xdisp, parent[0], pix_colors[Color_border]); 2521 XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]);
2454 XClearWindow (xdisp, parent[0]); 2522 XClearWindow (dpy, parent[0]);
2455 XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]); 2523 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2456#if HAVE_SCROLLBARS 2524
2457 if (scrollBar.win) 2525 if (scrollBar.win)
2458 { 2526 {
2459 XSetWindowBackground (xdisp, scrollBar.win, pix_colors[Color_border]); 2527 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]);
2460 scrollBar.setIdle (); 2528 scrollBar.state = STATE_IDLE;
2461 scrollbar_show (0); 2529 scrollBar.show (0);
2462 }
2463#endif
2464 } 2530 }
2465 2531
2532#endif
2533
2534 /* bgPixmap.apply () does not do the following : */
2466 scr_clear (); 2535 scr_clear ();
2467 scr_touch (true); 2536 scr_touch (true);
2468 want_refresh = 1; 2537 want_refresh = 1;
2469} 2538}
2470 2539
2477 2546
2478 num_scr_allow = 0; 2547 num_scr_allow = 0;
2479 want_refresh = 1; 2548 want_refresh = 1;
2480 2549
2481 if (really) 2550 if (really)
2482 XClearWindow (xdisp, vt); 2551 XClearWindow (dpy, vt);
2483} 2552}
2484 2553
2485void 2554void
2486rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW 2555rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW
2487{ 2556{
2536{ 2605{
2537 if (selection.op 2606 if (selection.op
2538 && current_screen == selection.screen 2607 && current_screen == selection.screen
2539 && selection.end.row >= view_start) 2608 && selection.end.row >= view_start)
2540 { 2609 {
2541#if ENABLE_FRILLS 2610#if !ENABLE_MINIMAL
2542 if (selection.rect) 2611 if (selection.rect)
2543 scr_xor_rect (selection.beg.row, selection.beg.col, 2612 scr_xor_rect (selection.beg.row, selection.beg.col,
2544 selection.end.row, selection.end.col, 2613 selection.end.row, selection.end.col,
2545 RS_RVid, RS_RVid | RS_Uline); 2614 RS_Sel | RS_RVid, RS_Sel | RS_RVid | RS_Uline);
2546 else 2615 else
2547#endif 2616#endif
2548 scr_xor_span (selection.beg.row, selection.beg.col, 2617 scr_xor_span (selection.beg.row, selection.beg.col,
2549 selection.end.row, selection.end.col, 2618 selection.end.row, selection.end.col,
2550 RS_RVid); 2619 RS_Sel | RS_RVid);
2551 } 2620 }
2552} 2621}
2553 2622
2554/* ------------------------------------------------------------------------- */ 2623/* ------------------------------------------------------------------------- */
2555/* 2624/*
2562{ 2631{
2563 int row, wrote; 2632 int row, wrote;
2564 unsigned int width, towrite; 2633 unsigned int width, towrite;
2565 char r1[] = "\n"; 2634 char r1[] = "\n";
2566 2635
2567 for (row = saveLines - nsaved; 2636 for (row = saveLines + top_row;
2568 row < saveLines + nrow - 1; row++) 2637 row < saveLines + nrow - 1; row++)
2569 { 2638 {
2570 width = row_buf[row].l >= 0 ? row_buf[row].l 2639 width = row_buf[row].l >= 0 ? row_buf[row].l
2571 : ncol; 2640 : ncol;
2572 for (towrite = width; towrite; towrite -= wrote) 2641 for (towrite = width; towrite; towrite -= wrote)
2616/* ------------------------------------------------------------------------- */ 2685/* ------------------------------------------------------------------------- */
2617/* 2686/*
2618 * Paste a selection direct to the command fd 2687 * Paste a selection direct to the command fd
2619 */ 2688 */
2620void 2689void
2621rxvt_term::paste (char *data, unsigned int len) NOTHROW 2690rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW
2622{ 2691{
2623 /* convert normal newline chars into common keyboard Return key sequence */ 2692 /* convert normal newline chars into common keyboard Return key sequence */
2624 for (unsigned int i = 0; i < len; i++) 2693 for (unsigned int i = 0; i < len; i++)
2625 if (data[i] == C0_LF) 2694 if (data[i] == C0_LF)
2626 data[i] = C0_CR; 2695 data[i] = C0_CR;
2627 2696
2697 if (priv_modes & PrivMode_BracketPaste)
2698 tt_printf ("\e[200~");
2699
2628 tt_write (data, len); 2700 tt_write (data, len);
2701
2702 if (priv_modes & PrivMode_BracketPaste)
2703 tt_printf ("\e[201~");
2704}
2705
2706void
2707rxvt_term::paste (char *data, unsigned int len) NOTHROW
2708{
2709 if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END)))
2710 return;
2711
2712 tt_paste (data, len);
2629} 2713}
2630 2714
2631/* ------------------------------------------------------------------------- */ 2715/* ------------------------------------------------------------------------- */
2632/* 2716/*
2633 * Respond to a notification that a primary selection has been sent 2717 * Respond to a notification that a primary selection has been sent
2662 } 2746 }
2663 2747
2664 unsigned long bytes_after; 2748 unsigned long bytes_after;
2665 XTextProperty ct; 2749 XTextProperty ct;
2666 2750
2667 if (XGetWindowProperty (xdisp, win, prop, 2751 if (XGetWindowProperty (dpy, win, prop,
2668 0, PROP_SIZE / 4, 2752 0, PROP_SIZE / 4,
2669 delete_prop, AnyPropertyType, 2753 delete_prop, AnyPropertyType,
2670 &ct.encoding, &ct.format, 2754 &ct.encoding, &ct.format,
2671 &ct.nitems, &bytes_after, 2755 &ct.nitems, &bytes_after,
2672 &ct.value) != Success) 2756 &ct.value) != Success)
2681 if (bytes_after) 2765 if (bytes_after)
2682 { 2766 {
2683 // fetch and append remaining data 2767 // fetch and append remaining data
2684 XTextProperty ct2; 2768 XTextProperty ct2;
2685 2769
2686 if (XGetWindowProperty (xdisp, win, prop, 2770 if (XGetWindowProperty (dpy, win, prop,
2687 ct.nitems / 4, (bytes_after + 3) / 4, 2771 ct.nitems / 4, (bytes_after + 3) / 4,
2688 delete_prop, AnyPropertyType, 2772 delete_prop, AnyPropertyType,
2689 &ct2.encoding, &ct2.format, 2773 &ct2.encoding, &ct2.format,
2690 &ct2.nitems, &bytes_after, 2774 &ct2.nitems, &bytes_after,
2691 &ct2.value) != Success) 2775 &ct2.value) != Success)
2704 2788
2705 if (ct.encoding == xa[XA_INCR]) 2789 if (ct.encoding == xa[XA_INCR])
2706 { 2790 {
2707 // INCR selection, start handshake 2791 // INCR selection, start handshake
2708 if (!delete_prop) 2792 if (!delete_prop)
2709 XDeleteProperty (xdisp, win, prop); 2793 XDeleteProperty (dpy, win, prop);
2710 2794
2711 selection_wait = Sel_incr; 2795 selection_wait = Sel_incr;
2712 incr_buf_fill = 0; 2796 incr_buf_fill = 0;
2713 incr_ev.start (NOW + 10); 2797 incr_ev.start (10);
2714 2798
2715 goto bailout; 2799 goto bailout;
2716 } 2800 }
2717 2801
2718 if (ct.nitems == 0) 2802 if (ct.nitems == 0)
2727 ct.nitems = incr_buf_fill; 2811 ct.nitems = incr_buf_fill;
2728 incr_buf = 0; 2812 incr_buf = 0;
2729 incr_buf_size = 0; 2813 incr_buf_size = 0;
2730 incr_ev.stop (); 2814 incr_ev.stop ();
2731 } 2815 }
2732 else 2816 else
2733 { 2817 {
2734 if (selection_wait == Sel_normal 2818 if (selection_wait == Sel_normal
2735 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion 2819 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion
2736 { 2820 {
2737 /* 2821 /*
2744 goto bailout; 2828 goto bailout;
2745 } 2829 }
2746 } 2830 }
2747 else if (selection_wait == Sel_incr) 2831 else if (selection_wait == Sel_incr)
2748 { 2832 {
2749 incr_ev.start (NOW + 10); 2833 incr_ev.start (10);
2750 2834
2751 while (incr_buf_fill + ct.nitems > incr_buf_size) 2835 while (incr_buf_fill + ct.nitems > incr_buf_size)
2752 { 2836 {
2753 incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; 2837 incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024;
2754 incr_buf = (char *)realloc (incr_buf, incr_buf_size); 2838 incr_buf = (char *)realloc (incr_buf, incr_buf_size);
2761 } 2845 }
2762 2846
2763 char **cl; 2847 char **cl;
2764 int cr; 2848 int cr;
2765 2849
2766#if ENABLE_FRILLS 2850#if !ENABLE_MINIMAL
2767 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 2851 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
2768 // so recode it manually 2852 // so recode it manually
2769 if (ct.encoding == xa[XA_UTF8_STRING]) 2853 if (ct.encoding == xa[XA_UTF8_STRING])
2770 { 2854 {
2771 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2855 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2775 paste (s, strlen (s)); 2859 paste (s, strlen (s));
2776 free (s); 2860 free (s);
2777 } 2861 }
2778 else 2862 else
2779#endif 2863#endif
2780 if (XmbTextPropertyToTextList (xdisp, &ct, &cl, &cr) >= 0 2864 if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0
2781 && cl) 2865 && cl)
2782 { 2866 {
2783 for (int i = 0; i < cr; i++) 2867 for (int i = 0; i < cr; i++)
2784 paste (cl[i], strlen (cl[i])); 2868 paste (cl[i], strlen (cl[i]));
2785 2869
2794 if (selection_wait == Sel_normal) 2878 if (selection_wait == Sel_normal)
2795 selection_wait = Sel_none; 2879 selection_wait = Sel_none;
2796} 2880}
2797 2881
2798void 2882void
2799rxvt_term::incr_cb (time_watcher &w) NOTHROW 2883rxvt_term::incr_cb (ev::timer &w, int revents) NOTHROW
2800{ 2884{
2801 selection_wait = Sel_none; 2885 selection_wait = Sel_none;
2802 2886
2803 incr_buf_size = 0; 2887 incr_buf_size = 0;
2804 free (incr_buf); 2888 free (incr_buf);
2815 selection_paste (win, prop, true); 2899 selection_paste (win, prop, true);
2816} 2900}
2817 2901
2818/* ------------------------------------------------------------------------- */ 2902/* ------------------------------------------------------------------------- */
2819/* 2903/*
2820 * Request the current selection: 2904 * Request the current selection:
2821 * Order: > internal selection if available 2905 * Order: > internal selection if available
2822 * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) 2906 * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+)
2823 * > CUT_BUFFER0 2907 * > CUT_BUFFER0
2824 * (+) if ownership is claimed but property is empty, rxvt_selection_paste () 2908 * (+) if ownership is claimed but property is empty, rxvt_selection_paste ()
2825 * will auto fallback to CUT_BUFFER0 2909 * will auto fallback to CUT_BUFFER0
2827 */ 2911 */
2828void 2912void
2829rxvt_term::selection_request (Time tm, int selnum) NOTHROW 2913rxvt_term::selection_request (Time tm, int selnum) NOTHROW
2830{ 2914{
2831 if (selection.text && selnum == Sel_Primary) 2915 if (selection.text && selnum == Sel_Primary)
2916 {
2832 { /* internal selection */ 2917 /* internal selection */
2833 char *str = rxvt_wcstombs (selection.text, selection.len); 2918 char *str = rxvt_wcstombs (selection.text, selection.len);
2834 paste (str, strlen (str)); 2919 paste (str, strlen (str));
2835 free (str); 2920 free (str);
2836 return; 2921 return;
2837 } 2922 }
2841 selection_wait = Sel_normal; 2926 selection_wait = Sel_normal;
2842 2927
2843#if X_HAVE_UTF8_STRING 2928#if X_HAVE_UTF8_STRING
2844 selection_type = Sel_UTF8String; 2929 selection_type = Sel_UTF8String;
2845 if (selection_request_other (xa[XA_UTF8_STRING], selnum)) 2930 if (selection_request_other (xa[XA_UTF8_STRING], selnum))
2846 return; 2931 return;
2847#else 2932#else
2848 selection_type = Sel_CompoundText; 2933 selection_type = Sel_CompoundText;
2849 if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) 2934 if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum))
2850 return; 2935 return;
2851#endif 2936#endif
2852 } 2937 }
2853 2938
2854 selection_wait = Sel_none; /* don't loop in selection_paste () */ 2939 selection_wait = Sel_none; /* don't loop in selection_paste () */
2855 selection_paste (display->root, XA_CUT_BUFFER0, false); 2940 selection_paste (display->root, XA_CUT_BUFFER0, false);
2867 else if (selnum == Sel_Secondary) 2952 else if (selnum == Sel_Secondary)
2868 sel = XA_SECONDARY; 2953 sel = XA_SECONDARY;
2869 else 2954 else
2870 sel = xa[XA_CLIPBOARD]; 2955 sel = xa[XA_CLIPBOARD];
2871 2956
2872 if (XGetSelectionOwner (xdisp, sel) != None) 2957 if (XGetSelectionOwner (dpy, sel) != None)
2873 { 2958 {
2874 XConvertSelection (xdisp, sel, target, xa[XA_VT_SELECTION], 2959 XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION],
2875 vt, selection_request_time); 2960 vt, selection_request_time);
2876 return 1; 2961 return 1;
2877 } 2962 }
2878 2963
2879 return 0; 2964 return 0;
2883/* 2968/*
2884 * Clear all selected text 2969 * Clear all selected text
2885 * EXT: SelectionClear 2970 * EXT: SelectionClear
2886 */ 2971 */
2887void 2972void
2888rxvt_term::selection_clear () NOTHROW 2973rxvt_term::selection_clear (bool clipboard) NOTHROW
2889{ 2974{
2975 if (!clipboard)
2976 {
2890 want_refresh = 1; 2977 want_refresh = 1;
2891 free (selection.text); 2978 free (selection.text);
2892 selection.text = NULL; 2979 selection.text = NULL;
2893 selection.len = 0; 2980 selection.len = 0;
2894 CLEAR_SELECTION (); 2981 CLEAR_SELECTION ();
2895 2982
2896 if (display->selection_owner == this) 2983 if (display->selection_owner == this)
2897 display->selection_owner = 0; 2984 display->selection_owner = 0;
2985 }
2986 else
2987 {
2988 free (selection.clip_text);
2989 selection.clip_text = NULL;
2990 selection.clip_len = 0;
2991
2992 if (display->clipboard_owner == this)
2993 display->clipboard_owner = 0;
2994 }
2898} 2995}
2899 2996
2900/* ------------------------------------------------------------------------- */ 2997/* ------------------------------------------------------------------------- */
2901/* 2998/*
2902 * Copy a selection into the cut buffer 2999 * Copy a selection into the cut buffer
2942 3039
2943 int end_col; 3040 int end_col;
2944 3041
2945 for (; row <= selection.end.row; row++, col = 0) 3042 for (; row <= selection.end.row; row++, col = 0)
2946 { 3043 {
2947#if ENABLE_FRILLS 3044#if !ENABLE_MINIMAL
2948 if (selection.rect) 3045 if (selection.rect)
2949 { 3046 {
2950 col = selection.beg.col; 3047 col = selection.beg.col;
2951 end_col = ncol + 1; 3048 end_col = ncol + 1;
2952 } 3049 }
2955 end_col = ROW(row).l; 3052 end_col = ROW(row).l;
2956 3053
2957 col = max (col, 0); 3054 col = max (col, 0);
2958 3055
2959 if (row == selection.end.row 3056 if (row == selection.end.row
2960#if ENABLE_FRILLS 3057#if !ENABLE_MINIMAL
2961 || selection.rect 3058 || selection.rect
2962#endif 3059#endif
2963 ) 3060 )
2964 min_it (end_col, selection.end.col); 3061 min_it (end_col, selection.end.col);
2965 3062
2988#endif 3085#endif
2989 else 3086 else
2990 new_selection_text[ofs++] = *t++; 3087 new_selection_text[ofs++] = *t++;
2991 } 3088 }
2992 3089
2993#if ENABLE_FRILLS 3090#if !ENABLE_MINIMAL
2994 if (selection.rect) 3091 if (selection.rect)
2995 { 3092 {
2996 while (ofs 3093 while (ofs
2997 && new_selection_text[ofs - 1] != C0_LF 3094 && new_selection_text[ofs - 1] != C0_LF
2998 && unicode::is_space (new_selection_text[ofs - 1])) 3095 && unicode::is_space (new_selection_text[ofs - 1]))
3028 3125
3029 selection_grab (tm); 3126 selection_grab (tm);
3030} 3127}
3031 3128
3032bool 3129bool
3033rxvt_term::selection_grab (Time tm) NOTHROW 3130rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW
3034{ 3131{
3132 Atom sel;
3133
3134 if (!clipboard)
3135 {
3035 selection_time = tm; 3136 selection_time = tm;
3036 3137 sel = XA_PRIMARY;
3037 XSetSelectionOwner (xdisp, XA_PRIMARY, vt, tm);
3038 if (XGetSelectionOwner (xdisp, XA_PRIMARY) == vt)
3039 { 3138 }
3139 else
3140 {
3141 clipboard_time = tm;
3142 sel = xa[XA_CLIPBOARD];
3143 }
3144
3145 XSetSelectionOwner (dpy, sel, vt, tm);
3146 if (XGetSelectionOwner (dpy, sel) == vt)
3147 {
3040 display->set_selection_owner (this); 3148 display->set_selection_owner (this, clipboard);
3041 return true; 3149 return true;
3042 } 3150 }
3043 else 3151 else
3044 { 3152 {
3045 selection_clear (); 3153 selection_clear (clipboard);
3046 return false; 3154 return false;
3047 } 3155 }
3048 3156
3049#if 0 3157#if 0
3050 XTextProperty ct; 3158 XTextProperty ct;
3051 3159
3052 if (XwcTextListToTextProperty (xdisp, &selection.text, 1, XStringStyle, &ct) >= 0) 3160 if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0)
3053 { 3161 {
3054 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3162 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
3055 XFree (ct.value); 3163 XFree (ct.value);
3056 } 3164 }
3057#endif 3165#endif
3103 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); 3211 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1);
3104 3212
3105 while (selection.mark.col > 0 3213 while (selection.mark.col > 0
3106 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) 3214 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR)
3107 --selection.mark.col; 3215 --selection.mark.col;
3108 3216
3109 if (selection.op) 3217 if (selection.op)
3218 {
3110 { /* clear the old selection */ 3219 /* clear the old selection */
3111 selection.beg.row = selection.end.row = selection.mark.row; 3220 selection.beg.row = selection.end.row = selection.mark.row;
3112 selection.beg.col = selection.end.col = selection.mark.col; 3221 selection.beg.col = selection.end.col = selection.mark.col;
3113 } 3222 }
3114 3223
3115 selection.op = SELECTION_INIT; 3224 selection.op = SELECTION_INIT;
3304 * a point/word/line which is either the start or end of the selection 3413 * a point/word/line which is either the start or end of the selection
3305 * and it was decided by whichever point/word/line was `fixed' at the 3414 * and it was decided by whichever point/word/line was `fixed' at the
3306 * time of the most recent button3 press 3415 * time of the most recent button3 press
3307 */ 3416 */
3308 if (button3 && buttonpress) 3417 if (button3 && buttonpress)
3418 {
3309 { /* button3 press */ 3419 /* button3 press */
3310 /* 3420 /*
3311 * first determine which edge of the selection we are closest to 3421 * first determine which edge of the selection we are closest to
3312 */ 3422 */
3313 if (ROWCOL_IS_BEFORE (pos, selection.beg) 3423 if (ROWCOL_IS_BEFORE (pos, selection.beg)
3314 || (!ROWCOL_IS_AFTER (pos, selection.end) 3424 || (!ROWCOL_IS_AFTER (pos, selection.end)
3332 selection.mark.row = selection.beg.row; 3442 selection.mark.row = selection.beg.row;
3333 selection.mark.col = selection.beg.col; 3443 selection.mark.col = selection.beg.col;
3334 } 3444 }
3335 } 3445 }
3336 else 3446 else
3447 {
3337 { /* button1 drag or button3 drag */ 3448 /* button1 drag or button3 drag */
3338 if (ROWCOL_IS_AFTER (selection.mark, pos)) 3449 if (ROWCOL_IS_AFTER (selection.mark, pos))
3339 { 3450 {
3340 if (selection.mark.row == selection.end.row 3451 if (selection.mark.row == selection.end.row
3341 && selection.mark.col == selection.end.col 3452 && selection.mark.col == selection.end.col
3342 && clickchange 3453 && clickchange
3359 3470
3360 if (selection.clicks == 1) 3471 if (selection.clicks == 1)
3361 { 3472 {
3362 if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN 3473 if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN
3363 && !ROW(selection.beg.row).is_longer () 3474 && !ROW(selection.beg.row).is_longer ()
3364#if ENABLE_FRILLS 3475#if !ENABLE_MINIMAL
3365 && !selection.rect 3476 && !selection.rect
3366#endif 3477#endif
3367 ) 3478 )
3368 selection.beg.col = ncol; 3479 selection.beg.col = ncol;
3369 3480
3370 if ( 3481 if (
3371 selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN 3482 selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN
3372 && !ROW(selection.end.row).is_longer () 3483 && !ROW(selection.end.row).is_longer ()
3373#if ENABLE_FRILLS 3484#if !ENABLE_MINIMAL
3374 && !selection.rect 3485 && !selection.rect
3375#endif 3486#endif
3376 ) 3487 )
3377 selection.end.col = ncol; 3488 selection.end.col = ncol;
3378 } 3489 }
3385 selection_delimit_word (DN, &selection.end, &selection.end); 3496 selection_delimit_word (DN, &selection.end, &selection.end);
3386 } 3497 }
3387 else if (selection.clicks == 3) 3498 else if (selection.clicks == 3)
3388 { 3499 {
3389#if ENABLE_FRILLS 3500#if ENABLE_FRILLS
3390 if (OPTION (Opt_tripleclickwords)) 3501 if (option (Opt_tripleclickwords))
3391 { 3502 {
3392 selection_delimit_word (UP, &selection.beg, &selection.beg); 3503 selection_delimit_word (UP, &selection.beg, &selection.beg);
3393 3504
3394 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3505 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3395 { 3506 {
3396 if (!ROW(end_row).is_longer ()) 3507 if (!ROW(end_row).is_longer ())
3397 { 3508 {
3398 selection.end.row = end_row; 3509 selection.end.row = end_row;
3399 selection.end.col = ROW(end_row).l; 3510 selection.end.col = ROW(end_row).l;
3511# if !ENABLE_MINIMAL
3400 selection_remove_trailing_spaces (); 3512 selection_remove_trailing_spaces ();
3513# endif
3401 break; 3514 break;
3402 } 3515 }
3403 } 3516 }
3404 } 3517 }
3405 else 3518 else
3421 selection.end.row++; 3534 selection.end.row++;
3422 } 3535 }
3423 } 3536 }
3424 3537
3425 if (button3 && buttonpress) 3538 if (button3 && buttonpress)
3539 {
3426 { /* mark may need to be changed */ 3540 /* mark may need to be changed */
3427 if (closeto == LEFT) 3541 if (closeto == LEFT)
3428 { 3542 {
3429 selection.mark.row = selection.end.row; 3543 selection.mark.row = selection.end.row;
3430 selection.mark.col = selection.end.col - (selection.clicks == 2); 3544 selection.mark.col = selection.end.col - (selection.clicks == 2);
3431 } 3545 }
3434 selection.mark.row = selection.beg.row; 3548 selection.mark.row = selection.beg.row;
3435 selection.mark.col = selection.beg.col; 3549 selection.mark.col = selection.beg.col;
3436 } 3550 }
3437 } 3551 }
3438 3552
3439#if ENABLE_FRILLS 3553#if !ENABLE_MINIMAL
3440 if (selection.rect && selection.beg.col > selection.end.col) 3554 if (selection.rect && selection.beg.col > selection.end.col)
3441 ::swap (selection.beg.col, selection.end.col); 3555 ::swap (selection.beg.col, selection.end.col);
3442#endif 3556#endif
3443} 3557}
3444 3558
3445#if ENABLE_FRILLS 3559#if !ENABLE_MINIMAL
3446void 3560void
3447rxvt_term::selection_remove_trailing_spaces () NOTHROW 3561rxvt_term::selection_remove_trailing_spaces () NOTHROW
3448{ 3562{
3449 int32_t end_col, end_row; 3563 int32_t end_col, end_row;
3450 text_t *stp; 3564 text_t *stp;
3528 *target++ = xa[XA_COMPOUND_TEXT]; 3642 *target++ = xa[XA_COMPOUND_TEXT];
3529#if X_HAVE_UTF8_STRING 3643#if X_HAVE_UTF8_STRING
3530 *target++ = xa[XA_UTF8_STRING]; 3644 *target++ = xa[XA_UTF8_STRING];
3531#endif 3645#endif
3532 3646
3533 XChangeProperty (xdisp, rq.requestor, rq.property, XA_ATOM, 3647 XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM,
3534 32, PropModeReplace, 3648 32, PropModeReplace,
3535 (unsigned char *)target_list, target - target_list); 3649 (unsigned char *)target_list, target - target_list);
3536 ev.property = rq.property; 3650 ev.property = rq.property;
3537 } 3651 }
3538#if TODO // TODO 3652#if TODO // TODO
3539 else if (rq.target == xa[XA_MULTIPLE]) 3653 else if (rq.target == xa[XA_MULTIPLE])
3540 { 3654 {
3541 /* TODO: Handle MULTIPLE */ 3655 /* TODO: Handle MULTIPLE */
3542 } 3656 }
3543#endif 3657#endif
3544 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3658 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == XA_PRIMARY && selection.text)
3545 { 3659 {
3546 XChangeProperty (xdisp, rq.requestor, rq.property, rq.target, 3660 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3547 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3661 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3662 ev.property = rq.property;
3663 }
3664 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
3665 {
3666 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3667 32, PropModeReplace, (unsigned char *)&clipboard_time, 1);
3548 ev.property = rq.property; 3668 ev.property = rq.property;
3549 } 3669 }
3550 else if (rq.target == XA_STRING 3670 else if (rq.target == XA_STRING
3551 || rq.target == xa[XA_TEXT] 3671 || rq.target == xa[XA_TEXT]
3552 || rq.target == xa[XA_COMPOUND_TEXT] 3672 || rq.target == xa[XA_COMPOUND_TEXT]
3575 style = enc_string; 3695 style = enc_string;
3576 else if (target == xa[XA_TEXT]) 3696 else if (target == xa[XA_TEXT])
3577 style = enc_text; 3697 style = enc_text;
3578 else if (target == xa[XA_COMPOUND_TEXT]) 3698 else if (target == xa[XA_COMPOUND_TEXT])
3579 style = enc_compound_text; 3699 style = enc_compound_text;
3580#if ENABLE_FRILLS 3700#if !ENABLE_MINIMAL
3581 else if (target == xa[XA_UTF8_STRING]) 3701 else if (target == xa[XA_UTF8_STRING])
3582 style = enc_utf8; 3702 style = enc_utf8;
3583#endif 3703#endif
3584 else 3704 else
3585 { 3705 {
3586 target = xa[XA_COMPOUND_TEXT]; 3706 target = xa[XA_COMPOUND_TEXT];
3587 style = enc_compound_text; 3707 style = enc_compound_text;
3588 } 3708 }
3589 3709
3590 if (selection.text) 3710 if (rq.selection == XA_PRIMARY && selection.text)
3591 { 3711 {
3592 cl = selection.text; 3712 cl = selection.text;
3593 selectlen = selection.len; 3713 selectlen = selection.len;
3594 } 3714 }
3715 else if (rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
3716 {
3717 cl = selection.clip_text;
3718 selectlen = selection.clip_len;
3719 }
3595 else 3720 else
3596 { 3721 {
3597 cl = L""; 3722 cl = L"";
3598 selectlen = 0; 3723 selectlen = 0;
3599 } 3724 }
3600 3725
3601#if ENABLE_FRILLS 3726#if !ENABLE_MINIMAL
3602 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 3727 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
3603 // so recode it manually 3728 // so recode it manually
3604 if (style == enc_utf8) 3729 if (style == enc_utf8)
3605 { 3730 {
3606 freect = 1; 3731 freect = 1;
3609 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); 3734 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen);
3610 ct.nitems = strlen ((char *)ct.value); 3735 ct.nitems = strlen ((char *)ct.value);
3611 } 3736 }
3612 else 3737 else
3613#endif 3738#endif
3614 if (XwcTextListToTextProperty (xdisp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) 3739 if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
3615 freect = 1; 3740 freect = 1;
3616 else 3741 else
3617 { 3742 {
3618 /* if we failed to convert then send it raw */ 3743 /* if we failed to convert then send it raw */
3619 ct.value = (unsigned char *)cl; 3744 ct.value = (unsigned char *)cl;
3620 ct.nitems = selectlen; 3745 ct.nitems = selectlen;
3621 ct.encoding = target; 3746 ct.encoding = target;
3622 } 3747 }
3623 3748
3624 XChangeProperty (xdisp, rq.requestor, rq.property, 3749 XChangeProperty (dpy, rq.requestor, rq.property,
3625 ct.encoding, 8, PropModeReplace, 3750 ct.encoding, 8, PropModeReplace,
3626 ct.value, (int)ct.nitems); 3751 ct.value, (int)ct.nitems);
3627 ev.property = rq.property; 3752 ev.property = rq.property;
3628 3753
3629 if (freect) 3754 if (freect)
3630 XFree (ct.value); 3755 XFree (ct.value);
3631 } 3756 }
3632 3757
3633 XSendEvent (xdisp, rq.requestor, False, 0L, (XEvent *)&ev); 3758 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev);
3634}
3635
3636/* ------------------------------------------------------------------------- *
3637 * MOUSE ROUTINES *
3638 * ------------------------------------------------------------------------- */
3639
3640/*
3641 * return col/row values corresponding to x/y pixel values
3642 */
3643void
3644rxvt_term::pixel_position (int *x, int *y) NOTHROW
3645{
3646 *x = Pixel2Col (*x);
3647 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */
3648 *y = Pixel2Row (*y);
3649 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */
3650} 3759}
3651 3760
3652/* ------------------------------------------------------------------------- */ 3761/* ------------------------------------------------------------------------- */
3653#ifdef USE_XIM 3762#ifdef USE_XIM
3654void 3763void
3655rxvt_term::im_set_position (XPoint &pos) NOTHROW 3764rxvt_term::im_set_position (XPoint &pos) NOTHROW
3656{ 3765{
3657 XWindowAttributes xwa; 3766 XWindowAttributes xwa;
3658 3767
3659 XGetWindowAttributes (xdisp, vt, &xwa); 3768 XGetWindowAttributes (dpy, vt, &xwa);
3660 3769
3661 pos.x = xwa.x + Col2Pixel (screen.cur.col); 3770 pos.x = xwa.x + Col2Pixel (screen.cur.col);
3662 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; 3771 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase;
3663} 3772}
3664#endif 3773#endif
3682 h += 2; min_it (h, nrow); 3791 h += 2; min_it (h, nrow);
3683 3792
3684 x -= 1; clamp_it (x, 0, ncol - w); 3793 x -= 1; clamp_it (x, 0, ncol - w);
3685 y -= 1; clamp_it (y, 0, nrow - h); 3794 y -= 1; clamp_it (y, 0, nrow - h);
3686 3795
3687 ov_x = x; ov_y = y; 3796 ov.x = x; ov.y = y;
3688 ov_w = w; ov_h = h; 3797 ov.w = w; ov.h = h;
3689 3798
3690 ov_text = new text_t *[h]; 3799 ov.text = new text_t *[h];
3691 ov_rend = new rend_t *[h]; 3800 ov.rend = new rend_t *[h];
3692 3801
3693 for (y = 0; y < h; y++) 3802 for (y = 0; y < h; y++)
3694 { 3803 {
3695 text_t *tp = ov_text[y] = new text_t[w]; 3804 text_t *tp = ov.text[y] = new text_t[w];
3696 rend_t *rp = ov_rend[y] = new rend_t[w]; 3805 rend_t *rp = ov.rend[y] = new rend_t[w];
3697 3806
3698 text_t t0, t1, t2; 3807 text_t t0, t1, t2;
3699 rend_t r = OVERLAY_RSTYLE; 3808 rend_t r = OVERLAY_RSTYLE;
3700 3809
3701 if (y == 0) 3810 if (y == 0)
3720} 3829}
3721 3830
3722void 3831void
3723rxvt_term::scr_overlay_off () NOTHROW 3832rxvt_term::scr_overlay_off () NOTHROW
3724{ 3833{
3725 if (!ov_text) 3834 if (!ov.text)
3726 return; 3835 return;
3727 3836
3728 want_refresh = 1; 3837 want_refresh = 1;
3729 3838
3730 for (int y = 0; y < ov_h; y++) 3839 for (int y = 0; y < ov.h; y++)
3731 { 3840 {
3732 delete [] ov_text[y]; 3841 delete [] ov.text[y];
3733 delete [] ov_rend[y]; 3842 delete [] ov.rend[y];
3734 } 3843 }
3735 3844
3736 delete [] ov_text; ov_text = 0; 3845 delete [] ov.text; ov.text = 0;
3737 delete [] ov_rend; ov_rend = 0; 3846 delete [] ov.rend; ov.rend = 0;
3738} 3847}
3739 3848
3740void 3849void
3741rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW 3850rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW
3742{ 3851{
3743 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3852 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3744 return; 3853 return;
3745 3854
3746 x++, y++; 3855 x++, y++;
3747 3856
3748 ov_text[y][x] = text; 3857 ov.text[y][x] = text;
3749 ov_rend[y][x] = rend; 3858 ov.rend[y][x] = rend;
3750} 3859}
3751 3860
3752void 3861void
3753rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW 3862rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW
3754{ 3863{
3773} 3882}
3774 3883
3775void 3884void
3776rxvt_term::scr_swap_overlay () NOTHROW 3885rxvt_term::scr_swap_overlay () NOTHROW
3777{ 3886{
3778 if (!ov_text) 3887 if (!ov.text)
3779 return; 3888 return;
3780 3889
3890 // hide cursor if it is within the overlay area
3891 if (IN_RANGE_EXC (screen.cur.col - ov.x, 0, ov.w)
3892 && IN_RANGE_EXC (screen.cur.row - ov.y, 0, ov.h))
3893 screen.flags &= ~Screen_VisibleCursor;
3894
3781 // swap screen mem with overlay 3895 // swap screen mem with overlay
3782 for (int y = ov_h; y--; ) 3896 for (int y = ov.h; y--; )
3783 { 3897 {
3784 text_t *t1 = ov_text[y]; 3898 text_t *t1 = ov.text[y];
3785 rend_t *r1 = ov_rend[y]; 3899 rend_t *r1 = ov.rend[y];
3786 3900
3787 text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; 3901 text_t *t2 = ROW(y + ov.y + view_start).t + ov.x;
3788 rend_t *r2 = ROW(y + ov_y + view_start).r + ov_x; 3902 rend_t *r2 = ROW(y + ov.y + view_start).r + ov.x;
3789 3903
3790 for (int x = ov_w; x--; ) 3904 for (int x = ov.w; x--; )
3791 { 3905 {
3792 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3906 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3793 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3907 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));
3794 } 3908 }
3795 } 3909 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines