… | |
… | |
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 |
|
|
60 | class out_of_input { } out_of_input; |
|
|
61 | |
57 | /*{{{ Convert the keypress event into a string */ |
62 | /*{{{ Convert the keypress event into a string */ |
58 | void |
63 | void |
59 | rxvt_term::lookup_key (XKeyEvent &ev) |
64 | rxvt_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 |
… | |
… | |
545 | break; |
535 | break; |
546 | } |
536 | } |
547 | if (newlen) |
537 | if (newlen) |
548 | len = STRLEN (kbuf); |
538 | len = STRLEN (kbuf); |
549 | } |
539 | } |
|
|
540 | |
550 | /* |
541 | /* |
551 | * Pass meta for all function keys, if 'meta' option set |
542 | * Pass meta for all function keys, if 'meta' option set |
552 | */ |
543 | */ |
553 | #ifdef META8_OPTION |
544 | #ifdef META8_OPTION |
554 | if (meta && (meta_char == 0x80) && len > 0) |
545 | if (meta && (meta_char == 0x80) && len > 0) |
… | |
… | |
569 | { |
560 | { |
570 | unsigned char *ch; |
561 | unsigned char *ch; |
571 | |
562 | |
572 | for (ch = kbuf; ch < kbuf + len; ch++) |
563 | for (ch = kbuf; ch < kbuf + len; ch++) |
573 | *ch |= 0x80; |
564 | *ch |= 0x80; |
|
|
565 | |
574 | meta = 0; |
566 | meta = 0; |
575 | } |
567 | } |
576 | #endif |
568 | #endif |
577 | /* nil */ ; |
569 | /* nil */ ; |
578 | } |
570 | } |
… | |
… | |
631 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
623 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
632 | /* attempt to `write' count to the input buffer */ |
624 | /* attempt to `write' count to the input buffer */ |
633 | unsigned int |
625 | unsigned int |
634 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
626 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
635 | { |
627 | { |
636 | unsigned int n, s; |
628 | unsigned int n, s; |
637 | |
629 | |
638 | n = cmdbuf_ptr - cmdbuf_base; |
630 | n = cmdbuf_ptr - cmdbuf_base; |
639 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
631 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
640 | |
632 | |
641 | if (n > 0 && s < count) |
633 | if (n > 0 && s < count) |
642 | { |
634 | { |
643 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
635 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
644 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
636 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
… | |
… | |
647 | s += n; |
639 | s += n; |
648 | } |
640 | } |
649 | |
641 | |
650 | if (count > s) |
642 | if (count > s) |
651 | { |
643 | { |
652 | rxvt_print_error ("data loss: cmd_write too large"); |
644 | rxvt_warn ("data loss: cmd_write too large, continuing.\n"); |
653 | count = s; |
645 | count = s; |
654 | } |
646 | } |
655 | |
647 | |
656 | for (; count--;) |
648 | for (; count--;) |
657 | *cmdbuf_endp++ = *str++; |
649 | *cmdbuf_endp++ = *str++; |
… | |
… | |
728 | |
720 | |
729 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
721 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
730 | cmdbuf_ptr = cmdbuf_base; |
722 | cmdbuf_ptr = cmdbuf_base; |
731 | cmdbuf_endp = cmdbuf_ptr + n; |
723 | cmdbuf_endp = cmdbuf_ptr + n; |
732 | |
724 | |
733 | n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n); |
725 | n = read (cmd_fd, cmdbuf_endp, CBUFSIZ - n); |
734 | |
726 | |
735 | if (n > 0) |
727 | if (n > 0) |
736 | { |
728 | { |
737 | cmdbuf_endp += n; |
729 | cmdbuf_endp += n; |
738 | return true; |
730 | return true; |
… | |
… | |
751 | |
743 | |
752 | if (revents & EVENT_WRITE) |
744 | if (revents & EVENT_WRITE) |
753 | tt_write (0, 0); |
745 | tt_write (0, 0); |
754 | else if (revents & EVENT_READ) |
746 | else if (revents & EVENT_READ) |
755 | { |
747 | { |
756 | bool flag = true; |
|
|
757 | |
|
|
758 | // loop, but don't allow a single term to monopolize us |
748 | // loop, but don't allow a single term to monopolize us |
759 | // the number of loops is fully arbitrary, and thus wrong |
749 | // the number of loops is fully arbitrary, and thus wrong |
760 | while (flag && pty_fill ()) |
750 | while (pty_fill ()) |
761 | { |
751 | { |
762 | if (!seen_input) |
752 | if (!seen_input) |
763 | { |
753 | { |
764 | seen_input = 1; |
754 | seen_input = 1; |
765 | /* 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. |
766 | tt_winch (); |
757 | tt_winch (); |
767 | } |
758 | } |
768 | |
759 | |
769 | if (cmd_parse ()) |
760 | if (cmd_parse ()) |
770 | break; |
761 | break; |
771 | } |
762 | } |
772 | } |
|
|
773 | } |
|
|
774 | |
|
|
775 | bool |
|
|
776 | rxvt_term::cmd_parse () |
|
|
777 | { |
|
|
778 | bool flag = false; |
|
|
779 | uint32_t ch = NOCHAR; |
|
|
780 | |
|
|
781 | for (;;) |
|
|
782 | { |
|
|
783 | if (ch == NOCHAR) |
|
|
784 | ch = next_char (); |
|
|
785 | |
|
|
786 | if (ch == NOCHAR) // TODO: improve |
|
|
787 | break; |
|
|
788 | |
|
|
789 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
790 | { |
|
|
791 | /* Read a text string from the input buffer */ |
|
|
792 | uint32_t buf[BUFSIZ]; |
|
|
793 | bool refreshnow = false; |
|
|
794 | int nlines = 0; |
|
|
795 | uint32_t *str = buf; |
|
|
796 | |
|
|
797 | *str++ = ch; |
|
|
798 | |
|
|
799 | for (;;) |
|
|
800 | { |
|
|
801 | ch = next_char (); |
|
|
802 | |
|
|
803 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
804 | break; |
|
|
805 | else |
|
|
806 | { |
|
|
807 | *str++ = ch; |
|
|
808 | |
|
|
809 | if (ch == '\n') |
|
|
810 | { |
|
|
811 | nlines++; |
|
|
812 | refresh_count++; |
|
|
813 | |
|
|
814 | if (! (Options & Opt_jumpScroll) |
|
|
815 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
|
|
816 | { |
|
|
817 | refreshnow = true; |
|
|
818 | flag = false; |
|
|
819 | ch = NOCHAR; |
|
|
820 | break; |
|
|
821 | } |
|
|
822 | |
|
|
823 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
|
|
824 | if (nlines >= TermWin.nrow - 1) |
|
|
825 | { |
|
|
826 | scr_add_lines (buf, nlines, str - buf); |
|
|
827 | nlines = 0; |
|
|
828 | str = buf; |
|
|
829 | } |
|
|
830 | } |
|
|
831 | |
|
|
832 | if (str >= buf + BUFSIZ) |
|
|
833 | { |
|
|
834 | ch = NOCHAR; |
|
|
835 | break; |
|
|
836 | } |
|
|
837 | } |
|
|
838 | } |
|
|
839 | |
|
|
840 | scr_add_lines (buf, nlines, str - buf); |
|
|
841 | |
|
|
842 | /* |
|
|
843 | * If there have been a lot of new lines, then update the screen |
|
|
844 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
845 | * the number of pages between refreshes is refresh_limit, which |
|
|
846 | * is incremented here because we must be doing flat-out scrolling. |
|
|
847 | * |
|
|
848 | * refreshing should be correct for small scrolls, because of the |
|
|
849 | * time-out |
|
|
850 | */ |
|
|
851 | if (refreshnow) |
|
|
852 | { |
|
|
853 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
854 | refresh_limit++; |
|
|
855 | |
|
|
856 | scr_refresh (refresh_type); |
|
|
857 | } |
|
|
858 | |
|
|
859 | } |
|
|
860 | else |
|
|
861 | { |
|
|
862 | switch (ch) |
|
|
863 | { |
|
|
864 | default: |
|
|
865 | process_nonprinting (ch); |
|
|
866 | break; |
|
|
867 | case C0_ESC: /* escape char */ |
|
|
868 | process_escape_seq (); |
|
|
869 | break; |
|
|
870 | /*case 0x9b: */ /* CSI */ |
|
|
871 | /* process_csi_seq (); */ |
|
|
872 | } |
|
|
873 | |
|
|
874 | ch = NOCHAR; |
|
|
875 | } |
|
|
876 | } |
|
|
877 | |
|
|
878 | return flag; |
|
|
879 | } |
|
|
880 | |
|
|
881 | // read the next character, currently handles UTF-8 |
|
|
882 | // will probably handle all sorts of other stuff in the future |
|
|
883 | uint32_t |
|
|
884 | rxvt_term::next_char () |
|
|
885 | { |
|
|
886 | while (cmdbuf_ptr < cmdbuf_endp) |
|
|
887 | { |
|
|
888 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
|
|
889 | if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr) |
|
|
890 | || !*cmdbuf_ptr) |
|
|
891 | return *cmdbuf_ptr++; |
|
|
892 | |
|
|
893 | wchar_t wc; |
|
|
894 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
|
|
895 | |
|
|
896 | if (len == (size_t)-2) |
|
|
897 | { |
|
|
898 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
899 | cmdbuf_ptr = cmdbuf_endp; |
|
|
900 | break; |
|
|
901 | } |
|
|
902 | |
|
|
903 | if (len == (size_t)-1) |
|
|
904 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
905 | |
|
|
906 | // assume wchar == unicode |
|
|
907 | cmdbuf_ptr += len; |
|
|
908 | return wc; |
|
|
909 | } |
|
|
910 | |
|
|
911 | return NOCHAR; |
|
|
912 | } |
|
|
913 | |
|
|
914 | /* rxvt_cmd_getc () - Return next input character */ |
|
|
915 | /* |
|
|
916 | * Return the next input character after first passing any keyboard input |
|
|
917 | * to the command. |
|
|
918 | */ |
|
|
919 | uint32_t |
|
|
920 | rxvt_term::cmd_getc () |
|
|
921 | { |
|
|
922 | for (;;) |
|
|
923 | { |
|
|
924 | uint32_t c = next_char (); |
|
|
925 | if (c != NOCHAR) |
|
|
926 | return c; |
|
|
927 | |
|
|
928 | // incomplete sequences should occur rarely, still, a better solution |
|
|
929 | // would be preferred. either setjmp/longjmp or better design. |
|
|
930 | fcntl (cmd_fd, F_SETFL, 0); |
|
|
931 | pty_fill (); |
|
|
932 | fcntl (cmd_fd, F_SETFL, O_NONBLOCK); |
|
|
933 | } |
763 | } |
934 | } |
764 | } |
935 | |
765 | |
936 | #ifdef POINTER_BLANK |
766 | #ifdef POINTER_BLANK |
937 | void |
767 | void |
… | |
… | |
1306 | |
1136 | |
1307 | } |
1137 | } |
1308 | break; |
1138 | break; |
1309 | |
1139 | |
1310 | case SelectionClear: |
1140 | case SelectionClear: |
1311 | display->set_selection_owner (0); |
1141 | selection_clear (); |
1312 | break; |
1142 | break; |
1313 | |
1143 | |
1314 | case SelectionNotify: |
1144 | case SelectionNotify: |
1315 | if (selection_wait == Sel_normal) |
1145 | if (selection_wait == Sel_normal) |
1316 | selection_paste (ev.xselection.requestor, |
1146 | selection_paste (ev.xselection.requestor, |
… | |
… | |
2087 | } |
1917 | } |
2088 | #endif |
1918 | #endif |
2089 | |
1919 | |
2090 | /*}}} */ |
1920 | /*}}} */ |
2091 | |
1921 | |
|
|
1922 | bool |
|
|
1923 | rxvt_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 |
|
|
2031 | unicode_t |
|
|
2032 | rxvt_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 | */ |
|
|
2066 | unicode_t |
|
|
2067 | rxvt_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 | } |
|
|
2076 | |
2092 | /*{{{ print pipe */ |
2077 | /*{{{ print pipe */ |
2093 | /*----------------------------------------------------------------------*/ |
2078 | /*----------------------------------------------------------------------*/ |
2094 | #ifdef PRINTPIPE |
2079 | #ifdef PRINTPIPE |
2095 | FILE * |
2080 | FILE * |
2096 | rxvt_term::popen_printer () |
2081 | rxvt_term::popen_printer () |
2097 | { |
2082 | { |
2098 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2083 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2099 | |
2084 | |
2100 | if (stream == NULL) |
2085 | if (stream == NULL) |
2101 | rxvt_print_error ("can't open printer pipe"); |
2086 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
|
|
2087 | |
2102 | return stream; |
2088 | return stream; |
2103 | } |
2089 | } |
2104 | |
2090 | |
2105 | int |
2091 | int |
2106 | rxvt_term::pclose_printer (FILE *stream) |
2092 | rxvt_term::pclose_printer (FILE *stream) |
2107 | { |
2093 | { |
2108 | fflush (stream); |
2094 | fflush (stream); |
2109 | /* pclose () reported not to work on SunOS 4.1.3 */ |
|
|
2110 | # if defined (__sun__) /* TODO: RESOLVE THIS */ |
|
|
2111 | /* pclose works provided SIGCHLD handler uses waitpid */ |
|
|
2112 | return pclose (stream); /* return fclose (stream); */ |
|
|
2113 | # else |
|
|
2114 | return pclose (stream); |
2095 | return pclose (stream); |
2115 | # endif |
|
|
2116 | } |
2096 | } |
2117 | |
2097 | |
2118 | /* |
2098 | /* |
2119 | * simulate attached vt100 printer |
2099 | * simulate attached vt100 printer |
2120 | */ |
2100 | */ |
2121 | void |
2101 | void |
2122 | rxvt_term::process_print_pipe () |
2102 | rxvt_term::process_print_pipe () |
2123 | { |
2103 | { |
2124 | int done; |
2104 | int done; |
2125 | FILE *fd; |
2105 | FILE *fd; |
2126 | |
2106 | |
2127 | if ((fd = popen_printer ()) == NULL) |
2107 | if ((fd = popen_printer ()) == NULL) |
2128 | return; |
2108 | return; |
2129 | |
2109 | |
2130 | /* |
2110 | /* |
2131 | * 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 |
2132 | * is received. |
2112 | * is received. |
2133 | */ |
2113 | */ |
2134 | for (done = 0; !done;) |
2114 | for (done = 0; !done;) |
2135 | { |
2115 | { |
2136 | unsigned char buf[8]; |
2116 | unsigned char buf[8]; |
2137 | unsigned char ch; |
2117 | unicode_t ch; |
2138 | unsigned int i, len; |
2118 | unsigned int i, len; |
2139 | |
2119 | |
2140 | if ((ch = cmd_getc ()) != C0_ESC) |
2120 | if ((ch = cmd_getc ()) != C0_ESC) |
2141 | { |
2121 | { |
2142 | if (putc (ch, fd) == EOF) |
2122 | if (putc (ch, fd) == EOF) |
2143 | break; /* done = 1 */ |
2123 | break; /* done = 1 */ |
… | |
… | |
2158 | { |
2138 | { |
2159 | if ((buf[len++] = cmd_getc ()) == 'i') |
2139 | if ((buf[len++] = cmd_getc ()) == 'i') |
2160 | break; /* done = 1 */ |
2140 | break; /* done = 1 */ |
2161 | } |
2141 | } |
2162 | } |
2142 | } |
|
|
2143 | |
2163 | for (i = 0; i < len; i++) |
2144 | for (i = 0; i < len; i++) |
2164 | if (putc (buf[i], fd) == EOF) |
2145 | if (putc (buf[i], fd) == EOF) |
2165 | { |
2146 | { |
2166 | done = 1; |
2147 | done = 1; |
2167 | break; |
2148 | break; |
2168 | } |
2149 | } |
2169 | } |
2150 | } |
2170 | } |
2151 | } |
|
|
2152 | |
2171 | pclose_printer (fd); |
2153 | pclose_printer (fd); |
2172 | } |
2154 | } |
2173 | #endif /* PRINTPIPE */ |
2155 | #endif /* PRINTPIPE */ |
2174 | /*}}} */ |
2156 | /*}}} */ |
2175 | |
2157 | |
… | |
… | |
2183 | }; |
2165 | }; |
2184 | /* *INDENT-ON* */ |
2166 | /* *INDENT-ON* */ |
2185 | |
2167 | |
2186 | /*{{{ process non-printing single characters */ |
2168 | /*{{{ process non-printing single characters */ |
2187 | void |
2169 | void |
2188 | rxvt_term::process_nonprinting (unsigned char ch) |
2170 | rxvt_term::process_nonprinting (unicode_t ch) |
2189 | { |
2171 | { |
2190 | switch (ch) |
2172 | switch (ch) |
2191 | { |
2173 | { |
|
|
2174 | case C0_ESC: |
|
|
2175 | process_escape_seq (); |
|
|
2176 | break; |
2192 | case C0_ENQ: /* terminal Status */ |
2177 | case C0_ENQ: /* terminal Status */ |
2193 | if (rs[Rs_answerbackstring]) |
2178 | if (rs[Rs_answerbackstring]) |
2194 | tt_write ( |
2179 | tt_write ( |
2195 | (const unsigned char *)rs[Rs_answerbackstring], |
2180 | (const unsigned char *)rs[Rs_answerbackstring], |
2196 | (unsigned int)STRLEN (rs[Rs_answerbackstring])); |
2181 | (unsigned int)STRLEN (rs[Rs_answerbackstring])); |
… | |
… | |
2219 | scr_charset_choose (1); |
2204 | scr_charset_choose (1); |
2220 | break; |
2205 | break; |
2221 | case C0_SI: /* shift in - acs */ |
2206 | case C0_SI: /* shift in - acs */ |
2222 | scr_charset_choose (0); |
2207 | scr_charset_choose (0); |
2223 | 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; |
2224 | } |
2220 | } |
2225 | } |
2221 | } |
2226 | /*}}} */ |
2222 | /*}}} */ |
2227 | |
2223 | |
2228 | |
2224 | |
2229 | /*{{{ process VT52 escape sequences */ |
2225 | /*{{{ process VT52 escape sequences */ |
2230 | void |
2226 | void |
2231 | rxvt_term::process_escape_vt52 (unsigned char ch) |
2227 | rxvt_term::process_escape_vt52 (unicode_t ch) |
2232 | { |
2228 | { |
2233 | int row, col; |
2229 | int row, col; |
2234 | |
2230 | |
2235 | switch (ch) |
2231 | switch (ch) |
2236 | { |
2232 | { |
… | |
… | |
2288 | |
2284 | |
2289 | /*{{{ process escape sequences */ |
2285 | /*{{{ process escape sequences */ |
2290 | void |
2286 | void |
2291 | rxvt_term::process_escape_seq () |
2287 | rxvt_term::process_escape_seq () |
2292 | { |
2288 | { |
2293 | unsigned char ch = cmd_getc (); |
2289 | unicode_t ch = cmd_getc (); |
2294 | |
2290 | |
2295 | if (PrivateModes & PrivMode_vt52) |
2291 | if (PrivateModes & PrivMode_vt52) |
2296 | { |
2292 | { |
2297 | process_escape_vt52 (ch); |
2293 | process_escape_vt52 (ch); |
2298 | return; |
2294 | return; |
… | |
… | |
2346 | break; |
2342 | break; |
2347 | |
2343 | |
2348 | /* 8.3.87: NEXT LINE */ |
2344 | /* 8.3.87: NEXT LINE */ |
2349 | case C1_NEL: /* ESC E */ |
2345 | case C1_NEL: /* ESC E */ |
2350 | { |
2346 | { |
2351 | uint32_t nlcr[] = { '\n', '\r' }; |
2347 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2352 | scr_add_lines (nlcr, 1, 2); |
2348 | scr_add_lines (nlcr, 1, 2); |
2353 | } |
2349 | } |
2354 | break; |
2350 | break; |
2355 | |
2351 | |
2356 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2352 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
2448 | /* *INDENT-ON* */ |
2444 | /* *INDENT-ON* */ |
2449 | |
2445 | |
2450 | void |
2446 | void |
2451 | rxvt_term::process_csi_seq () |
2447 | rxvt_term::process_csi_seq () |
2452 | { |
2448 | { |
2453 | unsigned char ch, priv, i; |
2449 | unicode_t ch, priv, i; |
2454 | unsigned int nargs, p; |
2450 | unsigned int nargs, p; |
2455 | int n, ndef; |
2451 | int n, ndef; |
2456 | int arg[ESC_ARGS]; |
2452 | int arg[ESC_ARGS]; |
2457 | |
2453 | |
2458 | for (nargs = ESC_ARGS; nargs > 0;) |
2454 | for (nargs = ESC_ARGS; nargs > 0;) |
2459 | arg[--nargs] = 0; |
2455 | arg[--nargs] = 0; |
2460 | |
2456 | |
2461 | priv = 0; |
2457 | priv = 0; |
… | |
… | |
2463 | if (ch >= '<' && ch <= '?') |
2459 | if (ch >= '<' && ch <= '?') |
2464 | { /* '<' '=' '>' '?' */ |
2460 | { /* '<' '=' '>' '?' */ |
2465 | priv = ch; |
2461 | priv = ch; |
2466 | ch = cmd_getc (); |
2462 | ch = cmd_getc (); |
2467 | } |
2463 | } |
|
|
2464 | |
2468 | /* read any numerical arguments */ |
2465 | /* read any numerical arguments */ |
2469 | for (n = -1; ch < CSI_ICH; ) |
2466 | for (n = -1; ch < CSI_ICH; ) |
2470 | { |
2467 | { |
2471 | if (isdigit (ch)) |
2468 | if (isdigit (ch)) |
2472 | { |
2469 | { |
… | |
… | |
2479 | { |
2476 | { |
2480 | if (nargs < ESC_ARGS) |
2477 | if (nargs < ESC_ARGS) |
2481 | arg[nargs++] = n; |
2478 | arg[nargs++] = n; |
2482 | n = -1; |
2479 | n = -1; |
2483 | } |
2480 | } |
2484 | else if (ch == '\b') |
2481 | else if (IS_CONTROL (ch)) |
2485 | { |
|
|
2486 | scr_backspace (); |
|
|
2487 | } |
|
|
2488 | else if (ch == C0_ESC) |
|
|
2489 | { |
|
|
2490 | process_escape_seq (); |
|
|
2491 | return; |
|
|
2492 | } |
|
|
2493 | else if (ch < ' ') |
|
|
2494 | { |
|
|
2495 | process_nonprinting (ch); |
2482 | process_nonprinting (ch); |
2496 | } |
2483 | |
2497 | ch = cmd_getc (); |
2484 | ch = cmd_getc (); |
2498 | } |
2485 | } |
2499 | |
2486 | |
2500 | if (ch > CSI_7F) |
2487 | if (ch > CSI_7F) |
2501 | return; |
2488 | return; |
… | |
… | |
2743 | #endif |
2730 | #endif |
2744 | |
2731 | |
2745 | case CSI_78: /* DECREQTPARM */ |
2732 | case CSI_78: /* DECREQTPARM */ |
2746 | if (arg[0] == 0 || arg[0] == 1) |
2733 | if (arg[0] == 0 || arg[0] == 1) |
2747 | 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); |
2748 | /* FALLTHROUGH */ |
2735 | break; |
2749 | |
2736 | |
2750 | default: |
2737 | default: |
2751 | break; |
2738 | break; |
2752 | } |
2739 | } |
2753 | } |
2740 | } |
… | |
… | |
2756 | #ifndef NO_FRILLS |
2743 | #ifndef NO_FRILLS |
2757 | /* ARGSUSED */ |
2744 | /* ARGSUSED */ |
2758 | void |
2745 | void |
2759 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
2746 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
2760 | { |
2747 | { |
2761 | int x, y; |
2748 | int x, y; |
2762 | #if 0 |
|
|
2763 | char *s; |
|
|
2764 | #endif |
|
|
2765 | XWindowAttributes wattr; |
2749 | XWindowAttributes wattr; |
2766 | Window wdummy; |
2750 | Window wdummy; |
2767 | |
2751 | |
2768 | if (nargs == 0) |
2752 | if (nargs == 0) |
2769 | return; |
2753 | return; |
|
|
2754 | |
2770 | switch (args[0]) |
2755 | switch (args[0]) |
2771 | { |
2756 | { |
2772 | /* |
2757 | /* |
2773 | * commands |
2758 | * commands |
2774 | */ |
2759 | */ |
2775 | case 1: /* deiconify window */ |
2760 | case 1: /* deiconify window */ |
2776 | XMapWindow (display->display, TermWin.parent[0]); |
2761 | XMapWindow (display->display, TermWin.parent[0]); |
2777 | break; |
2762 | break; |
2778 | case 2: /* iconify window */ |
2763 | case 2: /* iconify window */ |
2779 | XIconifyWindow (display->display, TermWin.parent[0], |
2764 | XIconifyWindow (display->display, TermWin.parent[0], |
… | |
… | |
2796 | break; |
2781 | break; |
2797 | case 8: /* set size (chars) */ |
2782 | case 8: /* set size (chars) */ |
2798 | set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), |
2783 | set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), |
2799 | (unsigned int) (args[1] * TermWin.fheight)); |
2784 | (unsigned int) (args[1] * TermWin.fheight)); |
2800 | break; |
2785 | break; |
|
|
2786 | |
|
|
2787 | //case 9: NYI, TODO, restore maximized window or maximize window |
2801 | default: |
2788 | default: |
2802 | if (args[0] >= 24) /* set height (chars) */ |
2789 | if (args[0] >= 24) /* set height (chars) */ |
2803 | set_widthheight ((unsigned int)TermWin.width, |
2790 | set_widthheight ((unsigned int)TermWin.width, |
2804 | (unsigned int) (args[1] * TermWin.fheight)); |
2791 | (unsigned int) (args[1] * TermWin.fheight)); |
2805 | break; |
2792 | break; |
|
|
2793 | |
|
|
2794 | |
2806 | /* |
2795 | /* |
2807 | * reports - some output format copied from XTerm |
2796 | * reports - some output format copied from XTerm |
2808 | */ |
2797 | */ |
2809 | case 11: /* report window state */ |
2798 | case 11: /* report window state */ |
2810 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2799 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2811 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
2800 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
2812 | break; |
2801 | break; |
2813 | case 13: /* report window position */ |
2802 | case 13: /* report window position */ |
… | |
… | |
2819 | break; |
2808 | break; |
2820 | case 14: /* report window size (pixels) */ |
2809 | case 14: /* report window size (pixels) */ |
2821 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2810 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2822 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
2811 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
2823 | break; |
2812 | break; |
2824 | case 18: /* report window size (chars) */ |
2813 | case 18: /* report text area size (chars) */ |
2825 | 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); |
2826 | break; |
2818 | break; |
2827 | #if 0 /* XXX: currently disabled due to security concerns */ |
2819 | #if 0 /* XXX: currently disabled due to security concerns */ |
2828 | case 20: /* report icon label */ |
2820 | case 20: /* report icon label */ |
2829 | XGetIconName (display->display, TermWin.parent[0], &s); |
2821 | XGetIconName (display->display, TermWin.parent[0], &s); |
2830 | tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ |
2822 | tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ |
… | |
… | |
2832 | case 21: /* report window title */ |
2824 | case 21: /* report window title */ |
2833 | XFetchName (display->display, TermWin.parent[0], &s); |
2825 | XFetchName (display->display, TermWin.parent[0], &s); |
2834 | tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ |
2826 | tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ |
2835 | break; |
2827 | break; |
2836 | #endif |
2828 | #endif |
2837 | |
|
|
2838 | } |
2829 | } |
2839 | } |
2830 | } |
2840 | #endif |
2831 | #endif |
2841 | |
2832 | |
2842 | /*----------------------------------------------------------------------*/ |
2833 | /*----------------------------------------------------------------------*/ |
2843 | /* |
2834 | /* |
2844 | * get input up until STRING TERMINATOR (or BEL) |
2835 | * get input up until STRING TERMINATOR (or BEL) |
2845 | * ends_how is terminator used. returned input must be free ()d |
2836 | * ends_how is terminator used. returned input must be free ()d |
2846 | */ |
2837 | */ |
2847 | unsigned char * |
2838 | unsigned char * |
2848 | rxvt_term::get_to_st (unsigned char *ends_how) |
2839 | rxvt_term::get_to_st (unicode_t &ends_how) |
2849 | { |
2840 | { |
2850 | int seen_esc = 0; /* seen escape? */ |
2841 | int seen_esc = 0; /* seen escape? */ |
2851 | unsigned int n = 0; |
2842 | unsigned int n = 0; |
2852 | unsigned char *s; |
2843 | unsigned char *s; |
|
|
2844 | unicode_t ch; |
2853 | unsigned char ch, string[STRING_MAX]; |
2845 | unsigned char string[STRING_MAX]; |
2854 | |
2846 | |
2855 | for (; (ch = cmd_getc ());) |
2847 | while ((ch = cmd_getc ())) |
2856 | { |
2848 | { |
2857 | if (ch == C0_BEL |
2849 | if (ch == C0_BEL |
2858 | || ch == CHAR_ST |
2850 | || ch == CHAR_ST |
2859 | || (ch == 0x5c && seen_esc)) /* 7bit ST */ |
2851 | || (ch == 0x5c && seen_esc)) /* 7bit ST */ |
2860 | break; |
2852 | break; |
|
|
2853 | |
2861 | if (ch == C0_ESC) |
2854 | if (ch == C0_ESC) |
2862 | { |
2855 | { |
2863 | seen_esc = 1; |
2856 | seen_esc = 1; |
2864 | continue; |
2857 | continue; |
2865 | } |
2858 | } |
2866 | else if (ch == '\t') |
2859 | else if (ch == '\t') |
2867 | ch = ' '; /* translate '\t' to space */ |
2860 | ch = ' '; /* translate '\t' to space */ |
2868 | else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) |
2861 | else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) |
2869 | return NULL; /* other control character - exit */ |
2862 | return NULL; /* other control character - exit */ |
|
|
2863 | |
2870 | if (n < sizeof (string) - 1) |
2864 | if (n < sizeof (string) - 1) |
2871 | string[n++] = ch; |
2865 | string[n++] = ch; |
|
|
2866 | |
2872 | seen_esc = 0; |
2867 | seen_esc = 0; |
2873 | } |
2868 | } |
|
|
2869 | |
2874 | string[n++] = '\0'; |
2870 | string[n++] = '\0'; |
|
|
2871 | |
2875 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
2872 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
2876 | return NULL; |
2873 | return NULL; |
|
|
2874 | |
2877 | *ends_how = (ch == 0x5c ? C0_ESC : ch); |
2875 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
2878 | STRNCPY (s, string, n); |
2876 | STRNCPY (s, string, n); |
2879 | return s; |
2877 | return s; |
2880 | } |
2878 | } |
2881 | |
2879 | |
2882 | /*----------------------------------------------------------------------*/ |
2880 | /*----------------------------------------------------------------------*/ |
… | |
… | |
2884 | * 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)' |
2885 | */ |
2883 | */ |
2886 | void |
2884 | void |
2887 | rxvt_term::process_dcs_seq () |
2885 | rxvt_term::process_dcs_seq () |
2888 | { |
2886 | { |
2889 | unsigned char eh, *s; |
2887 | unsigned char *s; |
|
|
2888 | unicode_t eh; |
|
|
2889 | |
2890 | /* |
2890 | /* |
2891 | * Not handled yet |
2891 | * Not handled yet |
2892 | */ |
2892 | */ |
2893 | s = get_to_st (&eh); |
2893 | s = get_to_st (eh); |
2894 | if (s) |
2894 | if (s) |
2895 | free (s); |
2895 | free (s); |
|
|
2896 | |
2896 | return; |
2897 | return; |
2897 | } |
2898 | } |
2898 | |
2899 | |
2899 | /*----------------------------------------------------------------------*/ |
2900 | /*----------------------------------------------------------------------*/ |
2900 | /* |
2901 | /* |
2901 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
2902 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
2902 | */ |
2903 | */ |
2903 | void |
2904 | void |
2904 | rxvt_term::process_osc_seq () |
2905 | rxvt_term::process_osc_seq () |
2905 | { |
2906 | { |
2906 | unsigned char ch, eh, *s; |
2907 | unicode_t ch, eh; |
2907 | int arg; |
2908 | int arg; |
2908 | |
2909 | |
2909 | ch = cmd_getc (); |
2910 | ch = cmd_getc (); |
2910 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
2911 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
2911 | arg = arg * 10 + (ch - '0'); |
2912 | arg = arg * 10 + (ch - '0'); |
2912 | |
2913 | |
2913 | if (ch == ';') |
2914 | if (ch == ';') |
2914 | { |
2915 | { |
2915 | s = get_to_st (&eh); |
2916 | unsigned char *s = get_to_st (eh); |
|
|
2917 | |
2916 | if (s) |
2918 | if (s) |
2917 | { |
2919 | { |
2918 | /* |
2920 | /* |
2919 | * rxvt_menubar_dispatch () violates the constness of the string, |
2921 | * rxvt_menubar_dispatch () violates the constness of the string, |
2920 | * so do it here |
2922 | * so do it here |
… | |
… | |
2925 | #else |
2927 | #else |
2926 | (void)0; |
2928 | (void)0; |
2927 | #endif |
2929 | #endif |
2928 | else |
2930 | else |
2929 | xterm_seq (arg, (char *)s, eh); |
2931 | xterm_seq (arg, (char *)s, eh); |
|
|
2932 | |
2930 | free (s); |
2933 | free (s); |
2931 | } |
2934 | } |
2932 | } |
2935 | } |
2933 | } |
2936 | } |
2934 | /* |
2937 | /* |
… | |
… | |
2955 | * 702 = find font |
2958 | * 702 = find font |
2956 | */ |
2959 | */ |
2957 | void |
2960 | void |
2958 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2961 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2959 | { |
2962 | { |
2960 | int changed = 0; |
2963 | int changed = 0; |
2961 | int color; |
2964 | int color; |
2962 | char *buf, *name; |
2965 | char *buf, *name; |
2963 | |
2966 | |
2964 | assert (str != NULL); |
2967 | assert (str != NULL); |
2965 | switch (op) |
2968 | switch (op) |
2966 | { |
2969 | { |
2967 | case XTerm_name: |
2970 | case XTerm_name: |
2968 | set_title (str); |
2971 | set_title (str); |
2969 | /* FALLTHROUGH */ |
2972 | /* FALLTHROUGH */ |
2970 | case XTerm_iconName: |
2973 | case XTerm_iconName: |
2971 | set_iconName (str); |
2974 | set_icon_name (str); |
2972 | break; |
2975 | break; |
2973 | case XTerm_title: |
2976 | case XTerm_title: |
2974 | set_title (str); |
2977 | set_title (str); |
2975 | break; |
2978 | break; |
2976 | case XTerm_Color: |
2979 | case XTerm_Color: |
2977 | for (buf = (char *)str; buf && *buf;) |
2980 | for (buf = (char *)str; buf && *buf;) |
2978 | { |
2981 | { |
2979 | if ((name = STRCHR (buf, ';')) == NULL) |
2982 | if ((name = STRCHR (buf, ';')) == NULL) |
2980 | break; |
2983 | break; |
|
|
2984 | |
2981 | *name++ = '\0'; |
2985 | *name++ = '\0'; |
2982 | color = atoi (buf); |
2986 | color = atoi (buf); |
|
|
2987 | |
2983 | if (color < 0 || color >= TOTAL_COLORS) |
2988 | if (color < 0 || color >= TOTAL_COLORS) |
2984 | break; |
2989 | break; |
|
|
2990 | |
2985 | if ((buf = STRCHR (name, ';')) != NULL) |
2991 | if ((buf = STRCHR (name, ';')) != NULL) |
2986 | *buf++ = '\0'; |
2992 | *buf++ = '\0'; |
|
|
2993 | |
2987 | set_window_color (color + minCOLOR, name); |
2994 | set_window_color (color + minCOLOR, name); |
2988 | } |
2995 | } |
2989 | break; |
2996 | break; |
2990 | #ifndef NO_CURSORCOLOR |
2997 | #ifndef NO_CURSORCOLOR |
2991 | case XTerm_Color_cursor: |
2998 | case XTerm_Color_cursor: |
… | |
… | |
3044 | break; |
3051 | break; |
3045 | case XTerm_restoreBG: |
3052 | case XTerm_restoreBG: |
3046 | set_window_color (Color_bg, str); |
3053 | set_window_color (Color_bg, str); |
3047 | break; |
3054 | break; |
3048 | case XTerm_logfile: |
3055 | case XTerm_logfile: |
|
|
3056 | // TODO, when secure mode? |
3049 | break; |
3057 | break; |
3050 | case XTerm_font: |
3058 | case XTerm_font: |
3051 | change_font (str); |
3059 | change_font (str); |
3052 | break; |
3060 | break; |
3053 | #ifndef NO_FRILLS |
3061 | #ifndef NO_FRILLS |
… | |
… | |
3079 | close (fd); |
3087 | close (fd); |
3080 | } |
3088 | } |
3081 | } |
3089 | } |
3082 | break; |
3090 | break; |
3083 | #endif |
3091 | #endif |
3084 | |
|
|
3085 | } |
3092 | } |
3086 | } |
3093 | } |
3087 | /*----------------------------------------------------------------------*/ |
3094 | /*----------------------------------------------------------------------*/ |
3088 | |
3095 | |
3089 | /*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */ |
3096 | /*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */ |
… | |
… | |
3097 | * so no need for fancy checking |
3104 | * so no need for fancy checking |
3098 | */ |
3105 | */ |
3099 | int |
3106 | int |
3100 | rxvt_term::privcases (int mode, unsigned long bit) |
3107 | rxvt_term::privcases (int mode, unsigned long bit) |
3101 | { |
3108 | { |
3102 | int state; |
3109 | int state; |
3103 | |
3110 | |
3104 | if (mode == 's') |
3111 | if (mode == 's') |
3105 | { |
3112 | { |
3106 | SavedModes |= (PrivateModes & bit); |
3113 | SavedModes |= (PrivateModes & bit); |
3107 | return -1; |
3114 | return -1; |
… | |
… | |
3112 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3119 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3113 | else |
3120 | else |
3114 | state = (mode == 't') ? ! (PrivateModes & bit) : mode; |
3121 | state = (mode == 't') ? ! (PrivateModes & bit) : mode; |
3115 | PrivMode (state, bit); |
3122 | PrivMode (state, bit); |
3116 | } |
3123 | } |
|
|
3124 | |
3117 | return state; |
3125 | return state; |
3118 | } |
3126 | } |
3119 | |
3127 | |
3120 | /* we're not using priv _yet_ */ |
3128 | /* we're not using priv _yet_ */ |
3121 | void |
3129 | void |
3122 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3130 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3123 | { |
3131 | { |
3124 | unsigned int i, j; |
3132 | unsigned int i, j; |
3125 | int state; |
3133 | int state; |
|
|
3134 | |
3126 | static const struct |
3135 | static const struct |
3127 | { |
3136 | { |
3128 | const int argval; |
3137 | const int argval; |
3129 | const unsigned long bit; |
3138 | const unsigned long bit; |
3130 | } |
3139 | } |
|
|
3140 | |
3131 | argtopriv[] = { |
3141 | argtopriv[] = { |
3132 | { 1, PrivMode_aplCUR }, |
3142 | { 1, PrivMode_aplCUR }, |
3133 | { 2, PrivMode_vt52 }, |
3143 | { 2, PrivMode_vt52 }, |
3134 | { 3, PrivMode_132 }, |
3144 | { 3, PrivMode_132 }, |
3135 | { 4, PrivMode_smoothScroll }, |
3145 | { 4, PrivMode_smoothScroll }, |
… | |
… | |
3141 | { menuBar_esc, PrivMode_menuBar }, |
3151 | { menuBar_esc, PrivMode_menuBar }, |
3142 | #endif |
3152 | #endif |
3143 | #ifdef scrollBar_esc |
3153 | #ifdef scrollBar_esc |
3144 | { scrollBar_esc, PrivMode_scrollBar }, |
3154 | { scrollBar_esc, PrivMode_scrollBar }, |
3145 | #endif |
3155 | #endif |
|
|
3156 | // 18, 19 printing-related |
3146 | { 25, PrivMode_VisibleCursor }, |
3157 | { 25, PrivMode_VisibleCursor }, |
|
|
3158 | // 30 show scrollbar rxvt. extension |
3147 | { 35, PrivMode_ShiftKeys }, |
3159 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3148 | { 40, PrivMode_132OK }, |
3160 | { 40, PrivMode_132OK }, |
|
|
3161 | // 41 xterm more fixes NYI |
|
|
3162 | // 45 margin bell NYI |
|
|
3163 | // 46 start logging |
3149 | { 47, PrivMode_Screen }, |
3164 | { 47, PrivMode_Screen }, |
3150 | { 66, PrivMode_aplKP }, |
3165 | { 66, PrivMode_aplKP }, |
3151 | #ifndef NO_BACKSPACE_KEY |
3166 | #ifndef NO_BACKSPACE_KEY |
3152 | { 67, PrivMode_BackSpace }, |
3167 | { 67, PrivMode_BackSpace }, |
3153 | #endif |
3168 | #endif |
3154 | { 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 |
3155 | { 1010, PrivMode_TtyOutputInh }, |
3173 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3156 | { 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 |
3157 | { 1047, PrivMode_Screen }, |
3178 | { 1047, PrivMode_Screen }, |
|
|
3179 | // 1048 save and restore cursor |
3158 | { 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 |
3159 | }; |
3182 | }; |
3160 | |
3183 | |
3161 | if (nargs == 0) |
3184 | if (nargs == 0) |
3162 | return; |
3185 | return; |
3163 | |
3186 | |
… | |
… | |
3178 | state = privcases (mode, argtopriv[j].bit); |
3201 | state = privcases (mode, argtopriv[j].bit); |
3179 | break; |
3202 | break; |
3180 | } |
3203 | } |
3181 | |
3204 | |
3182 | /* 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 | |
3183 | if (state == -1) |
3217 | if (state >= 0) |
|
|
3218 | /* extra handling for values with valid 0 or 1 state */ |
3184 | switch (arg[i]) |
3219 | switch (arg[i]) |
3185 | { |
3220 | { |
3186 | 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 */ |
3187 | if (mode == 0) |
3234 | if (state) |
3188 | scr_cursor (RESTORE); |
3235 | Options &= ~Opt_jumpScroll; |
3189 | else if (mode == 1) |
3236 | else |
3190 | 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); |
3191 | /* FALLTHROUGH */ |
3305 | /* FALLTHROUGH */ |
3192 | default: |
3306 | default: |
3193 | continue; /* for (;i;) */ |
3307 | break; |
3194 | } |
3308 | } |
3195 | |
|
|
3196 | /* extra handling for values with valid 0 or 1 state */ |
|
|
3197 | switch (arg[i]) |
|
|
3198 | { |
|
|
3199 | /* case 1: - application cursor keys */ |
|
|
3200 | case 2: /* VT52 mode */ |
|
|
3201 | /* oddball mode. should be set regardless of set/reset |
|
|
3202 | * parameter. Return from VT52 mode with an ESC < from |
|
|
3203 | * within VT52 mode |
|
|
3204 | */ |
|
|
3205 | PrivMode (1, PrivMode_vt52); |
|
|
3206 | break; |
|
|
3207 | case 3: /* 80/132 */ |
|
|
3208 | if (PrivateModes & PrivMode_132OK) |
|
|
3209 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
|
|
3210 | break; |
|
|
3211 | case 4: /* smooth scrolling */ |
|
|
3212 | if (state) |
|
|
3213 | Options &= ~Opt_jumpScroll; |
|
|
3214 | else |
|
|
3215 | Options |= Opt_jumpScroll; |
|
|
3216 | break; |
|
|
3217 | case 5: /* reverse video */ |
|
|
3218 | scr_rvideo_mode (state); |
|
|
3219 | break; |
|
|
3220 | case 6: /* relative/absolute origins */ |
|
|
3221 | scr_relative_origin (state); |
|
|
3222 | break; |
|
|
3223 | case 7: /* autowrap */ |
|
|
3224 | scr_autowrap (state); |
|
|
3225 | break; |
|
|
3226 | /* case 8: - auto repeat, can't do on a per window basis */ |
|
|
3227 | case 9: /* X10 mouse reporting */ |
|
|
3228 | if (state) /* orthogonal */ |
|
|
3229 | PrivateModes &= ~ (PrivMode_MouseX11); |
|
|
3230 | break; |
|
|
3231 | #ifdef menuBar_esc |
|
|
3232 | case menuBar_esc: |
|
|
3233 | #ifdef MENUBAR |
|
|
3234 | map_menuBar (state); |
|
|
3235 | #endif |
|
|
3236 | break; |
|
|
3237 | #endif |
|
|
3238 | #ifdef scrollBar_esc |
|
|
3239 | case scrollBar_esc: |
|
|
3240 | if (scrollbar_mapping (state)) |
|
|
3241 | { |
|
|
3242 | resize_all_windows (0, 0, 0); |
|
|
3243 | scr_touch (true); |
|
|
3244 | } |
|
|
3245 | break; |
|
|
3246 | #endif |
|
|
3247 | case 25: /* visible/invisible cursor */ |
|
|
3248 | scr_cursor_visible (state); |
|
|
3249 | break; |
|
|
3250 | /* case 35: - shift keys */ |
|
|
3251 | /* case 40: - 80 <--> 132 mode */ |
|
|
3252 | case 47: /* secondary screen */ |
|
|
3253 | scr_change_screen (state); |
|
|
3254 | break; |
|
|
3255 | /* case 66: - application key pad */ |
|
|
3256 | /* case 67: - backspace key */ |
|
|
3257 | case 1000: /* X11 mouse reporting */ |
|
|
3258 | if (state) /* orthogonal */ |
|
|
3259 | PrivateModes &= ~ (PrivMode_MouseX10); |
|
|
3260 | break; |
|
|
3261 | #if 0 |
|
|
3262 | case 1001: |
|
|
3263 | break; /* X11 mouse highlighting */ |
|
|
3264 | #endif |
|
|
3265 | case 1010: /* scroll to bottom on TTY output inhibit */ |
|
|
3266 | if (state) |
|
|
3267 | Options &= ~Opt_scrollTtyOutput; |
|
|
3268 | else |
|
|
3269 | Options |= Opt_scrollTtyOutput; |
|
|
3270 | break; |
|
|
3271 | case 1011: /* scroll to bottom on key press */ |
|
|
3272 | if (state) |
|
|
3273 | Options |= Opt_scrollTtyKeypress; |
|
|
3274 | else |
|
|
3275 | Options &= ~Opt_scrollTtyKeypress; |
|
|
3276 | break; |
|
|
3277 | case 1047: /* secondary screen w/ clearing */ |
|
|
3278 | case 1049: /* better secondary screen w/ clearing, but not fully implemented */ |
|
|
3279 | if (current_screen != PRIMARY) |
|
|
3280 | scr_erase_screen (2); |
|
|
3281 | scr_change_screen (state); |
|
|
3282 | /* FALLTHROUGH */ |
|
|
3283 | default: |
|
|
3284 | break; |
|
|
3285 | } |
|
|
3286 | } |
3309 | } |
3287 | } |
3310 | } |
3288 | /*}}} */ |
3311 | /*}}} */ |
3289 | |
3312 | |
3290 | /*{{{ process sgr sequences */ |
3313 | /*{{{ process sgr sequences */ |
3291 | void |
3314 | void |
3292 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
3315 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
3293 | { |
3316 | { |
3294 | unsigned int i; |
3317 | unsigned int i; |
3295 | short rendset; |
3318 | short rendset; |
3296 | int rendstyle; |
3319 | int rendstyle; |
3297 | |
3320 | |
3298 | if (nargs == 0) |
3321 | if (nargs == 0) |
3299 | { |
3322 | { |
3300 | scr_rendition (0, ~RS_None); |
3323 | scr_rendition (0, ~RS_None); |
3301 | return; |
3324 | return; |
3302 | } |
3325 | } |
|
|
3326 | |
3303 | for (i = 0; i < nargs; i++) |
3327 | for (i = 0; i < nargs; i++) |
3304 | { |
3328 | { |
3305 | rendset = -1; |
3329 | rendset = -1; |
3306 | switch (arg[i]) |
3330 | switch (arg[i]) |
3307 | { |
3331 | { |
… | |
… | |
3318 | rendset = 1, rendstyle = RS_Blink; |
3342 | rendset = 1, rendstyle = RS_Blink; |
3319 | break; |
3343 | break; |
3320 | case 7: |
3344 | case 7: |
3321 | rendset = 1, rendstyle = RS_RVid; |
3345 | rendset = 1, rendstyle = RS_RVid; |
3322 | break; |
3346 | break; |
|
|
3347 | case 8: |
|
|
3348 | // invisible. NYI |
|
|
3349 | break; |
3323 | case 22: |
3350 | case 22: |
3324 | rendset = 0, rendstyle = RS_Bold; |
3351 | rendset = 0, rendstyle = RS_Bold; |
3325 | break; |
3352 | break; |
3326 | case 24: |
3353 | case 24: |
3327 | rendset = 0, rendstyle = RS_Uline; |
3354 | rendset = 0, rendstyle = RS_Uline; |
… | |
… | |
3330 | rendset = 0, rendstyle = RS_Blink; |
3357 | rendset = 0, rendstyle = RS_Blink; |
3331 | break; |
3358 | break; |
3332 | case 27: |
3359 | case 27: |
3333 | rendset = 0, rendstyle = RS_RVid; |
3360 | rendset = 0, rendstyle = RS_RVid; |
3334 | break; |
3361 | break; |
|
|
3362 | case 28: |
|
|
3363 | // visible. NYI |
|
|
3364 | break; |
3335 | } |
3365 | } |
|
|
3366 | |
3336 | if (rendset != -1) |
3367 | if (rendset != -1) |
3337 | { |
3368 | { |
3338 | scr_rendition (rendset, rendstyle); |
3369 | scr_rendition (rendset, rendstyle); |
3339 | continue; /* for (;i;) */ |
3370 | continue; /* for (;i;) */ |
3340 | } |
3371 | } |
… | |
… | |
3347 | case 33: |
3378 | case 33: |
3348 | case 34: |
3379 | case 34: |
3349 | case 35: |
3380 | case 35: |
3350 | case 36: |
3381 | case 36: |
3351 | case 37: |
3382 | case 37: |
3352 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), |
3383 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
3353 | Color_fg); |
|
|
3354 | break; |
3384 | break; |
3355 | #ifdef TTY_256COLOR |
3385 | #ifdef TTY_256COLOR |
3356 | case 38: |
3386 | case 38: |
3357 | if (nargs > i + 2 && arg[i + 1] == 5) |
3387 | if (nargs > i + 2 && arg[i + 1] == 5) |
3358 | { |
3388 | { |
3359 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), |
3389 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
3360 | Color_fg); |
|
|
3361 | i += 2; |
3390 | i += 2; |
3362 | } |
3391 | } |
3363 | break; |
3392 | break; |
3364 | #endif |
3393 | #endif |
3365 | case 39: /* default fg */ |
3394 | case 39: /* default fg */ |
… | |
… | |
3372 | case 43: |
3401 | case 43: |
3373 | case 44: |
3402 | case 44: |
3374 | case 45: |
3403 | case 45: |
3375 | case 46: |
3404 | case 46: |
3376 | case 47: |
3405 | case 47: |
3377 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), |
3406 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
3378 | Color_bg); |
|
|
3379 | break; |
3407 | break; |
3380 | #ifdef TTY_256COLOR |
3408 | #ifdef TTY_256COLOR |
3381 | case 48: |
3409 | case 48: |
3382 | if (nargs > i + 2 && arg[i + 1] == 5) |
3410 | if (nargs > i + 2 && arg[i + 1] == 5) |
3383 | { |
3411 | { |
3384 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), |
3412 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
3385 | Color_bg); |
|
|
3386 | i += 2; |
3413 | i += 2; |
3387 | } |
3414 | } |
3388 | break; |
3415 | break; |
3389 | #endif |
3416 | #endif |
3390 | case 49: /* default bg */ |
3417 | case 49: /* default bg */ |
… | |
… | |
3423 | |
3450 | |
3424 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3451 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3425 | void |
3452 | void |
3426 | rxvt_term::process_graphics () |
3453 | rxvt_term::process_graphics () |
3427 | { |
3454 | { |
3428 | unsigned char ch, cmd = cmd_getc (); |
3455 | unicode_t ch, cmd = cmd_getc (); |
3429 | |
3456 | |
3430 | if (cmd == 'Q') |
3457 | if (cmd == 'Q') |
3431 | { /* query graphics */ |
3458 | { /* query graphics */ |
3432 | tt_printf ("\033G0\n"); /* no graphics */ |
3459 | tt_printf ("\033G0\n"); /* no graphics */ |
3433 | return; |
3460 | return; |