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.247 by root, Sat Jan 7 20:23:52 2006 UTC vs.
Revision 1.271 by root, Wed Jan 18 17:49:46 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
1317#if defined(CURSOR_BLINK) 1310 // for XQueryPointer
1318 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1319 {
1320 if (hidden_cursor)
1321 {
1322 hidden_cursor = 0;
1323 want_refresh = 1;
1324 }
1325
1326 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1327 }
1328#endif
1329
1330#if defined(POINTER_BLANK)
1331 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1332 {
1333 if (ev.type == MotionNotify
1334 || ev.type == ButtonPress
1335 || ev.type == ButtonRelease)
1336 if (hidden_pointer)
1337 pointer_unblank ();
1338
1339 if (ev.type == KeyPress && hidden_pointer == 0)
1340 pointer_blank ();
1341 }
1342#endif
1343
1344 Window unused_root, unused_child; 1311 Window unused_root, unused_child;
1345 int unused_root_x, unused_root_y; 1312 int unused_root_x, unused_root_y;
1346 unsigned int unused_mask; 1313 unsigned int unused_mask;
1347 1314
1348 switch (ev.type) 1315 switch (ev.type)
1355 1322
1356 break; 1323 break;
1357 1324
1358 case KeyRelease: 1325 case KeyRelease:
1359 { 1326 {
1360#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 1327#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1361 KeySym ks; 1328 KeySym keysym;
1362 1329
1363 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 :/
1364#endif 1331#endif
1365 1332
1366#if ENABLE_FRILLS || ISO_14755 1333#if ENABLE_FRILLS || ISO_14755
1367 // ISO 14755 support 1334 // ISO 14755 support
1368 if (iso14755buf) 1335 if (iso14755buf)
1373# endif 1340# endif
1374# if ISO_14755 1341# if ISO_14755
1375 // iso14755 part 5.2 handling: release time 1342 // iso14755 part 5.2 handling: release time
1376 // first: controls 1343 // first: controls
1377 if ((ev.xkey.state & ControlMask) 1344 if ((ev.xkey.state & ControlMask)
1378 && ((ks >= 0x40 && ks <= 0x5f) 1345 && ((keysym >= 0x40 && keysym <= 0x5f)
1379 || (ks >= 0x61 && ks <= 0x7f))) 1346 || (keysym >= 0x61 && keysym <= 0x7f)))
1380 { 1347 {
1381 iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); 1348 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1382 commit_iso14755 (); 1349 commit_iso14755 ();
1383 return; // case-break; 1350 goto skip_switch;
1384 } 1351 }
1385 1352
1386 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 1353 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1387 if (i[0] == ks) 1354 if (i[0] == keysym)
1388 { 1355 {
1389 iso14755buf = ISO_14755_51 | i[1]; 1356 iso14755buf = ISO_14755_51 | i[1];
1390 commit_iso14755 (); 1357 commit_iso14755 ();
1391 return; // case-break; 1358 goto skip_switch;
1392 } 1359 }
1393 1360
1394 scr_bell (); 1361 scr_bell ();
1395# endif 1362# endif
1396 iso14755buf = 0; 1363 iso14755buf = 0;
1416 iso14755buf = 0; 1383 iso14755buf = 0;
1417 } 1384 }
1418#endif 1385#endif
1419 1386
1420 if (ev.xany.window == vt 1387 if (ev.xany.window == vt
1421 && 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)))
1422 break; 1389 break;
1423 1390
1424#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1391#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1425 if (!(ev.xkey.state & ControlMask)) 1392 if (!(ev.xkey.state & ControlMask))
1426 slip_wheel_ev.stop (); 1393 slip_wheel_ev.stop ();
1427 else if (ks == XK_Control_L || ks == XK_Control_R) 1394 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1428 mouse_slip_wheel_speed = 0; 1395 mouse_slip_wheel_speed = 0;
1429#endif 1396#endif
1430 break; 1397 break;
1431 } 1398 }
1432 1399
1535 { 1502 {
1536 seen_resize = 1; 1503 seen_resize = 1;
1537 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1504 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1538 } 1505 }
1539 1506
1507 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1508
1540#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1509#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1541 if (OPTION (Opt_transparent)) 1510 if (OPTION (Opt_transparent))
1542 check_our_parents (); 1511 check_our_parents ();
1543#endif 1512#endif
1544 } 1513 }
1599 1568
1600 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1569 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1601 scr_expose (ev.xexpose.x, ev.xexpose.y, 1570 scr_expose (ev.xexpose.x, ev.xexpose.y,
1602 ev.xexpose.width, ev.xexpose.height, False); 1571 ev.xexpose.width, ev.xexpose.height, False);
1603 1572
1604 scr_refresh (refresh_type); 1573 want_refresh = 1;
1605 } 1574 }
1606 else 1575 else
1607 { 1576 {
1608 XEvent unused_event; 1577 XEvent unused_event;
1609 1578
1615 if (isScrollbarWindow (ev.xany.window)) 1584 if (isScrollbarWindow (ev.xany.window))
1616 { 1585 {
1617 scrollBar.setIdle (); 1586 scrollBar.setIdle ();
1618 scrollbar_show (0); 1587 scrollbar_show (0);
1619 } 1588 }
1620#ifdef MENUBAR
1621 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1622 menubar_expose ();
1623#endif
1624 1589
1625#ifdef TRANSPARENT 1590#ifdef TRANSPARENT
1626 if (am_transparent && ev.xany.window == parent[0]) 1591 if (am_transparent && ev.xany.window == parent[0])
1627 XClearWindow (disp, ev.xany.window); 1592 XClearWindow (disp, ev.xany.window);
1628#endif 1593#endif
1632 case MotionNotify: 1597 case MotionNotify:
1633#ifdef POINTER_BLANK 1598#ifdef POINTER_BLANK
1634 if (hidden_pointer) 1599 if (hidden_pointer)
1635 pointer_unblank (); 1600 pointer_unblank ();
1636#endif 1601#endif
1637#if MENUBAR
1638 if (isMenuBarWindow (ev.xany.window))
1639 {
1640 menubar_control (ev.xbutton);
1641 break;
1642 }
1643#endif
1644 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1602 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1645 break; 1603 break;
1646 1604
1647 if (ev.xany.window == vt) 1605 if (ev.xany.window == vt)
1648 { 1606 {
1607 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1649 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1608 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1650 ; // nop 1609 ; // nop
1651 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1610 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1652 { 1611 {
1653 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1612 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1654 ; 1613 ;
1736 &unused_root_x, &unused_root_y, 1695 &unused_root_x, &unused_root_y,
1737 &ev.xbutton.x, &ev.xbutton.y, 1696 &ev.xbutton.x, &ev.xbutton.y,
1738 &unused_mask); 1697 &unused_mask);
1739 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1698 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1740 scrollbar_size ()); 1699 scrollbar_size ());
1741 scr_refresh (refresh_type); 1700 want_refresh = 1;
1742 refresh_limit = 0; 1701 refresh_limit = 0;
1743 scrollbar_show (1); 1702 scrollbar_show (1);
1744 } 1703 }
1745 break; 1704 break;
1746 } 1705 }
1706
1707skip_switch: ;
1708
1709#if defined(CURSOR_BLINK)
1710 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1711 {
1712 if (hidden_cursor)
1713 {
1714 hidden_cursor = 0;
1715 want_refresh = 1;
1716 }
1717
1718 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1719 }
1720#endif
1721
1722#if defined(POINTER_BLANK)
1723 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1724 {
1725 if (ev.type == MotionNotify
1726 || ev.type == ButtonPress
1727 || ev.type == ButtonRelease)
1728 if (hidden_pointer)
1729 pointer_unblank ();
1730
1731 if (ev.type == KeyPress && hidden_pointer == 0)
1732 pointer_blank ();
1733 }
1734#endif
1747} 1735}
1748 1736
1749void 1737void
1750rxvt_term::focus_in () 1738rxvt_term::focus_in ()
1751{ 1739{
1817 1805
1818#if TRANSPARENT 1806#if TRANSPARENT
1819void 1807void
1820rxvt_term::rootwin_cb (XEvent &ev) 1808rxvt_term::rootwin_cb (XEvent &ev)
1821{ 1809{
1822 SET_R (this); 1810 make_current ();
1823 SET_LOCALE (locale);
1824 1811
1825 switch (ev.type) 1812 switch (ev.type)
1826 { 1813 {
1827 case PropertyNotify: 1814 case PropertyNotify:
1828 /* 1815 /*
1919#else 1906#else
1920 selection.rect = false; 1907 selection.rect = false;
1921#endif 1908#endif
1922 1909
1923 /* allow shift+left click to extend selection */ 1910 /* allow shift+left click to extend selection */
1924 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1911 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1925 { 1912 {
1926 if (MEvent.button == Button1 && clickintime) 1913 if (MEvent.button == Button1 && clickintime)
1927 selection_rotate (ev.x, ev.y); 1914 selection_rotate (ev.x, ev.y);
1928 else 1915 else
1929 selection_extend (ev.x, ev.y, 1); 1916 selection_extend (ev.x, ev.y, 1);
2097 } 2084 }
2098 } 2085 }
2099 2086
2100 return; 2087 return;
2101 } 2088 }
2102
2103#if MENUBAR
2104 /*
2105 * Menubar window processing of button press
2106 */
2107 if (isMenuBarWindow (ev.window))
2108 menubar_control (ev);
2109#endif
2110} 2089}
2111 2090
2112void 2091void
2113rxvt_term::button_release (XButtonEvent &ev) 2092rxvt_term::button_release (XButtonEvent &ev)
2114{ 2093{
2120 2099
2121 if (scrollbar_isUpDn ()) 2100 if (scrollbar_isUpDn ())
2122 { 2101 {
2123 scrollBar.setIdle (); 2102 scrollBar.setIdle ();
2124 scrollbar_show (0); 2103 scrollbar_show (0);
2125#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2126 refresh_type &= ~SMOOTH_REFRESH;
2127#endif
2128 } 2104 }
2129 2105
2130#ifdef SELECTION_SCROLLING 2106#ifdef SELECTION_SCROLLING
2131 if (sel_scroll_ev.active) 2107 if (sel_scroll_ev.active)
2132 sel_scroll_ev.stop(); 2108 sel_scroll_ev.stop();
2213 slip_wheel_ev.start (); 2189 slip_wheel_ev.start ();
2214 } 2190 }
2215 else 2191 else
2216 { 2192 {
2217# endif 2193# endif
2218# ifdef JUMP_MOUSE_WHEEL
2219 scr_page (v, i); 2194 scr_page (v, i);
2220 scr_refresh (SMOOTH_REFRESH);
2221 scrollbar_show (1); 2195 scrollbar_show (1);
2222# else
2223 while (i--)
2224 {
2225 scr_page (v, 1);
2226 scr_refresh (SMOOTH_REFRESH);
2227 scrollbar_show (1);
2228 }
2229# endif
2230# ifdef MOUSE_SLIP_WHEELING 2196# ifdef MOUSE_SLIP_WHEELING
2231 } 2197 }
2232#endif 2198# endif
2233 } 2199 }
2234 break; 2200 break;
2235#endif 2201#endif
2236 } 2202 }
2237 } 2203 }
2238#ifdef MENUBAR
2239 else if (isMenuBarWindow (ev.window))
2240 menubar_control (ev);
2241#endif
2242} 2204}
2243 2205
2244#ifdef TRANSPARENT 2206#ifdef TRANSPARENT
2245#if TINTING 2207#if TINTING
2246/* taken from aterm-0.4.2 */ 2208/* taken from aterm-0.4.2 */
2789 } 2751 }
2790 2752
2791 // scr_add_lines only works for nlines <= nrow - 1. 2753 // scr_add_lines only works for nlines <= nrow - 1.
2792 if (nlines >= nrow - 1) 2754 if (nlines >= nrow - 1)
2793 { 2755 {
2756 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2794 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))))
2795 scr_add_lines (buf, str - buf, nlines); 2758 scr_add_lines (buf, str - buf, nlines);
2796 2759
2797 nlines = 0; 2760 nlines = 0;
2798 str = buf; 2761 str = buf;
2799 eol = str + min (ncol, UBUFSIZ); 2762 eol = str + min (ncol, UBUFSIZ);
2814 2777
2815 seq_begin = cmdbuf_ptr; 2778 seq_begin = cmdbuf_ptr;
2816 ch = next_char (); 2779 ch = next_char ();
2817 } 2780 }
2818 2781
2782 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2819 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))))
2820 scr_add_lines (buf, str - buf, nlines); 2784 scr_add_lines (buf, str - buf, nlines);
2821 2785
2822 /* 2786 /*
2823 * 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
2824 * 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.
2830 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2794 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2831 refresh_limit++; 2795 refresh_limit++;
2832 else 2796 else
2833 { 2797 {
2834 flag = true; 2798 flag = true;
2835 scr_refresh (refresh_type); 2799 scr_refresh ();
2836 flush_ev.stop (); 2800 want_refresh = 1;
2837 } 2801 }
2838 } 2802 }
2839 2803
2840 } 2804 }
2841 else 2805 else
3802 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3766 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3803 */ 3767 */
3804void 3768void
3805rxvt_term::process_xterm_seq (int op, const char *str, char resp) 3769rxvt_term::process_xterm_seq (int op, const char *str, char resp)
3806{ 3770{
3807 int changed = 0;
3808 int color; 3771 int color;
3809 char *buf, *name; 3772 char *buf, *name;
3810 bool query = str[0] == '?' && !str[1]; 3773 bool query = str[0] == '?' && !str[1];
3811 int saveop = op; 3774 int saveop = op;
3812 dDisp; 3775 dDisp;
3867 { 3830 {
3868 if ((name = strchr (buf, ';')) == NULL) 3831 if ((name = strchr (buf, ';')) == NULL)
3869 break; 3832 break;
3870 3833
3871 *name++ = '\0'; 3834 *name++ = '\0';
3872 color = atoi (buf); 3835 color = atoi (buf) + minCOLOR;
3873 3836
3874 if (color < 0 || color >= TOTAL_COLORS) 3837 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3875 break; 3838 break;
3876 3839
3877 if ((buf = strchr (name, ';')) != NULL) 3840 if ((buf = strchr (name, ';')) != NULL)
3878 *buf++ = '\0'; 3841 *buf++ = '\0';
3879 3842
3880 if (name[0] == '?' && !name[1]) 3843 if (name[0] == '?' && !name[1])
3881 { 3844 {
3882 unsigned short r, g, b; 3845 unsigned short r, g, b;
3883 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3846 pix_colors_focused[color].get (display, r, g, b);
3884 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3847 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3885 } 3848 }
3886 else 3849 else
3887 set_window_color (color + minCOLOR, name); 3850 set_window_color (color, name);
3888 } 3851 }
3889 break; 3852 break;
3890 case XTerm_Color00: 3853 case XTerm_Color00:
3891 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3854 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3892 break; 3855 break;
3893 case XTerm_Color01: 3856 case XTerm_Color01:
3894 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3857 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3895 break; 3858 break;
3896#ifndef NO_CURSORCOLOR 3859#ifndef NO_CURSORCOLOR
3897 case XTerm_Color_cursor: 3860 case XTerm_Color_cursor:
3898 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3861 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3899 break; 3862 break;
3903 break; 3866 break;
3904 case XTerm_Color_pointer_bg: 3867 case XTerm_Color_pointer_bg:
3905 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3868 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3906 break; 3869 break;
3907#ifndef NO_BOLD_UNDERLINE_REVERSE 3870#ifndef NO_BOLD_UNDERLINE_REVERSE
3908 case XTerm_Color_BD:
3909 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3910 break;
3911 case XTerm_Color_UL:
3912 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3913 break;
3914 case XTerm_Color_RV: 3871 case XTerm_Color_RV:
3915 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3872 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3873 break;
3874 case Rxvt_Color_BD:
3875 case URxvt_Color_BD:
3876 process_color_seq (op, Color_BD, str, resp);
3877 break;
3878 case Rxvt_Color_UL:
3879 case URxvt_Color_UL:
3880 process_color_seq (op, Color_UL, str, resp);
3916 break; 3881 break;
3917 case URxvt_Color_IT: 3882 case URxvt_Color_IT:
3918 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3883 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3919 break; 3884 break;
3920#endif 3885#endif
3925 if (am_transparent) 3890 if (am_transparent)
3926 want_full_refresh = want_refresh = 1; 3891 want_full_refresh = want_refresh = 1;
3927 break; 3892 break;
3928#endif 3893#endif
3929 3894
3930 case XTerm_Pixmap: 3895 case Rxvt_Pixmap:
3896 {
3931 if (*str != ';') 3897 if (*str != ';')
3932 { 3898 {
3933#if XPM_BACKGROUND 3899#if XPM_BACKGROUND
3934 scale_pixmap (""); /* reset to default scaling */ 3900 scale_pixmap (""); /* reset to default scaling */
3935 set_bgPixmap (str); /* change pixmap */ 3901 set_bgPixmap (str); /* change pixmap */
3936#endif
3937 scr_touch (true); 3902 scr_touch (true);
3903#endif
3938 } 3904 }
3905
3906 int changed = 0;
3907
3939 while ((str = strchr (str, ';')) != NULL) 3908 while ((str = strchr (str, ';')) != NULL)
3940 { 3909 {
3941 str++; 3910 str++;
3942#if XPM_BACKGROUND 3911#if XPM_BACKGROUND
3943 changed += scale_pixmap (str); 3912 changed += scale_pixmap (str);
3944#endif 3913#endif
3945 } 3914 }
3946 3915
3947 if (changed) 3916 if (changed)
3948 { 3917 {
3949#ifdef XPM_BACKGROUND 3918#ifdef XPM_BACKGROUND
3950 resize_pixmap (); 3919 resize_pixmap ();
3951#endif
3952 scr_touch (true); 3920 scr_touch (true);
3921#endif
3953 } 3922 }
3923 }
3954 break; 3924 break;
3955 3925
3956 case XTerm_restoreFG: 3926 case Rxvt_restoreFG:
3957 set_window_color (Color_fg, str); 3927 set_window_color (Color_fg, str);
3958 break; 3928 break;
3959 case XTerm_restoreBG: 3929 case Rxvt_restoreBG:
3960 set_window_color (Color_bg, str); 3930 set_window_color (Color_bg, str);
3961 break; 3931 break;
3962 3932
3963 case XTerm_logfile: 3933 case XTerm_logfile:
3964 // TODO, when secure mode? 3934 // TODO, when secure mode?
3965 break; 3935 break;
3966 3936
3967#ifdef MENUBAR
3968 case URxvt_Menu:
3969 if (OPTION (Opt_insecure))
3970 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3971 break;
3972#endif
3973#if 0 3937#if 0
3974 case XTerm_dumpscreen: /* no error notices */ 3938 case Rxvt_dumpscreen: /* no error notices */
3975 { 3939 {
3976 int fd; 3940 int fd;
3977 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3941 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3978 { 3942 {
3979 scr_dump (fd); 3943 scr_dump (fd);
4010 if (query) 3974 if (query)
4011 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); 3975 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp);
4012 else 3976 else
4013 { 3977 {
4014 set_locale (str); 3978 set_locale (str);
4015 pty.set_utf8_mode (enc_utf8); 3979 pty->set_utf8_mode (enc_utf8);
4016 init_xlocale (); 3980 init_xlocale ();
4017 } 3981 }
4018 break; 3982 break;
4019 3983
4020 case URxvt_view_up: 3984 case URxvt_view_up:
4094 { 5, PrivMode_rVideo }, 4058 { 5, PrivMode_rVideo },
4095 { 6, PrivMode_relOrigin }, 4059 { 6, PrivMode_relOrigin },
4096 { 7, PrivMode_Autowrap }, 4060 { 7, PrivMode_Autowrap },
4097 // 8, bi-directional support mode 4061 // 8, bi-directional support mode
4098 { 9, PrivMode_MouseX10 }, 4062 { 9, PrivMode_MouseX10 },
4099#ifdef menuBar_esc
4100 { menuBar_esc, PrivMode_menuBar },
4101#endif
4102 // 18, 19 printing-related 4063 // 18, 19 printing-related
4103 { 25, PrivMode_VisibleCursor }, 4064 { 25, PrivMode_VisibleCursor },
4104#ifdef scrollBar_esc 4065#ifdef scrollBar_esc
4105 { scrollBar_esc, PrivMode_scrollBar }, 4066 { scrollBar_esc, PrivMode_scrollBar },
4106#endif 4067#endif
4153 /* extra handling for values with state unkept */ 4114 /* extra handling for values with state unkept */
4154 switch (arg[i]) 4115 switch (arg[i])
4155 { 4116 {
4156#if ENABLE_STYLES 4117#if ENABLE_STYLES
4157 case 1021: 4118 case 1021:
4158 if (mode) 4119 set_option (Opt_intensityStyles, mode);
4159 SET_OPTION (Opt_intensityStyles);
4160 else
4161 CLR_OPTION (Opt_intensityStyles);
4162 4120
4163 scr_touch (true); 4121 scr_touch (true);
4164 break; 4122 break;
4165#endif 4123#endif
4166 case 1048: /* alternative cursor save */ 4124 case 1048: /* alternative cursor save */
4188 case 3: /* 80/132 */ 4146 case 3: /* 80/132 */
4189 if (priv_modes & PrivMode_132OK) 4147 if (priv_modes & PrivMode_132OK)
4190 set_widthheight (((state ? 132 : 80) * fwidth), height); 4148 set_widthheight (((state ? 132 : 80) * fwidth), height);
4191 break; 4149 break;
4192 case 4: /* smooth scrolling */ 4150 case 4: /* smooth scrolling */
4193 if (!state) 4151 set_option (Opt_jumpScroll, !state);
4194 SET_OPTION (Opt_jumpScroll);
4195 else
4196 CLR_OPTION (Opt_jumpScroll);
4197 break; 4152 break;
4198 case 5: /* reverse video */ 4153 case 5: /* reverse video */
4199 scr_rvideo_mode (state); 4154 scr_rvideo_mode (state);
4200 break; 4155 break;
4201 case 6: /* relative/absolute origins */ 4156 case 6: /* relative/absolute origins */
4207 /* case 8: - auto repeat, can't do on a per window basis */ 4162 /* case 8: - auto repeat, can't do on a per window basis */
4208 case 9: /* X10 mouse reporting */ 4163 case 9: /* X10 mouse reporting */
4209 if (state) /* orthogonal */ 4164 if (state) /* orthogonal */
4210 priv_modes &= ~PrivMode_MouseX11; 4165 priv_modes &= ~PrivMode_MouseX11;
4211 break; 4166 break;
4212#ifdef menuBar_esc
4213 case menuBar_esc:
4214#ifdef MENUBAR
4215 map_menuBar (state);
4216#endif
4217 break;
4218#endif
4219#ifdef scrollBar_esc 4167#ifdef scrollBar_esc
4220 case scrollBar_esc: 4168 case scrollBar_esc:
4221 if (scrollbar_mapping (state)) 4169 if (scrollbar_mapping (state))
4222 { 4170 {
4223 resize_all_windows (0, 0, 0); 4171 resize_all_windows (0, 0, 0);
4242#if 0 4190#if 0
4243 case 1001: 4191 case 1001:
4244 break; /* X11 mouse highlighting */ 4192 break; /* X11 mouse highlighting */
4245#endif 4193#endif
4246 case 1010: /* scroll to bottom on TTY output inhibit */ 4194 case 1010: /* scroll to bottom on TTY output inhibit */
4247 if (!state) 4195 set_option (Opt_scrollTtyOutput, !state);
4248 SET_OPTION (Opt_scrollTtyOutput);
4249 else
4250 CLR_OPTION (Opt_scrollTtyOutput);
4251 break; 4196 break;
4252 case 1011: /* scroll to bottom on key press */ 4197 case 1011: /* scroll to bottom on key press */
4253 if (state) 4198 set_option (Opt_scrollTtyKeypress, state);
4254 SET_OPTION (Opt_scrollTtyKeypress);
4255 else
4256 CLR_OPTION (Opt_scrollTtyKeypress);
4257 break; 4199 break;
4258 case 1047: /* secondary screen w/ clearing last */ 4200 case 1047: /* secondary screen w/ clearing last */
4259 if (OPTION (Opt_secondaryScreen)) 4201 if (OPTION (Opt_secondaryScreen))
4260 if (current_screen != PRIMARY) 4202 if (current_screen != PRIMARY)
4261 scr_erase_screen (2); 4203 scr_erase_screen (2);
4471const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4413const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4472 4414
4473void 4415void
4474rxvt_term::tt_write (const char *data, unsigned int len) 4416rxvt_term::tt_write (const char *data, unsigned int len)
4475{ 4417{
4476 if (pty.pty < 0) 4418 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4477 return; 4419 return;
4478 4420
4421 if (pty->pty < 0)
4422 return;
4423
4479 if (v_buflen == 0) 4424 if (v_buflen == 0)
4480 { 4425 {
4481 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); 4426 ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE));
4482 4427
4483 if ((unsigned int)written == len) 4428 if ((unsigned int)written == len)
4484 return; 4429 return;
4485 4430
4486 data += written; 4431 data += written;
4495 pty_ev.set (EVENT_READ | EVENT_WRITE); 4440 pty_ev.set (EVENT_READ | EVENT_WRITE);
4496} 4441}
4497 4442
4498void rxvt_term::pty_write () 4443void rxvt_term::pty_write ()
4499{ 4444{
4500 int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 4445 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4501 4446
4502 if (written > 0) 4447 if (written > 0)
4503 { 4448 {
4504 v_buflen -= written; 4449 v_buflen -= written;
4505 4450

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines