… | |
… | |
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 | |
1821 | int |
1827 | int |
1822 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1828 | rxvt_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 | } |
… | |
… | |
1949 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1957 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1950 | |
1958 | |
1951 | /* |
1959 | /* |
1952 | * B: reverse any characters which are selected |
1960 | * B: reverse any characters which are selected |
1953 | */ |
1961 | */ |
|
|
1962 | PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
1954 | scr_reverse_selection (); |
1963 | scr_reverse_selection (); |
1955 | |
1964 | |
1956 | /* |
1965 | /* |
1957 | * C: set the cursor character (s) |
1966 | * C: set the cursor character (s) |
1958 | */ |
1967 | */ |
… | |
… | |
2358 | |
2367 | |
2359 | /* |
2368 | /* |
2360 | * H: cleanup selection |
2369 | * H: cleanup selection |
2361 | */ |
2370 | */ |
2362 | scr_reverse_selection (); |
2371 | scr_reverse_selection (); |
|
|
2372 | PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
2363 | |
2373 | |
2364 | if (refresh_type & SMOOTH_REFRESH) |
2374 | if (refresh_type & SMOOTH_REFRESH) |
2365 | XFlush (display->display); |
2375 | XFlush (display->display); |
2366 | |
2376 | |
2367 | num_scr = 0; |
2377 | num_scr = 0; |
… | |
… | |
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 | |
|
|
2987 | bool |
|
|
2988 | rxvt_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 |
… | |
… | |
3585 | |
3610 | |
3586 | #if ENABLE_OVERLAY |
3611 | #if ENABLE_OVERLAY |
3587 | void |
3612 | void |
3588 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3613 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3589 | { |
3614 | { |
3590 | if (nrow < 3 || ncol < 3) |
3615 | if (nrow < 1 || ncol < 1) |
3591 | return; |
3616 | return; |
3592 | |
3617 | |
3593 | want_refresh = 1; |
3618 | want_refresh = 1; |
3594 | |
3619 | |
3595 | scr_overlay_off (); |
3620 | scr_overlay_off (); |