ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.235 by root, Wed Jan 4 20:43:37 2006 UTC vs.
Revision 1.264 by root, Mon Jan 16 06:37:51 2006 UTC

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.
147 || !IN_RANGE_EXC (y, 0, nrow)) 147 || !IN_RANGE_EXC (y, 0, nrow))
148 return; 148 return;
149 149
150 for (;;) 150 for (;;)
151 { 151 {
152 const line_t &l = ROW(y - view_start); 152 const line_t &l = ROW(y + view_start);
153 153
154 text_t t = l.t[x]; 154 text_t t = l.t[x];
155 155
156 if (t != NOCHAR || !x) 156 if (t != NOCHAR || !x)
157 { 157 {
443 scr_move_to (0, 1); 443 scr_move_to (0, 1);
444 return; 444 return;
445 } 445 }
446 else if (keysym == XK_End) 446 else if (keysym == XK_End)
447 { 447 {
448 scr_move_to (1, 0); 448 scr_move_to (1, 1);
449 return; 449 return;
450 } 450 }
451 } 451 }
452#endif 452#endif
453 } 453 }
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_INT, keysym, 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)
967 } 970 }
968#endif 971#endif
969 972
970 if (want_refresh) 973 if (want_refresh)
971 { 974 {
975 if (SHOULD_INVOKE (HOOK_LINE_UPDATE))
976 {
977 int row = view_start;
978 int end_row = row + nrow;
979
980 while (row > top_row && ROW (row - 1).is_longer ())
981 --row;
982
983 do
984 {
985 int start_row = row;
986 line_t *l;
987
988 do
989 {
990 l = &ROW (row++);
991
992 if (!(l->f & LINE_FILTERED))
993 {
994 // line not filtered, mark it as filtered
995 l->f |= LINE_FILTERED;
996 while (l->is_longer ())
997 {
998 l = &ROW (row++);
999 l->f |= LINE_FILTERED;
1000 }
1001
1002 // and filter it
1003 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END));
1004
1005 break;
1006 }
1007 }
1008 while (l->is_longer () && row < end_row);
1009 }
1010 while (row < end_row);
1011 }
1012
972 scr_refresh (refresh_type); 1013 scr_refresh (refresh_type);
973 scrollbar_show (1); 1014 scrollbar_show (1);
974#ifdef USE_XIM 1015#ifdef USE_XIM
975 IMSendSpot (); 1016 IMSendSpot ();
976#endif 1017#endif
980} 1021}
981 1022
982void 1023void
983rxvt_term::check_cb (check_watcher &w) 1024rxvt_term::check_cb (check_watcher &w)
984{ 1025{
985 SET_R (this); 1026 make_current ();
986 SET_LOCALE (locale);
987 1027
988 display->flush (); 1028 display->flush ();
989 1029
990 if (want_refresh && !flush_ev.active) 1030 if (want_refresh && !flush_ev.active)
991 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally 1031 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
992} 1032}
993 1033
994void 1034void
995rxvt_term::flush_cb (time_watcher &w) 1035rxvt_term::flush_cb (time_watcher &w)
996{ 1036{
997 SET_R (this); 1037 make_current ();
998 SET_LOCALE (locale);
999 1038
1000 refresh_limit = 1; 1039 refresh_limit = 1;
1001 refresh_count = 0; 1040 refresh_count = 0;
1002 flush (); 1041 flush ();
1003} 1042}
1060{ 1099{
1061 if (mouse_slip_wheel_speed == 0 1100 if (mouse_slip_wheel_speed == 0
1062 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) 1101 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1063 : scr_page (UP, mouse_slip_wheel_speed)) 1102 : scr_page (UP, mouse_slip_wheel_speed))
1064 { 1103 {
1065 if (view_start == nsaved || 1104 if (view_start == top_row || view_start == 0)
1066 view_start == 0)
1067 mouse_slip_wheel_speed = 0; 1105 mouse_slip_wheel_speed = 0;
1068 1106
1069 refresh_type |= SMOOTH_REFRESH; 1107 refresh_type |= SMOOTH_REFRESH;
1070 want_refresh = 1; 1108 want_refresh = 1;
1071 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1109 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1132} 1170}
1133 1171
1134void 1172void
1135rxvt_term::pty_cb (io_watcher &w, short revents) 1173rxvt_term::pty_cb (io_watcher &w, short revents)
1136{ 1174{
1137 SET_R (this); 1175 make_current ();
1138 SET_LOCALE (locale);
1139 1176
1140 if (revents & EVENT_READ) 1177 if (revents & EVENT_READ)
1141 // loop, but don't allow a single term to monopolize us 1178 // loop, but don't allow a single term to monopolize us
1142 while (pty_fill ()) 1179 while (pty_fill ())
1143 if (cmd_parse ()) 1180 if (cmd_parse ())
1163 1200
1164#ifdef POINTER_BLANK 1201#ifdef POINTER_BLANK
1165void 1202void
1166rxvt_term::pointer_blank () 1203rxvt_term::pointer_blank ()
1167{ 1204{
1168 if (! OPTION (Opt_pointerBlank)) 1205 if (!OPTION (Opt_pointerBlank))
1169 return; 1206 return;
1170 1207
1171 XDefineCursor (display->display, vt, display->blank_cursor); 1208 XDefineCursor (display->display, vt, display->blank_cursor);
1172 XFlush (display->display); 1209 XFlush (display->display);
1173 1210
1175} 1212}
1176 1213
1177void 1214void
1178rxvt_term::pointer_cb (time_watcher &w) 1215rxvt_term::pointer_cb (time_watcher &w)
1179{ 1216{
1180 SET_R (this); 1217 make_current ();
1181 SET_LOCALE (locale);
1182 1218
1183 pointer_blank (); 1219 pointer_blank ();
1184} 1220}
1185#endif 1221#endif
1186 1222
1265 1301
1266/*{{{ process an X event */ 1302/*{{{ process an X event */
1267void 1303void
1268rxvt_term::x_cb (XEvent &ev) 1304rxvt_term::x_cb (XEvent &ev)
1269{ 1305{
1306 make_current ();
1307
1270 dDisp; 1308 dDisp;
1271 1309
1272 SET_R (this); 1310 if (ev.xany.window == vt
1273 SET_LOCALE (locale); 1311 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1312 return;
1274 1313
1275#if defined(CURSOR_BLINK) 1314 // for XQueryPointer
1276 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1277 {
1278 if (hidden_cursor)
1279 {
1280 hidden_cursor = 0;
1281 want_refresh = 1;
1282 }
1283
1284 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1285 }
1286#endif
1287
1288#if defined(POINTER_BLANK)
1289 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1290 {
1291 if (ev.type == MotionNotify
1292 || ev.type == ButtonPress
1293 || ev.type == ButtonRelease)
1294 if (hidden_pointer)
1295 pointer_unblank ();
1296
1297 if (ev.type == KeyPress && hidden_pointer == 0)
1298 pointer_blank ();
1299 }
1300#endif
1301
1302 Window unused_root, unused_child; 1315 Window unused_root, unused_child;
1303 int unused_root_x, unused_root_y; 1316 int unused_root_x, unused_root_y;
1304 unsigned int unused_mask; 1317 unsigned int unused_mask;
1305 1318
1306 switch (ev.type) 1319 switch (ev.type)
1313 1326
1314 break; 1327 break;
1315 1328
1316 case KeyRelease: 1329 case KeyRelease:
1317 { 1330 {
1318#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 1331#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1319 KeySym ks; 1332 KeySym keysym;
1320 1333
1321 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ 1334 keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1322#endif 1335#endif
1323 1336
1324#if ENABLE_FRILLS || ISO_14755 1337#if ENABLE_FRILLS || ISO_14755
1325 // ISO 14755 support 1338 // ISO 14755 support
1326 if (iso14755buf) 1339 if (iso14755buf)
1331# endif 1344# endif
1332# if ISO_14755 1345# if ISO_14755
1333 // iso14755 part 5.2 handling: release time 1346 // iso14755 part 5.2 handling: release time
1334 // first: controls 1347 // first: controls
1335 if ((ev.xkey.state & ControlMask) 1348 if ((ev.xkey.state & ControlMask)
1336 && ((ks >= 0x40 && ks <= 0x5f) 1349 && ((keysym >= 0x40 && keysym <= 0x5f)
1337 || (ks >= 0x61 && ks <= 0x7f))) 1350 || (keysym >= 0x61 && keysym <= 0x7f)))
1338 { 1351 {
1339 iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); 1352 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1340 commit_iso14755 (); 1353 commit_iso14755 ();
1341 return; // case-break; 1354 goto skip_switch;
1342 } 1355 }
1343 1356
1344 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 1357 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1345 if (i[0] == ks) 1358 if (i[0] == keysym)
1346 { 1359 {
1347 iso14755buf = ISO_14755_51 | i[1]; 1360 iso14755buf = ISO_14755_51 | i[1];
1348 commit_iso14755 (); 1361 commit_iso14755 ();
1349 return; // case-break; 1362 goto skip_switch;
1350 } 1363 }
1351 1364
1352 scr_bell (); 1365 scr_bell ();
1353# endif 1366# endif
1354 iso14755buf = 0; 1367 iso14755buf = 0;
1373 else 1386 else
1374 iso14755buf = 0; 1387 iso14755buf = 0;
1375 } 1388 }
1376#endif 1389#endif
1377 1390
1391 if (ev.xany.window == vt
1392 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1393 break;
1394
1378#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1395#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1379 if (!(ev.xkey.state & ControlMask)) 1396 if (!(ev.xkey.state & ControlMask))
1380 slip_wheel_ev.stop (); 1397 slip_wheel_ev.stop ();
1381 else if (ks == XK_Control_L || ks == XK_Control_R) 1398 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1382 mouse_slip_wheel_speed = 0; 1399 mouse_slip_wheel_speed = 0;
1383#endif 1400#endif
1384 break; 1401 break;
1385 } 1402 }
1386 1403
1516 1533
1517 case SelectionRequest: 1534 case SelectionRequest:
1518 selection_send (ev.xselectionrequest); 1535 selection_send (ev.xselectionrequest);
1519 break; 1536 break;
1520 1537
1538 case MapNotify:
1539 mapped = 1;
1540#ifdef TEXT_BLINK
1541 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1542#endif
1543 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1544 break;
1545
1521 case UnmapNotify: 1546 case UnmapNotify:
1522 mapped = 0; 1547 mapped = 0;
1523#ifdef TEXT_BLINK 1548#ifdef TEXT_BLINK
1524 text_blink_ev.stop (); 1549 text_blink_ev.stop ();
1525#endif 1550#endif
1526 break; 1551 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1527
1528 case MapNotify:
1529 mapped = 1;
1530#ifdef TEXT_BLINK
1531 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1532#endif
1533 break; 1552 break;
1534 1553
1535#ifdef TRANSPARENT 1554#ifdef TRANSPARENT
1536 case ReparentNotify: 1555 case ReparentNotify:
1537 rootwin_cb (ev); 1556 rootwin_cb (ev);
1551 1570
1552 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1571 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1553 scr_expose (ev.xexpose.x, ev.xexpose.y, 1572 scr_expose (ev.xexpose.x, ev.xexpose.y,
1554 ev.xexpose.width, ev.xexpose.height, False); 1573 ev.xexpose.width, ev.xexpose.height, False);
1555 1574
1556 scr_refresh (refresh_type); 1575 want_refresh = 1;
1557 } 1576 }
1558 else 1577 else
1559 { 1578 {
1560 XEvent unused_event; 1579 XEvent unused_event;
1561 1580
1596 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1615 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1597 break; 1616 break;
1598 1617
1599 if (ev.xany.window == vt) 1618 if (ev.xany.window == vt)
1600 { 1619 {
1620 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1621 ; // nop
1601 if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1622 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1602 { 1623 {
1603 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1624 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1604 ; 1625 ;
1605 1626
1606 XQueryPointer (disp, vt, 1627 XQueryPointer (disp, vt,
1686 &unused_root_x, &unused_root_y, 1707 &unused_root_x, &unused_root_y,
1687 &ev.xbutton.x, &ev.xbutton.y, 1708 &ev.xbutton.x, &ev.xbutton.y,
1688 &unused_mask); 1709 &unused_mask);
1689 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1710 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1690 scrollbar_size ()); 1711 scrollbar_size ());
1691 scr_refresh (refresh_type); 1712 want_refresh = 1;
1692 refresh_limit = 0; 1713 refresh_limit = 0;
1693 scrollbar_show (1); 1714 scrollbar_show (1);
1694 } 1715 }
1695 break; 1716 break;
1696 } 1717 }
1718
1719skip_switch: ;
1720
1721#if defined(CURSOR_BLINK)
1722 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1723 {
1724 if (hidden_cursor)
1725 {
1726 hidden_cursor = 0;
1727 want_refresh = 1;
1728 }
1729
1730 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1731 }
1732#endif
1733
1734#if defined(POINTER_BLANK)
1735 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1736 {
1737 if (ev.type == MotionNotify
1738 || ev.type == ButtonPress
1739 || ev.type == ButtonRelease)
1740 if (hidden_pointer)
1741 pointer_unblank ();
1742
1743 if (ev.type == KeyPress && hidden_pointer == 0)
1744 pointer_blank ();
1745 }
1746#endif
1697} 1747}
1698 1748
1699void 1749void
1700rxvt_term::focus_in () 1750rxvt_term::focus_in ()
1701{ 1751{
1702 if (!focus) 1752 if (!focus)
1703 { 1753 {
1704 focus = 1; 1754 focus = 1;
1705 want_refresh = 1; 1755 want_refresh = 1;
1706 1756
1707 PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1757 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1708 1758
1709#if USE_XIM 1759#if USE_XIM
1710 if (Input_Context != NULL) 1760 if (Input_Context != NULL)
1711 { 1761 {
1712 IMSetStatusPosition (); 1762 IMSetStatusPosition ();
1733 if (focus) 1783 if (focus)
1734 { 1784 {
1735 focus = 0; 1785 focus = 0;
1736 want_refresh = 1; 1786 want_refresh = 1;
1737 1787
1738 PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1788 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1739 1789
1740#if ENABLE_FRILLS || ISO_14755 1790#if ENABLE_FRILLS || ISO_14755
1741 if (iso14755buf) 1791 if (iso14755buf)
1742 { 1792 {
1743 iso14755buf = 0; 1793 iso14755buf = 0;
1767 1817
1768#if TRANSPARENT 1818#if TRANSPARENT
1769void 1819void
1770rxvt_term::rootwin_cb (XEvent &ev) 1820rxvt_term::rootwin_cb (XEvent &ev)
1771{ 1821{
1772 SET_R (this); 1822 make_current ();
1773 SET_LOCALE (locale);
1774 1823
1775 switch (ev.type) 1824 switch (ev.type)
1776 { 1825 {
1777 case PropertyNotify: 1826 case PropertyNotify:
1778 /* 1827 /*
1826#ifdef MOUSE_REPORT_DOUBLECLICK 1875#ifdef MOUSE_REPORT_DOUBLECLICK
1827 if (ev.button == MEvent.button && clickintime) 1876 if (ev.button == MEvent.button && clickintime)
1828 { 1877 {
1829 /* same button, within alloted time */ 1878 /* same button, within alloted time */
1830 MEvent.clicks++; 1879 MEvent.clicks++;
1880
1831 if (MEvent.clicks > 1) 1881 if (MEvent.clicks > 1)
1832 { 1882 {
1833 /* only report double clicks */ 1883 /* only report double clicks */
1834 MEvent.clicks = 2; 1884 MEvent.clicks = 2;
1835 mouse_report (ev); 1885 mouse_report (ev);
1855 else 1905 else
1856 { 1906 {
1857 if (ev.button != MEvent.button) 1907 if (ev.button != MEvent.button)
1858 MEvent.clicks = 0; 1908 MEvent.clicks = 0;
1859 1909
1860 if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) 1910 if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END)))
1861 switch (ev.button) 1911 switch (ev.button)
1862 { 1912 {
1863 case Button1: 1913 case Button1:
1864 /* allow meta + click to select rectangular areas */ 1914 /* allow meta + click to select rectangular areas */
1865 /* should be done in screen.C */ 1915 /* should be done in screen.C */
1868#else 1918#else
1869 selection.rect = false; 1919 selection.rect = false;
1870#endif 1920#endif
1871 1921
1872 /* allow shift+left click to extend selection */ 1922 /* allow shift+left click to extend selection */
1873 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1923 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1874 { 1924 {
1875 if (MEvent.button == Button1 && clickintime) 1925 if (MEvent.button == Button1 && clickintime)
1876 selection_rotate (ev.x, ev.y); 1926 selection_rotate (ev.x, ev.y);
1877 else 1927 else
1878 selection_extend (ev.x, ev.y, 1); 1928 selection_extend (ev.x, ev.y, 1);
2043 } 2093 }
2044 2094
2045 break; 2095 break;
2046 } 2096 }
2047 } 2097 }
2098
2048 return; 2099 return;
2049 } 2100 }
2101
2050#if MENUBAR 2102#if MENUBAR
2051 /* 2103 /*
2052 * Menubar window processing of button press 2104 * Menubar window processing of button press
2053 */ 2105 */
2054 if (isMenuBarWindow (ev.window)) 2106 if (isMenuBarWindow (ev.window))
2117 if (priv_modes & PrivMode_mouse_report 2169 if (priv_modes & PrivMode_mouse_report
2118 && bypass_keystate 2170 && bypass_keystate
2119 && ev.button == Button1 && MEvent.clicks <= 1) 2171 && ev.button == Button1 && MEvent.clicks <= 1)
2120 selection_extend (ev.x, ev.y, 0); 2172 selection_extend (ev.x, ev.y, 0);
2121 2173
2174 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2175 return;
2176
2122 switch (ev.button) 2177 switch (ev.button)
2123 { 2178 {
2124 case Button1: 2179 case Button1:
2125 case Button3: 2180 case Button3:
2126 selection_make (ev.time); 2181 selection_make (ev.time);
2157 slip_wheel_ev.start (); 2212 slip_wheel_ev.start ();
2158 } 2213 }
2159 else 2214 else
2160 { 2215 {
2161# endif 2216# endif
2162# ifdef JUMP_MOUSE_WHEEL
2163 scr_page (v, i); 2217 scr_page (v, i);
2164 scr_refresh (SMOOTH_REFRESH);
2165 scrollbar_show (1); 2218 scrollbar_show (1);
2166# else
2167 while (i--)
2168 {
2169 scr_page (v, 1);
2170 scr_refresh (SMOOTH_REFRESH);
2171 scrollbar_show (1);
2172 }
2173# endif
2174# ifdef MOUSE_SLIP_WHEELING 2219# ifdef MOUSE_SLIP_WHEELING
2175 } 2220 }
2176#endif 2221# endif
2177 } 2222 }
2178 break; 2223 break;
2179#endif 2224#endif
2180 } 2225 }
2181 } 2226 }
2670 2715
2671bool 2716bool
2672rxvt_term::cmd_parse () 2717rxvt_term::cmd_parse ()
2673{ 2718{
2674 bool flag = false; 2719 bool flag = false;
2675 unicode_t ch = NOCHAR; 2720 wchar_t ch = NOCHAR;
2676 char *seq_begin; // remember start of esc-sequence here 2721 char *seq_begin; // remember start of esc-sequence here
2677 2722
2678 for (;;) 2723 for (;;)
2679 { 2724 {
2680 if (ch == NOCHAR) 2725 if (ch == NOCHAR)
2681 { 2726 {
2682 seq_begin = cmdbuf_ptr; 2727 seq_begin = cmdbuf_ptr;
2683 ch = next_char (); 2728 ch = next_char ();
2684 }
2685 2729
2686 if (ch == NOCHAR) // TODO: improve 2730 if (ch == NOCHAR)
2687 break; 2731 break;
2732 }
2688 2733
2689 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2734 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)
2690 { 2735 {
2691 if (!seen_input) 2736 if (!seen_input)
2692 { 2737 {
2701 if (seen_resize && cmd_pid) 2746 if (seen_resize && cmd_pid)
2702 kill (-cmd_pid, SIGWINCH); 2747 kill (-cmd_pid, SIGWINCH);
2703 } 2748 }
2704 2749
2705 /* Read a text string from the input buffer */ 2750 /* Read a text string from the input buffer */
2706 unicode_t buf[UBUFSIZ]; 2751 wchar_t buf[UBUFSIZ];
2707 bool refreshnow = false; 2752 bool refreshnow = false;
2708 int nlines = 0; 2753 int nlines = 0;
2709 unicode_t *str = buf; 2754 wchar_t *str = buf;
2710 unicode_t *eol = str + min (ncol, UBUFSIZ); 2755 wchar_t *eol = str + min (ncol, UBUFSIZ);
2711 2756
2712 for (;;) 2757 for (;;)
2713 { 2758 {
2714 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2759 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2715 break; 2760 break;
2733 } 2778 }
2734 2779
2735 // scr_add_lines only works for nlines <= nrow - 1. 2780 // scr_add_lines only works for nlines <= nrow - 1.
2736 if (nlines >= nrow - 1) 2781 if (nlines >= nrow - 1)
2737 { 2782 {
2783 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))
2738 scr_add_lines (buf, nlines, str - buf); 2784 scr_add_lines (buf, str - buf, nlines);
2785
2739 nlines = 0; 2786 nlines = 0;
2740 str = buf; 2787 str = buf;
2741 eol = str + min (ncol, UBUFSIZ); 2788 eol = str + min (ncol, UBUFSIZ);
2742 } 2789 }
2743 2790
2756 2803
2757 seq_begin = cmdbuf_ptr; 2804 seq_begin = cmdbuf_ptr;
2758 ch = next_char (); 2805 ch = next_char ();
2759 } 2806 }
2760 2807
2808 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))
2761 scr_add_lines (buf, nlines, str - buf); 2809 scr_add_lines (buf, str - buf, nlines);
2762 2810
2763 /* 2811 /*
2764 * If there have been a lot of new lines, then update the screen 2812 * If there have been a lot of new lines, then update the screen
2765 * What the heck I'll cheat and only refresh less than every page-full. 2813 * What the heck I'll cheat and only refresh less than every page-full.
2766 * the number of pages between refreshes is refresh_limit, which 2814 * the number of pages between refreshes is refresh_limit, which
2772 refresh_limit++; 2820 refresh_limit++;
2773 else 2821 else
2774 { 2822 {
2775 flag = true; 2823 flag = true;
2776 scr_refresh (refresh_type); 2824 scr_refresh (refresh_type);
2777 flush_ev.stop (); 2825 want_refresh = 1;
2778 } 2826 }
2779 } 2827 }
2780 2828
2781 } 2829 }
2782 else 2830 else
2797 } 2845 }
2798 2846
2799 return flag; 2847 return flag;
2800} 2848}
2801 2849
2802// read the next octet
2803unicode_t
2804rxvt_term::next_octet ()
2805{
2806 return cmdbuf_ptr < cmdbuf_endp
2807 ? *cmdbuf_ptr++
2808 : NOCHAR;
2809}
2810
2811// read the next character 2850// read the next character
2812unicode_t 2851wchar_t
2813rxvt_term::next_char () 2852rxvt_term::next_char ()
2814{ 2853{
2815 while (cmdbuf_ptr < cmdbuf_endp) 2854 while (cmdbuf_ptr < cmdbuf_endp)
2816 { 2855 {
2817 // assume 7-bit to be ascii ALWAYS 2856 // assume 7-bit to be ascii ALWAYS
2827 cmdbuf_ptr = cmdbuf_endp; 2866 cmdbuf_ptr = cmdbuf_endp;
2828 break; 2867 break;
2829 } 2868 }
2830 2869
2831 if (len == (size_t)-1) 2870 if (len == (size_t)-1)
2832 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2871 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2833 2872
2834 // assume wchar == unicode 2873 // assume wchar == unicode
2835 cmdbuf_ptr += len; 2874 cmdbuf_ptr += len;
2836 return wc & UNICODE_MASK; 2875 return wc & UNICODE_MASK;
2837 } 2876 }
2838 2877
2839 return NOCHAR; 2878 return NOCHAR;
2879}
2880
2881// read the next octet
2882uint32_t
2883rxvt_term::next_octet ()
2884{
2885 return cmdbuf_ptr < cmdbuf_endp
2886 ? (unsigned char)*cmdbuf_ptr++
2887 : NOCHAR;
2840} 2888}
2841 2889
2842/* rxvt_cmd_getc () - Return next input character */ 2890/* rxvt_cmd_getc () - Return next input character */
2843/* 2891/*
2844 * Return the next input character after first passing any keyboard input 2892 * Return the next input character after first passing any keyboard input
2845 * to the command. 2893 * to the command.
2846 */ 2894 */
2847unicode_t 2895wchar_t
2848rxvt_term::cmd_getc () 2896rxvt_term::cmd_getc ()
2849{ 2897{
2850 unicode_t c = next_char (); 2898 wchar_t c = next_char ();
2851 2899
2852 if (c == NOCHAR) 2900 if (c == NOCHAR)
2853 throw out_of_input; 2901 throw out_of_input;
2854 2902
2855 return c; 2903 return c;
2856} 2904}
2857 2905
2858unicode_t 2906uint32_t
2859rxvt_term::cmd_get8 () 2907rxvt_term::cmd_get8 ()
2860{ 2908{
2861 unicode_t c = next_octet (); 2909 uint32_t c = next_octet ();
2862 2910
2863 if (c == NOCHAR) 2911 if (c == NOCHAR)
2864 throw out_of_input; 2912 throw out_of_input;
2865 2913
2866 return c; 2914 return c;
3133 break; 3181 break;
3134 3182
3135 /* 8.3.87: NEXT LINE */ 3183 /* 8.3.87: NEXT LINE */
3136 case C1_NEL: /* ESC E */ 3184 case C1_NEL: /* ESC E */
3137 { 3185 {
3138 unicode_t nlcr[] = { C0_LF, C0_CR }; 3186 wchar_t nlcr[] = { C0_LF, C0_CR };
3139 scr_add_lines (nlcr, 1, 2); 3187 scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1);
3140 } 3188 }
3141 break; 3189 break;
3142 3190
3143 /* kidnapped escape sequence: Should be 8.3.48 */ 3191 /* kidnapped escape sequence: Should be 8.3.48 */
3144 case C1_ESA: /* ESC G */ 3192 case C1_ESA: /* ESC G */
3808 { 3856 {
3809 if ((name = strchr (buf, ';')) == NULL) 3857 if ((name = strchr (buf, ';')) == NULL)
3810 break; 3858 break;
3811 3859
3812 *name++ = '\0'; 3860 *name++ = '\0';
3813 color = atoi (buf); 3861 color = atoi (buf) + minCOLOR;
3814 3862
3815 if (color < 0 || color >= TOTAL_COLORS) 3863 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3816 break; 3864 break;
3817 3865
3818 if ((buf = strchr (name, ';')) != NULL) 3866 if ((buf = strchr (name, ';')) != NULL)
3819 *buf++ = '\0'; 3867 *buf++ = '\0';
3820 3868
3821 if (name[0] == '?' && !name[1]) 3869 if (name[0] == '?' && !name[1])
3822 { 3870 {
3823 unsigned short r, g, b; 3871 unsigned short r, g, b;
3824 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3872 pix_colors_focused[color].get (display, r, g, b);
3825 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3873 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3826 } 3874 }
3827 else 3875 else
3828 set_window_color (color + minCOLOR, name); 3876 set_window_color (color, name);
3829 } 3877 }
3830 break; 3878 break;
3831 case XTerm_Color00: 3879 case XTerm_Color00:
3832 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3880 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3833 break; 3881 break;
3834 case XTerm_Color01: 3882 case XTerm_Color01:
3835 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3883 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3836 break; 3884 break;
3837#ifndef NO_CURSORCOLOR 3885#ifndef NO_CURSORCOLOR
3838 case XTerm_Color_cursor: 3886 case XTerm_Color_cursor:
3839 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3887 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3840 break; 3888 break;
3844 break; 3892 break;
3845 case XTerm_Color_pointer_bg: 3893 case XTerm_Color_pointer_bg:
3846 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3894 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3847 break; 3895 break;
3848#ifndef NO_BOLD_UNDERLINE_REVERSE 3896#ifndef NO_BOLD_UNDERLINE_REVERSE
3849 case XTerm_Color_BD:
3850 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3851 break;
3852 case XTerm_Color_UL:
3853 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3854 break;
3855 case XTerm_Color_RV: 3897 case XTerm_Color_RV:
3856 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3898 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3899 break;
3900 case Rxvt_Color_BD:
3901 case URxvt_Color_BD:
3902 process_color_seq (op, Color_BD, str, resp);
3903 break;
3904 case Rxvt_Color_UL:
3905 case URxvt_Color_UL:
3906 process_color_seq (op, Color_UL, str, resp);
3857 break; 3907 break;
3858 case URxvt_Color_IT: 3908 case URxvt_Color_IT:
3859 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3909 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3860 break; 3910 break;
3861#endif 3911#endif
3866 if (am_transparent) 3916 if (am_transparent)
3867 want_full_refresh = want_refresh = 1; 3917 want_full_refresh = want_refresh = 1;
3868 break; 3918 break;
3869#endif 3919#endif
3870 3920
3871 case XTerm_Pixmap: 3921 case Rxvt_Pixmap:
3872 if (*str != ';') 3922 if (*str != ';')
3873 { 3923 {
3874#if XPM_BACKGROUND 3924#if XPM_BACKGROUND
3875 scale_pixmap (""); /* reset to default scaling */ 3925 scale_pixmap (""); /* reset to default scaling */
3876 set_bgPixmap (str); /* change pixmap */ 3926 set_bgPixmap (str); /* change pixmap */
3877#endif
3878 scr_touch (true); 3927 scr_touch (true);
3928#endif
3879 } 3929 }
3930
3880 while ((str = strchr (str, ';')) != NULL) 3931 while ((str = strchr (str, ';')) != NULL)
3881 { 3932 {
3882 str++; 3933 str++;
3883#if XPM_BACKGROUND 3934#if XPM_BACKGROUND
3884 changed += scale_pixmap (str); 3935 changed += scale_pixmap (str);
3887 3938
3888 if (changed) 3939 if (changed)
3889 { 3940 {
3890#ifdef XPM_BACKGROUND 3941#ifdef XPM_BACKGROUND
3891 resize_pixmap (); 3942 resize_pixmap ();
3892#endif
3893 scr_touch (true); 3943 scr_touch (true);
3944#endif
3894 } 3945 }
3895 break; 3946 break;
3896 3947
3897 case XTerm_restoreFG: 3948 case Rxvt_restoreFG:
3898 set_window_color (Color_fg, str); 3949 set_window_color (Color_fg, str);
3899 break; 3950 break;
3900 case XTerm_restoreBG: 3951 case Rxvt_restoreBG:
3901 set_window_color (Color_bg, str); 3952 set_window_color (Color_bg, str);
3902 break; 3953 break;
3903 3954
3904 case XTerm_logfile: 3955 case XTerm_logfile:
3905 // TODO, when secure mode? 3956 // TODO, when secure mode?
3910 if (OPTION (Opt_insecure)) 3961 if (OPTION (Opt_insecure))
3911 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked 3962 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3912 break; 3963 break;
3913#endif 3964#endif
3914#if 0 3965#if 0
3915 case XTerm_dumpscreen: /* no error notices */ 3966 case Rxvt_dumpscreen: /* no error notices */
3916 { 3967 {
3917 int fd; 3968 int fd;
3918 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3969 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3919 { 3970 {
3920 scr_dump (fd); 3971 scr_dump (fd);
3972 break; 4023 break;
3973#endif 4024#endif
3974 4025
3975#if ENABLE_PERL 4026#if ENABLE_PERL
3976 case URxvt_perl: 4027 case URxvt_perl:
3977 if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) 4028 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END)))
3978 ; // no responses yet 4029 ; // no responses yet
3979 break; 4030 break;
3980#endif 4031#endif
3981 } 4032 }
3982} 4033}
4094 /* extra handling for values with state unkept */ 4145 /* extra handling for values with state unkept */
4095 switch (arg[i]) 4146 switch (arg[i])
4096 { 4147 {
4097#if ENABLE_STYLES 4148#if ENABLE_STYLES
4098 case 1021: 4149 case 1021:
4099 if (mode) 4150 set_option (Opt_intensityStyles, mode);
4100 SET_OPTION (Opt_intensityStyles);
4101 else
4102 CLR_OPTION (Opt_intensityStyles);
4103 4151
4104 scr_touch (true); 4152 scr_touch (true);
4105 break; 4153 break;
4106#endif 4154#endif
4107 case 1048: /* alternative cursor save */ 4155 case 1048: /* alternative cursor save */
4129 case 3: /* 80/132 */ 4177 case 3: /* 80/132 */
4130 if (priv_modes & PrivMode_132OK) 4178 if (priv_modes & PrivMode_132OK)
4131 set_widthheight (((state ? 132 : 80) * fwidth), height); 4179 set_widthheight (((state ? 132 : 80) * fwidth), height);
4132 break; 4180 break;
4133 case 4: /* smooth scrolling */ 4181 case 4: /* smooth scrolling */
4134 if (!state) 4182 set_option (Opt_jumpScroll, !state);
4135 SET_OPTION (Opt_jumpScroll);
4136 else
4137 CLR_OPTION (Opt_jumpScroll);
4138 break; 4183 break;
4139 case 5: /* reverse video */ 4184 case 5: /* reverse video */
4140 scr_rvideo_mode (state); 4185 scr_rvideo_mode (state);
4141 break; 4186 break;
4142 case 6: /* relative/absolute origins */ 4187 case 6: /* relative/absolute origins */
4183#if 0 4228#if 0
4184 case 1001: 4229 case 1001:
4185 break; /* X11 mouse highlighting */ 4230 break; /* X11 mouse highlighting */
4186#endif 4231#endif
4187 case 1010: /* scroll to bottom on TTY output inhibit */ 4232 case 1010: /* scroll to bottom on TTY output inhibit */
4188 if (!state) 4233 set_option (Opt_scrollTtyOutput, !state);
4189 SET_OPTION (Opt_scrollTtyOutput);
4190 else
4191 CLR_OPTION (Opt_scrollTtyOutput);
4192 break; 4234 break;
4193 case 1011: /* scroll to bottom on key press */ 4235 case 1011: /* scroll to bottom on key press */
4194 if (state) 4236 set_option (Opt_scrollTtyKeypress, state);
4195 SET_OPTION (Opt_scrollTtyKeypress);
4196 else
4197 CLR_OPTION (Opt_scrollTtyKeypress);
4198 break; 4237 break;
4199 case 1047: /* secondary screen w/ clearing last */ 4238 case 1047: /* secondary screen w/ clearing last */
4200 if (OPTION (Opt_secondaryScreen)) 4239 if (OPTION (Opt_secondaryScreen))
4201 if (current_screen != PRIMARY) 4240 if (current_screen != PRIMARY)
4202 scr_erase_screen (2); 4241 scr_erase_screen (2);
4412const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4451const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4413 4452
4414void 4453void
4415rxvt_term::tt_write (const char *data, unsigned int len) 4454rxvt_term::tt_write (const char *data, unsigned int len)
4416{ 4455{
4456 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4457 return;
4458
4459 if (pty.pty < 0)
4460 return;
4461
4417 if (v_buflen == 0) 4462 if (v_buflen == 0)
4418 { 4463 {
4419 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); 4464 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE));
4420 4465
4421 if ((unsigned int)written == len) 4466 if ((unsigned int)written == len)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines