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.56 by pcg, Tue Feb 24 00:02:44 2004 UTC vs.
Revision 1.73 by pcg, Mon Mar 15 00:08:11 2004 UTC

140 valid_keysym = keysym != NoSymbol; 140 valid_keysym = keysym != NoSymbol;
141 } 141 }
142 142
143 if (valid_keysym) 143 if (valid_keysym)
144 { 144 {
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) 145 if (TermWin.saveLines)
167 { 146 {
168#ifdef UNSHIFTED_SCROLLKEYS 147#ifdef UNSHIFTED_SCROLLKEYS
169 if (!ctrl && !meta) 148 if (!ctrl && !meta)
170 { 149 {
261#ifdef KEYSYM_RESOURCE 240#ifdef KEYSYM_RESOURCE
262 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) 241 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL)
263 { 242 {
264 unsigned int l; 243 unsigned int l;
265 const unsigned char *kbuf0; 244 const unsigned char *kbuf0;
266 const unsigned char ch = C0_ESC;
267 245
268 kbuf0 = (Keysym_map[keysym & 0xFF]); 246 kbuf0 = (Keysym_map[keysym & 0xFF]);
269 l = (unsigned int)*kbuf0++; 247 l = (unsigned int)*kbuf0++;
270 248
271 /* escape prefix */ 249 /* escape prefix */
272 if (meta) 250 if (meta
273# ifdef META8_OPTION 251# ifdef META8_OPTION
274 if (meta_char == C0_ESC) 252 && meta_char == C0_ESC
275# endif 253# endif
254 )
255 {
256 const unsigned char ch = C0_ESC;
276 tt_write (&ch, 1); 257 tt_write (&ch, 1);
258 }
259
277 tt_write (kbuf0, l); 260 tt_write (kbuf0, l);
278 return; 261 return;
279 } 262 }
280 else 263 else
281#endif 264#endif
291 ^ !!ctrl) ? '\b' : '\177'; 274 ^ !!ctrl) ? '\b' : '\177';
292 kbuf[1] = '\0'; 275 kbuf[1] = '\0';
293 } 276 }
294 else 277 else
295 STRCPY (kbuf, key_backspace); 278 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; 279 break;
309#endif 280#endif
310#ifndef NO_DELETE_KEY 281#ifndef NO_DELETE_KEY
311 case XK_Delete: 282 case XK_Delete:
312 STRCPY (kbuf, key_delete); 283 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; 284 break;
326#endif 285#endif
327 case XK_Tab: 286 case XK_Tab:
328 if (shft) 287 if (shft)
329 STRCPY (kbuf, "\033[Z"); 288 STRCPY (kbuf, "\033[Z");
371 kbuf[1] = 'O'; 330 kbuf[1] = 'O';
372 kbuf[2] = "dacb"[keysym - XK_Left]; 331 kbuf[2] = "dacb"[keysym - XK_Left];
373 } 332 }
374 else if (PrivateModes & PrivMode_aplCUR) 333 else if (PrivateModes & PrivMode_aplCUR)
375 kbuf[1] = 'O'; 334 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; 335 break;
412 336
413#ifndef UNSHIFTED_SCROLLKEYS 337#ifndef UNSHIFTED_SCROLLKEYS
414# ifdef XK_KP_Prior 338# ifdef XK_KP_Prior
415 case XK_KP_Prior: 339 case XK_KP_Prior:
604 break; 528 break;
605 } 529 }
606 if (newlen) 530 if (newlen)
607 len = STRLEN (kbuf); 531 len = STRLEN (kbuf);
608 } 532 }
533
609 /* 534 /*
610 * Pass meta for all function keys, if 'meta' option set 535 * Pass meta for all function keys, if 'meta' option set
611 */ 536 */
612#ifdef META8_OPTION 537#ifdef META8_OPTION
613 if (meta && (meta_char == 0x80) && len > 0) 538 if (meta && (meta_char == 0x80) && len > 0)
628 { 553 {
629 unsigned char *ch; 554 unsigned char *ch;
630 555
631 for (ch = kbuf; ch < kbuf + len; ch++) 556 for (ch = kbuf; ch < kbuf + len; ch++)
632 *ch |= 0x80; 557 *ch |= 0x80;
558
633 meta = 0; 559 meta = 0;
634 } 560 }
635#endif 561#endif
636 /* nil */ ; 562 /* nil */ ;
637 } 563 }
694{ 620{
695 unsigned int n, s; 621 unsigned int n, s;
696 622
697 n = cmdbuf_ptr - cmdbuf_base; 623 n = cmdbuf_ptr - cmdbuf_base;
698 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; 624 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp;
625
699 if (n > 0 && s < count) 626 if (n > 0 && s < count)
700 { 627 {
701 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 628 MEMMOVE (cmdbuf_base, cmdbuf_ptr,
702 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 629 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
703 cmdbuf_ptr = cmdbuf_base; 630 cmdbuf_ptr = cmdbuf_base;
704 cmdbuf_endp -= n; 631 cmdbuf_endp -= n;
705 s += n; 632 s += n;
706 } 633 }
634
707 if (count > s) 635 if (count > s)
708 { 636 {
709 rxvt_print_error ("data loss: cmd_write too large"); 637 rxvt_print_error ("data loss: cmd_write too large");
710 count = s; 638 count = s;
711 } 639 }
640
712 for (; count--;) 641 for (; count--;)
713 *cmdbuf_endp++ = *str++; 642 *cmdbuf_endp++ = *str++;
643
644 cmd_parse ();
645
714 return 0; 646 return 0;
715} 647}
716#endif /* MENUBAR_MAX */ 648#endif /* MENUBAR_MAX */
717 649
718void 650void
790 cmdbuf_endp += n; 722 cmdbuf_endp += n;
791 return true; 723 return true;
792 } 724 }
793 else if (n < 0 && errno != EAGAIN) 725 else if (n < 0 && errno != EAGAIN)
794 destroy (); 726 destroy ();
795 727
796 return false; 728 return false;
797} 729}
798 730
799void 731void
800rxvt_term::pty_cb (io_watcher &w, short revents) 732rxvt_term::pty_cb (io_watcher &w, short revents)
817 seen_input = 1; 749 seen_input = 1;
818 /* once we know the shell is running, send the screen size. Again! */ 750 /* once we know the shell is running, send the screen size. Again! */
819 tt_winch (); 751 tt_winch ();
820 } 752 }
821 753
822 uint32_t ch = NOCHAR; 754 if (cmd_parse ())
755 break;
756 }
757 }
758}
759
760bool
761rxvt_term::cmd_parse ()
762{
763 bool flag = false;
764 unicode_t ch = NOCHAR;
765
766 for (;;)
767 {
768 if (ch == NOCHAR)
769 ch = next_char ();
770
771 if (ch == NOCHAR) // TODO: improve
772 break;
773
774 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
775 {
776 /* Read a text string from the input buffer */
777 unicode_t buf[BUFSIZ];
778 bool refreshnow = false;
779 int nlines = 0;
780 unicode_t *str = buf;
781
782 *str++ = ch;
823 783
824 for (;;) 784 for (;;)
825 { 785 {
826 if (ch == NOCHAR)
827 ch = next_char (); 786 ch = next_char ();
828 787
829 if (ch == NOCHAR) // TODO: improve 788 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
830 break; 789 break;
831 790 else
832 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
833 { 791 {
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; 792 *str++ = ch;
841 793
842 for (;;) 794 if (ch == '\n')
843 { 795 {
844 ch = next_char ();
845
846 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
847 break;
848 else 796 nlines++;
797 refresh_count++;
798
799 if (! (Options & Opt_jumpScroll)
800 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
849 { 801 {
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; 802 refreshnow = true;
861 flag = false; 803 flag = false;
862 ch = NOCHAR; 804 ch = NOCHAR;
863 break; 805 break;
864 } 806 }
865 807
866 // scr_add_lines only works for nlines < TermWin.nrow - 1. 808 // scr_add_lines only works for nlines < TermWin.nrow - 1.
867 if (nlines >= TermWin.nrow - 1) 809 if (nlines >= TermWin.nrow - 1)
868 { 810 {
869 scr_add_lines (buf, nlines, str - buf); 811 scr_add_lines (buf, nlines, str - buf);
870 nlines = 0; 812 nlines = 0;
871 str = buf; 813 str = buf;
872 }
873 }
874
875 if (str >= buf + BUFSIZ)
876 {
877 ch = NOCHAR;
878 break;
879 }
880 } 814 }
881 } 815 }
882 816
883 scr_add_lines (buf, nlines, str - buf); 817 if (str >= buf + BUFSIZ)
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 { 818 {
896 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 819 ch = NOCHAR;
897 refresh_limit++; 820 break;
898
899 scr_refresh (refresh_type);
900 } 821 }
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 } 822 }
919 } 823 }
824
825 scr_add_lines (buf, nlines, str - buf);
826
827 /*
828 * If there have been a lot of new lines, then update the screen
829 * What the heck I'll cheat and only refresh less than every page-full.
830 * the number of pages between refreshes is refresh_limit, which
831 * is incremented here because we must be doing flat-out scrolling.
832 *
833 * refreshing should be correct for small scrolls, because of the
834 * time-out
835 */
836 if (refreshnow)
837 {
838 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
839 refresh_limit++;
840
841 scr_refresh (refresh_type);
842 }
843
844 }
845 else
920 } 846 {
847 switch (ch)
848 {
849 default:
850 process_nonprinting (ch);
851 break;
852 case C0_ESC: /* escape char */
853 process_escape_seq ();
854 break;
855 /*case 0x9b: */ /* CSI */
856 /* process_csi_seq (); */
857 }
858
859 ch = NOCHAR;
860 }
921 } 861 }
862
863 return flag;
922} 864}
923 865
924// read the next character, currently handles UTF-8 866// read the next character, currently handles UTF-8
925// will probably handle all sorts of other stuff in the future 867// will probably handle all sorts of other stuff in the future
926uint32_t 868unicode_t
927rxvt_term::next_char () 869rxvt_term::next_char ()
928{ 870{
929 while (cmdbuf_ptr < cmdbuf_endp) 871 while (cmdbuf_ptr < cmdbuf_endp)
930 { 872 {
931 if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh 873 // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh
874 if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr)
875 || !*cmdbuf_ptr)
932 return *cmdbuf_ptr++; 876 return *cmdbuf_ptr++;
933 877
934 wchar_t wc; 878 wchar_t wc;
935 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 879 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
936 880
937 if (len == (size_t)-2) 881 if (len == (size_t)-2)
938 return NOCHAR; 882 {
883 // the mbstate stores incomplete sequences. didn't know this :/
884 cmdbuf_ptr = cmdbuf_endp;
885 break;
886 }
939 887
940 if (len == (size_t)-1) 888 if (len == (size_t)-1)
941 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 889 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
942 890
943 // assume wchar == unicode 891 // assume wchar == unicode
951/* rxvt_cmd_getc () - Return next input character */ 899/* rxvt_cmd_getc () - Return next input character */
952/* 900/*
953 * Return the next input character after first passing any keyboard input 901 * Return the next input character after first passing any keyboard input
954 * to the command. 902 * to the command.
955 */ 903 */
956uint32_t 904unicode_t
957rxvt_term::cmd_getc () 905rxvt_term::cmd_getc ()
958{ 906{
959 for (;;) 907 for (;;)
960 { 908 {
961 uint32_t c = next_char (); 909 unicode_t c = next_char ();
962 if (c != NOCHAR) 910 if (c != NOCHAR)
963 return c; 911 return c;
964 912
965 // incomplete sequences should occur rarely, still, a better solution 913 // incomplete sequences should occur rarely, still, a better solution
966 // would be preferred. either setjmp/longjmp or better design. 914 // would be preferred. either setjmp/longjmp or better design.
1971 if (have_pixmap) 1919 if (have_pixmap)
1972 { 1920 {
1973 /* 1921 /*
1974 * Copy display->root pixmap transparency 1922 * Copy display->root pixmap transparency
1975 */ 1923 */
1976 int sx, sy, nx, ny; 1924 int sx, sy, nx, ny;
1977 unsigned int nw, nh; 1925 unsigned int nw, nh;
1978 Window cr; 1926 Window cr;
1979 XImage *image; 1927 XImage *image;
1980 GC gc; 1928 GC gc;
1981 XGCValues gcvalue; 1929 XGCValues gcvalue;
1982 1930
1983 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1931 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
1984 0, 0, &sx, &sy, &cr); 1932 0, 0, &sx, &sy, &cr);
1985 nw = (unsigned int)szHint.width; 1933 nw = (unsigned int)szHint.width;
1986 nh = (unsigned int)szHint.height; 1934 nh = (unsigned int)szHint.height;
1987 nx = ny = 0; 1935 nx = ny = 0;
1936
1988 if (sx < 0) 1937 if (sx < 0)
1989 { 1938 {
1990 nw += sx; 1939 nw += sx;
1991 nx = -sx; 1940 nx = -sx;
1992 sx = 0; 1941 sx = 0;
1993 } 1942 }
1943
1994 if (sy < 0) 1944 if (sy < 0)
1995 { 1945 {
1996 nh += sy; 1946 nh += sy;
1997 ny = -sy; 1947 ny = -sy;
1998 sy = 0; 1948 sy = 0;
1999 } 1949 }
1950
2000 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 1951 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2001 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 1952 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2002 allowedxerror = -1; 1953 allowedxerror = -1;
2003 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 1954 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes,
2004 ZPixmap); 1955 ZPixmap);
2037 if (!am_transparent || !am_pixmap_trans) 1988 if (!am_transparent || !am_pixmap_trans)
2038 pchanged = 1; 1989 pchanged = 1;
2039 am_transparent = am_pixmap_trans = 1; 1990 am_transparent = am_pixmap_trans = 1;
2040 } 1991 }
2041 } 1992 }
1993
2042 if (!am_pixmap_trans) 1994 if (!am_pixmap_trans)
2043 { 1995 {
2044 unsigned int n; 1996 unsigned int n;
2045 /* 1997 /*
2046 * InheritPixmap transparency 1998 * InheritPixmap transparency
2061 break; 2013 break;
2062 } 2014 }
2063 if (oldp != TermWin.parent[i]) 2015 if (oldp != TermWin.parent[i])
2064 pchanged = 1; 2016 pchanged = 1;
2065 } 2017 }
2018
2066 n = 0; 2019 n = 0;
2020
2067 if (pchanged) 2021 if (pchanged)
2068 { 2022 {
2069 for (; n < (unsigned int)i; n++) 2023 for (; n < (unsigned int)i; n++)
2070 { 2024 {
2071 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 2025 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
2075 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 2029 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2076 break; 2030 break;
2077 } 2031 }
2078 } 2032 }
2079 } 2033 }
2034
2080 if (n > (int) (sizeof (TermWin.parent) 2035 if (n > (int) (sizeof (TermWin.parent)
2081 / sizeof (TermWin.parent[0]))) 2036 / sizeof (TermWin.parent[0])))
2082 { 2037 {
2083 D_X ((stderr, "InheritPixmap Turning off")); 2038 D_X ((stderr, "InheritPixmap Turning off"));
2084 XSetWindowBackground (display->display, TermWin.parent[0], 2039 XSetWindowBackground (display->display, TermWin.parent[0],
2107 ParentRelative); 2062 ParentRelative);
2108 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2063 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
2109 ParentRelative); 2064 ParentRelative);
2110 am_transparent = 1; 2065 am_transparent = 1;
2111 } 2066 }
2067
2112 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2068 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2113 TermWin.parent[i] = None; 2069 TermWin.parent[i] = None;
2114 } 2070 }
2115 return pchanged; 2071 return pchanged;
2116} 2072}
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_print_error ("can't open printer pipe");
2131 return stream; 2087 return stream;
2132} 2088}
2344 scr_charset_set (2, (unsigned int)cmd_getc ()); 2300 scr_charset_set (2, (unsigned int)cmd_getc ());
2345 break; 2301 break;
2346 case '+': 2302 case '+':
2347 scr_charset_set (3, (unsigned int)cmd_getc ()); 2303 scr_charset_set (3, (unsigned int)cmd_getc ());
2348 break; 2304 break;
2349#ifdef MULTICHAR_SET
2350 case '$':
2351 scr_charset_set (-2, (unsigned int)cmd_getc ());
2352 break;
2353#endif
2354#ifndef NO_FRILLS 2305#ifndef NO_FRILLS
2355 case '6': 2306 case '6':
2356 scr_backindex (); 2307 scr_backindex ();
2357 break; 2308 break;
2358#endif 2309#endif
2380 break; 2331 break;
2381 2332
2382 /* 8.3.87: NEXT LINE */ 2333 /* 8.3.87: NEXT LINE */
2383 case C1_NEL: /* ESC E */ 2334 case C1_NEL: /* ESC E */
2384 { 2335 {
2385 uint32_t nlcr[] = { '\n', '\r' }; 2336 unicode_t nlcr[] = { L'\n', L'\r' };
2386 scr_add_lines (nlcr, 1, 2); 2337 scr_add_lines (nlcr, 1, 2);
2387 } 2338 }
2388 break; 2339 break;
2389 2340
2390 /* kidnapped escape sequence: Should be 8.3.48 */ 2341 /* kidnapped escape sequence: Should be 8.3.48 */
2699 case 7: /* unofficial extension */ 2650 case 7: /* unofficial extension */
2700 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2651 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2701 break; 2652 break;
2702#endif 2653#endif
2703 case 8: /* unofficial extension */ 2654 case 8: /* unofficial extension */
2704 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); 2655 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2705 break; 2656 break;
2706 } 2657 }
2707 break; 2658 break;
2708 2659
2709 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2660 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
2978 * 19 = change underlined character color 2929 * 19 = change underlined character color
2979 * 46 = change logfile (not implemented) 2930 * 46 = change logfile (not implemented)
2980 * 50 = change font 2931 * 50 = change font
2981 * 2932 *
2982 * rxvt extensions: 2933 * rxvt extensions:
2983 * 9 = change locale (NYI)
2984 * 10 = menu (may change in future) 2934 * 10 = menu (may change in future)
2985 * 20 = bg pixmap 2935 * 20 = bg pixmap
2986 * 39 = change default fg color 2936 * 39 = change default fg color
2987 * 49 = change default bg color 2937 * 49 = change default bg color
2988 * 55 = dump scrollback buffer and all of screen 2938 * 55 = dump scrollback buffer and all of screen
2939 * 701 = change locale
2940 * 702 = find font
2989 */ 2941 */
2990void 2942void
2991rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) 2943rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused)))
2992{ 2944{
2993 int changed = 0; 2945 int changed = 0;
3081 case XTerm_logfile: 3033 case XTerm_logfile:
3082 break; 3034 break;
3083 case XTerm_font: 3035 case XTerm_font:
3084 change_font (str); 3036 change_font (str);
3085 break; 3037 break;
3038#ifndef NO_FRILLS
3086 case XTerm_locale: 3039 case XTerm_locale:
3087 if (str[0] == '?' && !str[1]) 3040 if (str[0] == '?' && !str[1])
3088 tt_printf ("%-.250s\n", locale); 3041 tt_printf ("%-.250s\n", locale);
3089 else 3042 else
3090 { 3043 {
3091 set_locale (str); 3044 set_locale (str);
3045# ifdef USE_XIM
3092 im_cb (); 3046 im_cb ();
3047# endif
3093 } 3048 }
3094 break; 3049 break;
3050 case XTerm_findfont:
3051 {
3052 int fid = TermWin.fontset->find_font (atoi (str));
3053 tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name);
3054 }
3055 break;
3056#endif
3095#if 0 3057#if 0
3096 case XTerm_dumpscreen: /* no error notices */ 3058 case XTerm_dumpscreen: /* no error notices */
3097 { 3059 {
3098 int fd; 3060 int fd;
3099 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3061 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3164 { menuBar_esc, PrivMode_menuBar }, 3126 { menuBar_esc, PrivMode_menuBar },
3165#endif 3127#endif
3166#ifdef scrollBar_esc 3128#ifdef scrollBar_esc
3167 { scrollBar_esc, PrivMode_scrollBar }, 3129 { scrollBar_esc, PrivMode_scrollBar },
3168#endif 3130#endif
3131 // 18, 19 printing-related
3169 { 25, PrivMode_VisibleCursor }, 3132 { 25, PrivMode_VisibleCursor },
3133 // 30 show scrollbar rxvt. extension
3170 { 35, PrivMode_ShiftKeys }, 3134 { 35, PrivMode_ShiftKeys }, // rxvt extension
3171 { 40, PrivMode_132OK }, 3135 { 40, PrivMode_132OK },
3136 // 41 xterm more fixes NYI
3137 // 45 margin bell NYI
3138 // 46 start logging
3172 { 47, PrivMode_Screen }, 3139 { 47, PrivMode_Screen },
3173 { 66, PrivMode_aplKP }, 3140 { 66, PrivMode_aplKP },
3174#ifndef NO_BACKSPACE_KEY 3141#ifndef NO_BACKSPACE_KEY
3175 { 67, PrivMode_BackSpace }, 3142 { 67, PrivMode_BackSpace },
3176#endif 3143#endif
3177 { 1000, PrivMode_MouseX11 }, 3144 { 1000, PrivMode_MouseX11 },
3145 // 1001 Use Hilite Mouse Tracking. NYI, TODO
3146 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO
3147 // 1003 Use All Motion Mouse Tracking. NYI, TODO
3178 { 1010, PrivMode_TtyOutputInh }, 3148 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3179 { 1011, PrivMode_Keypress }, 3149 { 1011, PrivMode_Keypress }, // rxvt extension
3150 // 1035 enable modifiers for alt, numlock NYI
3151 // 1036 send ESC for meta keys NYI
3152 // 1037 send DEL for keypad delete NYI
3180 { 1047, PrivMode_Screen }, 3153 { 1047, PrivMode_Screen },
3154 // 1048 save and restore cursor
3181 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ 3155 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */
3156 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3182 }; 3157 };
3183 3158
3184 if (nargs == 0) 3159 if (nargs == 0)
3185 return; 3160 return;
3186 3161
3201 state = privcases (mode, argtopriv[j].bit); 3176 state = privcases (mode, argtopriv[j].bit);
3202 break; 3177 break;
3203 } 3178 }
3204 3179
3205 /* extra handling for values with state unkept */ 3180 /* extra handling for values with state unkept */
3181 switch (arg[i])
3182 {
3183 case 1048: /* alternative cursor save */
3184 case 1049:
3185 if (mode == 0)
3186 scr_cursor (RESTORE);
3187 else if (mode == 1)
3188 scr_cursor (SAVE);
3189 /* FALLTHROUGH */
3190 }
3191
3206 if (state == -1) 3192 if (state >= 0)
3193 /* extra handling for values with valid 0 or 1 state */
3207 switch (arg[i]) 3194 switch (arg[i])
3208 { 3195 {
3209 case 1048: /* alternative cursor save */ 3196 /* case 1: - application cursor keys */
3197 case 2: /* VT52 mode */
3198 /* oddball mode. should be set regardless of set/reset
3199 * parameter. Return from VT52 mode with an ESC < from
3200 * within VT52 mode
3201 */
3202 PrivMode (1, PrivMode_vt52);
3203 break;
3204 case 3: /* 80/132 */
3205 if (PrivateModes & PrivMode_132OK)
3206 set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height);
3207 break;
3208 case 4: /* smooth scrolling */
3210 if (mode == 0) 3209 if (state)
3211 scr_cursor (RESTORE); 3210 Options &= ~Opt_jumpScroll;
3212 else if (mode == 1) 3211 else
3213 scr_cursor (SAVE); 3212 Options |= Opt_jumpScroll;
3213 break;
3214 case 5: /* reverse video */
3215 scr_rvideo_mode (state);
3216 break;
3217 case 6: /* relative/absolute origins */
3218 scr_relative_origin (state);
3219 break;
3220 case 7: /* autowrap */
3221 scr_autowrap (state);
3222 break;
3223 /* case 8: - auto repeat, can't do on a per window basis */
3224 case 9: /* X10 mouse reporting */
3225 if (state) /* orthogonal */
3226 PrivateModes &= ~ (PrivMode_MouseX11);
3227 break;
3228#ifdef menuBar_esc
3229 case menuBar_esc:
3230#ifdef MENUBAR
3231 map_menuBar (state);
3232#endif
3233 break;
3234#endif
3235#ifdef scrollBar_esc
3236 case scrollBar_esc:
3237 if (scrollbar_mapping (state))
3238 {
3239 resize_all_windows (0, 0, 0);
3240 scr_touch (true);
3241 }
3242 break;
3243#endif
3244 case 25: /* visible/invisible cursor */
3245 scr_cursor_visible (state);
3246 break;
3247 /* case 35: - shift keys */
3248 /* case 40: - 80 <--> 132 mode */
3249 case 47: /* secondary screen */
3250 scr_change_screen (state);
3251 break;
3252 /* case 66: - application key pad */
3253 /* case 67: - backspace key */
3254 case 1000: /* X11 mouse reporting */
3255 if (state) /* orthogonal */
3256 PrivateModes &= ~ (PrivMode_MouseX10);
3257 break;
3258#if 0
3259 case 1001:
3260 break; /* X11 mouse highlighting */
3261#endif
3262 case 1010: /* scroll to bottom on TTY output inhibit */
3263 if (state)
3264 Options &= ~Opt_scrollTtyOutput;
3265 else
3266 Options |= Opt_scrollTtyOutput;
3267 break;
3268 case 1011: /* scroll to bottom on key press */
3269 if (state)
3270 Options |= Opt_scrollTtyKeypress;
3271 else
3272 Options &= ~Opt_scrollTtyKeypress;
3273 break;
3274 case 1047: /* secondary screen w/ clearing */
3275 case 1049: /* better secondary screen w/ clearing, but not fully implemented */
3276 if (current_screen != PRIMARY)
3277 scr_erase_screen (2);
3278 scr_change_screen (state);
3214 /* FALLTHROUGH */ 3279 /* FALLTHROUGH */
3215 default: 3280 default:
3216 continue; /* for (;i;) */ 3281 break;
3217 } 3282 }
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 } 3283 }
3311} 3284}
3312/*}}} */ 3285/*}}} */
3313 3286
3314/*{{{ process sgr sequences */ 3287/*{{{ process sgr sequences */
3342 rendset = 1, rendstyle = RS_Blink; 3315 rendset = 1, rendstyle = RS_Blink;
3343 break; 3316 break;
3344 case 7: 3317 case 7:
3345 rendset = 1, rendstyle = RS_RVid; 3318 rendset = 1, rendstyle = RS_RVid;
3346 break; 3319 break;
3320 case 8:
3321 // invisible. NYI
3322 break;
3347 case 22: 3323 case 22:
3348 rendset = 0, rendstyle = RS_Bold; 3324 rendset = 0, rendstyle = RS_Bold;
3349 break; 3325 break;
3350 case 24: 3326 case 24:
3351 rendset = 0, rendstyle = RS_Uline; 3327 rendset = 0, rendstyle = RS_Uline;
3354 rendset = 0, rendstyle = RS_Blink; 3330 rendset = 0, rendstyle = RS_Blink;
3355 break; 3331 break;
3356 case 27: 3332 case 27:
3357 rendset = 0, rendstyle = RS_RVid; 3333 rendset = 0, rendstyle = RS_RVid;
3358 break; 3334 break;
3335 case 28:
3336 // visible. NYI
3337 break;
3359 } 3338 }
3339
3360 if (rendset != -1) 3340 if (rendset != -1)
3361 { 3341 {
3362 scr_rendition (rendset, rendstyle); 3342 scr_rendition (rendset, rendstyle);
3363 continue; /* for (;i;) */ 3343 continue; /* for (;i;) */
3364 } 3344 }
3371 case 33: 3351 case 33:
3372 case 34: 3352 case 34:
3373 case 35: 3353 case 35:
3374 case 36: 3354 case 36:
3375 case 37: 3355 case 37:
3376 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), 3356 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg);
3377 Color_fg);
3378 break; 3357 break;
3379#ifdef TTY_256COLOR 3358#ifdef TTY_256COLOR
3380 case 38: 3359 case 38:
3381 if (nargs > i + 2 && arg[i + 1] == 5) 3360 if (nargs > i + 2 && arg[i + 1] == 5)
3382 { 3361 {
3383 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3362 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg);
3384 Color_fg);
3385 i += 2; 3363 i += 2;
3386 } 3364 }
3387 break; 3365 break;
3388#endif 3366#endif
3389 case 39: /* default fg */ 3367 case 39: /* default fg */
3396 case 43: 3374 case 43:
3397 case 44: 3375 case 44:
3398 case 45: 3376 case 45:
3399 case 46: 3377 case 46:
3400 case 47: 3378 case 47:
3401 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), 3379 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg);
3402 Color_bg);
3403 break; 3380 break;
3404#ifdef TTY_256COLOR 3381#ifdef TTY_256COLOR
3405 case 48: 3382 case 48:
3406 if (nargs > i + 2 && arg[i + 1] == 5) 3383 if (nargs > i + 2 && arg[i + 1] == 5)
3407 { 3384 {
3408 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3385 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg);
3409 Color_bg);
3410 i += 2; 3386 i += 2;
3411 } 3387 }
3412 break; 3388 break;
3413#endif 3389#endif
3414 case 49: /* default bg */ 3390 case 49: /* default bg */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines