… | |
… | |
63 | #include <csignal> |
63 | #include <csignal> |
64 | |
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
68 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
70 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
1044 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1041 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1045 | { |
1042 | { |
1046 | hidden_cursor = !hidden_cursor; |
1043 | hidden_cursor = !hidden_cursor; |
1047 | want_refresh = 1; |
1044 | want_refresh = 1; |
1048 | |
1045 | |
1049 | w.start (w.at + BLINK_INTERVAL); |
1046 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1050 | } |
1047 | } |
1051 | #endif |
1048 | #endif |
1052 | |
1049 | |
1053 | #ifdef TEXT_BLINK |
1050 | #ifdef TEXT_BLINK |
1054 | void |
1051 | void |
… | |
… | |
1405 | button_release (ev.xbutton); |
1402 | button_release (ev.xbutton); |
1406 | break; |
1403 | break; |
1407 | |
1404 | |
1408 | case ClientMessage: |
1405 | case ClientMessage: |
1409 | if (ev.xclient.format == 32 |
1406 | if (ev.xclient.format == 32 |
1410 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1407 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1411 | { |
1408 | { |
|
|
1409 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1410 | { |
|
|
1411 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1412 | { |
1412 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1413 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1414 | { |
|
|
1415 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1413 | destroy (); |
1416 | destroy (); |
|
|
1417 | } |
1414 | #if ENABLE_EWMH |
1418 | #if ENABLE_EWMH |
1415 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1419 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1416 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1417 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1418 | &ev); |
1422 | &ev); |
|
|
1423 | #endif |
|
|
1424 | } |
|
|
1425 | } |
|
|
1426 | #if ENABLE_XEMBED |
|
|
1427 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1428 | { |
|
|
1429 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1430 | focus_in (); |
|
|
1431 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1432 | focus_out (); |
|
|
1433 | } |
1419 | #endif |
1434 | #endif |
1420 | } |
1435 | } |
1421 | #if ENABLE_XEMBED |
|
|
1422 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1423 | { |
|
|
1424 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1425 | focus_in (); |
|
|
1426 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1427 | focus_out (); |
|
|
1428 | } |
|
|
1429 | #endif |
|
|
1430 | #ifdef OFFIX_DND |
|
|
1431 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1432 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1433 | && (ev.xclient.data.l[0] == DndFile |
|
|
1434 | || ev.xclient.data.l[0] == DndDir |
|
|
1435 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1436 | { |
|
|
1437 | /* Get Dnd data */ |
|
|
1438 | Atom ActualType; |
|
|
1439 | int ActualFormat; |
|
|
1440 | unsigned char *data; |
|
|
1441 | unsigned long Size, RemainingBytes; |
|
|
1442 | |
|
|
1443 | XGetWindowProperty (disp, display->root, |
|
|
1444 | xa[XA_DNDSELECTION], |
|
|
1445 | 0L, 1000000L, |
|
|
1446 | False, AnyPropertyType, |
|
|
1447 | &ActualType, &ActualFormat, |
|
|
1448 | &Size, &RemainingBytes, |
|
|
1449 | &data); |
|
|
1450 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1451 | XFree (data); |
|
|
1452 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1453 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1454 | } |
|
|
1455 | #endif /* OFFIX_DND */ |
|
|
1456 | break; |
1436 | break; |
1457 | |
1437 | |
1458 | case MappingNotify: |
1438 | case MappingNotify: |
1459 | XRefreshKeyboardMapping (&ev.xmapping); |
1439 | XRefreshKeyboardMapping (&ev.xmapping); |
1460 | break; |
1440 | break; |
… | |
… | |
1713 | { |
1693 | { |
1714 | hidden_cursor = 0; |
1694 | hidden_cursor = 0; |
1715 | want_refresh = 1; |
1695 | want_refresh = 1; |
1716 | } |
1696 | } |
1717 | |
1697 | |
1718 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1698 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1719 | } |
1699 | } |
1720 | #endif |
1700 | #endif |
1721 | |
1701 | |
1722 | #if defined(POINTER_BLANK) |
1702 | #if defined(POINTER_BLANK) |
1723 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1703 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
… | |
… | |
1751 | XSetICFocus (Input_Context); |
1731 | XSetICFocus (Input_Context); |
1752 | } |
1732 | } |
1753 | #endif |
1733 | #endif |
1754 | #if CURSOR_BLINK |
1734 | #if CURSOR_BLINK |
1755 | if (OPTION (Opt_cursorBlink)) |
1735 | if (OPTION (Opt_cursorBlink)) |
1756 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1736 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1757 | #endif |
1737 | #endif |
1758 | #if OFF_FOCUS_FADING |
1738 | #if OFF_FOCUS_FADING |
1759 | if (rs[Rs_fade]) |
1739 | if (rs[Rs_fade]) |
1760 | { |
1740 | { |
1761 | pix_colors = pix_colors_focused; |
1741 | pix_colors = pix_colors_focused; |
… | |
… | |
2157 | case Button3: |
2137 | case Button3: |
2158 | selection_make (ev.time); |
2138 | selection_make (ev.time); |
2159 | break; |
2139 | break; |
2160 | |
2140 | |
2161 | case Button2: |
2141 | case Button2: |
2162 | if (IN_RANGE_EXC (ev.x, 0, width) |
2142 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2163 | && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2143 | selection_request (ev.time, ev.state & ShiftMask ? Sel_Clipboard : Sel_Primary); |
2164 | selection_request (ev.time); |
|
|
2165 | |
|
|
2166 | break; |
2144 | break; |
2167 | |
2145 | |
2168 | #ifdef MOUSE_WHEEL |
2146 | #ifdef MOUSE_WHEEL |
2169 | case Button4: |
2147 | case Button4: |
2170 | case Button5: |
2148 | case Button5: |
… | |
… | |
2827 | return flag; |
2805 | return flag; |
2828 | } |
2806 | } |
2829 | |
2807 | |
2830 | // read the next character |
2808 | // read the next character |
2831 | wchar_t |
2809 | wchar_t |
2832 | rxvt_term::next_char () |
2810 | rxvt_term::next_char () NOTHROW |
2833 | { |
2811 | { |
2834 | while (cmdbuf_ptr < cmdbuf_endp) |
2812 | while (cmdbuf_ptr < cmdbuf_endp) |
2835 | { |
2813 | { |
2836 | // assume 7-bit to be ascii ALWAYS |
2814 | // assume 7-bit to be ascii ALWAYS |
2837 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2815 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2858 | return NOCHAR; |
2836 | return NOCHAR; |
2859 | } |
2837 | } |
2860 | |
2838 | |
2861 | // read the next octet |
2839 | // read the next octet |
2862 | uint32_t |
2840 | uint32_t |
2863 | rxvt_term::next_octet () |
2841 | rxvt_term::next_octet () NOTHROW |
2864 | { |
2842 | { |
2865 | return cmdbuf_ptr < cmdbuf_endp |
2843 | return cmdbuf_ptr < cmdbuf_endp |
2866 | ? (unsigned char)*cmdbuf_ptr++ |
2844 | ? (unsigned char)*cmdbuf_ptr++ |
2867 | : NOCHAR; |
2845 | : NOCHAR; |
2868 | } |
2846 | } |
|
|
2847 | |
|
|
2848 | static class out_of_input out_of_input; |
2869 | |
2849 | |
2870 | /* rxvt_cmd_getc () - Return next input character */ |
2850 | /* rxvt_cmd_getc () - Return next input character */ |
2871 | /* |
2851 | /* |
2872 | * Return the next input character after first passing any keyboard input |
2852 | * Return the next input character after first passing any keyboard input |
2873 | * to the command. |
2853 | * to the command. |
2874 | */ |
2854 | */ |
2875 | wchar_t |
2855 | wchar_t |
2876 | rxvt_term::cmd_getc () |
2856 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2877 | { |
2857 | { |
2878 | wchar_t c = next_char (); |
2858 | wchar_t c = next_char (); |
2879 | |
2859 | |
2880 | if (c == NOCHAR) |
2860 | if (c == NOCHAR) |
2881 | throw out_of_input; |
2861 | throw out_of_input; |
2882 | |
2862 | |
2883 | return c; |
2863 | return c; |
2884 | } |
2864 | } |
2885 | |
2865 | |
2886 | uint32_t |
2866 | uint32_t |
2887 | rxvt_term::cmd_get8 () |
2867 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2888 | { |
2868 | { |
2889 | uint32_t c = next_octet (); |
2869 | uint32_t c = next_octet (); |
2890 | |
2870 | |
2891 | if (c == NOCHAR) |
2871 | if (c == NOCHAR) |
2892 | throw out_of_input; |
2872 | throw out_of_input; |
… | |
… | |
4042 | return state; |
4022 | return state; |
4043 | } |
4023 | } |
4044 | |
4024 | |
4045 | /* we're not using priv _yet_ */ |
4025 | /* we're not using priv _yet_ */ |
4046 | void |
4026 | void |
4047 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4027 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4048 | { |
4028 | { |
4049 | unsigned int i, j; |
4029 | unsigned int i, j; |
4050 | int state; |
4030 | int state; |
4051 | |
4031 | |
4052 | static const struct |
4032 | static const struct |