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.274 by root, Fri Jan 20 10:27:08 2006 UTC

64 64
65/*----------------------------------------------------------------------*/ 65/*----------------------------------------------------------------------*/
66 66
67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
68 68
69// exception thrown when the command parser runs out of input data
70class out_of_input { } out_of_input;
71
72#if ENABLE_FRILLS || ISO_14755 69#if ENABLE_FRILLS || ISO_14755
73 70
74#define ISO_14755_STARTED 0x80000000UL 71#define ISO_14755_STARTED 0x80000000UL
75#define ISO_14755_51 0x40000000UL // basic (section 5.1) 72#define ISO_14755_51 0x40000000UL // basic (section 5.1)
76#define ISO_14755_52 0x20000000UL // keycap (section 5.2) 73#define ISO_14755_52 0x20000000UL // keycap (section 5.2)
147 || !IN_RANGE_EXC (y, 0, nrow)) 144 || !IN_RANGE_EXC (y, 0, nrow))
148 return; 145 return;
149 146
150 for (;;) 147 for (;;)
151 { 148 {
152 const line_t &l = ROW(y - view_start); 149 const line_t &l = ROW(y + view_start);
153 150
154 text_t t = l.t[x]; 151 text_t t = l.t[x];
155 152
156 if (t != NOCHAR || !x) 153 if (t != NOCHAR || !x)
157 { 154 {
443 scr_move_to (0, 1); 440 scr_move_to (0, 1);
444 return; 441 return;
445 } 442 }
446 else if (keysym == XK_End) 443 else if (keysym == XK_End)
447 { 444 {
448 scr_move_to (1, 0); 445 scr_move_to (1, 1);
449 return; 446 return;
450 } 447 }
451 } 448 }
452#endif 449#endif
453 } 450 }
464 { 461 {
465 switch (keysym) 462 switch (keysym)
466 { 463 {
467 /* normal XTerm key bindings */ 464 /* normal XTerm key bindings */
468 case XK_Insert: /* Shift+Insert = paste mouse selection */ 465 case XK_Insert: /* Shift+Insert = paste mouse selection */
469 selection_request (ev.time, 0, 0); 466 selection_request (ev.time, Sel_Primary);
470 return; 467 return;
471#if TODO 468#if TODO
472 /* rxvt extras */ 469 /* rxvt extras */
473 case XK_KP_Add: /* Shift+KP_Add = bigger font */ 470 case XK_KP_Add: /* Shift+KP_Add = bigger font */
474 change_font (FONT_UP); 471 change_font (FONT_UP);
867#endif 864#endif
868 /* nil */ ; 865 /* nil */ ;
869 } 866 }
870 } 867 }
871 868
872 if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STR_LEN, kbuf, len, DT_END))) 869 if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END)))
873 return; 870 return;
874 871
875 if (len <= 0) 872 if (len <= 0)
876 return; /* not mapped */ 873 return; /* not mapped */
877 874
919#endif /* DEBUG_CMD */ 916#endif /* DEBUG_CMD */
920 tt_write (kbuf, (unsigned int)len); 917 tt_write (kbuf, (unsigned int)len);
921} 918}
922/*}}} */ 919/*}}} */
923 920
924#if MENUBAR_MAX || defined (KEYSYM_RESOURCE) 921#if defined (KEYSYM_RESOURCE)
925/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */
926/* attempt to `write' count to the input buffer */
927unsigned int 922unsigned int
928rxvt_term::cmd_write (const char *str, unsigned int count) 923rxvt_term::cmd_write (const char *str, unsigned int count)
929{ 924{
930 unsigned int n, s; 925 unsigned int n, s;
931 926
972 967
973 if (want_refresh) 968 if (want_refresh)
974 { 969 {
975 if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) 970 if (SHOULD_INVOKE (HOOK_LINE_UPDATE))
976 { 971 {
977 int row = -view_start; 972 int row = view_start;
973 int end_row = row + nrow;
978 974
979 while (row > -nsaved && ROW (row - 1).is_longer ()) 975 while (row > top_row && ROW (row - 1).is_longer ())
980 --row; 976 --row;
981 977
982 while (row < -view_start + nrow) 978 do
983 { 979 {
984 int start_row = row; 980 int start_row = row;
985 line_t *l; 981 line_t *l;
986 982
987 do 983 do
988 { 984 {
989 l = &ROW (row); 985 l = &ROW (row++);
990 986
991 if (!(l->f & LINE_FILTERED)) 987 if (!(l->f & LINE_FILTERED))
992 { 988 {
993 // line not filtered, mark it as filtered 989 // line not filtered, mark it as filtered
994 l->f |= LINE_FILTERED; 990 l->f |= LINE_FILTERED;
995 while (l->is_longer ()) 991 while (l->is_longer ())
996 { 992 {
997 l = &ROW (++row); 993 l = &ROW (row++);
998 l->f |= LINE_FILTERED; 994 l->f |= LINE_FILTERED;
999 } 995 }
1000 996
1001 // and filter it 997 // and filter it
1002 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); 998 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END));
1003 999
1004 break; 1000 break;
1005 } 1001 }
1006 } 1002 }
1007 while (l->is_longer ()); 1003 while (l->is_longer () && row < end_row);
1008
1009 row++;
1010 } 1004 }
1005 while (row < end_row);
1011 1006 }
1012 }
1013 1007
1014 scr_refresh (refresh_type); 1008 scr_refresh ();
1015 scrollbar_show (1); 1009 scrollbar_show (1);
1016#ifdef USE_XIM 1010#ifdef USE_XIM
1017 IMSendSpot (); 1011 IMSendSpot ();
1018#endif 1012#endif
1019 } 1013 }
1022} 1016}
1023 1017
1024void 1018void
1025rxvt_term::check_cb (check_watcher &w) 1019rxvt_term::check_cb (check_watcher &w)
1026{ 1020{
1027 SET_R (this); 1021 make_current ();
1028 SET_LOCALE (locale);
1029 1022
1030 display->flush (); 1023 display->flush ();
1031 1024
1032 if (want_refresh && !flush_ev.active) 1025 if (want_refresh && !flush_ev.active)
1033 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally 1026 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
1034} 1027}
1035 1028
1036void 1029void
1037rxvt_term::flush_cb (time_watcher &w) 1030rxvt_term::flush_cb (time_watcher &w)
1038{ 1031{
1039 SET_R (this); 1032 make_current ();
1040 SET_LOCALE (locale);
1041 1033
1042 refresh_limit = 1; 1034 refresh_limit = 1;
1043 refresh_count = 0; 1035 refresh_count = 0;
1044 flush (); 1036 flush ();
1045} 1037}
1049rxvt_term::cursor_blink_cb (time_watcher &w) 1041rxvt_term::cursor_blink_cb (time_watcher &w)
1050{ 1042{
1051 hidden_cursor = !hidden_cursor; 1043 hidden_cursor = !hidden_cursor;
1052 want_refresh = 1; 1044 want_refresh = 1;
1053 1045
1054 w.start (w.at + BLINK_INTERVAL); 1046 w.start (w.at + CURSOR_BLINK_INTERVAL);
1055} 1047}
1056#endif 1048#endif
1057 1049
1058#ifdef TEXT_BLINK 1050#ifdef TEXT_BLINK
1059void 1051void
1073rxvt_term::cont_scroll_cb (time_watcher &w) 1065rxvt_term::cont_scroll_cb (time_watcher &w)
1074{ 1066{
1075 if ((scrollbar_isUp() || scrollbar_isDn()) && 1067 if ((scrollbar_isUp() || scrollbar_isDn()) &&
1076 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1068 scr_page (scrollbar_isUp() ? UP : DN, 1))
1077 { 1069 {
1078 refresh_type |= SMOOTH_REFRESH;
1079 want_refresh = 1; 1070 want_refresh = 1;
1080 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1071 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1081 } 1072 }
1082} 1073}
1083#endif 1074#endif
1087rxvt_term::sel_scroll_cb (time_watcher &w) 1078rxvt_term::sel_scroll_cb (time_watcher &w)
1088{ 1079{
1089 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1080 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1090 { 1081 {
1091 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1082 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1092 refresh_type |= SMOOTH_REFRESH;
1093 want_refresh = 1; 1083 want_refresh = 1;
1094 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1084 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1095 } 1085 }
1096} 1086}
1097#endif 1087#endif
1102{ 1092{
1103 if (mouse_slip_wheel_speed == 0 1093 if (mouse_slip_wheel_speed == 0
1104 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) 1094 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1105 : scr_page (UP, mouse_slip_wheel_speed)) 1095 : scr_page (UP, mouse_slip_wheel_speed))
1106 { 1096 {
1107 if (view_start == nsaved || 1097 if (view_start == top_row || view_start == 0)
1108 view_start == 0)
1109 mouse_slip_wheel_speed = 0; 1098 mouse_slip_wheel_speed = 0;
1110 1099
1111 refresh_type |= SMOOTH_REFRESH;
1112 want_refresh = 1; 1100 want_refresh = 1;
1113 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1101 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1114 } 1102 }
1115} 1103}
1116#endif 1104#endif
1146 1134
1147 memmove (cmdbuf_base, cmdbuf_ptr, n); 1135 memmove (cmdbuf_base, cmdbuf_ptr, n);
1148 cmdbuf_ptr = cmdbuf_base; 1136 cmdbuf_ptr = cmdbuf_base;
1149 cmdbuf_endp = cmdbuf_ptr + n; 1137 cmdbuf_endp = cmdbuf_ptr + n;
1150 1138
1151 ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); 1139 ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n);
1152 1140
1153 if (r > 0) 1141 if (r > 0)
1154 { 1142 {
1155 cmdbuf_endp += r; 1143 cmdbuf_endp += r;
1156 return true; 1144 return true;
1174} 1162}
1175 1163
1176void 1164void
1177rxvt_term::pty_cb (io_watcher &w, short revents) 1165rxvt_term::pty_cb (io_watcher &w, short revents)
1178{ 1166{
1179 SET_R (this); 1167 make_current ();
1180 SET_LOCALE (locale);
1181 1168
1182 if (revents & EVENT_READ) 1169 if (revents & EVENT_READ)
1183 // loop, but don't allow a single term to monopolize us 1170 // loop, but don't allow a single term to monopolize us
1184 while (pty_fill ()) 1171 while (pty_fill ())
1185 if (cmd_parse ()) 1172 if (cmd_parse ())
1217} 1204}
1218 1205
1219void 1206void
1220rxvt_term::pointer_cb (time_watcher &w) 1207rxvt_term::pointer_cb (time_watcher &w)
1221{ 1208{
1222 SET_R (this); 1209 make_current ();
1223 SET_LOCALE (locale);
1224 1210
1225 pointer_blank (); 1211 pointer_blank ();
1226} 1212}
1227#endif 1213#endif
1228 1214
1307 1293
1308/*{{{ process an X event */ 1294/*{{{ process an X event */
1309void 1295void
1310rxvt_term::x_cb (XEvent &ev) 1296rxvt_term::x_cb (XEvent &ev)
1311{ 1297{
1298 make_current ();
1299
1312 dDisp; 1300 dDisp;
1313 1301
1314 SET_R (this); 1302 if (ev.xany.window == vt
1315 SET_LOCALE (locale); 1303 && SHOULD_INVOKE (HOOK_X_EVENT)
1304 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1305 return;
1316 1306
1317#if defined(CURSOR_BLINK) 1307 // 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; 1308 Window unused_root, unused_child;
1345 int unused_root_x, unused_root_y; 1309 int unused_root_x, unused_root_y;
1346 unsigned int unused_mask; 1310 unsigned int unused_mask;
1347 1311
1348 switch (ev.type) 1312 switch (ev.type)
1355 1319
1356 break; 1320 break;
1357 1321
1358 case KeyRelease: 1322 case KeyRelease:
1359 { 1323 {
1360#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 1324#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1361 KeySym ks; 1325 KeySym keysym;
1362 1326
1363 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ 1327 keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1364#endif 1328#endif
1365 1329
1366#if ENABLE_FRILLS || ISO_14755 1330#if ENABLE_FRILLS || ISO_14755
1367 // ISO 14755 support 1331 // ISO 14755 support
1368 if (iso14755buf) 1332 if (iso14755buf)
1373# endif 1337# endif
1374# if ISO_14755 1338# if ISO_14755
1375 // iso14755 part 5.2 handling: release time 1339 // iso14755 part 5.2 handling: release time
1376 // first: controls 1340 // first: controls
1377 if ((ev.xkey.state & ControlMask) 1341 if ((ev.xkey.state & ControlMask)
1378 && ((ks >= 0x40 && ks <= 0x5f) 1342 && ((keysym >= 0x40 && keysym <= 0x5f)
1379 || (ks >= 0x61 && ks <= 0x7f))) 1343 || (keysym >= 0x61 && keysym <= 0x7f)))
1380 { 1344 {
1381 iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); 1345 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1382 commit_iso14755 (); 1346 commit_iso14755 ();
1383 return; // case-break; 1347 goto skip_switch;
1384 } 1348 }
1385 1349
1386 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 1350 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1387 if (i[0] == ks) 1351 if (i[0] == keysym)
1388 { 1352 {
1389 iso14755buf = ISO_14755_51 | i[1]; 1353 iso14755buf = ISO_14755_51 | i[1];
1390 commit_iso14755 (); 1354 commit_iso14755 ();
1391 return; // case-break; 1355 goto skip_switch;
1392 } 1356 }
1393 1357
1394 scr_bell (); 1358 scr_bell ();
1395# endif 1359# endif
1396 iso14755buf = 0; 1360 iso14755buf = 0;
1416 iso14755buf = 0; 1380 iso14755buf = 0;
1417 } 1381 }
1418#endif 1382#endif
1419 1383
1420 if (ev.xany.window == vt 1384 if (ev.xany.window == vt
1421 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) 1385 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1422 break; 1386 break;
1423 1387
1424#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1388#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1425 if (!(ev.xkey.state & ControlMask)) 1389 if (!(ev.xkey.state & ControlMask))
1426 slip_wheel_ev.stop (); 1390 slip_wheel_ev.stop ();
1427 else if (ks == XK_Control_L || ks == XK_Control_R) 1391 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1428 mouse_slip_wheel_speed = 0; 1392 mouse_slip_wheel_speed = 0;
1429#endif 1393#endif
1430 break; 1394 break;
1431 } 1395 }
1432 1396
1535 { 1499 {
1536 seen_resize = 1; 1500 seen_resize = 1;
1537 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1501 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1538 } 1502 }
1539 1503
1504 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1505
1540#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1506#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1541 if (OPTION (Opt_transparent)) 1507 if (OPTION (Opt_transparent))
1542 check_our_parents (); 1508 check_our_parents ();
1543#endif 1509#endif
1544 } 1510 }
1599 1565
1600 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1566 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1601 scr_expose (ev.xexpose.x, ev.xexpose.y, 1567 scr_expose (ev.xexpose.x, ev.xexpose.y,
1602 ev.xexpose.width, ev.xexpose.height, False); 1568 ev.xexpose.width, ev.xexpose.height, False);
1603 1569
1604 scr_refresh (refresh_type); 1570 want_refresh = 1;
1605 } 1571 }
1606 else 1572 else
1607 { 1573 {
1608 XEvent unused_event; 1574 XEvent unused_event;
1609 1575
1615 if (isScrollbarWindow (ev.xany.window)) 1581 if (isScrollbarWindow (ev.xany.window))
1616 { 1582 {
1617 scrollBar.setIdle (); 1583 scrollBar.setIdle ();
1618 scrollbar_show (0); 1584 scrollbar_show (0);
1619 } 1585 }
1620#ifdef MENUBAR
1621 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1622 menubar_expose ();
1623#endif
1624 1586
1625#ifdef TRANSPARENT 1587#ifdef TRANSPARENT
1626 if (am_transparent && ev.xany.window == parent[0]) 1588 if (am_transparent && ev.xany.window == parent[0])
1627 XClearWindow (disp, ev.xany.window); 1589 XClearWindow (disp, ev.xany.window);
1628#endif 1590#endif
1632 case MotionNotify: 1594 case MotionNotify:
1633#ifdef POINTER_BLANK 1595#ifdef POINTER_BLANK
1634 if (hidden_pointer) 1596 if (hidden_pointer)
1635 pointer_unblank (); 1597 pointer_unblank ();
1636#endif 1598#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) 1599 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1645 break; 1600 break;
1646 1601
1647 if (ev.xany.window == vt) 1602 if (ev.xany.window == vt)
1648 { 1603 {
1604 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1649 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1605 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1650 ; // nop 1606 ; // nop
1651 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1607 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1652 { 1608 {
1653 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1609 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1654 ; 1610 ;
1736 &unused_root_x, &unused_root_y, 1692 &unused_root_x, &unused_root_y,
1737 &ev.xbutton.x, &ev.xbutton.y, 1693 &ev.xbutton.x, &ev.xbutton.y,
1738 &unused_mask); 1694 &unused_mask);
1739 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1695 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1740 scrollbar_size ()); 1696 scrollbar_size ());
1741 scr_refresh (refresh_type); 1697 want_refresh = 1;
1742 refresh_limit = 0; 1698 refresh_limit = 0;
1743 scrollbar_show (1); 1699 scrollbar_show (1);
1744 } 1700 }
1745 break; 1701 break;
1746 } 1702 }
1703
1704skip_switch: ;
1705
1706#if defined(CURSOR_BLINK)
1707 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1708 {
1709 if (hidden_cursor)
1710 {
1711 hidden_cursor = 0;
1712 want_refresh = 1;
1713 }
1714
1715 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1716 }
1717#endif
1718
1719#if defined(POINTER_BLANK)
1720 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1721 {
1722 if (ev.type == MotionNotify
1723 || ev.type == ButtonPress
1724 || ev.type == ButtonRelease)
1725 if (hidden_pointer)
1726 pointer_unblank ();
1727
1728 if (ev.type == KeyPress && hidden_pointer == 0)
1729 pointer_blank ();
1730 }
1731#endif
1747} 1732}
1748 1733
1749void 1734void
1750rxvt_term::focus_in () 1735rxvt_term::focus_in ()
1751{ 1736{
1763 XSetICFocus (Input_Context); 1748 XSetICFocus (Input_Context);
1764 } 1749 }
1765#endif 1750#endif
1766#if CURSOR_BLINK 1751#if CURSOR_BLINK
1767 if (OPTION (Opt_cursorBlink)) 1752 if (OPTION (Opt_cursorBlink))
1768 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1753 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1769#endif 1754#endif
1770#if OFF_FOCUS_FADING 1755#if OFF_FOCUS_FADING
1771 if (rs[Rs_fade]) 1756 if (rs[Rs_fade])
1772 { 1757 {
1773 pix_colors = pix_colors_focused; 1758 pix_colors = pix_colors_focused;
1817 1802
1818#if TRANSPARENT 1803#if TRANSPARENT
1819void 1804void
1820rxvt_term::rootwin_cb (XEvent &ev) 1805rxvt_term::rootwin_cb (XEvent &ev)
1821{ 1806{
1822 SET_R (this); 1807 make_current ();
1823 SET_LOCALE (locale);
1824 1808
1825 switch (ev.type) 1809 switch (ev.type)
1826 { 1810 {
1827 case PropertyNotify: 1811 case PropertyNotify:
1828 /* 1812 /*
1919#else 1903#else
1920 selection.rect = false; 1904 selection.rect = false;
1921#endif 1905#endif
1922 1906
1923 /* allow shift+left click to extend selection */ 1907 /* allow shift+left click to extend selection */
1924 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1908 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1925 { 1909 {
1926 if (MEvent.button == Button1 && clickintime) 1910 if (MEvent.button == Button1 && clickintime)
1927 selection_rotate (ev.x, ev.y); 1911 selection_rotate (ev.x, ev.y);
1928 else 1912 else
1929 selection_extend (ev.x, ev.y, 1); 1913 selection_extend (ev.x, ev.y, 1);
2097 } 2081 }
2098 } 2082 }
2099 2083
2100 return; 2084 return;
2101 } 2085 }
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} 2086}
2111 2087
2112void 2088void
2113rxvt_term::button_release (XButtonEvent &ev) 2089rxvt_term::button_release (XButtonEvent &ev)
2114{ 2090{
2120 2096
2121 if (scrollbar_isUpDn ()) 2097 if (scrollbar_isUpDn ())
2122 { 2098 {
2123 scrollBar.setIdle (); 2099 scrollBar.setIdle ();
2124 scrollbar_show (0); 2100 scrollbar_show (0);
2125#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2126 refresh_type &= ~SMOOTH_REFRESH;
2127#endif
2128 } 2101 }
2129 2102
2130#ifdef SELECTION_SCROLLING 2103#ifdef SELECTION_SCROLLING
2131 if (sel_scroll_ev.active) 2104 if (sel_scroll_ev.active)
2132 sel_scroll_ev.stop(); 2105 sel_scroll_ev.stop();
2179 { 2152 {
2180 case Button1: 2153 case Button1:
2181 case Button3: 2154 case Button3:
2182 selection_make (ev.time); 2155 selection_make (ev.time);
2183 break; 2156 break;
2157
2184 case Button2: 2158 case Button2:
2185 selection_request (ev.time, ev.x, ev.y); 2159 if (IN_RANGE_EXC (ev.x, 0, width)
2160 && IN_RANGE_EXC (ev.y, 0, height)) // inside window?
2161 {
2162 if (ev.state & ShiftMask)
2163 selection_request (ev.time, Sel_Clipboard);
2164 else
2165 selection_request (ev.time, Sel_Primary);
2166 }
2186 break; 2167 break;
2168
2187#ifdef MOUSE_WHEEL 2169#ifdef MOUSE_WHEEL
2188 case Button4: 2170 case Button4:
2189 case Button5: 2171 case Button5:
2190 { 2172 {
2191 int i; 2173 int i;
2213 slip_wheel_ev.start (); 2195 slip_wheel_ev.start ();
2214 } 2196 }
2215 else 2197 else
2216 { 2198 {
2217# endif 2199# endif
2218# ifdef JUMP_MOUSE_WHEEL
2219 scr_page (v, i); 2200 scr_page (v, i);
2220 scr_refresh (SMOOTH_REFRESH);
2221 scrollbar_show (1); 2201 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 2202# ifdef MOUSE_SLIP_WHEELING
2231 } 2203 }
2232#endif 2204# endif
2233 } 2205 }
2234 break; 2206 break;
2235#endif 2207#endif
2236 } 2208 }
2237 } 2209 }
2238#ifdef MENUBAR
2239 else if (isMenuBarWindow (ev.window))
2240 menubar_control (ev);
2241#endif
2242} 2210}
2243 2211
2244#ifdef TRANSPARENT 2212#ifdef TRANSPARENT
2245#if TINTING 2213#if TINTING
2246/* taken from aterm-0.4.2 */ 2214/* taken from aterm-0.4.2 */
2789 } 2757 }
2790 2758
2791 // scr_add_lines only works for nlines <= nrow - 1. 2759 // scr_add_lines only works for nlines <= nrow - 1.
2792 if (nlines >= nrow - 1) 2760 if (nlines >= nrow - 1)
2793 { 2761 {
2762 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2794 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) 2763 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2795 scr_add_lines (buf, str - buf, nlines); 2764 scr_add_lines (buf, str - buf, nlines);
2796 2765
2797 nlines = 0; 2766 nlines = 0;
2798 str = buf; 2767 str = buf;
2799 eol = str + min (ncol, UBUFSIZ); 2768 eol = str + min (ncol, UBUFSIZ);
2814 2783
2815 seq_begin = cmdbuf_ptr; 2784 seq_begin = cmdbuf_ptr;
2816 ch = next_char (); 2785 ch = next_char ();
2817 } 2786 }
2818 2787
2788 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2819 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) 2789 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2820 scr_add_lines (buf, str - buf, nlines); 2790 scr_add_lines (buf, str - buf, nlines);
2821 2791
2822 /* 2792 /*
2823 * If there have been a lot of new lines, then update the screen 2793 * 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. 2794 * What the heck I'll cheat and only refresh less than every page-full.
2830 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2800 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2831 refresh_limit++; 2801 refresh_limit++;
2832 else 2802 else
2833 { 2803 {
2834 flag = true; 2804 flag = true;
2835 scr_refresh (refresh_type); 2805 scr_refresh ();
2836 flush_ev.stop (); 2806 want_refresh = 1;
2837 } 2807 }
2838 } 2808 }
2839 2809
2840 } 2810 }
2841 else 2811 else
2858 return flag; 2828 return flag;
2859} 2829}
2860 2830
2861// read the next character 2831// read the next character
2862wchar_t 2832wchar_t
2863rxvt_term::next_char () 2833rxvt_term::next_char () NOTHROW
2864{ 2834{
2865 while (cmdbuf_ptr < cmdbuf_endp) 2835 while (cmdbuf_ptr < cmdbuf_endp)
2866 { 2836 {
2867 // assume 7-bit to be ascii ALWAYS 2837 // assume 7-bit to be ascii ALWAYS
2868 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2838 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)
2889 return NOCHAR; 2859 return NOCHAR;
2890} 2860}
2891 2861
2892// read the next octet 2862// read the next octet
2893uint32_t 2863uint32_t
2894rxvt_term::next_octet () 2864rxvt_term::next_octet () NOTHROW
2895{ 2865{
2896 return cmdbuf_ptr < cmdbuf_endp 2866 return cmdbuf_ptr < cmdbuf_endp
2897 ? (unsigned char)*cmdbuf_ptr++ 2867 ? (unsigned char)*cmdbuf_ptr++
2898 : NOCHAR; 2868 : NOCHAR;
2899} 2869}
2870
2871static class out_of_input out_of_input;
2900 2872
2901/* rxvt_cmd_getc () - Return next input character */ 2873/* rxvt_cmd_getc () - Return next input character */
2902/* 2874/*
2903 * Return the next input character after first passing any keyboard input 2875 * Return the next input character after first passing any keyboard input
2904 * to the command. 2876 * to the command.
2905 */ 2877 */
2906wchar_t 2878wchar_t
2907rxvt_term::cmd_getc () 2879rxvt_term::cmd_getc () THROW ((class out_of_input))
2908{ 2880{
2909 wchar_t c = next_char (); 2881 wchar_t c = next_char ();
2910 2882
2911 if (c == NOCHAR) 2883 if (c == NOCHAR)
2912 throw out_of_input; 2884 throw out_of_input;
2913 2885
2914 return c; 2886 return c;
2915} 2887}
2916 2888
2917uint32_t 2889uint32_t
2918rxvt_term::cmd_get8 () 2890rxvt_term::cmd_get8 () THROW ((class out_of_input))
2919{ 2891{
2920 uint32_t c = next_octet (); 2892 uint32_t c = next_octet ();
2921 2893
2922 if (c == NOCHAR) 2894 if (c == NOCHAR)
2923 throw out_of_input; 2895 throw out_of_input;
3802 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3774 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3803 */ 3775 */
3804void 3776void
3805rxvt_term::process_xterm_seq (int op, const char *str, char resp) 3777rxvt_term::process_xterm_seq (int op, const char *str, char resp)
3806{ 3778{
3807 int changed = 0;
3808 int color; 3779 int color;
3809 char *buf, *name; 3780 char *buf, *name;
3810 bool query = str[0] == '?' && !str[1]; 3781 bool query = str[0] == '?' && !str[1];
3811 int saveop = op; 3782 int saveop = op;
3812 dDisp; 3783 dDisp;
3867 { 3838 {
3868 if ((name = strchr (buf, ';')) == NULL) 3839 if ((name = strchr (buf, ';')) == NULL)
3869 break; 3840 break;
3870 3841
3871 *name++ = '\0'; 3842 *name++ = '\0';
3872 color = atoi (buf); 3843 color = atoi (buf) + minCOLOR;
3873 3844
3874 if (color < 0 || color >= TOTAL_COLORS) 3845 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3875 break; 3846 break;
3876 3847
3877 if ((buf = strchr (name, ';')) != NULL) 3848 if ((buf = strchr (name, ';')) != NULL)
3878 *buf++ = '\0'; 3849 *buf++ = '\0';
3879 3850
3880 if (name[0] == '?' && !name[1]) 3851 if (name[0] == '?' && !name[1])
3881 { 3852 {
3882 unsigned short r, g, b; 3853 unsigned short r, g, b;
3883 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3854 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); 3855 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3885 } 3856 }
3886 else 3857 else
3887 set_window_color (color + minCOLOR, name); 3858 set_window_color (color, name);
3888 } 3859 }
3889 break; 3860 break;
3890 case XTerm_Color00: 3861 case XTerm_Color00:
3891 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3862 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3892 break; 3863 break;
3893 case XTerm_Color01: 3864 case XTerm_Color01:
3894 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3865 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3895 break; 3866 break;
3896#ifndef NO_CURSORCOLOR 3867#ifndef NO_CURSORCOLOR
3897 case XTerm_Color_cursor: 3868 case XTerm_Color_cursor:
3898 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3869 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3899 break; 3870 break;
3903 break; 3874 break;
3904 case XTerm_Color_pointer_bg: 3875 case XTerm_Color_pointer_bg:
3905 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3876 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3906 break; 3877 break;
3907#ifndef NO_BOLD_UNDERLINE_REVERSE 3878#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: 3879 case XTerm_Color_RV:
3915 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3880 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3881 break;
3882 case Rxvt_Color_BD:
3883 case URxvt_Color_BD:
3884 process_color_seq (op, Color_BD, str, resp);
3885 break;
3886 case Rxvt_Color_UL:
3887 case URxvt_Color_UL:
3888 process_color_seq (op, Color_UL, str, resp);
3916 break; 3889 break;
3917 case URxvt_Color_IT: 3890 case URxvt_Color_IT:
3918 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3891 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3919 break; 3892 break;
3920#endif 3893#endif
3925 if (am_transparent) 3898 if (am_transparent)
3926 want_full_refresh = want_refresh = 1; 3899 want_full_refresh = want_refresh = 1;
3927 break; 3900 break;
3928#endif 3901#endif
3929 3902
3930 case XTerm_Pixmap: 3903 case Rxvt_Pixmap:
3904 {
3931 if (*str != ';') 3905 if (*str != ';')
3932 { 3906 {
3933#if XPM_BACKGROUND 3907#if XPM_BACKGROUND
3934 scale_pixmap (""); /* reset to default scaling */ 3908 scale_pixmap (""); /* reset to default scaling */
3935 set_bgPixmap (str); /* change pixmap */ 3909 set_bgPixmap (str); /* change pixmap */
3936#endif
3937 scr_touch (true); 3910 scr_touch (true);
3911#endif
3938 } 3912 }
3913
3914 int changed = 0;
3915
3939 while ((str = strchr (str, ';')) != NULL) 3916 while ((str = strchr (str, ';')) != NULL)
3940 { 3917 {
3941 str++; 3918 str++;
3942#if XPM_BACKGROUND 3919#if XPM_BACKGROUND
3943 changed += scale_pixmap (str); 3920 changed += scale_pixmap (str);
3944#endif 3921#endif
3945 } 3922 }
3946 3923
3947 if (changed) 3924 if (changed)
3948 { 3925 {
3949#ifdef XPM_BACKGROUND 3926#ifdef XPM_BACKGROUND
3950 resize_pixmap (); 3927 resize_pixmap ();
3951#endif
3952 scr_touch (true); 3928 scr_touch (true);
3929#endif
3953 } 3930 }
3931 }
3954 break; 3932 break;
3955 3933
3956 case XTerm_restoreFG: 3934 case Rxvt_restoreFG:
3957 set_window_color (Color_fg, str); 3935 set_window_color (Color_fg, str);
3958 break; 3936 break;
3959 case XTerm_restoreBG: 3937 case Rxvt_restoreBG:
3960 set_window_color (Color_bg, str); 3938 set_window_color (Color_bg, str);
3961 break; 3939 break;
3962 3940
3963 case XTerm_logfile: 3941 case XTerm_logfile:
3964 // TODO, when secure mode? 3942 // TODO, when secure mode?
3965 break; 3943 break;
3966 3944
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 3945#if 0
3974 case XTerm_dumpscreen: /* no error notices */ 3946 case Rxvt_dumpscreen: /* no error notices */
3975 { 3947 {
3976 int fd; 3948 int fd;
3977 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3949 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3978 { 3950 {
3979 scr_dump (fd); 3951 scr_dump (fd);
4010 if (query) 3982 if (query)
4011 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); 3983 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp);
4012 else 3984 else
4013 { 3985 {
4014 set_locale (str); 3986 set_locale (str);
4015 pty.set_utf8_mode (enc_utf8); 3987 pty->set_utf8_mode (enc_utf8);
4016 init_xlocale (); 3988 init_xlocale ();
4017 } 3989 }
4018 break; 3990 break;
4019 3991
4020 case URxvt_view_up: 3992 case URxvt_view_up:
4073 return state; 4045 return state;
4074} 4046}
4075 4047
4076/* we're not using priv _yet_ */ 4048/* we're not using priv _yet_ */
4077void 4049void
4078rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) 4050rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg)
4079{ 4051{
4080 unsigned int i, j; 4052 unsigned int i, j;
4081 int state; 4053 int state;
4082 4054
4083 static const struct 4055 static const struct
4094 { 5, PrivMode_rVideo }, 4066 { 5, PrivMode_rVideo },
4095 { 6, PrivMode_relOrigin }, 4067 { 6, PrivMode_relOrigin },
4096 { 7, PrivMode_Autowrap }, 4068 { 7, PrivMode_Autowrap },
4097 // 8, bi-directional support mode 4069 // 8, bi-directional support mode
4098 { 9, PrivMode_MouseX10 }, 4070 { 9, PrivMode_MouseX10 },
4099#ifdef menuBar_esc
4100 { menuBar_esc, PrivMode_menuBar },
4101#endif
4102 // 18, 19 printing-related 4071 // 18, 19 printing-related
4103 { 25, PrivMode_VisibleCursor }, 4072 { 25, PrivMode_VisibleCursor },
4104#ifdef scrollBar_esc 4073#ifdef scrollBar_esc
4105 { scrollBar_esc, PrivMode_scrollBar }, 4074 { scrollBar_esc, PrivMode_scrollBar },
4106#endif 4075#endif
4153 /* extra handling for values with state unkept */ 4122 /* extra handling for values with state unkept */
4154 switch (arg[i]) 4123 switch (arg[i])
4155 { 4124 {
4156#if ENABLE_STYLES 4125#if ENABLE_STYLES
4157 case 1021: 4126 case 1021:
4158 if (mode) 4127 set_option (Opt_intensityStyles, mode);
4159 SET_OPTION (Opt_intensityStyles);
4160 else
4161 CLR_OPTION (Opt_intensityStyles);
4162 4128
4163 scr_touch (true); 4129 scr_touch (true);
4164 break; 4130 break;
4165#endif 4131#endif
4166 case 1048: /* alternative cursor save */ 4132 case 1048: /* alternative cursor save */
4188 case 3: /* 80/132 */ 4154 case 3: /* 80/132 */
4189 if (priv_modes & PrivMode_132OK) 4155 if (priv_modes & PrivMode_132OK)
4190 set_widthheight (((state ? 132 : 80) * fwidth), height); 4156 set_widthheight (((state ? 132 : 80) * fwidth), height);
4191 break; 4157 break;
4192 case 4: /* smooth scrolling */ 4158 case 4: /* smooth scrolling */
4193 if (!state) 4159 set_option (Opt_jumpScroll, !state);
4194 SET_OPTION (Opt_jumpScroll);
4195 else
4196 CLR_OPTION (Opt_jumpScroll);
4197 break; 4160 break;
4198 case 5: /* reverse video */ 4161 case 5: /* reverse video */
4199 scr_rvideo_mode (state); 4162 scr_rvideo_mode (state);
4200 break; 4163 break;
4201 case 6: /* relative/absolute origins */ 4164 case 6: /* relative/absolute origins */
4207 /* case 8: - auto repeat, can't do on a per window basis */ 4170 /* case 8: - auto repeat, can't do on a per window basis */
4208 case 9: /* X10 mouse reporting */ 4171 case 9: /* X10 mouse reporting */
4209 if (state) /* orthogonal */ 4172 if (state) /* orthogonal */
4210 priv_modes &= ~PrivMode_MouseX11; 4173 priv_modes &= ~PrivMode_MouseX11;
4211 break; 4174 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 4175#ifdef scrollBar_esc
4220 case scrollBar_esc: 4176 case scrollBar_esc:
4221 if (scrollbar_mapping (state)) 4177 if (scrollbar_mapping (state))
4222 { 4178 {
4223 resize_all_windows (0, 0, 0); 4179 resize_all_windows (0, 0, 0);
4242#if 0 4198#if 0
4243 case 1001: 4199 case 1001:
4244 break; /* X11 mouse highlighting */ 4200 break; /* X11 mouse highlighting */
4245#endif 4201#endif
4246 case 1010: /* scroll to bottom on TTY output inhibit */ 4202 case 1010: /* scroll to bottom on TTY output inhibit */
4247 if (!state) 4203 set_option (Opt_scrollTtyOutput, !state);
4248 SET_OPTION (Opt_scrollTtyOutput);
4249 else
4250 CLR_OPTION (Opt_scrollTtyOutput);
4251 break; 4204 break;
4252 case 1011: /* scroll to bottom on key press */ 4205 case 1011: /* scroll to bottom on key press */
4253 if (state) 4206 set_option (Opt_scrollTtyKeypress, state);
4254 SET_OPTION (Opt_scrollTtyKeypress);
4255 else
4256 CLR_OPTION (Opt_scrollTtyKeypress);
4257 break; 4207 break;
4258 case 1047: /* secondary screen w/ clearing last */ 4208 case 1047: /* secondary screen w/ clearing last */
4259 if (OPTION (Opt_secondaryScreen)) 4209 if (OPTION (Opt_secondaryScreen))
4260 if (current_screen != PRIMARY) 4210 if (current_screen != PRIMARY)
4261 scr_erase_screen (2); 4211 scr_erase_screen (2);
4471const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4421const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4472 4422
4473void 4423void
4474rxvt_term::tt_write (const char *data, unsigned int len) 4424rxvt_term::tt_write (const char *data, unsigned int len)
4475{ 4425{
4476 if (pty.pty < 0) 4426 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4477 return; 4427 return;
4478 4428
4429 if (pty->pty < 0)
4430 return;
4431
4479 if (v_buflen == 0) 4432 if (v_buflen == 0)
4480 { 4433 {
4481 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); 4434 ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE));
4482 4435
4483 if ((unsigned int)written == len) 4436 if ((unsigned int)written == len)
4484 return; 4437 return;
4485 4438
4486 data += written; 4439 data += written;
4495 pty_ev.set (EVENT_READ | EVENT_WRITE); 4448 pty_ev.set (EVENT_READ | EVENT_WRITE);
4496} 4449}
4497 4450
4498void rxvt_term::pty_write () 4451void rxvt_term::pty_write ()
4499{ 4452{
4500 int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 4453 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4501 4454
4502 if (written > 0) 4455 if (written > 0)
4503 { 4456 {
4504 v_buflen -= written; 4457 v_buflen -= written;
4505 4458

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines