… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
|
|
53 | |
|
|
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
52 | |
58 | |
53 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
60 | # include "keyboard.h" |
55 | #endif |
61 | #endif |
56 | |
62 | |
… | |
… | |
155 | } |
161 | } |
156 | |
162 | |
157 | x--; |
163 | x--; |
158 | } |
164 | } |
159 | } |
165 | } |
160 | #endif |
|
|
161 | |
166 | |
162 | void |
167 | void |
163 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
168 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
164 | { |
169 | { |
165 | #if ENABLE_OVERLAY |
|
|
166 | rxvt_fontset *fs = FONTSET (r); |
170 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
171 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
172 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
173 | int len; |
170 | |
174 | |
… | |
… | |
238 | |
242 | |
239 | # if ENABLE_COMBINING |
243 | # if ENABLE_COMBINING |
240 | if (alloc) |
244 | if (alloc) |
241 | delete [] alloc; |
245 | delete [] alloc; |
242 | # endif |
246 | # endif |
243 | #endif |
|
|
244 | } |
247 | } |
|
|
248 | #endif |
245 | |
249 | |
246 | void |
250 | void |
247 | rxvt_term::commit_iso14755 () |
251 | rxvt_term::commit_iso14755 () |
248 | { |
252 | { |
249 | wchar_t ch[2]; |
253 | wchar_t ch[2]; |
… | |
… | |
264 | mb[0] = ch[0]; |
268 | mb[0] = ch[0]; |
265 | len = 1; |
269 | len = 1; |
266 | } |
270 | } |
267 | |
271 | |
268 | if (len > 0) |
272 | if (len > 0) |
269 | tt_write ((unsigned char *)mb, len); |
273 | tt_write (mb, len); |
270 | else |
274 | else |
271 | scr_bell (); |
275 | scr_bell (); |
272 | } |
276 | } |
273 | |
277 | |
274 | iso14755buf = 0; |
278 | iso14755buf = 0; |
… | |
… | |
302 | KeySym keysym; |
306 | KeySym keysym; |
303 | #ifdef DEBUG_CMD |
307 | #ifdef DEBUG_CMD |
304 | static int debug_key = 1; /* accessible by a debugger only */ |
308 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | #endif |
309 | #endif |
306 | int valid_keysym; |
310 | int valid_keysym; |
307 | unsigned char kbuf[KBUFSZ]; |
311 | char kbuf[KBUFSZ]; |
308 | |
312 | |
309 | /* |
313 | /* |
310 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
311 | * escape sequence to toggle the Keypad. |
315 | * escape sequence to toggle the Keypad. |
312 | * |
316 | * |
… | |
… | |
330 | Status status_return; |
334 | Status status_return; |
331 | |
335 | |
332 | #if 0 |
336 | #if 0 |
333 | #ifdef X_HAVE_UTF8_STRING |
337 | #ifdef X_HAVE_UTF8_STRING |
334 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
335 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
339 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
336 | KBUFSZ, &keysym, &status_return); |
340 | KBUFSZ, &keysym, &status_return); |
337 | else |
341 | else |
338 | #endif |
342 | #endif |
339 | #endif |
343 | #endif |
340 | { |
344 | { |
… | |
… | |
377 | || status_return == XLookupBoth; |
381 | || status_return == XLookupBoth; |
378 | } |
382 | } |
379 | else |
383 | else |
380 | #endif |
384 | #endif |
381 | { |
385 | { |
382 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
386 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
383 | valid_keysym = keysym != NoSymbol; |
387 | valid_keysym = keysym != NoSymbol; |
384 | } |
388 | } |
385 | |
389 | |
386 | if (valid_keysym) |
390 | if (valid_keysym) |
387 | { |
391 | { |
… | |
… | |
851 | { |
855 | { |
852 | #ifdef META8_OPTION |
856 | #ifdef META8_OPTION |
853 | /* set 8-bit on */ |
857 | /* set 8-bit on */ |
854 | if (meta && (meta_char == 0x80)) |
858 | if (meta && (meta_char == 0x80)) |
855 | { |
859 | { |
856 | unsigned char *ch; |
860 | char *ch; |
857 | |
861 | |
858 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | *ch |= 0x80; |
863 | *ch |= 0x80; |
860 | |
864 | |
861 | meta = 0; |
865 | meta = 0; |
… | |
… | |
894 | #ifdef META8_OPTION |
898 | #ifdef META8_OPTION |
895 | && meta_char == C0_ESC |
899 | && meta_char == C0_ESC |
896 | #endif |
900 | #endif |
897 | ) |
901 | ) |
898 | { |
902 | { |
899 | const unsigned char ch = C0_ESC; |
903 | const char ch = C0_ESC; |
900 | tt_write (&ch, 1); |
904 | tt_write (&ch, 1); |
901 | } |
905 | } |
902 | |
906 | |
903 | #if defined(DEBUG_CMD) |
907 | #if defined(DEBUG_CMD) |
904 | /* Display keyboard buffer contents */ |
908 | /* Display keyboard buffer contents */ |
… | |
… | |
916 | |
920 | |
917 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
921 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
918 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
922 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
919 | /* attempt to `write' count to the input buffer */ |
923 | /* attempt to `write' count to the input buffer */ |
920 | unsigned int |
924 | unsigned int |
921 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
925 | rxvt_term::cmd_write (const char *str, unsigned int count) |
922 | { |
926 | { |
923 | unsigned int n, s; |
927 | unsigned int n, s; |
924 | |
928 | |
925 | n = cmdbuf_ptr - cmdbuf_base; |
929 | n = cmdbuf_ptr - cmdbuf_base; |
926 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
930 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
982 | SET_LOCALE (locale); |
986 | SET_LOCALE (locale); |
983 | |
987 | |
984 | display->flush (); |
988 | display->flush (); |
985 | |
989 | |
986 | if (want_refresh && !flush_ev.active) |
990 | if (want_refresh && !flush_ev.active) |
987 | flush_ev.start (NOW + 0.01); |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
988 | } |
992 | } |
989 | |
993 | |
990 | void |
994 | void |
991 | rxvt_term::flush_cb (time_watcher &w) |
995 | rxvt_term::flush_cb (time_watcher &w) |
992 | { |
996 | { |
… | |
… | |
1067 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1068 | } |
1072 | } |
1069 | } |
1073 | } |
1070 | #endif |
1074 | #endif |
1071 | |
1075 | |
|
|
1076 | #if HAVE_SCHED_YIELD |
|
|
1077 | static struct event_handler |
|
|
1078 | { |
|
|
1079 | check_watcher cw_yield; |
|
|
1080 | |
|
|
1081 | void yield (check_watcher &w) |
|
|
1082 | { |
|
|
1083 | sched_yield (); |
|
|
1084 | w.stop (); |
|
|
1085 | } |
|
|
1086 | |
|
|
1087 | event_handler () |
|
|
1088 | : cw_yield (this, &event_handler::yield) |
|
|
1089 | { |
|
|
1090 | } |
|
|
1091 | } event_handler; |
|
|
1092 | #endif |
|
|
1093 | |
1072 | bool |
1094 | bool |
1073 | rxvt_term::pty_fill () |
1095 | rxvt_term::pty_fill () |
1074 | { |
1096 | { |
1075 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1076 | |
1098 | |
1077 | if (CBUFSIZ == n) |
1099 | if (CBUFSIZ == n) |
1078 | { |
1100 | { |
1079 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1101 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1080 | n = 0; |
1102 | n = 0; |
1081 | } |
1103 | } |
1082 | |
1104 | |
1083 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1084 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_ptr = cmdbuf_base; |
1085 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | cmdbuf_endp = cmdbuf_ptr + n; |
1086 | |
1108 | |
1087 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1088 | |
1110 | |
1089 | if (n > 0) |
1111 | if (r > 0) |
1090 | { |
1112 | { |
1091 | cmdbuf_endp += n; |
1113 | cmdbuf_endp += r; |
1092 | return true; |
1114 | return true; |
1093 | } |
1115 | } |
1094 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1116 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1117 | { |
|
|
1118 | #if HAVE_SCHED_YIELD |
|
|
1119 | if (display->is_local) |
|
|
1120 | event_handler.cw_yield.start (); |
|
|
1121 | #endif |
|
|
1122 | } |
|
|
1123 | else |
1095 | { |
1124 | { |
1096 | pty_ev.stop (); |
1125 | pty_ev.stop (); |
1097 | |
1126 | |
1098 | if (!OPTION (Opt_hold)) |
1127 | if (!OPTION (Opt_hold)) |
1099 | destroy (); |
1128 | destroy (); |
… | |
… | |
1672 | { |
1701 | { |
1673 | if (!focus) |
1702 | if (!focus) |
1674 | { |
1703 | { |
1675 | focus = 1; |
1704 | focus = 1; |
1676 | want_refresh = 1; |
1705 | want_refresh = 1; |
|
|
1706 | |
|
|
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1708 | |
1677 | #if USE_XIM |
1709 | #if USE_XIM |
1678 | if (Input_Context != NULL) |
1710 | if (Input_Context != NULL) |
1679 | { |
1711 | { |
1680 | IMSetStatusPosition (); |
1712 | IMSetStatusPosition (); |
1681 | XSetICFocus (Input_Context); |
1713 | XSetICFocus (Input_Context); |
… | |
… | |
1701 | if (focus) |
1733 | if (focus) |
1702 | { |
1734 | { |
1703 | focus = 0; |
1735 | focus = 0; |
1704 | want_refresh = 1; |
1736 | want_refresh = 1; |
1705 | |
1737 | |
|
|
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1739 | |
1706 | #if ENABLE_FRILLS || ISO_14755 |
1740 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1741 | if (iso14755buf) |
|
|
1742 | { |
1707 | iso14755buf = 0; |
1743 | iso14755buf = 0; |
1708 | #endif |
|
|
1709 | #if ENABLE_OVERLAY |
1744 | # if ENABLE_OVERLAY |
1710 | scr_overlay_off (); |
1745 | scr_overlay_off (); |
|
|
1746 | # endif |
|
|
1747 | } |
1711 | #endif |
1748 | #endif |
1712 | #if USE_XIM |
1749 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1750 | if (Input_Context != NULL) |
1714 | XUnsetICFocus (Input_Context); |
1751 | XUnsetICFocus (Input_Context); |
1715 | #endif |
1752 | #endif |
… | |
… | |
1759 | rxvt_term::button_press (XButtonEvent &ev) |
1796 | rxvt_term::button_press (XButtonEvent &ev) |
1760 | { |
1797 | { |
1761 | int reportmode = 0, clickintime; |
1798 | int reportmode = 0, clickintime; |
1762 | |
1799 | |
1763 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1800 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1801 | |
1764 | if (!bypass_keystate) |
1802 | if (!bypass_keystate) |
1765 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1803 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1766 | |
1804 | |
1767 | /* |
1805 | /* |
1768 | * VT window processing of button press |
1806 | * VT window processing of button press |
… | |
… | |
1817 | else |
1855 | else |
1818 | { |
1856 | { |
1819 | if (ev.button != MEvent.button) |
1857 | if (ev.button != MEvent.button) |
1820 | MEvent.clicks = 0; |
1858 | MEvent.clicks = 0; |
1821 | |
1859 | |
|
|
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1822 | switch (ev.button) |
1861 | switch (ev.button) |
1823 | { |
1862 | { |
1824 | case Button1: |
1863 | case Button1: |
1825 | /* allow meta + click to select rectangular areas */ |
1864 | /* allow meta + click to select rectangular areas */ |
1826 | /* should be done in screen.C */ |
1865 | /* should be done in screen.C */ |
1827 | #if ENABLE_FRILLS |
1866 | #if ENABLE_FRILLS |
1828 | selection.rect = !!(ev.state & ModMetaMask); |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1829 | #else |
1868 | #else |
1830 | selection.rect = false; |
1869 | selection.rect = false; |
1831 | #endif |
1870 | #endif |
1832 | |
1871 | |
1833 | /* allow shift+left click to extend selection */ |
1872 | /* allow shift+left click to extend selection */ |
1834 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1835 | { |
1874 | { |
1836 | if (MEvent.button == Button1 && clickintime) |
1875 | if (MEvent.button == Button1 && clickintime) |
1837 | selection_rotate (ev.x, ev.y); |
1876 | selection_rotate (ev.x, ev.y); |
1838 | else |
1877 | else |
1839 | selection_extend (ev.x, ev.y, 1); |
1878 | selection_extend (ev.x, ev.y, 1); |
1840 | } |
1879 | } |
1841 | else |
1880 | else |
1842 | { |
1881 | { |
1843 | if (MEvent.button == Button1 && clickintime) |
1882 | if (MEvent.button == Button1 && clickintime) |
1844 | MEvent.clicks++; |
1883 | MEvent.clicks++; |
1845 | else |
1884 | else |
1846 | MEvent.clicks = 1; |
1885 | MEvent.clicks = 1; |
1847 | |
1886 | |
1848 | selection_click (MEvent.clicks, ev.x, ev.y); |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1849 | } |
1888 | } |
1850 | |
1889 | |
1851 | MEvent.button = Button1; |
1890 | MEvent.button = Button1; |
1852 | break; |
1891 | break; |
1853 | |
1892 | |
1854 | case Button3: |
1893 | case Button3: |
1855 | if (MEvent.button == Button3 && clickintime) |
1894 | if (MEvent.button == Button3 && clickintime) |
1856 | selection_rotate (ev.x, ev.y); |
1895 | selection_rotate (ev.x, ev.y); |
1857 | else |
1896 | else |
1858 | selection_extend (ev.x, ev.y, 1); |
1897 | selection_extend (ev.x, ev.y, 1); |
1859 | |
1898 | |
1860 | MEvent.button = Button3; |
1899 | MEvent.button = Button3; |
1861 | break; |
1900 | break; |
1862 | } |
1901 | } |
1863 | } |
1902 | } |
1864 | |
1903 | |
1865 | MEvent.time = ev.time; |
1904 | MEvent.time = ev.time; |
1866 | return; |
1905 | return; |
1867 | } |
1906 | } |
1868 | |
1907 | |
… | |
… | |
2632 | bool |
2671 | bool |
2633 | rxvt_term::cmd_parse () |
2672 | rxvt_term::cmd_parse () |
2634 | { |
2673 | { |
2635 | bool flag = false; |
2674 | bool flag = false; |
2636 | unicode_t ch = NOCHAR; |
2675 | unicode_t ch = NOCHAR; |
2637 | unsigned char *seq_begin; // remember start of esc-sequence here |
2676 | char *seq_begin; // remember start of esc-sequence here |
2638 | |
2677 | |
2639 | for (;;) |
2678 | for (;;) |
2640 | { |
2679 | { |
2641 | if (ch == NOCHAR) |
2680 | if (ch == NOCHAR) |
2642 | { |
2681 | { |
… | |
… | |
2686 | |
2725 | |
2687 | if (!OPTION (Opt_jumpScroll) |
2726 | if (!OPTION (Opt_jumpScroll) |
2688 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2727 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2689 | { |
2728 | { |
2690 | refreshnow = true; |
2729 | refreshnow = true; |
|
|
2730 | refresh_count = 0; |
2691 | ch = NOCHAR; |
2731 | ch = NOCHAR; |
2692 | break; |
2732 | break; |
2693 | } |
2733 | } |
2694 | |
2734 | |
2695 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
… | |
… | |
2732 | refresh_limit++; |
2772 | refresh_limit++; |
2733 | else |
2773 | else |
2734 | { |
2774 | { |
2735 | flag = true; |
2775 | flag = true; |
2736 | scr_refresh (refresh_type); |
2776 | scr_refresh (refresh_type); |
|
|
2777 | flush_ev.stop (); |
2737 | } |
2778 | } |
2738 | } |
2779 | } |
2739 | |
2780 | |
2740 | } |
2781 | } |
2741 | else |
2782 | else |
… | |
… | |
2772 | rxvt_term::next_char () |
2813 | rxvt_term::next_char () |
2773 | { |
2814 | { |
2774 | while (cmdbuf_ptr < cmdbuf_endp) |
2815 | while (cmdbuf_ptr < cmdbuf_endp) |
2775 | { |
2816 | { |
2776 | // assume 7-bit to be ascii ALWAYS |
2817 | // assume 7-bit to be ascii ALWAYS |
2777 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2818 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2778 | return *cmdbuf_ptr++; |
2819 | return *cmdbuf_ptr++; |
2779 | |
2820 | |
2780 | wchar_t wc; |
2821 | wchar_t wc; |
2781 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2822 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2782 | |
2823 | |
2783 | if (len == (size_t)-2) |
2824 | if (len == (size_t)-2) |
2784 | { |
2825 | { |
2785 | // the mbstate stores incomplete sequences. didn't know this :/ |
2826 | // the mbstate stores incomplete sequences. didn't know this :/ |
2786 | cmdbuf_ptr = cmdbuf_endp; |
2827 | cmdbuf_ptr = cmdbuf_endp; |
… | |
… | |
2925 | case C0_ESC: |
2966 | case C0_ESC: |
2926 | process_escape_seq (); |
2967 | process_escape_seq (); |
2927 | break; |
2968 | break; |
2928 | case C0_ENQ: /* terminal Status */ |
2969 | case C0_ENQ: /* terminal Status */ |
2929 | if (rs[Rs_answerbackstring]) |
2970 | if (rs[Rs_answerbackstring]) |
2930 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2971 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2931 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2932 | else |
2972 | else |
2933 | tt_write ((unsigned char *)VT100_ANS, |
2973 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2934 | (unsigned int)strlen (VT100_ANS)); |
|
|
2935 | break; |
2974 | break; |
2936 | case C0_BEL: /* bell */ |
2975 | case C0_BEL: /* bell */ |
2937 | scr_bell (); |
2976 | scr_bell (); |
2938 | break; |
2977 | break; |
2939 | case C0_BS: /* backspace */ |
2978 | case C0_BS: /* backspace */ |
… | |
… | |
3127 | process_dcs_seq (); |
3166 | process_dcs_seq (); |
3128 | break; |
3167 | break; |
3129 | |
3168 | |
3130 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3169 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3131 | case C1_SCI: /* ESC Z */ |
3170 | case C1_SCI: /* ESC Z */ |
3132 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3171 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3133 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3134 | break; /* steal obsolete ESC [ c */ |
3172 | break; /* steal obsolete ESC [ c */ |
3135 | |
3173 | |
3136 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3174 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3137 | case C1_CSI: /* ESC [ */ |
3175 | case C1_CSI: /* ESC [ */ |
3138 | process_csi_seq (); |
3176 | process_csi_seq (); |
… | |
… | |
3382 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3420 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3383 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3421 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3384 | break; |
3422 | break; |
3385 | |
3423 | |
3386 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3424 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3387 | tt_write ((const unsigned char *)VT100_ANS, |
3425 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3388 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3389 | break; |
3426 | break; |
3390 | |
3427 | |
3391 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3428 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3392 | process_sgr_mode (nargs, arg); |
3429 | process_sgr_mode (nargs, arg); |
3393 | break; |
3430 | break; |
… | |
… | |
3595 | /*----------------------------------------------------------------------*/ |
3632 | /*----------------------------------------------------------------------*/ |
3596 | /* |
3633 | /* |
3597 | * get input up until STRING TERMINATOR (or BEL) |
3634 | * get input up until STRING TERMINATOR (or BEL) |
3598 | * ends_how is terminator used. returned input must be free()'d |
3635 | * ends_how is terminator used. returned input must be free()'d |
3599 | */ |
3636 | */ |
3600 | unsigned char * |
3637 | char * |
3601 | rxvt_term::get_to_st (unicode_t &ends_how) |
3638 | rxvt_term::get_to_st (unicode_t &ends_how) |
3602 | { |
3639 | { |
3603 | unicode_t ch; |
3640 | unicode_t ch; |
3604 | bool seen_esc = false; |
3641 | bool seen_esc = false; |
3605 | unsigned int n = 0; |
3642 | unsigned int n = 0; |
… | |
… | |
3638 | |
3675 | |
3639 | string[n++] = '\0'; |
3676 | string[n++] = '\0'; |
3640 | |
3677 | |
3641 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3678 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3642 | |
3679 | |
3643 | return (unsigned char *)rxvt_wcstombs (string); |
3680 | return rxvt_wcstombs (string); |
3644 | } |
3681 | } |
3645 | |
3682 | |
3646 | /*----------------------------------------------------------------------*/ |
3683 | /*----------------------------------------------------------------------*/ |
3647 | /* |
3684 | /* |
3648 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3685 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3649 | */ |
3686 | */ |
3650 | void |
3687 | void |
3651 | rxvt_term::process_dcs_seq () |
3688 | rxvt_term::process_dcs_seq () |
3652 | { |
3689 | { |
3653 | unsigned char *s; |
3690 | char *s; |
3654 | unicode_t eh; |
3691 | unicode_t eh; |
3655 | |
3692 | |
3656 | /* |
3693 | /* |
3657 | * Not handled yet |
3694 | * Not handled yet |
3658 | */ |
3695 | */ |
… | |
… | |
3677 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3714 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3678 | arg = arg * 10 + (ch - '0'); |
3715 | arg = arg * 10 + (ch - '0'); |
3679 | |
3716 | |
3680 | if (ch == ';') |
3717 | if (ch == ';') |
3681 | { |
3718 | { |
3682 | unsigned char *s = get_to_st (eh); |
3719 | char *s = get_to_st (eh); |
3683 | |
3720 | |
3684 | if (s) |
3721 | if (s) |
3685 | { |
3722 | { |
3686 | process_xterm_seq (arg, (char *)s, eh); |
3723 | process_xterm_seq (arg, s, eh); |
3687 | free (s); |
3724 | free (s); |
3688 | } |
3725 | } |
3689 | } |
3726 | } |
3690 | } |
3727 | } |
3691 | |
3728 | |
3692 | void |
3729 | void |
3693 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3730 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3694 | { |
3731 | { |
3695 | if (str[0] == '?' && !str[1]) |
3732 | if (str[0] == '?' && !str[1]) |
3696 | { |
3733 | { |
3697 | unsigned short r, g, b; |
3734 | unsigned short r, g, b; |
3698 | pix_colors_focused[color].get (display, r, g, b); |
3735 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3704 | |
3741 | |
3705 | /* |
3742 | /* |
3706 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3743 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3707 | */ |
3744 | */ |
3708 | void |
3745 | void |
3709 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3746 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3710 | { |
3747 | { |
3711 | int changed = 0; |
3748 | int changed = 0; |
3712 | int color; |
3749 | int color; |
3713 | char *buf, *name; |
3750 | char *buf, *name; |
3714 | bool query = str[0] == '?' && !str[1]; |
3751 | bool query = str[0] == '?' && !str[1]; |
… | |
… | |
3921 | } |
3958 | } |
3922 | break; |
3959 | break; |
3923 | |
3960 | |
3924 | case URxvt_view_up: |
3961 | case URxvt_view_up: |
3925 | case URxvt_view_down: |
3962 | case URxvt_view_down: |
|
|
3963 | { |
3926 | int lines = atoi (str); |
3964 | int lines = atoi (str); |
3927 | |
3965 | |
3928 | if (lines) |
3966 | if (lines) |
3929 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3967 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3930 | else |
3968 | else |
3931 | { |
|
|
3932 | scr_erase_savelines (); |
3969 | scr_erase_savelines (); |
3933 | } |
3970 | } |
3934 | |
3971 | |
|
|
3972 | break; |
|
|
3973 | #endif |
|
|
3974 | |
|
|
3975 | #if ENABLE_PERL |
|
|
3976 | case URxvt_perl: |
|
|
3977 | if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
|
|
3978 | ; // no responses yet |
3935 | break; |
3979 | break; |
3936 | #endif |
3980 | #endif |
3937 | } |
3981 | } |
3938 | } |
3982 | } |
3939 | /*----------------------------------------------------------------------*/ |
3983 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4048 | } |
4092 | } |
4049 | |
4093 | |
4050 | /* extra handling for values with state unkept */ |
4094 | /* extra handling for values with state unkept */ |
4051 | switch (arg[i]) |
4095 | switch (arg[i]) |
4052 | { |
4096 | { |
|
|
4097 | #if ENABLE_STYLES |
|
|
4098 | case 1021: |
|
|
4099 | if (mode) |
|
|
4100 | SET_OPTION (Opt_intensityStyles); |
|
|
4101 | else |
|
|
4102 | CLR_OPTION (Opt_intensityStyles); |
|
|
4103 | |
|
|
4104 | scr_touch (true); |
|
|
4105 | break; |
|
|
4106 | #endif |
4053 | case 1048: /* alternative cursor save */ |
4107 | case 1048: /* alternative cursor save */ |
4054 | case 1049: |
4108 | case 1049: |
4055 | if (OPTION (Opt_secondaryScreen)) |
4109 | if (OPTION (Opt_secondaryScreen)) |
4056 | if (mode == 0) |
4110 | if (mode == 0) |
4057 | scr_cursor (RESTORE); |
4111 | scr_cursor (RESTORE); |
… | |
… | |
4140 | if (state) |
4194 | if (state) |
4141 | SET_OPTION (Opt_scrollTtyKeypress); |
4195 | SET_OPTION (Opt_scrollTtyKeypress); |
4142 | else |
4196 | else |
4143 | CLR_OPTION (Opt_scrollTtyKeypress); |
4197 | CLR_OPTION (Opt_scrollTtyKeypress); |
4144 | break; |
4198 | break; |
4145 | #if ENABLE_STYLES |
|
|
4146 | case 1021: |
|
|
4147 | if (state) |
|
|
4148 | SET_OPTION (Opt_intensityStyles); |
|
|
4149 | else |
|
|
4150 | CLR_OPTION (Opt_intensityStyles); |
|
|
4151 | #endif |
|
|
4152 | case 1047: /* secondary screen w/ clearing last */ |
4199 | case 1047: /* secondary screen w/ clearing last */ |
4153 | if (OPTION (Opt_secondaryScreen)) |
4200 | if (OPTION (Opt_secondaryScreen)) |
4154 | if (current_screen != PRIMARY) |
4201 | if (current_screen != PRIMARY) |
4155 | scr_erase_screen (2); |
4202 | scr_erase_screen (2); |
4156 | scr_change_screen (state); |
4203 | scr_change_screen (state); |
… | |
… | |
4315 | case 106: |
4362 | case 106: |
4316 | case 107: |
4363 | case 107: |
4317 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4364 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4318 | break; |
4365 | break; |
4319 | #endif |
4366 | #endif |
4320 | |
|
|
4321 | } |
4367 | } |
4322 | } |
4368 | } |
4323 | } |
4369 | } |
4324 | /*}}} */ |
4370 | /*}}} */ |
4325 | |
4371 | |
… | |
… | |
4349 | */ |
4395 | */ |
4350 | void |
4396 | void |
4351 | rxvt_term::tt_printf (const char *fmt,...) |
4397 | rxvt_term::tt_printf (const char *fmt,...) |
4352 | { |
4398 | { |
4353 | va_list arg_ptr; |
4399 | va_list arg_ptr; |
4354 | unsigned char buf[256]; |
4400 | char buf[256]; |
4355 | |
4401 | |
4356 | va_start (arg_ptr, fmt); |
4402 | va_start (arg_ptr, fmt); |
4357 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4403 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4358 | va_end (arg_ptr); |
4404 | va_end (arg_ptr); |
4359 | tt_write (buf, strlen (buf)); |
4405 | tt_write (buf, strlen (buf)); |
… | |
… | |
4364 | * or generated by us in response to a query ESC sequence. |
4410 | * or generated by us in response to a query ESC sequence. |
4365 | */ |
4411 | */ |
4366 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4412 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4367 | |
4413 | |
4368 | void |
4414 | void |
4369 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4415 | rxvt_term::tt_write (const char *data, unsigned int len) |
4370 | { |
4416 | { |
4371 | if (v_buflen == 0) |
4417 | if (v_buflen == 0) |
4372 | { |
4418 | { |
4373 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4419 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4374 | |
4420 | |
… | |
… | |
4377 | |
4423 | |
4378 | data += written; |
4424 | data += written; |
4379 | len -= written; |
4425 | len -= written; |
4380 | } |
4426 | } |
4381 | |
4427 | |
4382 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4428 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4383 | |
4429 | |
4384 | memcpy (v_buffer + v_buflen, data, len); |
4430 | memcpy (v_buffer + v_buflen, data, len); |
4385 | v_buflen += len; |
4431 | v_buflen += len; |
4386 | |
4432 | |
4387 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4433 | pty_ev.set (EVENT_READ | EVENT_WRITE); |