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.55 by pcg, Sun Feb 22 20:08:18 2004 UTC vs.
Revision 1.81 by pcg, Sun Mar 28 02:07:08 2004 UTC

52 52
53#include <wchar.h> 53#include <wchar.h>
54 54
55/*----------------------------------------------------------------------*/ 55/*----------------------------------------------------------------------*/
56 56
57#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
58
59// exception thrown when the command parser runs out of input data
60class out_of_input { } out_of_input;
61
57/*{{{ Convert the keypress event into a string */ 62/*{{{ Convert the keypress event into a string */
58void 63void
59rxvt_term::lookup_key (XKeyEvent &ev) 64rxvt_term::lookup_key (XKeyEvent &ev)
60{ 65{
61 int ctrl, meta, shft, len; 66 int ctrl, meta, shft, len;
88#ifdef USE_XIM 93#ifdef USE_XIM
89 if (Input_Context) 94 if (Input_Context)
90 { 95 {
91 Status status_return; 96 Status status_return;
92 97
98#if 0
93#ifdef X_HAVE_UTF8_STRING 99#ifdef X_HAVE_UTF8_STRING
94 if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful 100 if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful
95 len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, 101 len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf,
96 KBUFSZ, &keysym, &status_return); 102 KBUFSZ, &keysym, &status_return);
97 else 103 else
104#endif
98#endif 105#endif
99 { 106 {
100 wchar_t wkbuf[KBUFSZ + 1]; 107 wchar_t wkbuf[KBUFSZ + 1];
101 108
102 // the XOpenIM manpage lies about hardcoding the locale 109 // the XOpenIM manpage lies about hardcoding the locale
140 valid_keysym = keysym != NoSymbol; 147 valid_keysym = keysym != NoSymbol;
141 } 148 }
142 149
143 if (valid_keysym) 150 if (valid_keysym)
144 { 151 {
145 /* for some backwards compatibility */
146#if defined(HOTKEY_CTRL) || defined(HOTKEY_META)
147# ifdef HOTKEY_CTRL
148 if (ctrl)
149# else
150 if (meta)
151# endif
152 {
153 if (keysym == ks_bigfont)
154 {
155 change_font (FONT_UP);
156 return;
157 }
158 else if (keysym == ks_smallfont)
159 {
160 change_font (FONT_DN);
161 return;
162 }
163 }
164#endif
165
166 if (TermWin.saveLines) 152 if (TermWin.saveLines)
167 { 153 {
168#ifdef UNSHIFTED_SCROLLKEYS 154#ifdef UNSHIFTED_SCROLLKEYS
169 if (!ctrl && !meta) 155 if (!ctrl && !meta)
170 { 156 {
261#ifdef KEYSYM_RESOURCE 247#ifdef KEYSYM_RESOURCE
262 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) 248 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL)
263 { 249 {
264 unsigned int l; 250 unsigned int l;
265 const unsigned char *kbuf0; 251 const unsigned char *kbuf0;
266 const unsigned char ch = C0_ESC;
267 252
268 kbuf0 = (Keysym_map[keysym & 0xFF]); 253 kbuf0 = (Keysym_map[keysym & 0xFF]);
269 l = (unsigned int)*kbuf0++; 254 l = (unsigned int)*kbuf0++;
270 255
271 /* escape prefix */ 256 /* escape prefix */
272 if (meta) 257 if (meta
273# ifdef META8_OPTION 258# ifdef META8_OPTION
274 if (meta_char == C0_ESC) 259 && meta_char == C0_ESC
275# endif 260# endif
261 )
262 {
263 const unsigned char ch = C0_ESC;
276 tt_write (&ch, 1); 264 tt_write (&ch, 1);
265 }
266
277 tt_write (kbuf0, l); 267 tt_write (kbuf0, l);
278 return; 268 return;
279 } 269 }
280 else 270 else
281#endif 271#endif
291 ^ !!ctrl) ? '\b' : '\177'; 281 ^ !!ctrl) ? '\b' : '\177';
292 kbuf[1] = '\0'; 282 kbuf[1] = '\0';
293 } 283 }
294 else 284 else
295 STRCPY (kbuf, key_backspace); 285 STRCPY (kbuf, key_backspace);
296# ifdef MULTICHAR_SET
297 if ((Options & Opt_mc_hack) && screen.cur.col > 0)
298 {
299 int col, row;
300
301 newlen = STRLEN (kbuf);
302 col = screen.cur.col - 1;
303 row = screen.cur.row + TermWin.saveLines;
304 if (IS_MULTI2 (screen.rend[row][col]))
305 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
306 }
307# endif
308 break; 286 break;
309#endif 287#endif
310#ifndef NO_DELETE_KEY 288#ifndef NO_DELETE_KEY
311 case XK_Delete: 289 case XK_Delete:
312 STRCPY (kbuf, key_delete); 290 STRCPY (kbuf, key_delete);
313# ifdef MULTICHAR_SET
314 if (Options & Opt_mc_hack)
315 {
316 int col, row;
317
318 newlen = STRLEN (kbuf);
319 col = screen.cur.col;
320 row = screen.cur.row + TermWin.saveLines;
321 if (IS_MULTI1 (screen.rend[row][col]))
322 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
323 }
324# endif
325 break; 291 break;
326#endif 292#endif
327 case XK_Tab: 293 case XK_Tab:
328 if (shft) 294 if (shft)
329 STRCPY (kbuf, "\033[Z"); 295 STRCPY (kbuf, "\033[Z");
371 kbuf[1] = 'O'; 337 kbuf[1] = 'O';
372 kbuf[2] = "dacb"[keysym - XK_Left]; 338 kbuf[2] = "dacb"[keysym - XK_Left];
373 } 339 }
374 else if (PrivateModes & PrivMode_aplCUR) 340 else if (PrivateModes & PrivMode_aplCUR)
375 kbuf[1] = 'O'; 341 kbuf[1] = 'O';
376#ifdef MULTICHAR_SET
377 //TODO: ??
378 if (Options & Opt_mc_hack)
379 {
380 int col, row, m;
381
382 col = screen.cur.col;
383 row = screen.cur.row + TermWin.saveLines;
384 m = 0;
385 if (keysym == XK_Right
386 && IS_MULTI1 (screen.rend[row][col]))
387 m = 1;
388 else if (keysym == XK_Left)
389 {
390 if (col > 0)
391 {
392 if (IS_MULTI2 (screen.rend[row][col - 1]))
393 m = 1;
394 }
395 else if (screen.cur.row > 0)
396 {
397 col = screen.tlen[--row];
398 if (col == -1)
399 col = TermWin.ncol - 1;
400 else
401 col--;
402 if (col > 0
403 && IS_MULTI2 (screen.rend[row][col]))
404 m = 1;
405 }
406 }
407 if (m)
408 MEMMOVE (kbuf + 3, kbuf, 3 + 1);
409 }
410#endif
411 break; 342 break;
412 343
413#ifndef UNSHIFTED_SCROLLKEYS 344#ifndef UNSHIFTED_SCROLLKEYS
414# ifdef XK_KP_Prior 345# ifdef XK_KP_Prior
415 case XK_KP_Prior: 346 case XK_KP_Prior:
604 break; 535 break;
605 } 536 }
606 if (newlen) 537 if (newlen)
607 len = STRLEN (kbuf); 538 len = STRLEN (kbuf);
608 } 539 }
540
609 /* 541 /*
610 * Pass meta for all function keys, if 'meta' option set 542 * Pass meta for all function keys, if 'meta' option set
611 */ 543 */
612#ifdef META8_OPTION 544#ifdef META8_OPTION
613 if (meta && (meta_char == 0x80) && len > 0) 545 if (meta && (meta_char == 0x80) && len > 0)
628 { 560 {
629 unsigned char *ch; 561 unsigned char *ch;
630 562
631 for (ch = kbuf; ch < kbuf + len; ch++) 563 for (ch = kbuf; ch < kbuf + len; ch++)
632 *ch |= 0x80; 564 *ch |= 0x80;
565
633 meta = 0; 566 meta = 0;
634 } 567 }
635#endif 568#endif
636 /* nil */ ; 569 /* nil */ ;
637 } 570 }
690/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ 623/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */
691/* attempt to `write' count to the input buffer */ 624/* attempt to `write' count to the input buffer */
692unsigned int 625unsigned int
693rxvt_term::cmd_write (const unsigned char *str, unsigned int count) 626rxvt_term::cmd_write (const unsigned char *str, unsigned int count)
694{ 627{
695 unsigned int n, s; 628 unsigned int n, s;
696 629
697 n = cmdbuf_ptr - cmdbuf_base; 630 n = cmdbuf_ptr - cmdbuf_base;
698 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; 631 s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp;
632
699 if (n > 0 && s < count) 633 if (n > 0 && s < count)
700 { 634 {
701 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 635 MEMMOVE (cmdbuf_base, cmdbuf_ptr,
702 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 636 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
703 cmdbuf_ptr = cmdbuf_base; 637 cmdbuf_ptr = cmdbuf_base;
704 cmdbuf_endp -= n; 638 cmdbuf_endp -= n;
705 s += n; 639 s += n;
706 } 640 }
641
707 if (count > s) 642 if (count > s)
708 { 643 {
709 rxvt_print_error ("data loss: cmd_write too large"); 644 rxvt_warn ("data loss: cmd_write too large, continuing.\n");
710 count = s; 645 count = s;
711 } 646 }
647
712 for (; count--;) 648 for (; count--;)
713 *cmdbuf_endp++ = *str++; 649 *cmdbuf_endp++ = *str++;
650
651 cmd_parse ();
652
714 return 0; 653 return 0;
715} 654}
716#endif /* MENUBAR_MAX */ 655#endif /* MENUBAR_MAX */
717 656
718void 657void
781 720
782 memmove (cmdbuf_base, cmdbuf_ptr, n); 721 memmove (cmdbuf_base, cmdbuf_ptr, n);
783 cmdbuf_ptr = cmdbuf_base; 722 cmdbuf_ptr = cmdbuf_base;
784 cmdbuf_endp = cmdbuf_ptr + n; 723 cmdbuf_endp = cmdbuf_ptr + n;
785 724
786 n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n); 725 n = read (cmd_fd, cmdbuf_endp, CBUFSIZ - n);
787 726
788 if (n > 0) 727 if (n > 0)
789 { 728 {
790 cmdbuf_endp += n; 729 cmdbuf_endp += n;
791 return true; 730 return true;
792 } 731 }
793 else if (n < 0 && errno != EAGAIN) 732 else if (n < 0 && errno != EAGAIN)
794 destroy (); 733 destroy ();
795 734
796 return false; 735 return false;
797} 736}
798 737
799void 738void
800rxvt_term::pty_cb (io_watcher &w, short revents) 739rxvt_term::pty_cb (io_watcher &w, short revents)
804 743
805 if (revents & EVENT_WRITE) 744 if (revents & EVENT_WRITE)
806 tt_write (0, 0); 745 tt_write (0, 0);
807 else if (revents & EVENT_READ) 746 else if (revents & EVENT_READ)
808 { 747 {
809 bool flag = true;
810
811 // loop, but don't allow a single term to monopolize us 748 // loop, but don't allow a single term to monopolize us
812 // the number of loops is fully arbitrary, and thus wrong 749 // the number of loops is fully arbitrary, and thus wrong
813 while (flag && pty_fill ()) 750 while (pty_fill ())
814 { 751 {
815 if (!seen_input) 752 if (!seen_input)
816 { 753 {
817 seen_input = 1; 754 seen_input = 1;
818 /* once we know the shell is running, send the screen size. Again! */ 755 /* once we know the shell is running, send the screen size. Again! */
756 // I don't know why, btw.
819 tt_winch (); 757 tt_winch ();
820 } 758 }
821 759
822 uint32_t ch = NOCHAR; 760 if (cmd_parse ())
823
824 for (;;)
825 {
826 if (ch == NOCHAR)
827 ch = next_char ();
828
829 if (ch == NOCHAR) // TODO: improve
830 break; 761 break;
831
832 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
833 {
834 /* Read a text string from the input buffer */
835 uint32_t buf[BUFSIZ];
836 bool refreshnow = false;
837 int nlines = 0;
838 uint32_t *str = buf;
839
840 *str++ = ch;
841
842 for (;;)
843 {
844 ch = next_char ();
845
846 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
847 break;
848 else
849 {
850 *str++ = ch;
851
852 if (ch == '\n')
853 {
854 nlines++;
855 refresh_count++;
856
857 if (! (Options & Opt_jumpScroll)
858 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
859 {
860 refreshnow = true;
861 flag = false;
862 ch = NOCHAR;
863 break;
864 }
865
866 // scr_add_lines only works for nlines < TermWin.nrow - 1.
867 if (nlines >= TermWin.nrow - 1)
868 {
869 scr_add_lines (buf, nlines, str - buf);
870 nlines = 0;
871 str = buf;
872 }
873 }
874
875 if (str >= buf + BUFSIZ)
876 {
877 ch = NOCHAR;
878 break;
879 }
880 }
881 }
882
883 scr_add_lines (buf, nlines, str - buf);
884
885 /*
886 * If there have been a lot of new lines, then update the screen
887 * What the heck I'll cheat and only refresh less than every page-full.
888 * the number of pages between refreshes is refresh_limit, which
889 * is incremented here because we must be doing flat-out scrolling.
890 *
891 * refreshing should be correct for small scrolls, because of the
892 * time-out
893 */
894 if (refreshnow)
895 {
896 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
897 refresh_limit++;
898
899 scr_refresh (refresh_type);
900 }
901
902 }
903 else
904 {
905 switch (ch)
906 {
907 default:
908 process_nonprinting (ch);
909 break;
910 case C0_ESC: /* escape char */
911 process_escape_seq ();
912 break;
913 /*case 0x9b: */ /* CSI */
914 /* process_csi_seq (); */
915 }
916
917 ch = NOCHAR;
918 }
919 } 762 }
920 }
921 }
922}
923
924// read the next character, currently handles UTF-8
925// will probably handle all sorts of other stuff in the future
926uint32_t
927rxvt_term::next_char ()
928{
929 while (cmdbuf_ptr < cmdbuf_endp)
930 {
931 if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh
932 return *cmdbuf_ptr++;
933
934 wchar_t wc;
935 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
936
937 if (len == (size_t)-2)
938 return NOCHAR;
939
940 if (len == (size_t)-1)
941 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
942
943 // assume wchar == unicode
944 cmdbuf_ptr += len;
945 return wc;
946 }
947
948 return NOCHAR;
949}
950
951/* rxvt_cmd_getc () - Return next input character */
952/*
953 * Return the next input character after first passing any keyboard input
954 * to the command.
955 */
956uint32_t
957rxvt_term::cmd_getc ()
958{
959 for (;;)
960 {
961 uint32_t c = next_char ();
962 if (c != NOCHAR)
963 return c;
964
965 // incomplete sequences should occur rarely, still, a better solution
966 // would be preferred. either setjmp/longjmp or better design.
967 fcntl (cmd_fd, F_SETFL, 0);
968 pty_fill ();
969 fcntl (cmd_fd, F_SETFL, O_NONBLOCK);
970 } 763 }
971} 764}
972 765
973#ifdef POINTER_BLANK 766#ifdef POINTER_BLANK
974void 767void
1004 pointer_blank (); 797 pointer_blank ();
1005} 798}
1006#endif 799#endif
1007 800
1008void 801void
1009rxvt_term::mouse_report (const XButtonEvent &ev) 802rxvt_term::mouse_report (XButtonEvent &ev)
1010{ 803{
1011 int button_number, key_state = 0; 804 int button_number, key_state = 0;
1012 int x, y; 805 int x, y;
1013 806
1014 x = ev.x; 807 x = ev.x;
1015 y = ev.y; 808 y = ev.y;
1016 pixel_position (&x, &y); 809 pixel_position (&x, &y);
1017 810
1343 1136
1344 } 1137 }
1345 break; 1138 break;
1346 1139
1347 case SelectionClear: 1140 case SelectionClear:
1348 display->set_selection_owner (0); 1141 selection_clear ();
1349 break; 1142 break;
1350 1143
1351 case SelectionNotify: 1144 case SelectionNotify:
1352 if (selection_wait == Sel_normal) 1145 if (selection_wait == Sel_normal)
1353 selection_paste (ev.xselection.requestor, 1146 selection_paste (ev.xselection.requestor,
1422 pointer_unblank (); 1215 pointer_unblank ();
1423#endif 1216#endif
1424#if MENUBAR 1217#if MENUBAR
1425 if (isMenuBarWindow (ev.xany.window)) 1218 if (isMenuBarWindow (ev.xany.window))
1426 { 1219 {
1427 menubar_control (& (ev.xbutton)); 1220 menubar_control (ev.xbutton);
1428 break; 1221 break;
1429 } 1222 }
1430#endif 1223#endif
1431 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) 1224 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate))
1432 break; 1225 break;
1561#endif 1354#endif
1562 } 1355 }
1563} 1356}
1564 1357
1565void 1358void
1566rxvt_term::button_press (const XButtonEvent &ev) 1359rxvt_term::button_press (XButtonEvent &ev)
1567{ 1360{
1568 int reportmode = 0, clickintime; 1361 int reportmode = 0, clickintime;
1569 1362
1570 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1363 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1571 if (!bypass_keystate) 1364 if (!bypass_keystate)
1799 menubar_control (ev); 1592 menubar_control (ev);
1800#endif 1593#endif
1801} 1594}
1802 1595
1803void 1596void
1804rxvt_term::button_release (const XButtonEvent &ev) 1597rxvt_term::button_release (XButtonEvent &ev)
1805{ 1598{
1806 int reportmode = 0; 1599 int reportmode = 0;
1807 1600
1808 csrO = 0; /* reset csr Offset */ 1601 csrO = 0; /* reset csr Offset */
1809 if (!bypass_keystate) 1602 if (!bypass_keystate)
1971 if (have_pixmap) 1764 if (have_pixmap)
1972 { 1765 {
1973 /* 1766 /*
1974 * Copy display->root pixmap transparency 1767 * Copy display->root pixmap transparency
1975 */ 1768 */
1976 int sx, sy, nx, ny; 1769 int sx, sy, nx, ny;
1977 unsigned int nw, nh; 1770 unsigned int nw, nh;
1978 Window cr; 1771 Window cr;
1979 XImage *image; 1772 XImage *image;
1980 GC gc; 1773 GC gc;
1981 XGCValues gcvalue; 1774 XGCValues gcvalue;
1982 1775
1983 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1776 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
1984 0, 0, &sx, &sy, &cr); 1777 0, 0, &sx, &sy, &cr);
1985 nw = (unsigned int)szHint.width; 1778 nw = (unsigned int)szHint.width;
1986 nh = (unsigned int)szHint.height; 1779 nh = (unsigned int)szHint.height;
1987 nx = ny = 0; 1780 nx = ny = 0;
1781
1988 if (sx < 0) 1782 if (sx < 0)
1989 { 1783 {
1990 nw += sx; 1784 nw += sx;
1991 nx = -sx; 1785 nx = -sx;
1992 sx = 0; 1786 sx = 0;
1993 } 1787 }
1788
1994 if (sy < 0) 1789 if (sy < 0)
1995 { 1790 {
1996 nh += sy; 1791 nh += sy;
1997 ny = -sy; 1792 ny = -sy;
1998 sy = 0; 1793 sy = 0;
1999 } 1794 }
1795
2000 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 1796 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2001 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 1797 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2002 allowedxerror = -1; 1798 allowedxerror = -1;
2003 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 1799 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes,
2004 ZPixmap); 1800 ZPixmap);
2037 if (!am_transparent || !am_pixmap_trans) 1833 if (!am_transparent || !am_pixmap_trans)
2038 pchanged = 1; 1834 pchanged = 1;
2039 am_transparent = am_pixmap_trans = 1; 1835 am_transparent = am_pixmap_trans = 1;
2040 } 1836 }
2041 } 1837 }
1838
2042 if (!am_pixmap_trans) 1839 if (!am_pixmap_trans)
2043 { 1840 {
2044 unsigned int n; 1841 unsigned int n;
2045 /* 1842 /*
2046 * InheritPixmap transparency 1843 * InheritPixmap transparency
2061 break; 1858 break;
2062 } 1859 }
2063 if (oldp != TermWin.parent[i]) 1860 if (oldp != TermWin.parent[i])
2064 pchanged = 1; 1861 pchanged = 1;
2065 } 1862 }
1863
2066 n = 0; 1864 n = 0;
1865
2067 if (pchanged) 1866 if (pchanged)
2068 { 1867 {
2069 for (; n < (unsigned int)i; n++) 1868 for (; n < (unsigned int)i; n++)
2070 { 1869 {
2071 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 1870 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
2075 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 1874 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2076 break; 1875 break;
2077 } 1876 }
2078 } 1877 }
2079 } 1878 }
1879
2080 if (n > (int) (sizeof (TermWin.parent) 1880 if (n > (int) (sizeof (TermWin.parent)
2081 / sizeof (TermWin.parent[0]))) 1881 / sizeof (TermWin.parent[0])))
2082 { 1882 {
2083 D_X ((stderr, "InheritPixmap Turning off")); 1883 D_X ((stderr, "InheritPixmap Turning off"));
2084 XSetWindowBackground (display->display, TermWin.parent[0], 1884 XSetWindowBackground (display->display, TermWin.parent[0],
2107 ParentRelative); 1907 ParentRelative);
2108 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 1908 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
2109 ParentRelative); 1909 ParentRelative);
2110 am_transparent = 1; 1910 am_transparent = 1;
2111 } 1911 }
1912
2112 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 1913 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2113 TermWin.parent[i] = None; 1914 TermWin.parent[i] = None;
2114 } 1915 }
2115 return pchanged; 1916 return pchanged;
2116} 1917}
2117#endif 1918#endif
2118 1919
2119/*}}} */ 1920/*}}} */
1921
1922bool
1923rxvt_term::cmd_parse ()
1924{
1925 bool flag = false;
1926 unicode_t ch = NOCHAR;
1927 unsigned char *seq_begin; // remember start of esc-sequence here
1928
1929 for (;;)
1930 {
1931 if (ch == NOCHAR)
1932 {
1933 seq_begin = cmdbuf_ptr;
1934 ch = next_char ();
1935 }
1936
1937 if (ch == NOCHAR) // TODO: improve
1938 break;
1939
1940 if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r')
1941 {
1942 /* Read a text string from the input buffer */
1943 unicode_t buf[UBUFSIZ];
1944 bool refreshnow = false;
1945 int nlines = 0;
1946 unicode_t *str = buf;
1947
1948 *str++ = ch;
1949
1950 for (;;)
1951 {
1952 seq_begin = cmdbuf_ptr;
1953 ch = next_char ();
1954
1955 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r'))
1956 break;
1957
1958 *str++ = ch;
1959
1960 if (ch == '\n')
1961 {
1962 nlines++;
1963 refresh_count++;
1964
1965 if (! (Options & Opt_jumpScroll)
1966 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
1967 {
1968 refreshnow = true;
1969 flag = true;
1970 ch = NOCHAR;
1971 break;
1972 }
1973
1974 // scr_add_lines only works for nlines < TermWin.nrow - 1.
1975 if (nlines >= TermWin.nrow - 1)
1976 {
1977 scr_add_lines (buf, nlines, str - buf);
1978 nlines = 0;
1979 str = buf;
1980 }
1981 }
1982
1983 if (str >= buf + UBUFSIZ)
1984 {
1985 ch = NOCHAR;
1986 break;
1987 }
1988 }
1989
1990 scr_add_lines (buf, nlines, str - buf);
1991
1992 /*
1993 * If there have been a lot of new lines, then update the screen
1994 * What the heck I'll cheat and only refresh less than every page-full.
1995 * the number of pages between refreshes is refresh_limit, which
1996 * is incremented here because we must be doing flat-out scrolling.
1997 *
1998 * refreshing should be correct for small scrolls, because of the
1999 * time-out
2000 */
2001 if (refreshnow)
2002 {
2003 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2004 refresh_limit++;
2005
2006 scr_refresh (refresh_type);
2007 }
2008
2009 }
2010 else
2011 {
2012 try
2013 {
2014 process_nonprinting (ch);
2015 }
2016 catch (const class out_of_input &o)
2017 {
2018 // we ran out of input, retry later
2019 cmdbuf_ptr = seq_begin;
2020 break;
2021 }
2022
2023 ch = NOCHAR;
2024 }
2025 }
2026
2027 return flag;
2028}
2029
2030// read the next character
2031unicode_t
2032rxvt_term::next_char ()
2033{
2034 while (cmdbuf_ptr < cmdbuf_endp)
2035 {
2036 // assume 7-bit to be ascii ALWAYS
2037 if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)
2038 return *cmdbuf_ptr++;
2039
2040 wchar_t wc;
2041 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
2042
2043 if (len == (size_t)-2)
2044 {
2045 // the mbstate stores incomplete sequences. didn't know this :/
2046 cmdbuf_ptr = cmdbuf_endp;
2047 break;
2048 }
2049
2050 if (len == (size_t)-1)
2051 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2052
2053 // assume wchar == unicode
2054 cmdbuf_ptr += len;
2055 return wc;
2056 }
2057
2058 return NOCHAR;
2059}
2060
2061/* rxvt_cmd_getc () - Return next input character */
2062/*
2063 * Return the next input character after first passing any keyboard input
2064 * to the command.
2065 */
2066unicode_t
2067rxvt_term::cmd_getc ()
2068{
2069 unicode_t c = next_char ();
2070
2071 if (c == NOCHAR)
2072 throw out_of_input;
2073
2074 return c;
2075}
2120 2076
2121/*{{{ print pipe */ 2077/*{{{ print pipe */
2122/*----------------------------------------------------------------------*/ 2078/*----------------------------------------------------------------------*/
2123#ifdef PRINTPIPE 2079#ifdef PRINTPIPE
2124FILE * 2080FILE *
2125rxvt_term::popen_printer () 2081rxvt_term::popen_printer ()
2126{ 2082{
2127 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2083 FILE *stream = popen (rs[Rs_print_pipe], "w");
2128 2084
2129 if (stream == NULL) 2085 if (stream == NULL)
2130 rxvt_print_error ("can't open printer pipe"); 2086 rxvt_warn ("can't open printer pipe, not printing.\n");
2087
2131 return stream; 2088 return stream;
2132} 2089}
2133 2090
2134int 2091int
2135rxvt_term::pclose_printer (FILE *stream) 2092rxvt_term::pclose_printer (FILE *stream)
2136{ 2093{
2137 fflush (stream); 2094 fflush (stream);
2138 /* pclose () reported not to work on SunOS 4.1.3 */
2139# if defined (__sun__) /* TODO: RESOLVE THIS */
2140 /* pclose works provided SIGCHLD handler uses waitpid */
2141 return pclose (stream); /* return fclose (stream); */
2142# else
2143 return pclose (stream); 2095 return pclose (stream);
2144# endif
2145} 2096}
2146 2097
2147/* 2098/*
2148 * simulate attached vt100 printer 2099 * simulate attached vt100 printer
2149 */ 2100 */
2150void 2101void
2151rxvt_term::process_print_pipe () 2102rxvt_term::process_print_pipe ()
2152{ 2103{
2153 int done; 2104 int done;
2154 FILE *fd; 2105 FILE *fd;
2155 2106
2156 if ((fd = popen_printer ()) == NULL) 2107 if ((fd = popen_printer ()) == NULL)
2157 return; 2108 return;
2158 2109
2159 /* 2110 /*
2160 * Send all input to the printer until either ESC[4i or ESC[?4i 2111 * Send all input to the printer until either ESC[4i or ESC[?4i
2161 * is received. 2112 * is received.
2162 */ 2113 */
2163 for (done = 0; !done;) 2114 for (done = 0; !done;)
2164 { 2115 {
2165 unsigned char buf[8]; 2116 unsigned char buf[8];
2166 unsigned char ch; 2117 unicode_t ch;
2167 unsigned int i, len; 2118 unsigned int i, len;
2168 2119
2169 if ((ch = cmd_getc ()) != C0_ESC) 2120 if ((ch = cmd_getc ()) != C0_ESC)
2170 { 2121 {
2171 if (putc (ch, fd) == EOF) 2122 if (putc (ch, fd) == EOF)
2172 break; /* done = 1 */ 2123 break; /* done = 1 */
2187 { 2138 {
2188 if ((buf[len++] = cmd_getc ()) == 'i') 2139 if ((buf[len++] = cmd_getc ()) == 'i')
2189 break; /* done = 1 */ 2140 break; /* done = 1 */
2190 } 2141 }
2191 } 2142 }
2143
2192 for (i = 0; i < len; i++) 2144 for (i = 0; i < len; i++)
2193 if (putc (buf[i], fd) == EOF) 2145 if (putc (buf[i], fd) == EOF)
2194 { 2146 {
2195 done = 1; 2147 done = 1;
2196 break; 2148 break;
2197 } 2149 }
2198 } 2150 }
2199 } 2151 }
2152
2200 pclose_printer (fd); 2153 pclose_printer (fd);
2201} 2154}
2202#endif /* PRINTPIPE */ 2155#endif /* PRINTPIPE */
2203/*}}} */ 2156/*}}} */
2204 2157
2212}; 2165};
2213/* *INDENT-ON* */ 2166/* *INDENT-ON* */
2214 2167
2215/*{{{ process non-printing single characters */ 2168/*{{{ process non-printing single characters */
2216void 2169void
2217rxvt_term::process_nonprinting (unsigned char ch) 2170rxvt_term::process_nonprinting (unicode_t ch)
2218{ 2171{
2219 switch (ch) 2172 switch (ch)
2220 { 2173 {
2174 case C0_ESC:
2175 process_escape_seq ();
2176 break;
2221 case C0_ENQ: /* terminal Status */ 2177 case C0_ENQ: /* terminal Status */
2222 if (rs[Rs_answerbackstring]) 2178 if (rs[Rs_answerbackstring])
2223 tt_write ( 2179 tt_write (
2224 (const unsigned char *)rs[Rs_answerbackstring], 2180 (const unsigned char *)rs[Rs_answerbackstring],
2225 (unsigned int)STRLEN (rs[Rs_answerbackstring])); 2181 (unsigned int)STRLEN (rs[Rs_answerbackstring]));
2248 scr_charset_choose (1); 2204 scr_charset_choose (1);
2249 break; 2205 break;
2250 case C0_SI: /* shift in - acs */ 2206 case C0_SI: /* shift in - acs */
2251 scr_charset_choose (0); 2207 scr_charset_choose (0);
2252 break; 2208 break;
2209
2210 // 8-bit controls
2211 case 0x90: /* DCS */
2212 process_dcs_seq ();
2213 break;
2214 case 0x9b: /* CSI */
2215 process_csi_seq ();
2216 break;
2217 case 0x9d: /* CSI */
2218 process_osc_seq ();
2219 break;
2253 } 2220 }
2254} 2221}
2255/*}}} */ 2222/*}}} */
2256 2223
2257 2224
2258/*{{{ process VT52 escape sequences */ 2225/*{{{ process VT52 escape sequences */
2259void 2226void
2260rxvt_term::process_escape_vt52 (unsigned char ch) 2227rxvt_term::process_escape_vt52 (unicode_t ch)
2261{ 2228{
2262 int row, col; 2229 int row, col;
2263 2230
2264 switch (ch) 2231 switch (ch)
2265 { 2232 {
2317 2284
2318/*{{{ process escape sequences */ 2285/*{{{ process escape sequences */
2319void 2286void
2320rxvt_term::process_escape_seq () 2287rxvt_term::process_escape_seq ()
2321{ 2288{
2322 unsigned char ch = cmd_getc (); 2289 unicode_t ch = cmd_getc ();
2323 2290
2324 if (PrivateModes & PrivMode_vt52) 2291 if (PrivateModes & PrivMode_vt52)
2325 { 2292 {
2326 process_escape_vt52 (ch); 2293 process_escape_vt52 (ch);
2327 return; 2294 return;
2344 scr_charset_set (2, (unsigned int)cmd_getc ()); 2311 scr_charset_set (2, (unsigned int)cmd_getc ());
2345 break; 2312 break;
2346 case '+': 2313 case '+':
2347 scr_charset_set (3, (unsigned int)cmd_getc ()); 2314 scr_charset_set (3, (unsigned int)cmd_getc ());
2348 break; 2315 break;
2349#ifdef MULTICHAR_SET
2350 case '$':
2351 scr_charset_set (-2, (unsigned int)cmd_getc ());
2352 break;
2353#endif
2354#ifndef NO_FRILLS 2316#ifndef NO_FRILLS
2355 case '6': 2317 case '6':
2356 scr_backindex (); 2318 scr_backindex ();
2357 break; 2319 break;
2358#endif 2320#endif
2380 break; 2342 break;
2381 2343
2382 /* 8.3.87: NEXT LINE */ 2344 /* 8.3.87: NEXT LINE */
2383 case C1_NEL: /* ESC E */ 2345 case C1_NEL: /* ESC E */
2384 { 2346 {
2385 uint32_t nlcr[] = { '\n', '\r' }; 2347 unicode_t nlcr[] = { L'\n', L'\r' };
2386 scr_add_lines (nlcr, 1, 2); 2348 scr_add_lines (nlcr, 1, 2);
2387 } 2349 }
2388 break; 2350 break;
2389 2351
2390 /* kidnapped escape sequence: Should be 8.3.48 */ 2352 /* kidnapped escape sequence: Should be 8.3.48 */
2482/* *INDENT-ON* */ 2444/* *INDENT-ON* */
2483 2445
2484void 2446void
2485rxvt_term::process_csi_seq () 2447rxvt_term::process_csi_seq ()
2486{ 2448{
2487 unsigned char ch, priv, i; 2449 unicode_t ch, priv, i;
2488 unsigned int nargs, p; 2450 unsigned int nargs, p;
2489 int n, ndef; 2451 int n, ndef;
2490 int arg[ESC_ARGS]; 2452 int arg[ESC_ARGS];
2491 2453
2492 for (nargs = ESC_ARGS; nargs > 0;) 2454 for (nargs = ESC_ARGS; nargs > 0;)
2493 arg[--nargs] = 0; 2455 arg[--nargs] = 0;
2494 2456
2495 priv = 0; 2457 priv = 0;
2497 if (ch >= '<' && ch <= '?') 2459 if (ch >= '<' && ch <= '?')
2498 { /* '<' '=' '>' '?' */ 2460 { /* '<' '=' '>' '?' */
2499 priv = ch; 2461 priv = ch;
2500 ch = cmd_getc (); 2462 ch = cmd_getc ();
2501 } 2463 }
2464
2502 /* read any numerical arguments */ 2465 /* read any numerical arguments */
2503 for (n = -1; ch < CSI_ICH; ) 2466 for (n = -1; ch < CSI_ICH; )
2504 { 2467 {
2505 if (isdigit (ch)) 2468 if (isdigit (ch))
2506 { 2469 {
2513 { 2476 {
2514 if (nargs < ESC_ARGS) 2477 if (nargs < ESC_ARGS)
2515 arg[nargs++] = n; 2478 arg[nargs++] = n;
2516 n = -1; 2479 n = -1;
2517 } 2480 }
2518 else if (ch == '\b') 2481 else if (IS_CONTROL (ch))
2519 {
2520 scr_backspace ();
2521 }
2522 else if (ch == C0_ESC)
2523 {
2524 process_escape_seq ();
2525 return;
2526 }
2527 else if (ch < ' ')
2528 {
2529 process_nonprinting (ch); 2482 process_nonprinting (ch);
2530 } 2483
2531 ch = cmd_getc (); 2484 ch = cmd_getc ();
2532 } 2485 }
2533 2486
2534 if (ch > CSI_7F) 2487 if (ch > CSI_7F)
2535 return; 2488 return;
2699 case 7: /* unofficial extension */ 2652 case 7: /* unofficial extension */
2700 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2653 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2701 break; 2654 break;
2702#endif 2655#endif
2703 case 8: /* unofficial extension */ 2656 case 8: /* unofficial extension */
2704 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); 2657 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2705 break; 2658 break;
2706 } 2659 }
2707 break; 2660 break;
2708 2661
2709 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2662 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
2777#endif 2730#endif
2778 2731
2779 case CSI_78: /* DECREQTPARM */ 2732 case CSI_78: /* DECREQTPARM */
2780 if (arg[0] == 0 || arg[0] == 1) 2733 if (arg[0] == 0 || arg[0] == 1)
2781 tt_printf ("\033[%d;1;1;128;128;1;0x", arg[0] + 2); 2734 tt_printf ("\033[%d;1;1;128;128;1;0x", arg[0] + 2);
2782 /* FALLTHROUGH */ 2735 break;
2783 2736
2784 default: 2737 default:
2785 break; 2738 break;
2786 } 2739 }
2787} 2740}
2790#ifndef NO_FRILLS 2743#ifndef NO_FRILLS
2791/* ARGSUSED */ 2744/* ARGSUSED */
2792void 2745void
2793rxvt_term::process_window_ops (const int *args, unsigned int nargs) 2746rxvt_term::process_window_ops (const int *args, unsigned int nargs)
2794{ 2747{
2795 int x, y; 2748 int x, y;
2796#if 0
2797 char *s;
2798#endif
2799 XWindowAttributes wattr; 2749 XWindowAttributes wattr;
2800 Window wdummy; 2750 Window wdummy;
2801 2751
2802 if (nargs == 0) 2752 if (nargs == 0)
2803 return; 2753 return;
2754
2804 switch (args[0]) 2755 switch (args[0])
2805 { 2756 {
2806 /* 2757 /*
2807 * commands 2758 * commands
2808 */ 2759 */
2809 case 1: /* deiconify window */ 2760 case 1: /* deiconify window */
2810 XMapWindow (display->display, TermWin.parent[0]); 2761 XMapWindow (display->display, TermWin.parent[0]);
2811 break; 2762 break;
2812 case 2: /* iconify window */ 2763 case 2: /* iconify window */
2813 XIconifyWindow (display->display, TermWin.parent[0], 2764 XIconifyWindow (display->display, TermWin.parent[0],
2830 break; 2781 break;
2831 case 8: /* set size (chars) */ 2782 case 8: /* set size (chars) */
2832 set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), 2783 set_widthheight ((unsigned int) (args[2] * TermWin.fwidth),
2833 (unsigned int) (args[1] * TermWin.fheight)); 2784 (unsigned int) (args[1] * TermWin.fheight));
2834 break; 2785 break;
2786
2787 //case 9: NYI, TODO, restore maximized window or maximize window
2835 default: 2788 default:
2836 if (args[0] >= 24) /* set height (chars) */ 2789 if (args[0] >= 24) /* set height (chars) */
2837 set_widthheight ((unsigned int)TermWin.width, 2790 set_widthheight ((unsigned int)TermWin.width,
2838 (unsigned int) (args[1] * TermWin.fheight)); 2791 (unsigned int) (args[1] * TermWin.fheight));
2839 break; 2792 break;
2793
2794
2840 /* 2795 /*
2841 * reports - some output format copied from XTerm 2796 * reports - some output format copied from XTerm
2842 */ 2797 */
2843 case 11: /* report window state */ 2798 case 11: /* report window state */
2844 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 2799 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2845 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 2800 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
2846 break; 2801 break;
2847 case 13: /* report window position */ 2802 case 13: /* report window position */
2853 break; 2808 break;
2854 case 14: /* report window size (pixels) */ 2809 case 14: /* report window size (pixels) */
2855 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 2810 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2856 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 2811 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
2857 break; 2812 break;
2858 case 18: /* report window size (chars) */ 2813 case 18: /* report text area size (chars) */
2859 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); 2814 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol);
2815 break;
2816 case 19: /* report window size (chars) */
2817 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol);
2860 break; 2818 break;
2861#if 0 /* XXX: currently disabled due to security concerns */ 2819#if 0 /* XXX: currently disabled due to security concerns */
2862 case 20: /* report icon label */ 2820 case 20: /* report icon label */
2863 XGetIconName (display->display, TermWin.parent[0], &s); 2821 XGetIconName (display->display, TermWin.parent[0], &s);
2864 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ 2822 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */
2866 case 21: /* report window title */ 2824 case 21: /* report window title */
2867 XFetchName (display->display, TermWin.parent[0], &s); 2825 XFetchName (display->display, TermWin.parent[0], &s);
2868 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ 2826 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */
2869 break; 2827 break;
2870#endif 2828#endif
2871
2872 } 2829 }
2873} 2830}
2874#endif 2831#endif
2875 2832
2876/*----------------------------------------------------------------------*/ 2833/*----------------------------------------------------------------------*/
2877/* 2834/*
2878 * get input up until STRING TERMINATOR (or BEL) 2835 * get input up until STRING TERMINATOR (or BEL)
2879 * ends_how is terminator used. returned input must be free ()d 2836 * ends_how is terminator used. returned input must be free ()d
2880 */ 2837 */
2881unsigned char * 2838unsigned char *
2882rxvt_term::get_to_st (unsigned char *ends_how) 2839rxvt_term::get_to_st (unicode_t &ends_how)
2883{ 2840{
2884 int seen_esc = 0; /* seen escape? */ 2841 int seen_esc = 0; /* seen escape? */
2885 unsigned int n = 0; 2842 unsigned int n = 0;
2886 unsigned char *s; 2843 unsigned char *s;
2844 unicode_t ch;
2887 unsigned char ch, string[STRING_MAX]; 2845 unsigned char string[STRING_MAX];
2888 2846
2889 for (; (ch = cmd_getc ());) 2847 while ((ch = cmd_getc ()))
2890 { 2848 {
2891 if (ch == C0_BEL 2849 if (ch == C0_BEL
2892 || ch == CHAR_ST 2850 || ch == CHAR_ST
2893 || (ch == 0x5c && seen_esc)) /* 7bit ST */ 2851 || (ch == 0x5c && seen_esc)) /* 7bit ST */
2894 break; 2852 break;
2853
2895 if (ch == C0_ESC) 2854 if (ch == C0_ESC)
2896 { 2855 {
2897 seen_esc = 1; 2856 seen_esc = 1;
2898 continue; 2857 continue;
2899 } 2858 }
2900 else if (ch == '\t') 2859 else if (ch == '\t')
2901 ch = ' '; /* translate '\t' to space */ 2860 ch = ' '; /* translate '\t' to space */
2902 else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) 2861 else if (ch < 0x08 || (ch > 0x0d && ch < 0x20))
2903 return NULL; /* other control character - exit */ 2862 return NULL; /* other control character - exit */
2863
2904 if (n < sizeof (string) - 1) 2864 if (n < sizeof (string) - 1)
2905 string[n++] = ch; 2865 string[n++] = ch;
2866
2906 seen_esc = 0; 2867 seen_esc = 0;
2907 } 2868 }
2869
2908 string[n++] = '\0'; 2870 string[n++] = '\0';
2871
2909 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) 2872 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
2910 return NULL; 2873 return NULL;
2874
2911 *ends_how = (ch == 0x5c ? C0_ESC : ch); 2875 ends_how = (ch == 0x5c ? C0_ESC : ch);
2912 STRNCPY (s, string, n); 2876 STRNCPY (s, string, n);
2913 return s; 2877 return s;
2914} 2878}
2915 2879
2916/*----------------------------------------------------------------------*/ 2880/*----------------------------------------------------------------------*/
2918 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' 2882 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)'
2919 */ 2883 */
2920void 2884void
2921rxvt_term::process_dcs_seq () 2885rxvt_term::process_dcs_seq ()
2922{ 2886{
2923 unsigned char eh, *s; 2887 unsigned char *s;
2888 unicode_t eh;
2889
2924 /* 2890 /*
2925 * Not handled yet 2891 * Not handled yet
2926 */ 2892 */
2927 s = get_to_st (&eh); 2893 s = get_to_st (eh);
2928 if (s) 2894 if (s)
2929 free (s); 2895 free (s);
2896
2930 return; 2897 return;
2931} 2898}
2932 2899
2933/*----------------------------------------------------------------------*/ 2900/*----------------------------------------------------------------------*/
2934/* 2901/*
2935 * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' 2902 * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)'
2936 */ 2903 */
2937void 2904void
2938rxvt_term::process_osc_seq () 2905rxvt_term::process_osc_seq ()
2939{ 2906{
2940 unsigned char ch, eh, *s; 2907 unicode_t ch, eh;
2941 int arg; 2908 int arg;
2942 2909
2943 ch = cmd_getc (); 2910 ch = cmd_getc ();
2944 for (arg = 0; isdigit (ch); ch = cmd_getc ()) 2911 for (arg = 0; isdigit (ch); ch = cmd_getc ())
2945 arg = arg * 10 + (ch - '0'); 2912 arg = arg * 10 + (ch - '0');
2946 2913
2947 if (ch == ';') 2914 if (ch == ';')
2948 { 2915 {
2949 s = get_to_st (&eh); 2916 unsigned char *s = get_to_st (eh);
2917
2950 if (s) 2918 if (s)
2951 { 2919 {
2952 /* 2920 /*
2953 * rxvt_menubar_dispatch () violates the constness of the string, 2921 * rxvt_menubar_dispatch () violates the constness of the string,
2954 * so do it here 2922 * so do it here
2959#else 2927#else
2960 (void)0; 2928 (void)0;
2961#endif 2929#endif
2962 else 2930 else
2963 xterm_seq (arg, (char *)s, eh); 2931 xterm_seq (arg, (char *)s, eh);
2932
2964 free (s); 2933 free (s);
2965 } 2934 }
2966 } 2935 }
2967} 2936}
2968/* 2937/*
2978 * 19 = change underlined character color 2947 * 19 = change underlined character color
2979 * 46 = change logfile (not implemented) 2948 * 46 = change logfile (not implemented)
2980 * 50 = change font 2949 * 50 = change font
2981 * 2950 *
2982 * rxvt extensions: 2951 * rxvt extensions:
2983 * 9 = change locale (NYI)
2984 * 10 = menu (may change in future) 2952 * 10 = menu (may change in future)
2985 * 20 = bg pixmap 2953 * 20 = bg pixmap
2986 * 39 = change default fg color 2954 * 39 = change default fg color
2987 * 49 = change default bg color 2955 * 49 = change default bg color
2988 * 55 = dump scrollback buffer and all of screen 2956 * 55 = dump scrollback buffer and all of screen
2957 * 701 = change locale
2958 * 702 = find font
2989 */ 2959 */
2990void 2960void
2991rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) 2961rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused)))
2992{ 2962{
2993 int changed = 0; 2963 int changed = 0;
2994 int color; 2964 int color;
2995 char *buf, *name; 2965 char *buf, *name;
2996 2966
2997 assert (str != NULL); 2967 assert (str != NULL);
2998 switch (op) 2968 switch (op)
2999 { 2969 {
3000 case XTerm_name: 2970 case XTerm_name:
3001 set_title (str); 2971 set_title (str);
3002 /* FALLTHROUGH */ 2972 /* FALLTHROUGH */
3003 case XTerm_iconName: 2973 case XTerm_iconName:
3004 set_iconName (str); 2974 set_icon_name (str);
3005 break; 2975 break;
3006 case XTerm_title: 2976 case XTerm_title:
3007 set_title (str); 2977 set_title (str);
3008 break; 2978 break;
3009 case XTerm_Color: 2979 case XTerm_Color:
3010 for (buf = (char *)str; buf && *buf;) 2980 for (buf = (char *)str; buf && *buf;)
3011 { 2981 {
3012 if ((name = STRCHR (buf, ';')) == NULL) 2982 if ((name = STRCHR (buf, ';')) == NULL)
3013 break; 2983 break;
2984
3014 *name++ = '\0'; 2985 *name++ = '\0';
3015 color = atoi (buf); 2986 color = atoi (buf);
2987
3016 if (color < 0 || color >= TOTAL_COLORS) 2988 if (color < 0 || color >= TOTAL_COLORS)
3017 break; 2989 break;
2990
3018 if ((buf = STRCHR (name, ';')) != NULL) 2991 if ((buf = STRCHR (name, ';')) != NULL)
3019 *buf++ = '\0'; 2992 *buf++ = '\0';
2993
3020 set_window_color (color + minCOLOR, name); 2994 set_window_color (color + minCOLOR, name);
3021 } 2995 }
3022 break; 2996 break;
3023#ifndef NO_CURSORCOLOR 2997#ifndef NO_CURSORCOLOR
3024 case XTerm_Color_cursor: 2998 case XTerm_Color_cursor:
3077 break; 3051 break;
3078 case XTerm_restoreBG: 3052 case XTerm_restoreBG:
3079 set_window_color (Color_bg, str); 3053 set_window_color (Color_bg, str);
3080 break; 3054 break;
3081 case XTerm_logfile: 3055 case XTerm_logfile:
3056 // TODO, when secure mode?
3082 break; 3057 break;
3083 case XTerm_font: 3058 case XTerm_font:
3084 change_font (str); 3059 change_font (str);
3085 break; 3060 break;
3061#ifndef NO_FRILLS
3086 case XTerm_locale: 3062 case XTerm_locale:
3087 if (str[0] == '?' && !str[1]) 3063 if (str[0] == '?' && !str[1])
3088 tt_printf ("%-.250s\n", locale); 3064 tt_printf ("%-.250s\n", locale);
3089 else 3065 else
3090 { 3066 {
3091 set_locale (str); 3067 set_locale (str);
3068# ifdef USE_XIM
3092 im_cb (); 3069 im_cb ();
3070# endif
3093 } 3071 }
3094 break; 3072 break;
3073 case XTerm_findfont:
3074 {
3075 int fid = TermWin.fontset->find_font (atoi (str));
3076 tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name);
3077 }
3078 break;
3079#endif
3095#if 0 3080#if 0
3096 case XTerm_dumpscreen: /* no error notices */ 3081 case XTerm_dumpscreen: /* no error notices */
3097 { 3082 {
3098 int fd; 3083 int fd;
3099 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3084 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3102 close (fd); 3087 close (fd);
3103 } 3088 }
3104 } 3089 }
3105 break; 3090 break;
3106#endif 3091#endif
3107
3108 } 3092 }
3109} 3093}
3110/*----------------------------------------------------------------------*/ 3094/*----------------------------------------------------------------------*/
3111 3095
3112/*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */ 3096/*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */
3120 * so no need for fancy checking 3104 * so no need for fancy checking
3121 */ 3105 */
3122int 3106int
3123rxvt_term::privcases (int mode, unsigned long bit) 3107rxvt_term::privcases (int mode, unsigned long bit)
3124{ 3108{
3125 int state; 3109 int state;
3126 3110
3127 if (mode == 's') 3111 if (mode == 's')
3128 { 3112 {
3129 SavedModes |= (PrivateModes & bit); 3113 SavedModes |= (PrivateModes & bit);
3130 return -1; 3114 return -1;
3135 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3119 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
3136 else 3120 else
3137 state = (mode == 't') ? ! (PrivateModes & bit) : mode; 3121 state = (mode == 't') ? ! (PrivateModes & bit) : mode;
3138 PrivMode (state, bit); 3122 PrivMode (state, bit);
3139 } 3123 }
3124
3140 return state; 3125 return state;
3141} 3126}
3142 3127
3143/* we're not using priv _yet_ */ 3128/* we're not using priv _yet_ */
3144void 3129void
3145rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) 3130rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg)
3146{ 3131{
3147 unsigned int i, j; 3132 unsigned int i, j;
3148 int state; 3133 int state;
3134
3149 static const struct 3135 static const struct
3150 { 3136 {
3151 const int argval; 3137 const int argval;
3152 const unsigned long bit; 3138 const unsigned long bit;
3153 } 3139 }
3140
3154 argtopriv[] = { 3141 argtopriv[] = {
3155 { 1, PrivMode_aplCUR }, 3142 { 1, PrivMode_aplCUR },
3156 { 2, PrivMode_vt52 }, 3143 { 2, PrivMode_vt52 },
3157 { 3, PrivMode_132 }, 3144 { 3, PrivMode_132 },
3158 { 4, PrivMode_smoothScroll }, 3145 { 4, PrivMode_smoothScroll },
3164 { menuBar_esc, PrivMode_menuBar }, 3151 { menuBar_esc, PrivMode_menuBar },
3165#endif 3152#endif
3166#ifdef scrollBar_esc 3153#ifdef scrollBar_esc
3167 { scrollBar_esc, PrivMode_scrollBar }, 3154 { scrollBar_esc, PrivMode_scrollBar },
3168#endif 3155#endif
3156 // 18, 19 printing-related
3169 { 25, PrivMode_VisibleCursor }, 3157 { 25, PrivMode_VisibleCursor },
3158 // 30 show scrollbar rxvt. extension
3170 { 35, PrivMode_ShiftKeys }, 3159 { 35, PrivMode_ShiftKeys }, // rxvt extension
3171 { 40, PrivMode_132OK }, 3160 { 40, PrivMode_132OK },
3161 // 41 xterm more fixes NYI
3162 // 45 margin bell NYI
3163 // 46 start logging
3172 { 47, PrivMode_Screen }, 3164 { 47, PrivMode_Screen },
3173 { 66, PrivMode_aplKP }, 3165 { 66, PrivMode_aplKP },
3174#ifndef NO_BACKSPACE_KEY 3166#ifndef NO_BACKSPACE_KEY
3175 { 67, PrivMode_BackSpace }, 3167 { 67, PrivMode_BackSpace },
3176#endif 3168#endif
3177 { 1000, PrivMode_MouseX11 }, 3169 { 1000, PrivMode_MouseX11 },
3170 // 1001 Use Hilite Mouse Tracking. NYI, TODO
3171 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO
3172 // 1003 Use All Motion Mouse Tracking. NYI, TODO
3178 { 1010, PrivMode_TtyOutputInh }, 3173 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3179 { 1011, PrivMode_Keypress }, 3174 { 1011, PrivMode_Keypress }, // rxvt extension
3175 // 1035 enable modifiers for alt, numlock NYI
3176 // 1036 send ESC for meta keys NYI
3177 // 1037 send DEL for keypad delete NYI
3180 { 1047, PrivMode_Screen }, 3178 { 1047, PrivMode_Screen },
3179 // 1048 save and restore cursor
3181 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ 3180 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */
3181 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3182 }; 3182 };
3183 3183
3184 if (nargs == 0) 3184 if (nargs == 0)
3185 return; 3185 return;
3186 3186
3201 state = privcases (mode, argtopriv[j].bit); 3201 state = privcases (mode, argtopriv[j].bit);
3202 break; 3202 break;
3203 } 3203 }
3204 3204
3205 /* extra handling for values with state unkept */ 3205 /* extra handling for values with state unkept */
3206 switch (arg[i])
3207 {
3208 case 1048: /* alternative cursor save */
3209 case 1049:
3210 if (mode == 0)
3211 scr_cursor (RESTORE);
3212 else if (mode == 1)
3213 scr_cursor (SAVE);
3214 /* FALLTHROUGH */
3215 }
3216
3206 if (state == -1) 3217 if (state >= 0)
3218 /* extra handling for values with valid 0 or 1 state */
3207 switch (arg[i]) 3219 switch (arg[i])
3208 { 3220 {
3209 case 1048: /* alternative cursor save */ 3221 /* case 1: - application cursor keys */
3222 case 2: /* VT52 mode */
3223 /* oddball mode. should be set regardless of set/reset
3224 * parameter. Return from VT52 mode with an ESC < from
3225 * within VT52 mode
3226 */
3227 PrivMode (1, PrivMode_vt52);
3228 break;
3229 case 3: /* 80/132 */
3230 if (PrivateModes & PrivMode_132OK)
3231 set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height);
3232 break;
3233 case 4: /* smooth scrolling */
3210 if (mode == 0) 3234 if (state)
3211 scr_cursor (RESTORE); 3235 Options &= ~Opt_jumpScroll;
3212 else if (mode == 1) 3236 else
3213 scr_cursor (SAVE); 3237 Options |= Opt_jumpScroll;
3238 break;
3239 case 5: /* reverse video */
3240 scr_rvideo_mode (state);
3241 break;
3242 case 6: /* relative/absolute origins */
3243 scr_relative_origin (state);
3244 break;
3245 case 7: /* autowrap */
3246 scr_autowrap (state);
3247 break;
3248 /* case 8: - auto repeat, can't do on a per window basis */
3249 case 9: /* X10 mouse reporting */
3250 if (state) /* orthogonal */
3251 PrivateModes &= ~PrivMode_MouseX11;
3252 break;
3253#ifdef menuBar_esc
3254 case menuBar_esc:
3255#ifdef MENUBAR
3256 map_menuBar (state);
3257#endif
3258 break;
3259#endif
3260#ifdef scrollBar_esc
3261 case scrollBar_esc:
3262 if (scrollbar_mapping (state))
3263 {
3264 resize_all_windows (0, 0, 0);
3265 scr_touch (true);
3266 }
3267 break;
3268#endif
3269 case 25: /* visible/invisible cursor */
3270 scr_cursor_visible (state);
3271 break;
3272 /* case 35: - shift keys */
3273 /* case 40: - 80 <--> 132 mode */
3274 case 47: /* secondary screen */
3275 scr_change_screen (state);
3276 break;
3277 /* case 66: - application key pad */
3278 /* case 67: - backspace key */
3279 case 1000: /* X11 mouse reporting */
3280 if (state) /* orthogonal */
3281 PrivateModes &= ~PrivMode_MouseX10;
3282 break;
3283#if 0
3284 case 1001:
3285 break; /* X11 mouse highlighting */
3286#endif
3287 case 1010: /* scroll to bottom on TTY output inhibit */
3288 if (state)
3289 Options &= ~Opt_scrollTtyOutput;
3290 else
3291 Options |= Opt_scrollTtyOutput;
3292 break;
3293 case 1011: /* scroll to bottom on key press */
3294 if (state)
3295 Options |= Opt_scrollTtyKeypress;
3296 else
3297 Options &= ~Opt_scrollTtyKeypress;
3298 break;
3299 case 1047: /* secondary screen w/ clearing */
3300 case 1049: /* better secondary screen w/ clearing, but not fully implemented */
3301 if (current_screen != PRIMARY)
3302 scr_erase_screen (2);
3303
3304 scr_change_screen (state);
3214 /* FALLTHROUGH */ 3305 /* FALLTHROUGH */
3215 default: 3306 default:
3216 continue; /* for (;i;) */ 3307 break;
3217 } 3308 }
3218
3219 /* extra handling for values with valid 0 or 1 state */
3220 switch (arg[i])
3221 {
3222 /* case 1: - application cursor keys */
3223 case 2: /* VT52 mode */
3224 /* oddball mode. should be set regardless of set/reset
3225 * parameter. Return from VT52 mode with an ESC < from
3226 * within VT52 mode
3227 */
3228 PrivMode (1, PrivMode_vt52);
3229 break;
3230 case 3: /* 80/132 */
3231 if (PrivateModes & PrivMode_132OK)
3232 set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth),
3233 (unsigned int)TermWin.height);
3234 break;
3235 case 4: /* smooth scrolling */
3236 if (state)
3237 Options &= ~Opt_jumpScroll;
3238 else
3239 Options |= Opt_jumpScroll;
3240 break;
3241 case 5: /* reverse video */
3242 scr_rvideo_mode (state);
3243 break;
3244 case 6: /* relative/absolute origins */
3245 scr_relative_origin (state);
3246 break;
3247 case 7: /* autowrap */
3248 scr_autowrap (state);
3249 break;
3250 /* case 8: - auto repeat, can't do on a per window basis */
3251 case 9: /* X10 mouse reporting */
3252 if (state) /* orthogonal */
3253 PrivateModes &= ~ (PrivMode_MouseX11);
3254 break;
3255#ifdef menuBar_esc
3256 case menuBar_esc:
3257#ifdef MENUBAR
3258 map_menuBar (state);
3259#endif
3260 break;
3261#endif
3262#ifdef scrollBar_esc
3263 case scrollBar_esc:
3264 if (scrollbar_mapping (state))
3265 {
3266 resize_all_windows (0, 0, 0);
3267 scr_touch (true);
3268 }
3269 break;
3270#endif
3271 case 25: /* visible/invisible cursor */
3272 scr_cursor_visible (state);
3273 break;
3274 /* case 35: - shift keys */
3275 /* case 40: - 80 <--> 132 mode */
3276 case 47: /* secondary screen */
3277 scr_change_screen (state);
3278 break;
3279 /* case 66: - application key pad */
3280 /* case 67: - backspace key */
3281 case 1000: /* X11 mouse reporting */
3282 if (state) /* orthogonal */
3283 PrivateModes &= ~ (PrivMode_MouseX10);
3284 break;
3285#if 0
3286 case 1001:
3287 break; /* X11 mouse highlighting */
3288#endif
3289 case 1010: /* scroll to bottom on TTY output inhibit */
3290 if (state)
3291 Options &= ~Opt_scrollTtyOutput;
3292 else
3293 Options |= Opt_scrollTtyOutput;
3294 break;
3295 case 1011: /* scroll to bottom on key press */
3296 if (state)
3297 Options |= Opt_scrollTtyKeypress;
3298 else
3299 Options &= ~Opt_scrollTtyKeypress;
3300 break;
3301 case 1047: /* secondary screen w/ clearing */
3302 case 1049: /* better secondary screen w/ clearing, but not fully implemented */
3303 if (current_screen != PRIMARY)
3304 scr_erase_screen (2);
3305 scr_change_screen (state);
3306 /* FALLTHROUGH */
3307 default:
3308 break;
3309 }
3310 } 3309 }
3311} 3310}
3312/*}}} */ 3311/*}}} */
3313 3312
3314/*{{{ process sgr sequences */ 3313/*{{{ process sgr sequences */
3315void 3314void
3316rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) 3315rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
3317{ 3316{
3318 unsigned int i; 3317 unsigned int i;
3319 short rendset; 3318 short rendset;
3320 int rendstyle; 3319 int rendstyle;
3321 3320
3322 if (nargs == 0) 3321 if (nargs == 0)
3323 { 3322 {
3324 scr_rendition (0, ~RS_None); 3323 scr_rendition (0, ~RS_None);
3325 return; 3324 return;
3326 } 3325 }
3326
3327 for (i = 0; i < nargs; i++) 3327 for (i = 0; i < nargs; i++)
3328 { 3328 {
3329 rendset = -1; 3329 rendset = -1;
3330 switch (arg[i]) 3330 switch (arg[i])
3331 { 3331 {
3342 rendset = 1, rendstyle = RS_Blink; 3342 rendset = 1, rendstyle = RS_Blink;
3343 break; 3343 break;
3344 case 7: 3344 case 7:
3345 rendset = 1, rendstyle = RS_RVid; 3345 rendset = 1, rendstyle = RS_RVid;
3346 break; 3346 break;
3347 case 8:
3348 // invisible. NYI
3349 break;
3347 case 22: 3350 case 22:
3348 rendset = 0, rendstyle = RS_Bold; 3351 rendset = 0, rendstyle = RS_Bold;
3349 break; 3352 break;
3350 case 24: 3353 case 24:
3351 rendset = 0, rendstyle = RS_Uline; 3354 rendset = 0, rendstyle = RS_Uline;
3354 rendset = 0, rendstyle = RS_Blink; 3357 rendset = 0, rendstyle = RS_Blink;
3355 break; 3358 break;
3356 case 27: 3359 case 27:
3357 rendset = 0, rendstyle = RS_RVid; 3360 rendset = 0, rendstyle = RS_RVid;
3358 break; 3361 break;
3362 case 28:
3363 // visible. NYI
3364 break;
3359 } 3365 }
3366
3360 if (rendset != -1) 3367 if (rendset != -1)
3361 { 3368 {
3362 scr_rendition (rendset, rendstyle); 3369 scr_rendition (rendset, rendstyle);
3363 continue; /* for (;i;) */ 3370 continue; /* for (;i;) */
3364 } 3371 }
3371 case 33: 3378 case 33:
3372 case 34: 3379 case 34:
3373 case 35: 3380 case 35:
3374 case 36: 3381 case 36:
3375 case 37: 3382 case 37:
3376 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), 3383 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg);
3377 Color_fg);
3378 break; 3384 break;
3379#ifdef TTY_256COLOR 3385#ifdef TTY_256COLOR
3380 case 38: 3386 case 38:
3381 if (nargs > i + 2 && arg[i + 1] == 5) 3387 if (nargs > i + 2 && arg[i + 1] == 5)
3382 { 3388 {
3383 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3389 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg);
3384 Color_fg);
3385 i += 2; 3390 i += 2;
3386 } 3391 }
3387 break; 3392 break;
3388#endif 3393#endif
3389 case 39: /* default fg */ 3394 case 39: /* default fg */
3396 case 43: 3401 case 43:
3397 case 44: 3402 case 44:
3398 case 45: 3403 case 45:
3399 case 46: 3404 case 46:
3400 case 47: 3405 case 47:
3401 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), 3406 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg);
3402 Color_bg);
3403 break; 3407 break;
3404#ifdef TTY_256COLOR 3408#ifdef TTY_256COLOR
3405 case 48: 3409 case 48:
3406 if (nargs > i + 2 && arg[i + 1] == 5) 3410 if (nargs > i + 2 && arg[i + 1] == 5)
3407 { 3411 {
3408 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3412 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg);
3409 Color_bg);
3410 i += 2; 3413 i += 2;
3411 } 3414 }
3412 break; 3415 break;
3413#endif 3416#endif
3414 case 49: /* default bg */ 3417 case 49: /* default bg */
3447 3450
3448/*{{{ process Rob Nation's own graphics mode sequences */ 3451/*{{{ process Rob Nation's own graphics mode sequences */
3449void 3452void
3450rxvt_term::process_graphics () 3453rxvt_term::process_graphics ()
3451{ 3454{
3452 unsigned char ch, cmd = cmd_getc (); 3455 unicode_t ch, cmd = cmd_getc ();
3453 3456
3454 if (cmd == 'Q') 3457 if (cmd == 'Q')
3455 { /* query graphics */ 3458 { /* query graphics */
3456 tt_printf ("\033G0\n"); /* no graphics */ 3459 tt_printf ("\033G0\n"); /* no graphics */
3457 return; 3460 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines