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.192 by root, Thu Dec 22 19:25:58 2005 UTC vs.
Revision 1.205 by root, Tue Jan 3 04:18:47 2006 UTC

24 * This file handles _all_ screen updates and selections 24 * This file handles _all_ screen updates and selections
25 */ 25 */
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 30
30#include <X11/Xmd.h> /* get the typedef for CARD32 */ 31#include <X11/Xmd.h> /* get the typedef for CARD32 */
31 32
32#include <inttypes.h> 33#include <inttypes.h>
33 34
46 47
47/* ------------------------------------------------------------------------- * 48/* ------------------------------------------------------------------------- *
48 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * 49 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES *
49 * ------------------------------------------------------------------------- */ 50 * ------------------------------------------------------------------------- */
50#define ZERO_SCROLLBACK() \ 51#define ZERO_SCROLLBACK() \
51 if (options & Opt_scrollTtyOutput) \ 52 if (OPTION (Opt_scrollTtyOutput)) \
52 view_start = 0 53 view_start = 0
53#define CLEAR_SELECTION() \ 54#define CLEAR_SELECTION() \
54 selection.beg.row = selection.beg.col \ 55 selection.beg.row = selection.beg.col \
55 = selection.end.row = selection.end.col = 0 56 = selection.end.row = selection.end.col = 0
56#define CLEAR_ALL_SELECTION() \ 57#define CLEAR_ALL_SELECTION() \
351 lofs += len; 352 lofs += len;
352 qcol += len; 353 qcol += len;
353 } 354 }
354 } 355 }
355 356
356 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; 357 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0;
358#ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY
359 if (qline->l < 0)
360 {
361 fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D
362 qline->l = 0;
363 }
364#endif
357 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 365 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
358 } 366 }
359 while (p != pend && q > 0); 367 while (p != pend && q > 0);
360 368
361 term_start = total_rows - nrow; 369 term_start = total_rows - nrow;
385 } 393 }
386 394
387 term_start = 0; 395 term_start = 0;
388 } 396 }
389 397
390#ifdef DEBUG_STRICT 398#ifdef DEBUG_STRICT //TODO: remove
391 for (int i = -nsaved; i < nrow; i++) 399 for (int i = -nsaved; i < nrow; i++)
392 assert (ROW (i).t); 400 assert (ROW (i).t);
393#endif 401#endif
394 402
395 free (old_buf); 403 free (old_buf);
410 418
411 for (int col = ncol; col--; ) 419 for (int col = ncol; col--; )
412 tabs [col] = col % TABSIZE == 0; 420 tabs [col] = col % TABSIZE == 0;
413 421
414 tt_winch (); 422 tt_winch ();
423
424 PERL_INVOKE ((this, HOOK_RESET, DT_END));
415} 425}
416 426
417/* ------------------------------------------------------------------------- */ 427/* ------------------------------------------------------------------------- */
418/* 428/*
419 * Free everything. That way malloc debugging can find leakage. 429 * Free everything. That way malloc debugging can find leakage.
523 533
524 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); 534 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
525 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); 535 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
526 536
527#if NSCREENS 537#if NSCREENS
528 if (options & Opt_secondaryScreen) 538 if (OPTION (Opt_secondaryScreen))
529 { 539 {
530 num_scr = 0; 540 num_scr = 0;
531 541
532 for (int i = prev_nrow; i--; ) 542 for (int i = prev_nrow; i--; )
533 ::swap (ROW(i), swap_buf [i]); 543 ::swap (ROW(i), swap_buf [i]);
537 screen.flags |= Screen_VisibleCursor; 547 screen.flags |= Screen_VisibleCursor;
538 swap.flags |= Screen_VisibleCursor; 548 swap.flags |= Screen_VisibleCursor;
539 } 549 }
540 else 550 else
541#endif 551#endif
542 if (options & Opt_secondaryScroll) 552 if (OPTION (Opt_secondaryScroll))
543 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 553 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
544 554
545 return scrn; 555 return scrn;
546} 556}
547 557
609 num_scr += count; 619 num_scr += count;
610 620
611 if (count > 0 621 if (count > 0
612 && row1 == 0 622 && row1 == 0
613 && row2 == nrow - 1 623 && row2 == nrow - 1
614 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 624 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
615 { 625 {
616 nsaved = min (nsaved + count, saveLines); 626 nsaved = min (nsaved + count, saveLines);
627
628 PERL_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END));
629
617 term_start = (term_start + count) % total_rows; 630 term_start = (term_start + count) % total_rows;
618 631
619 if (selection.op && current_screen == selection.screen) 632 if (selection.op && current_screen == selection.screen)
620 { 633 {
621 selection.beg.row -= count; 634 selection.beg.row -= count;
622 selection.end.row -= count; 635 selection.end.row -= count;
623 selection.mark.row -= count; 636 selection.mark.row -= count;
624 637
625 selection_check (0); 638 if (selection.beg.row < -nsaved
639 || selection.end.row < -nsaved
640 || selection.mark.row < -nsaved)
641 {
642 CLEAR_ALL_SELECTION ();
643 selection.op = SELECTION_CLEAR;
644 }
626 } 645 }
627 646
628 for (int i = count; i--; ) 647 for (int i = count; i--; )
648 {
649 ROW(row2 - i).l = 0;
629 scr_blank_screen_mem (ROW(row2 - i), rstyle); 650 scr_blank_screen_mem (ROW(row2 - i), rstyle);
651 }
630 652
631 if ((options & Opt_scrollWithBuffer) 653 if (OPTION (Opt_scrollWithBuffer)
632 && view_start != 0 654 && view_start != 0
633 && view_start != saveLines) 655 && view_start != saveLines)
634 scr_page (UP, count); 656 scr_page (UP, count);
635 } 657 }
636 else 658 else
637 { 659 {
638 if (selection.op && current_screen == selection.screen) 660 if (selection.op && current_screen == selection.screen)
639 { 661 {
640 int i = selection.beg.row; 662 if ((selection.beg.row < row1 && selection.end.row > row1)
641 int j = selection.end.row; 663 || (selection.beg.row < row2 && selection.end.row > row2)
642
643 if ((i < row1 && j > row1)
644 || (i < row2 && j > row2)
645 || (i - count < row1 && i >= row1) 664 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
646 || (i - count > row2 && i <= row2) 665 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
647 || (j - count < row1 && j >= row1) 666 || (selection.end.row - count < row1 && selection.end.row >= row1)
648 || (j - count > row2 && j <= row2)) 667 || (selection.end.row - count > row2 && selection.end.row <= row2))
649 { 668 {
650 CLEAR_ALL_SELECTION (); 669 CLEAR_ALL_SELECTION ();
651 selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ 670 selection.op = SELECTION_CLEAR;
652 } 671 }
653 else if (j >= row1 && j <= row2) 672 else if (selection.end.row >= row1 && selection.end.row <= row2)
654 { 673 {
655 /* move selected region too */ 674 /* move selected region too */
656 selection.beg.row -= count; 675 selection.beg.row -= count;
657 selection.end.row -= count; 676 selection.end.row -= count;
658 selection.mark.row -= count; 677 selection.mark.row -= count;
693 if (len <= 0) /* sanity */ 712 if (len <= 0) /* sanity */
694 return; 713 return;
695 714
696 unsigned char checksel; 715 unsigned char checksel;
697 unicode_t c; 716 unicode_t c;
698 int row, last_col; 717 int last_col;
699 const unicode_t *strend = str + len; 718 const unicode_t *strend = str + len;
700 719
701 want_refresh = 1; 720 want_refresh = 1;
702 ZERO_SCROLLBACK (); 721 ZERO_SCROLLBACK ();
703 last_col = ncol; 722 last_col = ncol;
718#ifdef DEBUG_STRICT 737#ifdef DEBUG_STRICT
719 assert (screen.cur.col < last_col); 738 assert (screen.cur.col < last_col);
720 assert (screen.cur.row < nrow 739 assert (screen.cur.row < nrow
721 && screen.cur.row >= -nsaved); 740 && screen.cur.row >= -nsaved);
722#endif 741#endif
723 row = screen.cur.row; 742 int row = screen.cur.row;
724 743
725 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 744 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
726 745
727 line_t *line = &ROW(row); 746 line_t *line = &ROW(row);
728 747
730 { 749 {
731 c = *str++; 750 c = *str++;
732 751
733 if (c < 0x20) 752 if (c < 0x20)
734 if (c == C0_LF) 753 if (c == C0_LF)
735 { 754 {
736 if (!line->is_longer ()) /* XXX: think about this */ 755 if (!line->is_longer ()) /* XXX: think about this */
737 max_it (line->l, screen.cur.col); 756 max_it (line->l, screen.cur.col);
738 757
739 screen.flags &= ~Screen_WrapNext; 758 screen.flags &= ~Screen_WrapNext;
740 759
985 1004
986 if (count == 0) 1005 if (count == 0)
987 return; 1006 return;
988 else if (count > 0) 1007 else if (count > 0)
989 { 1008 {
990 int row = screen.cur.row;
991
992 line_t &l = ROW(row); 1009 line_t &l = ROW(screen.cur.row);
993 rend_t base_rend = l.r[i]; 1010 rend_t base_rend = l.r[i];
994 ht &= l.t[i] == ' '; 1011 ht &= l.t[i] == ' ';
995 1012
996 for (; ++i < ncol; ) 1013 for (; ++i < ncol; )
997 if (tabs[i]) 1014 if (tabs[i])
1007 if (count) 1024 if (count)
1008 x = ncol - 1; 1025 x = ncol - 1;
1009 1026
1010 // store horizontal tab commands as characters inside the text 1027 // store horizontal tab commands as characters inside the text
1011 // buffer so they can be selected and pasted. 1028 // buffer so they can be selected and pasted.
1012 if (ht && options & Opt_pastableTabs) 1029 if (ht && OPTION (Opt_pastableTabs))
1013 { 1030 {
1014 base_rend = SET_FONT (base_rend, 0); 1031 base_rend = SET_FONT (base_rend, 0);
1015 1032
1016 if (!l.is_longer ()) /* XXX: think about this */ 1033 if (!l.is_longer ()) /* XXX: think about this */
1017 max_it (l.l, x); 1034 max_it (l.l, x);
1072 */ 1089 */
1073#if ENABLE_FRILLS 1090#if ENABLE_FRILLS
1074void 1091void
1075rxvt_term::scr_forwardindex () 1092rxvt_term::scr_forwardindex ()
1076{ 1093{
1077 int row;
1078
1079 if (screen.cur.col < ncol - 1) 1094 if (screen.cur.col < ncol - 1)
1080 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1095 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1081 else 1096 else
1082 { 1097 {
1083 row = screen.cur.row;
1084
1085 if (ROW(row).is_longer ()) //TODO//FIXME//LEN 1098 if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN
1086 ROW(row).l = ncol; 1099 ROW(screen.cur.row).l = ncol;
1087 1100
1088 scr_gotorc (0, 0, R_RELATIVE); 1101 scr_gotorc (0, 0, R_RELATIVE);
1089 scr_insdel_chars (1, DELETE); 1102 scr_insdel_chars (1, DELETE);
1090 scr_gotorc (0, ncol - 1, R_RELATIVE); 1103 scr_gotorc (0, ncol - 1, R_RELATIVE);
1091 } 1104 }
1174 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1187 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1175 */ 1188 */
1176void 1189void
1177rxvt_term::scr_erase_line (int mode) 1190rxvt_term::scr_erase_line (int mode)
1178{ 1191{
1179 unsigned int row, col, num; 1192 unsigned int col, num;
1180 1193
1181 want_refresh = 1; 1194 want_refresh = 1;
1182 ZERO_SCROLLBACK (); 1195 ZERO_SCROLLBACK ();
1183 1196
1184 selection_check (1); 1197 selection_check (1);
1185 1198
1186 row = screen.cur.row; 1199 line_t &line = ROW(screen.cur.row);
1187 1200
1188 switch (mode) 1201 switch (mode)
1189 { 1202 {
1190 case 0: /* erase to end of line */ 1203 case 0: /* erase to end of line */
1191 col = screen.cur.col; 1204 col = screen.cur.col;
1192 num = ncol - col; 1205 num = ncol - col;
1193 min_it (ROW(row).l, col); 1206 min_it (line.l, col);
1194 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1207 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1195 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1208 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1196 CLEAR_SELECTION (); 1209 CLEAR_SELECTION ();
1197 break; 1210 break;
1198 case 1: /* erase to beginning of line */ 1211 case 1: /* erase to beginning of line */
1203 CLEAR_SELECTION (); 1216 CLEAR_SELECTION ();
1204 break; 1217 break;
1205 case 2: /* erase whole line */ 1218 case 2: /* erase whole line */
1206 col = 0; 1219 col = 0;
1207 num = ncol; 1220 num = ncol;
1208 ROW(row).l = 0; 1221 line.l = 0;
1209 if (selection.beg.row <= screen.cur.row 1222 if (selection.beg.row <= screen.cur.row
1210 && selection.end.row >= screen.cur.row) 1223 && selection.end.row >= screen.cur.row)
1211 CLEAR_SELECTION (); 1224 CLEAR_SELECTION ();
1212 break; 1225 break;
1213 default: 1226 default:
1214 return; 1227 return;
1215 } 1228 }
1216 1229
1217 scr_blank_line (ROW(row), col, num, rstyle); 1230 scr_blank_line (line, col, num, rstyle);
1218} 1231}
1219 1232
1220/* ------------------------------------------------------------------------- */ 1233/* ------------------------------------------------------------------------- */
1221/* 1234/*
1222 * Erase part of whole of the screen 1235 * Erase part of whole of the screen
1277 CLEAR_ROWS (row, num); 1290 CLEAR_ROWS (row, num);
1278 } 1291 }
1279 else 1292 else
1280 { 1293 {
1281 ren = rstyle & (RS_fgMask | RS_bgMask); 1294 ren = rstyle & (RS_fgMask | RS_bgMask);
1282 gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; 1295 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1283 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1296 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1284 ERASE_ROWS (row, num); 1297 ERASE_ROWS (row, num);
1285 gcvalue.foreground = pix_colors[Color_fg]; 1298 gcvalue.foreground = pix_colors[Color_fg];
1286 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1299 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1287 } 1300 }
1288 1301
1289 for (; num--; row++) 1302 for (; num--; row++)
1290 { 1303 {
1304 ROW (row).l = 0;
1291 scr_blank_screen_mem (ROW (row), rstyle); 1305 scr_blank_screen_mem (ROW (row), rstyle);
1292 ROW (row).l = 0;
1293 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1306 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1294 } 1307 }
1295} 1308}
1296 1309
1297#if ENABLE_FRILLS 1310#if ENABLE_FRILLS
1586 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1599 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1587#if XPM_BACKGROUND 1600#if XPM_BACKGROUND
1588 if (bgPixmap.pixmap == None) 1601 if (bgPixmap.pixmap == None)
1589#endif 1602#endif
1590#if TRANSPARENT 1603#if TRANSPARENT
1591 if (! (options & Opt_transparent) || am_transparent == 0) 1604 if (! OPTION (Opt_transparent) || am_transparent == 0)
1592#endif 1605#endif
1593 XSetWindowBackground (display->display, vt, 1606 XSetWindowBackground (display->display, vt,
1594 pix_colors[Color_bg]); 1607 pix_colors[Color_bg]);
1595 1608
1596 gcvalue.foreground = pix_colors[Color_fg]; 1609 gcvalue.foreground = pix_colors[Color_fg];
1812} 1825}
1813 1826
1814int 1827int
1815rxvt_term::scr_changeview (unsigned int oldviewstart) 1828rxvt_term::scr_changeview (unsigned int oldviewstart)
1816{ 1829{
1830 PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1831
1817 if (view_start != oldviewstart) 1832 if (view_start != oldviewstart)
1818 { 1833 {
1819 want_refresh = 1; 1834 want_refresh = 1;
1820 num_scr -= (view_start - oldviewstart); 1835 num_scr -= (view_start - oldviewstart);
1821 } 1836 }
1829{ 1844{
1830#ifndef NO_BELL 1845#ifndef NO_BELL
1831 1846
1832# ifndef NO_MAPALERT 1847# ifndef NO_MAPALERT
1833# ifdef MAPALERT_OPTION 1848# ifdef MAPALERT_OPTION
1834 if (options & Opt_mapAlert) 1849 if (OPTION (Opt_mapAlert))
1835# endif 1850# endif
1836 XMapWindow (display->display, parent[0]); 1851 XMapWindow (display->display, parent[0]);
1837# endif 1852# endif
1838 1853
1839 if (options & Opt_visualBell) 1854 if (OPTION (Opt_visualBell))
1840 { 1855 {
1841 scr_rvideo_mode (!rvideo); /* refresh also done */ 1856 scr_rvideo_mode (!rvideo); /* refresh also done */
1842 rxvt_usleep (VISUAL_BELL_DURATION); 1857 rxvt_usleep (VISUAL_BELL_DURATION);
1843 scr_rvideo_mode (!rvideo); /* refresh also done */ 1858 scr_rvideo_mode (!rvideo); /* refresh also done */
1844 } 1859 }
1935 1950
1936#if XPM_BACKGROUND 1951#if XPM_BACKGROUND
1937 must_clear |= bgPixmap.pixmap != None; 1952 must_clear |= bgPixmap.pixmap != None;
1938#endif 1953#endif
1939#if TRANSPARENT 1954#if TRANSPARENT
1940 must_clear |= (options & Opt_transparent) && am_transparent; 1955 must_clear |= OPTION (Opt_transparent) && am_transparent;
1941#endif 1956#endif
1942 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1957 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1943 1958
1944 /* 1959 /*
1945 * B: reverse any characters which are selected 1960 * B: reverse any characters which are selected
1969 1984
1970 crp = &ROW(screen.cur.row).r[col]; 1985 crp = &ROW(screen.cur.row).r[col];
1971 1986
1972 if (showcursor && focus) 1987 if (showcursor && focus)
1973 { 1988 {
1974 if (options & Opt_cursorUnderline) 1989 if (OPTION (Opt_cursorUnderline))
1975 *crp ^= RS_Uline; 1990 *crp ^= RS_Uline;
1976 else 1991 else
1977 { 1992 {
1978 *crp ^= RS_RVid; 1993 *crp ^= RS_RVid;
1979 1994
1981 cc1 = *crp & (RS_fgMask | RS_bgMask); 1996 cc1 = *crp & (RS_fgMask | RS_bgMask);
1982 if (ISSET_PIXCOLOR (Color_cursor)) 1997 if (ISSET_PIXCOLOR (Color_cursor))
1983 ccol1 = Color_cursor; 1998 ccol1 = Color_cursor;
1984 else 1999 else
1985#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2000#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1986 ccol1 = GET_FGCOLOR (rstyle); 2001 ccol1 = fgcolor_of (rstyle);
1987#else 2002#else
1988 ccol1 = Color_fg; 2003 ccol1 = Color_fg;
1989#endif 2004#endif
1990 if (ISSET_PIXCOLOR (Color_cursor2)) 2005 if (ISSET_PIXCOLOR (Color_cursor2))
1991 ccol2 = Color_cursor2; 2006 ccol2 = Color_cursor2;
1992 else 2007 else
1993#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2008#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1994 ccol2 = GET_BGCOLOR (rstyle); 2009 ccol2 = bgcolor_of (rstyle);
1995#else 2010#else
1996 ccol2 = Color_bg; 2011 ccol2 = Color_bg;
1997#endif 2012#endif
1998 *crp = SET_FGCOLOR (*crp, ccol1); 2013 *crp = SET_FGCOLOR (*crp, ccol1);
1999 *crp = SET_BGCOLOR (*crp, ccol2); 2014 *crp = SET_BGCOLOR (*crp, ccol2);
2032 oldcursor.col = screen.cur.col; 2047 oldcursor.col = screen.cur.col;
2033 } 2048 }
2034 } 2049 }
2035 } 2050 }
2036 2051
2052 PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2037#if ENABLE_OVERLAY 2053#if ENABLE_OVERLAY
2038 scr_swap_overlay (); 2054 scr_swap_overlay ();
2039#endif 2055#endif
2040 2056
2041#ifndef NO_SLOW_LINK_SUPPORT 2057#ifndef NO_SLOW_LINK_SUPPORT
2180 count++, i--; 2196 count++, i--;
2181 2197
2182 /* 2198 /*
2183 * Determine the attributes for the string 2199 * Determine the attributes for the string
2184 */ 2200 */
2185 int fore = GET_FGCOLOR (rend); // desired foreground 2201 int fore = fgcolor_of (rend); // desired foreground
2186 int back = GET_BGCOLOR (rend); // desired background 2202 int back = bgcolor_of (rend); // desired background
2187 2203
2188 // only do special processing if any attributes are set, which is rare 2204 // only do special processing if any attributes are set, which is unlikely
2189 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2205 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2190 { 2206 {
2191#if ENABLE_STYLES 2207#if ENABLE_STYLES
2192 // force redraw after "careful" characters to avoid pixel droppings 2208 // force redraw after "careful" characters to avoid pixel droppings
2193 if (srp[col] & RS_Careful && col < ncol - 1 && 0) 2209 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2304 } /* for (row....) */ 2320 } /* for (row....) */
2305 2321
2306#if ENABLE_OVERLAY 2322#if ENABLE_OVERLAY
2307 scr_swap_overlay (); 2323 scr_swap_overlay ();
2308#endif 2324#endif
2325 PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2309 2326
2310 /* 2327 /*
2311 * G: cleanup cursor and display outline cursor if necessary 2328 * G: cleanup cursor and display outline cursor if necessary
2312 */ 2329 */
2313 if (showcursor) 2330 if (showcursor)
2314 { 2331 {
2315 if (focus) 2332 if (focus)
2316 { 2333 {
2317 if (options & Opt_cursorUnderline) 2334 if (OPTION (Opt_cursorUnderline))
2318 *crp ^= RS_Uline; 2335 *crp ^= RS_Uline;
2319 else 2336 else
2320 { 2337 {
2321 *crp ^= RS_RVid; 2338 *crp ^= RS_RVid;
2322#ifndef NO_CURSORCOLOR 2339#ifndef NO_CURSORCOLOR
2441 2458
2442#if ENABLE_FRILLS 2459#if ENABLE_FRILLS
2443 if (selection.rect) 2460 if (selection.rect)
2444 { 2461 {
2445 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) 2462 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++)
2463 {
2464 text_t *stp = ROW(row).t;
2465 rend_t *srp = ROW(row).r;
2466
2446 for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) 2467 for (col = selection.beg.col; col < selection.end.col; col++)
2447 srp[col] ^= RS_RVid; 2468 srp[col] ^= RS_RVid;
2469
2470 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2471 srp[col] ^= RS_RVid | RS_Uline;
2472
2473 if (++col < selection.end.col)
2474 srp[col] ^= RS_RVid | RS_Uline;
2475 }
2448 } 2476 }
2449 else 2477 else
2450#endif 2478#endif
2451 { 2479 {
2452 if (selection.beg.row >= -view_start) 2480 if (selection.beg.row >= -view_start)
2455 row = selection.beg.row; 2483 row = selection.beg.row;
2456 } 2484 }
2457 else 2485 else
2458 { 2486 {
2459 col = 0; 2487 col = 0;
2460 row = view_start; 2488 row = -view_start;
2461 } 2489 }
2462 2490
2463 for (; row < min (selection.end.row, view_end); row++, col = 0) 2491 for (; row < min (selection.end.row, view_end); row++, col = 0)
2464 for (rend_t *srp = ROW(row).r; col < ncol; col++) 2492 for (rend_t *srp = ROW(row).r; col < ncol; col++)
2465 srp[col] ^= RS_RVid; 2493 srp[col] ^= RS_RVid;
2854 selection.op = SELECTION_DONE; 2882 selection.op = SELECTION_DONE;
2855 2883
2856 if (selection.clicks == 4) 2884 if (selection.clicks == 4)
2857 return; /* nothing selected, go away */ 2885 return; /* nothing selected, go away */
2858 2886
2887 if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2888 return;
2889
2859 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2890 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2860 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 2891 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2861 2892
2862 int ofs = 0; 2893 int ofs = 0;
2863 int extra = 0; 2894 int extra = 0;
2879#endif 2910#endif
2880 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2911 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN
2881 2912
2882 col = max (col, 0); 2913 col = max (col, 0);
2883 2914
2884 if (row == selection.end.row || selection.rect) 2915 if (row == selection.end.row
2916#if ENABLE_FRILLS
2917 || selection.rect
2918#endif
2919 )
2885 end_col = min (end_col, selection.end.col); 2920 min_it (end_col, selection.end.col);
2886 2921
2887 t = ROW(row).t + col; 2922 t = ROW(row).t + col;
2888 for (; col < end_col; col++) 2923 for (; col < end_col; col++)
2889 { 2924 {
2890 if (*t == NOCHAR) 2925 if (*t == NOCHAR)
2908#endif 2943#endif
2909 else 2944 else
2910 new_selection_text[ofs++] = *t++; 2945 new_selection_text[ofs++] = *t++;
2911 } 2946 }
2912 2947
2948#if ENABLE_FRILLS
2949 if (selection.rect)
2950 {
2951 while (ofs
2952 && new_selection_text[ofs - 1] != C0_LF
2953 && unicode::is_space (new_selection_text[ofs - 1]))
2954 --ofs;
2955
2956 new_selection_text[ofs++] = C0_LF;
2957 }
2958 else
2959#endif
2913 if (!ROW(row).is_longer () && row != selection.end.row) 2960 if (!ROW(row).is_longer () && row != selection.end.row)
2914 new_selection_text[ofs++] = C0_LF; 2961 new_selection_text[ofs++] = C0_LF;
2915 } 2962 }
2916 2963
2917 if (end_col != selection.end.col) 2964 if (end_col != selection.end.col)
2918 new_selection_text[ofs++] = C0_LF; 2965 new_selection_text[ofs++] = C0_LF;
2919 2966
2929 2976
2930 // we usually allocate much more than necessary, so realloc it smaller again 2977 // we usually allocate much more than necessary, so realloc it smaller again
2931 selection.len = ofs; 2978 selection.len = ofs;
2932 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); 2979 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t));
2933 2980
2981 if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END)))
2982 return;
2983
2984 selection_grab (tm);
2985}
2986
2987bool
2988rxvt_term::selection_grab (Time tm)
2989{
2990 selection_time = tm;
2991
2934 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2992 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2935 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2993 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
2994 {
2936 display->set_selection_owner (this); 2995 display->set_selection_owner (this);
2996 return true;
2997 }
2937 else 2998 else
2938 rxvt_warn ("can't get primary selection, ignoring.\n"); 2999 return false;
2939 3000
2940#if 0 3001#if 0
2941 XTextProperty ct; 3002 XTextProperty ct;
2942 3003
2943 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3004 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2944 { 3005 {
2945 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3006 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2946 XFree (ct.value); 3007 XFree (ct.value);
2947 } 3008 }
2948#endif 3009#endif
2949
2950 selection_time = tm;
2951} 3010}
2952 3011
2953/* ------------------------------------------------------------------------- */ 3012/* ------------------------------------------------------------------------- */
2954/* 3013/*
2955 * Mark or select text based upon number of clicks: 1, 2, or 3 3014 * Mark or select text based upon number of clicks: 1, 2, or 3
3270 selection_delimit_word (DN, &selection.end, &selection.end); 3329 selection_delimit_word (DN, &selection.end, &selection.end);
3271 } 3330 }
3272 else if (selection.clicks == 3) 3331 else if (selection.clicks == 3)
3273 { 3332 {
3274#if ENABLE_FRILLS 3333#if ENABLE_FRILLS
3275 if (options & Opt_tripleclickwords) 3334 if (OPTION (Opt_tripleclickwords))
3276 { 3335 {
3277 selection_delimit_word (UP, &selection.beg, &selection.beg); 3336 selection_delimit_word (UP, &selection.beg, &selection.beg);
3278 3337
3279 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3338 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3280 { 3339 {
3341 { 3400 {
3342 stp = ROW(end_row).t; 3401 stp = ROW(end_row).t;
3343 3402
3344 while (--end_col >= 0) 3403 while (--end_col >= 0)
3345 { 3404 {
3346 if (stp[end_col] != ' ' 3405 if (stp[end_col] != NOCHAR
3347 && stp[end_col] != '\t' 3406 && !unicode::is_space (stp[end_col]))
3348 && stp[end_col] != NOCHAR)
3349 break; 3407 break;
3350 } 3408 }
3351 3409
3352 if (end_col >= 0 3410 if (end_col >= 0
3353 || !ROW(end_row - 1).is_longer ()) 3411 || !ROW(end_row - 1).is_longer ())
3552 3610
3553#if ENABLE_OVERLAY 3611#if ENABLE_OVERLAY
3554void 3612void
3555rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3613rxvt_term::scr_overlay_new (int x, int y, int w, int h)
3556{ 3614{
3557 if (nrow < 3 || ncol < 3) 3615 if (nrow < 1 || ncol < 1)
3558 return; 3616 return;
3559 3617
3560 want_refresh = 1; 3618 want_refresh = 1;
3561 3619
3562 scr_overlay_off (); 3620 scr_overlay_off ();
3669 for (int y = ov_h; y--; ) 3727 for (int y = ov_h; y--; )
3670 { 3728 {
3671 text_t *t1 = ov_text[y]; 3729 text_t *t1 = ov_text[y];
3672 rend_t *r1 = ov_rend[y]; 3730 rend_t *r1 = ov_rend[y];
3673 3731
3674 text_t *t2 = ROW(y - view_start).t + ov_x; 3732 text_t *t2 = ROW(y + ov_y - view_start).t + ov_x;
3675 rend_t *r2 = ROW(y - view_start).r + ov_x; 3733 rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x;
3676 3734
3677 for (int x = ov_w; x--; ) 3735 for (int x = ov_w; x--; )
3678 { 3736 {
3679 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3737 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3680 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3738 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines