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.202 by root, Sat Dec 31 17:16:17 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
417 418
418 for (int col = ncol; col--; ) 419 for (int col = ncol; col--; )
419 tabs [col] = col % TABSIZE == 0; 420 tabs [col] = col % TABSIZE == 0;
420 421
421 tt_winch (); 422 tt_winch ();
423
424 PERL_INVOKE ((this, HOOK_RESET, DT_END));
422} 425}
423 426
424/* ------------------------------------------------------------------------- */ 427/* ------------------------------------------------------------------------- */
425/* 428/*
426 * Free everything. That way malloc debugging can find leakage. 429 * Free everything. That way malloc debugging can find leakage.
619 && row1 == 0 622 && row1 == 0
620 && row2 == nrow - 1 623 && row2 == nrow - 1
621 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) 624 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
622 { 625 {
623 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
624 term_start = (term_start + count) % total_rows; 630 term_start = (term_start + count) % total_rows;
625 631
626 if (selection.op && current_screen == selection.screen) 632 if (selection.op && current_screen == selection.screen)
627 { 633 {
628 selection.beg.row -= count; 634 selection.beg.row -= count;
716 last_col = ncol; 722 last_col = ncol;
717 723
718 if (nlines > 0) 724 if (nlines > 0)
719 { 725 {
720 nlines += screen.cur.row - screen.bscroll; 726 nlines += screen.cur.row - screen.bscroll;
727
721 if (nlines > 0 728 if (nlines > 0
722 && screen.tscroll == 0 729 && screen.tscroll == 0
723 && screen.bscroll == (nrow - 1)) 730 && screen.bscroll == (nrow - 1))
724 { 731 {
725 /* _at least_ this many lines need to be scrolled */ 732 /* _at least_ this many lines need to be scrolled */
1819} 1826}
1820 1827
1821int 1828int
1822rxvt_term::scr_changeview (unsigned int oldviewstart) 1829rxvt_term::scr_changeview (unsigned int oldviewstart)
1823{ 1830{
1831 PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1832
1824 if (view_start != oldviewstart) 1833 if (view_start != oldviewstart)
1825 { 1834 {
1826 want_refresh = 1; 1835 want_refresh = 1;
1827 num_scr -= (view_start - oldviewstart); 1836 num_scr -= (view_start - oldviewstart);
1828 } 1837 }
2039 oldcursor.col = screen.cur.col; 2048 oldcursor.col = screen.cur.col;
2040 } 2049 }
2041 } 2050 }
2042 } 2051 }
2043 2052
2053 PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2044#if ENABLE_OVERLAY 2054#if ENABLE_OVERLAY
2045 scr_swap_overlay (); 2055 scr_swap_overlay ();
2046#endif 2056#endif
2047 2057
2048#ifndef NO_SLOW_LINK_SUPPORT 2058#ifndef NO_SLOW_LINK_SUPPORT
2098 if (wlen < len) 2108 if (wlen < len)
2099 ::swap (wlen, len); 2109 ::swap (wlen, len);
2100 2110
2101 XCopyArea (display->display, vt, vt, 2111 XCopyArea (display->display, vt, vt,
2102 gc, 0, Row2Pixel (len + i), 2112 gc, 0, Row2Pixel (len + i),
2103 (unsigned int)TermWin_TotalWidth (), 2113 (unsigned int)this->width,
2104 (unsigned int)Height2Pixel (wlen - len + 1), 2114 (unsigned int)Height2Pixel (wlen - len + 1),
2105 0, Row2Pixel (len)); 2115 0, Row2Pixel (len));
2106 len = -1; 2116 len = -1;
2107 } 2117 }
2108 } 2118 }
2311 } /* for (row....) */ 2321 } /* for (row....) */
2312 2322
2313#if ENABLE_OVERLAY 2323#if ENABLE_OVERLAY
2314 scr_swap_overlay (); 2324 scr_swap_overlay ();
2315#endif 2325#endif
2326 PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2316 2327
2317 /* 2328 /*
2318 * G: cleanup cursor and display outline cursor if necessary 2329 * G: cleanup cursor and display outline cursor if necessary
2319 */ 2330 */
2320 if (showcursor) 2331 if (showcursor)
2456 2467
2457 for (col = selection.beg.col; col < selection.end.col; col++) 2468 for (col = selection.beg.col; col < selection.end.col; col++)
2458 srp[col] ^= RS_RVid; 2469 srp[col] ^= RS_RVid;
2459 2470
2460 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) 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)
2461 srp[col] ^= RS_RVid | RS_Uline; 2475 srp[col] ^= RS_RVid | RS_Uline;
2462 } 2476 }
2463 } 2477 }
2464 else 2478 else
2465#endif 2479#endif
2551/* ------------------------------------------------------------------------- */ 2565/* ------------------------------------------------------------------------- */
2552/* 2566/*
2553 * Paste a selection direct to the command fd 2567 * Paste a selection direct to the command fd
2554 */ 2568 */
2555void 2569void
2556rxvt_term::paste (unsigned char *data, unsigned int len) 2570rxvt_term::paste (char *data, unsigned int len)
2557{ 2571{
2558 /* convert normal newline chars into common keyboard Return key sequence */ 2572 /* convert normal newline chars into common keyboard Return key sequence */
2559 for (unsigned int i = 0; i < len; i++) 2573 for (unsigned int i = 0; i < len; i++)
2560 if (data[i] == C0_LF) 2574 if (data[i] == C0_LF)
2561 data[i] = C0_CR; 2575 data[i] = C0_CR;
2705 { 2719 {
2706 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2720 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2707 char *s = rxvt_wcstombs (w); 2721 char *s = rxvt_wcstombs (w);
2708 free (w); 2722 free (w);
2709 // TODO: strlen == only the first element will be converted. well... 2723 // TODO: strlen == only the first element will be converted. well...
2710 paste ((unsigned char *)s, strlen (s)); 2724 paste (s, strlen (s));
2711 free (s); 2725 free (s);
2712 } 2726 }
2713 else 2727 else
2714#endif 2728#endif
2715 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2729 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0
2716 && cl) 2730 && cl)
2717 { 2731 {
2718 for (int i = 0; i < cr; i++) 2732 for (int i = 0; i < cr; i++)
2719 paste ((unsigned char *)cl[i], strlen (cl[i])); 2733 paste (cl[i], strlen (cl[i]));
2720 2734
2721 XFreeStringList (cl); 2735 XFreeStringList (cl);
2722 } 2736 }
2723 else 2737 else
2724 paste (ct.value, ct.nitems); // paste raw 2738 paste ((char *)ct.value, ct.nitems); // paste raw
2725 2739
2726bailout: 2740bailout:
2727 XFree (ct.value); 2741 XFree (ct.value);
2728 2742
2729 if (selection_wait == Sel_normal) 2743 if (selection_wait == Sel_normal)
2767 return; /* outside window */ 2781 return; /* outside window */
2768 2782
2769 if (selection.text) 2783 if (selection.text)
2770 { /* internal selection */ 2784 { /* internal selection */
2771 char *str = rxvt_wcstombs (selection.text, selection.len); 2785 char *str = rxvt_wcstombs (selection.text, selection.len);
2772 paste ((unsigned char *)str, strlen (str)); 2786 paste (str, strlen (str));
2773 free (str); 2787 free (str);
2774 return; 2788 return;
2775 } 2789 }
2776 else 2790 else
2777 { 2791 {
2869 selection.op = SELECTION_DONE; 2883 selection.op = SELECTION_DONE;
2870 2884
2871 if (selection.clicks == 4) 2885 if (selection.clicks == 4)
2872 return; /* nothing selected, go away */ 2886 return; /* nothing selected, go away */
2873 2887
2888 if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2889 return;
2890
2874 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2891 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2875 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));
2876 2893
2877 int ofs = 0; 2894 int ofs = 0;
2878 int extra = 0; 2895 int extra = 0;
2960 2977
2961 // 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
2962 selection.len = ofs; 2979 selection.len = ofs;
2963 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));
2964 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
2965 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2993 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2966 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2994 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
2995 {
2967 display->set_selection_owner (this); 2996 display->set_selection_owner (this);
2997 return true;
2998 }
2968 else 2999 else
2969 rxvt_warn ("can't get primary selection, ignoring.\n"); 3000 return false;
2970 3001
2971#if 0 3002#if 0
2972 XTextProperty ct; 3003 XTextProperty ct;
2973 3004
2974 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3005 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2975 { 3006 {
2976 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3007 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2977 XFree (ct.value); 3008 XFree (ct.value);
2978 } 3009 }
2979#endif 3010#endif
2980
2981 selection_time = tm;
2982} 3011}
2983 3012
2984/* ------------------------------------------------------------------------- */ 3013/* ------------------------------------------------------------------------- */
2985/* 3014/*
2986 * 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
3108 } 3137 }
3109 } 3138 }
3110 break; 3139 break;
3111 } 3140 }
3112 3141
3113Old_Word_Selection_You_Die:
3114 if (dirn == DN) 3142 if (dirn == DN)
3115 col++; /* put us on one past the end */ 3143 col++; /* put us on one past the end */
3116 3144
3117 /* Poke the values back in */ 3145 /* Poke the values back in */
3118 ret->row = row; 3146 ret->row = row;
3295 else if (selection.clicks == 2) 3323 else if (selection.clicks == 2)
3296 { 3324 {
3297 if (ROWCOL_IS_AFTER (selection.end, selection.beg)) 3325 if (ROWCOL_IS_AFTER (selection.end, selection.beg))
3298 selection.end.col--; 3326 selection.end.col--;
3299 3327
3328 if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
3329 {
3300 selection_delimit_word (UP, &selection.beg, &selection.beg); 3330 selection_delimit_word (UP, &selection.beg, &selection.beg);
3301 selection_delimit_word (DN, &selection.end, &selection.end); 3331 selection_delimit_word (DN, &selection.end, &selection.end);
3332 }
3302 } 3333 }
3303 else if (selection.clicks == 3) 3334 else if (selection.clicks == 3)
3304 { 3335 {
3305#if ENABLE_FRILLS 3336#if ENABLE_FRILLS
3306 if (OPTION (Opt_tripleclickwords)) 3337 if (OPTION (Opt_tripleclickwords))
3582 3613
3583#if ENABLE_OVERLAY 3614#if ENABLE_OVERLAY
3584void 3615void
3585rxvt_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)
3586{ 3617{
3587 if (nrow < 3 || ncol < 3) 3618 if (nrow < 1 || ncol < 1)
3588 return; 3619 return;
3589 3620
3590 want_refresh = 1; 3621 want_refresh = 1;
3591 3622
3592 scr_overlay_off (); 3623 scr_overlay_off ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines