… | |
… | |
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; |
… | |
… | |
963 | } |
967 | } |
964 | #endif |
968 | #endif |
965 | |
969 | |
966 | if (want_refresh) |
970 | if (want_refresh) |
967 | { |
971 | { |
|
|
972 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
973 | { |
|
|
974 | int row = -view_start; |
|
|
975 | |
|
|
976 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
|
|
977 | --row; |
|
|
978 | |
|
|
979 | while (row < -view_start + nrow) |
|
|
980 | { |
|
|
981 | int start_row = row; |
|
|
982 | line_t *l; |
|
|
983 | |
|
|
984 | do |
|
|
985 | { |
|
|
986 | l = &ROW (row); |
|
|
987 | |
|
|
988 | if (!(l->f & LINE_FILTERED)) |
|
|
989 | { |
|
|
990 | // line not filtered, mark it as filtered |
|
|
991 | l->f |= LINE_FILTERED; |
|
|
992 | while (l->is_longer ()) |
|
|
993 | { |
|
|
994 | l = &ROW (++row); |
|
|
995 | l->f |= LINE_FILTERED; |
|
|
996 | } |
|
|
997 | |
|
|
998 | // and filter it |
|
|
999 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1000 | |
|
|
1001 | break; |
|
|
1002 | } |
|
|
1003 | } |
|
|
1004 | while (l->is_longer ()); |
|
|
1005 | |
|
|
1006 | row++; |
|
|
1007 | } |
|
|
1008 | |
|
|
1009 | } |
|
|
1010 | |
968 | scr_refresh (refresh_type); |
1011 | scr_refresh (refresh_type); |
969 | scrollbar_show (1); |
1012 | scrollbar_show (1); |
970 | #ifdef USE_XIM |
1013 | #ifdef USE_XIM |
971 | IMSendSpot (); |
1014 | IMSendSpot (); |
972 | #endif |
1015 | #endif |
… | |
… | |
982 | SET_LOCALE (locale); |
1025 | SET_LOCALE (locale); |
983 | |
1026 | |
984 | display->flush (); |
1027 | display->flush (); |
985 | |
1028 | |
986 | if (want_refresh && !flush_ev.active) |
1029 | if (want_refresh && !flush_ev.active) |
987 | flush_ev.start (NOW + 0.01); |
1030 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
988 | } |
1031 | } |
989 | |
1032 | |
990 | void |
1033 | void |
991 | rxvt_term::flush_cb (time_watcher &w) |
1034 | rxvt_term::flush_cb (time_watcher &w) |
992 | { |
1035 | { |
… | |
… | |
1067 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1110 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1068 | } |
1111 | } |
1069 | } |
1112 | } |
1070 | #endif |
1113 | #endif |
1071 | |
1114 | |
|
|
1115 | #if HAVE_SCHED_YIELD |
|
|
1116 | static struct event_handler |
|
|
1117 | { |
|
|
1118 | check_watcher cw_yield; |
|
|
1119 | |
|
|
1120 | void yield (check_watcher &w) |
|
|
1121 | { |
|
|
1122 | sched_yield (); |
|
|
1123 | w.stop (); |
|
|
1124 | } |
|
|
1125 | |
|
|
1126 | event_handler () |
|
|
1127 | : cw_yield (this, &event_handler::yield) |
|
|
1128 | { |
|
|
1129 | } |
|
|
1130 | } event_handler; |
|
|
1131 | #endif |
|
|
1132 | |
1072 | bool |
1133 | bool |
1073 | rxvt_term::pty_fill () |
1134 | rxvt_term::pty_fill () |
1074 | { |
1135 | { |
1075 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1136 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1076 | |
1137 | |
1077 | if (CBUFSIZ == n) |
1138 | if (CBUFSIZ == n) |
1078 | { |
1139 | { |
1079 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1140 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1080 | n = 0; |
1141 | n = 0; |
1081 | } |
1142 | } |
1082 | |
1143 | |
1083 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1144 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1084 | cmdbuf_ptr = cmdbuf_base; |
1145 | cmdbuf_ptr = cmdbuf_base; |
1085 | cmdbuf_endp = cmdbuf_ptr + n; |
1146 | cmdbuf_endp = cmdbuf_ptr + n; |
1086 | |
1147 | |
1087 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1148 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1088 | |
1149 | |
1089 | if (n > 0) |
1150 | if (r > 0) |
1090 | { |
1151 | { |
1091 | cmdbuf_endp += n; |
1152 | cmdbuf_endp += r; |
1092 | return true; |
1153 | return true; |
1093 | } |
1154 | } |
1094 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1155 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1156 | { |
|
|
1157 | #if HAVE_SCHED_YIELD |
|
|
1158 | if (display->is_local) |
|
|
1159 | event_handler.cw_yield.start (); |
|
|
1160 | #endif |
|
|
1161 | } |
|
|
1162 | else |
1095 | { |
1163 | { |
1096 | pty_ev.stop (); |
1164 | pty_ev.stop (); |
1097 | |
1165 | |
1098 | if (!OPTION (Opt_hold)) |
1166 | if (!OPTION (Opt_hold)) |
1099 | destroy (); |
1167 | destroy (); |
… | |
… | |
1672 | { |
1740 | { |
1673 | if (!focus) |
1741 | if (!focus) |
1674 | { |
1742 | { |
1675 | focus = 1; |
1743 | focus = 1; |
1676 | want_refresh = 1; |
1744 | want_refresh = 1; |
|
|
1745 | |
|
|
1746 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1747 | |
1677 | #if USE_XIM |
1748 | #if USE_XIM |
1678 | if (Input_Context != NULL) |
1749 | if (Input_Context != NULL) |
1679 | { |
1750 | { |
1680 | IMSetStatusPosition (); |
1751 | IMSetStatusPosition (); |
1681 | XSetICFocus (Input_Context); |
1752 | XSetICFocus (Input_Context); |
… | |
… | |
1701 | if (focus) |
1772 | if (focus) |
1702 | { |
1773 | { |
1703 | focus = 0; |
1774 | focus = 0; |
1704 | want_refresh = 1; |
1775 | want_refresh = 1; |
1705 | |
1776 | |
|
|
1777 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1778 | |
1706 | #if ENABLE_FRILLS || ISO_14755 |
1779 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1780 | if (iso14755buf) |
|
|
1781 | { |
1707 | iso14755buf = 0; |
1782 | iso14755buf = 0; |
1708 | #endif |
|
|
1709 | #if ENABLE_OVERLAY |
1783 | # if ENABLE_OVERLAY |
1710 | scr_overlay_off (); |
1784 | scr_overlay_off (); |
|
|
1785 | # endif |
|
|
1786 | } |
1711 | #endif |
1787 | #endif |
1712 | #if USE_XIM |
1788 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1789 | if (Input_Context != NULL) |
1714 | XUnsetICFocus (Input_Context); |
1790 | XUnsetICFocus (Input_Context); |
1715 | #endif |
1791 | #endif |
… | |
… | |
1759 | rxvt_term::button_press (XButtonEvent &ev) |
1835 | rxvt_term::button_press (XButtonEvent &ev) |
1760 | { |
1836 | { |
1761 | int reportmode = 0, clickintime; |
1837 | int reportmode = 0, clickintime; |
1762 | |
1838 | |
1763 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1839 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1840 | |
1764 | if (!bypass_keystate) |
1841 | if (!bypass_keystate) |
1765 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1842 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1766 | |
1843 | |
1767 | /* |
1844 | /* |
1768 | * VT window processing of button press |
1845 | * VT window processing of button press |
… | |
… | |
1817 | else |
1894 | else |
1818 | { |
1895 | { |
1819 | if (ev.button != MEvent.button) |
1896 | if (ev.button != MEvent.button) |
1820 | MEvent.clicks = 0; |
1897 | MEvent.clicks = 0; |
1821 | |
1898 | |
|
|
1899 | if (!HOOK_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1822 | switch (ev.button) |
1900 | switch (ev.button) |
1823 | { |
1901 | { |
1824 | case Button1: |
1902 | case Button1: |
1825 | /* allow meta + click to select rectangular areas */ |
1903 | /* allow meta + click to select rectangular areas */ |
1826 | /* should be done in screen.C */ |
1904 | /* should be done in screen.C */ |
1827 | #if ENABLE_FRILLS |
1905 | #if ENABLE_FRILLS |
1828 | selection.rect = !!(ev.state & ModMetaMask); |
1906 | selection.rect = !!(ev.state & ModMetaMask); |
1829 | #else |
1907 | #else |
1830 | selection.rect = false; |
1908 | selection.rect = false; |
1831 | #endif |
1909 | #endif |
1832 | |
1910 | |
1833 | /* allow shift+left click to extend selection */ |
1911 | /* allow shift+left click to extend selection */ |
1834 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1912 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1835 | { |
1913 | { |
1836 | if (MEvent.button == Button1 && clickintime) |
1914 | if (MEvent.button == Button1 && clickintime) |
1837 | selection_rotate (ev.x, ev.y); |
1915 | selection_rotate (ev.x, ev.y); |
1838 | else |
1916 | else |
1839 | selection_extend (ev.x, ev.y, 1); |
1917 | selection_extend (ev.x, ev.y, 1); |
1840 | } |
1918 | } |
1841 | else |
1919 | else |
1842 | { |
1920 | { |
1843 | if (MEvent.button == Button1 && clickintime) |
1921 | if (MEvent.button == Button1 && clickintime) |
1844 | MEvent.clicks++; |
1922 | MEvent.clicks++; |
1845 | else |
1923 | else |
1846 | MEvent.clicks = 1; |
1924 | MEvent.clicks = 1; |
1847 | |
1925 | |
1848 | selection_click (MEvent.clicks, ev.x, ev.y); |
1926 | selection_click (MEvent.clicks, ev.x, ev.y); |
1849 | } |
1927 | } |
1850 | |
1928 | |
1851 | MEvent.button = Button1; |
1929 | MEvent.button = Button1; |
1852 | break; |
1930 | break; |
1853 | |
1931 | |
1854 | case Button3: |
1932 | case Button3: |
1855 | if (MEvent.button == Button3 && clickintime) |
1933 | if (MEvent.button == Button3 && clickintime) |
1856 | selection_rotate (ev.x, ev.y); |
1934 | selection_rotate (ev.x, ev.y); |
1857 | else |
1935 | else |
1858 | selection_extend (ev.x, ev.y, 1); |
1936 | selection_extend (ev.x, ev.y, 1); |
1859 | |
1937 | |
1860 | MEvent.button = Button3; |
1938 | MEvent.button = Button3; |
1861 | break; |
1939 | break; |
1862 | } |
1940 | } |
1863 | } |
1941 | } |
1864 | |
1942 | |
1865 | MEvent.time = ev.time; |
1943 | MEvent.time = ev.time; |
1866 | return; |
1944 | return; |
1867 | } |
1945 | } |
1868 | |
1946 | |
… | |
… | |
2632 | bool |
2710 | bool |
2633 | rxvt_term::cmd_parse () |
2711 | rxvt_term::cmd_parse () |
2634 | { |
2712 | { |
2635 | bool flag = false; |
2713 | bool flag = false; |
2636 | unicode_t ch = NOCHAR; |
2714 | unicode_t ch = NOCHAR; |
2637 | unsigned char *seq_begin; // remember start of esc-sequence here |
2715 | char *seq_begin; // remember start of esc-sequence here |
2638 | |
2716 | |
2639 | for (;;) |
2717 | for (;;) |
2640 | { |
2718 | { |
2641 | if (ch == NOCHAR) |
2719 | if (ch == NOCHAR) |
2642 | { |
2720 | { |
… | |
… | |
2686 | |
2764 | |
2687 | if (!OPTION (Opt_jumpScroll) |
2765 | if (!OPTION (Opt_jumpScroll) |
2688 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2766 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2689 | { |
2767 | { |
2690 | refreshnow = true; |
2768 | refreshnow = true; |
|
|
2769 | refresh_count = 0; |
2691 | ch = NOCHAR; |
2770 | ch = NOCHAR; |
2692 | break; |
2771 | break; |
2693 | } |
2772 | } |
2694 | |
2773 | |
2695 | // scr_add_lines only works for nlines <= nrow - 1. |
2774 | // scr_add_lines only works for nlines <= nrow - 1. |
2696 | if (nlines >= nrow - 1) |
2775 | if (nlines >= nrow - 1) |
2697 | { |
2776 | { |
|
|
2777 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2698 | scr_add_lines (buf, nlines, str - buf); |
2778 | scr_add_lines (buf, nlines, str - buf); |
|
|
2779 | |
2699 | nlines = 0; |
2780 | nlines = 0; |
2700 | str = buf; |
2781 | str = buf; |
2701 | eol = str + min (ncol, UBUFSIZ); |
2782 | eol = str + min (ncol, UBUFSIZ); |
2702 | } |
2783 | } |
2703 | |
2784 | |
… | |
… | |
2716 | |
2797 | |
2717 | seq_begin = cmdbuf_ptr; |
2798 | seq_begin = cmdbuf_ptr; |
2718 | ch = next_char (); |
2799 | ch = next_char (); |
2719 | } |
2800 | } |
2720 | |
2801 | |
|
|
2802 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2721 | scr_add_lines (buf, nlines, str - buf); |
2803 | scr_add_lines (buf, nlines, str - buf); |
2722 | |
2804 | |
2723 | /* |
2805 | /* |
2724 | * If there have been a lot of new lines, then update the screen |
2806 | * If there have been a lot of new lines, then update the screen |
2725 | * What the heck I'll cheat and only refresh less than every page-full. |
2807 | * What the heck I'll cheat and only refresh less than every page-full. |
2726 | * the number of pages between refreshes is refresh_limit, which |
2808 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2732 | refresh_limit++; |
2814 | refresh_limit++; |
2733 | else |
2815 | else |
2734 | { |
2816 | { |
2735 | flag = true; |
2817 | flag = true; |
2736 | scr_refresh (refresh_type); |
2818 | scr_refresh (refresh_type); |
|
|
2819 | flush_ev.stop (); |
2737 | } |
2820 | } |
2738 | } |
2821 | } |
2739 | |
2822 | |
2740 | } |
2823 | } |
2741 | else |
2824 | else |
… | |
… | |
2772 | rxvt_term::next_char () |
2855 | rxvt_term::next_char () |
2773 | { |
2856 | { |
2774 | while (cmdbuf_ptr < cmdbuf_endp) |
2857 | while (cmdbuf_ptr < cmdbuf_endp) |
2775 | { |
2858 | { |
2776 | // assume 7-bit to be ascii ALWAYS |
2859 | // assume 7-bit to be ascii ALWAYS |
2777 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2860 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2778 | return *cmdbuf_ptr++; |
2861 | return *cmdbuf_ptr++; |
2779 | |
2862 | |
2780 | wchar_t wc; |
2863 | wchar_t wc; |
2781 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2864 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2782 | |
2865 | |
2783 | if (len == (size_t)-2) |
2866 | if (len == (size_t)-2) |
2784 | { |
2867 | { |
2785 | // the mbstate stores incomplete sequences. didn't know this :/ |
2868 | // the mbstate stores incomplete sequences. didn't know this :/ |
2786 | cmdbuf_ptr = cmdbuf_endp; |
2869 | cmdbuf_ptr = cmdbuf_endp; |
… | |
… | |
2925 | case C0_ESC: |
3008 | case C0_ESC: |
2926 | process_escape_seq (); |
3009 | process_escape_seq (); |
2927 | break; |
3010 | break; |
2928 | case C0_ENQ: /* terminal Status */ |
3011 | case C0_ENQ: /* terminal Status */ |
2929 | if (rs[Rs_answerbackstring]) |
3012 | if (rs[Rs_answerbackstring]) |
2930 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
3013 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2931 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2932 | else |
3014 | else |
2933 | tt_write ((unsigned char *)VT100_ANS, |
3015 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2934 | (unsigned int)strlen (VT100_ANS)); |
|
|
2935 | break; |
3016 | break; |
2936 | case C0_BEL: /* bell */ |
3017 | case C0_BEL: /* bell */ |
2937 | scr_bell (); |
3018 | scr_bell (); |
2938 | break; |
3019 | break; |
2939 | case C0_BS: /* backspace */ |
3020 | case C0_BS: /* backspace */ |
… | |
… | |
3127 | process_dcs_seq (); |
3208 | process_dcs_seq (); |
3128 | break; |
3209 | break; |
3129 | |
3210 | |
3130 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3211 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3131 | case C1_SCI: /* ESC Z */ |
3212 | case C1_SCI: /* ESC Z */ |
3132 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3213 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3133 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3134 | break; /* steal obsolete ESC [ c */ |
3214 | break; /* steal obsolete ESC [ c */ |
3135 | |
3215 | |
3136 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3216 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3137 | case C1_CSI: /* ESC [ */ |
3217 | case C1_CSI: /* ESC [ */ |
3138 | process_csi_seq (); |
3218 | process_csi_seq (); |
… | |
… | |
3382 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3462 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3383 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3463 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3384 | break; |
3464 | break; |
3385 | |
3465 | |
3386 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3466 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3387 | tt_write ((const unsigned char *)VT100_ANS, |
3467 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3388 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3389 | break; |
3468 | break; |
3390 | |
3469 | |
3391 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3470 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3392 | process_sgr_mode (nargs, arg); |
3471 | process_sgr_mode (nargs, arg); |
3393 | break; |
3472 | break; |
… | |
… | |
3595 | /*----------------------------------------------------------------------*/ |
3674 | /*----------------------------------------------------------------------*/ |
3596 | /* |
3675 | /* |
3597 | * get input up until STRING TERMINATOR (or BEL) |
3676 | * get input up until STRING TERMINATOR (or BEL) |
3598 | * ends_how is terminator used. returned input must be free()'d |
3677 | * ends_how is terminator used. returned input must be free()'d |
3599 | */ |
3678 | */ |
3600 | unsigned char * |
3679 | char * |
3601 | rxvt_term::get_to_st (unicode_t &ends_how) |
3680 | rxvt_term::get_to_st (unicode_t &ends_how) |
3602 | { |
3681 | { |
3603 | unicode_t ch; |
3682 | unicode_t ch; |
3604 | bool seen_esc = false; |
3683 | bool seen_esc = false; |
3605 | unsigned int n = 0; |
3684 | unsigned int n = 0; |
… | |
… | |
3638 | |
3717 | |
3639 | string[n++] = '\0'; |
3718 | string[n++] = '\0'; |
3640 | |
3719 | |
3641 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3720 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3642 | |
3721 | |
3643 | return (unsigned char *)rxvt_wcstombs (string); |
3722 | return rxvt_wcstombs (string); |
3644 | } |
3723 | } |
3645 | |
3724 | |
3646 | /*----------------------------------------------------------------------*/ |
3725 | /*----------------------------------------------------------------------*/ |
3647 | /* |
3726 | /* |
3648 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3727 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3649 | */ |
3728 | */ |
3650 | void |
3729 | void |
3651 | rxvt_term::process_dcs_seq () |
3730 | rxvt_term::process_dcs_seq () |
3652 | { |
3731 | { |
3653 | unsigned char *s; |
3732 | char *s; |
3654 | unicode_t eh; |
3733 | unicode_t eh; |
3655 | |
3734 | |
3656 | /* |
3735 | /* |
3657 | * Not handled yet |
3736 | * Not handled yet |
3658 | */ |
3737 | */ |
… | |
… | |
3677 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3756 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3678 | arg = arg * 10 + (ch - '0'); |
3757 | arg = arg * 10 + (ch - '0'); |
3679 | |
3758 | |
3680 | if (ch == ';') |
3759 | if (ch == ';') |
3681 | { |
3760 | { |
3682 | unsigned char *s = get_to_st (eh); |
3761 | char *s = get_to_st (eh); |
3683 | |
3762 | |
3684 | if (s) |
3763 | if (s) |
3685 | { |
3764 | { |
3686 | process_xterm_seq (arg, (char *)s, eh); |
3765 | process_xterm_seq (arg, s, eh); |
3687 | free (s); |
3766 | free (s); |
3688 | } |
3767 | } |
3689 | } |
3768 | } |
3690 | } |
3769 | } |
3691 | |
3770 | |
3692 | void |
3771 | void |
3693 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3772 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3694 | { |
3773 | { |
3695 | if (str[0] == '?' && !str[1]) |
3774 | if (str[0] == '?' && !str[1]) |
3696 | { |
3775 | { |
3697 | unsigned short r, g, b; |
3776 | unsigned short r, g, b; |
3698 | pix_colors_focused[color].get (display, r, g, b); |
3777 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3704 | |
3783 | |
3705 | /* |
3784 | /* |
3706 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3785 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3707 | */ |
3786 | */ |
3708 | void |
3787 | void |
3709 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3788 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3710 | { |
3789 | { |
3711 | int changed = 0; |
3790 | int changed = 0; |
3712 | int color; |
3791 | int color; |
3713 | char *buf, *name; |
3792 | char *buf, *name; |
3714 | bool query = str[0] == '?' && !str[1]; |
3793 | bool query = str[0] == '?' && !str[1]; |
… | |
… | |
3921 | } |
4000 | } |
3922 | break; |
4001 | break; |
3923 | |
4002 | |
3924 | case URxvt_view_up: |
4003 | case URxvt_view_up: |
3925 | case URxvt_view_down: |
4004 | case URxvt_view_down: |
|
|
4005 | { |
3926 | int lines = atoi (str); |
4006 | int lines = atoi (str); |
3927 | |
4007 | |
3928 | if (lines) |
4008 | if (lines) |
3929 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
4009 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3930 | else |
4010 | else |
3931 | { |
|
|
3932 | scr_erase_savelines (); |
4011 | scr_erase_savelines (); |
3933 | } |
4012 | } |
3934 | |
4013 | |
|
|
4014 | break; |
|
|
4015 | #endif |
|
|
4016 | |
|
|
4017 | #if ENABLE_PERL |
|
|
4018 | case URxvt_perl: |
|
|
4019 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
|
|
4020 | ; // no responses yet |
3935 | break; |
4021 | break; |
3936 | #endif |
4022 | #endif |
3937 | } |
4023 | } |
3938 | } |
4024 | } |
3939 | /*----------------------------------------------------------------------*/ |
4025 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4048 | } |
4134 | } |
4049 | |
4135 | |
4050 | /* extra handling for values with state unkept */ |
4136 | /* extra handling for values with state unkept */ |
4051 | switch (arg[i]) |
4137 | switch (arg[i]) |
4052 | { |
4138 | { |
|
|
4139 | #if ENABLE_STYLES |
|
|
4140 | case 1021: |
|
|
4141 | if (mode) |
|
|
4142 | SET_OPTION (Opt_intensityStyles); |
|
|
4143 | else |
|
|
4144 | CLR_OPTION (Opt_intensityStyles); |
|
|
4145 | |
|
|
4146 | scr_touch (true); |
|
|
4147 | break; |
|
|
4148 | #endif |
4053 | case 1048: /* alternative cursor save */ |
4149 | case 1048: /* alternative cursor save */ |
4054 | case 1049: |
4150 | case 1049: |
4055 | if (OPTION (Opt_secondaryScreen)) |
4151 | if (OPTION (Opt_secondaryScreen)) |
4056 | if (mode == 0) |
4152 | if (mode == 0) |
4057 | scr_cursor (RESTORE); |
4153 | scr_cursor (RESTORE); |
… | |
… | |
4140 | if (state) |
4236 | if (state) |
4141 | SET_OPTION (Opt_scrollTtyKeypress); |
4237 | SET_OPTION (Opt_scrollTtyKeypress); |
4142 | else |
4238 | else |
4143 | CLR_OPTION (Opt_scrollTtyKeypress); |
4239 | CLR_OPTION (Opt_scrollTtyKeypress); |
4144 | break; |
4240 | 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 */ |
4241 | case 1047: /* secondary screen w/ clearing last */ |
4153 | if (OPTION (Opt_secondaryScreen)) |
4242 | if (OPTION (Opt_secondaryScreen)) |
4154 | if (current_screen != PRIMARY) |
4243 | if (current_screen != PRIMARY) |
4155 | scr_erase_screen (2); |
4244 | scr_erase_screen (2); |
4156 | scr_change_screen (state); |
4245 | scr_change_screen (state); |
… | |
… | |
4293 | scr_color (Color_bg, Color_bg); |
4382 | scr_color (Color_bg, Color_bg); |
4294 | break; |
4383 | break; |
4295 | |
4384 | |
4296 | //case 50: // not variable spacing |
4385 | //case 50: // not variable spacing |
4297 | |
4386 | |
4298 | #ifndef NO_BRIGHTCOLOR |
4387 | #if ENABLE_FRILLS |
4299 | case 90: |
4388 | case 90: |
4300 | case 91: /* set bright fg color */ |
4389 | case 91: /* set bright fg color */ |
4301 | case 92: |
4390 | case 92: |
4302 | case 93: |
4391 | case 93: |
4303 | case 94: |
4392 | case 94: |
… | |
… | |
4315 | case 106: |
4404 | case 106: |
4316 | case 107: |
4405 | case 107: |
4317 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4406 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4318 | break; |
4407 | break; |
4319 | #endif |
4408 | #endif |
4320 | |
|
|
4321 | } |
4409 | } |
4322 | } |
4410 | } |
4323 | } |
4411 | } |
4324 | /*}}} */ |
4412 | /*}}} */ |
4325 | |
4413 | |
… | |
… | |
4349 | */ |
4437 | */ |
4350 | void |
4438 | void |
4351 | rxvt_term::tt_printf (const char *fmt,...) |
4439 | rxvt_term::tt_printf (const char *fmt,...) |
4352 | { |
4440 | { |
4353 | va_list arg_ptr; |
4441 | va_list arg_ptr; |
4354 | unsigned char buf[256]; |
4442 | char buf[256]; |
4355 | |
4443 | |
4356 | va_start (arg_ptr, fmt); |
4444 | va_start (arg_ptr, fmt); |
4357 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4445 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4358 | va_end (arg_ptr); |
4446 | va_end (arg_ptr); |
4359 | tt_write (buf, strlen (buf)); |
4447 | tt_write (buf, strlen (buf)); |
… | |
… | |
4364 | * or generated by us in response to a query ESC sequence. |
4452 | * or generated by us in response to a query ESC sequence. |
4365 | */ |
4453 | */ |
4366 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4454 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4367 | |
4455 | |
4368 | void |
4456 | void |
4369 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4457 | rxvt_term::tt_write (const char *data, unsigned int len) |
4370 | { |
4458 | { |
4371 | if (v_buflen == 0) |
4459 | if (v_buflen == 0) |
4372 | { |
4460 | { |
4373 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4461 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4374 | |
4462 | |
… | |
… | |
4377 | |
4465 | |
4378 | data += written; |
4466 | data += written; |
4379 | len -= written; |
4467 | len -= written; |
4380 | } |
4468 | } |
4381 | |
4469 | |
4382 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4470 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4383 | |
4471 | |
4384 | memcpy (v_buffer + v_buflen, data, len); |
4472 | memcpy (v_buffer + v_buflen, data, len); |
4385 | v_buflen += len; |
4473 | v_buflen += len; |
4386 | |
4474 | |
4387 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4475 | pty_ev.set (EVENT_READ | EVENT_WRITE); |