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.195 by root, Mon Dec 26 23:02:34 2005 UTC vs.
Revision 1.207 by root, Wed Jan 4 04:42:45 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 {
357 printf ("qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D 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
358 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 365 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
359 } 366 }
360 while (p != pend && q > 0); 367 while (p != pend && q > 0);
361 368
362 term_start = total_rows - nrow; 369 term_start = total_rows - nrow;
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;
636 { 648 {
637 ROW(row2 - i).l = 0; 649 ROW(row2 - i).l = 0;
638 scr_blank_screen_mem (ROW(row2 - i), rstyle); 650 scr_blank_screen_mem (ROW(row2 - i), rstyle);
639 } 651 }
640 652
641 if ((options & Opt_scrollWithBuffer) 653 if (OPTION (Opt_scrollWithBuffer)
642 && view_start != 0 654 && view_start != 0
643 && view_start != saveLines) 655 && view_start != saveLines)
644 scr_page (UP, count); 656 scr_page (UP, count);
645 } 657 }
646 else 658 else
1012 if (count) 1024 if (count)
1013 x = ncol - 1; 1025 x = ncol - 1;
1014 1026
1015 // store horizontal tab commands as characters inside the text 1027 // store horizontal tab commands as characters inside the text
1016 // buffer so they can be selected and pasted. 1028 // buffer so they can be selected and pasted.
1017 if (ht && options & Opt_pastableTabs) 1029 if (ht && OPTION (Opt_pastableTabs))
1018 { 1030 {
1019 base_rend = SET_FONT (base_rend, 0); 1031 base_rend = SET_FONT (base_rend, 0);
1020 1032
1021 if (!l.is_longer ()) /* XXX: think about this */ 1033 if (!l.is_longer ()) /* XXX: think about this */
1022 max_it (l.l, x); 1034 max_it (l.l, x);
1278 CLEAR_ROWS (row, num); 1290 CLEAR_ROWS (row, num);
1279 } 1291 }
1280 else 1292 else
1281 { 1293 {
1282 ren = rstyle & (RS_fgMask | RS_bgMask); 1294 ren = rstyle & (RS_fgMask | RS_bgMask);
1283 gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; 1295 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1284 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1296 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1285 ERASE_ROWS (row, num); 1297 ERASE_ROWS (row, num);
1286 gcvalue.foreground = pix_colors[Color_fg]; 1298 gcvalue.foreground = pix_colors[Color_fg];
1287 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1299 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1288 } 1300 }
1587 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1599 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1588#if XPM_BACKGROUND 1600#if XPM_BACKGROUND
1589 if (bgPixmap.pixmap == None) 1601 if (bgPixmap.pixmap == None)
1590#endif 1602#endif
1591#if TRANSPARENT 1603#if TRANSPARENT
1592 if (! (options & Opt_transparent) || am_transparent == 0) 1604 if (! OPTION (Opt_transparent) || am_transparent == 0)
1593#endif 1605#endif
1594 XSetWindowBackground (display->display, vt, 1606 XSetWindowBackground (display->display, vt,
1595 pix_colors[Color_bg]); 1607 pix_colors[Color_bg]);
1596 1608
1597 gcvalue.foreground = pix_colors[Color_fg]; 1609 gcvalue.foreground = pix_colors[Color_fg];
1813} 1825}
1814 1826
1815int 1827int
1816rxvt_term::scr_changeview (unsigned int oldviewstart) 1828rxvt_term::scr_changeview (unsigned int oldviewstart)
1817{ 1829{
1830 PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1831
1818 if (view_start != oldviewstart) 1832 if (view_start != oldviewstart)
1819 { 1833 {
1820 want_refresh = 1; 1834 want_refresh = 1;
1821 num_scr -= (view_start - oldviewstart); 1835 num_scr -= (view_start - oldviewstart);
1822 } 1836 }
1830{ 1844{
1831#ifndef NO_BELL 1845#ifndef NO_BELL
1832 1846
1833# ifndef NO_MAPALERT 1847# ifndef NO_MAPALERT
1834# ifdef MAPALERT_OPTION 1848# ifdef MAPALERT_OPTION
1835 if (options & Opt_mapAlert) 1849 if (OPTION (Opt_mapAlert))
1836# endif 1850# endif
1837 XMapWindow (display->display, parent[0]); 1851 XMapWindow (display->display, parent[0]);
1838# endif 1852# endif
1839 1853
1840 if (options & Opt_visualBell) 1854 if (OPTION (Opt_visualBell))
1841 { 1855 {
1842 scr_rvideo_mode (!rvideo); /* refresh also done */ 1856 scr_rvideo_mode (!rvideo); /* refresh also done */
1843 rxvt_usleep (VISUAL_BELL_DURATION); 1857 rxvt_usleep (VISUAL_BELL_DURATION);
1844 scr_rvideo_mode (!rvideo); /* refresh also done */ 1858 scr_rvideo_mode (!rvideo); /* refresh also done */
1845 } 1859 }
1936 1950
1937#if XPM_BACKGROUND 1951#if XPM_BACKGROUND
1938 must_clear |= bgPixmap.pixmap != None; 1952 must_clear |= bgPixmap.pixmap != None;
1939#endif 1953#endif
1940#if TRANSPARENT 1954#if TRANSPARENT
1941 must_clear |= (options & Opt_transparent) && am_transparent; 1955 must_clear |= OPTION (Opt_transparent) && am_transparent;
1942#endif 1956#endif
1943 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1957 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1944 1958
1945 /* 1959 /*
1946 * B: reverse any characters which are selected 1960 * B: reverse any characters which are selected
1970 1984
1971 crp = &ROW(screen.cur.row).r[col]; 1985 crp = &ROW(screen.cur.row).r[col];
1972 1986
1973 if (showcursor && focus) 1987 if (showcursor && focus)
1974 { 1988 {
1975 if (options & Opt_cursorUnderline) 1989 if (OPTION (Opt_cursorUnderline))
1976 *crp ^= RS_Uline; 1990 *crp ^= RS_Uline;
1977 else 1991 else
1978 { 1992 {
1979 *crp ^= RS_RVid; 1993 *crp ^= RS_RVid;
1980 1994
1982 cc1 = *crp & (RS_fgMask | RS_bgMask); 1996 cc1 = *crp & (RS_fgMask | RS_bgMask);
1983 if (ISSET_PIXCOLOR (Color_cursor)) 1997 if (ISSET_PIXCOLOR (Color_cursor))
1984 ccol1 = Color_cursor; 1998 ccol1 = Color_cursor;
1985 else 1999 else
1986#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2000#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1987 ccol1 = GET_FGCOLOR (rstyle); 2001 ccol1 = fgcolor_of (rstyle);
1988#else 2002#else
1989 ccol1 = Color_fg; 2003 ccol1 = Color_fg;
1990#endif 2004#endif
1991 if (ISSET_PIXCOLOR (Color_cursor2)) 2005 if (ISSET_PIXCOLOR (Color_cursor2))
1992 ccol2 = Color_cursor2; 2006 ccol2 = Color_cursor2;
1993 else 2007 else
1994#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2008#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1995 ccol2 = GET_BGCOLOR (rstyle); 2009 ccol2 = bgcolor_of (rstyle);
1996#else 2010#else
1997 ccol2 = Color_bg; 2011 ccol2 = Color_bg;
1998#endif 2012#endif
1999 *crp = SET_FGCOLOR (*crp, ccol1); 2013 *crp = SET_FGCOLOR (*crp, ccol1);
2000 *crp = SET_BGCOLOR (*crp, ccol2); 2014 *crp = SET_BGCOLOR (*crp, ccol2);
2033 oldcursor.col = screen.cur.col; 2047 oldcursor.col = screen.cur.col;
2034 } 2048 }
2035 } 2049 }
2036 } 2050 }
2037 2051
2052 PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2038#if ENABLE_OVERLAY 2053#if ENABLE_OVERLAY
2039 scr_swap_overlay (); 2054 scr_swap_overlay ();
2040#endif 2055#endif
2041 2056
2042#ifndef NO_SLOW_LINK_SUPPORT 2057#ifndef NO_SLOW_LINK_SUPPORT
2092 if (wlen < len) 2107 if (wlen < len)
2093 ::swap (wlen, len); 2108 ::swap (wlen, len);
2094 2109
2095 XCopyArea (display->display, vt, vt, 2110 XCopyArea (display->display, vt, vt,
2096 gc, 0, Row2Pixel (len + i), 2111 gc, 0, Row2Pixel (len + i),
2097 (unsigned int)TermWin_TotalWidth (), 2112 (unsigned int)this->width,
2098 (unsigned int)Height2Pixel (wlen - len + 1), 2113 (unsigned int)Height2Pixel (wlen - len + 1),
2099 0, Row2Pixel (len)); 2114 0, Row2Pixel (len));
2100 len = -1; 2115 len = -1;
2101 } 2116 }
2102 } 2117 }
2181 count++, i--; 2196 count++, i--;
2182 2197
2183 /* 2198 /*
2184 * Determine the attributes for the string 2199 * Determine the attributes for the string
2185 */ 2200 */
2186 int fore = GET_FGCOLOR (rend); // desired foreground 2201 int fore = fgcolor_of (rend); // desired foreground
2187 int back = GET_BGCOLOR (rend); // desired background 2202 int back = bgcolor_of (rend); // desired background
2188 2203
2189 // 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
2190 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))
2191 { 2206 {
2192#if ENABLE_STYLES 2207#if ENABLE_STYLES
2193 // force redraw after "careful" characters to avoid pixel droppings 2208 // force redraw after "careful" characters to avoid pixel droppings
2194 if (srp[col] & RS_Careful && col < ncol - 1 && 0) 2209 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2305 } /* for (row....) */ 2320 } /* for (row....) */
2306 2321
2307#if ENABLE_OVERLAY 2322#if ENABLE_OVERLAY
2308 scr_swap_overlay (); 2323 scr_swap_overlay ();
2309#endif 2324#endif
2325 PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2310 2326
2311 /* 2327 /*
2312 * G: cleanup cursor and display outline cursor if necessary 2328 * G: cleanup cursor and display outline cursor if necessary
2313 */ 2329 */
2314 if (showcursor) 2330 if (showcursor)
2315 { 2331 {
2316 if (focus) 2332 if (focus)
2317 { 2333 {
2318 if (options & Opt_cursorUnderline) 2334 if (OPTION (Opt_cursorUnderline))
2319 *crp ^= RS_Uline; 2335 *crp ^= RS_Uline;
2320 else 2336 else
2321 { 2337 {
2322 *crp ^= RS_RVid; 2338 *crp ^= RS_RVid;
2323#ifndef NO_CURSORCOLOR 2339#ifndef NO_CURSORCOLOR
2442 2458
2443#if ENABLE_FRILLS 2459#if ENABLE_FRILLS
2444 if (selection.rect) 2460 if (selection.rect)
2445 { 2461 {
2446 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
2447 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++)
2448 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 }
2449 } 2476 }
2450 else 2477 else
2451#endif 2478#endif
2452 { 2479 {
2453 if (selection.beg.row >= -view_start) 2480 if (selection.beg.row >= -view_start)
2537/* ------------------------------------------------------------------------- */ 2564/* ------------------------------------------------------------------------- */
2538/* 2565/*
2539 * Paste a selection direct to the command fd 2566 * Paste a selection direct to the command fd
2540 */ 2567 */
2541void 2568void
2542rxvt_term::paste (unsigned char *data, unsigned int len) 2569rxvt_term::paste (char *data, unsigned int len)
2543{ 2570{
2544 /* convert normal newline chars into common keyboard Return key sequence */ 2571 /* convert normal newline chars into common keyboard Return key sequence */
2545 for (unsigned int i = 0; i < len; i++) 2572 for (unsigned int i = 0; i < len; i++)
2546 if (data[i] == C0_LF) 2573 if (data[i] == C0_LF)
2547 data[i] = C0_CR; 2574 data[i] = C0_CR;
2691 { 2718 {
2692 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2719 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2693 char *s = rxvt_wcstombs (w); 2720 char *s = rxvt_wcstombs (w);
2694 free (w); 2721 free (w);
2695 // TODO: strlen == only the first element will be converted. well... 2722 // TODO: strlen == only the first element will be converted. well...
2696 paste ((unsigned char *)s, strlen (s)); 2723 paste (s, strlen (s));
2697 free (s); 2724 free (s);
2698 } 2725 }
2699 else 2726 else
2700#endif 2727#endif
2701 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2728 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0
2702 && cl) 2729 && cl)
2703 { 2730 {
2704 for (int i = 0; i < cr; i++) 2731 for (int i = 0; i < cr; i++)
2705 paste ((unsigned char *)cl[i], strlen (cl[i])); 2732 paste (cl[i], strlen (cl[i]));
2706 2733
2707 XFreeStringList (cl); 2734 XFreeStringList (cl);
2708 } 2735 }
2709 else 2736 else
2710 paste (ct.value, ct.nitems); // paste raw 2737 paste ((char *)ct.value, ct.nitems); // paste raw
2711 2738
2712bailout: 2739bailout:
2713 XFree (ct.value); 2740 XFree (ct.value);
2714 2741
2715 if (selection_wait == Sel_normal) 2742 if (selection_wait == Sel_normal)
2753 return; /* outside window */ 2780 return; /* outside window */
2754 2781
2755 if (selection.text) 2782 if (selection.text)
2756 { /* internal selection */ 2783 { /* internal selection */
2757 char *str = rxvt_wcstombs (selection.text, selection.len); 2784 char *str = rxvt_wcstombs (selection.text, selection.len);
2758 paste ((unsigned char *)str, strlen (str)); 2785 paste (str, strlen (str));
2759 free (str); 2786 free (str);
2760 return; 2787 return;
2761 } 2788 }
2762 else 2789 else
2763 { 2790 {
2855 selection.op = SELECTION_DONE; 2882 selection.op = SELECTION_DONE;
2856 2883
2857 if (selection.clicks == 4) 2884 if (selection.clicks == 4)
2858 return; /* nothing selected, go away */ 2885 return; /* nothing selected, go away */
2859 2886
2887 if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2888 return;
2889
2860 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2890 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2861 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));
2862 2892
2863 int ofs = 0; 2893 int ofs = 0;
2864 int extra = 0; 2894 int extra = 0;
2880#endif 2910#endif
2881 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
2882 2912
2883 col = max (col, 0); 2913 col = max (col, 0);
2884 2914
2885 if (row == selection.end.row || selection.rect) 2915 if (row == selection.end.row
2916#if ENABLE_FRILLS
2917 || selection.rect
2918#endif
2919 )
2886 end_col = min (end_col, selection.end.col); 2920 min_it (end_col, selection.end.col);
2887 2921
2888 t = ROW(row).t + col; 2922 t = ROW(row).t + col;
2889 for (; col < end_col; col++) 2923 for (; col < end_col; col++)
2890 { 2924 {
2891 if (*t == NOCHAR) 2925 if (*t == NOCHAR)
2909#endif 2943#endif
2910 else 2944 else
2911 new_selection_text[ofs++] = *t++; 2945 new_selection_text[ofs++] = *t++;
2912 } 2946 }
2913 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
2914 if (!ROW(row).is_longer () && row != selection.end.row) 2960 if (!ROW(row).is_longer () && row != selection.end.row)
2915 new_selection_text[ofs++] = C0_LF; 2961 new_selection_text[ofs++] = C0_LF;
2916 } 2962 }
2917 2963
2918 if (end_col != selection.end.col) 2964 if (end_col != selection.end.col)
2919 new_selection_text[ofs++] = C0_LF; 2965 new_selection_text[ofs++] = C0_LF;
2920 2966
2930 2976
2931 // 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
2932 selection.len = ofs; 2978 selection.len = ofs;
2933 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));
2934 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
2935 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2992 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2936 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2993 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
2994 {
2937 display->set_selection_owner (this); 2995 display->set_selection_owner (this);
2996 return true;
2997 }
2938 else 2998 else
2939 rxvt_warn ("can't get primary selection, ignoring.\n"); 2999 return false;
2940 3000
2941#if 0 3001#if 0
2942 XTextProperty ct; 3002 XTextProperty ct;
2943 3003
2944 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3004 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2945 { 3005 {
2946 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3006 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2947 XFree (ct.value); 3007 XFree (ct.value);
2948 } 3008 }
2949#endif 3009#endif
2950
2951 selection_time = tm;
2952} 3010}
2953 3011
2954/* ------------------------------------------------------------------------- */ 3012/* ------------------------------------------------------------------------- */
2955/* 3013/*
2956 * 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
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