ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.219 by root, Sat Dec 31 17:16:17 2005 UTC vs.
Revision 1.236 by root, Thu Jan 5 01:04:10 2006 UTC

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
162void 167void
163rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) 168rxvt_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
246void 250void
247rxvt_term::commit_iso14755 () 251rxvt_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 */
920unsigned int 924unsigned int
921rxvt_term::cmd_write (const unsigned char *str, unsigned int count) 925rxvt_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
990void 994void
991rxvt_term::flush_cb (time_watcher &w) 995rxvt_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
1077static 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
1072bool 1094bool
1073rxvt_term::pty_fill () 1095rxvt_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
1759rxvt_term::button_press (XButtonEvent &ev) 1796rxvt_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
2632bool 2671bool
2633rxvt_term::cmd_parse () 2672rxvt_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.
2696 if (nlines >= nrow - 1) 2736 if (nlines >= nrow - 1)
2697 { 2737 {
2738 if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END)))
2698 scr_add_lines (buf, nlines, str - buf); 2739 scr_add_lines (buf, nlines, str - buf);
2740
2699 nlines = 0; 2741 nlines = 0;
2700 str = buf; 2742 str = buf;
2701 eol = str + min (ncol, UBUFSIZ); 2743 eol = str + min (ncol, UBUFSIZ);
2702 } 2744 }
2703 2745
2716 2758
2717 seq_begin = cmdbuf_ptr; 2759 seq_begin = cmdbuf_ptr;
2718 ch = next_char (); 2760 ch = next_char ();
2719 } 2761 }
2720 2762
2763 if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END)))
2721 scr_add_lines (buf, nlines, str - buf); 2764 scr_add_lines (buf, nlines, str - buf);
2722 2765
2723 /* 2766 /*
2724 * 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
2725 * 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.
2726 * the number of pages between refreshes is refresh_limit, which 2769 * the number of pages between refreshes is refresh_limit, which
2732 refresh_limit++; 2775 refresh_limit++;
2733 else 2776 else
2734 { 2777 {
2735 flag = true; 2778 flag = true;
2736 scr_refresh (refresh_type); 2779 scr_refresh (refresh_type);
2780 flush_ev.stop ();
2737 } 2781 }
2738 } 2782 }
2739 2783
2740 } 2784 }
2741 else 2785 else
2772rxvt_term::next_char () 2816rxvt_term::next_char ()
2773{ 2817{
2774 while (cmdbuf_ptr < cmdbuf_endp) 2818 while (cmdbuf_ptr < cmdbuf_endp)
2775 { 2819 {
2776 // assume 7-bit to be ascii ALWAYS 2820 // assume 7-bit to be ascii ALWAYS
2777 if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2821 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)
2778 return *cmdbuf_ptr++; 2822 return *cmdbuf_ptr++;
2779 2823
2780 wchar_t wc; 2824 wchar_t wc;
2781 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);
2782 2826
2783 if (len == (size_t)-2) 2827 if (len == (size_t)-2)
2784 { 2828 {
2785 // the mbstate stores incomplete sequences. didn't know this :/ 2829 // the mbstate stores incomplete sequences. didn't know this :/
2786 cmdbuf_ptr = cmdbuf_endp; 2830 cmdbuf_ptr = cmdbuf_endp;
2925 case C0_ESC: 2969 case C0_ESC:
2926 process_escape_seq (); 2970 process_escape_seq ();
2927 break; 2971 break;
2928 case C0_ENQ: /* terminal Status */ 2972 case C0_ENQ: /* terminal Status */
2929 if (rs[Rs_answerbackstring]) 2973 if (rs[Rs_answerbackstring])
2930 tt_write ((const unsigned char *)rs[Rs_answerbackstring], 2974 tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring]));
2931 (unsigned int)strlen (rs[Rs_answerbackstring]));
2932 else 2975 else
2933 tt_write ((unsigned char *)VT100_ANS, 2976 tt_write (VT100_ANS, strlen (VT100_ANS));
2934 (unsigned int)strlen (VT100_ANS));
2935 break; 2977 break;
2936 case C0_BEL: /* bell */ 2978 case C0_BEL: /* bell */
2937 scr_bell (); 2979 scr_bell ();
2938 break; 2980 break;
2939 case C0_BS: /* backspace */ 2981 case C0_BS: /* backspace */
3127 process_dcs_seq (); 3169 process_dcs_seq ();
3128 break; 3170 break;
3129 3171
3130 /* 8.3.110: SINGLE CHARACTER INTRODUCER */ 3172 /* 8.3.110: SINGLE CHARACTER INTRODUCER */
3131 case C1_SCI: /* ESC Z */ 3173 case C1_SCI: /* ESC Z */
3132 tt_write ((const unsigned char *)ESCZ_ANSWER, 3174 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1);
3133 (unsigned int) (sizeof (ESCZ_ANSWER) - 1));
3134 break; /* steal obsolete ESC [ c */ 3175 break; /* steal obsolete ESC [ c */
3135 3176
3136 /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ 3177 /* 8.3.16: CONTROL SEQUENCE INTRODUCER */
3137 case C1_CSI: /* ESC [ */ 3178 case C1_CSI: /* ESC [ */
3138 process_csi_seq (); 3179 process_csi_seq ();
3382 case CSI_SU: /* 8.3.148: (1) SCROLL UP */ 3423 case CSI_SU: /* 8.3.148: (1) SCROLL UP */
3383 scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); 3424 scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]);
3384 break; 3425 break;
3385 3426
3386 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ 3427 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */
3387 tt_write ((const unsigned char *)VT100_ANS, 3428 tt_write (VT100_ANS, sizeof (VT100_ANS) - 1);
3388 (unsigned int) (sizeof (VT100_ANS) - 1));
3389 break; 3429 break;
3390 3430
3391 case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ 3431 case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */
3392 process_sgr_mode (nargs, arg); 3432 process_sgr_mode (nargs, arg);
3393 break; 3433 break;
3595/*----------------------------------------------------------------------*/ 3635/*----------------------------------------------------------------------*/
3596/* 3636/*
3597 * get input up until STRING TERMINATOR (or BEL) 3637 * get input up until STRING TERMINATOR (or BEL)
3598 * ends_how is terminator used. returned input must be free()'d 3638 * ends_how is terminator used. returned input must be free()'d
3599 */ 3639 */
3600unsigned char * 3640char *
3601rxvt_term::get_to_st (unicode_t &ends_how) 3641rxvt_term::get_to_st (unicode_t &ends_how)
3602{ 3642{
3603 unicode_t ch; 3643 unicode_t ch;
3604 bool seen_esc = false; 3644 bool seen_esc = false;
3605 unsigned int n = 0; 3645 unsigned int n = 0;
3638 3678
3639 string[n++] = '\0'; 3679 string[n++] = '\0';
3640 3680
3641 ends_how = (ch == 0x5c ? C0_ESC : ch); 3681 ends_how = (ch == 0x5c ? C0_ESC : ch);
3642 3682
3643 return (unsigned char *)rxvt_wcstombs (string); 3683 return rxvt_wcstombs (string);
3644} 3684}
3645 3685
3646/*----------------------------------------------------------------------*/ 3686/*----------------------------------------------------------------------*/
3647/* 3687/*
3648 * 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)'
3649 */ 3689 */
3650void 3690void
3651rxvt_term::process_dcs_seq () 3691rxvt_term::process_dcs_seq ()
3652{ 3692{
3653 unsigned char *s; 3693 char *s;
3654 unicode_t eh; 3694 unicode_t eh;
3655 3695
3656 /* 3696 /*
3657 * Not handled yet 3697 * Not handled yet
3658 */ 3698 */
3677 for (arg = 0; isdigit (ch); ch = cmd_getc ()) 3717 for (arg = 0; isdigit (ch); ch = cmd_getc ())
3678 arg = arg * 10 + (ch - '0'); 3718 arg = arg * 10 + (ch - '0');
3679 3719
3680 if (ch == ';') 3720 if (ch == ';')
3681 { 3721 {
3682 unsigned char *s = get_to_st (eh); 3722 char *s = get_to_st (eh);
3683 3723
3684 if (s) 3724 if (s)
3685 { 3725 {
3686 process_xterm_seq (arg, (char *)s, eh); 3726 process_xterm_seq (arg, s, eh);
3687 free (s); 3727 free (s);
3688 } 3728 }
3689 } 3729 }
3690} 3730}
3691 3731
3692void 3732void
3693rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) 3733rxvt_term::process_color_seq (int report, int color, const char *str, char resp)
3694{ 3734{
3695 if (str[0] == '?' && !str[1]) 3735 if (str[0] == '?' && !str[1])
3696 { 3736 {
3697 unsigned short r, g, b; 3737 unsigned short r, g, b;
3698 pix_colors_focused[color].get (display, r, g, b); 3738 pix_colors_focused[color].get (display, r, g, b);
3704 3744
3705/* 3745/*
3706 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3746 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3707 */ 3747 */
3708void 3748void
3709rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) 3749rxvt_term::process_xterm_seq (int op, const char *str, char resp)
3710{ 3750{
3711 int changed = 0; 3751 int changed = 0;
3712 int color; 3752 int color;
3713 char *buf, *name; 3753 char *buf, *name;
3714 bool query = str[0] == '?' && !str[1]; 3754 bool query = str[0] == '?' && !str[1];
3921 } 3961 }
3922 break; 3962 break;
3923 3963
3924 case URxvt_view_up: 3964 case URxvt_view_up:
3925 case URxvt_view_down: 3965 case URxvt_view_down:
3966 {
3926 int lines = atoi (str); 3967 int lines = atoi (str);
3927 3968
3928 if (lines) 3969 if (lines)
3929 scr_page (op == URxvt_view_up ? UP : DN, lines); 3970 scr_page (op == URxvt_view_up ? UP : DN, lines);
3930 else 3971 else
3931 {
3932 scr_erase_savelines (); 3972 scr_erase_savelines ();
3933 } 3973 }
3934 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
3935 break; 3982 break;
3936#endif 3983#endif
3937 } 3984 }
3938} 3985}
3939/*----------------------------------------------------------------------*/ 3986/*----------------------------------------------------------------------*/
4048 } 4095 }
4049 4096
4050 /* extra handling for values with state unkept */ 4097 /* extra handling for values with state unkept */
4051 switch (arg[i]) 4098 switch (arg[i])
4052 { 4099 {
4100#if ENABLE_STYLES
4101 case 1021:
4102 if (mode)
4103 SET_OPTION (Opt_intensityStyles);
4104 else
4105 CLR_OPTION (Opt_intensityStyles);
4106
4107 scr_touch (true);
4108 break;
4109#endif
4053 case 1048: /* alternative cursor save */ 4110 case 1048: /* alternative cursor save */
4054 case 1049: 4111 case 1049:
4055 if (OPTION (Opt_secondaryScreen)) 4112 if (OPTION (Opt_secondaryScreen))
4056 if (mode == 0) 4113 if (mode == 0)
4057 scr_cursor (RESTORE); 4114 scr_cursor (RESTORE);
4140 if (state) 4197 if (state)
4141 SET_OPTION (Opt_scrollTtyKeypress); 4198 SET_OPTION (Opt_scrollTtyKeypress);
4142 else 4199 else
4143 CLR_OPTION (Opt_scrollTtyKeypress); 4200 CLR_OPTION (Opt_scrollTtyKeypress);
4144 break; 4201 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 */ 4202 case 1047: /* secondary screen w/ clearing last */
4153 if (OPTION (Opt_secondaryScreen)) 4203 if (OPTION (Opt_secondaryScreen))
4154 if (current_screen != PRIMARY) 4204 if (current_screen != PRIMARY)
4155 scr_erase_screen (2); 4205 scr_erase_screen (2);
4156 scr_change_screen (state); 4206 scr_change_screen (state);
4293 scr_color (Color_bg, Color_bg); 4343 scr_color (Color_bg, Color_bg);
4294 break; 4344 break;
4295 4345
4296 //case 50: // not variable spacing 4346 //case 50: // not variable spacing
4297 4347
4298#ifndef NO_BRIGHTCOLOR 4348#if ENABLE_FRILLS
4299 case 90: 4349 case 90:
4300 case 91: /* set bright fg color */ 4350 case 91: /* set bright fg color */
4301 case 92: 4351 case 92:
4302 case 93: 4352 case 93:
4303 case 94: 4353 case 94:
4315 case 106: 4365 case 106:
4316 case 107: 4366 case 107:
4317 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); 4367 scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg);
4318 break; 4368 break;
4319#endif 4369#endif
4320
4321 } 4370 }
4322 } 4371 }
4323} 4372}
4324/*}}} */ 4373/*}}} */
4325 4374
4349 */ 4398 */
4350void 4399void
4351rxvt_term::tt_printf (const char *fmt,...) 4400rxvt_term::tt_printf (const char *fmt,...)
4352{ 4401{
4353 va_list arg_ptr; 4402 va_list arg_ptr;
4354 unsigned char buf[256]; 4403 char buf[256];
4355 4404
4356 va_start (arg_ptr, fmt); 4405 va_start (arg_ptr, fmt);
4357 vsnprintf ((char *)buf, 256, fmt, arg_ptr); 4406 vsnprintf ((char *)buf, 256, fmt, arg_ptr);
4358 va_end (arg_ptr); 4407 va_end (arg_ptr);
4359 tt_write (buf, strlen (buf)); 4408 tt_write (buf, strlen (buf));
4364 * or generated by us in response to a query ESC sequence. 4413 * or generated by us in response to a query ESC sequence.
4365 */ 4414 */
4366const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4415const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4367 4416
4368void 4417void
4369rxvt_term::tt_write (const unsigned char *data, unsigned int len) 4418rxvt_term::tt_write (const char *data, unsigned int len)
4370{ 4419{
4371 if (v_buflen == 0) 4420 if (v_buflen == 0)
4372 { 4421 {
4373 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));
4374 4423
4377 4426
4378 data += written; 4427 data += written;
4379 len -= written; 4428 len -= written;
4380 } 4429 }
4381 4430
4382 v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); 4431 v_buffer = (char *)realloc (v_buffer, v_buflen + len);
4383 4432
4384 memcpy (v_buffer + v_buflen, data, len); 4433 memcpy (v_buffer + v_buflen, data, len);
4385 v_buflen += len; 4434 v_buflen += len;
4386 4435
4387 pty_ev.set (EVENT_READ | EVENT_WRITE); 4436 pty_ev.set (EVENT_READ | EVENT_WRITE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines