… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de> |
30 | * Copyright (c) 2003-2014 Marc Lehmann <schmorp@schmorp.de> |
31 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
31 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
32 | * |
32 | * |
33 | * This program is free software; you can redistribute it and/or modify |
33 | * This program is free software; you can redistribute it and/or modify |
34 | * it under the terms of the GNU General Public License as published by |
34 | * it under the terms of the GNU General Public License as published by |
35 | * the Free Software Foundation; either version 2 of the License, or |
35 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
400 | break; |
400 | break; |
401 | } |
401 | } |
402 | return param; |
402 | return param; |
403 | } |
403 | } |
404 | |
404 | |
|
|
405 | static inline wchar_t * |
|
|
406 | rxvt_wcsdup (const wchar_t *str, int len) |
|
|
407 | { |
|
|
408 | wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t)); |
|
|
409 | memcpy (r, str, len * sizeof (wchar_t)); |
|
|
410 | r[len] = 0; |
|
|
411 | return r; |
|
|
412 | } |
|
|
413 | |
405 | void ecb_cold |
414 | void ecb_cold |
406 | rxvt_term::key_press (XKeyEvent &ev) |
415 | rxvt_term::key_press (XKeyEvent &ev) |
407 | { |
416 | { |
408 | int ctrl, meta, shft, len; |
417 | int ctrl, meta, shft, len; |
409 | KeySym keysym; |
418 | KeySym keysym; |
410 | int valid_keysym; |
419 | int valid_keysym; |
411 | char kbuf[KBUFSZ]; |
420 | char rkbuf[KBUFSZ]; |
|
|
421 | char *kbuf = rkbuf + 1; |
412 | |
422 | |
413 | #if ISO_14755 |
423 | #if ISO_14755 |
414 | if (iso14755buf & ISO_14755_52) |
424 | if (iso14755buf & ISO_14755_52) |
415 | return; |
425 | return; |
416 | #endif |
426 | #endif |
… | |
… | |
539 | #ifdef SCROLL_ON_HOMEEND_KEYS |
549 | #ifdef SCROLL_ON_HOMEEND_KEYS |
540 | if (IS_SCROLL_MOD) |
550 | if (IS_SCROLL_MOD) |
541 | { |
551 | { |
542 | if (keysym == XK_Home) |
552 | if (keysym == XK_Home) |
543 | { |
553 | { |
544 | scr_move_to (0, 1); |
554 | scr_changeview (top_row); |
545 | return; |
555 | return; |
546 | } |
556 | } |
547 | else if (keysym == XK_End) |
557 | else if (keysym == XK_End) |
548 | { |
558 | { |
549 | scr_move_to (1, 1); |
559 | scr_changeview (0); |
550 | return; |
560 | return; |
551 | } |
561 | } |
552 | } |
562 | } |
553 | #endif |
563 | #endif |
554 | } |
564 | } |
… | |
… | |
576 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
586 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
577 | return; |
587 | return; |
578 | #endif |
588 | #endif |
579 | } |
589 | } |
580 | } |
590 | } |
|
|
591 | } |
|
|
592 | |
|
|
593 | if (ctrl && meta && (keysym == XK_c || keysym == XK_v)) |
|
|
594 | { |
|
|
595 | if (keysym == XK_v) |
|
|
596 | selection_request (ev.time, Sel_Clipboard); |
|
|
597 | else if (selection.len > 0) |
|
|
598 | { |
|
|
599 | free (selection.clip_text); |
|
|
600 | selection.clip_text = rxvt_wcsdup (selection.text, selection.len); |
|
|
601 | selection.clip_len = selection.len; |
|
|
602 | selection_grab (CurrentTime, true); |
|
|
603 | } |
|
|
604 | |
|
|
605 | return; |
581 | } |
606 | } |
582 | |
607 | |
583 | #if ENABLE_FRILLS || ISO_14755 |
608 | #if ENABLE_FRILLS || ISO_14755 |
584 | // ISO 14755 support |
609 | // ISO 14755 support |
585 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51)) |
610 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51)) |
… | |
… | |
832 | #endif |
857 | #endif |
833 | /* nil */ ; |
858 | /* nil */ ; |
834 | } |
859 | } |
835 | } |
860 | } |
836 | |
861 | |
|
|
862 | /* escape prefix */ |
|
|
863 | if (len && meta |
|
|
864 | #ifdef META8_OPTION |
|
|
865 | && meta_char == C0_ESC |
|
|
866 | #endif |
|
|
867 | ) |
|
|
868 | { |
|
|
869 | *--kbuf = C0_ESC; |
|
|
870 | len++; |
|
|
871 | } |
|
|
872 | |
837 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
873 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
838 | return; |
874 | return; |
839 | |
875 | |
840 | if (len <= 0) |
876 | if (len <= 0) |
841 | return; /* not mapped */ |
877 | return; /* not mapped */ |
… | |
… | |
844 | if (view_start) |
880 | if (view_start) |
845 | { |
881 | { |
846 | view_start = 0; |
882 | view_start = 0; |
847 | want_refresh = 1; |
883 | want_refresh = 1; |
848 | } |
884 | } |
849 | |
|
|
850 | /* escape prefix */ |
|
|
851 | if (meta |
|
|
852 | #ifdef META8_OPTION |
|
|
853 | && meta_char == C0_ESC |
|
|
854 | #endif |
|
|
855 | ) |
|
|
856 | { |
|
|
857 | const char ch = C0_ESC; |
|
|
858 | tt_write (&ch, 1); |
|
|
859 | } |
|
|
860 | |
885 | |
861 | tt_write (kbuf, (unsigned int)len); |
886 | tt_write (kbuf, (unsigned int)len); |
862 | } |
887 | } |
863 | |
888 | |
864 | void ecb_cold |
889 | void ecb_cold |
… | |
… | |
1077 | |
1102 | |
1078 | #ifdef SELECTION_SCROLLING |
1103 | #ifdef SELECTION_SCROLLING |
1079 | void |
1104 | void |
1080 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1105 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1081 | { |
1106 | { |
1082 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1107 | if (scr_page (scroll_selection_lines)) |
1083 | { |
1108 | { |
1084 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1109 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1085 | want_refresh = 1; |
1110 | want_refresh = 1; |
1086 | refresh_check (); |
1111 | refresh_check (); |
1087 | } |
1112 | } |
… | |
… | |
1092 | |
1117 | |
1093 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1118 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1094 | void |
1119 | void |
1095 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1120 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1096 | { |
1121 | { |
1097 | if (scr_changeview (view_start - mouse_slip_wheel_speed)) |
1122 | if (scr_page (mouse_slip_wheel_speed)) |
1098 | { |
1123 | { |
1099 | want_refresh = 1; |
1124 | want_refresh = 1; |
1100 | refresh_check (); |
1125 | refresh_check (); |
1101 | } |
1126 | } |
1102 | |
1127 | |
… | |
… | |
1638 | |
1663 | |
1639 | #ifdef SELECTION_SCROLLING |
1664 | #ifdef SELECTION_SCROLLING |
1640 | if (ev.xbutton.y < int_bwidth |
1665 | if (ev.xbutton.y < int_bwidth |
1641 | || Pixel2Row (ev.xbutton.y) > (nrow-1)) |
1666 | || Pixel2Row (ev.xbutton.y) > (nrow-1)) |
1642 | { |
1667 | { |
|
|
1668 | page_dirn scroll_selection_dir; |
1643 | int dist; |
1669 | int dist; |
1644 | |
1670 | |
1645 | /* don't clobber the current delay if we are |
1671 | /* don't clobber the current delay if we are |
1646 | * already in the middle of scrolling. |
1672 | * already in the middle of scrolling. |
1647 | */ |
1673 | */ |
… | |
… | |
1670 | scroll_selection_lines = Pixel2Height (dist) |
1696 | scroll_selection_lines = Pixel2Height (dist) |
1671 | / SELECTION_SCROLL_LINE_SPEEDUP |
1697 | / SELECTION_SCROLL_LINE_SPEEDUP |
1672 | + 1; |
1698 | + 1; |
1673 | min_it (scroll_selection_lines, |
1699 | min_it (scroll_selection_lines, |
1674 | SELECTION_SCROLL_MAX_LINES); |
1700 | SELECTION_SCROLL_MAX_LINES); |
|
|
1701 | scroll_selection_lines *= scroll_selection_dir; |
1675 | } |
1702 | } |
1676 | else |
1703 | else |
1677 | { |
1704 | { |
1678 | /* we are within the text window, so we |
1705 | /* we are within the text window, so we |
1679 | * shouldn't be scrolling |
1706 | * shouldn't be scrolling |
… | |
… | |
2195 | |
2222 | |
2196 | #ifdef MOUSE_WHEEL |
2223 | #ifdef MOUSE_WHEEL |
2197 | case Button4: |
2224 | case Button4: |
2198 | case Button5: |
2225 | case Button5: |
2199 | { |
2226 | { |
2200 | int i; |
2227 | int lines; |
2201 | page_dirn v; |
2228 | page_dirn dirn; |
2202 | |
2229 | |
2203 | v = ev.button == Button4 ? UP : DN; |
2230 | dirn = ev.button == Button4 ? UP : DN; |
2204 | |
2231 | |
2205 | if (ev.state & ShiftMask) |
2232 | if (ev.state & ShiftMask) |
2206 | i = 1; |
2233 | lines = 1; |
2207 | else if (option (Opt_mouseWheelScrollPage)) |
2234 | else if (option (Opt_mouseWheelScrollPage)) |
2208 | i = nrow - 1; |
2235 | lines = nrow - 1; |
2209 | else |
2236 | else |
2210 | i = 5; |
2237 | lines = 5; |
2211 | |
2238 | |
2212 | # ifdef MOUSE_SLIP_WHEELING |
2239 | # ifdef MOUSE_SLIP_WHEELING |
2213 | if (ev.state & ControlMask) |
2240 | if (ev.state & ControlMask) |
2214 | { |
2241 | { |
2215 | mouse_slip_wheel_speed += v; |
2242 | mouse_slip_wheel_speed += dirn; |
2216 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2243 | clamp_it (mouse_slip_wheel_speed, -nrow, nrow); |
2217 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
|
|
2218 | |
2244 | |
2219 | if (!slip_wheel_ev.is_active ()) |
2245 | if (!slip_wheel_ev.is_active ()) |
2220 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2246 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2221 | } |
2247 | } |
2222 | else |
2248 | else |
2223 | # endif |
2249 | # endif |
2224 | { |
2250 | { |
2225 | scr_page (v, i); |
2251 | scr_page (dirn, lines); |
2226 | scrollBar.show (1); |
2252 | scrollBar.show (1); |
2227 | } |
2253 | } |
2228 | } |
2254 | } |
2229 | break; |
2255 | break; |
2230 | #endif |
2256 | #endif |
… | |
… | |
3226 | rxvt_term::get_to_st (unicode_t &ends_how) |
3252 | rxvt_term::get_to_st (unicode_t &ends_how) |
3227 | { |
3253 | { |
3228 | unicode_t ch; |
3254 | unicode_t ch; |
3229 | bool seen_esc = false; |
3255 | bool seen_esc = false; |
3230 | unsigned int n = 0; |
3256 | unsigned int n = 0; |
3231 | wchar_t string[STRING_MAX]; |
3257 | wchar_t string[CBUFSIZ]; |
3232 | |
3258 | |
3233 | while ((ch = cmd_getc ()) != NOCHAR) |
3259 | while ((ch = cmd_getc ()) != NOCHAR) |
3234 | { |
3260 | { |
3235 | if (seen_esc) |
3261 | if (seen_esc) |
3236 | { |
3262 | { |
… | |
… | |
3251 | else if (ch < 0x20) |
3277 | else if (ch < 0x20) |
3252 | return NULL; /* other control character - exit */ |
3278 | return NULL; /* other control character - exit */ |
3253 | |
3279 | |
3254 | seen_esc = false; |
3280 | seen_esc = false; |
3255 | |
3281 | |
3256 | if (n >= STRING_MAX - 1) |
3282 | if (n >= sizeof (string) - 1) |
3257 | // stop at some sane length |
3283 | // stop at some sane length |
3258 | return NULL; |
3284 | return NULL; |
3259 | |
3285 | |
3260 | string[n++] = ch; |
3286 | string[n++] = ch; |
3261 | } |
3287 | } |
… | |
… | |
3378 | &nitems, &bytes_after, &value) == Success |
3404 | &nitems, &bytes_after, &value) == Success |
3379 | && actual_type != None |
3405 | && actual_type != None |
3380 | && actual_format == 8) |
3406 | && actual_format == 8) |
3381 | str = (const char *)(value); |
3407 | str = (const char *)(value); |
3382 | |
3408 | |
3383 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3409 | tt_printf ("\033]%d;%s%c", op, option (Opt_insecure) ? str : "", resp); |
3384 | |
3410 | |
3385 | XFree (value); |
3411 | XFree (value); |
3386 | } |
3412 | } |
3387 | else |
3413 | else |
3388 | { |
3414 | { |