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.203 by root, Sat Dec 31 19:30:25 2005 UTC vs.
Revision 1.208 by root, Wed Jan 4 05:24:55 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;
1819} 1825}
1820 1826
1821int 1827int
1822rxvt_term::scr_changeview (unsigned int oldviewstart) 1828rxvt_term::scr_changeview (unsigned int oldviewstart)
1823{ 1829{
1830 PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1831
1824 if (view_start != oldviewstart) 1832 if (view_start != oldviewstart)
1825 { 1833 {
1826 want_refresh = 1; 1834 want_refresh = 1;
1827 num_scr -= (view_start - oldviewstart); 1835 num_scr -= (view_start - oldviewstart);
1828 } 1836 }
2039 oldcursor.col = screen.cur.col; 2047 oldcursor.col = screen.cur.col;
2040 } 2048 }
2041 } 2049 }
2042 } 2050 }
2043 2051
2052 PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2044#if ENABLE_OVERLAY 2053#if ENABLE_OVERLAY
2045 scr_swap_overlay (); 2054 scr_swap_overlay ();
2046#endif 2055#endif
2047 2056
2048#ifndef NO_SLOW_LINK_SUPPORT 2057#ifndef NO_SLOW_LINK_SUPPORT
2098 if (wlen < len) 2107 if (wlen < len)
2099 ::swap (wlen, len); 2108 ::swap (wlen, len);
2100 2109
2101 XCopyArea (display->display, vt, vt, 2110 XCopyArea (display->display, vt, vt,
2102 gc, 0, Row2Pixel (len + i), 2111 gc, 0, Row2Pixel (len + i),
2103 (unsigned int)TermWin_TotalWidth (), 2112 (unsigned int)this->width,
2104 (unsigned int)Height2Pixel (wlen - len + 1), 2113 (unsigned int)Height2Pixel (wlen - len + 1),
2105 0, Row2Pixel (len)); 2114 0, Row2Pixel (len));
2106 len = -1; 2115 len = -1;
2107 } 2116 }
2108 } 2117 }
2311 } /* for (row....) */ 2320 } /* for (row....) */
2312 2321
2313#if ENABLE_OVERLAY 2322#if ENABLE_OVERLAY
2314 scr_swap_overlay (); 2323 scr_swap_overlay ();
2315#endif 2324#endif
2325 PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2316 2326
2317 /* 2327 /*
2318 * G: cleanup cursor and display outline cursor if necessary 2328 * G: cleanup cursor and display outline cursor if necessary
2319 */ 2329 */
2320 if (showcursor) 2330 if (showcursor)
2554/* ------------------------------------------------------------------------- */ 2564/* ------------------------------------------------------------------------- */
2555/* 2565/*
2556 * Paste a selection direct to the command fd 2566 * Paste a selection direct to the command fd
2557 */ 2567 */
2558void 2568void
2559rxvt_term::paste (unsigned char *data, unsigned int len) 2569rxvt_term::paste (char *data, unsigned int len)
2560{ 2570{
2561 /* convert normal newline chars into common keyboard Return key sequence */ 2571 /* convert normal newline chars into common keyboard Return key sequence */
2562 for (unsigned int i = 0; i < len; i++) 2572 for (unsigned int i = 0; i < len; i++)
2563 if (data[i] == C0_LF) 2573 if (data[i] == C0_LF)
2564 data[i] = C0_CR; 2574 data[i] = C0_CR;
2708 { 2718 {
2709 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2719 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2710 char *s = rxvt_wcstombs (w); 2720 char *s = rxvt_wcstombs (w);
2711 free (w); 2721 free (w);
2712 // TODO: strlen == only the first element will be converted. well... 2722 // TODO: strlen == only the first element will be converted. well...
2713 paste ((unsigned char *)s, strlen (s)); 2723 paste (s, strlen (s));
2714 free (s); 2724 free (s);
2715 } 2725 }
2716 else 2726 else
2717#endif 2727#endif
2718 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2728 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0
2719 && cl) 2729 && cl)
2720 { 2730 {
2721 for (int i = 0; i < cr; i++) 2731 for (int i = 0; i < cr; i++)
2722 paste ((unsigned char *)cl[i], strlen (cl[i])); 2732 paste (cl[i], strlen (cl[i]));
2723 2733
2724 XFreeStringList (cl); 2734 XFreeStringList (cl);
2725 } 2735 }
2726 else 2736 else
2727 paste (ct.value, ct.nitems); // paste raw 2737 paste ((char *)ct.value, ct.nitems); // paste raw
2728 2738
2729bailout: 2739bailout:
2730 XFree (ct.value); 2740 XFree (ct.value);
2731 2741
2732 if (selection_wait == Sel_normal) 2742 if (selection_wait == Sel_normal)
2770 return; /* outside window */ 2780 return; /* outside window */
2771 2781
2772 if (selection.text) 2782 if (selection.text)
2773 { /* internal selection */ 2783 { /* internal selection */
2774 char *str = rxvt_wcstombs (selection.text, selection.len); 2784 char *str = rxvt_wcstombs (selection.text, selection.len);
2775 paste ((unsigned char *)str, strlen (str)); 2785 paste (str, strlen (str));
2776 free (str); 2786 free (str);
2777 return; 2787 return;
2778 } 2788 }
2779 else 2789 else
2780 { 2790 {
2872 selection.op = SELECTION_DONE; 2882 selection.op = SELECTION_DONE;
2873 2883
2874 if (selection.clicks == 4) 2884 if (selection.clicks == 4)
2875 return; /* nothing selected, go away */ 2885 return; /* nothing selected, go away */
2876 2886
2887 if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2888 return;
2889
2877 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2890 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2878 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));
2879 2892
2880 int ofs = 0; 2893 int ofs = 0;
2881 int extra = 0; 2894 int extra = 0;
2963 2976
2964 // 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
2965 selection.len = ofs; 2978 selection.len = ofs;
2966 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));
2967 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
2968 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2992 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2969 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2993 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
2994 {
2970 display->set_selection_owner (this); 2995 display->set_selection_owner (this);
2996 return true;
2997 }
2971 else 2998 else
2972 rxvt_warn ("can't get primary selection, ignoring.\n"); 2999 return false;
2973 3000
2974#if 0 3001#if 0
2975 XTextProperty ct; 3002 XTextProperty ct;
2976 3003
2977 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3004 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2978 { 3005 {
2979 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3006 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2980 XFree (ct.value); 3007 XFree (ct.value);
2981 } 3008 }
2982#endif 3009#endif
2983
2984 selection_time = tm;
2985} 3010}
2986 3011
2987/* ------------------------------------------------------------------------- */ 3012/* ------------------------------------------------------------------------- */
2988/* 3013/*
2989 * 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
3111 } 3136 }
3112 } 3137 }
3113 break; 3138 break;
3114 } 3139 }
3115 3140
3116Old_Word_Selection_You_Die:
3117 if (dirn == DN) 3141 if (dirn == DN)
3118 col++; /* put us on one past the end */ 3142 col++; /* put us on one past the end */
3119 3143
3120 /* Poke the values back in */ 3144 /* Poke the values back in */
3121 ret->row = row; 3145 ret->row = row;
3298 else if (selection.clicks == 2) 3322 else if (selection.clicks == 2)
3299 { 3323 {
3300 if (ROWCOL_IS_AFTER (selection.end, selection.beg)) 3324 if (ROWCOL_IS_AFTER (selection.end, selection.beg))
3301 selection.end.col--; 3325 selection.end.col--;
3302 3326
3327 if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
3328 {
3303 selection_delimit_word (UP, &selection.beg, &selection.beg); 3329 selection_delimit_word (UP, &selection.beg, &selection.beg);
3304 selection_delimit_word (DN, &selection.end, &selection.end); 3330 selection_delimit_word (DN, &selection.end, &selection.end);
3331 }
3305 } 3332 }
3306 else if (selection.clicks == 3) 3333 else if (selection.clicks == 3)
3307 { 3334 {
3308#if ENABLE_FRILLS 3335#if ENABLE_FRILLS
3309 if (OPTION (Opt_tripleclickwords)) 3336 if (OPTION (Opt_tripleclickwords))
3585 3612
3586#if ENABLE_OVERLAY 3613#if ENABLE_OVERLAY
3587void 3614void
3588rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3615rxvt_term::scr_overlay_new (int x, int y, int w, int h)
3589{ 3616{
3590 if (nrow < 3 || ncol < 3) 3617 if (nrow < 1 || ncol < 1)
3591 return; 3618 return;
3592 3619
3593 want_refresh = 1; 3620 want_refresh = 1;
3594 3621
3595 scr_overlay_off (); 3622 scr_overlay_off ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines