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.145 by root, Mon Aug 16 12:04:57 2004 UTC vs.
Revision 1.175 by root, Sat Dec 11 17:18:29 2004 UTC

49#include "rxvt.h" /* NECESSARY */ 49#include "rxvt.h" /* NECESSARY */
50#include "version.h" 50#include "version.h"
51#include "command.h" 51#include "command.h"
52 52
53#include <wchar.h> 53#include <wchar.h>
54#include <signal.h>
54 55
55/*----------------------------------------------------------------------*/ 56/*----------------------------------------------------------------------*/
56 57
57#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 58#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
58 59
133 { 134 {
134 text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; 135 text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x];
135 136
136 if (t != NOCHAR || !x) 137 if (t != NOCHAR || !x)
137 { 138 {
138 iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]); 139 iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x],
140 screen.rend[y + TermWin.saveLines - TermWin.view_start][x]);
139 iso14755buf = ISO_14755_54; 141 iso14755buf = ISO_14755_54;
140 break; 142 break;
141 } 143 }
142 144
143 x--; 145 x--;
146} 148}
147#endif 149#endif
148 150
149#if ENABLE_OVERLAY 151#if ENABLE_OVERLAY
150void 152void
151rxvt_term::iso14755_51 (wchar_t ch) 153rxvt_term::iso14755_51 (unicode_t ch, rend_t r)
152{ 154{
155 rxvt_fontset *fs = FONTSET (r);
156 rxvt_font *f = (*fs)[fs->find_font (ch)];
153 wchar_t *chr, *alloc; 157 wchar_t *chr, *alloc, ch2;
154 int len; 158 int len;
155 159
156#if ENABLE_COMBINING 160#if ENABLE_COMBINING
157 if (IS_COMPOSE (ch)) 161 if (IS_COMPOSE (ch))
158 { 162 {
161 rxvt_composite.expand (ch, chr); 165 rxvt_composite.expand (ch, chr);
162 } 166 }
163 else 167 else
164#endif 168#endif
165 { 169 {
170 ch2 = ch;
171
166 alloc = 0; 172 alloc = 0;
167 chr = &ch; 173 chr = &ch2;
168 len = 1; 174 len = 1;
169 } 175 }
170 176
171 scr_overlay_new (0, -1, 8 + 5, len); 177 int width = strlen (f->name);
178
179 scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1);
180
181 r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r));
172 182
173 for (int y = 0; y < len; y++) 183 for (int y = 0; y < len; y++)
174 { 184 {
175 char buf[9]; 185 char buf[9];
176 186
181 scr_overlay_set (9, y, '='); 191 scr_overlay_set (9, y, '=');
182#if !UNICODE3 192#if !UNICODE3
183 if (ch >= 0x10000) 193 if (ch >= 0x10000)
184 ch = 0xfffd; 194 ch = 0xfffd;
185#endif 195#endif
186 scr_overlay_set (11, y, ch); 196 scr_overlay_set (11, y, ch, r);
187 scr_overlay_set (12, y, NOCHAR); 197 scr_overlay_set (12, y, NOCHAR, r);
188 } 198 }
199
200 scr_overlay_set (0, len, f->name);
189 201
190#if ENABLE_COMBINING 202#if ENABLE_COMBINING
191 if (alloc) 203 if (alloc)
192 delete [] alloc; 204 delete [] alloc;
193#endif 205#endif
406 { 418 {
407 /* normal XTerm key bindings */ 419 /* normal XTerm key bindings */
408 case XK_Insert: /* Shift+Insert = paste mouse selection */ 420 case XK_Insert: /* Shift+Insert = paste mouse selection */
409 selection_request (ev.time, 0, 0); 421 selection_request (ev.time, 0, 0);
410 return; 422 return;
411#if TODO // TODO 423#if TODO
412 /* rxvt extras */ 424 /* rxvt extras */
413 case XK_KP_Add: /* Shift+KP_Add = bigger font */ 425 case XK_KP_Add: /* Shift+KP_Add = bigger font */
414 change_font (FONT_UP); 426 change_font (FONT_UP);
415 return; 427 return;
416 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ 428 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */
899#endif /* MENUBAR_MAX */ 911#endif /* MENUBAR_MAX */
900 912
901void 913void
902rxvt_term::flush () 914rxvt_term::flush ()
903{ 915{
916 flush_ev.stop ();
917
904#ifdef TRANSPARENT 918#ifdef TRANSPARENT
905 if (want_full_refresh) 919 if (want_full_refresh)
906 { 920 {
907 want_full_refresh = 0; 921 want_full_refresh = 0;
908 scr_clear (); 922 scr_clear ();
918 IMSendSpot (); 932 IMSendSpot ();
919#endif 933#endif
920 } 934 }
921 935
922 display->flush (); 936 display->flush ();
923
924 flush_ev.stop ();
925} 937}
926 938
927void 939void
928rxvt_term::check_cb (check_watcher &w) 940rxvt_term::check_cb (check_watcher &w)
929{ 941{
1137 + ((MEvent.state & ModMetaMask) ? 8 : 0) 1149 + ((MEvent.state & ModMetaMask) ? 8 : 0)
1138 + ((MEvent.state & ControlMask) ? 16 : 0); 1150 + ((MEvent.state & ControlMask) ? 16 : 0);
1139#ifdef MOUSE_REPORT_DOUBLECLICK 1151#ifdef MOUSE_REPORT_DOUBLECLICK
1140 key_state += ((MEvent.clicks > 1) ? 32 : 0); 1152 key_state += ((MEvent.clicks > 1) ? 32 : 0);
1141#endif 1153#endif
1142
1143 } 1154 }
1144 1155
1145#ifdef DEBUG_MOUSEREPORT 1156#if DEBUG_MOUSEREPORT
1146 fprintf (stderr, "Mouse ["); 1157 fprintf (stderr, "Mouse [");
1147 if (key_state & 16) 1158 if (key_state & 16)
1148 fputc ('C', stderr); 1159 fputc ('C', stderr);
1149 if (key_state & 4) 1160 if (key_state & 4)
1150 fputc ('S', stderr); 1161 fputc ('S', stderr);
1154 fputc ('2', stderr); 1165 fputc ('2', stderr);
1155 fprintf (stderr, "]: <%d>, %d/%d\n", 1166 fprintf (stderr, "]: <%d>, %d/%d\n",
1156 button_number, 1167 button_number,
1157 x + 1, 1168 x + 1,
1158 y + 1); 1169 y + 1);
1159#else 1170#endif
1171
1160 tt_printf ("\033[M%c%c%c", 1172 tt_printf ("\033[M%c%c%c",
1161 (32 + button_number + key_state), 1173 (32 + button_number + key_state),
1162 (32 + x + 1), 1174 (32 + x + 1),
1163 (32 + y + 1)); 1175 (32 + y + 1));
1164#endif
1165} 1176}
1166 1177
1167#ifdef USING_W11LIB 1178#ifdef USING_W11LIB
1168void 1179void
1169rxvt_W11_process_x_event (XEvent *ev) 1180rxvt_W11_process_x_event (XEvent *ev)
1206 if (ev.type == KeyPress && hidden_pointer == 0) 1217 if (ev.type == KeyPress && hidden_pointer == 0)
1207 pointer_blank (); 1218 pointer_blank ();
1208 } 1219 }
1209#endif 1220#endif
1210 1221
1211#ifdef USE_XIM
1212 if (XFilterEvent (&ev, None))
1213 return;
1214#endif
1215
1216 Window unused_root, unused_child; 1222 Window unused_root, unused_child;
1217 int unused_root_x, unused_root_y; 1223 int unused_root_x, unused_root_y;
1218 unsigned int unused_mask; 1224 unsigned int unused_mask;
1219 1225
1220 switch (ev.type) 1226 switch (ev.type)
1221 { 1227 {
1222 case KeyPress: 1228 case KeyPress:
1223#if ISO_14755 1229#if ISO_14755
1227 1233
1228 break; 1234 break;
1229 1235
1230 case KeyRelease: 1236 case KeyRelease:
1231 { 1237 {
1232#if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS) 1238#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755
1233 KeySym ks; 1239 KeySym ks;
1234 1240
1235 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ 1241 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1236#endif 1242#endif
1237 1243
1328 0L, 1000000L, 1334 0L, 1000000L,
1329 False, AnyPropertyType, 1335 False, AnyPropertyType,
1330 &ActualType, &ActualFormat, 1336 &ActualType, &ActualFormat,
1331 &Size, &RemainingBytes, 1337 &Size, &RemainingBytes,
1332 &data); 1338 &data);
1333 XChangeProperty (display->display, display->root, 1339 set_string_property (XA_CUT_BUFFER0, data);
1334 XA_CUT_BUFFER0, XA_STRING,
1335 8, PropModeReplace,
1336 data, strlen (data));
1337 XFree (data); 1340 XFree (data);
1338 selection_paste (display->root, XA_CUT_BUFFER0, True); 1341 selection_paste (display->root, XA_CUT_BUFFER0, True);
1339 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); 1342 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime);
1340 } 1343 }
1341#endif /* OFFIX_DND */ 1344#endif /* OFFIX_DND */
1388#endif 1391#endif
1389#ifdef OFF_FOCUS_FADING 1392#ifdef OFF_FOCUS_FADING
1390 if (rs[Rs_fade]) 1393 if (rs[Rs_fade])
1391 { 1394 {
1392 pix_colors = pix_colors_focused; 1395 pix_colors = pix_colors_focused;
1393 set_colorfgbg ();
1394 scr_clear (); 1396 scr_recolour ();
1395 scr_touch (true);
1396 } 1397 }
1397#endif 1398#endif
1398 1399
1399 } 1400 }
1400 break; 1401 break;
1402 case FocusOut: 1403 case FocusOut:
1403 if (TermWin.focus) 1404 if (TermWin.focus)
1404 { 1405 {
1405 TermWin.focus = 0; 1406 TermWin.focus = 0;
1406 want_refresh = 1; 1407 want_refresh = 1;
1408
1409#if ENABLE_FRILLS || ISO_14755
1410 iso14755buf = 0;
1411#endif
1412#if ENABLE_OVERLAY
1413 scr_overlay_off ();
1414#endif
1407#ifdef USE_XIM 1415#ifdef USE_XIM
1408 if (Input_Context != NULL) 1416 if (Input_Context != NULL)
1409 XUnsetICFocus (Input_Context); 1417 XUnsetICFocus (Input_Context);
1410#endif 1418#endif
1411#ifdef CURSOR_BLINK 1419#ifdef CURSOR_BLINK
1415#endif 1423#endif
1416#ifdef OFF_FOCUS_FADING 1424#ifdef OFF_FOCUS_FADING
1417 if (rs[Rs_fade]) 1425 if (rs[Rs_fade])
1418 { 1426 {
1419 pix_colors = pix_colors_unfocused; 1427 pix_colors = pix_colors_unfocused;
1420 set_colorfgbg ();
1421 scr_clear (); 1428 scr_recolour ();
1422 scr_touch (true);
1423 } 1429 }
1424#endif 1430#endif
1425
1426 } 1431 }
1427 break; 1432 break;
1428 1433
1429 case ConfigureNotify: 1434 case ConfigureNotify:
1430 if (ev.xconfigure.window == TermWin.parent[0]) 1435 if (ev.xconfigure.window == TermWin.parent[0])
1438 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); 1443 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
1439 } 1444 }
1440 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); 1445 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev));
1441 1446
1442 if (szHint.width != width || szHint.height != height) 1447 if (szHint.width != width || szHint.height != height)
1448 {
1449 seen_resize = 1;
1443 resize_all_windows (width, height, 1); 1450 resize_all_windows (width, height, 1);
1451 }
1444 1452
1445#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1453#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1446 if (options & Opt_transparent) 1454 if (options & Opt_transparent)
1447 {
1448 check_our_parents (); 1455 check_our_parents ();
1449 if (am_transparent)
1450 want_refresh = want_full_refresh = 1;
1451 }
1452#endif 1456#endif
1453 } 1457 }
1454 break; 1458 break;
1455 1459
1456 case PropertyNotify: 1460 case PropertyNotify:
1547 { 1551 {
1548 menubar_control (ev.xbutton); 1552 menubar_control (ev.xbutton);
1549 break; 1553 break;
1550 } 1554 }
1551#endif 1555#endif
1552 if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) 1556 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1553 break; 1557 break;
1554 1558
1555 if (ev.xany.window == TermWin.vt) 1559 if (ev.xany.window == TermWin.vt)
1556 { 1560 {
1557 if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1561 if (ev.xbutton.state & (Button1Mask | Button3Mask))
1560 ; 1564 ;
1561 1565
1562 XQueryPointer (display->display, TermWin.vt, 1566 XQueryPointer (display->display, TermWin.vt,
1563 &unused_root, &unused_child, 1567 &unused_root, &unused_child,
1564 &unused_root_x, &unused_root_y, 1568 &unused_root_x, &unused_root_y,
1565 & (ev.xbutton.x), & (ev.xbutton.y), 1569 &ev.xbutton.x, &ev.xbutton.y,
1566 &unused_mask); 1570 &ev.xbutton.state);
1567#ifdef MOUSE_THRESHOLD 1571#ifdef MOUSE_THRESHOLD
1568 /* deal with a `jumpy' mouse */ 1572 /* deal with a `jumpy' mouse */
1569 if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) 1573 if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD)
1570 { 1574 {
1571#endif 1575#endif
1576 iso14755_54 (ev.xbutton.x, ev.xbutton.y); 1580 iso14755_54 (ev.xbutton.x, ev.xbutton.y);
1577 break; 1581 break;
1578 } 1582 }
1579#endif 1583#endif
1580 selection_extend (ev.xbutton.x, ev.xbutton.y, 1584 selection_extend (ev.xbutton.x, ev.xbutton.y,
1581 (ev.xbutton.state & Button3Mask) ? 2 : 0); 1585 ev.xbutton.state & Button3Mask ? 2 : 0);
1586
1582#ifdef SELECTION_SCROLLING 1587#ifdef SELECTION_SCROLLING
1583 if (ev.xbutton.y < TermWin.int_bwidth 1588 if (ev.xbutton.y < TermWin.int_bwidth
1584 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) 1589 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1))
1585 { 1590 {
1586 int dist; 1591 int dist;
1597 selection_save_x = ev.xbutton.x; 1602 selection_save_x = ev.xbutton.x;
1598 selection_save_y = ev.xbutton.y; 1603 selection_save_y = ev.xbutton.y;
1599 selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; 1604 selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0;
1600 1605
1601 /* calc number of lines to scroll */ 1606 /* calc number of lines to scroll */
1602 if (ev.xbutton.y<TermWin.int_bwidth) 1607 if (ev.xbutton.y < TermWin.int_bwidth)
1603 { 1608 {
1604 scroll_selection_dir = UP; 1609 scroll_selection_dir = UP;
1605 dist = TermWin.int_bwidth - ev.xbutton.y; 1610 dist = TermWin.int_bwidth - ev.xbutton.y;
1606 } 1611 }
1607 else 1612 else
1631 } 1636 }
1632 } 1637 }
1633 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1638 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
1634 { 1639 {
1635 while (XCheckTypedWindowEvent (display->display, scrollBar.win, 1640 while (XCheckTypedWindowEvent (display->display, scrollBar.win,
1636 MotionNotify, &ev)) ; 1641 MotionNotify, &ev))
1642 ;
1643
1637 XQueryPointer (display->display, scrollBar.win, 1644 XQueryPointer (display->display, scrollBar.win,
1638 &unused_root, &unused_child, 1645 &unused_root, &unused_child,
1639 &unused_root_x, &unused_root_y, 1646 &unused_root_x, &unused_root_y,
1640 & (ev.xbutton.x), & (ev.xbutton.y), 1647 &ev.xbutton.x, &ev.xbutton.y,
1641 &unused_mask); 1648 &unused_mask);
1642 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1649 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1643 scrollbar_size ()); 1650 scrollbar_size ());
1644 scr_refresh (refresh_type); 1651 scr_refresh (refresh_type);
1645 refresh_limit = 0; 1652 refresh_limit = 0;
1700 return; 1707 return;
1701 } 1708 }
1702#endif 1709#endif
1703 1710
1704 clickintime = ev.time - MEvent.time < MULTICLICK_TIME; 1711 clickintime = ev.time - MEvent.time < MULTICLICK_TIME;
1712
1705 if (reportmode) 1713 if (reportmode)
1706 { 1714 {
1707 /* mouse report from vt window */ 1715 /* mouse report from vt window */
1708 /* save the xbutton state (for ButtonRelease) */ 1716 /* save the xbutton state (for ButtonRelease) */
1709 MEvent.state = ev.state; 1717 MEvent.state = ev.state;
1738 } 1746 }
1739 else 1747 else
1740 { 1748 {
1741 if (ev.button != MEvent.button) 1749 if (ev.button != MEvent.button)
1742 MEvent.clicks = 0; 1750 MEvent.clicks = 0;
1751
1743 switch (ev.button) 1752 switch (ev.button)
1744 { 1753 {
1745 case Button1: 1754 case Button1:
1755 /* allow meta + click to select rectangular areas */
1756 /* should be done in screen.C */
1757#if ENABLE_FRILLS
1758 selection.rect = !! (ev.state & ModMetaMask);
1759#else
1760 selection.rect = false;
1761#endif
1762
1746 /* allow shift+left click to extend selection */ 1763 /* allow shift+left click to extend selection */
1747 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1764 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report))
1748 { 1765 {
1749 if (MEvent.button == Button1 && clickintime) 1766 if (MEvent.button == Button1 && clickintime)
1750 selection_rotate (ev.x, ev.y); 1767 selection_rotate (ev.x, ev.y);
2392 sy = 0; 2409 sy = 0;
2393 } 2410 }
2394 2411
2395 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2412 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2396 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2413 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2414
2415 XSync (display->display, False);
2397 allowedxerror = -1; 2416 allowedxerror = -1;
2398 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2417 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2399 2418
2400 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2419 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2401 /* XXX: may need a delay here? */ 2420 /* XXX: may need a delay here? */
2447 2466
2448 am_transparent = am_pixmap_trans = 1; 2467 am_transparent = am_pixmap_trans = 1;
2449 } 2468 }
2450 } 2469 }
2451 2470
2452 if (!am_pixmap_trans) 2471 if (am_pixmap_trans)
2472 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
2473 else
2453 { 2474 {
2454 unsigned int n; 2475 unsigned int n;
2455 /* 2476 /*
2456 * InheritPixmap transparency 2477 * InheritPixmap transparency
2457 */ 2478 */
2515 2536
2516 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2537 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2517 TermWin.parent[i] = None; 2538 TermWin.parent[i] = None;
2518 } 2539 }
2519 2540
2520 // this is experimental
2521 if (scrollBar.win) 2541 if (scrollBar.win)
2522 { 2542 {
2523 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); 2543 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
2524 XClearWindow (display->display, scrollBar.win);
2525 scrollBar.setIdle (); 2544 scrollBar.setIdle ();
2526 scrollbar_show (0); 2545 scrollbar_show (0);
2546 }
2547
2548 if (am_transparent)
2549 {
2550 want_refresh = want_full_refresh = 1;
2551 if (am_pixmap_trans)
2552 flush ();
2527 } 2553 }
2528 2554
2529 return pchanged; 2555 return pchanged;
2530} 2556}
2531#endif 2557#endif
2557 seen_input = 1; 2583 seen_input = 1;
2558 // many badly-written programs (e.g. jed) contain a race condition: 2584 // many badly-written programs (e.g. jed) contain a race condition:
2559 // they first read the screensize and then install a SIGWINCH handler. 2585 // they first read the screensize and then install a SIGWINCH handler.
2560 // some window managers resize the window early, and these programs 2586 // some window managers resize the window early, and these programs
2561 // then sometimes get the size wrong. 2587 // then sometimes get the size wrong.
2588 // unfortunately other programs are even more buggy and dislike
2589 // being sent SIGWINCH, so only do it when we were in fact being
2590 // resized.
2591 if (seen_resize)
2562 kill (-cmd_pid, SIGWINCH); 2592 kill (-cmd_pid, SIGWINCH);
2563 } 2593 }
2564 2594
2565 /* Read a text string from the input buffer */ 2595 /* Read a text string from the input buffer */
2566 unicode_t buf[UBUFSIZ]; 2596 unicode_t buf[UBUFSIZ];
2567 bool refreshnow = false; 2597 bool refreshnow = false;
3487 * ends_how is terminator used. returned input must be free()'d 3517 * ends_how is terminator used. returned input must be free()'d
3488 */ 3518 */
3489unsigned char * 3519unsigned char *
3490rxvt_term::get_to_st (unicode_t &ends_how) 3520rxvt_term::get_to_st (unicode_t &ends_how)
3491{ 3521{
3492 unicode_t prev = 0, ch; 3522 unicode_t ch;
3523 bool seen_esc = false;
3493 unsigned int n = 0; 3524 unsigned int n = 0;
3494 unsigned char *s;
3495 unsigned char string[STRING_MAX]; 3525 wchar_t string[STRING_MAX];
3496 3526
3497 while ((ch = cmd_getc ()) != NOCHAR) 3527 while ((ch = cmd_getc ()) != NOCHAR)
3498 { 3528 {
3499 if (prev == C0_ESC) 3529 if (seen_esc)
3500 { 3530 {
3501 if (ch == 0x5c) /* 7bit ST */ 3531 if (ch == 0x5c) /* 7bit ST */
3502 break; 3532 break;
3503 else 3533 else
3504 return NULL; 3534 return NULL;
3505 } 3535 }
3536 else if (ch == C0_ESC)
3537 {
3538 seen_esc = true;
3539 continue;
3540 }
3506 else if (ch == C0_BEL || ch == CHAR_ST) 3541 else if (ch == C0_BEL || ch == CHAR_ST)
3507 break; 3542 break;
3508 else if (ch < 0x20) 3543 else if (ch < 0x20)
3509 return NULL; /* other control character - exit */ 3544 return NULL; /* other control character - exit */
3545
3546 seen_esc = false;
3510 3547
3511 if (n >= sizeof (string) - 1) 3548 if (n >= sizeof (string) - 1)
3512 // stop at some sane length 3549 // stop at some sane length
3513 return NULL; 3550 return NULL;
3514 3551
3515 if (ch == C0_SYN) 3552 if (ch == C0_SYN)
3516 {
3517 string[n++] = cmd_get8 (); 3553 string[n++] = cmd_get8 ();
3518 prev = 0;
3519 }
3520 else 3554 else
3521 string[n++] = prev = ch; 3555 string[n++] = ch;
3522 } 3556 }
3523 3557
3524 string[n++] = '\0'; 3558 string[n++] = '\0';
3525 3559
3526 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
3527 return NULL;
3528
3529 ends_how = (ch == 0x5c ? C0_ESC : ch); 3560 ends_how = (ch == 0x5c ? C0_ESC : ch);
3530 strncpy (s, string, n); 3561
3531 return s; 3562 return (unsigned char *)rxvt_wcstombs (string);
3532} 3563}
3533 3564
3534/*----------------------------------------------------------------------*/ 3565/*----------------------------------------------------------------------*/
3535/* 3566/*
3536 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' 3567 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)'
3620{ 3651{
3621 int changed = 0; 3652 int changed = 0;
3622 int color; 3653 int color;
3623 char *buf, *name; 3654 char *buf, *name;
3624 bool query = str[0] == '?' && !str[1]; 3655 bool query = str[0] == '?' && !str[1];
3656 int saveop = op;
3625 3657
3626 assert (str != NULL); 3658 assert (str != NULL);
3627 switch (op) 3659 switch (op)
3628 { 3660 {
3629 case XTerm_name: 3661 case XTerm_name:
3636 set_title (str); 3668 set_title (str);
3637 break; 3669 break;
3638 case XTerm_property: 3670 case XTerm_property:
3639 if (str[0] == '?') 3671 if (str[0] == '?')
3640 { 3672 {
3641 Atom prop = XInternAtom (display->display, str + 1, True); 3673 Atom prop = display->atom (str + 1);
3642 Atom actual_type; 3674 Atom actual_type;
3643 int actual_format; 3675 int actual_format;
3644 unsigned long nitems; 3676 unsigned long nitems;
3645 unsigned long bytes_after; 3677 unsigned long bytes_after;
3646 unsigned char *value = 0; 3678 unsigned char *value = 0;
3664 char *eq = strchr (str, '='); // constness lost, but verified to be ok 3696 char *eq = strchr (str, '='); // constness lost, but verified to be ok
3665 3697
3666 if (eq) 3698 if (eq)
3667 { 3699 {
3668 *eq = 0; 3700 *eq = 0;
3669 XChangeProperty (display->display, TermWin.parent[0], 3701 set_utf8_property (display->atom (str), eq + 1);
3670 display->atom (str), XA_STRING, 8,
3671 PropModeReplace, (unsigned char *)eq + 1,
3672 strlen (eq + 1));
3673 } 3702 }
3674 else 3703 else
3675 XDeleteProperty (display->display, TermWin.parent[0], 3704 XDeleteProperty (display->display, TermWin.parent[0],
3676 display->atom (str)); 3705 display->atom (str));
3677 } 3706 }
3721 break; 3750 break;
3722#ifndef NO_BOLD_UNDERLINE_REVERSE 3751#ifndef NO_BOLD_UNDERLINE_REVERSE
3723 case XTerm_Color_BD: 3752 case XTerm_Color_BD:
3724 process_color_seq (XTerm_Color_BD, Color_BD, str, resp); 3753 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3725 break; 3754 break;
3755 case XTerm_Color_IT:
3756 process_color_seq (XTerm_Color_IT, Color_IT, str, resp);
3757 break;
3726 case XTerm_Color_UL: 3758 case XTerm_Color_UL:
3727 process_color_seq (XTerm_Color_UL, Color_UL, str, resp); 3759 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3728 break; 3760 break;
3729 case XTerm_Color_RV: 3761 case XTerm_Color_RV:
3730 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3762 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3763 break;
3764#endif
3765#if TRANSPARENT && TINTING
3766 case XTerm_Color_tint:
3767 process_color_seq (XTerm_Color_tint, Color_tint, str, resp);
3768 check_our_parents ();
3769 if (am_transparent)
3770 want_full_refresh = want_refresh = 1;
3731 break; 3771 break;
3732#endif 3772#endif
3733 3773
3734 case XTerm_Pixmap: 3774 case XTerm_Pixmap:
3735 if (*str != ';') 3775 if (*str != ';')
3767 case XTerm_logfile: 3807 case XTerm_logfile:
3768 // TODO, when secure mode? 3808 // TODO, when secure mode?
3769 break; 3809 break;
3770 3810
3771 case XTerm_font: 3811 case XTerm_font:
3812 op = URxvt_font;
3813 case URxvt_font:
3814#if ENABLE_STYLES
3815 case URxvt_boldFont:
3816 case URxvt_italicFont:
3817 case URxvt_boldItalicFont:
3818#endif
3772 if (query) 3819 if (query)
3773 tt_printf ("\33]%d;%-.250s%c", XTerm_font, 3820 tt_printf ("\33]%d;%-.250s%c", saveop,
3774 (options & Opt_insecure) && TermWin.fontset->fontdesc 3821 (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc
3775 ? TermWin.fontset->fontdesc : "", 3822 ? TermWin.fontset[op - URxvt_font]->fontdesc : "",
3776 resp); 3823 resp);
3777 else 3824 else
3825 {
3826 const char *&res = rs[Rs_font + (op - URxvt_font)];
3827
3828 res = strdup (str);
3829 allocated.push_back ((void *)res);
3778 change_font (str); 3830 set_fonts ();
3831 }
3779 break; 3832 break;
3780 3833
3781#if ENABLE_FRILLS 3834#if ENABLE_FRILLS
3782 case XTerm_locale: 3835 case XTerm_locale:
3783 if (query) 3836 if (query)
3787 set_locale (str); 3840 set_locale (str);
3788# ifdef USE_XIM 3841# ifdef USE_XIM
3789 im_cb (); 3842 im_cb ();
3790# endif 3843# endif
3791 } 3844 }
3792 break;
3793
3794 case XTerm_findfont:
3795 {
3796 int fid = TermWin.fontset->find_font (atoi (str));
3797 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont,
3798 fid,
3799 (options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "",
3800 resp);
3801 }
3802 break; 3845 break;
3803#endif 3846#endif
3804 3847
3805#ifdef MENUBAR 3848#ifdef MENUBAR
3806 case XTerm_Menu: 3849 case XTerm_Menu:
3935 3978
3936 /* extra handling for values with state unkept */ 3979 /* extra handling for values with state unkept */
3937 switch (arg[i]) 3980 switch (arg[i])
3938 { 3981 {
3939 case 1048: /* alternative cursor save */ 3982 case 1048: /* alternative cursor save */
3983 case 1049:
3940 if (options & Opt_secondaryScreen) 3984 if (options & Opt_secondaryScreen)
3941 if (mode == 0) 3985 if (mode == 0)
3942 scr_cursor (RESTORE); 3986 scr_cursor (RESTORE);
3943 else if (mode == 1) 3987 else if (mode == 1)
3944 scr_cursor (SAVE); 3988 scr_cursor (SAVE);
4069 rendset = 0, rendstyle = ~RS_None; 4113 rendset = 0, rendstyle = ~RS_None;
4070 break; 4114 break;
4071 case 1: 4115 case 1:
4072 rendset = 1, rendstyle = RS_Bold; 4116 rendset = 1, rendstyle = RS_Bold;
4073 break; 4117 break;
4074 //case 2: // faint or second colour 4118 //case 2: // low intensity
4075 //case 3: // italic 4119 case 3:
4120 rendset = 1, rendstyle = RS_Italic;
4121 break;
4076 case 4: 4122 case 4:
4077 rendset = 1, rendstyle = RS_Uline; 4123 rendset = 1, rendstyle = RS_Uline;
4078 break; 4124 break;
4079 case 5: // slowly blinking 4125 case 5: // slowly blinking
4080 case 6: // rapidly blinking 4126 case 6: // rapidly blinking
4092 //case 11: // scoansi acs on, first alt font 4138 //case 11: // scoansi acs on, first alt font
4093 //case 12: // scoansi acs on, |0x80, second alt font 4139 //case 12: // scoansi acs on, |0x80, second alt font
4094 //... 4140 //...
4095 //case 19: // ninth alt font 4141 //case 19: // ninth alt font
4096 //case 20: // gothic 4142 //case 20: // gothic
4097 case 21: // disable bold, faint 4143 case 21: // disable bold, faint, sometimes doubly underlined (iso 8613)
4098 rendset = 0, rendstyle = RS_Bold; 4144 rendset = 0, rendstyle = RS_Bold;
4099 break; 4145 break;
4100 case 22: 4146 case 22: // normal intensity
4101 rendset = 0, rendstyle = RS_Bold; 4147 rendset = 0, rendstyle = RS_Bold;
4102 break; 4148 break;
4103 //case 23: disable italic 4149 case 23: // disable italic
4150 rendset = 0, rendstyle = RS_Italic;
4151 break;
4104 case 24: 4152 case 24:
4105 rendset = 0, rendstyle = RS_Uline; 4153 rendset = 0, rendstyle = RS_Uline;
4106 break; 4154 break;
4107 case 25: 4155 case 25:
4108 rendset = 0, rendstyle = RS_Blink; 4156 rendset = 0, rendstyle = RS_Blink;
4109 break; 4157 break;
4110 case 26: 4158 case 26: // variable spacing (iso 8613)
4111 rendset = 0, rendstyle = RS_Blink; 4159 rendset = 0, rendstyle = RS_Blink;
4112 break; 4160 break;
4113 case 27: 4161 case 27:
4114 rendset = 0, rendstyle = RS_RVid; 4162 rendset = 0, rendstyle = RS_RVid;
4115 break; 4163 break;
4133 case 35: 4181 case 35:
4134 case 36: 4182 case 36:
4135 case 37: 4183 case 37:
4136 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); 4184 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg);
4137 break; 4185 break;
4138#ifdef TTY_256COLOR 4186 case 38: // set fg color, ISO 8613-6
4139 case 38:
4140 if (nargs > i + 2 && arg[i + 1] == 5) 4187 if (nargs > i + 2 && arg[i + 1] == 5)
4141 { 4188 {
4142 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); 4189 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg);
4143 i += 2; 4190 i += 2;
4144 } 4191 }
4145 break; 4192 break;
4146#endif
4147 case 39: /* default fg */ 4193 case 39: /* default fg */
4148 scr_color (Color_fg, Color_fg); 4194 scr_color (Color_fg, Color_fg);
4149 break; 4195 break;
4150 4196
4151 case 40: 4197 case 40:
4156 case 45: 4202 case 45:
4157 case 46: 4203 case 46:
4158 case 47: 4204 case 47:
4159 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); 4205 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg);
4160 break; 4206 break;
4161#ifdef TTY_256COLOR 4207 case 48: // set bg color, ISO 8613-6
4162 case 48:
4163 if (nargs > i + 2 && arg[i + 1] == 5) 4208 if (nargs > i + 2 && arg[i + 1] == 5)
4164 { 4209 {
4165 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); 4210 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg);
4166 i += 2; 4211 i += 2;
4167 } 4212 }
4168 break; 4213 break;
4169#endif
4170 case 49: /* default bg */ 4214 case 49: /* default bg */
4171 scr_color (Color_bg, Color_bg); 4215 scr_color (Color_bg, Color_bg);
4172 break; 4216 break;
4217
4218 //case 50: // not variable spacing
4173 4219
4174#ifndef NO_BRIGHTCOLOR 4220#ifndef NO_BRIGHTCOLOR
4175 case 90: 4221 case 90:
4176 case 91: /* set bright fg color */ 4222 case 91: /* set bright fg color */
4177 case 92: 4223 case 92:
4178 case 93: 4224 case 93:
4179 case 94: 4225 case 94:
4180 case 95: 4226 case 95:
4181 case 96: 4227 case 96:
4182 case 97: 4228 case 97:
4183 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), 4229 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg);
4184 Color_fg);
4185 break; 4230 break;
4186 case 100: 4231 case 100:
4187 case 101: /* set bright bg color */ 4232 case 101: /* set bright bg color */
4188 case 102: 4233 case 102:
4189 case 103: 4234 case 103:
4190 case 104: 4235 case 104:
4191 case 105: 4236 case 105:
4192 case 106: 4237 case 106:
4193 case 107: 4238 case 107:
4194 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), 4239 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg);
4195 Color_bg);
4196 break; 4240 break;
4197#endif 4241#endif
4198 4242
4199 } 4243 }
4200 } 4244 }
4242 * or generated by us in response to a query ESC sequence. 4286 * or generated by us in response to a query ESC sequence.
4243 */ 4287 */
4244void 4288void
4245rxvt_term::tt_write (const unsigned char *data, unsigned int len) 4289rxvt_term::tt_write (const unsigned char *data, unsigned int len)
4246{ 4290{
4247 enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT 4291 const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4248 4292
4249 if (len) 4293 if (len)
4250 { 4294 {
4251 if (v_buflen == 0) 4295 if (v_buflen == 0)
4252 { 4296 {
4266 v_buflen += len; 4310 v_buflen += len;
4267 } 4311 }
4268 4312
4269 for (;;) 4313 for (;;)
4270 { 4314 {
4271 int written = write (pty.pty, v_buffer, min (MAX_PTY_WRITE, v_buflen)); 4315 int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4272 4316
4273 if (written > 0) 4317 if (written > 0)
4274 { 4318 {
4275 v_buflen -= written; 4319 v_buflen -= written;
4276 4320

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines