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.454 by sf-exg, Sat Aug 21 16:07:15 2010 UTC vs.
Revision 1.486 by sf-exg, Fri Apr 29 13:29:45 2011 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-2007 Marc Lehmann <pcg@goof.com> 30 * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de>
31 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> 31 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it>
32 * 32 *
33 * This program is free software; you can redistribute it and/or modify 33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by 34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or 35 * the Free Software Foundation; either version 2 of the License, or
257#endif 257#endif
258 258
259void 259void
260rxvt_term::commit_iso14755 () 260rxvt_term::commit_iso14755 ()
261{ 261{
262 wchar_t ch[2];
263
264 ch[0] = iso14755buf & ISO_14755_MASK; 262 wchar_t ch = iso14755buf & ISO_14755_MASK;
265 ch[1] = 0;
266 263
267 if (iso14755buf & ISO_14755_51) 264 if (iso14755buf & ISO_14755_51)
268 { 265 {
269 char mb[16]; 266 char mb[MB_LEN_MAX];
270 int len; 267 int len;
271 268
272 // allow verbatim 0-bytes and control-bytes to be entered 269 // allow verbatim 0-bytes and control-bytes to be entered
273 if (ch[0] >= 0x20) 270 if (ch >= 0x20)
274 len = wcstombs (mb, ch, 16); 271 len = wctomb (mb, ch);
275 else 272 else
276 { 273 {
277 mb[0] = ch[0]; 274 mb[0] = ch;
278 len = 1; 275 len = 1;
279 } 276 }
280 277
281 if (len > 0) 278 if (len > 0)
282 tt_write (mb, len); 279 tt_write (mb, len);
569 selection_request (ev.time); 566 selection_request (ev.time);
570 return; 567 return;
571#if TODO 568#if TODO
572 /* rxvt extras */ 569 /* rxvt extras */
573 case XK_KP_Add: /* Shift+KP_Add = bigger font */ 570 case XK_KP_Add: /* Shift+KP_Add = bigger font */
574 change_font (FONT_UP);
575 return; 571 return;
576 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ 572 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */
577 change_font (FONT_DN);
578 return; 573 return;
579#endif 574#endif
580 } 575 }
581 } 576 }
582 } 577 }
771 766
772 default: 767 default:
773 { 768 {
774 int param = map_function_key (keysym); 769 int param = map_function_key (keysym);
775 if (param > 0) 770 if (param > 0)
776 {
777 int n = sprintf (kbuf,"\033[%d~", param); 771 sprintf (kbuf,"\033[%d~", param);
778 /*
779 * pass Shift/Control indicators for function keys ending with `~'
780 *
781 * eg,
782 * Prior = "ESC[5~"
783 * Shift+Prior = "ESC[5$"
784 * Ctrl+Prior = "ESC[5^"
785 * Ctrl+Shift+Prior = "ESC[5@"
786 */
787 kbuf[n-1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
788 }
789 else 772 else
790 newlen = 0; 773 newlen = 0;
791 } 774 }
792 break; 775 break;
793 } 776 }
844 view_start = 0; 827 view_start = 0;
845 want_refresh = 1; 828 want_refresh = 1;
846 } 829 }
847 830
848 /* 831 /*
832 * these modifications only affect the static keybuffer
833 * pass Shift/Control indicators for function keys ending with `~'
834 *
835 * eg,
836 * Prior = "ESC[5~"
837 * Shift+Prior = "ESC[5$"
838 * Ctrl+Prior = "ESC[5^"
839 * Ctrl+Shift+Prior = "ESC[5@"
849 * Meta adds an Escape prefix (with META8_OPTION, if meta == <escape>). 840 * Meta adds an Escape prefix (with META8_OPTION, if meta == <escape>).
850 */ 841 */
842 if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~')
843 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
851 844
852 /* escape prefix */ 845 /* escape prefix */
853 if (meta 846 if (meta
854#ifdef META8_OPTION 847#ifdef META8_OPTION
855 && meta_char == C0_ESC 848 && meta_char == C0_ESC
891 commit_iso14755 (); 884 commit_iso14755 ();
892 885
893 return; 886 return;
894 } 887 }
895 888
896 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) 889 for (unsigned short *i = iso14755_symtab; i[0]; i += 2)
897 if (i[0] == keysym) 890 if (i[0] == keysym)
898 { 891 {
899 iso14755buf = ISO_14755_51 | i[1]; 892 iso14755buf = ISO_14755_51 | i[1];
900 commit_iso14755 (); 893 commit_iso14755 ();
901 894
938 else if (keysym == XK_Control_L || keysym == XK_Control_R) 931 else if (keysym == XK_Control_L || keysym == XK_Control_R)
939 mouse_slip_wheel_speed = 0; 932 mouse_slip_wheel_speed = 0;
940#endif 933#endif
941} 934}
942 935
943#if defined (KEYSYM_RESOURCE)
944unsigned int
945rxvt_term::cmd_write (const char *str, unsigned int count)
946{
947 unsigned int n, s;
948
949 n = cmdbuf_ptr - cmdbuf_base;
950 s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp;
951
952 if (n > 0 && s < count)
953 {
954 memmove (cmdbuf_base, cmdbuf_ptr,
955 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
956 cmdbuf_ptr = cmdbuf_base;
957 cmdbuf_endp -= n;
958 s += n;
959 }
960
961 if (count > s)
962 {
963 rxvt_warn ("data loss: cmd_write too large, continuing.\n");
964 count = s;
965 }
966
967 for (; count--;)
968 *cmdbuf_endp++ = *str++;
969
970 cmd_parse ();
971
972 return 0;
973}
974#endif
975
976void 936void
977rxvt_term::flush () 937rxvt_term::flush ()
978{ 938{
979 flush_ev.stop (); 939 flush_ev.stop ();
980 940
981#ifdef HAVE_BG_PIXMAP 941#ifdef HAVE_BG_PIXMAP
982 if (bgPixmap.check_clearChanged ()) 942 if (bg_flags & BG_NEEDS_REFRESH)
983 { 943 {
984// scr_clear (true); This needs to be researched further! 944 bg_flags &= ~BG_NEEDS_REFRESH;
985 scr_touch (false); 945 scr_touch (false);
986 } 946 }
987#endif 947#endif
988 948
989 if (want_refresh) 949 if (want_refresh)
1154 { 1114 {
1155 } 1115 }
1156} event_handler; 1116} event_handler;
1157#endif 1117#endif
1158 1118
1119/* make sure all the cmd data is at beginning of cmdbuf */
1120void
1121rxvt_term::cmdbuf_reify ()
1122{
1123 if (cmdbuf_ptr == cmdbuf_base)
1124 return;
1125
1126 ssize_t used = cmdbuf_endp - cmdbuf_ptr;
1127
1128 memmove (cmdbuf_base, cmdbuf_ptr, used);
1129 cmdbuf_ptr = cmdbuf_base;
1130 cmdbuf_endp = cmdbuf_ptr + used;
1131
1132}
1133
1134#if defined (KEYSYM_RESOURCE)
1135void
1136rxvt_term::cmdbuf_append (const char *str, size_t count)
1137{
1138 cmdbuf_reify ();
1139
1140 size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp;
1141
1142 if (count > avail)
1143 return;
1144
1145 memcpy (cmdbuf_endp, str, count);
1146 cmdbuf_endp += count;
1147
1148 cmd_parse ();
1149}
1150#endif
1151
1159bool 1152bool
1160rxvt_term::pty_fill () 1153rxvt_term::pty_fill ()
1161{ 1154{
1162 ssize_t n = cmdbuf_endp - cmdbuf_ptr; 1155 cmdbuf_reify ();
1163 1156
1164 if (CBUFSIZ == n) 1157 size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp;
1165 { 1158
1166 rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); 1159 if (!avail)
1167 n = 0;
1168 } 1160 {
1169 1161 // normally this indicates a "too long" command sequence - just drop the data we have
1170 memmove (cmdbuf_base, cmdbuf_ptr, n);
1171 cmdbuf_ptr = cmdbuf_base; 1162 cmdbuf_ptr = cmdbuf_base;
1172 cmdbuf_endp = cmdbuf_ptr + n; 1163 cmdbuf_endp = cmdbuf_ptr;
1164 avail = CBUFSIZ;
1165 }
1173 1166
1174 ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); 1167 ssize_t r = read (pty->pty, cmdbuf_endp, avail);
1175 1168
1176 if (r > 0) 1169 if (r > 0)
1177 { 1170 {
1178 cmdbuf_endp += r; 1171 cmdbuf_endp += r;
1179 return true; 1172 return true;
1253{ 1246{
1254 int button_number, key_state = 0; 1247 int button_number, key_state = 0;
1255 int x, y; 1248 int x, y;
1256 int code = 32; 1249 int code = 32;
1257 1250
1258 x = Pixel2Col (ev.x); 1251 x = Pixel2Col (ev.x) + 1;
1259 y = Pixel2Row (ev.y); 1252 y = Pixel2Row (ev.y) + 1;
1253
1260 if (ev.type == MotionNotify) 1254 if (ev.type == MotionNotify)
1261 { 1255 {
1262 if (x == mouse_row && y == mouse_col) 1256 if (x == mouse_row && y == mouse_col)
1263 return; 1257 return;
1258
1264 mouse_row = x; 1259 mouse_row = x;
1265 mouse_col = y; 1260 mouse_col = y;
1266 code += 32; 1261 code += 32;
1267 } 1262 }
1268 1263
1271 else 1266 else
1272 { 1267 {
1273 button_number = MEvent.button - Button1; 1268 button_number = MEvent.button - Button1;
1274 /* add 0x3D for wheel events, like xterm does */ 1269 /* add 0x3D for wheel events, like xterm does */
1275 if (button_number >= 3) 1270 if (button_number >= 3)
1276 button_number += (64 - 3); 1271 button_number += 64 - 3;
1277 } 1272 }
1278 1273
1279 if (priv_modes & PrivMode_MouseX10) 1274 if (priv_modes & PrivMode_MouseX10)
1280 { 1275 {
1281 /* 1276 /*
1313 fputc ('A', stderr); 1308 fputc ('A', stderr);
1314 if (key_state & 32) 1309 if (key_state & 32)
1315 fputc ('2', stderr); 1310 fputc ('2', stderr);
1316 fprintf (stderr, "]: <%d>, %d/%d\n", 1311 fprintf (stderr, "]: <%d>, %d/%d\n",
1317 button_number, 1312 button_number,
1318 x + 1, 1313 x,
1319 y + 1); 1314 y);
1320#endif 1315#endif
1321 1316
1317#if ENABLE_FRILLS
1318 if (priv_modes & PrivMode_ExtMouseRight)
1319 tt_printf ("\033[%d;%d;%dM",
1320 code + button_number + key_state,
1321 x,
1322 y);
1323 else if (priv_modes & PrivMode_ExtModeMouse)
1324 tt_printf ("\033[M%c%lc%lc",
1325 code + button_number + key_state,
1326 wint_t (32 + x),
1327 wint_t (32 + y));
1328 else
1329#endif
1322 tt_printf ("\033[M%c%c%c", 1330 tt_printf ("\033[M%c%c%c",
1323 (code + button_number + key_state), 1331 code + button_number + key_state,
1324 (32 + x + 1), 1332 32 + x,
1325 (32 + y + 1)); 1333 32 + y);
1326} 1334}
1327 1335
1328/*{{{ process an X event */ 1336/*{{{ process an X event */
1329void 1337void
1330rxvt_term::x_cb (XEvent &ev) 1338rxvt_term::x_cb (XEvent &ev)
1432 && ev.xfocus.mode != NotifyGrab) 1440 && ev.xfocus.mode != NotifyGrab)
1433 focus_out (); 1441 focus_out ();
1434 break; 1442 break;
1435 1443
1436 case ConfigureNotify: 1444 case ConfigureNotify:
1437 /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n",
1438 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y,
1439 szHint.width, szHint.height);*/
1440 if (ev.xconfigure.window == parent[0]) 1445 if (ev.xconfigure.window == parent)
1441 { 1446 {
1442 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1447 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1443 ; 1448 ;
1449
1450#ifdef HAVE_BG_PIXMAP
1451 bool moved = false;
1452 if (bg_window_position_sensitive ())
1453 {
1454 int x, y;
1455 if (ev.xconfigure.send_event)
1456 {
1457 x = ev.xconfigure.x;
1458 y = ev.xconfigure.y;
1459 }
1460 else
1461 get_window_origin (x, y);
1462
1463 if (bg_set_position (x, y)
1464 || !(bg_flags & BG_IS_VALID))
1465 moved = true;
1466 }
1467#endif
1444 1468
1445 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1469 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1446 { 1470 {
1447 seen_resize = 1; 1471 seen_resize = 1;
1448 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1472 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1449 } 1473 }
1450 else 1474 else
1451 { 1475 {
1452#ifdef HAVE_BG_PIXMAP 1476#ifdef HAVE_BG_PIXMAP
1453 if (bgPixmap.window_position_sensitive ()) 1477 if (moved)
1454 { 1478 {
1455 if (mapped) 1479 if (mapped)
1456 update_background (); 1480 update_background ();
1457 else 1481 else
1458 bgPixmap.invalidate (); 1482 bg_invalidate ();
1459 } 1483 }
1460#endif 1484#endif
1461 } 1485 }
1462 1486
1463 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1487 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1464 } 1488 }
1465 break; 1489 break;
1466 1490
1467 case PropertyNotify: 1491 case PropertyNotify:
1468 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) 1492 HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END));
1469 if (ev.xproperty.atom == xa[XA_VT_SELECTION]
1470 && ev.xproperty.state == PropertyNewValue)
1471 selection_property (ev.xproperty.window, ev.xproperty.atom);
1472
1473 break; 1493 break;
1474 1494
1475 case SelectionClear: 1495 case SelectionClear:
1476 selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]); 1496 selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]);
1477 break;
1478
1479 case SelectionNotify:
1480 if (selection_wait == Sel_normal)
1481 selection_paste (ev.xselection.requestor, ev.xselection.property, true);
1482 break; 1497 break;
1483 1498
1484 case SelectionRequest: 1499 case SelectionRequest:
1485 selection_send (ev.xselectionrequest); 1500 selection_send (ev.xselectionrequest);
1486 break; 1501 break;
1497 * by scheduling background redraw as soon as we can, but giving a short 1512 * by scheduling background redraw as soon as we can, but giving a short
1498 * bit of time for ConfigureNotifies to arrive. 1513 * bit of time for ConfigureNotifies to arrive.
1499 * We should render background PRIOR to drawing any text, but AFTER all 1514 * We should render background PRIOR to drawing any text, but AFTER all
1500 * of ConfigureNotifys for the best results. 1515 * of ConfigureNotifys for the best results.
1501 */ 1516 */
1502 if (bgPixmap.flags & bgPixmap_t::isInvalid) 1517 if (!(bg_flags & BG_IS_VALID))
1503 update_background_ev.start (0.025); 1518 update_background_ev.start (0.025);
1504#endif 1519#endif
1505 mapped = 1; 1520 mapped = 1;
1506#ifdef TEXT_BLINK 1521#ifdef TEXT_BLINK
1507 text_blink_ev.start (); 1522 text_blink_ev.start ();
1522 if (ev.xany.window == vt) 1537 if (ev.xany.window == vt)
1523 { 1538 {
1524 do 1539 do
1525 { 1540 {
1526 scr_expose (ev.xexpose.x, ev.xexpose.y, 1541 scr_expose (ev.xexpose.x, ev.xexpose.y,
1527 ev.xexpose.width, ev.xexpose.height, False); 1542 ev.xexpose.width, ev.xexpose.height, false);
1528 } 1543 }
1529 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); 1544 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1530 1545
1531 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1546 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1532 1547
1533 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1548 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1534 { 1549 {
1535 scr_expose (ev.xexpose.x, ev.xexpose.y, 1550 scr_expose (ev.xexpose.x, ev.xexpose.y,
1536 ev.xexpose.width, ev.xexpose.height, False); 1551 ev.xexpose.width, ev.xexpose.height, false);
1537 } 1552 }
1538 1553
1539 want_refresh = 1; 1554 want_refresh = 1;
1540 } 1555 }
1541 else 1556 else
1701rxvt_term::set_urgency (bool enable) 1716rxvt_term::set_urgency (bool enable)
1702{ 1717{
1703 if (enable == urgency_hint) 1718 if (enable == urgency_hint)
1704 return; 1719 return;
1705 1720
1706 if (XWMHints *h = XGetWMHints (dpy, parent[0])) 1721 if (XWMHints *h = XGetWMHints (dpy, parent))
1707 { 1722 {
1708 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); 1723 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1709 XSetWMHints (dpy, parent[0], h); 1724 XSetWMHints (dpy, parent, h);
1710 urgency_hint = enable; 1725 urgency_hint = enable;
1711 } 1726 }
1712} 1727}
1713#endif 1728#endif
1714 1729
1822 * use the property to determine the pixmap. We use it later on. 1837 * use the property to determine the pixmap. We use it later on.
1823 */ 1838 */
1824 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] 1839 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1825 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) 1840 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1826 { 1841 {
1827 bgPixmap.set_root_pixmap (); 1842 bg_set_root_pixmap ();
1828 update_background (); 1843 update_background ();
1829 } 1844 }
1830 1845
1831 break; 1846 break;
1832 } 1847 }
2369 : NOCHAR; 2384 : NOCHAR;
2370} 2385}
2371 2386
2372static class out_of_input out_of_input; 2387static class out_of_input out_of_input;
2373 2388
2374/* rxvt_cmd_getc () - Return next input character */
2375/*
2376 * Return the next input character after first passing any keyboard input
2377 * to the command.
2378 */
2379wchar_t 2389wchar_t
2380rxvt_term::cmd_getc () THROW ((class out_of_input)) 2390rxvt_term::cmd_getc () THROW ((class out_of_input))
2381{ 2391{
2382 wchar_t c = next_char (); 2392 wchar_t c = next_char ();
2383 2393
2476 pclose_printer (fd); 2486 pclose_printer (fd);
2477} 2487}
2478#endif /* PRINTPIPE */ 2488#endif /* PRINTPIPE */
2479/*}}} */ 2489/*}}} */
2480 2490
2481/* *INDENT-OFF* */
2482enum { 2491enum {
2483 C1_40 = 0x40, 2492 C1_40 = 0x40,
2484 C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, 2493 C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA,
2485 C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3, 2494 C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3,
2486 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, 2495 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,
2487 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC, 2496 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC,
2488}; 2497};
2489/* *INDENT-ON* */
2490 2498
2491/*{{{ process non-printing single characters */ 2499/*{{{ process non-printing single characters */
2492void 2500void
2493rxvt_term::process_nonprinting (unicode_t ch) 2501rxvt_term::process_nonprinting (unicode_t ch)
2494{ 2502{
2665 2673
2666 /* 8.3.87: NEXT LINE */ 2674 /* 8.3.87: NEXT LINE */
2667 case C1_NEL: /* ESC E */ 2675 case C1_NEL: /* ESC E */
2668 { 2676 {
2669 wchar_t nlcr[] = { C0_LF, C0_CR }; 2677 wchar_t nlcr[] = { C0_LF, C0_CR };
2670 scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); 2678 scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1);
2671 } 2679 }
2672 break; 2680 break;
2673 2681
2674 /* kidnapped escape sequence: Should be 8.3.48 */ 2682 /* kidnapped escape sequence: Should be 8.3.48 */
2675 case C1_ESA: /* ESC G */ 2683 case C1_ESA: /* ESC G */
2676 process_graphics (); 2684 // used by original rxvt for rob nations own graphics mode
2685 if (cmd_getc () == 'Q')
2686 tt_printf ("\033G0\012"); /* query graphics - no graphics */
2677 break; 2687 break;
2678 2688
2679 /* 8.3.63: CHARACTER TABULATION SET */ 2689 /* 8.3.63: CHARACTER TABULATION SET */
2680 case C1_HTS: /* ESC H */ 2690 case C1_HTS: /* ESC H */
2681 scr_set_tab (1); 2691 scr_set_tab (1);
2731 } 2741 }
2732} 2742}
2733/*}}} */ 2743/*}}} */
2734 2744
2735/*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ 2745/*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */
2736/* *INDENT-OFF* */
2737enum { 2746enum {
2738 CSI_ICH = 0x40, 2747 CSI_ICH = 0x40,
2739 CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, 2748 CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA,
2740 CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , 2749 CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA ,
2741 CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, 2750 CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC,
2744 CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, 2753 CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ,
2745 CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , 2754 CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 ,
2746 CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F 2755 CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F
2747}; 2756};
2748 2757
2749#define make_byte(b7,b6,b5,b4,b3,b2,b1,b0) \ 2758#define make_byte(b0,b1,b2,b3,b4,b5,b6,b7) \
2750 (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ 2759 (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \
2751 | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) 2760 | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0))
2752#define get_byte_array_bit(array, bit) \ 2761#define get_byte_array_bit(array, bit) \
2753 (!! ((array)[ (bit) / 8] & (128 >> ((bit) & 7)))) 2762 (!! ((array)[(bit) >> 3] & (1 << ((bit) & 7))))
2754 2763
2755const unsigned char csi_defaults[] = 2764static const unsigned char csi_defaults[] =
2756 { 2765 {
2757 make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ 2766 make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */
2758 make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ 2767 make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */
2759 make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ 2768 make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */
2760 make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ 2769 make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */
2761 make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ 2770 make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */
2762 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ 2771 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */
2763 make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ 2772 make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */
2764 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */ 2773 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */
2765 }; 2774 };
2766/* *INDENT-ON* */
2767 2775
2768void 2776void
2769rxvt_term::process_csi_seq () 2777rxvt_term::process_csi_seq ()
2770{ 2778{
2771 unicode_t ch, priv, i; 2779 unicode_t ch, priv, i;
2849 { 2857 {
2850 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ 2858 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */
2851 scr_soft_reset (); 2859 scr_soft_reset ();
2852 2860
2853 static const int pm_h[] = { 7, 25 }; 2861 static const int pm_h[] = { 7, 25 };
2854 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 }; 2862 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 };
2855 2863
2856 process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h); 2864 process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h);
2857 process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l); 2865 process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l);
2858 } 2866 }
2859 break; 2867 break;
2860 } 2868 }
2861 2869
2862 return; 2870 return;
3081 } 3089 }
3082} 3090}
3083/*}}} */ 3091/*}}} */
3084 3092
3085#if !ENABLE_MINIMAL 3093#if !ENABLE_MINIMAL
3086/* ARGSUSED */
3087void 3094void
3088rxvt_term::process_window_ops (const int *args, unsigned int nargs) 3095rxvt_term::process_window_ops (const int *args, unsigned int nargs)
3089{ 3096{
3090 int x, y; 3097 int x, y;
3091 XWindowAttributes wattr; 3098 XWindowAttributes wattr;
3100 { 3107 {
3101 /* 3108 /*
3102 * commands 3109 * commands
3103 */ 3110 */
3104 case 1: /* deiconify window */ 3111 case 1: /* deiconify window */
3105 XMapWindow (dpy, parent[0]); 3112 XMapWindow (dpy, parent);
3106 break; 3113 break;
3107 case 2: /* iconify window */ 3114 case 2: /* iconify window */
3108 XIconifyWindow (dpy, parent[0], display->screen); 3115 XIconifyWindow (dpy, parent, display->screen);
3109 break; 3116 break;
3110 case 3: /* set position (pixels) */ 3117 case 3: /* set position (pixels) */
3111 XMoveWindow (dpy, parent[0], args[1], args[2]); 3118 XMoveWindow (dpy, parent, args[1], args[2]);
3112 break; 3119 break;
3113 case 4: /* set size (pixels) */ 3120 case 4: /* set size (pixels) */
3114 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); 3121 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
3115 break; 3122 break;
3116 case 5: /* raise window */ 3123 case 5: /* raise window */
3117 XRaiseWindow (dpy, parent[0]); 3124 XRaiseWindow (dpy, parent);
3118 break; 3125 break;
3119 case 6: /* lower window */ 3126 case 6: /* lower window */
3120 XLowerWindow (dpy, parent[0]); 3127 XLowerWindow (dpy, parent);
3121 break; 3128 break;
3122 case 7: /* refresh window */ 3129 case 7: /* refresh window */
3123 scr_touch (true); 3130 scr_touch (true);
3124 break; 3131 break;
3125 case 8: /* set size (chars) */ 3132 case 8: /* set size (chars) */
3136 3143
3137 /* 3144 /*
3138 * reports - some output format copied from XTerm 3145 * reports - some output format copied from XTerm
3139 */ 3146 */
3140 case 11: /* report window state */ 3147 case 11: /* report window state */
3141 XGetWindowAttributes (dpy, parent[0], &wattr); 3148 XGetWindowAttributes (dpy, parent, &wattr);
3142 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3149 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
3143 break; 3150 break;
3144 case 13: /* report window position */ 3151 case 13: /* report window position */
3145 XGetWindowAttributes (dpy, parent[0], &wattr); 3152 XGetWindowAttributes (dpy, parent, &wattr);
3146 XTranslateCoordinates (dpy, parent[0], wattr.root, 3153 XTranslateCoordinates (dpy, parent, wattr.root,
3147 -wattr.border_width, -wattr.border_width, 3154 -wattr.border_width, -wattr.border_width,
3148 &x, &y, &wdummy); 3155 &x, &y, &wdummy);
3149 tt_printf ("\033[3;%d;%dt", x, y); 3156 tt_printf ("\033[3;%d;%dt", x, y);
3150 break; 3157 break;
3151 case 14: /* report window size (pixels) */ 3158 case 14: /* report window size (pixels) */
3152 XGetWindowAttributes (dpy, parent[0], &wattr); 3159 XGetWindowAttributes (dpy, parent, &wattr);
3153 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3160 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
3154 break; 3161 break;
3155 case 18: /* report text area size (chars) */ 3162 case 18: /* report text area size (chars) */
3156 tt_printf ("\033[8;%d;%dt", nrow, ncol); 3163 tt_printf ("\033[8;%d;%dt", nrow, ncol);
3157 break; 3164 break;
3159 tt_printf ("\033[9;%d;%dt", nrow, ncol); 3166 tt_printf ("\033[9;%d;%dt", nrow, ncol);
3160 break; 3167 break;
3161 case 20: /* report icon label */ 3168 case 20: /* report icon label */
3162 { 3169 {
3163 char *s; 3170 char *s;
3164 XGetIconName (dpy, parent[0], &s); 3171 XGetIconName (dpy, parent, &s);
3165 tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3172 tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3166 XFree (s); 3173 XFree (s);
3167 } 3174 }
3168 break; 3175 break;
3169 case 21: /* report window title */ 3176 case 21: /* report window title */
3170 { 3177 {
3171 char *s; 3178 char *s;
3172 XFetchName (dpy, parent[0], &s); 3179 XFetchName (dpy, parent, &s);
3173 tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3180 tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3174 XFree (s); 3181 XFree (s);
3175 } 3182 }
3176 break; 3183 break;
3177 } 3184 }
3331 unsigned long bytes_after; 3338 unsigned long bytes_after;
3332 unsigned char *value = 0; 3339 unsigned char *value = 0;
3333 const char *str = ""; 3340 const char *str = "";
3334 3341
3335 if (prop 3342 if (prop
3336 && XGetWindowProperty (dpy, parent[0], 3343 && XGetWindowProperty (dpy, parent,
3337 prop, 0, 1<<16, 0, AnyPropertyType, 3344 prop, 0, 1<<16, 0, AnyPropertyType,
3338 &actual_type, &actual_format, 3345 &actual_type, &actual_format,
3339 &nitems, &bytes_after, &value) == Success 3346 &nitems, &bytes_after, &value) == Success
3340 && actual_type != None 3347 && actual_type != None
3341 && actual_format == 8) 3348 && actual_format == 8)
3353 { 3360 {
3354 *eq = 0; 3361 *eq = 0;
3355 set_utf8_property (display->atom (str), eq + 1); 3362 set_utf8_property (display->atom (str), eq + 1);
3356 } 3363 }
3357 else 3364 else
3358 XDeleteProperty (dpy, parent[0], 3365 XDeleteProperty (dpy, parent,
3359 display->atom (str)); 3366 display->atom (str));
3360 } 3367 }
3361 break; 3368 break;
3362 3369
3363 case XTerm_Color: 3370 case XTerm_Color:
3424 process_color_seq (op, Color_tint, str, resp); 3431 process_color_seq (op, Color_tint, str, resp);
3425 { 3432 {
3426 bool changed = false; 3433 bool changed = false;
3427 3434
3428 if (ISSET_PIXCOLOR (Color_tint)) 3435 if (ISSET_PIXCOLOR (Color_tint))
3429 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); 3436 changed = bg_set_tint (pix_colors_focused [Color_tint]);
3430 else
3431 changed = bgPixmap.unset_tint ();
3432 3437
3433 if (changed) 3438 if (changed)
3434 update_background (); 3439 update_background ();
3435 } 3440 }
3436 3441
3442 if (!strcmp (str, "?")) 3447 if (!strcmp (str, "?"))
3443 { 3448 {
3444 char str[256]; 3449 char str[256];
3445 3450
3446 sprintf (str, "[%dx%d+%d+%d]", 3451 sprintf (str, "[%dx%d+%d+%d]",
3447 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), 3452 min (h_scale, 32767), min (v_scale, 32767),
3448 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); 3453 min (h_align, 32767), min (v_align, 32767));
3449 process_xterm_seq (XTerm_title, str, CHAR_ST); 3454 process_xterm_seq (XTerm_title, str, CHAR_ST);
3450 } 3455 }
3451 else 3456 else
3452 { 3457 {
3453 int changed = 0; 3458 int changed = 0;
3454 3459
3455 if (*str != ';') 3460 if (*str != ';')
3456 { 3461 {
3457 /* reset to default scaling :*/
3458 bgPixmap.unset_geometry ();
3459 if (bgPixmap.set_file (str)) /* change pixmap */ 3462 if (bg_set_file (str)) /* change pixmap */
3463 {
3460 changed++; 3464 changed++;
3461 str = strchr (str, ';'); 3465 str = strchr (str, ';');
3462 if (str == NULL) 3466 if (str == NULL)
3463 bgPixmap.set_defaultGeometry (); 3467 bg_set_default_geometry ();
3468 else
3469 bg_set_geometry (str+1);
3470 }
3464 } 3471 }
3465 3472 else
3466 while (str)
3467 { 3473 {
3468 str++; 3474 str++;
3469 if (bgPixmap.set_geometry (str)) 3475 if (bg_set_geometry (str, true))
3470 changed++; 3476 changed++;
3471 str = strchr (str, ';');
3472 } 3477 }
3473 3478
3474 if (changed) 3479 if (changed)
3480 {
3481 if (bg_window_position_sensitive ())
3482 {
3483 int x, y;
3484 get_window_origin (x, y);
3485 bg_set_position (x, y);
3486 }
3475 update_background (); 3487 update_background ();
3488 }
3476 } 3489 }
3477 break; 3490 break;
3478#endif 3491#endif
3479 3492
3480 case XTerm_logfile: 3493 case XTerm_logfile:
3631 { 67, PrivMode_BackSpace }, // DECBKM 3644 { 67, PrivMode_BackSpace }, // DECBKM
3632#endif 3645#endif
3633 { 1000, PrivMode_MouseX11 }, 3646 { 1000, PrivMode_MouseX11 },
3634 { 1002, PrivMode_MouseBtnEvent }, 3647 { 1002, PrivMode_MouseBtnEvent },
3635 { 1003, PrivMode_MouseAnyEvent }, 3648 { 1003, PrivMode_MouseAnyEvent },
3649#if ENABLE_FRILLS
3650 { 1005, PrivMode_ExtModeMouse },
3651#endif
3636 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3652 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3637 { 1011, PrivMode_Keypress }, // rxvt extension 3653 { 1011, PrivMode_Keypress }, // rxvt extension
3654#if ENABLE_FRILLS
3655 { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005
3656#endif
3638 // 1035 enable modifiers for alt, numlock NYI 3657 // 1035 enable modifiers for alt, numlock NYI
3639 // 1036 send ESC for meta keys NYI 3658 // 1036 send ESC for meta keys NYI
3640 // 1037 send DEL for keypad delete NYI 3659 // 1037 send DEL for keypad delete NYI
3641 { 1047, PrivMode_Screen }, 3660 { 1047, PrivMode_Screen },
3642 // 1048 save and restore cursor 3661 // 1048 save and restore cursor, implemented in code
3643 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ 3662 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
3644 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3663 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3645 { 2004, PrivMode_BracketPaste }, 3664 { 2004, PrivMode_BracketPaste },
3646 }; 3665 };
3647 3666
3657 for (i = 0; i < nargs; i++) 3676 for (i = 0; i < nargs; i++)
3658 { 3677 {
3659 state = -1; 3678 state = -1;
3660 3679
3661 /* basic handling */ 3680 /* basic handling */
3662 for (j = 0; j < (sizeof (argtopriv)/sizeof (argtopriv[0])); j++) 3681 for (j = 0; j < ARRAY_LENGTH(argtopriv); j++)
3663 if (argtopriv[j].argval == arg[i]) 3682 if (argtopriv[j].argval == arg[i])
3664 { 3683 {
3665 state = privcases (mode, argtopriv[j].bit); 3684 state = privcases (mode, argtopriv[j].bit);
3666 break; 3685 break;
3667 } 3686 }
3745 case 1003: 3764 case 1003:
3746 if (state) 3765 if (state)
3747 { 3766 {
3748 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); 3767 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3749 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; 3768 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3769 mouse_row = mouse_col = 0;
3750 vt_emask_mouse = PointerMotionMask; 3770 vt_emask_mouse = PointerMotionMask;
3751 } 3771 }
3752 else 3772 else
3753 vt_emask_mouse = NoEventMask; 3773 vt_emask_mouse = NoEventMask;
3754 3774
3939 } 3959 }
3940 } 3960 }
3941} 3961}
3942/*}}} */ 3962/*}}} */
3943 3963
3944/*{{{ (do not) process Rob Nation's own graphics mode sequences */
3945void
3946rxvt_term::process_graphics ()
3947{
3948 unicode_t ch, cmd = cmd_getc ();
3949
3950 if (cmd == 'Q')
3951 {
3952 /* query graphics */
3953 tt_printf ("\033G0\012"); /* no graphics */
3954 return;
3955 }
3956 /* swallow other graphics sequences until terminating ':' */
3957 do
3958 ch = cmd_getc ();
3959 while (ch != ':');
3960}
3961/*}}} */
3962
3963/* ------------------------------------------------------------------------- */ 3964/* ------------------------------------------------------------------------- */
3964 3965
3965/* 3966/*
3966 * Send printf () formatted output to the command. 3967 * Send printf () formatted output to the command.
3967 * Only use for small amounts of data. 3968 * Only use for small amounts of data.
3980 3981
3981/* ---------------------------------------------------------------------- */ 3982/* ---------------------------------------------------------------------- */
3982/* Write data to the pty as typed by the user, pasted with the mouse, 3983/* Write data to the pty as typed by the user, pasted with the mouse,
3983 * or generated by us in response to a query ESC sequence. 3984 * or generated by us in response to a query ESC sequence.
3984 */ 3985 */
3985const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 3986static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
3986 3987
3987void 3988void
3988rxvt_term::tt_write (const char *data, unsigned int len) 3989rxvt_term::tt_write (const char *data, unsigned int len)
3989{ 3990{
3990 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) 3991 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
3995 3996
3996 if (v_buflen == 0) 3997 if (v_buflen == 0)
3997 { 3998 {
3998 ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); 3999 ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE));
3999 4000
4001 max_it (written, 0);
4002
4000 if ((unsigned int)written == len) 4003 if (written == len)
4001 return; 4004 return;
4002 4005
4003 data += written; 4006 data += written;
4004 len -= written; 4007 len -= written;
4005 } 4008 }
4006 4009
4007 v_buffer = (char *)realloc (v_buffer, v_buflen + len); 4010 v_buffer = (char *)rxvt_realloc (v_buffer, v_buflen + len);
4008 4011
4009 memcpy (v_buffer + v_buflen, data, len); 4012 memcpy (v_buffer + v_buflen, data, len);
4010 v_buflen += len; 4013 v_buflen += len;
4011 4014
4012 pty_ev.set (ev::READ | ev::WRITE); 4015 pty_ev.set (ev::READ | ev::WRITE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines