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.240 by root, Fri Jan 6 03:40:19 2006 UTC vs.
Revision 1.276 by root, Fri Jan 20 11:02:46 2006 UTC

25 * - extensive modifications 25 * - extensive modifications
26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
27 * Copyright (c) 2001 Marius Gedminas 27 * Copyright (c) 2001 Marius Gedminas
28 * - Ctrl/Mod4+Tab works like Meta+Tab (options) 28 * - Ctrl/Mod4+Tab works like Meta+Tab (options)
29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> 29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org>
30 * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> 30 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com>
31 * 31 *
32 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU General Public License as published by 33 * it under the terms of the GNU General Public License as published by
34 * the Free Software Foundation; either version 2 of the License, or 34 * the Free Software Foundation; either version 2 of the License, or
35 * (at your option) any later version. 35 * (at your option) any later version.
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);
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_STRING_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 ())
1205 1192
1206#ifdef POINTER_BLANK 1193#ifdef POINTER_BLANK
1207void 1194void
1208rxvt_term::pointer_blank () 1195rxvt_term::pointer_blank ()
1209{ 1196{
1210 if (! OPTION (Opt_pointerBlank)) 1197 if (!OPTION (Opt_pointerBlank))
1211 return; 1198 return;
1212 1199
1213 XDefineCursor (display->display, vt, display->blank_cursor); 1200 XDefineCursor (display->display, vt, display->blank_cursor);
1214 XFlush (display->display); 1201 XFlush (display->display);
1215 1202
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;
1415 else 1379 else
1416 iso14755buf = 0; 1380 iso14755buf = 0;
1417 } 1381 }
1418#endif 1382#endif
1419 1383
1384 if (ev.xany.window == vt
1385 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1386 break;
1387
1420#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1388#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1421 if (!(ev.xkey.state & ControlMask)) 1389 if (!(ev.xkey.state & ControlMask))
1422 slip_wheel_ev.stop (); 1390 slip_wheel_ev.stop ();
1423 else if (ks == XK_Control_L || ks == XK_Control_R) 1391 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1424 mouse_slip_wheel_speed = 0; 1392 mouse_slip_wheel_speed = 0;
1425#endif 1393#endif
1426 break; 1394 break;
1427 } 1395 }
1428 1396
1433 case ButtonRelease: 1401 case ButtonRelease:
1434 button_release (ev.xbutton); 1402 button_release (ev.xbutton);
1435 break; 1403 break;
1436 1404
1437 case ClientMessage: 1405 case ClientMessage:
1438 if (ev.xclient.format == 32 1406 if (ev.xclient.format == 32)
1439 && ev.xclient.message_type == xa[XA_WM_PROTOCOLS])
1440 { 1407 {
1408 if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS])
1409 {
1441 if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) 1410 if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW])
1411 {
1412 if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, ev, DT_END)))
1442 destroy (); 1413 destroy ();
1414 }
1443#if ENABLE_EWMH 1415#if ENABLE_EWMH
1444 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) 1416 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING])
1445 XSendEvent (disp, ev.xclient.window = display->root, 1417 XSendEvent (disp, ev.xclient.window = display->root,
1446 False, SubstructureRedirectMask | SubstructureNotifyMask, 1418 False, SubstructureRedirectMask | SubstructureNotifyMask,
1447 &ev); 1419 &ev);
1420#endif
1421 }
1422#if ENABLE_XEMBED
1423 else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED])
1424 {
1425 if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN)
1426 focus_in ();
1427 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1428 focus_out ();
1429 }
1448#endif 1430#endif
1449 } 1431 }
1450#if ENABLE_XEMBED
1451 else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED])
1452 {
1453 if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN)
1454 focus_in ();
1455 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1456 focus_out ();
1457 }
1458#endif
1459#ifdef OFFIX_DND
1460 /* OffiX Dnd (drag 'n' drop) protocol */
1461 else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL]
1462 && (ev.xclient.data.l[0] == DndFile
1463 || ev.xclient.data.l[0] == DndDir
1464 || ev.xclient.data.l[0] == DndLink))
1465 {
1466 /* Get Dnd data */
1467 Atom ActualType;
1468 int ActualFormat;
1469 unsigned char *data;
1470 unsigned long Size, RemainingBytes;
1471
1472 XGetWindowProperty (disp, display->root,
1473 xa[XA_DNDSELECTION],
1474 0L, 1000000L,
1475 False, AnyPropertyType,
1476 &ActualType, &ActualFormat,
1477 &Size, &RemainingBytes,
1478 &data);
1479 set_string_property (XA_CUT_BUFFER0, data);
1480 XFree (data);
1481 selection_paste (display->root, XA_CUT_BUFFER0, true);
1482 XSetInputFocus (disp, display->root, RevertToNone, CurrentTime);
1483 }
1484#endif /* OFFIX_DND */
1485 break; 1432 break;
1486 1433
1487 case MappingNotify: 1434 case MappingNotify:
1488 XRefreshKeyboardMapping (&ev.xmapping); 1435 XRefreshKeyboardMapping (&ev.xmapping);
1489 break; 1436 break;
1531 { 1478 {
1532 seen_resize = 1; 1479 seen_resize = 1;
1533 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1480 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1534 } 1481 }
1535 1482
1483 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1484
1536#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1485#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1537 if (OPTION (Opt_transparent)) 1486 if (OPTION (Opt_transparent))
1538 check_our_parents (); 1487 check_our_parents ();
1539#endif 1488#endif
1540 } 1489 }
1558 1507
1559 case SelectionRequest: 1508 case SelectionRequest:
1560 selection_send (ev.xselectionrequest); 1509 selection_send (ev.xselectionrequest);
1561 break; 1510 break;
1562 1511
1512 case MapNotify:
1513 mapped = 1;
1514#ifdef TEXT_BLINK
1515 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1516#endif
1517 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1518 break;
1519
1563 case UnmapNotify: 1520 case UnmapNotify:
1564 mapped = 0; 1521 mapped = 0;
1565#ifdef TEXT_BLINK 1522#ifdef TEXT_BLINK
1566 text_blink_ev.stop (); 1523 text_blink_ev.stop ();
1567#endif 1524#endif
1568 break; 1525 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1569
1570 case MapNotify:
1571 mapped = 1;
1572#ifdef TEXT_BLINK
1573 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
1574#endif
1575 break; 1526 break;
1576 1527
1577#ifdef TRANSPARENT 1528#ifdef TRANSPARENT
1578 case ReparentNotify: 1529 case ReparentNotify:
1579 rootwin_cb (ev); 1530 rootwin_cb (ev);
1593 1544
1594 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1545 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev))
1595 scr_expose (ev.xexpose.x, ev.xexpose.y, 1546 scr_expose (ev.xexpose.x, ev.xexpose.y,
1596 ev.xexpose.width, ev.xexpose.height, False); 1547 ev.xexpose.width, ev.xexpose.height, False);
1597 1548
1598 scr_refresh (refresh_type); 1549 want_refresh = 1;
1599 } 1550 }
1600 else 1551 else
1601 { 1552 {
1602 XEvent unused_event; 1553 XEvent unused_event;
1603 1554
1609 if (isScrollbarWindow (ev.xany.window)) 1560 if (isScrollbarWindow (ev.xany.window))
1610 { 1561 {
1611 scrollBar.setIdle (); 1562 scrollBar.setIdle ();
1612 scrollbar_show (0); 1563 scrollbar_show (0);
1613 } 1564 }
1614#ifdef MENUBAR
1615 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1616 menubar_expose ();
1617#endif
1618 1565
1619#ifdef TRANSPARENT 1566#ifdef TRANSPARENT
1620 if (am_transparent && ev.xany.window == parent[0]) 1567 if (am_transparent && ev.xany.window == parent[0])
1621 XClearWindow (disp, ev.xany.window); 1568 XClearWindow (disp, ev.xany.window);
1622#endif 1569#endif
1626 case MotionNotify: 1573 case MotionNotify:
1627#ifdef POINTER_BLANK 1574#ifdef POINTER_BLANK
1628 if (hidden_pointer) 1575 if (hidden_pointer)
1629 pointer_unblank (); 1576 pointer_unblank ();
1630#endif 1577#endif
1631#if MENUBAR
1632 if (isMenuBarWindow (ev.xany.window))
1633 {
1634 menubar_control (ev.xbutton);
1635 break;
1636 }
1637#endif
1638 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1578 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1639 break; 1579 break;
1640 1580
1641 if (ev.xany.window == vt) 1581 if (ev.xany.window == vt)
1642 { 1582 {
1583 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1643 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1584 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1644 ; // nop 1585 ; // nop
1645 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1586 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1646 { 1587 {
1647 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1588 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1648 ; 1589 ;
1730 &unused_root_x, &unused_root_y, 1671 &unused_root_x, &unused_root_y,
1731 &ev.xbutton.x, &ev.xbutton.y, 1672 &ev.xbutton.x, &ev.xbutton.y,
1732 &unused_mask); 1673 &unused_mask);
1733 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1674 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1734 scrollbar_size ()); 1675 scrollbar_size ());
1735 scr_refresh (refresh_type); 1676 want_refresh = 1;
1736 refresh_limit = 0; 1677 refresh_limit = 0;
1737 scrollbar_show (1); 1678 scrollbar_show (1);
1738 } 1679 }
1739 break; 1680 break;
1740 } 1681 }
1682
1683skip_switch: ;
1684
1685#if defined(CURSOR_BLINK)
1686 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress)
1687 {
1688 if (hidden_cursor)
1689 {
1690 hidden_cursor = 0;
1691 want_refresh = 1;
1692 }
1693
1694 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1695 }
1696#endif
1697
1698#if defined(POINTER_BLANK)
1699 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0)
1700 {
1701 if (ev.type == MotionNotify
1702 || ev.type == ButtonPress
1703 || ev.type == ButtonRelease)
1704 if (hidden_pointer)
1705 pointer_unblank ();
1706
1707 if (ev.type == KeyPress && hidden_pointer == 0)
1708 pointer_blank ();
1709 }
1710#endif
1741} 1711}
1742 1712
1743void 1713void
1744rxvt_term::focus_in () 1714rxvt_term::focus_in ()
1745{ 1715{
1757 XSetICFocus (Input_Context); 1727 XSetICFocus (Input_Context);
1758 } 1728 }
1759#endif 1729#endif
1760#if CURSOR_BLINK 1730#if CURSOR_BLINK
1761 if (OPTION (Opt_cursorBlink)) 1731 if (OPTION (Opt_cursorBlink))
1762 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1732 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1763#endif 1733#endif
1764#if OFF_FOCUS_FADING 1734#if OFF_FOCUS_FADING
1765 if (rs[Rs_fade]) 1735 if (rs[Rs_fade])
1766 { 1736 {
1767 pix_colors = pix_colors_focused; 1737 pix_colors = pix_colors_focused;
1811 1781
1812#if TRANSPARENT 1782#if TRANSPARENT
1813void 1783void
1814rxvt_term::rootwin_cb (XEvent &ev) 1784rxvt_term::rootwin_cb (XEvent &ev)
1815{ 1785{
1816 SET_R (this); 1786 make_current ();
1817 SET_LOCALE (locale);
1818 1787
1819 switch (ev.type) 1788 switch (ev.type)
1820 { 1789 {
1821 case PropertyNotify: 1790 case PropertyNotify:
1822 /* 1791 /*
1870#ifdef MOUSE_REPORT_DOUBLECLICK 1839#ifdef MOUSE_REPORT_DOUBLECLICK
1871 if (ev.button == MEvent.button && clickintime) 1840 if (ev.button == MEvent.button && clickintime)
1872 { 1841 {
1873 /* same button, within alloted time */ 1842 /* same button, within alloted time */
1874 MEvent.clicks++; 1843 MEvent.clicks++;
1844
1875 if (MEvent.clicks > 1) 1845 if (MEvent.clicks > 1)
1876 { 1846 {
1877 /* only report double clicks */ 1847 /* only report double clicks */
1878 MEvent.clicks = 2; 1848 MEvent.clicks = 2;
1879 mouse_report (ev); 1849 mouse_report (ev);
1912#else 1882#else
1913 selection.rect = false; 1883 selection.rect = false;
1914#endif 1884#endif
1915 1885
1916 /* allow shift+left click to extend selection */ 1886 /* allow shift+left click to extend selection */
1917 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1887 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1918 { 1888 {
1919 if (MEvent.button == Button1 && clickintime) 1889 if (MEvent.button == Button1 && clickintime)
1920 selection_rotate (ev.x, ev.y); 1890 selection_rotate (ev.x, ev.y);
1921 else 1891 else
1922 selection_extend (ev.x, ev.y, 1); 1892 selection_extend (ev.x, ev.y, 1);
2087 } 2057 }
2088 2058
2089 break; 2059 break;
2090 } 2060 }
2091 } 2061 }
2062
2092 return; 2063 return;
2093 } 2064 }
2094#if MENUBAR
2095 /*
2096 * Menubar window processing of button press
2097 */
2098 if (isMenuBarWindow (ev.window))
2099 menubar_control (ev);
2100#endif
2101} 2065}
2102 2066
2103void 2067void
2104rxvt_term::button_release (XButtonEvent &ev) 2068rxvt_term::button_release (XButtonEvent &ev)
2105{ 2069{
2111 2075
2112 if (scrollbar_isUpDn ()) 2076 if (scrollbar_isUpDn ())
2113 { 2077 {
2114 scrollBar.setIdle (); 2078 scrollBar.setIdle ();
2115 scrollbar_show (0); 2079 scrollbar_show (0);
2116#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2117 refresh_type &= ~SMOOTH_REFRESH;
2118#endif
2119 } 2080 }
2120 2081
2121#ifdef SELECTION_SCROLLING 2082#ifdef SELECTION_SCROLLING
2122 if (sel_scroll_ev.active) 2083 if (sel_scroll_ev.active)
2123 sel_scroll_ev.stop(); 2084 sel_scroll_ev.stop();
2161 if (priv_modes & PrivMode_mouse_report 2122 if (priv_modes & PrivMode_mouse_report
2162 && bypass_keystate 2123 && bypass_keystate
2163 && ev.button == Button1 && MEvent.clicks <= 1) 2124 && ev.button == Button1 && MEvent.clicks <= 1)
2164 selection_extend (ev.x, ev.y, 0); 2125 selection_extend (ev.x, ev.y, 0);
2165 2126
2166 if (!HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) 2127 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2167 return; 2128 return;
2168 2129
2169 switch (ev.button) 2130 switch (ev.button)
2170 { 2131 {
2171 case Button1: 2132 case Button1:
2172 case Button3: 2133 case Button3:
2173 selection_make (ev.time); 2134 selection_make (ev.time);
2174 break; 2135 break;
2136
2175 case Button2: 2137 case Button2:
2176 selection_request (ev.time, ev.x, ev.y); 2138 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window?
2139 selection_request (ev.time, ev.state & ShiftMask ? Sel_Clipboard : Sel_Primary);
2177 break; 2140 break;
2141
2178#ifdef MOUSE_WHEEL 2142#ifdef MOUSE_WHEEL
2179 case Button4: 2143 case Button4:
2180 case Button5: 2144 case Button5:
2181 { 2145 {
2182 int i; 2146 int i;
2204 slip_wheel_ev.start (); 2168 slip_wheel_ev.start ();
2205 } 2169 }
2206 else 2170 else
2207 { 2171 {
2208# endif 2172# endif
2209# ifdef JUMP_MOUSE_WHEEL
2210 scr_page (v, i); 2173 scr_page (v, i);
2211 scr_refresh (SMOOTH_REFRESH);
2212 scrollbar_show (1); 2174 scrollbar_show (1);
2213# else
2214 while (i--)
2215 {
2216 scr_page (v, 1);
2217 scr_refresh (SMOOTH_REFRESH);
2218 scrollbar_show (1);
2219 }
2220# endif
2221# ifdef MOUSE_SLIP_WHEELING 2175# ifdef MOUSE_SLIP_WHEELING
2222 } 2176 }
2223#endif 2177# endif
2224 } 2178 }
2225 break; 2179 break;
2226#endif 2180#endif
2227 } 2181 }
2228 } 2182 }
2229#ifdef MENUBAR
2230 else if (isMenuBarWindow (ev.window))
2231 menubar_control (ev);
2232#endif
2233} 2183}
2234 2184
2235#ifdef TRANSPARENT 2185#ifdef TRANSPARENT
2236#if TINTING 2186#if TINTING
2237/* taken from aterm-0.4.2 */ 2187/* taken from aterm-0.4.2 */
2717 2667
2718bool 2668bool
2719rxvt_term::cmd_parse () 2669rxvt_term::cmd_parse ()
2720{ 2670{
2721 bool flag = false; 2671 bool flag = false;
2722 unicode_t ch = NOCHAR; 2672 wchar_t ch = NOCHAR;
2723 char *seq_begin; // remember start of esc-sequence here 2673 char *seq_begin; // remember start of esc-sequence here
2724 2674
2725 for (;;) 2675 for (;;)
2726 { 2676 {
2727 if (ch == NOCHAR) 2677 if (ch == NOCHAR)
2748 if (seen_resize && cmd_pid) 2698 if (seen_resize && cmd_pid)
2749 kill (-cmd_pid, SIGWINCH); 2699 kill (-cmd_pid, SIGWINCH);
2750 } 2700 }
2751 2701
2752 /* Read a text string from the input buffer */ 2702 /* Read a text string from the input buffer */
2753 unicode_t buf[UBUFSIZ]; 2703 wchar_t buf[UBUFSIZ];
2754 bool refreshnow = false; 2704 bool refreshnow = false;
2755 int nlines = 0; 2705 int nlines = 0;
2756 unicode_t *str = buf; 2706 wchar_t *str = buf;
2757 unicode_t *eol = str + min (ncol, UBUFSIZ); 2707 wchar_t *eol = str + min (ncol, UBUFSIZ);
2758 2708
2759 for (;;) 2709 for (;;)
2760 { 2710 {
2761 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2711 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2762 break; 2712 break;
2780 } 2730 }
2781 2731
2782 // scr_add_lines only works for nlines <= nrow - 1. 2732 // scr_add_lines only works for nlines <= nrow - 1.
2783 if (nlines >= nrow - 1) 2733 if (nlines >= nrow - 1)
2784 { 2734 {
2735 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2785 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) 2736 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2786 scr_add_lines (buf, nlines, str - buf); 2737 scr_add_lines (buf, str - buf, nlines);
2787 2738
2788 nlines = 0; 2739 nlines = 0;
2789 str = buf; 2740 str = buf;
2790 eol = str + min (ncol, UBUFSIZ); 2741 eol = str + min (ncol, UBUFSIZ);
2791 } 2742 }
2805 2756
2806 seq_begin = cmdbuf_ptr; 2757 seq_begin = cmdbuf_ptr;
2807 ch = next_char (); 2758 ch = next_char ();
2808 } 2759 }
2809 2760
2761 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2810 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) 2762 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2811 scr_add_lines (buf, nlines, str - buf); 2763 scr_add_lines (buf, str - buf, nlines);
2812 2764
2813 /* 2765 /*
2814 * If there have been a lot of new lines, then update the screen 2766 * If there have been a lot of new lines, then update the screen
2815 * What the heck I'll cheat and only refresh less than every page-full. 2767 * What the heck I'll cheat and only refresh less than every page-full.
2816 * the number of pages between refreshes is refresh_limit, which 2768 * the number of pages between refreshes is refresh_limit, which
2821 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2773 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2822 refresh_limit++; 2774 refresh_limit++;
2823 else 2775 else
2824 { 2776 {
2825 flag = true; 2777 flag = true;
2826 scr_refresh (refresh_type); 2778 scr_refresh ();
2827 flush_ev.stop (); 2779 want_refresh = 1;
2828 } 2780 }
2829 } 2781 }
2830 2782
2831 } 2783 }
2832 else 2784 else
2847 } 2799 }
2848 2800
2849 return flag; 2801 return flag;
2850} 2802}
2851 2803
2852// read the next octet
2853unicode_t
2854rxvt_term::next_octet ()
2855{
2856 return cmdbuf_ptr < cmdbuf_endp
2857 ? *cmdbuf_ptr++
2858 : NOCHAR;
2859}
2860
2861// read the next character 2804// read the next character
2862unicode_t 2805wchar_t
2863rxvt_term::next_char () 2806rxvt_term::next_char () NOTHROW
2864{ 2807{
2865 while (cmdbuf_ptr < cmdbuf_endp) 2808 while (cmdbuf_ptr < cmdbuf_endp)
2866 { 2809 {
2867 // assume 7-bit to be ascii ALWAYS 2810 // assume 7-bit to be ascii ALWAYS
2868 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2811 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)
2877 cmdbuf_ptr = cmdbuf_endp; 2820 cmdbuf_ptr = cmdbuf_endp;
2878 break; 2821 break;
2879 } 2822 }
2880 2823
2881 if (len == (size_t)-1) 2824 if (len == (size_t)-1)
2882 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2825 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2883 2826
2884 // assume wchar == unicode 2827 // assume wchar == unicode
2885 cmdbuf_ptr += len; 2828 cmdbuf_ptr += len;
2886 return wc & UNICODE_MASK; 2829 return wc & UNICODE_MASK;
2887 } 2830 }
2888 2831
2889 return NOCHAR; 2832 return NOCHAR;
2890} 2833}
2834
2835// read the next octet
2836uint32_t
2837rxvt_term::next_octet () NOTHROW
2838{
2839 return cmdbuf_ptr < cmdbuf_endp
2840 ? (unsigned char)*cmdbuf_ptr++
2841 : NOCHAR;
2842}
2843
2844static class out_of_input out_of_input;
2891 2845
2892/* rxvt_cmd_getc () - Return next input character */ 2846/* rxvt_cmd_getc () - Return next input character */
2893/* 2847/*
2894 * Return the next input character after first passing any keyboard input 2848 * Return the next input character after first passing any keyboard input
2895 * to the command. 2849 * to the command.
2896 */ 2850 */
2897unicode_t 2851wchar_t
2898rxvt_term::cmd_getc () 2852rxvt_term::cmd_getc () THROW ((class out_of_input))
2899{ 2853{
2900 unicode_t c = next_char (); 2854 wchar_t c = next_char ();
2901 2855
2902 if (c == NOCHAR) 2856 if (c == NOCHAR)
2903 throw out_of_input; 2857 throw out_of_input;
2904 2858
2905 return c; 2859 return c;
2906} 2860}
2907 2861
2908unicode_t 2862uint32_t
2909rxvt_term::cmd_get8 () 2863rxvt_term::cmd_get8 () THROW ((class out_of_input))
2910{ 2864{
2911 unicode_t c = next_octet (); 2865 uint32_t c = next_octet ();
2912 2866
2913 if (c == NOCHAR) 2867 if (c == NOCHAR)
2914 throw out_of_input; 2868 throw out_of_input;
2915 2869
2916 return c; 2870 return c;
3183 break; 3137 break;
3184 3138
3185 /* 8.3.87: NEXT LINE */ 3139 /* 8.3.87: NEXT LINE */
3186 case C1_NEL: /* ESC E */ 3140 case C1_NEL: /* ESC E */
3187 { 3141 {
3188 unicode_t nlcr[] = { C0_LF, C0_CR }; 3142 wchar_t nlcr[] = { C0_LF, C0_CR };
3189 scr_add_lines (nlcr, 1, 2); 3143 scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1);
3190 } 3144 }
3191 break; 3145 break;
3192 3146
3193 /* kidnapped escape sequence: Should be 8.3.48 */ 3147 /* kidnapped escape sequence: Should be 8.3.48 */
3194 case C1_ESA: /* ESC G */ 3148 case C1_ESA: /* ESC G */
3793 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3747 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3794 */ 3748 */
3795void 3749void
3796rxvt_term::process_xterm_seq (int op, const char *str, char resp) 3750rxvt_term::process_xterm_seq (int op, const char *str, char resp)
3797{ 3751{
3798 int changed = 0;
3799 int color; 3752 int color;
3800 char *buf, *name; 3753 char *buf, *name;
3801 bool query = str[0] == '?' && !str[1]; 3754 bool query = str[0] == '?' && !str[1];
3802 int saveop = op; 3755 int saveop = op;
3803 dDisp; 3756 dDisp;
3858 { 3811 {
3859 if ((name = strchr (buf, ';')) == NULL) 3812 if ((name = strchr (buf, ';')) == NULL)
3860 break; 3813 break;
3861 3814
3862 *name++ = '\0'; 3815 *name++ = '\0';
3863 color = atoi (buf); 3816 color = atoi (buf) + minCOLOR;
3864 3817
3865 if (color < 0 || color >= TOTAL_COLORS) 3818 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3866 break; 3819 break;
3867 3820
3868 if ((buf = strchr (name, ';')) != NULL) 3821 if ((buf = strchr (name, ';')) != NULL)
3869 *buf++ = '\0'; 3822 *buf++ = '\0';
3870 3823
3871 if (name[0] == '?' && !name[1]) 3824 if (name[0] == '?' && !name[1])
3872 { 3825 {
3873 unsigned short r, g, b; 3826 unsigned short r, g, b;
3874 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3827 pix_colors_focused[color].get (display, r, g, b);
3875 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3828 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3876 } 3829 }
3877 else 3830 else
3878 set_window_color (color + minCOLOR, name); 3831 set_window_color (color, name);
3879 } 3832 }
3880 break; 3833 break;
3881 case XTerm_Color00: 3834 case XTerm_Color00:
3882 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3835 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3883 break; 3836 break;
3884 case XTerm_Color01: 3837 case XTerm_Color01:
3885 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3838 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3886 break; 3839 break;
3887#ifndef NO_CURSORCOLOR 3840#ifndef NO_CURSORCOLOR
3888 case XTerm_Color_cursor: 3841 case XTerm_Color_cursor:
3889 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3842 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3890 break; 3843 break;
3894 break; 3847 break;
3895 case XTerm_Color_pointer_bg: 3848 case XTerm_Color_pointer_bg:
3896 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3849 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3897 break; 3850 break;
3898#ifndef NO_BOLD_UNDERLINE_REVERSE 3851#ifndef NO_BOLD_UNDERLINE_REVERSE
3899 case XTerm_Color_BD:
3900 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3901 break;
3902 case XTerm_Color_UL:
3903 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3904 break;
3905 case XTerm_Color_RV: 3852 case XTerm_Color_RV:
3906 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3853 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3854 break;
3855 case Rxvt_Color_BD:
3856 case URxvt_Color_BD:
3857 process_color_seq (op, Color_BD, str, resp);
3858 break;
3859 case Rxvt_Color_UL:
3860 case URxvt_Color_UL:
3861 process_color_seq (op, Color_UL, str, resp);
3907 break; 3862 break;
3908 case URxvt_Color_IT: 3863 case URxvt_Color_IT:
3909 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3864 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3910 break; 3865 break;
3911#endif 3866#endif
3916 if (am_transparent) 3871 if (am_transparent)
3917 want_full_refresh = want_refresh = 1; 3872 want_full_refresh = want_refresh = 1;
3918 break; 3873 break;
3919#endif 3874#endif
3920 3875
3921 case XTerm_Pixmap: 3876 case Rxvt_Pixmap:
3877 {
3922 if (*str != ';') 3878 if (*str != ';')
3923 { 3879 {
3924#if XPM_BACKGROUND 3880#if XPM_BACKGROUND
3925 scale_pixmap (""); /* reset to default scaling */ 3881 scale_pixmap (""); /* reset to default scaling */
3926 set_bgPixmap (str); /* change pixmap */ 3882 set_bgPixmap (str); /* change pixmap */
3927#endif
3928 scr_touch (true); 3883 scr_touch (true);
3884#endif
3929 } 3885 }
3886
3887 int changed = 0;
3888
3930 while ((str = strchr (str, ';')) != NULL) 3889 while ((str = strchr (str, ';')) != NULL)
3931 { 3890 {
3932 str++; 3891 str++;
3933#if XPM_BACKGROUND 3892#if XPM_BACKGROUND
3934 changed += scale_pixmap (str); 3893 changed += scale_pixmap (str);
3935#endif 3894#endif
3936 } 3895 }
3937 3896
3938 if (changed) 3897 if (changed)
3939 { 3898 {
3940#ifdef XPM_BACKGROUND 3899#ifdef XPM_BACKGROUND
3941 resize_pixmap (); 3900 resize_pixmap ();
3942#endif
3943 scr_touch (true); 3901 scr_touch (true);
3902#endif
3944 } 3903 }
3904 }
3945 break; 3905 break;
3946 3906
3947 case XTerm_restoreFG: 3907 case Rxvt_restoreFG:
3948 set_window_color (Color_fg, str); 3908 set_window_color (Color_fg, str);
3949 break; 3909 break;
3950 case XTerm_restoreBG: 3910 case Rxvt_restoreBG:
3951 set_window_color (Color_bg, str); 3911 set_window_color (Color_bg, str);
3952 break; 3912 break;
3953 3913
3954 case XTerm_logfile: 3914 case XTerm_logfile:
3955 // TODO, when secure mode? 3915 // TODO, when secure mode?
3956 break; 3916 break;
3957 3917
3958#ifdef MENUBAR
3959 case URxvt_Menu:
3960 if (OPTION (Opt_insecure))
3961 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3962 break;
3963#endif
3964#if 0 3918#if 0
3965 case XTerm_dumpscreen: /* no error notices */ 3919 case Rxvt_dumpscreen: /* no error notices */
3966 { 3920 {
3967 int fd; 3921 int fd;
3968 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3922 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3969 { 3923 {
3970 scr_dump (fd); 3924 scr_dump (fd);
4001 if (query) 3955 if (query)
4002 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); 3956 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp);
4003 else 3957 else
4004 { 3958 {
4005 set_locale (str); 3959 set_locale (str);
4006 pty.set_utf8_mode (enc_utf8); 3960 pty->set_utf8_mode (enc_utf8);
4007 init_xlocale (); 3961 init_xlocale ();
4008 } 3962 }
4009 break; 3963 break;
4010 3964
4011 case URxvt_view_up: 3965 case URxvt_view_up:
4022 break; 3976 break;
4023#endif 3977#endif
4024 3978
4025#if ENABLE_PERL 3979#if ENABLE_PERL
4026 case URxvt_perl: 3980 case URxvt_perl:
4027 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) 3981 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END)))
4028 ; // no responses yet 3982 ; // no responses yet
4029 break; 3983 break;
4030#endif 3984#endif
4031 } 3985 }
4032} 3986}
4064 return state; 4018 return state;
4065} 4019}
4066 4020
4067/* we're not using priv _yet_ */ 4021/* we're not using priv _yet_ */
4068void 4022void
4069rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) 4023rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg)
4070{ 4024{
4071 unsigned int i, j; 4025 unsigned int i, j;
4072 int state; 4026 int state;
4073 4027
4074 static const struct 4028 static const struct
4085 { 5, PrivMode_rVideo }, 4039 { 5, PrivMode_rVideo },
4086 { 6, PrivMode_relOrigin }, 4040 { 6, PrivMode_relOrigin },
4087 { 7, PrivMode_Autowrap }, 4041 { 7, PrivMode_Autowrap },
4088 // 8, bi-directional support mode 4042 // 8, bi-directional support mode
4089 { 9, PrivMode_MouseX10 }, 4043 { 9, PrivMode_MouseX10 },
4090#ifdef menuBar_esc
4091 { menuBar_esc, PrivMode_menuBar },
4092#endif
4093 // 18, 19 printing-related 4044 // 18, 19 printing-related
4094 { 25, PrivMode_VisibleCursor }, 4045 { 25, PrivMode_VisibleCursor },
4095#ifdef scrollBar_esc 4046#ifdef scrollBar_esc
4096 { scrollBar_esc, PrivMode_scrollBar }, 4047 { scrollBar_esc, PrivMode_scrollBar },
4097#endif 4048#endif
4144 /* extra handling for values with state unkept */ 4095 /* extra handling for values with state unkept */
4145 switch (arg[i]) 4096 switch (arg[i])
4146 { 4097 {
4147#if ENABLE_STYLES 4098#if ENABLE_STYLES
4148 case 1021: 4099 case 1021:
4149 if (mode) 4100 set_option (Opt_intensityStyles, mode);
4150 SET_OPTION (Opt_intensityStyles);
4151 else
4152 CLR_OPTION (Opt_intensityStyles);
4153 4101
4154 scr_touch (true); 4102 scr_touch (true);
4155 break; 4103 break;
4156#endif 4104#endif
4157 case 1048: /* alternative cursor save */ 4105 case 1048: /* alternative cursor save */
4179 case 3: /* 80/132 */ 4127 case 3: /* 80/132 */
4180 if (priv_modes & PrivMode_132OK) 4128 if (priv_modes & PrivMode_132OK)
4181 set_widthheight (((state ? 132 : 80) * fwidth), height); 4129 set_widthheight (((state ? 132 : 80) * fwidth), height);
4182 break; 4130 break;
4183 case 4: /* smooth scrolling */ 4131 case 4: /* smooth scrolling */
4184 if (!state) 4132 set_option (Opt_jumpScroll, !state);
4185 SET_OPTION (Opt_jumpScroll);
4186 else
4187 CLR_OPTION (Opt_jumpScroll);
4188 break; 4133 break;
4189 case 5: /* reverse video */ 4134 case 5: /* reverse video */
4190 scr_rvideo_mode (state); 4135 scr_rvideo_mode (state);
4191 break; 4136 break;
4192 case 6: /* relative/absolute origins */ 4137 case 6: /* relative/absolute origins */
4198 /* case 8: - auto repeat, can't do on a per window basis */ 4143 /* case 8: - auto repeat, can't do on a per window basis */
4199 case 9: /* X10 mouse reporting */ 4144 case 9: /* X10 mouse reporting */
4200 if (state) /* orthogonal */ 4145 if (state) /* orthogonal */
4201 priv_modes &= ~PrivMode_MouseX11; 4146 priv_modes &= ~PrivMode_MouseX11;
4202 break; 4147 break;
4203#ifdef menuBar_esc
4204 case menuBar_esc:
4205#ifdef MENUBAR
4206 map_menuBar (state);
4207#endif
4208 break;
4209#endif
4210#ifdef scrollBar_esc 4148#ifdef scrollBar_esc
4211 case scrollBar_esc: 4149 case scrollBar_esc:
4212 if (scrollbar_mapping (state)) 4150 if (scrollbar_mapping (state))
4213 { 4151 {
4214 resize_all_windows (0, 0, 0); 4152 resize_all_windows (0, 0, 0);
4233#if 0 4171#if 0
4234 case 1001: 4172 case 1001:
4235 break; /* X11 mouse highlighting */ 4173 break; /* X11 mouse highlighting */
4236#endif 4174#endif
4237 case 1010: /* scroll to bottom on TTY output inhibit */ 4175 case 1010: /* scroll to bottom on TTY output inhibit */
4238 if (!state) 4176 set_option (Opt_scrollTtyOutput, !state);
4239 SET_OPTION (Opt_scrollTtyOutput);
4240 else
4241 CLR_OPTION (Opt_scrollTtyOutput);
4242 break; 4177 break;
4243 case 1011: /* scroll to bottom on key press */ 4178 case 1011: /* scroll to bottom on key press */
4244 if (state) 4179 set_option (Opt_scrollTtyKeypress, state);
4245 SET_OPTION (Opt_scrollTtyKeypress);
4246 else
4247 CLR_OPTION (Opt_scrollTtyKeypress);
4248 break; 4180 break;
4249 case 1047: /* secondary screen w/ clearing last */ 4181 case 1047: /* secondary screen w/ clearing last */
4250 if (OPTION (Opt_secondaryScreen)) 4182 if (OPTION (Opt_secondaryScreen))
4251 if (current_screen != PRIMARY) 4183 if (current_screen != PRIMARY)
4252 scr_erase_screen (2); 4184 scr_erase_screen (2);
4462const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4394const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4463 4395
4464void 4396void
4465rxvt_term::tt_write (const char *data, unsigned int len) 4397rxvt_term::tt_write (const char *data, unsigned int len)
4466{ 4398{
4467 if (pty.pty < 0) 4399 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4468 return; 4400 return;
4469 4401
4402 if (pty->pty < 0)
4403 return;
4404
4470 if (v_buflen == 0) 4405 if (v_buflen == 0)
4471 { 4406 {
4472 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); 4407 ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE));
4473 4408
4474 if ((unsigned int)written == len) 4409 if ((unsigned int)written == len)
4475 return; 4410 return;
4476 4411
4477 data += written; 4412 data += written;
4486 pty_ev.set (EVENT_READ | EVENT_WRITE); 4421 pty_ev.set (EVENT_READ | EVENT_WRITE);
4487} 4422}
4488 4423
4489void rxvt_term::pty_write () 4424void rxvt_term::pty_write ()
4490{ 4425{
4491 int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 4426 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4492 4427
4493 if (written > 0) 4428 if (written > 0)
4494 { 4429 {
4495 v_buflen -= written; 4430 v_buflen -= written;
4496 4431

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines