… | |
… | |
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; |
… | |
… | |
1284 | tt_printf ("\033[M%c%c%c", |
1265 | tt_printf ("\033[M%c%c%c", |
1285 | (32 + button_number + key_state), |
1266 | (32 + button_number + key_state), |
1286 | (32 + x + 1), |
1267 | (32 + x + 1), |
1287 | (32 + y + 1)); |
1268 | (32 + y + 1)); |
1288 | } |
1269 | } |
1289 | |
|
|
1290 | #ifdef USING_W11LIB |
|
|
1291 | void |
|
|
1292 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1293 | { |
|
|
1294 | rxvt_t *r = rxvt_get_r (); |
|
|
1295 | |
|
|
1296 | x_cb (*ev); |
|
|
1297 | } |
|
|
1298 | #endif |
|
|
1299 | |
1270 | |
1300 | /*{{{ process an X event */ |
1271 | /*{{{ process an X event */ |
1301 | void |
1272 | void |
1302 | rxvt_term::x_cb (XEvent &ev) |
1273 | rxvt_term::x_cb (XEvent &ev) |
1303 | { |
1274 | { |
… | |
… | |
1408 | button_release (ev.xbutton); |
1379 | button_release (ev.xbutton); |
1409 | break; |
1380 | break; |
1410 | |
1381 | |
1411 | case ClientMessage: |
1382 | case ClientMessage: |
1412 | if (ev.xclient.format == 32 |
1383 | if (ev.xclient.format == 32 |
1413 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1384 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1414 | { |
1385 | { |
|
|
1386 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1387 | { |
|
|
1388 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1389 | { |
1415 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1390 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1391 | { |
|
|
1392 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1416 | destroy (); |
1393 | destroy (); |
|
|
1394 | } |
1417 | #if ENABLE_EWMH |
1395 | #if ENABLE_EWMH |
1418 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1396 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1419 | XSendEvent (disp, ev.xclient.window = display->root, |
1397 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1398 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | &ev); |
1399 | &ev); |
|
|
1400 | #endif |
|
|
1401 | } |
|
|
1402 | } |
|
|
1403 | #if ENABLE_XEMBED |
|
|
1404 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1405 | { |
|
|
1406 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1407 | focus_in (); |
|
|
1408 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1409 | focus_out (); |
|
|
1410 | } |
1422 | #endif |
1411 | #endif |
1423 | } |
1412 | } |
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; |
1413 | break; |
1460 | |
1414 | |
1461 | case MappingNotify: |
1415 | case MappingNotify: |
1462 | XRefreshKeyboardMapping (&ev.xmapping); |
1416 | XRefreshKeyboardMapping (&ev.xmapping); |
1463 | break; |
1417 | break; |
… | |
… | |
1505 | { |
1459 | { |
1506 | seen_resize = 1; |
1460 | seen_resize = 1; |
1507 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1461 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1508 | } |
1462 | } |
1509 | |
1463 | |
|
|
1464 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1465 | |
1510 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1466 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1511 | if (OPTION (Opt_transparent)) |
1467 | if (OPTION (Opt_transparent)) |
1512 | check_our_parents (); |
1468 | check_our_parents (); |
1513 | #endif |
1469 | #endif |
1514 | } |
1470 | } |
1515 | break; |
1471 | break; |
1516 | |
1472 | |
1517 | case PropertyNotify: |
1473 | case PropertyNotify: |
|
|
1474 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1518 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1475 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1519 | && ev.xproperty.state == PropertyNewValue) |
1476 | && ev.xproperty.state == PropertyNewValue) |
1520 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1477 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1521 | |
1478 | |
1522 | break; |
1479 | break; |
1523 | |
1480 | |
1524 | case SelectionClear: |
1481 | case SelectionClear: |
1525 | selection_clear (); |
1482 | selection_clear (); |
… | |
… | |
1714 | { |
1671 | { |
1715 | hidden_cursor = 0; |
1672 | hidden_cursor = 0; |
1716 | want_refresh = 1; |
1673 | want_refresh = 1; |
1717 | } |
1674 | } |
1718 | |
1675 | |
1719 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1676 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1720 | } |
1677 | } |
1721 | #endif |
1678 | #endif |
1722 | |
1679 | |
1723 | #if defined(POINTER_BLANK) |
1680 | #if defined(POINTER_BLANK) |
1724 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1681 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
… | |
… | |
1752 | XSetICFocus (Input_Context); |
1709 | XSetICFocus (Input_Context); |
1753 | } |
1710 | } |
1754 | #endif |
1711 | #endif |
1755 | #if CURSOR_BLINK |
1712 | #if CURSOR_BLINK |
1756 | if (OPTION (Opt_cursorBlink)) |
1713 | if (OPTION (Opt_cursorBlink)) |
1757 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1714 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1758 | #endif |
1715 | #endif |
1759 | #if OFF_FOCUS_FADING |
1716 | #if OFF_FOCUS_FADING |
1760 | if (rs[Rs_fade]) |
1717 | if (rs[Rs_fade]) |
1761 | { |
1718 | { |
1762 | pix_colors = pix_colors_focused; |
1719 | pix_colors = pix_colors_focused; |
… | |
… | |
1843 | /* |
1800 | /* |
1844 | * VT window processing of button press |
1801 | * VT window processing of button press |
1845 | */ |
1802 | */ |
1846 | if (ev.window == vt) |
1803 | if (ev.window == vt) |
1847 | { |
1804 | { |
|
|
1805 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1806 | return; |
|
|
1807 | |
1848 | #if ISO_14755 |
1808 | #if ISO_14755 |
1849 | // 5.4 |
1809 | // 5.4 |
1850 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1851 | { |
1811 | { |
1852 | iso14755_54 (ev.x, ev.y); |
1812 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1894 | else |
1854 | else |
1895 | { |
1855 | { |
1896 | if (ev.button != MEvent.button) |
1856 | if (ev.button != MEvent.button) |
1897 | MEvent.clicks = 0; |
1857 | MEvent.clicks = 0; |
1898 | |
1858 | |
1899 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1900 | switch (ev.button) |
1859 | switch (ev.button) |
1901 | { |
1860 | { |
1902 | case Button1: |
1861 | case Button1: |
1903 | /* allow meta + click to select rectangular areas */ |
1862 | /* allow meta + click to select rectangular areas */ |
1904 | /* should be done in screen.C */ |
1863 | /* should be done in screen.C */ |
1905 | #if ENABLE_FRILLS |
1864 | #if ENABLE_FRILLS |
1906 | selection.rect = !!(ev.state & ModMetaMask); |
1865 | selection.rect = !!(ev.state & ModMetaMask); |
1907 | #else |
1866 | #else |
1908 | selection.rect = false; |
1867 | selection.rect = false; |
1909 | #endif |
1868 | #endif |
1910 | |
1869 | |
1911 | /* allow shift+left click to extend selection */ |
1870 | /* allow shift+left click to extend selection */ |
1912 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1871 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1913 | { |
1872 | { |
1914 | if (MEvent.button == Button1 && clickintime) |
1873 | if (MEvent.button == Button1 && clickintime) |
1915 | selection_rotate (ev.x, ev.y); |
1874 | selection_rotate (ev.x, ev.y); |
1916 | else |
1875 | else |
1917 | selection_extend (ev.x, ev.y, 1); |
1876 | selection_extend (ev.x, ev.y, 1); |
1918 | } |
1877 | } |
1919 | else |
1878 | else |
1920 | { |
1879 | { |
1921 | if (MEvent.button == Button1 && clickintime) |
1880 | if (MEvent.button == Button1 && clickintime) |
1922 | MEvent.clicks++; |
1881 | MEvent.clicks++; |
1923 | else |
1882 | else |
1924 | MEvent.clicks = 1; |
1883 | MEvent.clicks = 1; |
1925 | |
1884 | |
1926 | selection_click (MEvent.clicks, ev.x, ev.y); |
1885 | selection_click (MEvent.clicks, ev.x, ev.y); |
1927 | } |
1886 | } |
1928 | |
1887 | |
1929 | MEvent.button = Button1; |
1888 | MEvent.button = Button1; |
1930 | break; |
1889 | break; |
1931 | |
1890 | |
1932 | case Button3: |
1891 | case Button3: |
1933 | if (MEvent.button == Button3 && clickintime) |
1892 | if (MEvent.button == Button3 && clickintime) |
1934 | selection_rotate (ev.x, ev.y); |
1893 | selection_rotate (ev.x, ev.y); |
1935 | else |
1894 | else |
1936 | selection_extend (ev.x, ev.y, 1); |
1895 | selection_extend (ev.x, ev.y, 1); |
1937 | |
1896 | |
1938 | MEvent.button = Button3; |
1897 | MEvent.button = Button3; |
1939 | break; |
1898 | break; |
1940 | } |
1899 | } |
1941 | } |
1900 | } |
1942 | |
1901 | |
1943 | MEvent.time = ev.time; |
1902 | MEvent.time = ev.time; |
1944 | return; |
1903 | return; |
1945 | } |
1904 | } |
1946 | |
1905 | |
… | |
… | |
2100 | |
2059 | |
2101 | if (scrollbar_isUpDn ()) |
2060 | if (scrollbar_isUpDn ()) |
2102 | { |
2061 | { |
2103 | scrollBar.setIdle (); |
2062 | scrollBar.setIdle (); |
2104 | scrollbar_show (0); |
2063 | scrollbar_show (0); |
2105 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2106 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2107 | #endif |
|
|
2108 | } |
2064 | } |
2109 | |
2065 | |
2110 | #ifdef SELECTION_SCROLLING |
2066 | #ifdef SELECTION_SCROLLING |
2111 | if (sel_scroll_ev.active) |
2067 | if (sel_scroll_ev.active) |
2112 | sel_scroll_ev.stop(); |
2068 | sel_scroll_ev.stop(); |
2113 | #endif |
2069 | #endif |
2114 | |
2070 | |
2115 | if (ev.window == vt) |
2071 | if (ev.window == vt) |
2116 | { |
2072 | { |
|
|
2073 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2074 | return; |
|
|
2075 | |
2117 | #if ISO_14755 |
2076 | #if ISO_14755 |
2118 | // 5.4 |
2077 | // 5.4 |
2119 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2078 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2120 | return; |
2079 | return; |
2121 | #endif |
2080 | #endif |
|
|
2081 | |
2122 | if (reportmode) |
2082 | if (reportmode) |
2123 | { |
2083 | { |
2124 | /* mouse report from vt window */ |
2084 | /* mouse report from vt window */ |
2125 | /* don't report release of wheel "buttons" */ |
2085 | /* don't report release of wheel "buttons" */ |
2126 | if (ev.button >= 4) |
2086 | if (ev.button >= 4) |
… | |
… | |
2150 | if (priv_modes & PrivMode_mouse_report |
2110 | if (priv_modes & PrivMode_mouse_report |
2151 | && bypass_keystate |
2111 | && bypass_keystate |
2152 | && ev.button == Button1 && MEvent.clicks <= 1) |
2112 | && ev.button == Button1 && MEvent.clicks <= 1) |
2153 | selection_extend (ev.x, ev.y, 0); |
2113 | selection_extend (ev.x, ev.y, 0); |
2154 | |
2114 | |
2155 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2156 | return; |
|
|
2157 | |
|
|
2158 | switch (ev.button) |
2115 | switch (ev.button) |
2159 | { |
2116 | { |
2160 | case Button1: |
2117 | case Button1: |
2161 | case Button3: |
2118 | case Button3: |
2162 | selection_make (ev.time); |
2119 | selection_make (ev.time); |
2163 | break; |
2120 | break; |
|
|
2121 | |
2164 | case Button2: |
2122 | case Button2: |
2165 | selection_request (ev.time, ev.x, ev.y); |
2123 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2124 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2166 | break; |
2125 | break; |
|
|
2126 | |
2167 | #ifdef MOUSE_WHEEL |
2127 | #ifdef MOUSE_WHEEL |
2168 | case Button4: |
2128 | case Button4: |
2169 | case Button5: |
2129 | case Button5: |
2170 | { |
2130 | { |
2171 | int i; |
2131 | int i; |
… | |
… | |
2649 | am_transparent = 0; |
2609 | am_transparent = 0; |
2650 | /* XXX: also turn off Opt_transparent? */ |
2610 | /* XXX: also turn off Opt_transparent? */ |
2651 | } |
2611 | } |
2652 | else |
2612 | else |
2653 | { |
2613 | { |
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++) |
2614 | for (n = 0; n < (unsigned int)i; n++) |
2660 | { |
2615 | { |
2661 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2616 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2662 | XClearWindow (disp, parent[n]); |
2617 | XClearWindow (disp, parent[n]); |
2663 | } |
2618 | } |
… | |
… | |
2798 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2753 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2799 | refresh_limit++; |
2754 | refresh_limit++; |
2800 | else |
2755 | else |
2801 | { |
2756 | { |
2802 | flag = true; |
2757 | flag = true; |
2803 | scr_refresh (refresh_type); |
2758 | scr_refresh (); |
2804 | want_refresh = 1; |
2759 | want_refresh = 1; |
2805 | } |
2760 | } |
2806 | } |
2761 | } |
2807 | |
2762 | |
2808 | } |
2763 | } |
… | |
… | |
2826 | return flag; |
2781 | return flag; |
2827 | } |
2782 | } |
2828 | |
2783 | |
2829 | // read the next character |
2784 | // read the next character |
2830 | wchar_t |
2785 | wchar_t |
2831 | rxvt_term::next_char () |
2786 | rxvt_term::next_char () NOTHROW |
2832 | { |
2787 | { |
2833 | while (cmdbuf_ptr < cmdbuf_endp) |
2788 | while (cmdbuf_ptr < cmdbuf_endp) |
2834 | { |
2789 | { |
2835 | // assume 7-bit to be ascii ALWAYS |
2790 | // assume 7-bit to be ascii ALWAYS |
2836 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2791 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2857 | return NOCHAR; |
2812 | return NOCHAR; |
2858 | } |
2813 | } |
2859 | |
2814 | |
2860 | // read the next octet |
2815 | // read the next octet |
2861 | uint32_t |
2816 | uint32_t |
2862 | rxvt_term::next_octet () |
2817 | rxvt_term::next_octet () NOTHROW |
2863 | { |
2818 | { |
2864 | return cmdbuf_ptr < cmdbuf_endp |
2819 | return cmdbuf_ptr < cmdbuf_endp |
2865 | ? (unsigned char)*cmdbuf_ptr++ |
2820 | ? (unsigned char)*cmdbuf_ptr++ |
2866 | : NOCHAR; |
2821 | : NOCHAR; |
2867 | } |
2822 | } |
|
|
2823 | |
|
|
2824 | static class out_of_input out_of_input; |
2868 | |
2825 | |
2869 | /* rxvt_cmd_getc () - Return next input character */ |
2826 | /* rxvt_cmd_getc () - Return next input character */ |
2870 | /* |
2827 | /* |
2871 | * Return the next input character after first passing any keyboard input |
2828 | * Return the next input character after first passing any keyboard input |
2872 | * to the command. |
2829 | * to the command. |
2873 | */ |
2830 | */ |
2874 | wchar_t |
2831 | wchar_t |
2875 | rxvt_term::cmd_getc () |
2832 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2876 | { |
2833 | { |
2877 | wchar_t c = next_char (); |
2834 | wchar_t c = next_char (); |
2878 | |
2835 | |
2879 | if (c == NOCHAR) |
2836 | if (c == NOCHAR) |
2880 | throw out_of_input; |
2837 | throw out_of_input; |
2881 | |
2838 | |
2882 | return c; |
2839 | return c; |
2883 | } |
2840 | } |
2884 | |
2841 | |
2885 | uint32_t |
2842 | uint32_t |
2886 | rxvt_term::cmd_get8 () |
2843 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2887 | { |
2844 | { |
2888 | uint32_t c = next_octet (); |
2845 | uint32_t c = next_octet (); |
2889 | |
2846 | |
2890 | if (c == NOCHAR) |
2847 | if (c == NOCHAR) |
2891 | throw out_of_input; |
2848 | throw out_of_input; |
… | |
… | |
3312 | ndef = get_byte_array_bit (csi_defaults, i); |
3269 | ndef = get_byte_array_bit (csi_defaults, i); |
3313 | for (p = 0; p < nargs; p++) |
3270 | for (p = 0; p < nargs; p++) |
3314 | if (arg[p] == -1) |
3271 | if (arg[p] == -1) |
3315 | arg[p] = ndef; |
3272 | arg[p] = ndef; |
3316 | |
3273 | |
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 | /* |
3274 | /* |
3325 | * private mode handling |
3275 | * private mode handling |
3326 | */ |
3276 | */ |
3327 | if (priv) |
3277 | if (priv) |
3328 | { |
3278 | { |
3329 | switch (priv) |
3279 | switch (priv) |
3330 | { |
3280 | { |
3331 | case '>': |
3281 | case '>': |
3332 | if (ch == CSI_DA) /* secondary device attributes */ |
3282 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3283 | { |
|
|
3284 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3285 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3286 | // |
|
|
3287 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3288 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3289 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3290 | // |
3333 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3291 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3292 | } |
3334 | break; |
3293 | break; |
3335 | case '?': |
3294 | case '?': |
3336 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3295 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3337 | process_terminal_mode (ch, priv, nargs, arg); |
3296 | process_terminal_mode (ch, priv, nargs, arg); |
3338 | break; |
3297 | break; |
… | |
… | |
3770 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3729 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3771 | */ |
3730 | */ |
3772 | void |
3731 | void |
3773 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3732 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3774 | { |
3733 | { |
3775 | int changed = 0; |
|
|
3776 | int color; |
3734 | int color; |
3777 | char *buf, *name; |
3735 | char *buf, *name; |
3778 | bool query = str[0] == '?' && !str[1]; |
3736 | bool query = str[0] == '?' && !str[1]; |
3779 | int saveop = op; |
3737 | int saveop = op; |
3780 | dDisp; |
3738 | dDisp; |
… | |
… | |
3896 | want_full_refresh = want_refresh = 1; |
3854 | want_full_refresh = want_refresh = 1; |
3897 | break; |
3855 | break; |
3898 | #endif |
3856 | #endif |
3899 | |
3857 | |
3900 | case Rxvt_Pixmap: |
3858 | case Rxvt_Pixmap: |
|
|
3859 | { |
3901 | if (*str != ';') |
3860 | if (*str != ';') |
3902 | { |
3861 | { |
3903 | #if XPM_BACKGROUND |
3862 | #if XPM_BACKGROUND |
3904 | scale_pixmap (""); /* reset to default scaling */ |
3863 | scale_pixmap (""); /* reset to default scaling */ |
3905 | set_bgPixmap (str); /* change pixmap */ |
3864 | set_bgPixmap (str); /* change pixmap */ |
3906 | scr_touch (true); |
3865 | scr_touch (true); |
3907 | #endif |
3866 | #endif |
3908 | } |
3867 | } |
3909 | |
3868 | |
|
|
3869 | int changed = 0; |
|
|
3870 | |
3910 | while ((str = strchr (str, ';')) != NULL) |
3871 | while ((str = strchr (str, ';')) != NULL) |
3911 | { |
3872 | { |
3912 | str++; |
3873 | str++; |
3913 | #if XPM_BACKGROUND |
3874 | #if XPM_BACKGROUND |
3914 | changed += scale_pixmap (str); |
3875 | changed += scale_pixmap (str); |
3915 | #endif |
3876 | #endif |
3916 | } |
3877 | } |
3917 | |
3878 | |
3918 | if (changed) |
3879 | if (changed) |
3919 | { |
3880 | { |
3920 | #ifdef XPM_BACKGROUND |
3881 | #ifdef XPM_BACKGROUND |
3921 | resize_pixmap (); |
3882 | resize_pixmap (); |
3922 | scr_touch (true); |
3883 | scr_touch (true); |
3923 | #endif |
3884 | #endif |
3924 | } |
3885 | } |
|
|
3886 | } |
3925 | break; |
3887 | break; |
3926 | |
3888 | |
3927 | case Rxvt_restoreFG: |
3889 | case Rxvt_restoreFG: |
3928 | set_window_color (Color_fg, str); |
3890 | set_window_color (Color_fg, str); |
3929 | break; |
3891 | break; |
… | |
… | |
3975 | if (query) |
3937 | if (query) |
3976 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3938 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3977 | else |
3939 | else |
3978 | { |
3940 | { |
3979 | set_locale (str); |
3941 | set_locale (str); |
3980 | pty.set_utf8_mode (enc_utf8); |
3942 | pty->set_utf8_mode (enc_utf8); |
3981 | init_xlocale (); |
3943 | init_xlocale (); |
3982 | } |
3944 | } |
3983 | break; |
3945 | break; |
3984 | |
3946 | |
3985 | case URxvt_view_up: |
3947 | case URxvt_view_up: |
… | |
… | |
4038 | return state; |
4000 | return state; |
4039 | } |
4001 | } |
4040 | |
4002 | |
4041 | /* we're not using priv _yet_ */ |
4003 | /* we're not using priv _yet_ */ |
4042 | void |
4004 | void |
4043 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4005 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4044 | { |
4006 | { |
4045 | unsigned int i, j; |
4007 | unsigned int i, j; |
4046 | int state; |
4008 | int state; |
4047 | |
4009 | |
4048 | static const struct |
4010 | static const struct |
… | |
… | |
4417 | rxvt_term::tt_write (const char *data, unsigned int len) |
4379 | rxvt_term::tt_write (const char *data, unsigned int len) |
4418 | { |
4380 | { |
4419 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4381 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4420 | return; |
4382 | return; |
4421 | |
4383 | |
4422 | if (pty.pty < 0) |
4384 | if (pty->pty < 0) |
4423 | return; |
4385 | return; |
4424 | |
4386 | |
4425 | if (v_buflen == 0) |
4387 | if (v_buflen == 0) |
4426 | { |
4388 | { |
4427 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4389 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4428 | |
4390 | |
4429 | if ((unsigned int)written == len) |
4391 | if ((unsigned int)written == len) |
4430 | return; |
4392 | return; |
4431 | |
4393 | |
4432 | data += written; |
4394 | data += written; |
… | |
… | |
4441 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4403 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4442 | } |
4404 | } |
4443 | |
4405 | |
4444 | void rxvt_term::pty_write () |
4406 | void rxvt_term::pty_write () |
4445 | { |
4407 | { |
4446 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4408 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4447 | |
4409 | |
4448 | if (written > 0) |
4410 | if (written > 0) |
4449 | { |
4411 | { |
4450 | v_buflen -= written; |
4412 | v_buflen -= written; |
4451 | |
4413 | |