… | |
… | |
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-2005 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
867 | #endif |
867 | #endif |
868 | /* nil */ ; |
868 | /* nil */ ; |
869 | } |
869 | } |
870 | } |
870 | } |
871 | |
871 | |
|
|
872 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
873 | return; |
|
|
874 | |
872 | if (len <= 0) |
875 | if (len <= 0) |
873 | return; /* not mapped */ |
876 | return; /* not mapped */ |
874 | |
877 | |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
876 | if (view_start) |
879 | if (view_start) |
… | |
… | |
1202 | |
1205 | |
1203 | #ifdef POINTER_BLANK |
1206 | #ifdef POINTER_BLANK |
1204 | void |
1207 | void |
1205 | rxvt_term::pointer_blank () |
1208 | rxvt_term::pointer_blank () |
1206 | { |
1209 | { |
1207 | if (! OPTION (Opt_pointerBlank)) |
1210 | if (!OPTION (Opt_pointerBlank)) |
1208 | return; |
1211 | return; |
1209 | |
1212 | |
1210 | XDefineCursor (display->display, vt, display->blank_cursor); |
1213 | XDefineCursor (display->display, vt, display->blank_cursor); |
1211 | XFlush (display->display); |
1214 | XFlush (display->display); |
1212 | |
1215 | |
… | |
… | |
1411 | # endif |
1414 | # endif |
1412 | else |
1415 | else |
1413 | iso14755buf = 0; |
1416 | iso14755buf = 0; |
1414 | } |
1417 | } |
1415 | #endif |
1418 | #endif |
|
|
1419 | |
|
|
1420 | if (ev.xany.window == vt |
|
|
1421 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
1422 | break; |
1416 | |
1423 | |
1417 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1424 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1418 | if (!(ev.xkey.state & ControlMask)) |
1425 | if (!(ev.xkey.state & ControlMask)) |
1419 | slip_wheel_ev.stop (); |
1426 | slip_wheel_ev.stop (); |
1420 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1427 | else if (ks == XK_Control_L || ks == XK_Control_R) |
… | |
… | |
1635 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1642 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1636 | break; |
1643 | break; |
1637 | |
1644 | |
1638 | if (ev.xany.window == vt) |
1645 | if (ev.xany.window == vt) |
1639 | { |
1646 | { |
|
|
1647 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1648 | ; // nop |
1640 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1649 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1641 | { |
1650 | { |
1642 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1651 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1643 | ; |
1652 | ; |
1644 | |
1653 | |
1645 | XQueryPointer (disp, vt, |
1654 | XQueryPointer (disp, vt, |
… | |
… | |
1865 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1874 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1866 | if (ev.button == MEvent.button && clickintime) |
1875 | if (ev.button == MEvent.button && clickintime) |
1867 | { |
1876 | { |
1868 | /* same button, within alloted time */ |
1877 | /* same button, within alloted time */ |
1869 | MEvent.clicks++; |
1878 | MEvent.clicks++; |
|
|
1879 | |
1870 | if (MEvent.clicks > 1) |
1880 | if (MEvent.clicks > 1) |
1871 | { |
1881 | { |
1872 | /* only report double clicks */ |
1882 | /* only report double clicks */ |
1873 | MEvent.clicks = 2; |
1883 | MEvent.clicks = 2; |
1874 | mouse_report (ev); |
1884 | mouse_report (ev); |
… | |
… | |
1894 | else |
1904 | else |
1895 | { |
1905 | { |
1896 | if (ev.button != MEvent.button) |
1906 | if (ev.button != MEvent.button) |
1897 | MEvent.clicks = 0; |
1907 | MEvent.clicks = 0; |
1898 | |
1908 | |
1899 | if (!HOOK_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1909 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
1900 | switch (ev.button) |
1910 | switch (ev.button) |
1901 | { |
1911 | { |
1902 | case Button1: |
1912 | case Button1: |
1903 | /* allow meta + click to select rectangular areas */ |
1913 | /* allow meta + click to select rectangular areas */ |
1904 | /* should be done in screen.C */ |
1914 | /* should be done in screen.C */ |
… | |
… | |
2082 | } |
2092 | } |
2083 | |
2093 | |
2084 | break; |
2094 | break; |
2085 | } |
2095 | } |
2086 | } |
2096 | } |
|
|
2097 | |
2087 | return; |
2098 | return; |
2088 | } |
2099 | } |
|
|
2100 | |
2089 | #if MENUBAR |
2101 | #if MENUBAR |
2090 | /* |
2102 | /* |
2091 | * Menubar window processing of button press |
2103 | * Menubar window processing of button press |
2092 | */ |
2104 | */ |
2093 | if (isMenuBarWindow (ev.window)) |
2105 | if (isMenuBarWindow (ev.window)) |
… | |
… | |
2155 | */ |
2167 | */ |
2156 | if (priv_modes & PrivMode_mouse_report |
2168 | if (priv_modes & PrivMode_mouse_report |
2157 | && bypass_keystate |
2169 | && bypass_keystate |
2158 | && ev.button == Button1 && MEvent.clicks <= 1) |
2170 | && ev.button == Button1 && MEvent.clicks <= 1) |
2159 | selection_extend (ev.x, ev.y, 0); |
2171 | selection_extend (ev.x, ev.y, 0); |
|
|
2172 | |
|
|
2173 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2174 | return; |
2160 | |
2175 | |
2161 | switch (ev.button) |
2176 | switch (ev.button) |
2162 | { |
2177 | { |
2163 | case Button1: |
2178 | case Button1: |
2164 | case Button3: |
2179 | case Button3: |
… | |
… | |
2709 | |
2724 | |
2710 | bool |
2725 | bool |
2711 | rxvt_term::cmd_parse () |
2726 | rxvt_term::cmd_parse () |
2712 | { |
2727 | { |
2713 | bool flag = false; |
2728 | bool flag = false; |
2714 | unicode_t ch = NOCHAR; |
2729 | wchar_t ch = NOCHAR; |
2715 | char *seq_begin; // remember start of esc-sequence here |
2730 | char *seq_begin; // remember start of esc-sequence here |
2716 | |
2731 | |
2717 | for (;;) |
2732 | for (;;) |
2718 | { |
2733 | { |
2719 | if (ch == NOCHAR) |
2734 | if (ch == NOCHAR) |
… | |
… | |
2740 | if (seen_resize && cmd_pid) |
2755 | if (seen_resize && cmd_pid) |
2741 | kill (-cmd_pid, SIGWINCH); |
2756 | kill (-cmd_pid, SIGWINCH); |
2742 | } |
2757 | } |
2743 | |
2758 | |
2744 | /* Read a text string from the input buffer */ |
2759 | /* Read a text string from the input buffer */ |
2745 | unicode_t buf[UBUFSIZ]; |
2760 | wchar_t buf[UBUFSIZ]; |
2746 | bool refreshnow = false; |
2761 | bool refreshnow = false; |
2747 | int nlines = 0; |
2762 | int nlines = 0; |
2748 | unicode_t *str = buf; |
2763 | wchar_t *str = buf; |
2749 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2764 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2750 | |
2765 | |
2751 | for (;;) |
2766 | for (;;) |
2752 | { |
2767 | { |
2753 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2768 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2754 | break; |
2769 | break; |
… | |
… | |
2772 | } |
2787 | } |
2773 | |
2788 | |
2774 | // scr_add_lines only works for nlines <= nrow - 1. |
2789 | // scr_add_lines only works for nlines <= nrow - 1. |
2775 | if (nlines >= nrow - 1) |
2790 | if (nlines >= nrow - 1) |
2776 | { |
2791 | { |
2777 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2792 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2778 | scr_add_lines (buf, nlines, str - buf); |
2793 | scr_add_lines (buf, str - buf, nlines); |
2779 | |
2794 | |
2780 | nlines = 0; |
2795 | nlines = 0; |
2781 | str = buf; |
2796 | str = buf; |
2782 | eol = str + min (ncol, UBUFSIZ); |
2797 | eol = str + min (ncol, UBUFSIZ); |
2783 | } |
2798 | } |
… | |
… | |
2797 | |
2812 | |
2798 | seq_begin = cmdbuf_ptr; |
2813 | seq_begin = cmdbuf_ptr; |
2799 | ch = next_char (); |
2814 | ch = next_char (); |
2800 | } |
2815 | } |
2801 | |
2816 | |
2802 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2817 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2803 | scr_add_lines (buf, nlines, str - buf); |
2818 | scr_add_lines (buf, str - buf, nlines); |
2804 | |
2819 | |
2805 | /* |
2820 | /* |
2806 | * If there have been a lot of new lines, then update the screen |
2821 | * If there have been a lot of new lines, then update the screen |
2807 | * What the heck I'll cheat and only refresh less than every page-full. |
2822 | * What the heck I'll cheat and only refresh less than every page-full. |
2808 | * the number of pages between refreshes is refresh_limit, which |
2823 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2839 | } |
2854 | } |
2840 | |
2855 | |
2841 | return flag; |
2856 | return flag; |
2842 | } |
2857 | } |
2843 | |
2858 | |
2844 | // read the next octet |
|
|
2845 | unicode_t |
|
|
2846 | rxvt_term::next_octet () |
|
|
2847 | { |
|
|
2848 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2849 | ? *cmdbuf_ptr++ |
|
|
2850 | : NOCHAR; |
|
|
2851 | } |
|
|
2852 | |
|
|
2853 | // read the next character |
2859 | // read the next character |
2854 | unicode_t |
2860 | wchar_t |
2855 | rxvt_term::next_char () |
2861 | rxvt_term::next_char () |
2856 | { |
2862 | { |
2857 | while (cmdbuf_ptr < cmdbuf_endp) |
2863 | while (cmdbuf_ptr < cmdbuf_endp) |
2858 | { |
2864 | { |
2859 | // assume 7-bit to be ascii ALWAYS |
2865 | // assume 7-bit to be ascii ALWAYS |
… | |
… | |
2869 | cmdbuf_ptr = cmdbuf_endp; |
2875 | cmdbuf_ptr = cmdbuf_endp; |
2870 | break; |
2876 | break; |
2871 | } |
2877 | } |
2872 | |
2878 | |
2873 | if (len == (size_t)-1) |
2879 | if (len == (size_t)-1) |
2874 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2880 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2875 | |
2881 | |
2876 | // assume wchar == unicode |
2882 | // assume wchar == unicode |
2877 | cmdbuf_ptr += len; |
2883 | cmdbuf_ptr += len; |
2878 | return wc & UNICODE_MASK; |
2884 | return wc & UNICODE_MASK; |
2879 | } |
2885 | } |
2880 | |
2886 | |
2881 | return NOCHAR; |
2887 | return NOCHAR; |
|
|
2888 | } |
|
|
2889 | |
|
|
2890 | // read the next octet |
|
|
2891 | uint32_t |
|
|
2892 | rxvt_term::next_octet () |
|
|
2893 | { |
|
|
2894 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2895 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2896 | : NOCHAR; |
2882 | } |
2897 | } |
2883 | |
2898 | |
2884 | /* rxvt_cmd_getc () - Return next input character */ |
2899 | /* rxvt_cmd_getc () - Return next input character */ |
2885 | /* |
2900 | /* |
2886 | * Return the next input character after first passing any keyboard input |
2901 | * Return the next input character after first passing any keyboard input |
2887 | * to the command. |
2902 | * to the command. |
2888 | */ |
2903 | */ |
2889 | unicode_t |
2904 | wchar_t |
2890 | rxvt_term::cmd_getc () |
2905 | rxvt_term::cmd_getc () |
2891 | { |
2906 | { |
2892 | unicode_t c = next_char (); |
2907 | wchar_t c = next_char (); |
2893 | |
2908 | |
2894 | if (c == NOCHAR) |
2909 | if (c == NOCHAR) |
2895 | throw out_of_input; |
2910 | throw out_of_input; |
2896 | |
2911 | |
2897 | return c; |
2912 | return c; |
2898 | } |
2913 | } |
2899 | |
2914 | |
2900 | unicode_t |
2915 | uint32_t |
2901 | rxvt_term::cmd_get8 () |
2916 | rxvt_term::cmd_get8 () |
2902 | { |
2917 | { |
2903 | unicode_t c = next_octet (); |
2918 | uint32_t c = next_octet (); |
2904 | |
2919 | |
2905 | if (c == NOCHAR) |
2920 | if (c == NOCHAR) |
2906 | throw out_of_input; |
2921 | throw out_of_input; |
2907 | |
2922 | |
2908 | return c; |
2923 | return c; |
… | |
… | |
3175 | break; |
3190 | break; |
3176 | |
3191 | |
3177 | /* 8.3.87: NEXT LINE */ |
3192 | /* 8.3.87: NEXT LINE */ |
3178 | case C1_NEL: /* ESC E */ |
3193 | case C1_NEL: /* ESC E */ |
3179 | { |
3194 | { |
3180 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3195 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3181 | scr_add_lines (nlcr, 1, 2); |
3196 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3182 | } |
3197 | } |
3183 | break; |
3198 | break; |
3184 | |
3199 | |
3185 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3200 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3186 | case C1_ESA: /* ESC G */ |
3201 | case C1_ESA: /* ESC G */ |
… | |
… | |
4014 | break; |
4029 | break; |
4015 | #endif |
4030 | #endif |
4016 | |
4031 | |
4017 | #if ENABLE_PERL |
4032 | #if ENABLE_PERL |
4018 | case URxvt_perl: |
4033 | case URxvt_perl: |
4019 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
4034 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
4020 | ; // no responses yet |
4035 | ; // no responses yet |
4021 | break; |
4036 | break; |
4022 | #endif |
4037 | #endif |
4023 | } |
4038 | } |
4024 | } |
4039 | } |
… | |
… | |
4454 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4469 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4455 | |
4470 | |
4456 | void |
4471 | void |
4457 | rxvt_term::tt_write (const char *data, unsigned int len) |
4472 | rxvt_term::tt_write (const char *data, unsigned int len) |
4458 | { |
4473 | { |
|
|
4474 | if (pty.pty < 0) |
|
|
4475 | return; |
|
|
4476 | |
4459 | if (v_buflen == 0) |
4477 | if (v_buflen == 0) |
4460 | { |
4478 | { |
4461 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4479 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4462 | |
4480 | |
4463 | if ((unsigned int)written == len) |
4481 | if ((unsigned int)written == len) |