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.248 by root, Sun Jan 8 00:07:18 2006 UTC vs.
Revision 1.270 by root, Wed Jan 18 10:31:37 2006 UTC

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_STR_LEN, kbuf, len, DT_END))) 872 if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END)))
873 return; 873 return;
874 874
875 if (len <= 0) 875 if (len <= 0)
876 return; /* not mapped */ 876 return; /* not mapped */
877 877
919#endif /* DEBUG_CMD */ 919#endif /* DEBUG_CMD */
920 tt_write (kbuf, (unsigned int)len); 920 tt_write (kbuf, (unsigned int)len);
921} 921}
922/*}}} */ 922/*}}} */
923 923
924#if MENUBAR_MAX || defined (KEYSYM_RESOURCE) 924#if defined (KEYSYM_RESOURCE)
925/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */
926/* attempt to `write' count to the input buffer */
927unsigned int 925unsigned int
928rxvt_term::cmd_write (const char *str, unsigned int count) 926rxvt_term::cmd_write (const char *str, unsigned int count)
929{ 927{
930 unsigned int n, s; 928 unsigned int n, s;
931 929
972 970
973 if (want_refresh) 971 if (want_refresh)
974 { 972 {
975 if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) 973 if (SHOULD_INVOKE (HOOK_LINE_UPDATE))
976 { 974 {
977 int row = -view_start; 975 int row = view_start;
976 int end_row = row + nrow;
978 977
979 while (row > -nsaved && ROW (row - 1).is_longer ()) 978 while (row > top_row && ROW (row - 1).is_longer ())
980 --row; 979 --row;
981 980
982 while (row < -view_start + nrow) 981 do
983 { 982 {
984 int start_row = row; 983 int start_row = row;
985 line_t *l; 984 line_t *l;
986 985
987 do 986 do
988 { 987 {
989 l = &ROW (row); 988 l = &ROW (row++);
990 989
991 if (!(l->f & LINE_FILTERED)) 990 if (!(l->f & LINE_FILTERED))
992 { 991 {
993 // line not filtered, mark it as filtered 992 // line not filtered, mark it as filtered
994 l->f |= LINE_FILTERED; 993 l->f |= LINE_FILTERED;
995 while (l->is_longer ()) 994 while (l->is_longer ())
996 { 995 {
997 l = &ROW (++row); 996 l = &ROW (row++);
998 l->f |= LINE_FILTERED; 997 l->f |= LINE_FILTERED;
999 } 998 }
1000 999
1001 // and filter it 1000 // and filter it
1002 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); 1001 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END));
1003 1002
1004 break; 1003 break;
1005 } 1004 }
1006 } 1005 }
1007 while (l->is_longer ()); 1006 while (l->is_longer () && row < end_row);
1008
1009 row++;
1010 } 1007 }
1008 while (row < end_row);
1011 1009 }
1012 }
1013 1010
1014 scr_refresh (refresh_type); 1011 scr_refresh ();
1015 scrollbar_show (1); 1012 scrollbar_show (1);
1016#ifdef USE_XIM 1013#ifdef USE_XIM
1017 IMSendSpot (); 1014 IMSendSpot ();
1018#endif 1015#endif
1019 } 1016 }
1022} 1019}
1023 1020
1024void 1021void
1025rxvt_term::check_cb (check_watcher &w) 1022rxvt_term::check_cb (check_watcher &w)
1026{ 1023{
1027 SET_R (this); 1024 make_current ();
1028 SET_LOCALE (locale);
1029 1025
1030 display->flush (); 1026 display->flush ();
1031 1027
1032 if (want_refresh && !flush_ev.active) 1028 if (want_refresh && !flush_ev.active)
1033 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally 1029 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
1034} 1030}
1035 1031
1036void 1032void
1037rxvt_term::flush_cb (time_watcher &w) 1033rxvt_term::flush_cb (time_watcher &w)
1038{ 1034{
1039 SET_R (this); 1035 make_current ();
1040 SET_LOCALE (locale);
1041 1036
1042 refresh_limit = 1; 1037 refresh_limit = 1;
1043 refresh_count = 0; 1038 refresh_count = 0;
1044 flush (); 1039 flush ();
1045} 1040}
1073rxvt_term::cont_scroll_cb (time_watcher &w) 1068rxvt_term::cont_scroll_cb (time_watcher &w)
1074{ 1069{
1075 if ((scrollbar_isUp() || scrollbar_isDn()) && 1070 if ((scrollbar_isUp() || scrollbar_isDn()) &&
1076 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1071 scr_page (scrollbar_isUp() ? UP : DN, 1))
1077 { 1072 {
1078 refresh_type |= SMOOTH_REFRESH;
1079 want_refresh = 1; 1073 want_refresh = 1;
1080 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1074 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1081 } 1075 }
1082} 1076}
1083#endif 1077#endif
1087rxvt_term::sel_scroll_cb (time_watcher &w) 1081rxvt_term::sel_scroll_cb (time_watcher &w)
1088{ 1082{
1089 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1083 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1090 { 1084 {
1091 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1085 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1092 refresh_type |= SMOOTH_REFRESH;
1093 want_refresh = 1; 1086 want_refresh = 1;
1094 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1087 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1095 } 1088 }
1096} 1089}
1097#endif 1090#endif
1102{ 1095{
1103 if (mouse_slip_wheel_speed == 0 1096 if (mouse_slip_wheel_speed == 0
1104 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) 1097 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1105 : scr_page (UP, mouse_slip_wheel_speed)) 1098 : scr_page (UP, mouse_slip_wheel_speed))
1106 { 1099 {
1107 if (view_start == nsaved || 1100 if (view_start == top_row || view_start == 0)
1108 view_start == 0)
1109 mouse_slip_wheel_speed = 0; 1101 mouse_slip_wheel_speed = 0;
1110 1102
1111 refresh_type |= SMOOTH_REFRESH;
1112 want_refresh = 1; 1103 want_refresh = 1;
1113 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1104 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1114 } 1105 }
1115} 1106}
1116#endif 1107#endif
1146 1137
1147 memmove (cmdbuf_base, cmdbuf_ptr, n); 1138 memmove (cmdbuf_base, cmdbuf_ptr, n);
1148 cmdbuf_ptr = cmdbuf_base; 1139 cmdbuf_ptr = cmdbuf_base;
1149 cmdbuf_endp = cmdbuf_ptr + n; 1140 cmdbuf_endp = cmdbuf_ptr + n;
1150 1141
1151 ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); 1142 ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n);
1152 1143
1153 if (r > 0) 1144 if (r > 0)
1154 { 1145 {
1155 cmdbuf_endp += r; 1146 cmdbuf_endp += r;
1156 return true; 1147 return true;
1174} 1165}
1175 1166
1176void 1167void
1177rxvt_term::pty_cb (io_watcher &w, short revents) 1168rxvt_term::pty_cb (io_watcher &w, short revents)
1178{ 1169{
1179 SET_R (this); 1170 make_current ();
1180 SET_LOCALE (locale);
1181 1171
1182 if (revents & EVENT_READ) 1172 if (revents & EVENT_READ)
1183 // loop, but don't allow a single term to monopolize us 1173 // loop, but don't allow a single term to monopolize us
1184 while (pty_fill ()) 1174 while (pty_fill ())
1185 if (cmd_parse ()) 1175 if (cmd_parse ())
1217} 1207}
1218 1208
1219void 1209void
1220rxvt_term::pointer_cb (time_watcher &w) 1210rxvt_term::pointer_cb (time_watcher &w)
1221{ 1211{
1222 SET_R (this); 1212 make_current ();
1223 SET_LOCALE (locale);
1224 1213
1225 pointer_blank (); 1214 pointer_blank ();
1226} 1215}
1227#endif 1216#endif
1228 1217
1307 1296
1308/*{{{ process an X event */ 1297/*{{{ process an X event */
1309void 1298void
1310rxvt_term::x_cb (XEvent &ev) 1299rxvt_term::x_cb (XEvent &ev)
1311{ 1300{
1301 make_current ();
1302
1312 dDisp; 1303 dDisp;
1313 1304
1314 SET_R (this); 1305 if (ev.xany.window == vt
1315 SET_LOCALE (locale); 1306 && SHOULD_INVOKE (HOOK_X_EVENT)
1307 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1308 return;
1316 1309
1310 // for XQueryPointer
1317 Window unused_root, unused_child; 1311 Window unused_root, unused_child;
1318 int unused_root_x, unused_root_y; 1312 int unused_root_x, unused_root_y;
1319 unsigned int unused_mask; 1313 unsigned int unused_mask;
1320 1314
1321 switch (ev.type) 1315 switch (ev.type)
1328 1322
1329 break; 1323 break;
1330 1324
1331 case KeyRelease: 1325 case KeyRelease:
1332 { 1326 {
1333#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 1327#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1334 KeySym ks; 1328 KeySym keysym;
1335 1329
1336 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ 1330 keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1337#endif 1331#endif
1338 1332
1339#if ENABLE_FRILLS || ISO_14755 1333#if ENABLE_FRILLS || ISO_14755
1340 // ISO 14755 support 1334 // ISO 14755 support
1341 if (iso14755buf) 1335 if (iso14755buf)
1346# endif 1340# endif
1347# if ISO_14755 1341# if ISO_14755
1348 // iso14755 part 5.2 handling: release time 1342 // iso14755 part 5.2 handling: release time
1349 // first: controls 1343 // first: controls
1350 if ((ev.xkey.state & ControlMask) 1344 if ((ev.xkey.state & ControlMask)
1351 && ((ks >= 0x40 && ks <= 0x5f) 1345 && ((keysym >= 0x40 && keysym <= 0x5f)
1352 || (ks >= 0x61 && ks <= 0x7f))) 1346 || (keysym >= 0x61 && keysym <= 0x7f)))
1353 { 1347 {
1354 iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); 1348 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1355 commit_iso14755 (); 1349 commit_iso14755 ();
1356 goto skip_switch; 1350 goto skip_switch;
1357 } 1351 }
1358 1352
1359 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 1353 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1360 if (i[0] == ks) 1354 if (i[0] == keysym)
1361 { 1355 {
1362 iso14755buf = ISO_14755_51 | i[1]; 1356 iso14755buf = ISO_14755_51 | i[1];
1363 commit_iso14755 (); 1357 commit_iso14755 ();
1364 goto skip_switch; 1358 goto skip_switch;
1365 } 1359 }
1389 iso14755buf = 0; 1383 iso14755buf = 0;
1390 } 1384 }
1391#endif 1385#endif
1392 1386
1393 if (ev.xany.window == vt 1387 if (ev.xany.window == vt
1394 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) 1388 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1395 break; 1389 break;
1396 1390
1397#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1391#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1398 if (!(ev.xkey.state & ControlMask)) 1392 if (!(ev.xkey.state & ControlMask))
1399 slip_wheel_ev.stop (); 1393 slip_wheel_ev.stop ();
1400 else if (ks == XK_Control_L || ks == XK_Control_R) 1394 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1401 mouse_slip_wheel_speed = 0; 1395 mouse_slip_wheel_speed = 0;
1402#endif 1396#endif
1403 break; 1397 break;
1404 } 1398 }
1405 1399
1508 { 1502 {
1509 seen_resize = 1; 1503 seen_resize = 1;
1510 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1504 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1511 } 1505 }
1512 1506
1507 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1508
1513#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1509#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1514 if (OPTION (Opt_transparent)) 1510 if (OPTION (Opt_transparent))
1515 check_our_parents (); 1511 check_our_parents ();
1516#endif 1512#endif
1517 } 1513 }
1572 1568
1573 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1569 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1574 scr_expose (ev.xexpose.x, ev.xexpose.y, 1570 scr_expose (ev.xexpose.x, ev.xexpose.y,
1575 ev.xexpose.width, ev.xexpose.height, False); 1571 ev.xexpose.width, ev.xexpose.height, False);
1576 1572
1577 scr_refresh (refresh_type); 1573 want_refresh = 1;
1578 } 1574 }
1579 else 1575 else
1580 { 1576 {
1581 XEvent unused_event; 1577 XEvent unused_event;
1582 1578
1588 if (isScrollbarWindow (ev.xany.window)) 1584 if (isScrollbarWindow (ev.xany.window))
1589 { 1585 {
1590 scrollBar.setIdle (); 1586 scrollBar.setIdle ();
1591 scrollbar_show (0); 1587 scrollbar_show (0);
1592 } 1588 }
1593#ifdef MENUBAR
1594 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1595 menubar_expose ();
1596#endif
1597 1589
1598#ifdef TRANSPARENT 1590#ifdef TRANSPARENT
1599 if (am_transparent && ev.xany.window == parent[0]) 1591 if (am_transparent && ev.xany.window == parent[0])
1600 XClearWindow (disp, ev.xany.window); 1592 XClearWindow (disp, ev.xany.window);
1601#endif 1593#endif
1605 case MotionNotify: 1597 case MotionNotify:
1606#ifdef POINTER_BLANK 1598#ifdef POINTER_BLANK
1607 if (hidden_pointer) 1599 if (hidden_pointer)
1608 pointer_unblank (); 1600 pointer_unblank ();
1609#endif 1601#endif
1610#if MENUBAR
1611 if (isMenuBarWindow (ev.xany.window))
1612 {
1613 menubar_control (ev.xbutton);
1614 break;
1615 }
1616#endif
1617 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1602 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1618 break; 1603 break;
1619 1604
1620 if (ev.xany.window == vt) 1605 if (ev.xany.window == vt)
1621 { 1606 {
1607 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1622 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1608 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1623 ; // nop 1609 ; // nop
1624 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1610 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1625 { 1611 {
1626 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1612 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1627 ; 1613 ;
1709 &unused_root_x, &unused_root_y, 1695 &unused_root_x, &unused_root_y,
1710 &ev.xbutton.x, &ev.xbutton.y, 1696 &ev.xbutton.x, &ev.xbutton.y,
1711 &unused_mask); 1697 &unused_mask);
1712 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1698 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1713 scrollbar_size ()); 1699 scrollbar_size ());
1714 scr_refresh (refresh_type); 1700 want_refresh = 1;
1715 refresh_limit = 0; 1701 refresh_limit = 0;
1716 scrollbar_show (1); 1702 scrollbar_show (1);
1717 } 1703 }
1718 break; 1704 break;
1719 } 1705 }
1819 1805
1820#if TRANSPARENT 1806#if TRANSPARENT
1821void 1807void
1822rxvt_term::rootwin_cb (XEvent &ev) 1808rxvt_term::rootwin_cb (XEvent &ev)
1823{ 1809{
1824 SET_R (this); 1810 make_current ();
1825 SET_LOCALE (locale);
1826 1811
1827 switch (ev.type) 1812 switch (ev.type)
1828 { 1813 {
1829 case PropertyNotify: 1814 case PropertyNotify:
1830 /* 1815 /*
1921#else 1906#else
1922 selection.rect = false; 1907 selection.rect = false;
1923#endif 1908#endif
1924 1909
1925 /* allow shift+left click to extend selection */ 1910 /* allow shift+left click to extend selection */
1926 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1911 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1927 { 1912 {
1928 if (MEvent.button == Button1 && clickintime) 1913 if (MEvent.button == Button1 && clickintime)
1929 selection_rotate (ev.x, ev.y); 1914 selection_rotate (ev.x, ev.y);
1930 else 1915 else
1931 selection_extend (ev.x, ev.y, 1); 1916 selection_extend (ev.x, ev.y, 1);
2099 } 2084 }
2100 } 2085 }
2101 2086
2102 return; 2087 return;
2103 } 2088 }
2104
2105#if MENUBAR
2106 /*
2107 * Menubar window processing of button press
2108 */
2109 if (isMenuBarWindow (ev.window))
2110 menubar_control (ev);
2111#endif
2112} 2089}
2113 2090
2114void 2091void
2115rxvt_term::button_release (XButtonEvent &ev) 2092rxvt_term::button_release (XButtonEvent &ev)
2116{ 2093{
2122 2099
2123 if (scrollbar_isUpDn ()) 2100 if (scrollbar_isUpDn ())
2124 { 2101 {
2125 scrollBar.setIdle (); 2102 scrollBar.setIdle ();
2126 scrollbar_show (0); 2103 scrollbar_show (0);
2127#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2128 refresh_type &= ~SMOOTH_REFRESH;
2129#endif
2130 } 2104 }
2131 2105
2132#ifdef SELECTION_SCROLLING 2106#ifdef SELECTION_SCROLLING
2133 if (sel_scroll_ev.active) 2107 if (sel_scroll_ev.active)
2134 sel_scroll_ev.stop(); 2108 sel_scroll_ev.stop();
2215 slip_wheel_ev.start (); 2189 slip_wheel_ev.start ();
2216 } 2190 }
2217 else 2191 else
2218 { 2192 {
2219# endif 2193# endif
2220# ifdef JUMP_MOUSE_WHEEL
2221 scr_page (v, i); 2194 scr_page (v, i);
2222 scr_refresh (SMOOTH_REFRESH);
2223 scrollbar_show (1); 2195 scrollbar_show (1);
2224# else
2225 while (i--)
2226 {
2227 scr_page (v, 1);
2228 scr_refresh (SMOOTH_REFRESH);
2229 scrollbar_show (1);
2230 }
2231# endif
2232# ifdef MOUSE_SLIP_WHEELING 2196# ifdef MOUSE_SLIP_WHEELING
2233 } 2197 }
2234#endif 2198# endif
2235 } 2199 }
2236 break; 2200 break;
2237#endif 2201#endif
2238 } 2202 }
2239 } 2203 }
2240#ifdef MENUBAR
2241 else if (isMenuBarWindow (ev.window))
2242 menubar_control (ev);
2243#endif
2244} 2204}
2245 2205
2246#ifdef TRANSPARENT 2206#ifdef TRANSPARENT
2247#if TINTING 2207#if TINTING
2248/* taken from aterm-0.4.2 */ 2208/* taken from aterm-0.4.2 */
2791 } 2751 }
2792 2752
2793 // scr_add_lines only works for nlines <= nrow - 1. 2753 // scr_add_lines only works for nlines <= nrow - 1.
2794 if (nlines >= nrow - 1) 2754 if (nlines >= nrow - 1)
2795 { 2755 {
2756 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2796 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) 2757 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2797 scr_add_lines (buf, str - buf, nlines); 2758 scr_add_lines (buf, str - buf, nlines);
2798 2759
2799 nlines = 0; 2760 nlines = 0;
2800 str = buf; 2761 str = buf;
2801 eol = str + min (ncol, UBUFSIZ); 2762 eol = str + min (ncol, UBUFSIZ);
2816 2777
2817 seq_begin = cmdbuf_ptr; 2778 seq_begin = cmdbuf_ptr;
2818 ch = next_char (); 2779 ch = next_char ();
2819 } 2780 }
2820 2781
2782 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2821 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) 2783 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2822 scr_add_lines (buf, str - buf, nlines); 2784 scr_add_lines (buf, str - buf, nlines);
2823 2785
2824 /* 2786 /*
2825 * If there have been a lot of new lines, then update the screen 2787 * If there have been a lot of new lines, then update the screen
2826 * What the heck I'll cheat and only refresh less than every page-full. 2788 * What the heck I'll cheat and only refresh less than every page-full.
2832 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2794 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2833 refresh_limit++; 2795 refresh_limit++;
2834 else 2796 else
2835 { 2797 {
2836 flag = true; 2798 flag = true;
2837 scr_refresh (refresh_type); 2799 scr_refresh ();
2838 flush_ev.stop (); 2800 want_refresh = 1;
2839 } 2801 }
2840 } 2802 }
2841 2803
2842 } 2804 }
2843 else 2805 else
3869 { 3831 {
3870 if ((name = strchr (buf, ';')) == NULL) 3832 if ((name = strchr (buf, ';')) == NULL)
3871 break; 3833 break;
3872 3834
3873 *name++ = '\0'; 3835 *name++ = '\0';
3874 color = atoi (buf); 3836 color = atoi (buf) + minCOLOR;
3875 3837
3876 if (color < 0 || color >= TOTAL_COLORS) 3838 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3877 break; 3839 break;
3878 3840
3879 if ((buf = strchr (name, ';')) != NULL) 3841 if ((buf = strchr (name, ';')) != NULL)
3880 *buf++ = '\0'; 3842 *buf++ = '\0';
3881 3843
3882 if (name[0] == '?' && !name[1]) 3844 if (name[0] == '?' && !name[1])
3883 { 3845 {
3884 unsigned short r, g, b; 3846 unsigned short r, g, b;
3885 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3847 pix_colors_focused[color].get (display, r, g, b);
3886 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3848 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3887 } 3849 }
3888 else 3850 else
3889 set_window_color (color + minCOLOR, name); 3851 set_window_color (color, name);
3890 } 3852 }
3891 break; 3853 break;
3892 case XTerm_Color00: 3854 case XTerm_Color00:
3893 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3855 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3894 break; 3856 break;
3895 case XTerm_Color01: 3857 case XTerm_Color01:
3896 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3858 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3897 break; 3859 break;
3898#ifndef NO_CURSORCOLOR 3860#ifndef NO_CURSORCOLOR
3899 case XTerm_Color_cursor: 3861 case XTerm_Color_cursor:
3900 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3862 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3901 break; 3863 break;
3905 break; 3867 break;
3906 case XTerm_Color_pointer_bg: 3868 case XTerm_Color_pointer_bg:
3907 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3869 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3908 break; 3870 break;
3909#ifndef NO_BOLD_UNDERLINE_REVERSE 3871#ifndef NO_BOLD_UNDERLINE_REVERSE
3910 case XTerm_Color_BD:
3911 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3912 break;
3913 case XTerm_Color_UL:
3914 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3915 break;
3916 case XTerm_Color_RV: 3872 case XTerm_Color_RV:
3917 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3873 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3874 break;
3875 case Rxvt_Color_BD:
3876 case URxvt_Color_BD:
3877 process_color_seq (op, Color_BD, str, resp);
3878 break;
3879 case Rxvt_Color_UL:
3880 case URxvt_Color_UL:
3881 process_color_seq (op, Color_UL, str, resp);
3918 break; 3882 break;
3919 case URxvt_Color_IT: 3883 case URxvt_Color_IT:
3920 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3884 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3921 break; 3885 break;
3922#endif 3886#endif
3927 if (am_transparent) 3891 if (am_transparent)
3928 want_full_refresh = want_refresh = 1; 3892 want_full_refresh = want_refresh = 1;
3929 break; 3893 break;
3930#endif 3894#endif
3931 3895
3932 case XTerm_Pixmap: 3896 case Rxvt_Pixmap:
3933 if (*str != ';') 3897 if (*str != ';')
3934 { 3898 {
3935#if XPM_BACKGROUND 3899#if XPM_BACKGROUND
3936 scale_pixmap (""); /* reset to default scaling */ 3900 scale_pixmap (""); /* reset to default scaling */
3937 set_bgPixmap (str); /* change pixmap */ 3901 set_bgPixmap (str); /* change pixmap */
3938#endif
3939 scr_touch (true); 3902 scr_touch (true);
3903#endif
3940 } 3904 }
3905
3941 while ((str = strchr (str, ';')) != NULL) 3906 while ((str = strchr (str, ';')) != NULL)
3942 { 3907 {
3943 str++; 3908 str++;
3944#if XPM_BACKGROUND 3909#if XPM_BACKGROUND
3945 changed += scale_pixmap (str); 3910 changed += scale_pixmap (str);
3948 3913
3949 if (changed) 3914 if (changed)
3950 { 3915 {
3951#ifdef XPM_BACKGROUND 3916#ifdef XPM_BACKGROUND
3952 resize_pixmap (); 3917 resize_pixmap ();
3953#endif
3954 scr_touch (true); 3918 scr_touch (true);
3919#endif
3955 } 3920 }
3956 break; 3921 break;
3957 3922
3958 case XTerm_restoreFG: 3923 case Rxvt_restoreFG:
3959 set_window_color (Color_fg, str); 3924 set_window_color (Color_fg, str);
3960 break; 3925 break;
3961 case XTerm_restoreBG: 3926 case Rxvt_restoreBG:
3962 set_window_color (Color_bg, str); 3927 set_window_color (Color_bg, str);
3963 break; 3928 break;
3964 3929
3965 case XTerm_logfile: 3930 case XTerm_logfile:
3966 // TODO, when secure mode? 3931 // TODO, when secure mode?
3967 break; 3932 break;
3968 3933
3969#ifdef MENUBAR
3970 case URxvt_Menu:
3971 if (OPTION (Opt_insecure))
3972 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3973 break;
3974#endif
3975#if 0 3934#if 0
3976 case XTerm_dumpscreen: /* no error notices */ 3935 case Rxvt_dumpscreen: /* no error notices */
3977 { 3936 {
3978 int fd; 3937 int fd;
3979 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3938 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3980 { 3939 {
3981 scr_dump (fd); 3940 scr_dump (fd);
4012 if (query) 3971 if (query)
4013 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); 3972 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp);
4014 else 3973 else
4015 { 3974 {
4016 set_locale (str); 3975 set_locale (str);
4017 pty.set_utf8_mode (enc_utf8); 3976 pty->set_utf8_mode (enc_utf8);
4018 init_xlocale (); 3977 init_xlocale ();
4019 } 3978 }
4020 break; 3979 break;
4021 3980
4022 case URxvt_view_up: 3981 case URxvt_view_up:
4096 { 5, PrivMode_rVideo }, 4055 { 5, PrivMode_rVideo },
4097 { 6, PrivMode_relOrigin }, 4056 { 6, PrivMode_relOrigin },
4098 { 7, PrivMode_Autowrap }, 4057 { 7, PrivMode_Autowrap },
4099 // 8, bi-directional support mode 4058 // 8, bi-directional support mode
4100 { 9, PrivMode_MouseX10 }, 4059 { 9, PrivMode_MouseX10 },
4101#ifdef menuBar_esc
4102 { menuBar_esc, PrivMode_menuBar },
4103#endif
4104 // 18, 19 printing-related 4060 // 18, 19 printing-related
4105 { 25, PrivMode_VisibleCursor }, 4061 { 25, PrivMode_VisibleCursor },
4106#ifdef scrollBar_esc 4062#ifdef scrollBar_esc
4107 { scrollBar_esc, PrivMode_scrollBar }, 4063 { scrollBar_esc, PrivMode_scrollBar },
4108#endif 4064#endif
4155 /* extra handling for values with state unkept */ 4111 /* extra handling for values with state unkept */
4156 switch (arg[i]) 4112 switch (arg[i])
4157 { 4113 {
4158#if ENABLE_STYLES 4114#if ENABLE_STYLES
4159 case 1021: 4115 case 1021:
4160 if (mode) 4116 set_option (Opt_intensityStyles, mode);
4161 SET_OPTION (Opt_intensityStyles);
4162 else
4163 CLR_OPTION (Opt_intensityStyles);
4164 4117
4165 scr_touch (true); 4118 scr_touch (true);
4166 break; 4119 break;
4167#endif 4120#endif
4168 case 1048: /* alternative cursor save */ 4121 case 1048: /* alternative cursor save */
4190 case 3: /* 80/132 */ 4143 case 3: /* 80/132 */
4191 if (priv_modes & PrivMode_132OK) 4144 if (priv_modes & PrivMode_132OK)
4192 set_widthheight (((state ? 132 : 80) * fwidth), height); 4145 set_widthheight (((state ? 132 : 80) * fwidth), height);
4193 break; 4146 break;
4194 case 4: /* smooth scrolling */ 4147 case 4: /* smooth scrolling */
4195 if (!state) 4148 set_option (Opt_jumpScroll, !state);
4196 SET_OPTION (Opt_jumpScroll);
4197 else
4198 CLR_OPTION (Opt_jumpScroll);
4199 break; 4149 break;
4200 case 5: /* reverse video */ 4150 case 5: /* reverse video */
4201 scr_rvideo_mode (state); 4151 scr_rvideo_mode (state);
4202 break; 4152 break;
4203 case 6: /* relative/absolute origins */ 4153 case 6: /* relative/absolute origins */
4209 /* case 8: - auto repeat, can't do on a per window basis */ 4159 /* case 8: - auto repeat, can't do on a per window basis */
4210 case 9: /* X10 mouse reporting */ 4160 case 9: /* X10 mouse reporting */
4211 if (state) /* orthogonal */ 4161 if (state) /* orthogonal */
4212 priv_modes &= ~PrivMode_MouseX11; 4162 priv_modes &= ~PrivMode_MouseX11;
4213 break; 4163 break;
4214#ifdef menuBar_esc
4215 case menuBar_esc:
4216#ifdef MENUBAR
4217 map_menuBar (state);
4218#endif
4219 break;
4220#endif
4221#ifdef scrollBar_esc 4164#ifdef scrollBar_esc
4222 case scrollBar_esc: 4165 case scrollBar_esc:
4223 if (scrollbar_mapping (state)) 4166 if (scrollbar_mapping (state))
4224 { 4167 {
4225 resize_all_windows (0, 0, 0); 4168 resize_all_windows (0, 0, 0);
4244#if 0 4187#if 0
4245 case 1001: 4188 case 1001:
4246 break; /* X11 mouse highlighting */ 4189 break; /* X11 mouse highlighting */
4247#endif 4190#endif
4248 case 1010: /* scroll to bottom on TTY output inhibit */ 4191 case 1010: /* scroll to bottom on TTY output inhibit */
4249 if (!state) 4192 set_option (Opt_scrollTtyOutput, !state);
4250 SET_OPTION (Opt_scrollTtyOutput);
4251 else
4252 CLR_OPTION (Opt_scrollTtyOutput);
4253 break; 4193 break;
4254 case 1011: /* scroll to bottom on key press */ 4194 case 1011: /* scroll to bottom on key press */
4255 if (state) 4195 set_option (Opt_scrollTtyKeypress, state);
4256 SET_OPTION (Opt_scrollTtyKeypress);
4257 else
4258 CLR_OPTION (Opt_scrollTtyKeypress);
4259 break; 4196 break;
4260 case 1047: /* secondary screen w/ clearing last */ 4197 case 1047: /* secondary screen w/ clearing last */
4261 if (OPTION (Opt_secondaryScreen)) 4198 if (OPTION (Opt_secondaryScreen))
4262 if (current_screen != PRIMARY) 4199 if (current_screen != PRIMARY)
4263 scr_erase_screen (2); 4200 scr_erase_screen (2);
4473const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4410const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4474 4411
4475void 4412void
4476rxvt_term::tt_write (const char *data, unsigned int len) 4413rxvt_term::tt_write (const char *data, unsigned int len)
4477{ 4414{
4478 if (pty.pty < 0) 4415 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4479 return; 4416 return;
4480 4417
4418 if (pty->pty < 0)
4419 return;
4420
4481 if (v_buflen == 0) 4421 if (v_buflen == 0)
4482 { 4422 {
4483 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); 4423 ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE));
4484 4424
4485 if ((unsigned int)written == len) 4425 if ((unsigned int)written == len)
4486 return; 4426 return;
4487 4427
4488 data += written; 4428 data += written;
4497 pty_ev.set (EVENT_READ | EVENT_WRITE); 4437 pty_ev.set (EVENT_READ | EVENT_WRITE);
4498} 4438}
4499 4439
4500void rxvt_term::pty_write () 4440void rxvt_term::pty_write ()
4501{ 4441{
4502 int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 4442 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4503 4443
4504 if (written > 0) 4444 if (written > 0)
4505 { 4445 {
4506 v_buflen -= written; 4446 v_buflen -= written;
4507 4447

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines