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.51 by pcg, Sun Feb 22 08:28:36 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
110 SET_LOCALE (locale); 117 SET_LOCALE (locale);
111 118
112 if (status_return == XLookupChars 119 if (status_return == XLookupChars
113 || status_return == XLookupBoth) 120 || status_return == XLookupBoth)
114 { 121 {
122 /* make sure the user can type ctrl-@, i.e. NUL */
123 if (len == 1 && *wkbuf == 0)
124 {
125 kbuf[0] = 0;
126 len = 1;
127 }
128 else
129 {
115 wkbuf[len] = 0; 130 wkbuf[len] = 0;
116 len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); 131 len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ);
117 if (len < 0) 132 if (len < 0)
118 len = 0; 133 len = 0;
134 }
119 } 135 }
120 else 136 else
121 len = 0; 137 len = 0;
122 } 138 }
123 139
131 valid_keysym = keysym != NoSymbol; 147 valid_keysym = keysym != NoSymbol;
132 } 148 }
133 149
134 if (valid_keysym) 150 if (valid_keysym)
135 { 151 {
136 /* for some backwards compatibility */
137#if defined(HOTKEY_CTRL) || defined(HOTKEY_META)
138# ifdef HOTKEY_CTRL
139 if (ctrl)
140# else
141 if (meta)
142# endif
143 {
144 if (keysym == ks_bigfont)
145 {
146 change_font (FONT_UP);
147 return;
148 }
149 else if (keysym == ks_smallfont)
150 {
151 change_font (FONT_DN);
152 return;
153 }
154 }
155#endif
156
157 if (TermWin.saveLines) 152 if (TermWin.saveLines)
158 { 153 {
159#ifdef UNSHIFTED_SCROLLKEYS 154#ifdef UNSHIFTED_SCROLLKEYS
160 if (!ctrl && !meta) 155 if (!ctrl && !meta)
161 { 156 {
252#ifdef KEYSYM_RESOURCE 247#ifdef KEYSYM_RESOURCE
253 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) 248 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL)
254 { 249 {
255 unsigned int l; 250 unsigned int l;
256 const unsigned char *kbuf0; 251 const unsigned char *kbuf0;
257 const unsigned char ch = C0_ESC;
258 252
259 kbuf0 = (Keysym_map[keysym & 0xFF]); 253 kbuf0 = (Keysym_map[keysym & 0xFF]);
260 l = (unsigned int)*kbuf0++; 254 l = (unsigned int)*kbuf0++;
261 255
262 /* escape prefix */ 256 /* escape prefix */
263 if (meta) 257 if (meta
264# ifdef META8_OPTION 258# ifdef META8_OPTION
265 if (meta_char == C0_ESC) 259 && meta_char == C0_ESC
266# endif 260# endif
261 )
262 {
263 const unsigned char ch = C0_ESC;
267 tt_write (&ch, 1); 264 tt_write (&ch, 1);
265 }
266
268 tt_write (kbuf0, l); 267 tt_write (kbuf0, l);
269 return; 268 return;
270 } 269 }
271 else 270 else
272#endif 271#endif
282 ^ !!ctrl) ? '\b' : '\177'; 281 ^ !!ctrl) ? '\b' : '\177';
283 kbuf[1] = '\0'; 282 kbuf[1] = '\0';
284 } 283 }
285 else 284 else
286 STRCPY (kbuf, key_backspace); 285 STRCPY (kbuf, key_backspace);
287# ifdef MULTICHAR_SET
288 if ((Options & Opt_mc_hack) && screen.cur.col > 0)
289 {
290 int col, row;
291
292 newlen = STRLEN (kbuf);
293 col = screen.cur.col - 1;
294 row = screen.cur.row + TermWin.saveLines;
295 if (IS_MULTI2 (screen.rend[row][col]))
296 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
297 }
298# endif
299 break; 286 break;
300#endif 287#endif
301#ifndef NO_DELETE_KEY 288#ifndef NO_DELETE_KEY
302 case XK_Delete: 289 case XK_Delete:
303 STRCPY (kbuf, key_delete); 290 STRCPY (kbuf, key_delete);
304# ifdef MULTICHAR_SET
305 if (Options & Opt_mc_hack)
306 {
307 int col, row;
308
309 newlen = STRLEN (kbuf);
310 col = screen.cur.col;
311 row = screen.cur.row + TermWin.saveLines;
312 if (IS_MULTI1 (screen.rend[row][col]))
313 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
314 }
315# endif
316 break; 291 break;
317#endif 292#endif
318 case XK_Tab: 293 case XK_Tab:
319 if (shft) 294 if (shft)
320 STRCPY (kbuf, "\033[Z"); 295 STRCPY (kbuf, "\033[Z");
362 kbuf[1] = 'O'; 337 kbuf[1] = 'O';
363 kbuf[2] = "dacb"[keysym - XK_Left]; 338 kbuf[2] = "dacb"[keysym - XK_Left];
364 } 339 }
365 else if (PrivateModes & PrivMode_aplCUR) 340 else if (PrivateModes & PrivMode_aplCUR)
366 kbuf[1] = 'O'; 341 kbuf[1] = 'O';
367#ifdef MULTICHAR_SET
368 //TODO: ??
369 if (Options & Opt_mc_hack)
370 {
371 int col, row, m;
372
373 col = screen.cur.col;
374 row = screen.cur.row + TermWin.saveLines;
375 m = 0;
376 if (keysym == XK_Right
377 && IS_MULTI1 (screen.rend[row][col]))
378 m = 1;
379 else if (keysym == XK_Left)
380 {
381 if (col > 0)
382 {
383 if (IS_MULTI2 (screen.rend[row][col - 1]))
384 m = 1;
385 }
386 else if (screen.cur.row > 0)
387 {
388 col = screen.tlen[--row];
389 if (col == -1)
390 col = TermWin.ncol - 1;
391 else
392 col--;
393 if (col > 0
394 && IS_MULTI2 (screen.rend[row][col]))
395 m = 1;
396 }
397 }
398 if (m)
399 MEMMOVE (kbuf + 3, kbuf, 3 + 1);
400 }
401#endif
402 break; 342 break;
403 343
404#ifndef UNSHIFTED_SCROLLKEYS 344#ifndef UNSHIFTED_SCROLLKEYS
405# ifdef XK_KP_Prior 345# ifdef XK_KP_Prior
406 case XK_KP_Prior: 346 case XK_KP_Prior:
595 break; 535 break;
596 } 536 }
597 if (newlen) 537 if (newlen)
598 len = STRLEN (kbuf); 538 len = STRLEN (kbuf);
599 } 539 }
540
600 /* 541 /*
601 * Pass meta for all function keys, if 'meta' option set 542 * Pass meta for all function keys, if 'meta' option set
602 */ 543 */
603#ifdef META8_OPTION 544#ifdef META8_OPTION
604 if (meta && (meta_char == 0x80) && len > 0) 545 if (meta && (meta_char == 0x80) && len > 0)
619 { 560 {
620 unsigned char *ch; 561 unsigned char *ch;
621 562
622 for (ch = kbuf; ch < kbuf + len; ch++) 563 for (ch = kbuf; ch < kbuf + len; ch++)
623 *ch |= 0x80; 564 *ch |= 0x80;
565
624 meta = 0; 566 meta = 0;
625 } 567 }
626#endif 568#endif
627 /* nil */ ; 569 /* nil */ ;
628 } 570 }
653 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); 595 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
654 596
655 /* escape prefix */ 597 /* escape prefix */
656 if (meta 598 if (meta
657#ifdef META8_OPTION 599#ifdef META8_OPTION
658 && (meta_char == C0_ESC) 600 && meta_char == C0_ESC
659#endif 601#endif
660 ) 602 )
661 { 603 {
662 const unsigned char ch = C0_ESC; 604 const unsigned char ch = C0_ESC;
663
664 tt_write (&ch, 1); 605 tt_write (&ch, 1);
665 } 606 }
607
666#ifdef DEBUG_CMD 608#if defined(DEBUG_CMD)
667 if (debug_key)
668 { /* Display keyboard buffer contents */ 609 /* Display keyboard buffer contents */
669 char *p; 610 unsigned char *p;
670 int i; 611 int i;
671 612
672 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); 613 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len);
673 for (i = 0, p = kbuf; i < len; i++, p++) 614 for (i = 0, p = kbuf; i < len; i++, p++)
674 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); 615 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p);
675 fprintf (stderr, "'\n"); 616 fprintf (stderr, "'\n");
676 }
677#endif /* DEBUG_CMD */ 617#endif /* DEBUG_CMD */
678 tt_write (kbuf, (unsigned int)len); 618 tt_write (kbuf, (unsigned int)len);
679} 619}
680/*}}} */ 620/*}}} */
681 621
683/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ 623/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */
684/* attempt to `write' count to the input buffer */ 624/* attempt to `write' count to the input buffer */
685unsigned int 625unsigned int
686rxvt_term::cmd_write (const unsigned char *str, unsigned int count) 626rxvt_term::cmd_write (const unsigned char *str, unsigned int count)
687{ 627{
688 unsigned int n, s; 628 unsigned int n, s;
689 629
690 n = cmdbuf_ptr - cmdbuf_base; 630 n = cmdbuf_ptr - cmdbuf_base;
691 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; 631 s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp;
632
692 if (n > 0 && s < count) 633 if (n > 0 && s < count)
693 { 634 {
694 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 635 MEMMOVE (cmdbuf_base, cmdbuf_ptr,
695 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 636 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
696 cmdbuf_ptr = cmdbuf_base; 637 cmdbuf_ptr = cmdbuf_base;
697 cmdbuf_endp -= n; 638 cmdbuf_endp -= n;
698 s += n; 639 s += n;
699 } 640 }
641
700 if (count > s) 642 if (count > s)
701 { 643 {
702 rxvt_print_error ("data loss: cmd_write too large"); 644 rxvt_warn ("data loss: cmd_write too large, continuing.\n");
703 count = s; 645 count = s;
704 } 646 }
647
705 for (; count--;) 648 for (; count--;)
706 *cmdbuf_endp++ = *str++; 649 *cmdbuf_endp++ = *str++;
650
651 cmd_parse ();
652
707 return 0; 653 return 0;
708} 654}
709#endif /* MENUBAR_MAX */ 655#endif /* MENUBAR_MAX */
710 656
711void 657void
774 720
775 memmove (cmdbuf_base, cmdbuf_ptr, n); 721 memmove (cmdbuf_base, cmdbuf_ptr, n);
776 cmdbuf_ptr = cmdbuf_base; 722 cmdbuf_ptr = cmdbuf_base;
777 cmdbuf_endp = cmdbuf_ptr + n; 723 cmdbuf_endp = cmdbuf_ptr + n;
778 724
779 n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n); 725 n = read (cmd_fd, cmdbuf_endp, CBUFSIZ - n);
780 726
781 if (n > 0) 727 if (n > 0)
782 { 728 {
783 cmdbuf_endp += n; 729 cmdbuf_endp += n;
784 return true; 730 return true;
785 } 731 }
786 else if (n < 0 && errno != EAGAIN) 732 else if (n < 0 && errno != EAGAIN)
787 destroy (); 733 destroy ();
788 734
789 return false; 735 return false;
790} 736}
791 737
792void 738void
793rxvt_term::pty_cb (io_watcher &w, short revents) 739rxvt_term::pty_cb (io_watcher &w, short revents)
797 743
798 if (revents & EVENT_WRITE) 744 if (revents & EVENT_WRITE)
799 tt_write (0, 0); 745 tt_write (0, 0);
800 else if (revents & EVENT_READ) 746 else if (revents & EVENT_READ)
801 { 747 {
802 bool flag = true;
803
804 // loop, but don't allow a single term to monopolize us 748 // loop, but don't allow a single term to monopolize us
805 // the number of loops is fully arbitrary, and thus wrong 749 // the number of loops is fully arbitrary, and thus wrong
806 while (flag && pty_fill ()) 750 while (pty_fill ())
807 { 751 {
808 if (!seen_input) 752 if (!seen_input)
809 { 753 {
810 seen_input = 1; 754 seen_input = 1;
811 /* 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.
812 tt_winch (); 757 tt_winch ();
813 } 758 }
814 759
815 uint32_t ch = NOCHAR; 760 if (cmd_parse ())
816
817 for (;;)
818 {
819 if (ch == NOCHAR)
820 ch = next_char ();
821
822 if (ch == NOCHAR) // TODO: improve
823 break; 761 break;
824
825 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
826 {
827 /* Read a text string from the input buffer */
828 uint32_t buf[BUFSIZ];
829 bool refreshnow = false;
830 int nlines = 0;
831 uint32_t *str = buf;
832
833 *str++ = ch;
834
835 for (;;)
836 {
837 ch = next_char ();
838
839 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
840 break;
841 else
842 {
843 *str++ = ch;
844
845 if (ch == '\n')
846 {
847 nlines++;
848 refresh_count++;
849
850 if (! (Options & Opt_jumpScroll)
851 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
852 {
853 refreshnow = true;
854 flag = false;
855 ch = NOCHAR;
856 break;
857 }
858
859 // scr_add_lines only works for nlines < TermWin.nrow - 1.
860 if (nlines >= TermWin.nrow - 1)
861 {
862 scr_add_lines (buf, nlines, str - buf);
863 nlines = 0;
864 str = buf;
865 }
866 }
867
868 if (str >= buf + BUFSIZ)
869 {
870 ch = NOCHAR;
871 break;
872 }
873 }
874 }
875
876 scr_add_lines (buf, nlines, str - buf);
877
878 /*
879 * If there have been a lot of new lines, then update the screen
880 * What the heck I'll cheat and only refresh less than every page-full.
881 * the number of pages between refreshes is refresh_limit, which
882 * is incremented here because we must be doing flat-out scrolling.
883 *
884 * refreshing should be correct for small scrolls, because of the
885 * time-out
886 */
887 if (refreshnow)
888 {
889 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
890 refresh_limit++;
891
892 scr_refresh (refresh_type);
893 }
894
895 }
896 else
897 {
898 switch (ch)
899 {
900 default:
901 process_nonprinting (ch);
902 break;
903 case C0_ESC: /* escape char */
904 process_escape_seq ();
905 break;
906 /*case 0x9b: */ /* CSI */
907 /* process_csi_seq (); */
908 }
909
910 ch = NOCHAR;
911 }
912 } 762 }
913 }
914 }
915}
916
917// read the next character, currently handles UTF-8
918// will probably handle all sorts of other stuff in the future
919uint32_t
920rxvt_term::next_char ()
921{
922 while (cmdbuf_ptr < cmdbuf_endp)
923 {
924 if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh
925 return *cmdbuf_ptr++;
926
927 wchar_t wc;
928 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
929
930 if (len == (size_t)-2)
931 return NOCHAR;
932
933 if (len == (size_t)-1)
934 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
935
936 // assume wchar == unicode
937 cmdbuf_ptr += len;
938 return wc;
939 }
940
941 return NOCHAR;
942}
943
944/* rxvt_cmd_getc () - Return next input character */
945/*
946 * Return the next input character after first passing any keyboard input
947 * to the command.
948 */
949uint32_t
950rxvt_term::cmd_getc ()
951{
952 for (;;)
953 {
954 uint32_t c = next_char ();
955 if (c != NOCHAR)
956 return c;
957
958 // incomplete sequences should occur rarely, still, a better solution
959 // would be preferred. either setjmp/longjmp or better design.
960 fcntl (cmd_fd, F_SETFL, 0);
961 pty_fill ();
962 fcntl (cmd_fd, F_SETFL, O_NONBLOCK);
963 } 763 }
964} 764}
965 765
966#ifdef POINTER_BLANK 766#ifdef POINTER_BLANK
967void 767void
997 pointer_blank (); 797 pointer_blank ();
998} 798}
999#endif 799#endif
1000 800
1001void 801void
1002rxvt_term::mouse_report (const XButtonEvent &ev) 802rxvt_term::mouse_report (XButtonEvent &ev)
1003{ 803{
1004 int button_number, key_state = 0; 804 int button_number, key_state = 0;
1005 int x, y; 805 int x, y;
1006 806
1007 x = ev.x; 807 x = ev.x;
1008 y = ev.y; 808 y = ev.y;
1009 pixel_position (&x, &y); 809 pixel_position (&x, &y);
1010 810
1336 1136
1337 } 1137 }
1338 break; 1138 break;
1339 1139
1340 case SelectionClear: 1140 case SelectionClear:
1341 display->set_selection_owner (0); 1141 selection_clear ();
1342 break; 1142 break;
1343 1143
1344 case SelectionNotify: 1144 case SelectionNotify:
1345 if (selection_wait == Sel_normal) 1145 if (selection_wait == Sel_normal)
1346 selection_paste (ev.xselection.requestor, 1146 selection_paste (ev.xselection.requestor,
1415 pointer_unblank (); 1215 pointer_unblank ();
1416#endif 1216#endif
1417#if MENUBAR 1217#if MENUBAR
1418 if (isMenuBarWindow (ev.xany.window)) 1218 if (isMenuBarWindow (ev.xany.window))
1419 { 1219 {
1420 menubar_control (& (ev.xbutton)); 1220 menubar_control (ev.xbutton);
1421 break; 1221 break;
1422 } 1222 }
1423#endif 1223#endif
1424 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) 1224 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate))
1425 break; 1225 break;
1554#endif 1354#endif
1555 } 1355 }
1556} 1356}
1557 1357
1558void 1358void
1559rxvt_term::button_press (const XButtonEvent &ev) 1359rxvt_term::button_press (XButtonEvent &ev)
1560{ 1360{
1561 int reportmode = 0, clickintime; 1361 int reportmode = 0, clickintime;
1562 1362
1563 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1363 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1564 if (!bypass_keystate) 1364 if (!bypass_keystate)
1792 menubar_control (ev); 1592 menubar_control (ev);
1793#endif 1593#endif
1794} 1594}
1795 1595
1796void 1596void
1797rxvt_term::button_release (const XButtonEvent &ev) 1597rxvt_term::button_release (XButtonEvent &ev)
1798{ 1598{
1799 int reportmode = 0; 1599 int reportmode = 0;
1800 1600
1801 csrO = 0; /* reset csr Offset */ 1601 csrO = 0; /* reset csr Offset */
1802 if (!bypass_keystate) 1602 if (!bypass_keystate)
1964 if (have_pixmap) 1764 if (have_pixmap)
1965 { 1765 {
1966 /* 1766 /*
1967 * Copy display->root pixmap transparency 1767 * Copy display->root pixmap transparency
1968 */ 1768 */
1969 int sx, sy, nx, ny; 1769 int sx, sy, nx, ny;
1970 unsigned int nw, nh; 1770 unsigned int nw, nh;
1971 Window cr; 1771 Window cr;
1972 XImage *image; 1772 XImage *image;
1973 GC gc; 1773 GC gc;
1974 XGCValues gcvalue; 1774 XGCValues gcvalue;
1975 1775
1976 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1776 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
1977 0, 0, &sx, &sy, &cr); 1777 0, 0, &sx, &sy, &cr);
1978 nw = (unsigned int)szHint.width; 1778 nw = (unsigned int)szHint.width;
1979 nh = (unsigned int)szHint.height; 1779 nh = (unsigned int)szHint.height;
1980 nx = ny = 0; 1780 nx = ny = 0;
1781
1981 if (sx < 0) 1782 if (sx < 0)
1982 { 1783 {
1983 nw += sx; 1784 nw += sx;
1984 nx = -sx; 1785 nx = -sx;
1985 sx = 0; 1786 sx = 0;
1986 } 1787 }
1788
1987 if (sy < 0) 1789 if (sy < 0)
1988 { 1790 {
1989 nh += sy; 1791 nh += sy;
1990 ny = -sy; 1792 ny = -sy;
1991 sy = 0; 1793 sy = 0;
1992 } 1794 }
1795
1993 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 1796 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
1994 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 1797 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
1995 allowedxerror = -1; 1798 allowedxerror = -1;
1996 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 1799 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes,
1997 ZPixmap); 1800 ZPixmap);
2030 if (!am_transparent || !am_pixmap_trans) 1833 if (!am_transparent || !am_pixmap_trans)
2031 pchanged = 1; 1834 pchanged = 1;
2032 am_transparent = am_pixmap_trans = 1; 1835 am_transparent = am_pixmap_trans = 1;
2033 } 1836 }
2034 } 1837 }
1838
2035 if (!am_pixmap_trans) 1839 if (!am_pixmap_trans)
2036 { 1840 {
2037 unsigned int n; 1841 unsigned int n;
2038 /* 1842 /*
2039 * InheritPixmap transparency 1843 * InheritPixmap transparency
2054 break; 1858 break;
2055 } 1859 }
2056 if (oldp != TermWin.parent[i]) 1860 if (oldp != TermWin.parent[i])
2057 pchanged = 1; 1861 pchanged = 1;
2058 } 1862 }
1863
2059 n = 0; 1864 n = 0;
1865
2060 if (pchanged) 1866 if (pchanged)
2061 { 1867 {
2062 for (; n < (unsigned int)i; n++) 1868 for (; n < (unsigned int)i; n++)
2063 { 1869 {
2064 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 1870 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
2068 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 1874 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2069 break; 1875 break;
2070 } 1876 }
2071 } 1877 }
2072 } 1878 }
1879
2073 if (n > (int) (sizeof (TermWin.parent) 1880 if (n > (int) (sizeof (TermWin.parent)
2074 / sizeof (TermWin.parent[0]))) 1881 / sizeof (TermWin.parent[0])))
2075 { 1882 {
2076 D_X ((stderr, "InheritPixmap Turning off")); 1883 D_X ((stderr, "InheritPixmap Turning off"));
2077 XSetWindowBackground (display->display, TermWin.parent[0], 1884 XSetWindowBackground (display->display, TermWin.parent[0],
2100 ParentRelative); 1907 ParentRelative);
2101 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 1908 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
2102 ParentRelative); 1909 ParentRelative);
2103 am_transparent = 1; 1910 am_transparent = 1;
2104 } 1911 }
1912
2105 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 1913 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2106 TermWin.parent[i] = None; 1914 TermWin.parent[i] = None;
2107 } 1915 }
2108 return pchanged; 1916 return pchanged;
2109} 1917}
2110#endif 1918#endif
2111 1919
2112/*}}} */ 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}
2113 2076
2114/*{{{ print pipe */ 2077/*{{{ print pipe */
2115/*----------------------------------------------------------------------*/ 2078/*----------------------------------------------------------------------*/
2116#ifdef PRINTPIPE 2079#ifdef PRINTPIPE
2117FILE * 2080FILE *
2118rxvt_term::popen_printer () 2081rxvt_term::popen_printer ()
2119{ 2082{
2120 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2083 FILE *stream = popen (rs[Rs_print_pipe], "w");
2121 2084
2122 if (stream == NULL) 2085 if (stream == NULL)
2123 rxvt_print_error ("can't open printer pipe"); 2086 rxvt_warn ("can't open printer pipe, not printing.\n");
2087
2124 return stream; 2088 return stream;
2125} 2089}
2126 2090
2127int 2091int
2128rxvt_term::pclose_printer (FILE *stream) 2092rxvt_term::pclose_printer (FILE *stream)
2129{ 2093{
2130 fflush (stream); 2094 fflush (stream);
2131 /* pclose () reported not to work on SunOS 4.1.3 */
2132# if defined (__sun__) /* TODO: RESOLVE THIS */
2133 /* pclose works provided SIGCHLD handler uses waitpid */
2134 return pclose (stream); /* return fclose (stream); */
2135# else
2136 return pclose (stream); 2095 return pclose (stream);
2137# endif
2138} 2096}
2139 2097
2140/* 2098/*
2141 * simulate attached vt100 printer 2099 * simulate attached vt100 printer
2142 */ 2100 */
2143void 2101void
2144rxvt_term::process_print_pipe () 2102rxvt_term::process_print_pipe ()
2145{ 2103{
2146 int done; 2104 int done;
2147 FILE *fd; 2105 FILE *fd;
2148 2106
2149 if ((fd = popen_printer ()) == NULL) 2107 if ((fd = popen_printer ()) == NULL)
2150 return; 2108 return;
2151 2109
2152 /* 2110 /*
2153 * 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
2154 * is received. 2112 * is received.
2155 */ 2113 */
2156 for (done = 0; !done;) 2114 for (done = 0; !done;)
2157 { 2115 {
2158 unsigned char buf[8]; 2116 unsigned char buf[8];
2159 unsigned char ch; 2117 unicode_t ch;
2160 unsigned int i, len; 2118 unsigned int i, len;
2161 2119
2162 if ((ch = cmd_getc ()) != C0_ESC) 2120 if ((ch = cmd_getc ()) != C0_ESC)
2163 { 2121 {
2164 if (putc (ch, fd) == EOF) 2122 if (putc (ch, fd) == EOF)
2165 break; /* done = 1 */ 2123 break; /* done = 1 */
2180 { 2138 {
2181 if ((buf[len++] = cmd_getc ()) == 'i') 2139 if ((buf[len++] = cmd_getc ()) == 'i')
2182 break; /* done = 1 */ 2140 break; /* done = 1 */
2183 } 2141 }
2184 } 2142 }
2143
2185 for (i = 0; i < len; i++) 2144 for (i = 0; i < len; i++)
2186 if (putc (buf[i], fd) == EOF) 2145 if (putc (buf[i], fd) == EOF)
2187 { 2146 {
2188 done = 1; 2147 done = 1;
2189 break; 2148 break;
2190 } 2149 }
2191 } 2150 }
2192 } 2151 }
2152
2193 pclose_printer (fd); 2153 pclose_printer (fd);
2194} 2154}
2195#endif /* PRINTPIPE */ 2155#endif /* PRINTPIPE */
2196/*}}} */ 2156/*}}} */
2197 2157
2205}; 2165};
2206/* *INDENT-ON* */ 2166/* *INDENT-ON* */
2207 2167
2208/*{{{ process non-printing single characters */ 2168/*{{{ process non-printing single characters */
2209void 2169void
2210rxvt_term::process_nonprinting (unsigned char ch) 2170rxvt_term::process_nonprinting (unicode_t ch)
2211{ 2171{
2212 switch (ch) 2172 switch (ch)
2213 { 2173 {
2174 case C0_ESC:
2175 process_escape_seq ();
2176 break;
2214 case C0_ENQ: /* terminal Status */ 2177 case C0_ENQ: /* terminal Status */
2215 if (rs[Rs_answerbackstring]) 2178 if (rs[Rs_answerbackstring])
2216 tt_write ( 2179 tt_write (
2217 (const unsigned char *)rs[Rs_answerbackstring], 2180 (const unsigned char *)rs[Rs_answerbackstring],
2218 (unsigned int)STRLEN (rs[Rs_answerbackstring])); 2181 (unsigned int)STRLEN (rs[Rs_answerbackstring]));
2241 scr_charset_choose (1); 2204 scr_charset_choose (1);
2242 break; 2205 break;
2243 case C0_SI: /* shift in - acs */ 2206 case C0_SI: /* shift in - acs */
2244 scr_charset_choose (0); 2207 scr_charset_choose (0);
2245 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;
2246 } 2220 }
2247} 2221}
2248/*}}} */ 2222/*}}} */
2249 2223
2250 2224
2251/*{{{ process VT52 escape sequences */ 2225/*{{{ process VT52 escape sequences */
2252void 2226void
2253rxvt_term::process_escape_vt52 (unsigned char ch) 2227rxvt_term::process_escape_vt52 (unicode_t ch)
2254{ 2228{
2255 int row, col; 2229 int row, col;
2256 2230
2257 switch (ch) 2231 switch (ch)
2258 { 2232 {
2310 2284
2311/*{{{ process escape sequences */ 2285/*{{{ process escape sequences */
2312void 2286void
2313rxvt_term::process_escape_seq () 2287rxvt_term::process_escape_seq ()
2314{ 2288{
2315 unsigned char ch = cmd_getc (); 2289 unicode_t ch = cmd_getc ();
2316 2290
2317 if (PrivateModes & PrivMode_vt52) 2291 if (PrivateModes & PrivMode_vt52)
2318 { 2292 {
2319 process_escape_vt52 (ch); 2293 process_escape_vt52 (ch);
2320 return; 2294 return;
2337 scr_charset_set (2, (unsigned int)cmd_getc ()); 2311 scr_charset_set (2, (unsigned int)cmd_getc ());
2338 break; 2312 break;
2339 case '+': 2313 case '+':
2340 scr_charset_set (3, (unsigned int)cmd_getc ()); 2314 scr_charset_set (3, (unsigned int)cmd_getc ());
2341 break; 2315 break;
2342#ifdef MULTICHAR_SET
2343 case '$':
2344 scr_charset_set (-2, (unsigned int)cmd_getc ());
2345 break;
2346#endif
2347#ifndef NO_FRILLS 2316#ifndef NO_FRILLS
2348 case '6': 2317 case '6':
2349 scr_backindex (); 2318 scr_backindex ();
2350 break; 2319 break;
2351#endif 2320#endif
2373 break; 2342 break;
2374 2343
2375 /* 8.3.87: NEXT LINE */ 2344 /* 8.3.87: NEXT LINE */
2376 case C1_NEL: /* ESC E */ 2345 case C1_NEL: /* ESC E */
2377 { 2346 {
2378 uint32_t nlcr[] = { '\n', '\r' }; 2347 unicode_t nlcr[] = { L'\n', L'\r' };
2379 scr_add_lines (nlcr, 1, 2); 2348 scr_add_lines (nlcr, 1, 2);
2380 } 2349 }
2381 break; 2350 break;
2382 2351
2383 /* kidnapped escape sequence: Should be 8.3.48 */ 2352 /* kidnapped escape sequence: Should be 8.3.48 */
2475/* *INDENT-ON* */ 2444/* *INDENT-ON* */
2476 2445
2477void 2446void
2478rxvt_term::process_csi_seq () 2447rxvt_term::process_csi_seq ()
2479{ 2448{
2480 unsigned char ch, priv, i; 2449 unicode_t ch, priv, i;
2481 unsigned int nargs, p; 2450 unsigned int nargs, p;
2482 int n, ndef; 2451 int n, ndef;
2483 int arg[ESC_ARGS]; 2452 int arg[ESC_ARGS];
2484 2453
2485 for (nargs = ESC_ARGS; nargs > 0;) 2454 for (nargs = ESC_ARGS; nargs > 0;)
2486 arg[--nargs] = 0; 2455 arg[--nargs] = 0;
2487 2456
2488 priv = 0; 2457 priv = 0;
2490 if (ch >= '<' && ch <= '?') 2459 if (ch >= '<' && ch <= '?')
2491 { /* '<' '=' '>' '?' */ 2460 { /* '<' '=' '>' '?' */
2492 priv = ch; 2461 priv = ch;
2493 ch = cmd_getc (); 2462 ch = cmd_getc ();
2494 } 2463 }
2464
2495 /* read any numerical arguments */ 2465 /* read any numerical arguments */
2496 for (n = -1; ch < CSI_ICH; ) 2466 for (n = -1; ch < CSI_ICH; )
2497 { 2467 {
2498 if (isdigit (ch)) 2468 if (isdigit (ch))
2499 { 2469 {
2506 { 2476 {
2507 if (nargs < ESC_ARGS) 2477 if (nargs < ESC_ARGS)
2508 arg[nargs++] = n; 2478 arg[nargs++] = n;
2509 n = -1; 2479 n = -1;
2510 } 2480 }
2511 else if (ch == '\b') 2481 else if (IS_CONTROL (ch))
2512 {
2513 scr_backspace ();
2514 }
2515 else if (ch == C0_ESC)
2516 {
2517 process_escape_seq ();
2518 return;
2519 }
2520 else if (ch < ' ')
2521 {
2522 process_nonprinting (ch); 2482 process_nonprinting (ch);
2523 } 2483
2524 ch = cmd_getc (); 2484 ch = cmd_getc ();
2525 } 2485 }
2526 2486
2527 if (ch > CSI_7F) 2487 if (ch > CSI_7F)
2528 return; 2488 return;
2692 case 7: /* unofficial extension */ 2652 case 7: /* unofficial extension */
2693 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2653 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2694 break; 2654 break;
2695#endif 2655#endif
2696 case 8: /* unofficial extension */ 2656 case 8: /* unofficial extension */
2697 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); 2657 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2698 break; 2658 break;
2699 } 2659 }
2700 break; 2660 break;
2701 2661
2702 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2662 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
2770#endif 2730#endif
2771 2731
2772 case CSI_78: /* DECREQTPARM */ 2732 case CSI_78: /* DECREQTPARM */
2773 if (arg[0] == 0 || arg[0] == 1) 2733 if (arg[0] == 0 || arg[0] == 1)
2774 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);
2775 /* FALLTHROUGH */ 2735 break;
2776 2736
2777 default: 2737 default:
2778 break; 2738 break;
2779 } 2739 }
2780} 2740}
2783#ifndef NO_FRILLS 2743#ifndef NO_FRILLS
2784/* ARGSUSED */ 2744/* ARGSUSED */
2785void 2745void
2786rxvt_term::process_window_ops (const int *args, unsigned int nargs) 2746rxvt_term::process_window_ops (const int *args, unsigned int nargs)
2787{ 2747{
2788 int x, y; 2748 int x, y;
2789#if 0
2790 char *s;
2791#endif
2792 XWindowAttributes wattr; 2749 XWindowAttributes wattr;
2793 Window wdummy; 2750 Window wdummy;
2794 2751
2795 if (nargs == 0) 2752 if (nargs == 0)
2796 return; 2753 return;
2754
2797 switch (args[0]) 2755 switch (args[0])
2798 { 2756 {
2799 /* 2757 /*
2800 * commands 2758 * commands
2801 */ 2759 */
2802 case 1: /* deiconify window */ 2760 case 1: /* deiconify window */
2803 XMapWindow (display->display, TermWin.parent[0]); 2761 XMapWindow (display->display, TermWin.parent[0]);
2804 break; 2762 break;
2805 case 2: /* iconify window */ 2763 case 2: /* iconify window */
2806 XIconifyWindow (display->display, TermWin.parent[0], 2764 XIconifyWindow (display->display, TermWin.parent[0],
2823 break; 2781 break;
2824 case 8: /* set size (chars) */ 2782 case 8: /* set size (chars) */
2825 set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), 2783 set_widthheight ((unsigned int) (args[2] * TermWin.fwidth),
2826 (unsigned int) (args[1] * TermWin.fheight)); 2784 (unsigned int) (args[1] * TermWin.fheight));
2827 break; 2785 break;
2786
2787 //case 9: NYI, TODO, restore maximized window or maximize window
2828 default: 2788 default:
2829 if (args[0] >= 24) /* set height (chars) */ 2789 if (args[0] >= 24) /* set height (chars) */
2830 set_widthheight ((unsigned int)TermWin.width, 2790 set_widthheight ((unsigned int)TermWin.width,
2831 (unsigned int) (args[1] * TermWin.fheight)); 2791 (unsigned int) (args[1] * TermWin.fheight));
2832 break; 2792 break;
2793
2794
2833 /* 2795 /*
2834 * reports - some output format copied from XTerm 2796 * reports - some output format copied from XTerm
2835 */ 2797 */
2836 case 11: /* report window state */ 2798 case 11: /* report window state */
2837 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 2799 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2838 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 2800 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
2839 break; 2801 break;
2840 case 13: /* report window position */ 2802 case 13: /* report window position */
2846 break; 2808 break;
2847 case 14: /* report window size (pixels) */ 2809 case 14: /* report window size (pixels) */
2848 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 2810 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2849 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 2811 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
2850 break; 2812 break;
2851 case 18: /* report window size (chars) */ 2813 case 18: /* report text area size (chars) */
2852 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);
2853 break; 2818 break;
2854#if 0 /* XXX: currently disabled due to security concerns */ 2819#if 0 /* XXX: currently disabled due to security concerns */
2855 case 20: /* report icon label */ 2820 case 20: /* report icon label */
2856 XGetIconName (display->display, TermWin.parent[0], &s); 2821 XGetIconName (display->display, TermWin.parent[0], &s);
2857 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ 2822 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */
2859 case 21: /* report window title */ 2824 case 21: /* report window title */
2860 XFetchName (display->display, TermWin.parent[0], &s); 2825 XFetchName (display->display, TermWin.parent[0], &s);
2861 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ 2826 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */
2862 break; 2827 break;
2863#endif 2828#endif
2864
2865 } 2829 }
2866} 2830}
2867#endif 2831#endif
2868 2832
2869/*----------------------------------------------------------------------*/ 2833/*----------------------------------------------------------------------*/
2870/* 2834/*
2871 * get input up until STRING TERMINATOR (or BEL) 2835 * get input up until STRING TERMINATOR (or BEL)
2872 * ends_how is terminator used. returned input must be free ()d 2836 * ends_how is terminator used. returned input must be free ()d
2873 */ 2837 */
2874unsigned char * 2838unsigned char *
2875rxvt_term::get_to_st (unsigned char *ends_how) 2839rxvt_term::get_to_st (unicode_t &ends_how)
2876{ 2840{
2877 int seen_esc = 0; /* seen escape? */ 2841 int seen_esc = 0; /* seen escape? */
2878 unsigned int n = 0; 2842 unsigned int n = 0;
2879 unsigned char *s; 2843 unsigned char *s;
2844 unicode_t ch;
2880 unsigned char ch, string[STRING_MAX]; 2845 unsigned char string[STRING_MAX];
2881 2846
2882 for (; (ch = cmd_getc ());) 2847 while ((ch = cmd_getc ()))
2883 { 2848 {
2884 if (ch == C0_BEL 2849 if (ch == C0_BEL
2885 || ch == CHAR_ST 2850 || ch == CHAR_ST
2886 || (ch == 0x5c && seen_esc)) /* 7bit ST */ 2851 || (ch == 0x5c && seen_esc)) /* 7bit ST */
2887 break; 2852 break;
2853
2888 if (ch == C0_ESC) 2854 if (ch == C0_ESC)
2889 { 2855 {
2890 seen_esc = 1; 2856 seen_esc = 1;
2891 continue; 2857 continue;
2892 } 2858 }
2893 else if (ch == '\t') 2859 else if (ch == '\t')
2894 ch = ' '; /* translate '\t' to space */ 2860 ch = ' '; /* translate '\t' to space */
2895 else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) 2861 else if (ch < 0x08 || (ch > 0x0d && ch < 0x20))
2896 return NULL; /* other control character - exit */ 2862 return NULL; /* other control character - exit */
2863
2897 if (n < sizeof (string) - 1) 2864 if (n < sizeof (string) - 1)
2898 string[n++] = ch; 2865 string[n++] = ch;
2866
2899 seen_esc = 0; 2867 seen_esc = 0;
2900 } 2868 }
2869
2901 string[n++] = '\0'; 2870 string[n++] = '\0';
2871
2902 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) 2872 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
2903 return NULL; 2873 return NULL;
2874
2904 *ends_how = (ch == 0x5c ? C0_ESC : ch); 2875 ends_how = (ch == 0x5c ? C0_ESC : ch);
2905 STRNCPY (s, string, n); 2876 STRNCPY (s, string, n);
2906 return s; 2877 return s;
2907} 2878}
2908 2879
2909/*----------------------------------------------------------------------*/ 2880/*----------------------------------------------------------------------*/
2911 * 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)'
2912 */ 2883 */
2913void 2884void
2914rxvt_term::process_dcs_seq () 2885rxvt_term::process_dcs_seq ()
2915{ 2886{
2916 unsigned char eh, *s; 2887 unsigned char *s;
2888 unicode_t eh;
2889
2917 /* 2890 /*
2918 * Not handled yet 2891 * Not handled yet
2919 */ 2892 */
2920 s = get_to_st (&eh); 2893 s = get_to_st (eh);
2921 if (s) 2894 if (s)
2922 free (s); 2895 free (s);
2896
2923 return; 2897 return;
2924} 2898}
2925 2899
2926/*----------------------------------------------------------------------*/ 2900/*----------------------------------------------------------------------*/
2927/* 2901/*
2928 * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' 2902 * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)'
2929 */ 2903 */
2930void 2904void
2931rxvt_term::process_osc_seq () 2905rxvt_term::process_osc_seq ()
2932{ 2906{
2933 unsigned char ch, eh, *s; 2907 unicode_t ch, eh;
2934 int arg; 2908 int arg;
2935 2909
2936 ch = cmd_getc (); 2910 ch = cmd_getc ();
2937 for (arg = 0; isdigit (ch); ch = cmd_getc ()) 2911 for (arg = 0; isdigit (ch); ch = cmd_getc ())
2938 arg = arg * 10 + (ch - '0'); 2912 arg = arg * 10 + (ch - '0');
2939 2913
2940 if (ch == ';') 2914 if (ch == ';')
2941 { 2915 {
2942 s = get_to_st (&eh); 2916 unsigned char *s = get_to_st (eh);
2917
2943 if (s) 2918 if (s)
2944 { 2919 {
2945 /* 2920 /*
2946 * rxvt_menubar_dispatch () violates the constness of the string, 2921 * rxvt_menubar_dispatch () violates the constness of the string,
2947 * so do it here 2922 * so do it here
2952#else 2927#else
2953 (void)0; 2928 (void)0;
2954#endif 2929#endif
2955 else 2930 else
2956 xterm_seq (arg, (char *)s, eh); 2931 xterm_seq (arg, (char *)s, eh);
2932
2957 free (s); 2933 free (s);
2958 } 2934 }
2959 } 2935 }
2960} 2936}
2961/* 2937/*
2971 * 19 = change underlined character color 2947 * 19 = change underlined character color
2972 * 46 = change logfile (not implemented) 2948 * 46 = change logfile (not implemented)
2973 * 50 = change font 2949 * 50 = change font
2974 * 2950 *
2975 * rxvt extensions: 2951 * rxvt extensions:
2976 * 9 = change locale (NYI)
2977 * 10 = menu (may change in future) 2952 * 10 = menu (may change in future)
2978 * 20 = bg pixmap 2953 * 20 = bg pixmap
2979 * 39 = change default fg color 2954 * 39 = change default fg color
2980 * 49 = change default bg color 2955 * 49 = change default bg color
2981 * 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
2982 */ 2959 */
2983void 2960void
2984rxvt_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)))
2985{ 2962{
2986 int changed = 0; 2963 int changed = 0;
2987 int color; 2964 int color;
2988 char *buf, *name; 2965 char *buf, *name;
2989 2966
2990 assert (str != NULL); 2967 assert (str != NULL);
2991 switch (op) 2968 switch (op)
2992 { 2969 {
2993 case XTerm_name: 2970 case XTerm_name:
2994 set_title (str); 2971 set_title (str);
2995 /* FALLTHROUGH */ 2972 /* FALLTHROUGH */
2996 case XTerm_iconName: 2973 case XTerm_iconName:
2997 set_iconName (str); 2974 set_icon_name (str);
2998 break; 2975 break;
2999 case XTerm_title: 2976 case XTerm_title:
3000 set_title (str); 2977 set_title (str);
3001 break; 2978 break;
3002 case XTerm_Color: 2979 case XTerm_Color:
3003 for (buf = (char *)str; buf && *buf;) 2980 for (buf = (char *)str; buf && *buf;)
3004 { 2981 {
3005 if ((name = STRCHR (buf, ';')) == NULL) 2982 if ((name = STRCHR (buf, ';')) == NULL)
3006 break; 2983 break;
2984
3007 *name++ = '\0'; 2985 *name++ = '\0';
3008 color = atoi (buf); 2986 color = atoi (buf);
2987
3009 if (color < 0 || color >= TOTAL_COLORS) 2988 if (color < 0 || color >= TOTAL_COLORS)
3010 break; 2989 break;
2990
3011 if ((buf = STRCHR (name, ';')) != NULL) 2991 if ((buf = STRCHR (name, ';')) != NULL)
3012 *buf++ = '\0'; 2992 *buf++ = '\0';
2993
3013 set_window_color (color + minCOLOR, name); 2994 set_window_color (color + minCOLOR, name);
3014 } 2995 }
3015 break; 2996 break;
3016#ifndef NO_CURSORCOLOR 2997#ifndef NO_CURSORCOLOR
3017 case XTerm_Color_cursor: 2998 case XTerm_Color_cursor:
3070 break; 3051 break;
3071 case XTerm_restoreBG: 3052 case XTerm_restoreBG:
3072 set_window_color (Color_bg, str); 3053 set_window_color (Color_bg, str);
3073 break; 3054 break;
3074 case XTerm_logfile: 3055 case XTerm_logfile:
3056 // TODO, when secure mode?
3075 break; 3057 break;
3076 case XTerm_font: 3058 case XTerm_font:
3077 change_font (str); 3059 change_font (str);
3078 break; 3060 break;
3061#ifndef NO_FRILLS
3079 case XTerm_locale: 3062 case XTerm_locale:
3080 /* TODO */ 3063 if (str[0] == '?' && !str[1])
3064 tt_printf ("%-.250s\n", locale);
3065 else
3066 {
3067 set_locale (str);
3068# ifdef USE_XIM
3069 im_cb ();
3070# endif
3071 }
3081 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
3082#if 0 3080#if 0
3083 case XTerm_dumpscreen: /* no error notices */ 3081 case XTerm_dumpscreen: /* no error notices */
3084 { 3082 {
3085 int fd; 3083 int fd;
3086 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)
3089 close (fd); 3087 close (fd);
3090 } 3088 }
3091 } 3089 }
3092 break; 3090 break;
3093#endif 3091#endif
3094
3095 } 3092 }
3096} 3093}
3097/*----------------------------------------------------------------------*/ 3094/*----------------------------------------------------------------------*/
3098 3095
3099/*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */ 3096/*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */
3107 * so no need for fancy checking 3104 * so no need for fancy checking
3108 */ 3105 */
3109int 3106int
3110rxvt_term::privcases (int mode, unsigned long bit) 3107rxvt_term::privcases (int mode, unsigned long bit)
3111{ 3108{
3112 int state; 3109 int state;
3113 3110
3114 if (mode == 's') 3111 if (mode == 's')
3115 { 3112 {
3116 SavedModes |= (PrivateModes & bit); 3113 SavedModes |= (PrivateModes & bit);
3117 return -1; 3114 return -1;
3122 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3119 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
3123 else 3120 else
3124 state = (mode == 't') ? ! (PrivateModes & bit) : mode; 3121 state = (mode == 't') ? ! (PrivateModes & bit) : mode;
3125 PrivMode (state, bit); 3122 PrivMode (state, bit);
3126 } 3123 }
3124
3127 return state; 3125 return state;
3128} 3126}
3129 3127
3130/* we're not using priv _yet_ */ 3128/* we're not using priv _yet_ */
3131void 3129void
3132rxvt_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)
3133{ 3131{
3134 unsigned int i, j; 3132 unsigned int i, j;
3135 int state; 3133 int state;
3134
3136 static const struct 3135 static const struct
3137 { 3136 {
3138 const int argval; 3137 const int argval;
3139 const unsigned long bit; 3138 const unsigned long bit;
3140 } 3139 }
3140
3141 argtopriv[] = { 3141 argtopriv[] = {
3142 { 1, PrivMode_aplCUR }, 3142 { 1, PrivMode_aplCUR },
3143 { 2, PrivMode_vt52 }, 3143 { 2, PrivMode_vt52 },
3144 { 3, PrivMode_132 }, 3144 { 3, PrivMode_132 },
3145 { 4, PrivMode_smoothScroll }, 3145 { 4, PrivMode_smoothScroll },
3151 { menuBar_esc, PrivMode_menuBar }, 3151 { menuBar_esc, PrivMode_menuBar },
3152#endif 3152#endif
3153#ifdef scrollBar_esc 3153#ifdef scrollBar_esc
3154 { scrollBar_esc, PrivMode_scrollBar }, 3154 { scrollBar_esc, PrivMode_scrollBar },
3155#endif 3155#endif
3156 // 18, 19 printing-related
3156 { 25, PrivMode_VisibleCursor }, 3157 { 25, PrivMode_VisibleCursor },
3158 // 30 show scrollbar rxvt. extension
3157 { 35, PrivMode_ShiftKeys }, 3159 { 35, PrivMode_ShiftKeys }, // rxvt extension
3158 { 40, PrivMode_132OK }, 3160 { 40, PrivMode_132OK },
3161 // 41 xterm more fixes NYI
3162 // 45 margin bell NYI
3163 // 46 start logging
3159 { 47, PrivMode_Screen }, 3164 { 47, PrivMode_Screen },
3160 { 66, PrivMode_aplKP }, 3165 { 66, PrivMode_aplKP },
3161#ifndef NO_BACKSPACE_KEY 3166#ifndef NO_BACKSPACE_KEY
3162 { 67, PrivMode_BackSpace }, 3167 { 67, PrivMode_BackSpace },
3163#endif 3168#endif
3164 { 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
3165 { 1010, PrivMode_TtyOutputInh }, 3173 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3166 { 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
3167 { 1047, PrivMode_Screen }, 3178 { 1047, PrivMode_Screen },
3179 // 1048 save and restore cursor
3168 { 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
3169 }; 3182 };
3170 3183
3171 if (nargs == 0) 3184 if (nargs == 0)
3172 return; 3185 return;
3173 3186
3188 state = privcases (mode, argtopriv[j].bit); 3201 state = privcases (mode, argtopriv[j].bit);
3189 break; 3202 break;
3190 } 3203 }
3191 3204
3192 /* 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
3193 if (state == -1) 3217 if (state >= 0)
3218 /* extra handling for values with valid 0 or 1 state */
3194 switch (arg[i]) 3219 switch (arg[i])
3195 { 3220 {
3196 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 */
3197 if (mode == 0) 3234 if (state)
3198 scr_cursor (RESTORE); 3235 Options &= ~Opt_jumpScroll;
3199 else if (mode == 1) 3236 else
3200 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);
3201 /* FALLTHROUGH */ 3305 /* FALLTHROUGH */
3202 default: 3306 default:
3203 continue; /* for (;i;) */ 3307 break;
3204 } 3308 }
3205
3206 /* extra handling for values with valid 0 or 1 state */
3207 switch (arg[i])
3208 {
3209 /* case 1: - application cursor keys */
3210 case 2: /* VT52 mode */
3211 /* oddball mode. should be set regardless of set/reset
3212 * parameter. Return from VT52 mode with an ESC < from
3213 * within VT52 mode
3214 */
3215 PrivMode (1, PrivMode_vt52);
3216 break;
3217 case 3: /* 80/132 */
3218 if (PrivateModes & PrivMode_132OK)
3219 set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth),
3220 (unsigned int)TermWin.height);
3221 break;
3222 case 4: /* smooth scrolling */
3223 if (state)
3224 Options &= ~Opt_jumpScroll;
3225 else
3226 Options |= Opt_jumpScroll;
3227 break;
3228 case 5: /* reverse video */
3229 scr_rvideo_mode (state);
3230 break;
3231 case 6: /* relative/absolute origins */
3232 scr_relative_origin (state);
3233 break;
3234 case 7: /* autowrap */
3235 scr_autowrap (state);
3236 break;
3237 /* case 8: - auto repeat, can't do on a per window basis */
3238 case 9: /* X10 mouse reporting */
3239 if (state) /* orthogonal */
3240 PrivateModes &= ~ (PrivMode_MouseX11);
3241 break;
3242#ifdef menuBar_esc
3243 case menuBar_esc:
3244#ifdef MENUBAR
3245 map_menuBar (state);
3246#endif
3247 break;
3248#endif
3249#ifdef scrollBar_esc
3250 case scrollBar_esc:
3251 if (scrollbar_mapping (state))
3252 {
3253 resize_all_windows (0, 0, 0);
3254 scr_touch (true);
3255 }
3256 break;
3257#endif
3258 case 25: /* visible/invisible cursor */
3259 scr_cursor_visible (state);
3260 break;
3261 /* case 35: - shift keys */
3262 /* case 40: - 80 <--> 132 mode */
3263 case 47: /* secondary screen */
3264 scr_change_screen (state);
3265 break;
3266 /* case 66: - application key pad */
3267 /* case 67: - backspace key */
3268 case 1000: /* X11 mouse reporting */
3269 if (state) /* orthogonal */
3270 PrivateModes &= ~ (PrivMode_MouseX10);
3271 break;
3272#if 0
3273 case 1001:
3274 break; /* X11 mouse highlighting */
3275#endif
3276 case 1010: /* scroll to bottom on TTY output inhibit */
3277 if (state)
3278 Options &= ~Opt_scrollTtyOutput;
3279 else
3280 Options |= Opt_scrollTtyOutput;
3281 break;
3282 case 1011: /* scroll to bottom on key press */
3283 if (state)
3284 Options |= Opt_scrollTtyKeypress;
3285 else
3286 Options &= ~Opt_scrollTtyKeypress;
3287 break;
3288 case 1047: /* secondary screen w/ clearing */
3289 case 1049: /* better secondary screen w/ clearing, but not fully implemented */
3290 if (current_screen != PRIMARY)
3291 scr_erase_screen (2);
3292 scr_change_screen (state);
3293 /* FALLTHROUGH */
3294 default:
3295 break;
3296 }
3297 } 3309 }
3298} 3310}
3299/*}}} */ 3311/*}}} */
3300 3312
3301/*{{{ process sgr sequences */ 3313/*{{{ process sgr sequences */
3302void 3314void
3303rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) 3315rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
3304{ 3316{
3305 unsigned int i; 3317 unsigned int i;
3306 short rendset; 3318 short rendset;
3307 int rendstyle; 3319 int rendstyle;
3308 3320
3309 if (nargs == 0) 3321 if (nargs == 0)
3310 { 3322 {
3311 scr_rendition (0, ~RS_None); 3323 scr_rendition (0, ~RS_None);
3312 return; 3324 return;
3313 } 3325 }
3326
3314 for (i = 0; i < nargs; i++) 3327 for (i = 0; i < nargs; i++)
3315 { 3328 {
3316 rendset = -1; 3329 rendset = -1;
3317 switch (arg[i]) 3330 switch (arg[i])
3318 { 3331 {
3329 rendset = 1, rendstyle = RS_Blink; 3342 rendset = 1, rendstyle = RS_Blink;
3330 break; 3343 break;
3331 case 7: 3344 case 7:
3332 rendset = 1, rendstyle = RS_RVid; 3345 rendset = 1, rendstyle = RS_RVid;
3333 break; 3346 break;
3347 case 8:
3348 // invisible. NYI
3349 break;
3334 case 22: 3350 case 22:
3335 rendset = 0, rendstyle = RS_Bold; 3351 rendset = 0, rendstyle = RS_Bold;
3336 break; 3352 break;
3337 case 24: 3353 case 24:
3338 rendset = 0, rendstyle = RS_Uline; 3354 rendset = 0, rendstyle = RS_Uline;
3341 rendset = 0, rendstyle = RS_Blink; 3357 rendset = 0, rendstyle = RS_Blink;
3342 break; 3358 break;
3343 case 27: 3359 case 27:
3344 rendset = 0, rendstyle = RS_RVid; 3360 rendset = 0, rendstyle = RS_RVid;
3345 break; 3361 break;
3362 case 28:
3363 // visible. NYI
3364 break;
3346 } 3365 }
3366
3347 if (rendset != -1) 3367 if (rendset != -1)
3348 { 3368 {
3349 scr_rendition (rendset, rendstyle); 3369 scr_rendition (rendset, rendstyle);
3350 continue; /* for (;i;) */ 3370 continue; /* for (;i;) */
3351 } 3371 }
3358 case 33: 3378 case 33:
3359 case 34: 3379 case 34:
3360 case 35: 3380 case 35:
3361 case 36: 3381 case 36:
3362 case 37: 3382 case 37:
3363 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), 3383 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg);
3364 Color_fg);
3365 break; 3384 break;
3366#ifdef TTY_256COLOR 3385#ifdef TTY_256COLOR
3367 case 38: 3386 case 38:
3368 if (nargs > i + 2 && arg[i + 1] == 5) 3387 if (nargs > i + 2 && arg[i + 1] == 5)
3369 { 3388 {
3370 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3389 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg);
3371 Color_fg);
3372 i += 2; 3390 i += 2;
3373 } 3391 }
3374 break; 3392 break;
3375#endif 3393#endif
3376 case 39: /* default fg */ 3394 case 39: /* default fg */
3383 case 43: 3401 case 43:
3384 case 44: 3402 case 44:
3385 case 45: 3403 case 45:
3386 case 46: 3404 case 46:
3387 case 47: 3405 case 47:
3388 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), 3406 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg);
3389 Color_bg);
3390 break; 3407 break;
3391#ifdef TTY_256COLOR 3408#ifdef TTY_256COLOR
3392 case 48: 3409 case 48:
3393 if (nargs > i + 2 && arg[i + 1] == 5) 3410 if (nargs > i + 2 && arg[i + 1] == 5)
3394 { 3411 {
3395 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3412 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg);
3396 Color_bg);
3397 i += 2; 3413 i += 2;
3398 } 3414 }
3399 break; 3415 break;
3400#endif 3416#endif
3401 case 49: /* default bg */ 3417 case 49: /* default bg */
3434 3450
3435/*{{{ process Rob Nation's own graphics mode sequences */ 3451/*{{{ process Rob Nation's own graphics mode sequences */
3436void 3452void
3437rxvt_term::process_graphics () 3453rxvt_term::process_graphics ()
3438{ 3454{
3439 unsigned char ch, cmd = cmd_getc (); 3455 unicode_t ch, cmd = cmd_getc ();
3440 3456
3441 if (cmd == 'Q') 3457 if (cmd == 'Q')
3442 { /* query graphics */ 3458 { /* query graphics */
3443 tt_printf ("\033G0\n"); /* no graphics */ 3459 tt_printf ("\033G0\n"); /* no graphics */
3444 return; 3460 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines