… | |
… | |
64 | |
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
68 | |
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
|
|
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) |
76 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
73 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
… | |
… | |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
299 | rxvt_term::lookup_key (XKeyEvent &ev) |
303 | { |
300 | { |
304 | int ctrl, meta, shft, len; |
301 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
302 | unsigned int newlen; |
306 | KeySym keysym; |
303 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
304 | int valid_keysym; |
311 | char kbuf[KBUFSZ]; |
305 | char kbuf[KBUFSZ]; |
312 | |
306 | |
313 | /* |
307 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
308 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
… | |
… | |
464 | { |
458 | { |
465 | switch (keysym) |
459 | switch (keysym) |
466 | { |
460 | { |
467 | /* normal XTerm key bindings */ |
461 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
463 | selection_request (ev.time); |
470 | return; |
464 | return; |
471 | #if TODO |
465 | #if TODO |
472 | /* rxvt extras */ |
466 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
468 | change_font (FONT_UP); |
… | |
… | |
905 | { |
899 | { |
906 | const char ch = C0_ESC; |
900 | const char ch = C0_ESC; |
907 | tt_write (&ch, 1); |
901 | tt_write (&ch, 1); |
908 | } |
902 | } |
909 | |
903 | |
910 | #if defined(DEBUG_CMD) |
|
|
911 | /* Display keyboard buffer contents */ |
|
|
912 | unsigned char *p; |
|
|
913 | int i; |
|
|
914 | |
|
|
915 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
916 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
917 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
918 | fprintf (stderr, "'\n"); |
|
|
919 | #endif /* DEBUG_CMD */ |
|
|
920 | tt_write (kbuf, (unsigned int)len); |
904 | tt_write (kbuf, (unsigned int)len); |
921 | } |
905 | } |
922 | /*}}} */ |
906 | /*}}} */ |
923 | |
907 | |
924 | #if defined (KEYSYM_RESOURCE) |
908 | #if defined (KEYSYM_RESOURCE) |
… | |
… | |
1006 | while (l->is_longer () && row < end_row); |
990 | while (l->is_longer () && row < end_row); |
1007 | } |
991 | } |
1008 | while (row < end_row); |
992 | while (row < end_row); |
1009 | } |
993 | } |
1010 | |
994 | |
1011 | scr_refresh (refresh_type); |
995 | scr_refresh (); |
1012 | scrollbar_show (1); |
996 | scrollbar_show (1); |
1013 | #ifdef USE_XIM |
997 | #ifdef USE_XIM |
1014 | IMSendSpot (); |
998 | IMSendSpot (); |
1015 | #endif |
999 | #endif |
1016 | } |
1000 | } |
… | |
… | |
1044 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1028 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1045 | { |
1029 | { |
1046 | hidden_cursor = !hidden_cursor; |
1030 | hidden_cursor = !hidden_cursor; |
1047 | want_refresh = 1; |
1031 | want_refresh = 1; |
1048 | |
1032 | |
1049 | w.start (w.at + BLINK_INTERVAL); |
1033 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1050 | } |
1034 | } |
1051 | #endif |
1035 | #endif |
1052 | |
1036 | |
1053 | #ifdef TEXT_BLINK |
1037 | #ifdef TEXT_BLINK |
1054 | void |
1038 | void |
… | |
… | |
1068 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1052 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1069 | { |
1053 | { |
1070 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1054 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1071 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1055 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1072 | { |
1056 | { |
1073 | refresh_type |= SMOOTH_REFRESH; |
|
|
1074 | want_refresh = 1; |
1057 | want_refresh = 1; |
1075 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1058 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1076 | } |
1059 | } |
1077 | } |
1060 | } |
1078 | #endif |
1061 | #endif |
… | |
… | |
1082 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1065 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1083 | { |
1066 | { |
1084 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1067 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1085 | { |
1068 | { |
1086 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1069 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1087 | refresh_type |= SMOOTH_REFRESH; |
|
|
1088 | want_refresh = 1; |
1070 | want_refresh = 1; |
1089 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1090 | } |
1072 | } |
1091 | } |
1073 | } |
1092 | #endif |
1074 | #endif |
… | |
… | |
1100 | : scr_page (UP, mouse_slip_wheel_speed)) |
1082 | : scr_page (UP, mouse_slip_wheel_speed)) |
1101 | { |
1083 | { |
1102 | if (view_start == top_row || view_start == 0) |
1084 | if (view_start == top_row || view_start == 0) |
1103 | mouse_slip_wheel_speed = 0; |
1085 | mouse_slip_wheel_speed = 0; |
1104 | |
1086 | |
1105 | refresh_type |= SMOOTH_REFRESH; |
|
|
1106 | want_refresh = 1; |
1087 | want_refresh = 1; |
1107 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1088 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1108 | } |
1089 | } |
1109 | } |
1090 | } |
1110 | #endif |
1091 | #endif |
… | |
… | |
1140 | |
1121 | |
1141 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1122 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1142 | cmdbuf_ptr = cmdbuf_base; |
1123 | cmdbuf_ptr = cmdbuf_base; |
1143 | cmdbuf_endp = cmdbuf_ptr + n; |
1124 | cmdbuf_endp = cmdbuf_ptr + n; |
1144 | |
1125 | |
1145 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1126 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1146 | |
1127 | |
1147 | if (r > 0) |
1128 | if (r > 0) |
1148 | { |
1129 | { |
1149 | cmdbuf_endp += r; |
1130 | cmdbuf_endp += r; |
1150 | return true; |
1131 | return true; |
… | |
… | |
1408 | button_release (ev.xbutton); |
1389 | button_release (ev.xbutton); |
1409 | break; |
1390 | break; |
1410 | |
1391 | |
1411 | case ClientMessage: |
1392 | case ClientMessage: |
1412 | if (ev.xclient.format == 32 |
1393 | if (ev.xclient.format == 32 |
1413 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1394 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1414 | { |
1395 | { |
|
|
1396 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1397 | { |
|
|
1398 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1399 | { |
1415 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1400 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1401 | { |
|
|
1402 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1416 | destroy (); |
1403 | destroy (); |
|
|
1404 | } |
1417 | #if ENABLE_EWMH |
1405 | #if ENABLE_EWMH |
1418 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1406 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1419 | XSendEvent (disp, ev.xclient.window = display->root, |
1407 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1408 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | &ev); |
1409 | &ev); |
|
|
1410 | #endif |
|
|
1411 | } |
|
|
1412 | } |
|
|
1413 | #if ENABLE_XEMBED |
|
|
1414 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1415 | { |
|
|
1416 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1417 | focus_in (); |
|
|
1418 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1419 | focus_out (); |
|
|
1420 | } |
1422 | #endif |
1421 | #endif |
1423 | } |
1422 | } |
1424 | #if ENABLE_XEMBED |
|
|
1425 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1426 | { |
|
|
1427 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1428 | focus_in (); |
|
|
1429 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1430 | focus_out (); |
|
|
1431 | } |
|
|
1432 | #endif |
|
|
1433 | #ifdef OFFIX_DND |
|
|
1434 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1435 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1436 | && (ev.xclient.data.l[0] == DndFile |
|
|
1437 | || ev.xclient.data.l[0] == DndDir |
|
|
1438 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1439 | { |
|
|
1440 | /* Get Dnd data */ |
|
|
1441 | Atom ActualType; |
|
|
1442 | int ActualFormat; |
|
|
1443 | unsigned char *data; |
|
|
1444 | unsigned long Size, RemainingBytes; |
|
|
1445 | |
|
|
1446 | XGetWindowProperty (disp, display->root, |
|
|
1447 | xa[XA_DNDSELECTION], |
|
|
1448 | 0L, 1000000L, |
|
|
1449 | False, AnyPropertyType, |
|
|
1450 | &ActualType, &ActualFormat, |
|
|
1451 | &Size, &RemainingBytes, |
|
|
1452 | &data); |
|
|
1453 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1454 | XFree (data); |
|
|
1455 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1456 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1457 | } |
|
|
1458 | #endif /* OFFIX_DND */ |
|
|
1459 | break; |
1423 | break; |
1460 | |
1424 | |
1461 | case MappingNotify: |
1425 | case MappingNotify: |
1462 | XRefreshKeyboardMapping (&ev.xmapping); |
1426 | XRefreshKeyboardMapping (&ev.xmapping); |
1463 | break; |
1427 | break; |
… | |
… | |
1505 | { |
1469 | { |
1506 | seen_resize = 1; |
1470 | seen_resize = 1; |
1507 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1471 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1508 | } |
1472 | } |
1509 | |
1473 | |
|
|
1474 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1475 | |
1510 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1476 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1511 | if (OPTION (Opt_transparent)) |
1477 | if (OPTION (Opt_transparent)) |
1512 | check_our_parents (); |
1478 | check_our_parents (); |
1513 | #endif |
1479 | #endif |
1514 | } |
1480 | } |
1515 | break; |
1481 | break; |
1516 | |
1482 | |
1517 | case PropertyNotify: |
1483 | case PropertyNotify: |
|
|
1484 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1518 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1485 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1519 | && ev.xproperty.state == PropertyNewValue) |
1486 | && ev.xproperty.state == PropertyNewValue) |
1520 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1487 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1521 | |
1488 | |
1522 | break; |
1489 | break; |
1523 | |
1490 | |
1524 | case SelectionClear: |
1491 | case SelectionClear: |
1525 | selection_clear (); |
1492 | selection_clear (); |
… | |
… | |
1714 | { |
1681 | { |
1715 | hidden_cursor = 0; |
1682 | hidden_cursor = 0; |
1716 | want_refresh = 1; |
1683 | want_refresh = 1; |
1717 | } |
1684 | } |
1718 | |
1685 | |
1719 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1686 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1720 | } |
1687 | } |
1721 | #endif |
1688 | #endif |
1722 | |
1689 | |
1723 | #if defined(POINTER_BLANK) |
1690 | #if defined(POINTER_BLANK) |
1724 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1691 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
… | |
… | |
1752 | XSetICFocus (Input_Context); |
1719 | XSetICFocus (Input_Context); |
1753 | } |
1720 | } |
1754 | #endif |
1721 | #endif |
1755 | #if CURSOR_BLINK |
1722 | #if CURSOR_BLINK |
1756 | if (OPTION (Opt_cursorBlink)) |
1723 | if (OPTION (Opt_cursorBlink)) |
1757 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1724 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1758 | #endif |
1725 | #endif |
1759 | #if OFF_FOCUS_FADING |
1726 | #if OFF_FOCUS_FADING |
1760 | if (rs[Rs_fade]) |
1727 | if (rs[Rs_fade]) |
1761 | { |
1728 | { |
1762 | pix_colors = pix_colors_focused; |
1729 | pix_colors = pix_colors_focused; |
… | |
… | |
1843 | /* |
1810 | /* |
1844 | * VT window processing of button press |
1811 | * VT window processing of button press |
1845 | */ |
1812 | */ |
1846 | if (ev.window == vt) |
1813 | if (ev.window == vt) |
1847 | { |
1814 | { |
|
|
1815 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1816 | return; |
|
|
1817 | |
1848 | #if ISO_14755 |
1818 | #if ISO_14755 |
1849 | // 5.4 |
1819 | // 5.4 |
1850 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1820 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1851 | { |
1821 | { |
1852 | iso14755_54 (ev.x, ev.y); |
1822 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1894 | else |
1864 | else |
1895 | { |
1865 | { |
1896 | if (ev.button != MEvent.button) |
1866 | if (ev.button != MEvent.button) |
1897 | MEvent.clicks = 0; |
1867 | MEvent.clicks = 0; |
1898 | |
1868 | |
1899 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1900 | switch (ev.button) |
1869 | switch (ev.button) |
1901 | { |
1870 | { |
1902 | case Button1: |
1871 | case Button1: |
1903 | /* allow meta + click to select rectangular areas */ |
1872 | /* allow meta + click to select rectangular areas */ |
1904 | /* should be done in screen.C */ |
1873 | /* should be done in screen.C */ |
1905 | #if ENABLE_FRILLS |
1874 | #if ENABLE_FRILLS |
1906 | selection.rect = !!(ev.state & ModMetaMask); |
1875 | selection.rect = !!(ev.state & ModMetaMask); |
1907 | #else |
1876 | #else |
1908 | selection.rect = false; |
1877 | selection.rect = false; |
1909 | #endif |
1878 | #endif |
1910 | |
1879 | |
1911 | /* allow shift+left click to extend selection */ |
1880 | /* allow shift+left click to extend selection */ |
1912 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1881 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1913 | { |
1882 | { |
1914 | if (MEvent.button == Button1 && clickintime) |
1883 | if (MEvent.button == Button1 && clickintime) |
1915 | selection_rotate (ev.x, ev.y); |
1884 | selection_rotate (ev.x, ev.y); |
1916 | else |
1885 | else |
1917 | selection_extend (ev.x, ev.y, 1); |
1886 | selection_extend (ev.x, ev.y, 1); |
1918 | } |
1887 | } |
1919 | else |
1888 | else |
1920 | { |
1889 | { |
1921 | if (MEvent.button == Button1 && clickintime) |
1890 | if (MEvent.button == Button1 && clickintime) |
1922 | MEvent.clicks++; |
1891 | MEvent.clicks++; |
1923 | else |
1892 | else |
1924 | MEvent.clicks = 1; |
1893 | MEvent.clicks = 1; |
1925 | |
1894 | |
1926 | selection_click (MEvent.clicks, ev.x, ev.y); |
1895 | selection_click (MEvent.clicks, ev.x, ev.y); |
1927 | } |
1896 | } |
1928 | |
1897 | |
1929 | MEvent.button = Button1; |
1898 | MEvent.button = Button1; |
1930 | break; |
1899 | break; |
1931 | |
1900 | |
1932 | case Button3: |
1901 | case Button3: |
1933 | if (MEvent.button == Button3 && clickintime) |
1902 | if (MEvent.button == Button3 && clickintime) |
1934 | selection_rotate (ev.x, ev.y); |
1903 | selection_rotate (ev.x, ev.y); |
1935 | else |
1904 | else |
1936 | selection_extend (ev.x, ev.y, 1); |
1905 | selection_extend (ev.x, ev.y, 1); |
1937 | |
1906 | |
1938 | MEvent.button = Button3; |
1907 | MEvent.button = Button3; |
1939 | break; |
1908 | break; |
1940 | } |
1909 | } |
1941 | } |
1910 | } |
1942 | |
1911 | |
1943 | MEvent.time = ev.time; |
1912 | MEvent.time = ev.time; |
1944 | return; |
1913 | return; |
1945 | } |
1914 | } |
1946 | |
1915 | |
… | |
… | |
2100 | |
2069 | |
2101 | if (scrollbar_isUpDn ()) |
2070 | if (scrollbar_isUpDn ()) |
2102 | { |
2071 | { |
2103 | scrollBar.setIdle (); |
2072 | scrollBar.setIdle (); |
2104 | scrollbar_show (0); |
2073 | scrollbar_show (0); |
2105 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2106 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2107 | #endif |
|
|
2108 | } |
2074 | } |
2109 | |
2075 | |
2110 | #ifdef SELECTION_SCROLLING |
2076 | #ifdef SELECTION_SCROLLING |
2111 | if (sel_scroll_ev.active) |
2077 | if (sel_scroll_ev.active) |
2112 | sel_scroll_ev.stop(); |
2078 | sel_scroll_ev.stop(); |
2113 | #endif |
2079 | #endif |
2114 | |
2080 | |
2115 | if (ev.window == vt) |
2081 | if (ev.window == vt) |
2116 | { |
2082 | { |
|
|
2083 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2084 | return; |
|
|
2085 | |
2117 | #if ISO_14755 |
2086 | #if ISO_14755 |
2118 | // 5.4 |
2087 | // 5.4 |
2119 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2088 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2120 | return; |
2089 | return; |
2121 | #endif |
2090 | #endif |
|
|
2091 | |
2122 | if (reportmode) |
2092 | if (reportmode) |
2123 | { |
2093 | { |
2124 | /* mouse report from vt window */ |
2094 | /* mouse report from vt window */ |
2125 | /* don't report release of wheel "buttons" */ |
2095 | /* don't report release of wheel "buttons" */ |
2126 | if (ev.button >= 4) |
2096 | if (ev.button >= 4) |
… | |
… | |
2150 | if (priv_modes & PrivMode_mouse_report |
2120 | if (priv_modes & PrivMode_mouse_report |
2151 | && bypass_keystate |
2121 | && bypass_keystate |
2152 | && ev.button == Button1 && MEvent.clicks <= 1) |
2122 | && ev.button == Button1 && MEvent.clicks <= 1) |
2153 | selection_extend (ev.x, ev.y, 0); |
2123 | selection_extend (ev.x, ev.y, 0); |
2154 | |
2124 | |
2155 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2156 | return; |
|
|
2157 | |
|
|
2158 | switch (ev.button) |
2125 | switch (ev.button) |
2159 | { |
2126 | { |
2160 | case Button1: |
2127 | case Button1: |
2161 | case Button3: |
2128 | case Button3: |
2162 | selection_make (ev.time); |
2129 | selection_make (ev.time); |
2163 | break; |
2130 | break; |
|
|
2131 | |
2164 | case Button2: |
2132 | case Button2: |
2165 | selection_request (ev.time, ev.x, ev.y); |
2133 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2134 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2166 | break; |
2135 | break; |
|
|
2136 | |
2167 | #ifdef MOUSE_WHEEL |
2137 | #ifdef MOUSE_WHEEL |
2168 | case Button4: |
2138 | case Button4: |
2169 | case Button5: |
2139 | case Button5: |
2170 | { |
2140 | { |
2171 | int i; |
2141 | int i; |
… | |
… | |
2649 | am_transparent = 0; |
2619 | am_transparent = 0; |
2650 | /* XXX: also turn off Opt_transparent? */ |
2620 | /* XXX: also turn off Opt_transparent? */ |
2651 | } |
2621 | } |
2652 | else |
2622 | else |
2653 | { |
2623 | { |
2654 | #if WAIT_FOR_WM |
|
|
2655 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2656 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2657 | sleep (1); |
|
|
2658 | #endif |
|
|
2659 | for (n = 0; n < (unsigned int)i; n++) |
2624 | for (n = 0; n < (unsigned int)i; n++) |
2660 | { |
2625 | { |
2661 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2626 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2662 | XClearWindow (disp, parent[n]); |
2627 | XClearWindow (disp, parent[n]); |
2663 | } |
2628 | } |
… | |
… | |
2798 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2763 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2799 | refresh_limit++; |
2764 | refresh_limit++; |
2800 | else |
2765 | else |
2801 | { |
2766 | { |
2802 | flag = true; |
2767 | flag = true; |
2803 | scr_refresh (refresh_type); |
2768 | scr_refresh (); |
2804 | want_refresh = 1; |
2769 | want_refresh = 1; |
2805 | } |
2770 | } |
2806 | } |
2771 | } |
2807 | |
2772 | |
2808 | } |
2773 | } |
… | |
… | |
2826 | return flag; |
2791 | return flag; |
2827 | } |
2792 | } |
2828 | |
2793 | |
2829 | // read the next character |
2794 | // read the next character |
2830 | wchar_t |
2795 | wchar_t |
2831 | rxvt_term::next_char () |
2796 | rxvt_term::next_char () NOTHROW |
2832 | { |
2797 | { |
2833 | while (cmdbuf_ptr < cmdbuf_endp) |
2798 | while (cmdbuf_ptr < cmdbuf_endp) |
2834 | { |
2799 | { |
2835 | // assume 7-bit to be ascii ALWAYS |
2800 | // assume 7-bit to be ascii ALWAYS |
2836 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2801 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2857 | return NOCHAR; |
2822 | return NOCHAR; |
2858 | } |
2823 | } |
2859 | |
2824 | |
2860 | // read the next octet |
2825 | // read the next octet |
2861 | uint32_t |
2826 | uint32_t |
2862 | rxvt_term::next_octet () |
2827 | rxvt_term::next_octet () NOTHROW |
2863 | { |
2828 | { |
2864 | return cmdbuf_ptr < cmdbuf_endp |
2829 | return cmdbuf_ptr < cmdbuf_endp |
2865 | ? (unsigned char)*cmdbuf_ptr++ |
2830 | ? (unsigned char)*cmdbuf_ptr++ |
2866 | : NOCHAR; |
2831 | : NOCHAR; |
2867 | } |
2832 | } |
|
|
2833 | |
|
|
2834 | static class out_of_input out_of_input; |
2868 | |
2835 | |
2869 | /* rxvt_cmd_getc () - Return next input character */ |
2836 | /* rxvt_cmd_getc () - Return next input character */ |
2870 | /* |
2837 | /* |
2871 | * Return the next input character after first passing any keyboard input |
2838 | * Return the next input character after first passing any keyboard input |
2872 | * to the command. |
2839 | * to the command. |
2873 | */ |
2840 | */ |
2874 | wchar_t |
2841 | wchar_t |
2875 | rxvt_term::cmd_getc () |
2842 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2876 | { |
2843 | { |
2877 | wchar_t c = next_char (); |
2844 | wchar_t c = next_char (); |
2878 | |
2845 | |
2879 | if (c == NOCHAR) |
2846 | if (c == NOCHAR) |
2880 | throw out_of_input; |
2847 | throw out_of_input; |
2881 | |
2848 | |
2882 | return c; |
2849 | return c; |
2883 | } |
2850 | } |
2884 | |
2851 | |
2885 | uint32_t |
2852 | uint32_t |
2886 | rxvt_term::cmd_get8 () |
2853 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2887 | { |
2854 | { |
2888 | uint32_t c = next_octet (); |
2855 | uint32_t c = next_octet (); |
2889 | |
2856 | |
2890 | if (c == NOCHAR) |
2857 | if (c == NOCHAR) |
2891 | throw out_of_input; |
2858 | throw out_of_input; |
… | |
… | |
3312 | ndef = get_byte_array_bit (csi_defaults, i); |
3279 | ndef = get_byte_array_bit (csi_defaults, i); |
3313 | for (p = 0; p < nargs; p++) |
3280 | for (p = 0; p < nargs; p++) |
3314 | if (arg[p] == -1) |
3281 | if (arg[p] == -1) |
3315 | arg[p] = ndef; |
3282 | arg[p] = ndef; |
3316 | |
3283 | |
3317 | #ifdef DEBUG_CMD |
|
|
3318 | fprintf (stderr, "CSI "); |
|
|
3319 | for (p = 0; p < nargs; p++) |
|
|
3320 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3321 | fprintf (stderr, "%c\n", ch); |
|
|
3322 | #endif |
|
|
3323 | |
|
|
3324 | /* |
3284 | /* |
3325 | * private mode handling |
3285 | * private mode handling |
3326 | */ |
3286 | */ |
3327 | if (priv) |
3287 | if (priv) |
3328 | { |
3288 | { |
3329 | switch (priv) |
3289 | switch (priv) |
3330 | { |
3290 | { |
3331 | case '>': |
3291 | case '>': |
3332 | if (ch == CSI_DA) /* secondary device attributes */ |
3292 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3293 | { |
|
|
3294 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3295 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3296 | // |
|
|
3297 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3298 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3299 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3300 | // |
3333 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3301 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3302 | } |
3334 | break; |
3303 | break; |
3335 | case '?': |
3304 | case '?': |
3336 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3305 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3337 | process_terminal_mode (ch, priv, nargs, arg); |
3306 | process_terminal_mode (ch, priv, nargs, arg); |
3338 | break; |
3307 | break; |
… | |
… | |
3770 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3739 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3771 | */ |
3740 | */ |
3772 | void |
3741 | void |
3773 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3742 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3774 | { |
3743 | { |
3775 | int changed = 0; |
|
|
3776 | int color; |
3744 | int color; |
3777 | char *buf, *name; |
3745 | char *buf, *name; |
3778 | bool query = str[0] == '?' && !str[1]; |
3746 | bool query = str[0] == '?' && !str[1]; |
3779 | int saveop = op; |
3747 | int saveop = op; |
3780 | dDisp; |
3748 | dDisp; |
… | |
… | |
3896 | want_full_refresh = want_refresh = 1; |
3864 | want_full_refresh = want_refresh = 1; |
3897 | break; |
3865 | break; |
3898 | #endif |
3866 | #endif |
3899 | |
3867 | |
3900 | case Rxvt_Pixmap: |
3868 | case Rxvt_Pixmap: |
|
|
3869 | { |
3901 | if (*str != ';') |
3870 | if (*str != ';') |
3902 | { |
3871 | { |
3903 | #if XPM_BACKGROUND |
3872 | #if XPM_BACKGROUND |
3904 | scale_pixmap (""); /* reset to default scaling */ |
3873 | scale_pixmap (""); /* reset to default scaling */ |
3905 | set_bgPixmap (str); /* change pixmap */ |
3874 | set_bgPixmap (str); /* change pixmap */ |
3906 | scr_touch (true); |
3875 | scr_touch (true); |
3907 | #endif |
3876 | #endif |
3908 | } |
3877 | } |
3909 | |
3878 | |
|
|
3879 | int changed = 0; |
|
|
3880 | |
3910 | while ((str = strchr (str, ';')) != NULL) |
3881 | while ((str = strchr (str, ';')) != NULL) |
3911 | { |
3882 | { |
3912 | str++; |
3883 | str++; |
3913 | #if XPM_BACKGROUND |
3884 | #if XPM_BACKGROUND |
3914 | changed += scale_pixmap (str); |
3885 | changed += scale_pixmap (str); |
3915 | #endif |
3886 | #endif |
3916 | } |
3887 | } |
3917 | |
3888 | |
3918 | if (changed) |
3889 | if (changed) |
3919 | { |
3890 | { |
3920 | #ifdef XPM_BACKGROUND |
3891 | #ifdef XPM_BACKGROUND |
3921 | resize_pixmap (); |
3892 | resize_pixmap (); |
3922 | scr_touch (true); |
3893 | scr_touch (true); |
3923 | #endif |
3894 | #endif |
3924 | } |
3895 | } |
|
|
3896 | } |
3925 | break; |
3897 | break; |
3926 | |
3898 | |
3927 | case Rxvt_restoreFG: |
3899 | case Rxvt_restoreFG: |
3928 | set_window_color (Color_fg, str); |
3900 | set_window_color (Color_fg, str); |
3929 | break; |
3901 | break; |
… | |
… | |
3975 | if (query) |
3947 | if (query) |
3976 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3948 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3977 | else |
3949 | else |
3978 | { |
3950 | { |
3979 | set_locale (str); |
3951 | set_locale (str); |
3980 | pty.set_utf8_mode (enc_utf8); |
3952 | pty->set_utf8_mode (enc_utf8); |
3981 | init_xlocale (); |
3953 | init_xlocale (); |
3982 | } |
3954 | } |
3983 | break; |
3955 | break; |
3984 | |
3956 | |
3985 | case URxvt_view_up: |
3957 | case URxvt_view_up: |
… | |
… | |
4038 | return state; |
4010 | return state; |
4039 | } |
4011 | } |
4040 | |
4012 | |
4041 | /* we're not using priv _yet_ */ |
4013 | /* we're not using priv _yet_ */ |
4042 | void |
4014 | void |
4043 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4015 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4044 | { |
4016 | { |
4045 | unsigned int i, j; |
4017 | unsigned int i, j; |
4046 | int state; |
4018 | int state; |
4047 | |
4019 | |
4048 | static const struct |
4020 | static const struct |
… | |
… | |
4417 | rxvt_term::tt_write (const char *data, unsigned int len) |
4389 | rxvt_term::tt_write (const char *data, unsigned int len) |
4418 | { |
4390 | { |
4419 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4391 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4420 | return; |
4392 | return; |
4421 | |
4393 | |
4422 | if (pty.pty < 0) |
4394 | if (pty->pty < 0) |
4423 | return; |
4395 | return; |
4424 | |
4396 | |
4425 | if (v_buflen == 0) |
4397 | if (v_buflen == 0) |
4426 | { |
4398 | { |
4427 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4399 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4428 | |
4400 | |
4429 | if ((unsigned int)written == len) |
4401 | if ((unsigned int)written == len) |
4430 | return; |
4402 | return; |
4431 | |
4403 | |
4432 | data += written; |
4404 | data += written; |
… | |
… | |
4441 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4413 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4442 | } |
4414 | } |
4443 | |
4415 | |
4444 | void rxvt_term::pty_write () |
4416 | void rxvt_term::pty_write () |
4445 | { |
4417 | { |
4446 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4418 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4447 | |
4419 | |
4448 | if (written > 0) |
4420 | if (written > 0) |
4449 | { |
4421 | { |
4450 | v_buflen -= written; |
4422 | v_buflen -= written; |
4451 | |
4423 | |