… | |
… | |
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 | |
… | |
… | |
262 | mb[0] = ch[0]; |
268 | mb[0] = ch[0]; |
263 | len = 1; |
269 | len = 1; |
264 | } |
270 | } |
265 | |
271 | |
266 | if (len > 0) |
272 | if (len > 0) |
267 | tt_write ((unsigned char *)mb, len); |
273 | tt_write (mb, len); |
268 | else |
274 | else |
269 | scr_bell (); |
275 | scr_bell (); |
270 | } |
276 | } |
271 | |
277 | |
272 | iso14755buf = 0; |
278 | iso14755buf = 0; |
… | |
… | |
300 | KeySym keysym; |
306 | KeySym keysym; |
301 | #ifdef DEBUG_CMD |
307 | #ifdef DEBUG_CMD |
302 | static int debug_key = 1; /* accessible by a debugger only */ |
308 | static int debug_key = 1; /* accessible by a debugger only */ |
303 | #endif |
309 | #endif |
304 | int valid_keysym; |
310 | int valid_keysym; |
305 | unsigned char kbuf[KBUFSZ]; |
311 | char kbuf[KBUFSZ]; |
306 | |
312 | |
307 | /* |
313 | /* |
308 | * 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 |
309 | * escape sequence to toggle the Keypad. |
315 | * escape sequence to toggle the Keypad. |
310 | * |
316 | * |
… | |
… | |
328 | Status status_return; |
334 | Status status_return; |
329 | |
335 | |
330 | #if 0 |
336 | #if 0 |
331 | #ifdef X_HAVE_UTF8_STRING |
337 | #ifdef X_HAVE_UTF8_STRING |
332 | 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 |
333 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
339 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
334 | KBUFSZ, &keysym, &status_return); |
340 | KBUFSZ, &keysym, &status_return); |
335 | else |
341 | else |
336 | #endif |
342 | #endif |
337 | #endif |
343 | #endif |
338 | { |
344 | { |
… | |
… | |
375 | || status_return == XLookupBoth; |
381 | || status_return == XLookupBoth; |
376 | } |
382 | } |
377 | else |
383 | else |
378 | #endif |
384 | #endif |
379 | { |
385 | { |
380 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
386 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
381 | valid_keysym = keysym != NoSymbol; |
387 | valid_keysym = keysym != NoSymbol; |
382 | } |
388 | } |
383 | |
389 | |
384 | if (valid_keysym) |
390 | if (valid_keysym) |
385 | { |
391 | { |
… | |
… | |
849 | { |
855 | { |
850 | #ifdef META8_OPTION |
856 | #ifdef META8_OPTION |
851 | /* set 8-bit on */ |
857 | /* set 8-bit on */ |
852 | if (meta && (meta_char == 0x80)) |
858 | if (meta && (meta_char == 0x80)) |
853 | { |
859 | { |
854 | unsigned char *ch; |
860 | char *ch; |
855 | |
861 | |
856 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
857 | *ch |= 0x80; |
863 | *ch |= 0x80; |
858 | |
864 | |
859 | meta = 0; |
865 | meta = 0; |
… | |
… | |
892 | #ifdef META8_OPTION |
898 | #ifdef META8_OPTION |
893 | && meta_char == C0_ESC |
899 | && meta_char == C0_ESC |
894 | #endif |
900 | #endif |
895 | ) |
901 | ) |
896 | { |
902 | { |
897 | const unsigned char ch = C0_ESC; |
903 | const char ch = C0_ESC; |
898 | tt_write (&ch, 1); |
904 | tt_write (&ch, 1); |
899 | } |
905 | } |
900 | |
906 | |
901 | #if defined(DEBUG_CMD) |
907 | #if defined(DEBUG_CMD) |
902 | /* Display keyboard buffer contents */ |
908 | /* Display keyboard buffer contents */ |
… | |
… | |
914 | |
920 | |
915 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
921 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
916 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
922 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
917 | /* attempt to `write' count to the input buffer */ |
923 | /* attempt to `write' count to the input buffer */ |
918 | unsigned int |
924 | unsigned int |
919 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
925 | rxvt_term::cmd_write (const char *str, unsigned int count) |
920 | { |
926 | { |
921 | unsigned int n, s; |
927 | unsigned int n, s; |
922 | |
928 | |
923 | n = cmdbuf_ptr - cmdbuf_base; |
929 | n = cmdbuf_ptr - cmdbuf_base; |
924 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
930 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
980 | SET_LOCALE (locale); |
986 | SET_LOCALE (locale); |
981 | |
987 | |
982 | display->flush (); |
988 | display->flush (); |
983 | |
989 | |
984 | if (want_refresh && !flush_ev.active) |
990 | if (want_refresh && !flush_ev.active) |
985 | flush_ev.start (NOW + 0.01); |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
986 | } |
992 | } |
987 | |
993 | |
988 | void |
994 | void |
989 | rxvt_term::flush_cb (time_watcher &w) |
995 | rxvt_term::flush_cb (time_watcher &w) |
990 | { |
996 | { |
… | |
… | |
1065 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1066 | } |
1072 | } |
1067 | } |
1073 | } |
1068 | #endif |
1074 | #endif |
1069 | |
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 | |
1070 | bool |
1094 | bool |
1071 | rxvt_term::pty_fill () |
1095 | rxvt_term::pty_fill () |
1072 | { |
1096 | { |
1073 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1074 | |
1098 | |
1075 | if (CBUFSIZ == n) |
1099 | if (CBUFSIZ == n) |
1076 | { |
1100 | { |
1077 | 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"); |
1078 | n = 0; |
1102 | n = 0; |
1079 | } |
1103 | } |
1080 | |
1104 | |
1081 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1082 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_ptr = cmdbuf_base; |
1083 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | cmdbuf_endp = cmdbuf_ptr + n; |
1084 | |
1108 | |
1085 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1086 | |
1110 | |
1087 | if (n > 0) |
1111 | if (r > 0) |
1088 | { |
1112 | { |
1089 | cmdbuf_endp += n; |
1113 | cmdbuf_endp += r; |
1090 | return true; |
1114 | return true; |
1091 | } |
1115 | } |
1092 | 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 |
1093 | { |
1124 | { |
1094 | pty_ev.stop (); |
1125 | pty_ev.stop (); |
1095 | |
1126 | |
1096 | if (!OPTION (Opt_hold)) |
1127 | if (!OPTION (Opt_hold)) |
1097 | destroy (); |
1128 | destroy (); |
… | |
… | |
1670 | { |
1701 | { |
1671 | if (!focus) |
1702 | if (!focus) |
1672 | { |
1703 | { |
1673 | focus = 1; |
1704 | focus = 1; |
1674 | want_refresh = 1; |
1705 | want_refresh = 1; |
|
|
1706 | |
|
|
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1708 | |
1675 | #if USE_XIM |
1709 | #if USE_XIM |
1676 | if (Input_Context != NULL) |
1710 | if (Input_Context != NULL) |
1677 | { |
1711 | { |
1678 | IMSetStatusPosition (); |
1712 | IMSetStatusPosition (); |
1679 | XSetICFocus (Input_Context); |
1713 | XSetICFocus (Input_Context); |
… | |
… | |
1699 | if (focus) |
1733 | if (focus) |
1700 | { |
1734 | { |
1701 | focus = 0; |
1735 | focus = 0; |
1702 | want_refresh = 1; |
1736 | want_refresh = 1; |
1703 | |
1737 | |
|
|
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1739 | |
1704 | #if ENABLE_FRILLS || ISO_14755 |
1740 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1741 | if (iso14755buf) |
|
|
1742 | { |
1705 | iso14755buf = 0; |
1743 | iso14755buf = 0; |
1706 | #endif |
|
|
1707 | #if ENABLE_OVERLAY |
1744 | # if ENABLE_OVERLAY |
1708 | scr_overlay_off (); |
1745 | scr_overlay_off (); |
|
|
1746 | # endif |
|
|
1747 | } |
1709 | #endif |
1748 | #endif |
1710 | #if USE_XIM |
1749 | #if USE_XIM |
1711 | if (Input_Context != NULL) |
1750 | if (Input_Context != NULL) |
1712 | XUnsetICFocus (Input_Context); |
1751 | XUnsetICFocus (Input_Context); |
1713 | #endif |
1752 | #endif |
… | |
… | |
1757 | rxvt_term::button_press (XButtonEvent &ev) |
1796 | rxvt_term::button_press (XButtonEvent &ev) |
1758 | { |
1797 | { |
1759 | int reportmode = 0, clickintime; |
1798 | int reportmode = 0, clickintime; |
1760 | |
1799 | |
1761 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1800 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1801 | |
1762 | if (!bypass_keystate) |
1802 | if (!bypass_keystate) |
1763 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1803 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1764 | |
1804 | |
1765 | /* |
1805 | /* |
1766 | * VT window processing of button press |
1806 | * VT window processing of button press |
… | |
… | |
1815 | else |
1855 | else |
1816 | { |
1856 | { |
1817 | if (ev.button != MEvent.button) |
1857 | if (ev.button != MEvent.button) |
1818 | MEvent.clicks = 0; |
1858 | MEvent.clicks = 0; |
1819 | |
1859 | |
|
|
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1820 | switch (ev.button) |
1861 | switch (ev.button) |
1821 | { |
1862 | { |
1822 | case Button1: |
1863 | case Button1: |
1823 | /* allow meta + click to select rectangular areas */ |
1864 | /* allow meta + click to select rectangular areas */ |
1824 | /* should be done in screen.C */ |
1865 | /* should be done in screen.C */ |
1825 | #if ENABLE_FRILLS |
1866 | #if ENABLE_FRILLS |
1826 | selection.rect = !!(ev.state & ModMetaMask); |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1827 | #else |
1868 | #else |
1828 | selection.rect = false; |
1869 | selection.rect = false; |
1829 | #endif |
1870 | #endif |
1830 | |
1871 | |
1831 | /* allow shift+left click to extend selection */ |
1872 | /* allow shift+left click to extend selection */ |
1832 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1833 | { |
1874 | { |
1834 | if (MEvent.button == Button1 && clickintime) |
1875 | if (MEvent.button == Button1 && clickintime) |
1835 | selection_rotate (ev.x, ev.y); |
1876 | selection_rotate (ev.x, ev.y); |
1836 | else |
1877 | else |
1837 | selection_extend (ev.x, ev.y, 1); |
1878 | selection_extend (ev.x, ev.y, 1); |
1838 | } |
1879 | } |
1839 | else |
1880 | else |
1840 | { |
1881 | { |
1841 | if (MEvent.button == Button1 && clickintime) |
1882 | if (MEvent.button == Button1 && clickintime) |
1842 | MEvent.clicks++; |
1883 | MEvent.clicks++; |
1843 | else |
1884 | else |
1844 | MEvent.clicks = 1; |
1885 | MEvent.clicks = 1; |
1845 | |
1886 | |
1846 | selection_click (MEvent.clicks, ev.x, ev.y); |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1847 | } |
1888 | } |
1848 | |
1889 | |
1849 | MEvent.button = Button1; |
1890 | MEvent.button = Button1; |
1850 | break; |
1891 | break; |
1851 | |
1892 | |
1852 | case Button3: |
1893 | case Button3: |
1853 | if (MEvent.button == Button3 && clickintime) |
1894 | if (MEvent.button == Button3 && clickintime) |
1854 | selection_rotate (ev.x, ev.y); |
1895 | selection_rotate (ev.x, ev.y); |
1855 | else |
1896 | else |
1856 | selection_extend (ev.x, ev.y, 1); |
1897 | selection_extend (ev.x, ev.y, 1); |
1857 | |
1898 | |
1858 | MEvent.button = Button3; |
1899 | MEvent.button = Button3; |
1859 | break; |
1900 | break; |
1860 | } |
1901 | } |
1861 | } |
1902 | } |
1862 | |
1903 | |
1863 | MEvent.time = ev.time; |
1904 | MEvent.time = ev.time; |
1864 | return; |
1905 | return; |
1865 | } |
1906 | } |
1866 | |
1907 | |
… | |
… | |
2630 | bool |
2671 | bool |
2631 | rxvt_term::cmd_parse () |
2672 | rxvt_term::cmd_parse () |
2632 | { |
2673 | { |
2633 | bool flag = false; |
2674 | bool flag = false; |
2634 | unicode_t ch = NOCHAR; |
2675 | unicode_t ch = NOCHAR; |
2635 | unsigned char *seq_begin; // remember start of esc-sequence here |
2676 | char *seq_begin; // remember start of esc-sequence here |
2636 | |
2677 | |
2637 | for (;;) |
2678 | for (;;) |
2638 | { |
2679 | { |
2639 | if (ch == NOCHAR) |
2680 | if (ch == NOCHAR) |
2640 | { |
2681 | { |
… | |
… | |
2684 | |
2725 | |
2685 | if (!OPTION (Opt_jumpScroll) |
2726 | if (!OPTION (Opt_jumpScroll) |
2686 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2727 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2687 | { |
2728 | { |
2688 | refreshnow = true; |
2729 | refreshnow = true; |
|
|
2730 | refresh_count = 0; |
2689 | ch = NOCHAR; |
2731 | ch = NOCHAR; |
2690 | break; |
2732 | break; |
2691 | } |
2733 | } |
2692 | |
2734 | |
2693 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
2694 | if (nlines >= nrow - 1) |
2736 | if (nlines >= nrow - 1) |
2695 | { |
2737 | { |
|
|
2738 | if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2696 | scr_add_lines (buf, nlines, str - buf); |
2739 | scr_add_lines (buf, nlines, str - buf); |
|
|
2740 | |
2697 | nlines = 0; |
2741 | nlines = 0; |
2698 | str = buf; |
2742 | str = buf; |
2699 | eol = str + min (ncol, UBUFSIZ); |
2743 | eol = str + min (ncol, UBUFSIZ); |
2700 | } |
2744 | } |
2701 | |
2745 | |
… | |
… | |
2714 | |
2758 | |
2715 | seq_begin = cmdbuf_ptr; |
2759 | seq_begin = cmdbuf_ptr; |
2716 | ch = next_char (); |
2760 | ch = next_char (); |
2717 | } |
2761 | } |
2718 | |
2762 | |
|
|
2763 | if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2719 | scr_add_lines (buf, nlines, str - buf); |
2764 | scr_add_lines (buf, nlines, str - buf); |
2720 | |
2765 | |
2721 | /* |
2766 | /* |
2722 | * If there have been a lot of new lines, then update the screen |
2767 | * If there have been a lot of new lines, then update the screen |
2723 | * What the heck I'll cheat and only refresh less than every page-full. |
2768 | * What the heck I'll cheat and only refresh less than every page-full. |
2724 | * the number of pages between refreshes is refresh_limit, which |
2769 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2730 | refresh_limit++; |
2775 | refresh_limit++; |
2731 | else |
2776 | else |
2732 | { |
2777 | { |
2733 | flag = true; |
2778 | flag = true; |
2734 | scr_refresh (refresh_type); |
2779 | scr_refresh (refresh_type); |
|
|
2780 | flush_ev.stop (); |
2735 | } |
2781 | } |
2736 | } |
2782 | } |
2737 | |
2783 | |
2738 | } |
2784 | } |
2739 | else |
2785 | else |
… | |
… | |
2770 | rxvt_term::next_char () |
2816 | rxvt_term::next_char () |
2771 | { |
2817 | { |
2772 | while (cmdbuf_ptr < cmdbuf_endp) |
2818 | while (cmdbuf_ptr < cmdbuf_endp) |
2773 | { |
2819 | { |
2774 | // assume 7-bit to be ascii ALWAYS |
2820 | // assume 7-bit to be ascii ALWAYS |
2775 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2821 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2776 | return *cmdbuf_ptr++; |
2822 | return *cmdbuf_ptr++; |
2777 | |
2823 | |
2778 | wchar_t wc; |
2824 | wchar_t wc; |
2779 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2825 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2780 | |
2826 | |
2781 | if (len == (size_t)-2) |
2827 | if (len == (size_t)-2) |
2782 | { |
2828 | { |
2783 | // the mbstate stores incomplete sequences. didn't know this :/ |
2829 | // the mbstate stores incomplete sequences. didn't know this :/ |
2784 | cmdbuf_ptr = cmdbuf_endp; |
2830 | cmdbuf_ptr = cmdbuf_endp; |
… | |
… | |
2923 | case C0_ESC: |
2969 | case C0_ESC: |
2924 | process_escape_seq (); |
2970 | process_escape_seq (); |
2925 | break; |
2971 | break; |
2926 | case C0_ENQ: /* terminal Status */ |
2972 | case C0_ENQ: /* terminal Status */ |
2927 | if (rs[Rs_answerbackstring]) |
2973 | if (rs[Rs_answerbackstring]) |
2928 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2974 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2929 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2930 | else |
2975 | else |
2931 | tt_write ((unsigned char *)VT100_ANS, |
2976 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2932 | (unsigned int)strlen (VT100_ANS)); |
|
|
2933 | break; |
2977 | break; |
2934 | case C0_BEL: /* bell */ |
2978 | case C0_BEL: /* bell */ |
2935 | scr_bell (); |
2979 | scr_bell (); |
2936 | break; |
2980 | break; |
2937 | case C0_BS: /* backspace */ |
2981 | case C0_BS: /* backspace */ |
… | |
… | |
3125 | process_dcs_seq (); |
3169 | process_dcs_seq (); |
3126 | break; |
3170 | break; |
3127 | |
3171 | |
3128 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3172 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3129 | case C1_SCI: /* ESC Z */ |
3173 | case C1_SCI: /* ESC Z */ |
3130 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3174 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3131 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3132 | break; /* steal obsolete ESC [ c */ |
3175 | break; /* steal obsolete ESC [ c */ |
3133 | |
3176 | |
3134 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3177 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3135 | case C1_CSI: /* ESC [ */ |
3178 | case C1_CSI: /* ESC [ */ |
3136 | process_csi_seq (); |
3179 | process_csi_seq (); |
… | |
… | |
3380 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3423 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3381 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3424 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3382 | break; |
3425 | break; |
3383 | |
3426 | |
3384 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3427 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3385 | tt_write ((const unsigned char *)VT100_ANS, |
3428 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3386 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3387 | break; |
3429 | break; |
3388 | |
3430 | |
3389 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3431 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3390 | process_sgr_mode (nargs, arg); |
3432 | process_sgr_mode (nargs, arg); |
3391 | break; |
3433 | break; |
… | |
… | |
3593 | /*----------------------------------------------------------------------*/ |
3635 | /*----------------------------------------------------------------------*/ |
3594 | /* |
3636 | /* |
3595 | * get input up until STRING TERMINATOR (or BEL) |
3637 | * get input up until STRING TERMINATOR (or BEL) |
3596 | * ends_how is terminator used. returned input must be free()'d |
3638 | * ends_how is terminator used. returned input must be free()'d |
3597 | */ |
3639 | */ |
3598 | unsigned char * |
3640 | char * |
3599 | rxvt_term::get_to_st (unicode_t &ends_how) |
3641 | rxvt_term::get_to_st (unicode_t &ends_how) |
3600 | { |
3642 | { |
3601 | unicode_t ch; |
3643 | unicode_t ch; |
3602 | bool seen_esc = false; |
3644 | bool seen_esc = false; |
3603 | unsigned int n = 0; |
3645 | unsigned int n = 0; |
… | |
… | |
3636 | |
3678 | |
3637 | string[n++] = '\0'; |
3679 | string[n++] = '\0'; |
3638 | |
3680 | |
3639 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3681 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3640 | |
3682 | |
3641 | return (unsigned char *)rxvt_wcstombs (string); |
3683 | return rxvt_wcstombs (string); |
3642 | } |
3684 | } |
3643 | |
3685 | |
3644 | /*----------------------------------------------------------------------*/ |
3686 | /*----------------------------------------------------------------------*/ |
3645 | /* |
3687 | /* |
3646 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3688 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3647 | */ |
3689 | */ |
3648 | void |
3690 | void |
3649 | rxvt_term::process_dcs_seq () |
3691 | rxvt_term::process_dcs_seq () |
3650 | { |
3692 | { |
3651 | unsigned char *s; |
3693 | char *s; |
3652 | unicode_t eh; |
3694 | unicode_t eh; |
3653 | |
3695 | |
3654 | /* |
3696 | /* |
3655 | * Not handled yet |
3697 | * Not handled yet |
3656 | */ |
3698 | */ |
… | |
… | |
3675 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3717 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3676 | arg = arg * 10 + (ch - '0'); |
3718 | arg = arg * 10 + (ch - '0'); |
3677 | |
3719 | |
3678 | if (ch == ';') |
3720 | if (ch == ';') |
3679 | { |
3721 | { |
3680 | unsigned char *s = get_to_st (eh); |
3722 | char *s = get_to_st (eh); |
3681 | |
3723 | |
3682 | if (s) |
3724 | if (s) |
3683 | { |
3725 | { |
3684 | process_xterm_seq (arg, (char *)s, eh); |
3726 | process_xterm_seq (arg, s, eh); |
3685 | free (s); |
3727 | free (s); |
3686 | } |
3728 | } |
3687 | } |
3729 | } |
3688 | } |
3730 | } |
3689 | |
3731 | |
3690 | void |
3732 | void |
3691 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3733 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3692 | { |
3734 | { |
3693 | if (str[0] == '?' && !str[1]) |
3735 | if (str[0] == '?' && !str[1]) |
3694 | { |
3736 | { |
3695 | unsigned short r, g, b; |
3737 | unsigned short r, g, b; |
3696 | pix_colors_focused[color].get (display, r, g, b); |
3738 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3702 | |
3744 | |
3703 | /* |
3745 | /* |
3704 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3746 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3705 | */ |
3747 | */ |
3706 | void |
3748 | void |
3707 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3749 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3708 | { |
3750 | { |
3709 | int changed = 0; |
3751 | int changed = 0; |
3710 | int color; |
3752 | int color; |
3711 | char *buf, *name; |
3753 | char *buf, *name; |
3712 | bool query = str[0] == '?' && !str[1]; |
3754 | bool query = str[0] == '?' && !str[1]; |
… | |
… | |
3919 | } |
3961 | } |
3920 | break; |
3962 | break; |
3921 | |
3963 | |
3922 | case URxvt_view_up: |
3964 | case URxvt_view_up: |
3923 | case URxvt_view_down: |
3965 | case URxvt_view_down: |
|
|
3966 | { |
3924 | int lines = atoi (str); |
3967 | int lines = atoi (str); |
3925 | |
3968 | |
3926 | if (lines) |
3969 | if (lines) |
3927 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3970 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3928 | else |
3971 | else |
3929 | { |
|
|
3930 | scr_erase_savelines (); |
3972 | scr_erase_savelines (); |
3931 | } |
3973 | } |
3932 | |
3974 | |
|
|
3975 | break; |
|
|
3976 | #endif |
|
|
3977 | |
|
|
3978 | #if ENABLE_PERL |
|
|
3979 | case URxvt_perl: |
|
|
3980 | if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
|
|
3981 | ; // no responses yet |
3933 | break; |
3982 | break; |
3934 | #endif |
3983 | #endif |
3935 | } |
3984 | } |
3936 | } |
3985 | } |
3937 | /*----------------------------------------------------------------------*/ |
3986 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4053 | if (mode) |
4102 | if (mode) |
4054 | SET_OPTION (Opt_intensityStyles); |
4103 | SET_OPTION (Opt_intensityStyles); |
4055 | else |
4104 | else |
4056 | CLR_OPTION (Opt_intensityStyles); |
4105 | CLR_OPTION (Opt_intensityStyles); |
4057 | |
4106 | |
4058 | want_refresh = 1; |
4107 | scr_touch (true); |
4059 | want_full_refresh = 1; |
|
|
4060 | break; |
4108 | break; |
4061 | #endif |
4109 | #endif |
4062 | case 1048: /* alternative cursor save */ |
4110 | case 1048: /* alternative cursor save */ |
4063 | case 1049: |
4111 | case 1049: |
4064 | if (OPTION (Opt_secondaryScreen)) |
4112 | if (OPTION (Opt_secondaryScreen)) |
… | |
… | |
4295 | scr_color (Color_bg, Color_bg); |
4343 | scr_color (Color_bg, Color_bg); |
4296 | break; |
4344 | break; |
4297 | |
4345 | |
4298 | //case 50: // not variable spacing |
4346 | //case 50: // not variable spacing |
4299 | |
4347 | |
4300 | #ifndef NO_BRIGHTCOLOR |
4348 | #if ENABLE_FRILLS |
4301 | case 90: |
4349 | case 90: |
4302 | case 91: /* set bright fg color */ |
4350 | case 91: /* set bright fg color */ |
4303 | case 92: |
4351 | case 92: |
4304 | case 93: |
4352 | case 93: |
4305 | case 94: |
4353 | case 94: |
… | |
… | |
4350 | */ |
4398 | */ |
4351 | void |
4399 | void |
4352 | rxvt_term::tt_printf (const char *fmt,...) |
4400 | rxvt_term::tt_printf (const char *fmt,...) |
4353 | { |
4401 | { |
4354 | va_list arg_ptr; |
4402 | va_list arg_ptr; |
4355 | unsigned char buf[256]; |
4403 | char buf[256]; |
4356 | |
4404 | |
4357 | va_start (arg_ptr, fmt); |
4405 | va_start (arg_ptr, fmt); |
4358 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4406 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4359 | va_end (arg_ptr); |
4407 | va_end (arg_ptr); |
4360 | tt_write (buf, strlen (buf)); |
4408 | tt_write (buf, strlen (buf)); |
… | |
… | |
4365 | * or generated by us in response to a query ESC sequence. |
4413 | * or generated by us in response to a query ESC sequence. |
4366 | */ |
4414 | */ |
4367 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4415 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4368 | |
4416 | |
4369 | void |
4417 | void |
4370 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4418 | rxvt_term::tt_write (const char *data, unsigned int len) |
4371 | { |
4419 | { |
4372 | if (v_buflen == 0) |
4420 | if (v_buflen == 0) |
4373 | { |
4421 | { |
4374 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4422 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4375 | |
4423 | |
… | |
… | |
4378 | |
4426 | |
4379 | data += written; |
4427 | data += written; |
4380 | len -= written; |
4428 | len -= written; |
4381 | } |
4429 | } |
4382 | |
4430 | |
4383 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4431 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4384 | |
4432 | |
4385 | memcpy (v_buffer + v_buflen, data, len); |
4433 | memcpy (v_buffer + v_buflen, data, len); |
4386 | v_buflen += len; |
4434 | v_buflen += len; |
4387 | |
4435 | |
4388 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4436 | pty_ev.set (EVENT_READ | EVENT_WRITE); |