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.245 by root, Fri Jan 6 18:33:30 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 }
1562 1528
1563 case SelectionRequest: 1529 case SelectionRequest:
1564 selection_send (ev.xselectionrequest); 1530 selection_send (ev.xselectionrequest);
1565 break; 1531 break;
1566 1532
1533 case MapNotify:
1534 mapped = 1;
1535#ifdef TEXT_BLINK
1536 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1537#endif
1538 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1539 break;
1540
1567 case UnmapNotify: 1541 case UnmapNotify:
1568 mapped = 0; 1542 mapped = 0;
1569#ifdef TEXT_BLINK 1543#ifdef TEXT_BLINK
1570 text_blink_ev.stop (); 1544 text_blink_ev.stop ();
1571#endif 1545#endif
1572 break; 1546 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1573
1574 case MapNotify:
1575 mapped = 1;
1576#ifdef TEXT_BLINK
1577 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1578#endif
1579 break; 1547 break;
1580 1548
1581#ifdef TRANSPARENT 1549#ifdef TRANSPARENT
1582 case ReparentNotify: 1550 case ReparentNotify:
1583 rootwin_cb (ev); 1551 rootwin_cb (ev);
1597 1565
1598 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1566 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1599 scr_expose (ev.xexpose.x, ev.xexpose.y, 1567 scr_expose (ev.xexpose.x, ev.xexpose.y,
1600 ev.xexpose.width, ev.xexpose.height, False); 1568 ev.xexpose.width, ev.xexpose.height, False);
1601 1569
1602 scr_refresh (refresh_type); 1570 want_refresh = 1;
1603 } 1571 }
1604 else 1572 else
1605 { 1573 {
1606 XEvent unused_event; 1574 XEvent unused_event;
1607 1575
1613 if (isScrollbarWindow (ev.xany.window)) 1581 if (isScrollbarWindow (ev.xany.window))
1614 { 1582 {
1615 scrollBar.setIdle (); 1583 scrollBar.setIdle ();
1616 scrollbar_show (0); 1584 scrollbar_show (0);
1617 } 1585 }
1618#ifdef MENUBAR
1619 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1620 menubar_expose ();
1621#endif
1622 1586
1623#ifdef TRANSPARENT 1587#ifdef TRANSPARENT
1624 if (am_transparent && ev.xany.window == parent[0]) 1588 if (am_transparent && ev.xany.window == parent[0])
1625 XClearWindow (disp, ev.xany.window); 1589 XClearWindow (disp, ev.xany.window);
1626#endif 1590#endif
1630 case MotionNotify: 1594 case MotionNotify:
1631#ifdef POINTER_BLANK 1595#ifdef POINTER_BLANK
1632 if (hidden_pointer) 1596 if (hidden_pointer)
1633 pointer_unblank (); 1597 pointer_unblank ();
1634#endif 1598#endif
1635#if MENUBAR
1636 if (isMenuBarWindow (ev.xany.window))
1637 {
1638 menubar_control (ev.xbutton);
1639 break;
1640 }
1641#endif
1642 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1599 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1643 break; 1600 break;
1644 1601
1645 if (ev.xany.window == vt) 1602 if (ev.xany.window == vt)
1646 { 1603 {
1604 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1647 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1605 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1648 ; // nop 1606 ; // nop
1649 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1607 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1650 { 1608 {
1651 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1609 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1652 ; 1610 ;
1734 &unused_root_x, &unused_root_y, 1692 &unused_root_x, &unused_root_y,
1735 &ev.xbutton.x, &ev.xbutton.y, 1693 &ev.xbutton.x, &ev.xbutton.y,
1736 &unused_mask); 1694 &unused_mask);
1737 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1695 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1738 scrollbar_size ()); 1696 scrollbar_size ());
1739 scr_refresh (refresh_type); 1697 want_refresh = 1;
1740 refresh_limit = 0; 1698 refresh_limit = 0;
1741 scrollbar_show (1); 1699 scrollbar_show (1);
1742 } 1700 }
1743 break; 1701 break;
1744 } 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
1745} 1732}
1746 1733
1747void 1734void
1748rxvt_term::focus_in () 1735rxvt_term::focus_in ()
1749{ 1736{
1761 XSetICFocus (Input_Context); 1748 XSetICFocus (Input_Context);
1762 } 1749 }
1763#endif 1750#endif
1764#if CURSOR_BLINK 1751#if CURSOR_BLINK
1765 if (OPTION (Opt_cursorBlink)) 1752 if (OPTION (Opt_cursorBlink))
1766 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1753 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1767#endif 1754#endif
1768#if OFF_FOCUS_FADING 1755#if OFF_FOCUS_FADING
1769 if (rs[Rs_fade]) 1756 if (rs[Rs_fade])
1770 { 1757 {
1771 pix_colors = pix_colors_focused; 1758 pix_colors = pix_colors_focused;
1815 1802
1816#if TRANSPARENT 1803#if TRANSPARENT
1817void 1804void
1818rxvt_term::rootwin_cb (XEvent &ev) 1805rxvt_term::rootwin_cb (XEvent &ev)
1819{ 1806{
1820 SET_R (this); 1807 make_current ();
1821 SET_LOCALE (locale);
1822 1808
1823 switch (ev.type) 1809 switch (ev.type)
1824 { 1810 {
1825 case PropertyNotify: 1811 case PropertyNotify:
1826 /* 1812 /*
1917#else 1903#else
1918 selection.rect = false; 1904 selection.rect = false;
1919#endif 1905#endif
1920 1906
1921 /* allow shift+left click to extend selection */ 1907 /* allow shift+left click to extend selection */
1922 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1908 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1923 { 1909 {
1924 if (MEvent.button == Button1 && clickintime) 1910 if (MEvent.button == Button1 && clickintime)
1925 selection_rotate (ev.x, ev.y); 1911 selection_rotate (ev.x, ev.y);
1926 else 1912 else
1927 selection_extend (ev.x, ev.y, 1); 1913 selection_extend (ev.x, ev.y, 1);
2095 } 2081 }
2096 } 2082 }
2097 2083
2098 return; 2084 return;
2099 } 2085 }
2100
2101#if MENUBAR
2102 /*
2103 * Menubar window processing of button press
2104 */
2105 if (isMenuBarWindow (ev.window))
2106 menubar_control (ev);
2107#endif
2108} 2086}
2109 2087
2110void 2088void
2111rxvt_term::button_release (XButtonEvent &ev) 2089rxvt_term::button_release (XButtonEvent &ev)
2112{ 2090{
2118 2096
2119 if (scrollbar_isUpDn ()) 2097 if (scrollbar_isUpDn ())
2120 { 2098 {
2121 scrollBar.setIdle (); 2099 scrollBar.setIdle ();
2122 scrollbar_show (0); 2100 scrollbar_show (0);
2123#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2124 refresh_type &= ~SMOOTH_REFRESH;
2125#endif
2126 } 2101 }
2127 2102
2128#ifdef SELECTION_SCROLLING 2103#ifdef SELECTION_SCROLLING
2129 if (sel_scroll_ev.active) 2104 if (sel_scroll_ev.active)
2130 sel_scroll_ev.stop(); 2105 sel_scroll_ev.stop();
2177 { 2152 {
2178 case Button1: 2153 case Button1:
2179 case Button3: 2154 case Button3:
2180 selection_make (ev.time); 2155 selection_make (ev.time);
2181 break; 2156 break;
2157
2182 case Button2: 2158 case Button2:
2183 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 }
2184 break; 2167 break;
2168
2185#ifdef MOUSE_WHEEL 2169#ifdef MOUSE_WHEEL
2186 case Button4: 2170 case Button4:
2187 case Button5: 2171 case Button5:
2188 { 2172 {
2189 int i; 2173 int i;
2211 slip_wheel_ev.start (); 2195 slip_wheel_ev.start ();
2212 } 2196 }
2213 else 2197 else
2214 { 2198 {
2215# endif 2199# endif
2216# ifdef JUMP_MOUSE_WHEEL
2217 scr_page (v, i); 2200 scr_page (v, i);
2218 scr_refresh (SMOOTH_REFRESH);
2219 scrollbar_show (1); 2201 scrollbar_show (1);
2220# else
2221 while (i--)
2222 {
2223 scr_page (v, 1);
2224 scr_refresh (SMOOTH_REFRESH);
2225 scrollbar_show (1);
2226 }
2227# endif
2228# ifdef MOUSE_SLIP_WHEELING 2202# ifdef MOUSE_SLIP_WHEELING
2229 } 2203 }
2230#endif 2204# endif
2231 } 2205 }
2232 break; 2206 break;
2233#endif 2207#endif
2234 } 2208 }
2235 } 2209 }
2236#ifdef MENUBAR
2237 else if (isMenuBarWindow (ev.window))
2238 menubar_control (ev);
2239#endif
2240} 2210}
2241 2211
2242#ifdef TRANSPARENT 2212#ifdef TRANSPARENT
2243#if TINTING 2213#if TINTING
2244/* taken from aterm-0.4.2 */ 2214/* taken from aterm-0.4.2 */
2787 } 2757 }
2788 2758
2789 // scr_add_lines only works for nlines <= nrow - 1. 2759 // scr_add_lines only works for nlines <= nrow - 1.
2790 if (nlines >= nrow - 1) 2760 if (nlines >= nrow - 1)
2791 { 2761 {
2762 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2792 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))))
2793 scr_add_lines (buf, str - buf, nlines); 2764 scr_add_lines (buf, str - buf, nlines);
2794 2765
2795 nlines = 0; 2766 nlines = 0;
2796 str = buf; 2767 str = buf;
2797 eol = str + min (ncol, UBUFSIZ); 2768 eol = str + min (ncol, UBUFSIZ);
2812 2783
2813 seq_begin = cmdbuf_ptr; 2784 seq_begin = cmdbuf_ptr;
2814 ch = next_char (); 2785 ch = next_char ();
2815 } 2786 }
2816 2787
2788 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2817 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))))
2818 scr_add_lines (buf, str - buf, nlines); 2790 scr_add_lines (buf, str - buf, nlines);
2819 2791
2820 /* 2792 /*
2821 * 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
2822 * 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.
2828 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2800 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2829 refresh_limit++; 2801 refresh_limit++;
2830 else 2802 else
2831 { 2803 {
2832 flag = true; 2804 flag = true;
2833 scr_refresh (refresh_type); 2805 scr_refresh ();
2834 flush_ev.stop (); 2806 want_refresh = 1;
2835 } 2807 }
2836 } 2808 }
2837 2809
2838 } 2810 }
2839 else 2811 else
2856 return flag; 2828 return flag;
2857} 2829}
2858 2830
2859// read the next character 2831// read the next character
2860wchar_t 2832wchar_t
2861rxvt_term::next_char () 2833rxvt_term::next_char () NOTHROW
2862{ 2834{
2863 while (cmdbuf_ptr < cmdbuf_endp) 2835 while (cmdbuf_ptr < cmdbuf_endp)
2864 { 2836 {
2865 // assume 7-bit to be ascii ALWAYS 2837 // assume 7-bit to be ascii ALWAYS
2866 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2838 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)
2887 return NOCHAR; 2859 return NOCHAR;
2888} 2860}
2889 2861
2890// read the next octet 2862// read the next octet
2891uint32_t 2863uint32_t
2892rxvt_term::next_octet () 2864rxvt_term::next_octet () NOTHROW
2893{ 2865{
2894 return cmdbuf_ptr < cmdbuf_endp 2866 return cmdbuf_ptr < cmdbuf_endp
2895 ? *cmdbuf_ptr++ 2867 ? (unsigned char)*cmdbuf_ptr++
2896 : NOCHAR; 2868 : NOCHAR;
2897} 2869}
2870
2871static class out_of_input out_of_input;
2898 2872
2899/* rxvt_cmd_getc () - Return next input character */ 2873/* rxvt_cmd_getc () - Return next input character */
2900/* 2874/*
2901 * Return the next input character after first passing any keyboard input 2875 * Return the next input character after first passing any keyboard input
2902 * to the command. 2876 * to the command.
2903 */ 2877 */
2904wchar_t 2878wchar_t
2905rxvt_term::cmd_getc () 2879rxvt_term::cmd_getc () THROW ((class out_of_input))
2906{ 2880{
2907 wchar_t c = next_char (); 2881 wchar_t c = next_char ();
2908 2882
2909 if (c == NOCHAR) 2883 if (c == NOCHAR)
2910 throw out_of_input; 2884 throw out_of_input;
2911 2885
2912 return c; 2886 return c;
2913} 2887}
2914 2888
2915uint32_t 2889uint32_t
2916rxvt_term::cmd_get8 () 2890rxvt_term::cmd_get8 () THROW ((class out_of_input))
2917{ 2891{
2918 uint32_t c = next_octet (); 2892 uint32_t c = next_octet ();
2919 2893
2920 if (c == NOCHAR) 2894 if (c == NOCHAR)
2921 throw out_of_input; 2895 throw out_of_input;
3800 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3774 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3801 */ 3775 */
3802void 3776void
3803rxvt_term::process_xterm_seq (int op, const char *str, char resp) 3777rxvt_term::process_xterm_seq (int op, const char *str, char resp)
3804{ 3778{
3805 int changed = 0;
3806 int color; 3779 int color;
3807 char *buf, *name; 3780 char *buf, *name;
3808 bool query = str[0] == '?' && !str[1]; 3781 bool query = str[0] == '?' && !str[1];
3809 int saveop = op; 3782 int saveop = op;
3810 dDisp; 3783 dDisp;
3865 { 3838 {
3866 if ((name = strchr (buf, ';')) == NULL) 3839 if ((name = strchr (buf, ';')) == NULL)
3867 break; 3840 break;
3868 3841
3869 *name++ = '\0'; 3842 *name++ = '\0';
3870 color = atoi (buf); 3843 color = atoi (buf) + minCOLOR;
3871 3844
3872 if (color < 0 || color >= TOTAL_COLORS) 3845 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3873 break; 3846 break;
3874 3847
3875 if ((buf = strchr (name, ';')) != NULL) 3848 if ((buf = strchr (name, ';')) != NULL)
3876 *buf++ = '\0'; 3849 *buf++ = '\0';
3877 3850
3878 if (name[0] == '?' && !name[1]) 3851 if (name[0] == '?' && !name[1])
3879 { 3852 {
3880 unsigned short r, g, b; 3853 unsigned short r, g, b;
3881 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3854 pix_colors_focused[color].get (display, r, g, b);
3882 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);
3883 } 3856 }
3884 else 3857 else
3885 set_window_color (color + minCOLOR, name); 3858 set_window_color (color, name);
3886 } 3859 }
3887 break; 3860 break;
3888 case XTerm_Color00: 3861 case XTerm_Color00:
3889 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3862 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3890 break; 3863 break;
3891 case XTerm_Color01: 3864 case XTerm_Color01:
3892 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3865 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3893 break; 3866 break;
3894#ifndef NO_CURSORCOLOR 3867#ifndef NO_CURSORCOLOR
3895 case XTerm_Color_cursor: 3868 case XTerm_Color_cursor:
3896 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3869 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3897 break; 3870 break;
3901 break; 3874 break;
3902 case XTerm_Color_pointer_bg: 3875 case XTerm_Color_pointer_bg:
3903 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);
3904 break; 3877 break;
3905#ifndef NO_BOLD_UNDERLINE_REVERSE 3878#ifndef NO_BOLD_UNDERLINE_REVERSE
3906 case XTerm_Color_BD:
3907 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3908 break;
3909 case XTerm_Color_UL:
3910 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3911 break;
3912 case XTerm_Color_RV: 3879 case XTerm_Color_RV:
3913 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);
3914 break; 3889 break;
3915 case URxvt_Color_IT: 3890 case URxvt_Color_IT:
3916 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3891 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3917 break; 3892 break;
3918#endif 3893#endif
3923 if (am_transparent) 3898 if (am_transparent)
3924 want_full_refresh = want_refresh = 1; 3899 want_full_refresh = want_refresh = 1;
3925 break; 3900 break;
3926#endif 3901#endif
3927 3902
3928 case XTerm_Pixmap: 3903 case Rxvt_Pixmap:
3904 {
3929 if (*str != ';') 3905 if (*str != ';')
3930 { 3906 {
3931#if XPM_BACKGROUND 3907#if XPM_BACKGROUND
3932 scale_pixmap (""); /* reset to default scaling */ 3908 scale_pixmap (""); /* reset to default scaling */
3933 set_bgPixmap (str); /* change pixmap */ 3909 set_bgPixmap (str); /* change pixmap */
3934#endif
3935 scr_touch (true); 3910 scr_touch (true);
3911#endif
3936 } 3912 }
3913
3914 int changed = 0;
3915
3937 while ((str = strchr (str, ';')) != NULL) 3916 while ((str = strchr (str, ';')) != NULL)
3938 { 3917 {
3939 str++; 3918 str++;
3940#if XPM_BACKGROUND 3919#if XPM_BACKGROUND
3941 changed += scale_pixmap (str); 3920 changed += scale_pixmap (str);
3942#endif 3921#endif
3943 } 3922 }
3944 3923
3945 if (changed) 3924 if (changed)
3946 { 3925 {
3947#ifdef XPM_BACKGROUND 3926#ifdef XPM_BACKGROUND
3948 resize_pixmap (); 3927 resize_pixmap ();
3949#endif
3950 scr_touch (true); 3928 scr_touch (true);
3929#endif
3951 } 3930 }
3931 }
3952 break; 3932 break;
3953 3933
3954 case XTerm_restoreFG: 3934 case Rxvt_restoreFG:
3955 set_window_color (Color_fg, str); 3935 set_window_color (Color_fg, str);
3956 break; 3936 break;
3957 case XTerm_restoreBG: 3937 case Rxvt_restoreBG:
3958 set_window_color (Color_bg, str); 3938 set_window_color (Color_bg, str);
3959 break; 3939 break;
3960 3940
3961 case XTerm_logfile: 3941 case XTerm_logfile:
3962 // TODO, when secure mode? 3942 // TODO, when secure mode?
3963 break; 3943 break;
3964 3944
3965#ifdef MENUBAR
3966 case URxvt_Menu:
3967 if (OPTION (Opt_insecure))
3968 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3969 break;
3970#endif
3971#if 0 3945#if 0
3972 case XTerm_dumpscreen: /* no error notices */ 3946 case Rxvt_dumpscreen: /* no error notices */
3973 { 3947 {
3974 int fd; 3948 int fd;
3975 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)
3976 { 3950 {
3977 scr_dump (fd); 3951 scr_dump (fd);
4008 if (query) 3982 if (query)
4009 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);
4010 else 3984 else
4011 { 3985 {
4012 set_locale (str); 3986 set_locale (str);
4013 pty.set_utf8_mode (enc_utf8); 3987 pty->set_utf8_mode (enc_utf8);
4014 init_xlocale (); 3988 init_xlocale ();
4015 } 3989 }
4016 break; 3990 break;
4017 3991
4018 case URxvt_view_up: 3992 case URxvt_view_up:
4071 return state; 4045 return state;
4072} 4046}
4073 4047
4074/* we're not using priv _yet_ */ 4048/* we're not using priv _yet_ */
4075void 4049void
4076rxvt_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)
4077{ 4051{
4078 unsigned int i, j; 4052 unsigned int i, j;
4079 int state; 4053 int state;
4080 4054
4081 static const struct 4055 static const struct
4092 { 5, PrivMode_rVideo }, 4066 { 5, PrivMode_rVideo },
4093 { 6, PrivMode_relOrigin }, 4067 { 6, PrivMode_relOrigin },
4094 { 7, PrivMode_Autowrap }, 4068 { 7, PrivMode_Autowrap },
4095 // 8, bi-directional support mode 4069 // 8, bi-directional support mode
4096 { 9, PrivMode_MouseX10 }, 4070 { 9, PrivMode_MouseX10 },
4097#ifdef menuBar_esc
4098 { menuBar_esc, PrivMode_menuBar },
4099#endif
4100 // 18, 19 printing-related 4071 // 18, 19 printing-related
4101 { 25, PrivMode_VisibleCursor }, 4072 { 25, PrivMode_VisibleCursor },
4102#ifdef scrollBar_esc 4073#ifdef scrollBar_esc
4103 { scrollBar_esc, PrivMode_scrollBar }, 4074 { scrollBar_esc, PrivMode_scrollBar },
4104#endif 4075#endif
4151 /* extra handling for values with state unkept */ 4122 /* extra handling for values with state unkept */
4152 switch (arg[i]) 4123 switch (arg[i])
4153 { 4124 {
4154#if ENABLE_STYLES 4125#if ENABLE_STYLES
4155 case 1021: 4126 case 1021:
4156 if (mode) 4127 set_option (Opt_intensityStyles, mode);
4157 SET_OPTION (Opt_intensityStyles);
4158 else
4159 CLR_OPTION (Opt_intensityStyles);
4160 4128
4161 scr_touch (true); 4129 scr_touch (true);
4162 break; 4130 break;
4163#endif 4131#endif
4164 case 1048: /* alternative cursor save */ 4132 case 1048: /* alternative cursor save */
4186 case 3: /* 80/132 */ 4154 case 3: /* 80/132 */
4187 if (priv_modes & PrivMode_132OK) 4155 if (priv_modes & PrivMode_132OK)
4188 set_widthheight (((state ? 132 : 80) * fwidth), height); 4156 set_widthheight (((state ? 132 : 80) * fwidth), height);
4189 break; 4157 break;
4190 case 4: /* smooth scrolling */ 4158 case 4: /* smooth scrolling */
4191 if (!state) 4159 set_option (Opt_jumpScroll, !state);
4192 SET_OPTION (Opt_jumpScroll);
4193 else
4194 CLR_OPTION (Opt_jumpScroll);
4195 break; 4160 break;
4196 case 5: /* reverse video */ 4161 case 5: /* reverse video */
4197 scr_rvideo_mode (state); 4162 scr_rvideo_mode (state);
4198 break; 4163 break;
4199 case 6: /* relative/absolute origins */ 4164 case 6: /* relative/absolute origins */
4205 /* 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 */
4206 case 9: /* X10 mouse reporting */ 4171 case 9: /* X10 mouse reporting */
4207 if (state) /* orthogonal */ 4172 if (state) /* orthogonal */
4208 priv_modes &= ~PrivMode_MouseX11; 4173 priv_modes &= ~PrivMode_MouseX11;
4209 break; 4174 break;
4210#ifdef menuBar_esc
4211 case menuBar_esc:
4212#ifdef MENUBAR
4213 map_menuBar (state);
4214#endif
4215 break;
4216#endif
4217#ifdef scrollBar_esc 4175#ifdef scrollBar_esc
4218 case scrollBar_esc: 4176 case scrollBar_esc:
4219 if (scrollbar_mapping (state)) 4177 if (scrollbar_mapping (state))
4220 { 4178 {
4221 resize_all_windows (0, 0, 0); 4179 resize_all_windows (0, 0, 0);
4240#if 0 4198#if 0
4241 case 1001: 4199 case 1001:
4242 break; /* X11 mouse highlighting */ 4200 break; /* X11 mouse highlighting */
4243#endif 4201#endif
4244 case 1010: /* scroll to bottom on TTY output inhibit */ 4202 case 1010: /* scroll to bottom on TTY output inhibit */
4245 if (!state) 4203 set_option (Opt_scrollTtyOutput, !state);
4246 SET_OPTION (Opt_scrollTtyOutput);
4247 else
4248 CLR_OPTION (Opt_scrollTtyOutput);
4249 break; 4204 break;
4250 case 1011: /* scroll to bottom on key press */ 4205 case 1011: /* scroll to bottom on key press */
4251 if (state) 4206 set_option (Opt_scrollTtyKeypress, state);
4252 SET_OPTION (Opt_scrollTtyKeypress);
4253 else
4254 CLR_OPTION (Opt_scrollTtyKeypress);
4255 break; 4207 break;
4256 case 1047: /* secondary screen w/ clearing last */ 4208 case 1047: /* secondary screen w/ clearing last */
4257 if (OPTION (Opt_secondaryScreen)) 4209 if (OPTION (Opt_secondaryScreen))
4258 if (current_screen != PRIMARY) 4210 if (current_screen != PRIMARY)
4259 scr_erase_screen (2); 4211 scr_erase_screen (2);
4469const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4421const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4470 4422
4471void 4423void
4472rxvt_term::tt_write (const char *data, unsigned int len) 4424rxvt_term::tt_write (const char *data, unsigned int len)
4473{ 4425{
4474 if (pty.pty < 0) 4426 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4475 return; 4427 return;
4476 4428
4429 if (pty->pty < 0)
4430 return;
4431
4477 if (v_buflen == 0) 4432 if (v_buflen == 0)
4478 { 4433 {
4479 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));
4480 4435
4481 if ((unsigned int)written == len) 4436 if ((unsigned int)written == len)
4482 return; 4437 return;
4483 4438
4484 data += written; 4439 data += written;
4493 pty_ev.set (EVENT_READ | EVENT_WRITE); 4448 pty_ev.set (EVENT_READ | EVENT_WRITE);
4494} 4449}
4495 4450
4496void rxvt_term::pty_write () 4451void rxvt_term::pty_write ()
4497{ 4452{
4498 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));
4499 4454
4500 if (written > 0) 4455 if (written > 0)
4501 { 4456 {
4502 v_buflen -= written; 4457 v_buflen -= written;
4503 4458

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines