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.191 by root, Thu Dec 22 18:36:55 2005 UTC vs.
Revision 1.209 by root, Thu Jan 5 01:04:10 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() \
283 // to come up with a lean and mean algorithm. 284 // to come up with a lean and mean algorithm.
284 285
285 row_col_t ocur = screen.cur; 286 row_col_t ocur = screen.cur;
286 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 287 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
287 288
288 while (p != pend && q > 0) 289 do
289 { 290 {
290 p = MOD (p - 1, prev_total_rows); 291 p = MOD (p - 1, prev_total_rows);
291#ifdef DEBUG_STRICT 292#ifdef DEBUG_STRICT
292 assert (old_buf [MOD (p, prev_total_rows)].t); 293 assert (old_buf [MOD (p, prev_total_rows)].t);
293#endif 294#endif
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 }
367 while (p != pend && q > 0);
359 368
360 term_start = total_rows - nrow; 369 term_start = total_rows - nrow;
361 view_start = 0;
362 nsaved = term_start - q; 370 nsaved = term_start - q;
363 371
364 // make sure all terminal lines exist 372 // make sure all terminal lines exist
365 while (nsaved < 0) 373 while (nsaved < 0)
366 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); 374 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
383 { 391 {
384 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); 392 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
385 } 393 }
386 394
387 term_start = 0; 395 term_start = 0;
388 view_start = 0;
389 } 396 }
390 397
391#ifdef DEBUG_STRICT 398#ifdef DEBUG_STRICT //TODO: remove
392 for (int i = -nsaved; i < nrow; i++) 399 for (int i = -nsaved; i < nrow; i++)
393 assert (ROW (i).t); 400 assert (ROW (i).t);
394#endif 401#endif
395 402
396 free (old_buf); 403 free (old_buf);
411 418
412 for (int col = ncol; col--; ) 419 for (int col = ncol; col--; )
413 tabs [col] = col % TABSIZE == 0; 420 tabs [col] = col % TABSIZE == 0;
414 421
415 tt_winch (); 422 tt_winch ();
423
424 PERL_INVOKE ((this, HOOK_RESET, DT_END));
416} 425}
417 426
418/* ------------------------------------------------------------------------- */ 427/* ------------------------------------------------------------------------- */
419/* 428/*
420 * Free everything. That way malloc debugging can find leakage. 429 * Free everything. That way malloc debugging can find leakage.
524 533
525 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); 534 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
526 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); 535 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
527 536
528#if NSCREENS 537#if NSCREENS
529 if (options & Opt_secondaryScreen) 538 if (OPTION (Opt_secondaryScreen))
530 { 539 {
531 num_scr = 0; 540 num_scr = 0;
532 541
533 for (int i = prev_nrow; i--; ) 542 for (int i = prev_nrow; i--; )
534 ::swap (ROW(i), swap_buf [i]); 543 ::swap (ROW(i), swap_buf [i]);
538 screen.flags |= Screen_VisibleCursor; 547 screen.flags |= Screen_VisibleCursor;
539 swap.flags |= Screen_VisibleCursor; 548 swap.flags |= Screen_VisibleCursor;
540 } 549 }
541 else 550 else
542#endif 551#endif
543 if (options & Opt_secondaryScroll) 552 if (OPTION (Opt_secondaryScroll))
544 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 553 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
545 554
546 return scrn; 555 return scrn;
547} 556}
548 557
610 num_scr += count; 619 num_scr += count;
611 620
612 if (count > 0 621 if (count > 0
613 && row1 == 0 622 && row1 == 0
614 && row2 == nrow - 1 623 && row2 == nrow - 1
615 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 624 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
616 { 625 {
617 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
618 term_start = (term_start + count) % total_rows; 630 term_start = (term_start + count) % total_rows;
619 631
620 if (selection.op && current_screen == selection.screen) 632 if (selection.op && current_screen == selection.screen)
621 { 633 {
622 selection.beg.row -= count; 634 selection.beg.row -= count;
623 selection.end.row -= count; 635 selection.end.row -= count;
624 selection.mark.row -= count; 636 selection.mark.row -= count;
625 637
626 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 }
627 } 645 }
628 646
629 for (int i = count; i--; ) 647 for (int i = count; i--; )
648 {
649 ROW(row2 - i).l = 0;
630 scr_blank_screen_mem (ROW(row2 - i), rstyle); 650 scr_blank_screen_mem (ROW(row2 - i), rstyle);
651 }
631 652
632 if ((options & Opt_scrollWithBuffer) 653 if (OPTION (Opt_scrollWithBuffer)
633 && view_start != 0 654 && view_start != 0
634 && view_start != saveLines) 655 && view_start != saveLines)
635 scr_page (UP, count); 656 scr_page (UP, count);
636 } 657 }
637 else 658 else
638 { 659 {
639 if (selection.op && current_screen == selection.screen) 660 if (selection.op && current_screen == selection.screen)
640 { 661 {
641 int i = selection.beg.row; 662 if ((selection.beg.row < row1 && selection.end.row > row1)
642 int j = selection.end.row; 663 || (selection.beg.row < row2 && selection.end.row > row2)
643
644 if ((i < row1 && j > row1)
645 || (i < row2 && j > row2)
646 || (i - count < row1 && i >= row1) 664 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
647 || (i - count > row2 && i <= row2) 665 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
648 || (j - count < row1 && j >= row1) 666 || (selection.end.row - count < row1 && selection.end.row >= row1)
649 || (j - count > row2 && j <= row2)) 667 || (selection.end.row - count > row2 && selection.end.row <= row2))
650 { 668 {
651 CLEAR_ALL_SELECTION (); 669 CLEAR_ALL_SELECTION ();
652 selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ 670 selection.op = SELECTION_CLEAR;
653 } 671 }
654 else if (j >= row1 && j <= row2) 672 else if (selection.end.row >= row1 && selection.end.row <= row2)
655 { 673 {
656 /* move selected region too */ 674 /* move selected region too */
657 selection.beg.row -= count; 675 selection.beg.row -= count;
658 selection.end.row -= count; 676 selection.end.row -= count;
659 selection.mark.row -= count; 677 selection.mark.row -= count;
694 if (len <= 0) /* sanity */ 712 if (len <= 0) /* sanity */
695 return; 713 return;
696 714
697 unsigned char checksel; 715 unsigned char checksel;
698 unicode_t c; 716 unicode_t c;
699 int row, last_col; 717 int last_col;
700 const unicode_t *strend = str + len; 718 const unicode_t *strend = str + len;
701 719
702 want_refresh = 1; 720 want_refresh = 1;
703 ZERO_SCROLLBACK (); 721 ZERO_SCROLLBACK ();
704 last_col = ncol; 722 last_col = ncol;
705 723
706 if (nlines > 0) 724 if (nlines > 0)
707 { 725 {
708 nlines += screen.cur.row - screen.bscroll; 726 nlines += screen.cur.row - screen.bscroll;
727
709 if (nlines > 0 728 if (nlines > 0
710 && screen.tscroll == 0 729 && screen.tscroll == 0
711 && screen.bscroll == (nrow - 1)) 730 && screen.bscroll == (nrow - 1))
712 { 731 {
713 /* _at least_ this many lines need to be scrolled */ 732 /* _at least_ this many lines need to be scrolled */
719#ifdef DEBUG_STRICT 738#ifdef DEBUG_STRICT
720 assert (screen.cur.col < last_col); 739 assert (screen.cur.col < last_col);
721 assert (screen.cur.row < nrow 740 assert (screen.cur.row < nrow
722 && screen.cur.row >= -nsaved); 741 && screen.cur.row >= -nsaved);
723#endif 742#endif
724 row = screen.cur.row; 743 int row = screen.cur.row;
725 744
726 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 745 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
727 746
728 line_t *line = &ROW(row); 747 line_t *line = &ROW(row);
729 748
731 { 750 {
732 c = *str++; 751 c = *str++;
733 752
734 if (c < 0x20) 753 if (c < 0x20)
735 if (c == C0_LF) 754 if (c == C0_LF)
736 { 755 {
737 if (!line->is_longer ()) /* XXX: think about this */ 756 if (!line->is_longer ()) /* XXX: think about this */
738 max_it (line->l, screen.cur.col); 757 max_it (line->l, screen.cur.col);
739 758
740 screen.flags &= ~Screen_WrapNext; 759 screen.flags &= ~Screen_WrapNext;
741 760
986 1005
987 if (count == 0) 1006 if (count == 0)
988 return; 1007 return;
989 else if (count > 0) 1008 else if (count > 0)
990 { 1009 {
991 int row = screen.cur.row;
992
993 line_t &l = ROW(row); 1010 line_t &l = ROW(screen.cur.row);
994 rend_t base_rend = l.r[i]; 1011 rend_t base_rend = l.r[i];
995 ht &= l.t[i] == ' '; 1012 ht &= l.t[i] == ' ';
996 1013
997 for (; ++i < ncol; ) 1014 for (; ++i < ncol; )
998 if (tabs[i]) 1015 if (tabs[i])
1008 if (count) 1025 if (count)
1009 x = ncol - 1; 1026 x = ncol - 1;
1010 1027
1011 // store horizontal tab commands as characters inside the text 1028 // store horizontal tab commands as characters inside the text
1012 // buffer so they can be selected and pasted. 1029 // buffer so they can be selected and pasted.
1013 if (ht && options & Opt_pastableTabs) 1030 if (ht && OPTION (Opt_pastableTabs))
1014 { 1031 {
1015 base_rend = SET_FONT (base_rend, 0); 1032 base_rend = SET_FONT (base_rend, 0);
1016 1033
1017 if (!l.is_longer ()) /* XXX: think about this */ 1034 if (!l.is_longer ()) /* XXX: think about this */
1018 max_it (l.l, x); 1035 max_it (l.l, x);
1073 */ 1090 */
1074#if ENABLE_FRILLS 1091#if ENABLE_FRILLS
1075void 1092void
1076rxvt_term::scr_forwardindex () 1093rxvt_term::scr_forwardindex ()
1077{ 1094{
1078 int row;
1079
1080 if (screen.cur.col < ncol - 1) 1095 if (screen.cur.col < ncol - 1)
1081 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1096 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1082 else 1097 else
1083 { 1098 {
1084 row = screen.cur.row;
1085
1086 if (ROW(row).is_longer ()) //TODO//FIXME//LEN 1099 if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN
1087 ROW(row).l = ncol; 1100 ROW(screen.cur.row).l = ncol;
1088 1101
1089 scr_gotorc (0, 0, R_RELATIVE); 1102 scr_gotorc (0, 0, R_RELATIVE);
1090 scr_insdel_chars (1, DELETE); 1103 scr_insdel_chars (1, DELETE);
1091 scr_gotorc (0, ncol - 1, R_RELATIVE); 1104 scr_gotorc (0, ncol - 1, R_RELATIVE);
1092 } 1105 }
1175 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1188 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1176 */ 1189 */
1177void 1190void
1178rxvt_term::scr_erase_line (int mode) 1191rxvt_term::scr_erase_line (int mode)
1179{ 1192{
1180 unsigned int row, col, num; 1193 unsigned int col, num;
1181 1194
1182 want_refresh = 1; 1195 want_refresh = 1;
1183 ZERO_SCROLLBACK (); 1196 ZERO_SCROLLBACK ();
1184 1197
1185 selection_check (1); 1198 selection_check (1);
1186 1199
1187 row = screen.cur.row; 1200 line_t &line = ROW(screen.cur.row);
1188 1201
1189 switch (mode) 1202 switch (mode)
1190 { 1203 {
1191 case 0: /* erase to end of line */ 1204 case 0: /* erase to end of line */
1192 col = screen.cur.col; 1205 col = screen.cur.col;
1193 num = ncol - col; 1206 num = ncol - col;
1194 min_it (ROW(row).l, col); 1207 min_it (line.l, col);
1195 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1208 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1196 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1209 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1197 CLEAR_SELECTION (); 1210 CLEAR_SELECTION ();
1198 break; 1211 break;
1199 case 1: /* erase to beginning of line */ 1212 case 1: /* erase to beginning of line */
1204 CLEAR_SELECTION (); 1217 CLEAR_SELECTION ();
1205 break; 1218 break;
1206 case 2: /* erase whole line */ 1219 case 2: /* erase whole line */
1207 col = 0; 1220 col = 0;
1208 num = ncol; 1221 num = ncol;
1209 ROW(row).l = 0; 1222 line.l = 0;
1210 if (selection.beg.row <= screen.cur.row 1223 if (selection.beg.row <= screen.cur.row
1211 && selection.end.row >= screen.cur.row) 1224 && selection.end.row >= screen.cur.row)
1212 CLEAR_SELECTION (); 1225 CLEAR_SELECTION ();
1213 break; 1226 break;
1214 default: 1227 default:
1215 return; 1228 return;
1216 } 1229 }
1217 1230
1218 scr_blank_line (ROW(row), col, num, rstyle); 1231 scr_blank_line (line, col, num, rstyle);
1219} 1232}
1220 1233
1221/* ------------------------------------------------------------------------- */ 1234/* ------------------------------------------------------------------------- */
1222/* 1235/*
1223 * Erase part of whole of the screen 1236 * Erase part of whole of the screen
1278 CLEAR_ROWS (row, num); 1291 CLEAR_ROWS (row, num);
1279 } 1292 }
1280 else 1293 else
1281 { 1294 {
1282 ren = rstyle & (RS_fgMask | RS_bgMask); 1295 ren = rstyle & (RS_fgMask | RS_bgMask);
1283 gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; 1296 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1284 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1297 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1285 ERASE_ROWS (row, num); 1298 ERASE_ROWS (row, num);
1286 gcvalue.foreground = pix_colors[Color_fg]; 1299 gcvalue.foreground = pix_colors[Color_fg];
1287 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1300 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1288 } 1301 }
1289 1302
1290 for (; num--; row++) 1303 for (; num--; row++)
1291 { 1304 {
1305 ROW (row).l = 0;
1292 scr_blank_screen_mem (ROW (row), rstyle); 1306 scr_blank_screen_mem (ROW (row), rstyle);
1293 ROW (row).l = 0;
1294 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1307 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1295 } 1308 }
1296} 1309}
1297 1310
1298#if ENABLE_FRILLS 1311#if ENABLE_FRILLS
1587 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1600 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1588#if XPM_BACKGROUND 1601#if XPM_BACKGROUND
1589 if (bgPixmap.pixmap == None) 1602 if (bgPixmap.pixmap == None)
1590#endif 1603#endif
1591#if TRANSPARENT 1604#if TRANSPARENT
1592 if (! (options & Opt_transparent) || am_transparent == 0) 1605 if (! OPTION (Opt_transparent) || am_transparent == 0)
1593#endif 1606#endif
1594 XSetWindowBackground (display->display, vt, 1607 XSetWindowBackground (display->display, vt,
1595 pix_colors[Color_bg]); 1608 pix_colors[Color_bg]);
1596 1609
1597 gcvalue.foreground = pix_colors[Color_fg]; 1610 gcvalue.foreground = pix_colors[Color_fg];
1813} 1826}
1814 1827
1815int 1828int
1816rxvt_term::scr_changeview (unsigned int oldviewstart) 1829rxvt_term::scr_changeview (unsigned int oldviewstart)
1817{ 1830{
1831 PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1832
1818 if (view_start != oldviewstart) 1833 if (view_start != oldviewstart)
1819 { 1834 {
1820 want_refresh = 1; 1835 want_refresh = 1;
1821 num_scr -= (view_start - oldviewstart); 1836 num_scr -= (view_start - oldviewstart);
1822 } 1837 }
1830{ 1845{
1831#ifndef NO_BELL 1846#ifndef NO_BELL
1832 1847
1833# ifndef NO_MAPALERT 1848# ifndef NO_MAPALERT
1834# ifdef MAPALERT_OPTION 1849# ifdef MAPALERT_OPTION
1835 if (options & Opt_mapAlert) 1850 if (OPTION (Opt_mapAlert))
1836# endif 1851# endif
1837 XMapWindow (display->display, parent[0]); 1852 XMapWindow (display->display, parent[0]);
1838# endif 1853# endif
1839 1854
1840 if (options & Opt_visualBell) 1855 if (OPTION (Opt_visualBell))
1841 { 1856 {
1842 scr_rvideo_mode (!rvideo); /* refresh also done */ 1857 scr_rvideo_mode (!rvideo); /* refresh also done */
1843 rxvt_usleep (VISUAL_BELL_DURATION); 1858 rxvt_usleep (VISUAL_BELL_DURATION);
1844 scr_rvideo_mode (!rvideo); /* refresh also done */ 1859 scr_rvideo_mode (!rvideo); /* refresh also done */
1845 } 1860 }
1936 1951
1937#if XPM_BACKGROUND 1952#if XPM_BACKGROUND
1938 must_clear |= bgPixmap.pixmap != None; 1953 must_clear |= bgPixmap.pixmap != None;
1939#endif 1954#endif
1940#if TRANSPARENT 1955#if TRANSPARENT
1941 must_clear |= (options & Opt_transparent) && am_transparent; 1956 must_clear |= OPTION (Opt_transparent) && am_transparent;
1942#endif 1957#endif
1943 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1958 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1944 1959
1945 /* 1960 /*
1946 * B: reverse any characters which are selected 1961 * B: reverse any characters which are selected
1970 1985
1971 crp = &ROW(screen.cur.row).r[col]; 1986 crp = &ROW(screen.cur.row).r[col];
1972 1987
1973 if (showcursor && focus) 1988 if (showcursor && focus)
1974 { 1989 {
1975 if (options & Opt_cursorUnderline) 1990 if (OPTION (Opt_cursorUnderline))
1976 *crp ^= RS_Uline; 1991 *crp ^= RS_Uline;
1977 else 1992 else
1978 { 1993 {
1979 *crp ^= RS_RVid; 1994 *crp ^= RS_RVid;
1980 1995
1982 cc1 = *crp & (RS_fgMask | RS_bgMask); 1997 cc1 = *crp & (RS_fgMask | RS_bgMask);
1983 if (ISSET_PIXCOLOR (Color_cursor)) 1998 if (ISSET_PIXCOLOR (Color_cursor))
1984 ccol1 = Color_cursor; 1999 ccol1 = Color_cursor;
1985 else 2000 else
1986#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2001#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1987 ccol1 = GET_FGCOLOR (rstyle); 2002 ccol1 = fgcolor_of (rstyle);
1988#else 2003#else
1989 ccol1 = Color_fg; 2004 ccol1 = Color_fg;
1990#endif 2005#endif
1991 if (ISSET_PIXCOLOR (Color_cursor2)) 2006 if (ISSET_PIXCOLOR (Color_cursor2))
1992 ccol2 = Color_cursor2; 2007 ccol2 = Color_cursor2;
1993 else 2008 else
1994#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2009#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1995 ccol2 = GET_BGCOLOR (rstyle); 2010 ccol2 = bgcolor_of (rstyle);
1996#else 2011#else
1997 ccol2 = Color_bg; 2012 ccol2 = Color_bg;
1998#endif 2013#endif
1999 *crp = SET_FGCOLOR (*crp, ccol1); 2014 *crp = SET_FGCOLOR (*crp, ccol1);
2000 *crp = SET_BGCOLOR (*crp, ccol2); 2015 *crp = SET_BGCOLOR (*crp, ccol2);
2033 oldcursor.col = screen.cur.col; 2048 oldcursor.col = screen.cur.col;
2034 } 2049 }
2035 } 2050 }
2036 } 2051 }
2037 2052
2053 PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2038#if ENABLE_OVERLAY 2054#if ENABLE_OVERLAY
2039 scr_swap_overlay (); 2055 scr_swap_overlay ();
2040#endif 2056#endif
2041 2057
2042#ifndef NO_SLOW_LINK_SUPPORT 2058#ifndef NO_SLOW_LINK_SUPPORT
2092 if (wlen < len) 2108 if (wlen < len)
2093 ::swap (wlen, len); 2109 ::swap (wlen, len);
2094 2110
2095 XCopyArea (display->display, vt, vt, 2111 XCopyArea (display->display, vt, vt,
2096 gc, 0, Row2Pixel (len + i), 2112 gc, 0, Row2Pixel (len + i),
2097 (unsigned int)TermWin_TotalWidth (), 2113 (unsigned int)this->width,
2098 (unsigned int)Height2Pixel (wlen - len + 1), 2114 (unsigned int)Height2Pixel (wlen - len + 1),
2099 0, Row2Pixel (len)); 2115 0, Row2Pixel (len));
2100 len = -1; 2116 len = -1;
2101 } 2117 }
2102 } 2118 }
2181 count++, i--; 2197 count++, i--;
2182 2198
2183 /* 2199 /*
2184 * Determine the attributes for the string 2200 * Determine the attributes for the string
2185 */ 2201 */
2186 int fore = GET_FGCOLOR (rend); // desired foreground 2202 int fore = fgcolor_of (rend); // desired foreground
2187 int back = GET_BGCOLOR (rend); // desired background 2203 int back = bgcolor_of (rend); // desired background
2188 2204
2189 // only do special processing if any attributes are set, which is rare 2205 // only do special processing if any attributes are set, which is unlikely
2190 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2206 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2191 { 2207 {
2192#if ENABLE_STYLES 2208#if ENABLE_STYLES
2193 // force redraw after "careful" characters to avoid pixel droppings 2209 // force redraw after "careful" characters to avoid pixel droppings
2194 if (srp[col] & RS_Careful && col < ncol - 1 && 0) 2210 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2305 } /* for (row....) */ 2321 } /* for (row....) */
2306 2322
2307#if ENABLE_OVERLAY 2323#if ENABLE_OVERLAY
2308 scr_swap_overlay (); 2324 scr_swap_overlay ();
2309#endif 2325#endif
2326 PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2310 2327
2311 /* 2328 /*
2312 * G: cleanup cursor and display outline cursor if necessary 2329 * G: cleanup cursor and display outline cursor if necessary
2313 */ 2330 */
2314 if (showcursor) 2331 if (showcursor)
2315 { 2332 {
2316 if (focus) 2333 if (focus)
2317 { 2334 {
2318 if (options & Opt_cursorUnderline) 2335 if (OPTION (Opt_cursorUnderline))
2319 *crp ^= RS_Uline; 2336 *crp ^= RS_Uline;
2320 else 2337 else
2321 { 2338 {
2322 *crp ^= RS_RVid; 2339 *crp ^= RS_RVid;
2323#ifndef NO_CURSORCOLOR 2340#ifndef NO_CURSORCOLOR
2442 2459
2443#if ENABLE_FRILLS 2460#if ENABLE_FRILLS
2444 if (selection.rect) 2461 if (selection.rect)
2445 { 2462 {
2446 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) 2463 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++)
2464 {
2465 text_t *stp = ROW(row).t;
2466 rend_t *srp = ROW(row).r;
2467
2447 for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) 2468 for (col = selection.beg.col; col < selection.end.col; col++)
2448 srp[col] ^= RS_RVid; 2469 srp[col] ^= RS_RVid;
2470
2471 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2472 srp[col] ^= RS_RVid | RS_Uline;
2473
2474 if (++col < selection.end.col)
2475 srp[col] ^= RS_RVid | RS_Uline;
2476 }
2449 } 2477 }
2450 else 2478 else
2451#endif 2479#endif
2452 { 2480 {
2453 if (selection.beg.row >= -view_start) 2481 if (selection.beg.row >= -view_start)
2456 row = selection.beg.row; 2484 row = selection.beg.row;
2457 } 2485 }
2458 else 2486 else
2459 { 2487 {
2460 col = 0; 2488 col = 0;
2461 row = view_start; 2489 row = -view_start;
2462 } 2490 }
2463 2491
2464 for (; row < min (selection.end.row, view_end); row++, col = 0) 2492 for (; row < min (selection.end.row, view_end); row++, col = 0)
2465 for (rend_t *srp = ROW(row).r; col < ncol; col++) 2493 for (rend_t *srp = ROW(row).r; col < ncol; col++)
2466 srp[col] ^= RS_RVid; 2494 srp[col] ^= RS_RVid;
2537/* ------------------------------------------------------------------------- */ 2565/* ------------------------------------------------------------------------- */
2538/* 2566/*
2539 * Paste a selection direct to the command fd 2567 * Paste a selection direct to the command fd
2540 */ 2568 */
2541void 2569void
2542rxvt_term::paste (unsigned char *data, unsigned int len) 2570rxvt_term::paste (char *data, unsigned int len)
2543{ 2571{
2544 /* convert normal newline chars into common keyboard Return key sequence */ 2572 /* convert normal newline chars into common keyboard Return key sequence */
2545 for (unsigned int i = 0; i < len; i++) 2573 for (unsigned int i = 0; i < len; i++)
2546 if (data[i] == C0_LF) 2574 if (data[i] == C0_LF)
2547 data[i] = C0_CR; 2575 data[i] = C0_CR;
2691 { 2719 {
2692 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2720 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2693 char *s = rxvt_wcstombs (w); 2721 char *s = rxvt_wcstombs (w);
2694 free (w); 2722 free (w);
2695 // TODO: strlen == only the first element will be converted. well... 2723 // TODO: strlen == only the first element will be converted. well...
2696 paste ((unsigned char *)s, strlen (s)); 2724 paste (s, strlen (s));
2697 free (s); 2725 free (s);
2698 } 2726 }
2699 else 2727 else
2700#endif 2728#endif
2701 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2729 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0
2702 && cl) 2730 && cl)
2703 { 2731 {
2704 for (int i = 0; i < cr; i++) 2732 for (int i = 0; i < cr; i++)
2705 paste ((unsigned char *)cl[i], strlen (cl[i])); 2733 paste (cl[i], strlen (cl[i]));
2706 2734
2707 XFreeStringList (cl); 2735 XFreeStringList (cl);
2708 } 2736 }
2709 else 2737 else
2710 paste (ct.value, ct.nitems); // paste raw 2738 paste ((char *)ct.value, ct.nitems); // paste raw
2711 2739
2712bailout: 2740bailout:
2713 XFree (ct.value); 2741 XFree (ct.value);
2714 2742
2715 if (selection_wait == Sel_normal) 2743 if (selection_wait == Sel_normal)
2753 return; /* outside window */ 2781 return; /* outside window */
2754 2782
2755 if (selection.text) 2783 if (selection.text)
2756 { /* internal selection */ 2784 { /* internal selection */
2757 char *str = rxvt_wcstombs (selection.text, selection.len); 2785 char *str = rxvt_wcstombs (selection.text, selection.len);
2758 paste ((unsigned char *)str, strlen (str)); 2786 paste (str, strlen (str));
2759 free (str); 2787 free (str);
2760 return; 2788 return;
2761 } 2789 }
2762 else 2790 else
2763 { 2791 {
2855 selection.op = SELECTION_DONE; 2883 selection.op = SELECTION_DONE;
2856 2884
2857 if (selection.clicks == 4) 2885 if (selection.clicks == 4)
2858 return; /* nothing selected, go away */ 2886 return; /* nothing selected, go away */
2859 2887
2888 if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2889 return;
2890
2860 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2891 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2861 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 2892 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2862 2893
2863 int ofs = 0; 2894 int ofs = 0;
2864 int extra = 0; 2895 int extra = 0;
2880#endif 2911#endif
2881 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2912 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN
2882 2913
2883 col = max (col, 0); 2914 col = max (col, 0);
2884 2915
2885 if (row == selection.end.row || selection.rect) 2916 if (row == selection.end.row
2917#if ENABLE_FRILLS
2918 || selection.rect
2919#endif
2920 )
2886 end_col = min (end_col, selection.end.col); 2921 min_it (end_col, selection.end.col);
2887 2922
2888 t = ROW(row).t + col; 2923 t = ROW(row).t + col;
2889 for (; col < end_col; col++) 2924 for (; col < end_col; col++)
2890 { 2925 {
2891 if (*t == NOCHAR) 2926 if (*t == NOCHAR)
2909#endif 2944#endif
2910 else 2945 else
2911 new_selection_text[ofs++] = *t++; 2946 new_selection_text[ofs++] = *t++;
2912 } 2947 }
2913 2948
2949#if ENABLE_FRILLS
2950 if (selection.rect)
2951 {
2952 while (ofs
2953 && new_selection_text[ofs - 1] != C0_LF
2954 && unicode::is_space (new_selection_text[ofs - 1]))
2955 --ofs;
2956
2957 new_selection_text[ofs++] = C0_LF;
2958 }
2959 else
2960#endif
2914 if (!ROW(row).is_longer () && row != selection.end.row) 2961 if (!ROW(row).is_longer () && row != selection.end.row)
2915 new_selection_text[ofs++] = C0_LF; 2962 new_selection_text[ofs++] = C0_LF;
2916 } 2963 }
2917 2964
2918 if (end_col != selection.end.col) 2965 if (end_col != selection.end.col)
2919 new_selection_text[ofs++] = C0_LF; 2966 new_selection_text[ofs++] = C0_LF;
2920 2967
2930 2977
2931 // we usually allocate much more than necessary, so realloc it smaller again 2978 // we usually allocate much more than necessary, so realloc it smaller again
2932 selection.len = ofs; 2979 selection.len = ofs;
2933 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); 2980 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t));
2934 2981
2982 if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END)))
2983 return;
2984
2985 selection_grab (tm);
2986}
2987
2988bool
2989rxvt_term::selection_grab (Time tm)
2990{
2991 selection_time = tm;
2992
2935 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2993 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2936 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2994 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
2995 {
2937 display->set_selection_owner (this); 2996 display->set_selection_owner (this);
2997 return true;
2998 }
2938 else 2999 else
2939 rxvt_warn ("can't get primary selection, ignoring.\n"); 3000 return false;
2940 3001
2941#if 0 3002#if 0
2942 XTextProperty ct; 3003 XTextProperty ct;
2943 3004
2944 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3005 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2945 { 3006 {
2946 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3007 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2947 XFree (ct.value); 3008 XFree (ct.value);
2948 } 3009 }
2949#endif 3010#endif
2950
2951 selection_time = tm;
2952} 3011}
2953 3012
2954/* ------------------------------------------------------------------------- */ 3013/* ------------------------------------------------------------------------- */
2955/* 3014/*
2956 * Mark or select text based upon number of clicks: 1, 2, or 3 3015 * Mark or select text based upon number of clicks: 1, 2, or 3
3078 } 3137 }
3079 } 3138 }
3080 break; 3139 break;
3081 } 3140 }
3082 3141
3083Old_Word_Selection_You_Die:
3084 if (dirn == DN) 3142 if (dirn == DN)
3085 col++; /* put us on one past the end */ 3143 col++; /* put us on one past the end */
3086 3144
3087 /* Poke the values back in */ 3145 /* Poke the values back in */
3088 ret->row = row; 3146 ret->row = row;
3265 else if (selection.clicks == 2) 3323 else if (selection.clicks == 2)
3266 { 3324 {
3267 if (ROWCOL_IS_AFTER (selection.end, selection.beg)) 3325 if (ROWCOL_IS_AFTER (selection.end, selection.beg))
3268 selection.end.col--; 3326 selection.end.col--;
3269 3327
3328 if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
3329 {
3270 selection_delimit_word (UP, &selection.beg, &selection.beg); 3330 selection_delimit_word (UP, &selection.beg, &selection.beg);
3271 selection_delimit_word (DN, &selection.end, &selection.end); 3331 selection_delimit_word (DN, &selection.end, &selection.end);
3332 }
3272 } 3333 }
3273 else if (selection.clicks == 3) 3334 else if (selection.clicks == 3)
3274 { 3335 {
3275#if ENABLE_FRILLS 3336#if ENABLE_FRILLS
3276 if (options & Opt_tripleclickwords) 3337 if (OPTION (Opt_tripleclickwords))
3277 { 3338 {
3278 selection_delimit_word (UP, &selection.beg, &selection.beg); 3339 selection_delimit_word (UP, &selection.beg, &selection.beg);
3279 3340
3280 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3341 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3281 { 3342 {
3342 { 3403 {
3343 stp = ROW(end_row).t; 3404 stp = ROW(end_row).t;
3344 3405
3345 while (--end_col >= 0) 3406 while (--end_col >= 0)
3346 { 3407 {
3347 if (stp[end_col] != ' ' 3408 if (stp[end_col] != NOCHAR
3348 && stp[end_col] != '\t' 3409 && !unicode::is_space (stp[end_col]))
3349 && stp[end_col] != NOCHAR)
3350 break; 3410 break;
3351 } 3411 }
3352 3412
3353 if (end_col >= 0 3413 if (end_col >= 0
3354 || !ROW(end_row - 1).is_longer ()) 3414 || !ROW(end_row - 1).is_longer ())
3553 3613
3554#if ENABLE_OVERLAY 3614#if ENABLE_OVERLAY
3555void 3615void
3556rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3616rxvt_term::scr_overlay_new (int x, int y, int w, int h)
3557{ 3617{
3558 if (nrow < 3 || ncol < 3) 3618 if (nrow < 1 || ncol < 1)
3559 return; 3619 return;
3560 3620
3561 want_refresh = 1; 3621 want_refresh = 1;
3562 3622
3563 scr_overlay_off (); 3623 scr_overlay_off ();
3670 for (int y = ov_h; y--; ) 3730 for (int y = ov_h; y--; )
3671 { 3731 {
3672 text_t *t1 = ov_text[y]; 3732 text_t *t1 = ov_text[y];
3673 rend_t *r1 = ov_rend[y]; 3733 rend_t *r1 = ov_rend[y];
3674 3734
3675 text_t *t2 = ROW(y - view_start).t + ov_x; 3735 text_t *t2 = ROW(y + ov_y - view_start).t + ov_x;
3676 rend_t *r2 = ROW(y - view_start).r + ov_x; 3736 rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x;
3677 3737
3678 for (int x = ov_w; x--; ) 3738 for (int x = ov_w; x--; )
3679 { 3739 {
3680 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3740 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3681 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3741 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