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.234 by root, Wed Jan 4 04:42:45 2006 UTC vs.
Revision 1.254 by root, Wed Jan 11 02:13:56 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.
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 > -nsaved && 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 row++;
994 else
995 {
996 // line not filtered, mark it as filtered
997 l->f |= LINE_FILTERED;
998 while (l->is_longer ())
999 {
1000 l = &ROW (++row);
1001 l->f |= LINE_FILTERED;
1002 }
1003
1004 // and filter it
1005 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END));
1006
1007 break;
1008 }
1009 }
1010 while (l->is_longer () && row < end_row);
1011 }
1012 while (++row < end_row);
1013 }
1014
972 scr_refresh (refresh_type); 1015 scr_refresh (refresh_type);
973 scrollbar_show (1); 1016 scrollbar_show (1);
974#ifdef USE_XIM 1017#ifdef USE_XIM
975 IMSendSpot (); 1018 IMSendSpot ();
976#endif 1019#endif
1163 1206
1164#ifdef POINTER_BLANK 1207#ifdef POINTER_BLANK
1165void 1208void
1166rxvt_term::pointer_blank () 1209rxvt_term::pointer_blank ()
1167{ 1210{
1168 if (! OPTION (Opt_pointerBlank)) 1211 if (!OPTION (Opt_pointerBlank))
1169 return; 1212 return;
1170 1213
1171 XDefineCursor (display->display, vt, display->blank_cursor); 1214 XDefineCursor (display->display, vt, display->blank_cursor);
1172 XFlush (display->display); 1215 XFlush (display->display);
1173 1216
1270 dDisp; 1313 dDisp;
1271 1314
1272 SET_R (this); 1315 SET_R (this);
1273 SET_LOCALE (locale); 1316 SET_LOCALE (locale);
1274 1317
1275#if defined(CURSOR_BLINK)
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; 1318 Window unused_root, unused_child;
1303 int unused_root_x, unused_root_y; 1319 int unused_root_x, unused_root_y;
1304 unsigned int unused_mask; 1320 unsigned int unused_mask;
1305 1321
1306 switch (ev.type) 1322 switch (ev.type)
1313 1329
1314 break; 1330 break;
1315 1331
1316 case KeyRelease: 1332 case KeyRelease:
1317 { 1333 {
1318#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 1334#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1319 KeySym ks; 1335 KeySym keysym;
1320 1336
1321 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ 1337 keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1322#endif 1338#endif
1323 1339
1324#if ENABLE_FRILLS || ISO_14755 1340#if ENABLE_FRILLS || ISO_14755
1325 // ISO 14755 support 1341 // ISO 14755 support
1326 if (iso14755buf) 1342 if (iso14755buf)
1331# endif 1347# endif
1332# if ISO_14755 1348# if ISO_14755
1333 // iso14755 part 5.2 handling: release time 1349 // iso14755 part 5.2 handling: release time
1334 // first: controls 1350 // first: controls
1335 if ((ev.xkey.state & ControlMask) 1351 if ((ev.xkey.state & ControlMask)
1336 && ((ks >= 0x40 && ks <= 0x5f) 1352 && ((keysym >= 0x40 && keysym <= 0x5f)
1337 || (ks >= 0x61 && ks <= 0x7f))) 1353 || (keysym >= 0x61 && keysym <= 0x7f)))
1338 { 1354 {
1339 iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); 1355 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1340 commit_iso14755 (); 1356 commit_iso14755 ();
1341 return; // case-break; 1357 goto skip_switch;
1342 } 1358 }
1343 1359
1344 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 1360 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1345 if (i[0] == ks) 1361 if (i[0] == keysym)
1346 { 1362 {
1347 iso14755buf = ISO_14755_51 | i[1]; 1363 iso14755buf = ISO_14755_51 | i[1];
1348 commit_iso14755 (); 1364 commit_iso14755 ();
1349 return; // case-break; 1365 goto skip_switch;
1350 } 1366 }
1351 1367
1352 scr_bell (); 1368 scr_bell ();
1353# endif 1369# endif
1354 iso14755buf = 0; 1370 iso14755buf = 0;
1373 else 1389 else
1374 iso14755buf = 0; 1390 iso14755buf = 0;
1375 } 1391 }
1376#endif 1392#endif
1377 1393
1394 if (ev.xany.window == vt
1395 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1396 break;
1397
1378#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1398#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1379 if (!(ev.xkey.state & ControlMask)) 1399 if (!(ev.xkey.state & ControlMask))
1380 slip_wheel_ev.stop (); 1400 slip_wheel_ev.stop ();
1381 else if (ks == XK_Control_L || ks == XK_Control_R) 1401 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1382 mouse_slip_wheel_speed = 0; 1402 mouse_slip_wheel_speed = 0;
1383#endif 1403#endif
1384 break; 1404 break;
1385 } 1405 }
1386 1406
1516 1536
1517 case SelectionRequest: 1537 case SelectionRequest:
1518 selection_send (ev.xselectionrequest); 1538 selection_send (ev.xselectionrequest);
1519 break; 1539 break;
1520 1540
1541 case MapNotify:
1542 mapped = 1;
1543#ifdef TEXT_BLINK
1544 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1545#endif
1546 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1547 break;
1548
1521 case UnmapNotify: 1549 case UnmapNotify:
1522 mapped = 0; 1550 mapped = 0;
1523#ifdef TEXT_BLINK 1551#ifdef TEXT_BLINK
1524 text_blink_ev.stop (); 1552 text_blink_ev.stop ();
1525#endif 1553#endif
1526 break; 1554 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; 1555 break;
1534 1556
1535#ifdef TRANSPARENT 1557#ifdef TRANSPARENT
1536 case ReparentNotify: 1558 case ReparentNotify:
1537 rootwin_cb (ev); 1559 rootwin_cb (ev);
1551 1573
1552 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1574 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1553 scr_expose (ev.xexpose.x, ev.xexpose.y, 1575 scr_expose (ev.xexpose.x, ev.xexpose.y,
1554 ev.xexpose.width, ev.xexpose.height, False); 1576 ev.xexpose.width, ev.xexpose.height, False);
1555 1577
1556 scr_refresh (refresh_type); 1578 want_refresh = 1;
1557 } 1579 }
1558 else 1580 else
1559 { 1581 {
1560 XEvent unused_event; 1582 XEvent unused_event;
1561 1583
1596 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1618 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1597 break; 1619 break;
1598 1620
1599 if (ev.xany.window == vt) 1621 if (ev.xany.window == vt)
1600 { 1622 {
1623 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1624 ; // nop
1601 if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1625 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1602 { 1626 {
1603 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1627 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1604 ; 1628 ;
1605 1629
1606 XQueryPointer (disp, vt, 1630 XQueryPointer (disp, vt,
1686 &unused_root_x, &unused_root_y, 1710 &unused_root_x, &unused_root_y,
1687 &ev.xbutton.x, &ev.xbutton.y, 1711 &ev.xbutton.x, &ev.xbutton.y,
1688 &unused_mask); 1712 &unused_mask);
1689 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1713 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1690 scrollbar_size ()); 1714 scrollbar_size ());
1691 scr_refresh (refresh_type); 1715 want_refresh = 1;
1692 refresh_limit = 0; 1716 refresh_limit = 0;
1693 scrollbar_show (1); 1717 scrollbar_show (1);
1694 } 1718 }
1695 break; 1719 break;
1696 } 1720 }
1721
1722skip_switch: ;
1723
1724#if defined(CURSOR_BLINK)
1725 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1726 {
1727 if (hidden_cursor)
1728 {
1729 hidden_cursor = 0;
1730 want_refresh = 1;
1731 }
1732
1733 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1734 }
1735#endif
1736
1737#if defined(POINTER_BLANK)
1738 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1739 {
1740 if (ev.type == MotionNotify
1741 || ev.type == ButtonPress
1742 || ev.type == ButtonRelease)
1743 if (hidden_pointer)
1744 pointer_unblank ();
1745
1746 if (ev.type == KeyPress && hidden_pointer == 0)
1747 pointer_blank ();
1748 }
1749#endif
1697} 1750}
1698 1751
1699void 1752void
1700rxvt_term::focus_in () 1753rxvt_term::focus_in ()
1701{ 1754{
1702 if (!focus) 1755 if (!focus)
1703 { 1756 {
1704 focus = 1; 1757 focus = 1;
1705 want_refresh = 1; 1758 want_refresh = 1;
1706 1759
1707 PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1760 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1708 1761
1709#if USE_XIM 1762#if USE_XIM
1710 if (Input_Context != NULL) 1763 if (Input_Context != NULL)
1711 { 1764 {
1712 IMSetStatusPosition (); 1765 IMSetStatusPosition ();
1733 if (focus) 1786 if (focus)
1734 { 1787 {
1735 focus = 0; 1788 focus = 0;
1736 want_refresh = 1; 1789 want_refresh = 1;
1737 1790
1738 PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1791 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1739 1792
1740#if ENABLE_FRILLS || ISO_14755 1793#if ENABLE_FRILLS || ISO_14755
1741 if (iso14755buf) 1794 if (iso14755buf)
1742 { 1795 {
1743 iso14755buf = 0; 1796 iso14755buf = 0;
1826#ifdef MOUSE_REPORT_DOUBLECLICK 1879#ifdef MOUSE_REPORT_DOUBLECLICK
1827 if (ev.button == MEvent.button && clickintime) 1880 if (ev.button == MEvent.button && clickintime)
1828 { 1881 {
1829 /* same button, within alloted time */ 1882 /* same button, within alloted time */
1830 MEvent.clicks++; 1883 MEvent.clicks++;
1884
1831 if (MEvent.clicks > 1) 1885 if (MEvent.clicks > 1)
1832 { 1886 {
1833 /* only report double clicks */ 1887 /* only report double clicks */
1834 MEvent.clicks = 2; 1888 MEvent.clicks = 2;
1835 mouse_report (ev); 1889 mouse_report (ev);
1855 else 1909 else
1856 { 1910 {
1857 if (ev.button != MEvent.button) 1911 if (ev.button != MEvent.button)
1858 MEvent.clicks = 0; 1912 MEvent.clicks = 0;
1859 1913
1860 if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) 1914 if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END)))
1861 switch (ev.button) 1915 switch (ev.button)
1862 { 1916 {
1863 case Button1: 1917 case Button1:
1864 /* allow meta + click to select rectangular areas */ 1918 /* allow meta + click to select rectangular areas */
1865 /* should be done in screen.C */ 1919 /* should be done in screen.C */
2043 } 2097 }
2044 2098
2045 break; 2099 break;
2046 } 2100 }
2047 } 2101 }
2102
2048 return; 2103 return;
2049 } 2104 }
2105
2050#if MENUBAR 2106#if MENUBAR
2051 /* 2107 /*
2052 * Menubar window processing of button press 2108 * Menubar window processing of button press
2053 */ 2109 */
2054 if (isMenuBarWindow (ev.window)) 2110 if (isMenuBarWindow (ev.window))
2117 if (priv_modes & PrivMode_mouse_report 2173 if (priv_modes & PrivMode_mouse_report
2118 && bypass_keystate 2174 && bypass_keystate
2119 && ev.button == Button1 && MEvent.clicks <= 1) 2175 && ev.button == Button1 && MEvent.clicks <= 1)
2120 selection_extend (ev.x, ev.y, 0); 2176 selection_extend (ev.x, ev.y, 0);
2121 2177
2178 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2179 return;
2180
2122 switch (ev.button) 2181 switch (ev.button)
2123 { 2182 {
2124 case Button1: 2183 case Button1:
2125 case Button3: 2184 case Button3:
2126 selection_make (ev.time); 2185 selection_make (ev.time);
2157 slip_wheel_ev.start (); 2216 slip_wheel_ev.start ();
2158 } 2217 }
2159 else 2218 else
2160 { 2219 {
2161# endif 2220# endif
2162# ifdef JUMP_MOUSE_WHEEL
2163 scr_page (v, i); 2221 scr_page (v, i);
2164 scr_refresh (SMOOTH_REFRESH);
2165 scrollbar_show (1); 2222 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 2223# ifdef MOUSE_SLIP_WHEELING
2175 } 2224 }
2176#endif 2225# endif
2177 } 2226 }
2178 break; 2227 break;
2179#endif 2228#endif
2180 } 2229 }
2181 } 2230 }
2670 2719
2671bool 2720bool
2672rxvt_term::cmd_parse () 2721rxvt_term::cmd_parse ()
2673{ 2722{
2674 bool flag = false; 2723 bool flag = false;
2675 unicode_t ch = NOCHAR; 2724 wchar_t ch = NOCHAR;
2676 char *seq_begin; // remember start of esc-sequence here 2725 char *seq_begin; // remember start of esc-sequence here
2677 2726
2678 for (;;) 2727 for (;;)
2679 { 2728 {
2680 if (ch == NOCHAR) 2729 if (ch == NOCHAR)
2681 { 2730 {
2682 seq_begin = cmdbuf_ptr; 2731 seq_begin = cmdbuf_ptr;
2683 ch = next_char (); 2732 ch = next_char ();
2684 }
2685 2733
2686 if (ch == NOCHAR) // TODO: improve 2734 if (ch == NOCHAR)
2687 break; 2735 break;
2736 }
2688 2737
2689 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2738 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)
2690 { 2739 {
2691 if (!seen_input) 2740 if (!seen_input)
2692 { 2741 {
2701 if (seen_resize && cmd_pid) 2750 if (seen_resize && cmd_pid)
2702 kill (-cmd_pid, SIGWINCH); 2751 kill (-cmd_pid, SIGWINCH);
2703 } 2752 }
2704 2753
2705 /* Read a text string from the input buffer */ 2754 /* Read a text string from the input buffer */
2706 unicode_t buf[UBUFSIZ]; 2755 wchar_t buf[UBUFSIZ];
2707 bool refreshnow = false; 2756 bool refreshnow = false;
2708 int nlines = 0; 2757 int nlines = 0;
2709 unicode_t *str = buf; 2758 wchar_t *str = buf;
2710 unicode_t *eol = str + min (ncol, UBUFSIZ); 2759 wchar_t *eol = str + min (ncol, UBUFSIZ);
2711 2760
2712 for (;;) 2761 for (;;)
2713 { 2762 {
2714 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2763 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2715 break; 2764 break;
2733 } 2782 }
2734 2783
2735 // scr_add_lines only works for nlines <= nrow - 1. 2784 // scr_add_lines only works for nlines <= nrow - 1.
2736 if (nlines >= nrow - 1) 2785 if (nlines >= nrow - 1)
2737 { 2786 {
2787 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))
2738 scr_add_lines (buf, nlines, str - buf); 2788 scr_add_lines (buf, str - buf, nlines);
2789
2739 nlines = 0; 2790 nlines = 0;
2740 str = buf; 2791 str = buf;
2741 eol = str + min (ncol, UBUFSIZ); 2792 eol = str + min (ncol, UBUFSIZ);
2742 } 2793 }
2743 2794
2756 2807
2757 seq_begin = cmdbuf_ptr; 2808 seq_begin = cmdbuf_ptr;
2758 ch = next_char (); 2809 ch = next_char ();
2759 } 2810 }
2760 2811
2812 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))
2761 scr_add_lines (buf, nlines, str - buf); 2813 scr_add_lines (buf, str - buf, nlines);
2762 2814
2763 /* 2815 /*
2764 * If there have been a lot of new lines, then update the screen 2816 * 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. 2817 * 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 2818 * the number of pages between refreshes is refresh_limit, which
2772 refresh_limit++; 2824 refresh_limit++;
2773 else 2825 else
2774 { 2826 {
2775 flag = true; 2827 flag = true;
2776 scr_refresh (refresh_type); 2828 scr_refresh (refresh_type);
2777 flush_ev.stop (); 2829 want_refresh = 1;
2778 } 2830 }
2779 } 2831 }
2780 2832
2781 } 2833 }
2782 else 2834 else
2797 } 2849 }
2798 2850
2799 return flag; 2851 return flag;
2800} 2852}
2801 2853
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 2854// read the next character
2812unicode_t 2855wchar_t
2813rxvt_term::next_char () 2856rxvt_term::next_char ()
2814{ 2857{
2815 while (cmdbuf_ptr < cmdbuf_endp) 2858 while (cmdbuf_ptr < cmdbuf_endp)
2816 { 2859 {
2817 // assume 7-bit to be ascii ALWAYS 2860 // assume 7-bit to be ascii ALWAYS
2827 cmdbuf_ptr = cmdbuf_endp; 2870 cmdbuf_ptr = cmdbuf_endp;
2828 break; 2871 break;
2829 } 2872 }
2830 2873
2831 if (len == (size_t)-1) 2874 if (len == (size_t)-1)
2832 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2875 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2833 2876
2834 // assume wchar == unicode 2877 // assume wchar == unicode
2835 cmdbuf_ptr += len; 2878 cmdbuf_ptr += len;
2836 return wc & UNICODE_MASK; 2879 return wc & UNICODE_MASK;
2837 } 2880 }
2838 2881
2839 return NOCHAR; 2882 return NOCHAR;
2883}
2884
2885// read the next octet
2886uint32_t
2887rxvt_term::next_octet ()
2888{
2889 return cmdbuf_ptr < cmdbuf_endp
2890 ? (unsigned char)*cmdbuf_ptr++
2891 : NOCHAR;
2840} 2892}
2841 2893
2842/* rxvt_cmd_getc () - Return next input character */ 2894/* rxvt_cmd_getc () - Return next input character */
2843/* 2895/*
2844 * Return the next input character after first passing any keyboard input 2896 * Return the next input character after first passing any keyboard input
2845 * to the command. 2897 * to the command.
2846 */ 2898 */
2847unicode_t 2899wchar_t
2848rxvt_term::cmd_getc () 2900rxvt_term::cmd_getc ()
2849{ 2901{
2850 unicode_t c = next_char (); 2902 wchar_t c = next_char ();
2851 2903
2852 if (c == NOCHAR) 2904 if (c == NOCHAR)
2853 throw out_of_input; 2905 throw out_of_input;
2854 2906
2855 return c; 2907 return c;
2856} 2908}
2857 2909
2858unicode_t 2910uint32_t
2859rxvt_term::cmd_get8 () 2911rxvt_term::cmd_get8 ()
2860{ 2912{
2861 unicode_t c = next_octet (); 2913 uint32_t c = next_octet ();
2862 2914
2863 if (c == NOCHAR) 2915 if (c == NOCHAR)
2864 throw out_of_input; 2916 throw out_of_input;
2865 2917
2866 return c; 2918 return c;
3133 break; 3185 break;
3134 3186
3135 /* 8.3.87: NEXT LINE */ 3187 /* 8.3.87: NEXT LINE */
3136 case C1_NEL: /* ESC E */ 3188 case C1_NEL: /* ESC E */
3137 { 3189 {
3138 unicode_t nlcr[] = { C0_LF, C0_CR }; 3190 wchar_t nlcr[] = { C0_LF, C0_CR };
3139 scr_add_lines (nlcr, 1, 2); 3191 scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1);
3140 } 3192 }
3141 break; 3193 break;
3142 3194
3143 /* kidnapped escape sequence: Should be 8.3.48 */ 3195 /* kidnapped escape sequence: Should be 8.3.48 */
3144 case C1_ESA: /* ESC G */ 3196 case C1_ESA: /* ESC G */
3972 break; 4024 break;
3973#endif 4025#endif
3974 4026
3975#if ENABLE_PERL 4027#if ENABLE_PERL
3976 case URxvt_perl: 4028 case URxvt_perl:
3977 if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) 4029 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END)))
3978 ; // no responses yet 4030 ; // no responses yet
3979 break; 4031 break;
3980#endif 4032#endif
3981 } 4033 }
3982} 4034}
4094 /* extra handling for values with state unkept */ 4146 /* extra handling for values with state unkept */
4095 switch (arg[i]) 4147 switch (arg[i])
4096 { 4148 {
4097#if ENABLE_STYLES 4149#if ENABLE_STYLES
4098 case 1021: 4150 case 1021:
4099 if (mode) 4151 set_option (Opt_intensityStyles, mode);
4100 SET_OPTION (Opt_intensityStyles);
4101 else
4102 CLR_OPTION (Opt_intensityStyles);
4103 4152
4104 scr_touch (true); 4153 scr_touch (true);
4105 break; 4154 break;
4106#endif 4155#endif
4107 case 1048: /* alternative cursor save */ 4156 case 1048: /* alternative cursor save */
4129 case 3: /* 80/132 */ 4178 case 3: /* 80/132 */
4130 if (priv_modes & PrivMode_132OK) 4179 if (priv_modes & PrivMode_132OK)
4131 set_widthheight (((state ? 132 : 80) * fwidth), height); 4180 set_widthheight (((state ? 132 : 80) * fwidth), height);
4132 break; 4181 break;
4133 case 4: /* smooth scrolling */ 4182 case 4: /* smooth scrolling */
4134 if (!state) 4183 set_option (Opt_jumpScroll, !state);
4135 SET_OPTION (Opt_jumpScroll);
4136 else
4137 CLR_OPTION (Opt_jumpScroll);
4138 break; 4184 break;
4139 case 5: /* reverse video */ 4185 case 5: /* reverse video */
4140 scr_rvideo_mode (state); 4186 scr_rvideo_mode (state);
4141 break; 4187 break;
4142 case 6: /* relative/absolute origins */ 4188 case 6: /* relative/absolute origins */
4183#if 0 4229#if 0
4184 case 1001: 4230 case 1001:
4185 break; /* X11 mouse highlighting */ 4231 break; /* X11 mouse highlighting */
4186#endif 4232#endif
4187 case 1010: /* scroll to bottom on TTY output inhibit */ 4233 case 1010: /* scroll to bottom on TTY output inhibit */
4188 if (!state) 4234 set_option (Opt_scrollTtyOutput, !state);
4189 SET_OPTION (Opt_scrollTtyOutput);
4190 else
4191 CLR_OPTION (Opt_scrollTtyOutput);
4192 break; 4235 break;
4193 case 1011: /* scroll to bottom on key press */ 4236 case 1011: /* scroll to bottom on key press */
4194 if (state) 4237 set_option (Opt_scrollTtyKeypress, state);
4195 SET_OPTION (Opt_scrollTtyKeypress);
4196 else
4197 CLR_OPTION (Opt_scrollTtyKeypress);
4198 break; 4238 break;
4199 case 1047: /* secondary screen w/ clearing last */ 4239 case 1047: /* secondary screen w/ clearing last */
4200 if (OPTION (Opt_secondaryScreen)) 4240 if (OPTION (Opt_secondaryScreen))
4201 if (current_screen != PRIMARY) 4241 if (current_screen != PRIMARY)
4202 scr_erase_screen (2); 4242 scr_erase_screen (2);
4340 scr_color (Color_bg, Color_bg); 4380 scr_color (Color_bg, Color_bg);
4341 break; 4381 break;
4342 4382
4343 //case 50: // not variable spacing 4383 //case 50: // not variable spacing
4344 4384
4345#ifndef NO_BRIGHTCOLOR 4385#if ENABLE_FRILLS
4346 case 90: 4386 case 90:
4347 case 91: /* set bright fg color */ 4387 case 91: /* set bright fg color */
4348 case 92: 4388 case 92:
4349 case 93: 4389 case 93:
4350 case 94: 4390 case 94:
4412const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4452const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4413 4453
4414void 4454void
4415rxvt_term::tt_write (const char *data, unsigned int len) 4455rxvt_term::tt_write (const char *data, unsigned int len)
4416{ 4456{
4457 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4458 return;
4459
4460 if (pty.pty < 0)
4461 return;
4462
4417 if (v_buflen == 0) 4463 if (v_buflen == 0)
4418 { 4464 {
4419 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); 4465 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE));
4420 4466
4421 if ((unsigned int)written == len) 4467 if ((unsigned int)written == len)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines