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.485 by sf-exg, Fri Apr 29 13:08:24 2011 UTC vs.
Revision 1.512 by root, Mon May 28 16:40:03 2012 UTC

54 54
55#ifdef KEYSYM_RESOURCE 55#ifdef KEYSYM_RESOURCE
56# include "keyboard.h" 56# include "keyboard.h"
57#endif 57#endif
58 58
59#include <csignal> 59#include <signal.h>
60 60
61#if LINUX_YIELD_HACK 61#if LINUX_YIELD_HACK
62# include <ctime> 62# include <time.h>
63#endif 63#endif
64 64
65/*----------------------------------------------------------------------*/ 65/*----------------------------------------------------------------------*/
66 66
67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
131 XK_KP_Space, 0x2422, 131 XK_KP_Space, 0x2422,
132#endif 132#endif
133 0, 133 0,
134}; 134};
135 135
136void 136void ecb_cold
137rxvt_term::iso14755_54 (int x, int y) 137rxvt_term::iso14755_54 (int x, int y)
138{ 138{
139 x = Pixel2Col (x); 139 x = Pixel2Col (x);
140 y = Pixel2Row (y); 140 y = Pixel2Row (y);
141 141
158 158
159 x--; 159 x--;
160 } 160 }
161} 161}
162 162
163void 163void ecb_cold
164rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) 164rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y)
165{ 165{
166 rxvt_fontset *fs = FONTSET (r); 166 rxvt_fontset *fs = FONTSET (r);
167 wchar_t *chr, *alloc, ch2, **fname; 167 wchar_t *chr, *alloc, ch2, **fname;
168 int len; 168 int len;
254 delete [] alloc; 254 delete [] alloc;
255# endif 255# endif
256} 256}
257#endif 257#endif
258 258
259void 259void ecb_cold
260rxvt_term::commit_iso14755 () 260rxvt_term::commit_iso14755 ()
261{ 261{
262 wchar_t ch[2];
263
264 ch[0] = iso14755buf & ISO_14755_MASK; 262 wchar_t ch = iso14755buf & ISO_14755_MASK;
265 ch[1] = 0;
266 263
267 if (iso14755buf & ISO_14755_51) 264 if (iso14755buf & ISO_14755_51)
268 { 265 {
269 char mb[16]; 266 char mb[MB_LEN_MAX];
270 int len; 267 int len;
271 268
272 // allow verbatim 0-bytes and control-bytes to be entered 269 // allow verbatim 0-bytes and control-bytes to be entered
273 if (ch[0] >= 0x20) 270 if (ch >= 0x20)
274 len = wcstombs (mb, ch, 16); 271 len = wctomb (mb, ch);
275 else 272 else
276 { 273 {
277 mb[0] = ch[0]; 274 mb[0] = ch;
278 len = 1; 275 len = 1;
279 } 276 }
280 277
281 if (len > 0) 278 if (len > 0)
282 tt_write (mb, len); 279 tt_write (mb, len);
285 } 282 }
286 283
287 iso14755buf = 0; 284 iso14755buf = 0;
288} 285}
289 286
290static int 287static int ecb_cold
291hex_keyval (XKeyEvent &ev) 288hex_keyval (XKeyEvent &ev)
292{ 289{
293 // check whether this event corresponds to a hex digit 290 // check whether this event corresponds to a hex digit
294 // if the modifiers had not been pressed. 291 // if the modifiers had not been pressed.
295 for (int index = 0; index < 8; index++) 292 for (int index = 0; index < 8; index++)
304 301
305 return -1; 302 return -1;
306} 303}
307#endif 304#endif
308 305
309static inline KeySym 306static inline KeySym ecb_cold
310translate_keypad (KeySym keysym, bool kp) 307translate_keypad (KeySym keysym, bool kp)
311{ 308{
312#ifdef XK_KP_Home 309#ifdef XK_KP_Home
313 static const KeySym keypadtrans[] = { 310 static const KeySym keypadtrans[] = {
314 XK_KP_7, // XK_KP_Home 311 XK_KP_7, // XK_KP_Home
340# endif 337# endif
341#endif 338#endif
342 return keysym; 339 return keysym;
343} 340}
344 341
345static inline int 342static inline int ecb_cold
346map_function_key (KeySym keysym) 343map_function_key (KeySym keysym)
347{ 344{
348 int param = 0; 345 int param = 0;
349 346
350 if (IN_RANGE_INC (keysym, XK_F1, XK_F35)) 347 if (IN_RANGE_INC (keysym, XK_F1, XK_F35))
399 break; 396 break;
400 } 397 }
401 return param; 398 return param;
402} 399}
403 400
404void 401void ecb_cold
405rxvt_term::key_press (XKeyEvent &ev) 402rxvt_term::key_press (XKeyEvent &ev)
406{ 403{
407 int ctrl, meta, shft, len; 404 int ctrl, meta, shft, len;
408 KeySym keysym; 405 KeySym keysym;
409 int valid_keysym; 406 int valid_keysym;
779 } 776 }
780 777
781 if (newlen) 778 if (newlen)
782 len = strlen (kbuf); 779 len = strlen (kbuf);
783 780
781 if (len > 0)
782 {
784 /* 783 /*
784 * pass Shift/Control indicators for function keys ending with `~'
785 *
786 * eg,
787 * Prior = "ESC[5~"
788 * Shift+Prior = "ESC[5$"
789 * Ctrl+Prior = "ESC[5^"
790 * Ctrl+Shift+Prior = "ESC[5@"
791 */
792 if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~')
793 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
794
795 /*
785 * Pass meta for all function keys, if 'meta' option set 796 * Pass meta for all function keys, if 'meta' option set
786 */ 797 */
787#ifdef META8_OPTION 798#ifdef META8_OPTION
788 if (meta && (meta_char == 0x80) && len > 0) 799 if (meta && (meta_char == 0x80))
789 kbuf[len - 1] |= 0x80; 800 kbuf[len - 1] |= 0x80;
790#endif 801#endif
802 }
791 803
792 } 804 }
793 else if (ctrl && keysym == XK_minus) 805 else if (ctrl && keysym == XK_minus)
794 { 806 {
795 len = 1; 807 len = 1;
829 { 841 {
830 view_start = 0; 842 view_start = 0;
831 want_refresh = 1; 843 want_refresh = 1;
832 } 844 }
833 845
834 /*
835 * these modifications only affect the static keybuffer
836 * pass Shift/Control indicators for function keys ending with `~'
837 *
838 * eg,
839 * Prior = "ESC[5~"
840 * Shift+Prior = "ESC[5$"
841 * Ctrl+Prior = "ESC[5^"
842 * Ctrl+Shift+Prior = "ESC[5@"
843 * Meta adds an Escape prefix (with META8_OPTION, if meta == <escape>).
844 */
845 if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~')
846 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
847
848 /* escape prefix */ 846 /* escape prefix */
849 if (meta 847 if (meta
850#ifdef META8_OPTION 848#ifdef META8_OPTION
851 && meta_char == C0_ESC 849 && meta_char == C0_ESC
852#endif 850#endif
857 } 855 }
858 856
859 tt_write (kbuf, (unsigned int)len); 857 tt_write (kbuf, (unsigned int)len);
860} 858}
861 859
862void 860void ecb_cold
863rxvt_term::key_release (XKeyEvent &ev) 861rxvt_term::key_release (XKeyEvent &ev)
864{ 862{
865#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL 863#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
866 KeySym keysym; 864 KeySym keysym;
867 865
990 } 988 }
991 989
992 scr_refresh (); 990 scr_refresh ();
993 scrollBar.show (1); 991 scrollBar.show (1);
994#ifdef USE_XIM 992#ifdef USE_XIM
995 IMSendSpot (); 993 im_send_spot ();
996#endif 994#endif
997 } 995 }
998 996
999 display->flush (); 997 display->flush ();
1000} 998}
1018 flush (); 1016 flush ();
1019} 1017}
1020 1018
1021#ifdef CURSOR_BLINK 1019#ifdef CURSOR_BLINK
1022void 1020void
1021rxvt_term::cursor_blink_reset ()
1022{
1023 if (hidden_cursor)
1024 {
1025 hidden_cursor = 0;
1026 want_refresh = 1;
1027 }
1028
1029 if (option (Opt_cursorBlink))
1030 cursor_blink_ev.again ();
1031 else
1032 cursor_blink_ev.stop ();
1033}
1034
1035void
1023rxvt_term::cursor_blink_cb (ev::timer &w, int revents) 1036rxvt_term::cursor_blink_cb (ev::timer &w, int revents)
1024{ 1037{
1025 hidden_cursor = !hidden_cursor; 1038 hidden_cursor = !hidden_cursor;
1026 want_refresh = 1; 1039 want_refresh = 1;
1027 refresh_check (); 1040 refresh_check ();
1045 1058
1046#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1059#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1047void 1060void
1048rxvt_term::cont_scroll_cb (ev::timer &w, int revents) 1061rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1049{ 1062{
1050 if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) 1063 if ((scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN)
1051 && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1)) 1064 && scr_page (scrollBar.state == SB_STATE_UP ? UP : DN, 1))
1052 { 1065 {
1053 want_refresh = 1; 1066 want_refresh = 1;
1054 refresh_check (); 1067 refresh_check ();
1055 } 1068 }
1056 else 1069 else
1206 pty_write (); 1219 pty_write ();
1207 1220
1208 refresh_check (); 1221 refresh_check ();
1209} 1222}
1210 1223
1211void 1224void ecb_cold
1212rxvt_term::pointer_unblank () 1225rxvt_term::pointer_unblank ()
1213{ 1226{
1214 XDefineCursor (dpy, vt, TermWin_cursor); 1227 XDefineCursor (dpy, vt, TermWin_cursor);
1215 recolour_cursor (); 1228 recolour_cursor ();
1216 1229
1221 pointer_ev.start (pointerBlankDelay); 1234 pointer_ev.start (pointerBlankDelay);
1222#endif 1235#endif
1223} 1236}
1224 1237
1225#ifdef POINTER_BLANK 1238#ifdef POINTER_BLANK
1226void 1239void ecb_cold
1227rxvt_term::pointer_blank () 1240rxvt_term::pointer_blank ()
1228{ 1241{
1229 if (!option (Opt_pointerBlank)) 1242 if (!option (Opt_pointerBlank))
1230 return; 1243 return;
1231 1244
1233 XFlush (dpy); 1246 XFlush (dpy);
1234 1247
1235 hidden_pointer = 1; 1248 hidden_pointer = 1;
1236} 1249}
1237 1250
1238void 1251void ecb_cold
1239rxvt_term::pointer_cb (ev::timer &w, int revents) 1252rxvt_term::pointer_cb (ev::timer &w, int revents)
1240{ 1253{
1241 make_current (); 1254 make_current ();
1242 1255
1243 pointer_blank (); 1256 pointer_blank ();
1335 32 + x, 1348 32 + x,
1336 32 + y); 1349 32 + y);
1337} 1350}
1338 1351
1339/*{{{ process an X event */ 1352/*{{{ process an X event */
1340void 1353void ecb_hot
1341rxvt_term::x_cb (XEvent &ev) 1354rxvt_term::x_cb (XEvent &ev)
1342{ 1355{
1343 make_current (); 1356 make_current ();
1344 1357
1345 dLocal (Display *, dpy); 1358 dLocal (Display *, dpy);
1476 } 1489 }
1477 else 1490 else
1478 { 1491 {
1479#ifdef HAVE_BG_PIXMAP 1492#ifdef HAVE_BG_PIXMAP
1480 if (moved) 1493 if (moved)
1481 {
1482 if (mapped)
1483 update_background (); 1494 update_background ();
1484 else
1485 bg_invalidate ();
1486 }
1487#endif 1495#endif
1488 } 1496 }
1489 1497
1490 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1498 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1491 } 1499 }
1565 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) 1573 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1566 ; 1574 ;
1567 1575
1568 if (scrollBar.state && ev.xany.window == scrollBar.win) 1576 if (scrollBar.state && ev.xany.window == scrollBar.win)
1569 { 1577 {
1570 scrollBar.state = STATE_IDLE; 1578 scrollBar.state = SB_STATE_IDLE;
1571 scrollBar.show (0); 1579 scrollBar.show (0);
1572 } 1580 }
1573 } 1581 }
1574 break; 1582 break;
1575 1583
1641 dist = int_bwidth - ev.xbutton.y; 1649 dist = int_bwidth - ev.xbutton.y;
1642 } 1650 }
1643 else 1651 else
1644 { 1652 {
1645 scroll_selection_dir = DN; 1653 scroll_selection_dir = DN;
1646 dist = ev.xbutton.y - (int_bwidth + height); 1654 dist = ev.xbutton.y - (int_bwidth + vt_height);
1647 } 1655 }
1648 1656
1649 scroll_selection_lines = Pixel2Height (dist) 1657 scroll_selection_lines = Pixel2Height (dist)
1650 / SELECTION_SCROLL_LINE_SPEEDUP 1658 / SELECTION_SCROLL_LINE_SPEEDUP
1651 + 1; 1659 + 1;
1663#ifdef MOUSE_THRESHOLD 1671#ifdef MOUSE_THRESHOLD
1664 } 1672 }
1665#endif 1673#endif
1666 } 1674 }
1667 } 1675 }
1668 else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) 1676 else if (scrollBar.state == SB_STATE_MOTION && ev.xany.window == scrollBar.win)
1669 { 1677 {
1670 while (XCheckTypedWindowEvent (dpy, scrollBar.win, 1678 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1671 MotionNotify, &ev)) 1679 MotionNotify, &ev))
1672 ; 1680 ;
1673 1681
1674 XQueryPointer (dpy, scrollBar.win, 1682 XQueryPointer (dpy, scrollBar.win,
1675 &unused_root, &unused_child, 1683 &unused_root, &unused_child,
1676 &unused_root_x, &unused_root_y, 1684 &unused_root_x, &unused_root_y,
1677 &ev.xbutton.x, &ev.xbutton.y, 1685 &ev.xbutton.x, &ev.xbutton.y,
1678 &unused_mask); 1686 &unused_mask);
1679 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1687 scr_move_to (scrollBar.position (ev.xbutton.y) - csrO,
1680 scrollBar.size ()); 1688 scrollBar.size ());
1681 want_refresh = 1; 1689 want_refresh = 1;
1682 scrollBar.show (1); 1690 scrollBar.show (1);
1683 } 1691 }
1684 break; 1692 break;
1685 } 1693 }
1686 1694
1687#if defined(CURSOR_BLINK) 1695#if defined(CURSOR_BLINK)
1688 if (option (Opt_cursorBlink) && ev.type == KeyPress) 1696 if (ev.type == KeyPress)
1689 {
1690 if (hidden_cursor)
1691 {
1692 hidden_cursor = 0;
1693 want_refresh = 1;
1694 }
1695
1696 cursor_blink_ev.again (); 1697 cursor_blink_reset ();
1697 }
1698#endif 1698#endif
1699 1699
1700#if defined(POINTER_BLANK) 1700#if defined(POINTER_BLANK)
1701 if (option (Opt_pointerBlank) && pointerBlankDelay > 0) 1701 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1702 { 1702 {
1713 1713
1714 refresh_check (); 1714 refresh_check ();
1715} 1715}
1716 1716
1717#if ENABLE_FRILLS 1717#if ENABLE_FRILLS
1718void 1718void ecb_cold
1719rxvt_term::set_urgency (bool enable) 1719rxvt_term::set_urgency (bool enable)
1720{ 1720{
1721 if (enable == urgency_hint) 1721 if (enable == urgency_hint)
1722 return; 1722 return;
1723 1723
1724 if (XWMHints *h = XGetWMHints (dpy, parent)) 1724 if (XWMHints *h = XGetWMHints (dpy, parent))
1725 { 1725 {
1726 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); 1726 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1727 XSetWMHints (dpy, parent, h); 1727 XSetWMHints (dpy, parent, h);
1728 urgency_hint = enable; 1728 urgency_hint = enable;
1729 XFree (h);
1729 } 1730 }
1730} 1731}
1731#endif 1732#endif
1732 1733
1733void 1734void ecb_cold
1734rxvt_term::focus_in () 1735rxvt_term::focus_in ()
1735{ 1736{
1736 if (!focus) 1737 if (!focus)
1737 { 1738 {
1738 focus = 1; 1739 focus = 1;
1739 want_refresh = 1; 1740 want_refresh = 1;
1740 1741
1741#if USE_XIM 1742#if USE_XIM
1742 if (Input_Context != NULL) 1743 if (Input_Context != NULL)
1743 { 1744 {
1744 IMSetPosition (); 1745 im_set_position ();
1745 XSetICFocus (Input_Context); 1746 XSetICFocus (Input_Context);
1746 } 1747 }
1747#endif 1748#endif
1748#if CURSOR_BLINK 1749#if CURSOR_BLINK
1749 if (option (Opt_cursorBlink)) 1750 if (option (Opt_cursorBlink))
1763 1764
1764 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); 1765 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1765 } 1766 }
1766} 1767}
1767 1768
1768void 1769void ecb_cold
1769rxvt_term::focus_out () 1770rxvt_term::focus_out ()
1770{ 1771{
1771 if (focus) 1772 if (focus)
1772 { 1773 {
1773 focus = 0; 1774 focus = 0;
1806 1807
1807 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1808 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1808 } 1809 }
1809} 1810}
1810 1811
1811void 1812void ecb_cold
1812rxvt_term::update_fade_color (unsigned int idx) 1813rxvt_term::update_fade_color (unsigned int idx)
1813{ 1814{
1814#if OFF_FOCUS_FADING 1815#if OFF_FOCUS_FADING
1815 if (rs[Rs_fade]) 1816 if (rs[Rs_fade])
1816 { 1817 {
1820 } 1821 }
1821#endif 1822#endif
1822} 1823}
1823 1824
1824#if ENABLE_TRANSPARENCY || ENABLE_PERL 1825#if ENABLE_TRANSPARENCY || ENABLE_PERL
1825void 1826void ecb_hot
1826rxvt_term::rootwin_cb (XEvent &ev) 1827rxvt_term::rootwin_cb (XEvent &ev)
1827{ 1828{
1828 make_current (); 1829 make_current ();
1829 1830
1830 if (SHOULD_INVOKE (HOOK_ROOT_EVENT) 1831 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1980 if (scrollBar.upButton (ev.y)) 1981 if (scrollBar.upButton (ev.y))
1981 direction = UP; /* up */ 1982 direction = UP; /* up */
1982 else if (scrollBar.dnButton (ev.y)) 1983 else if (scrollBar.dnButton (ev.y))
1983 direction = DN; /* down */ 1984 direction = DN; /* down */
1984 1985
1985 scrollBar.state = STATE_IDLE; 1986 scrollBar.state = SB_STATE_IDLE;
1986 /* 1987 /*
1987 * Rxvt-style scrollbar: 1988 * Rxvt-style scrollbar:
1988 * move up if mouse is above slider 1989 * move up if mouse is above slider
1989 * move dn if mouse is below slider 1990 * move dn if mouse is below slider
1990 * 1991 *
2029 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2030 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2030#endif 2031#endif
2031 if (scr_page (direction, 1)) 2032 if (scr_page (direction, 1))
2032 { 2033 {
2033 if (direction == UP) 2034 if (direction == UP)
2034 scrollBar.state = STATE_UP; 2035 scrollBar.state = SB_STATE_UP;
2035 else 2036 else
2036 scrollBar.state = STATE_DOWN; 2037 scrollBar.state = SB_STATE_DOWN;
2037 } 2038 }
2038 } 2039 }
2039 else 2040 else
2040 switch (ev.button) 2041 switch (ev.button)
2041 { 2042 {
2042 case Button2: 2043 case Button2:
2043 switch (scrollBar.align) 2044 switch (scrollBar.align)
2044 { 2045 {
2045 case R_SB_ALIGN_TOP: 2046 case SB_ALIGN_TOP:
2046 csrO = 0; 2047 csrO = 0;
2047 break; 2048 break;
2048 case R_SB_ALIGN_CENTRE: 2049 case SB_ALIGN_CENTRE:
2049 csrO = (scrollBar.bot - scrollBar.top) / 2; 2050 csrO = (scrollBar.bot - scrollBar.top) / 2;
2050 break; 2051 break;
2051 case R_SB_ALIGN_BOTTOM: 2052 case SB_ALIGN_BOTTOM:
2052 csrO = scrollBar.bot - scrollBar.top; 2053 csrO = scrollBar.bot - scrollBar.top;
2053 break; 2054 break;
2054 } 2055 }
2055 2056
2056 if (scrollBar.style == R_SB_XTERM 2057 if (scrollBar.style == SB_STYLE_XTERM
2057 || scrollbar_above_slider (ev.y) 2058 || scrollBar.above_slider (ev.y)
2058 || scrollbar_below_slider (ev.y)) 2059 || scrollBar.below_slider (ev.y))
2059 scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ()); 2060 scr_move_to (scrollBar.position (ev.y) - csrO, scrollBar.size ());
2060 2061
2061 scrollBar.state = STATE_MOTION; 2062 scrollBar.state = SB_STATE_MOTION;
2062 break; 2063 break;
2063 2064
2064 case Button1: 2065 case Button1:
2065 if (scrollBar.align == R_SB_ALIGN_CENTRE) 2066 if (scrollBar.align == SB_ALIGN_CENTRE)
2066 csrO = ev.y - scrollBar.top; 2067 csrO = ev.y - scrollBar.top;
2067 /* FALLTHROUGH */ 2068 /* FALLTHROUGH */
2068 2069
2069 case Button3: 2070 case Button3:
2070 if (scrollBar.style != R_SB_XTERM) 2071 if (scrollBar.style != SB_STYLE_XTERM)
2071 { 2072 {
2072 if (scrollbar_above_slider (ev.y)) 2073 if (scrollBar.above_slider (ev.y))
2073# ifdef RXVT_SCROLL_FULL 2074# ifdef RXVT_SCROLL_FULL
2074 scr_page (UP, nrow - 1); 2075 scr_page (UP, nrow - 1);
2075# else 2076# else
2076 scr_page (UP, nrow / 4); 2077 scr_page (UP, nrow / 4);
2077# endif 2078# endif
2078 else if (scrollbar_below_slider (ev.y)) 2079 else if (scrollBar.below_slider (ev.y))
2079# ifdef RXVT_SCROLL_FULL 2080# ifdef RXVT_SCROLL_FULL
2080 scr_page (DN, nrow - 1); 2081 scr_page (DN, nrow - 1);
2081# else 2082# else
2082 scr_page (DN, nrow / 4); 2083 scr_page (DN, nrow / 4);
2083# endif 2084# endif
2084 else 2085 else
2085 scrollBar.state = STATE_MOTION; 2086 scrollBar.state = SB_STATE_MOTION;
2086 } 2087 }
2087 else 2088 else
2088 { 2089 {
2089 scr_page ((ev.button == Button1 ? DN : UP), 2090 scr_page ((ev.button == Button1 ? DN : UP),
2090 (nrow 2091 (nrow
2091 * scrollbar_position (ev.y) 2092 * scrollBar.position (ev.y)
2092 / scrollBar.size ())); 2093 / scrollBar.size ()));
2093 } 2094 }
2094 2095
2095 break; 2096 break;
2096 } 2097 }
2107 2108
2108 csrO = 0; /* reset csr Offset */ 2109 csrO = 0; /* reset csr Offset */
2109 if (!bypass_keystate) 2110 if (!bypass_keystate)
2110 reportmode = !! (priv_modes & PrivMode_mouse_report); 2111 reportmode = !! (priv_modes & PrivMode_mouse_report);
2111 2112
2112 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) 2113 if (scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN)
2113 { 2114 {
2114 scrollBar.state = STATE_IDLE; 2115 scrollBar.state = SB_STATE_IDLE;
2115 scrollBar.show (0); 2116 scrollBar.show (0);
2116 } 2117 }
2117 2118
2118#ifdef SELECTION_SCROLLING 2119#ifdef SELECTION_SCROLLING
2119 sel_scroll_ev.stop(); 2120 sel_scroll_ev.stop();
2169 case Button3: 2170 case Button3:
2170 selection_make (ev.time); 2171 selection_make (ev.time);
2171 break; 2172 break;
2172 2173
2173 case Button2: 2174 case Button2:
2174 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? 2175 if (IN_RANGE_EXC (ev.x, 0, vt_width) && IN_RANGE_EXC (ev.y, 0, vt_height)) // inside window?
2175 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); 2176 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
2176 break; 2177 break;
2177 2178
2178#ifdef MOUSE_WHEEL 2179#ifdef MOUSE_WHEEL
2179 case Button4: 2180 case Button4:
2214 } 2215 }
2215} 2216}
2216 2217
2217/*}}} */ 2218/*}}} */
2218 2219
2219void 2220void ecb_hot
2220rxvt_term::cmd_parse () 2221rxvt_term::cmd_parse ()
2221{ 2222{
2222 wchar_t ch = NOCHAR; 2223 wchar_t ch = NOCHAR;
2223 char *seq_begin; // remember start of esc-sequence here 2224 char *seq_begin; // remember start of esc-sequence here
2224 2225
2225 for (;;) 2226 for (;;)
2226 { 2227 {
2227 if (expect_false (ch == NOCHAR)) 2228 if (ecb_unlikely (ch == NOCHAR))
2228 { 2229 {
2229 seq_begin = cmdbuf_ptr; 2230 seq_begin = cmdbuf_ptr;
2230 ch = next_char (); 2231 ch = next_char ();
2231 2232
2232 if (ch == NOCHAR) 2233 if (ch == NOCHAR)
2233 break; 2234 break;
2234 } 2235 }
2235 2236
2236 if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) 2237 if (ecb_likely (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
2237 { 2238 {
2238 if (expect_false (!seen_input)) 2239 if (ecb_unlikely (!seen_input))
2239 { 2240 {
2240 seen_input = 1; 2241 seen_input = 1;
2241 // many badly-written programs (e.g. jed) contain a race condition: 2242 // many badly-written programs (e.g. jed) contain a race condition:
2242 // they first read the screensize and then install a SIGWINCH handler. 2243 // they first read the screensize and then install a SIGWINCH handler.
2243 // some window managers resize the window early, and these programs 2244 // some window managers resize the window early, and these programs
2256 wchar_t *str = buf; 2257 wchar_t *str = buf;
2257 wchar_t *eol = str + min (ncol, UBUFSIZ); 2258 wchar_t *eol = str + min (ncol, UBUFSIZ);
2258 2259
2259 for (;;) 2260 for (;;)
2260 { 2261 {
2261 if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) 2262 if (ecb_unlikely (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
2262 break; 2263 break;
2263 2264
2264 *str++ = ch; 2265 *str++ = ch;
2265 2266
2266 if (expect_false (ch == C0_LF || str >= eol)) 2267 if (ecb_unlikely (ch == C0_LF || str >= eol))
2267 { 2268 {
2268 if (ch == C0_LF) 2269 if (ch == C0_LF)
2269 nlines++; 2270 nlines++;
2270 2271
2271 refresh_count++; 2272 refresh_count++;
2343 } 2344 }
2344 } 2345 }
2345} 2346}
2346 2347
2347// read the next character 2348// read the next character
2348wchar_t 2349wchar_t ecb_hot
2349rxvt_term::next_char () NOTHROW 2350rxvt_term::next_char () NOTHROW
2350{ 2351{
2351 while (cmdbuf_ptr < cmdbuf_endp) 2352 while (cmdbuf_ptr < cmdbuf_endp)
2352 { 2353 {
2353 // assume 7-bit to be ascii ALWAYS 2354 // assume 7-bit to be ascii ALWAYS
2354 if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) 2355 if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
2355 return *cmdbuf_ptr++; 2356 return *cmdbuf_ptr++;
2356 2357
2357 wchar_t wc; 2358 wchar_t wc;
2358 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 2359 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
2359 2360
2377 2378
2378 return NOCHAR; 2379 return NOCHAR;
2379} 2380}
2380 2381
2381// read the next octet 2382// read the next octet
2382uint32_t 2383uint32_t ecb_hot
2383rxvt_term::next_octet () NOTHROW 2384rxvt_term::next_octet () NOTHROW
2384{ 2385{
2385 return cmdbuf_ptr < cmdbuf_endp 2386 return cmdbuf_ptr < cmdbuf_endp
2386 ? (unsigned char)*cmdbuf_ptr++ 2387 ? (unsigned char)*cmdbuf_ptr++
2387 : NOCHAR; 2388 : NOCHAR;
2388} 2389}
2389 2390
2390static class out_of_input out_of_input; 2391static class out_of_input out_of_input;
2391 2392
2392wchar_t 2393wchar_t ecb_hot
2393rxvt_term::cmd_getc () THROW ((class out_of_input)) 2394rxvt_term::cmd_getc () THROW ((class out_of_input))
2394{ 2395{
2395 wchar_t c = next_char (); 2396 wchar_t c = next_char ();
2396 2397
2397 if (c == NOCHAR) 2398 if (c == NOCHAR)
2398 throw out_of_input; 2399 throw out_of_input;
2399 2400
2400 return c; 2401 return c;
2401} 2402}
2402 2403
2403uint32_t 2404uint32_t ecb_hot
2404rxvt_term::cmd_get8 () THROW ((class out_of_input)) 2405rxvt_term::cmd_get8 () THROW ((class out_of_input))
2405{ 2406{
2406 uint32_t c = next_octet (); 2407 uint32_t c = next_octet ();
2407 2408
2408 if (c == NOCHAR) 2409 if (c == NOCHAR)
2412} 2413}
2413 2414
2414/*{{{ print pipe */ 2415/*{{{ print pipe */
2415/*----------------------------------------------------------------------*/ 2416/*----------------------------------------------------------------------*/
2416#ifdef PRINTPIPE 2417#ifdef PRINTPIPE
2417FILE * 2418FILE * ecb_cold
2418rxvt_term::popen_printer () 2419rxvt_term::popen_printer ()
2419{ 2420{
2420 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); 2421 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w");
2421 2422
2422 if (stream == NULL) 2423 if (stream == NULL)
2423 rxvt_warn ("can't open printer pipe, not printing.\n"); 2424 rxvt_warn ("can't open printer pipe, not printing.\n");
2424 2425
2425 return stream; 2426 return stream;
2426} 2427}
2427 2428
2428int 2429int ecb_cold
2429rxvt_term::pclose_printer (FILE *stream) 2430rxvt_term::pclose_printer (FILE *stream)
2430{ 2431{
2431 fflush (stream); 2432 fflush (stream);
2432 return pclose (stream); 2433 return pclose (stream);
2433} 2434}
2434 2435
2435/* 2436/*
2436 * simulate attached vt100 printer 2437 * simulate attached vt100 printer
2437 */ 2438 */
2438void 2439void ecb_cold
2439rxvt_term::process_print_pipe () 2440rxvt_term::process_print_pipe ()
2440{ 2441{
2441 FILE *fd = popen_printer (); 2442 FILE *fd = popen_printer ();
2442 2443
2443 if (!fd) 2444 if (!fd)
2498 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, 2499 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,
2499 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC, 2500 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC,
2500}; 2501};
2501 2502
2502/*{{{ process non-printing single characters */ 2503/*{{{ process non-printing single characters */
2503void 2504void ecb_hot
2504rxvt_term::process_nonprinting (unicode_t ch) 2505rxvt_term::process_nonprinting (unicode_t ch)
2505{ 2506{
2506 switch (ch) 2507 switch (ch)
2507 { 2508 {
2508 case C0_ESC: 2509 case C0_ESC:
2554} 2555}
2555/*}}} */ 2556/*}}} */
2556 2557
2557 2558
2558/*{{{ process VT52 escape sequences */ 2559/*{{{ process VT52 escape sequences */
2559void 2560void ecb_cold
2560rxvt_term::process_escape_vt52 (unicode_t ch) 2561rxvt_term::process_escape_vt52 (unicode_t ch)
2561{ 2562{
2562 int row, col; 2563 int row, col;
2563 2564
2564 switch (ch) 2565 switch (ch)
2598 break; 2599 break;
2599 case 'Z': /* identify the terminal type */ 2600 case 'Z': /* identify the terminal type */
2600 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ 2601 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */
2601 break; 2602 break;
2602 case '<': /* turn off VT52 mode */ 2603 case '<': /* turn off VT52 mode */
2603 set_privmode (PrivMode_vt52, 0); 2604 priv_modes &= ~PrivMode_vt52;
2604 break; 2605 break;
2605 case 'F': /* use special graphics character set */ 2606 case 'F': /* use special graphics character set */
2606 case 'G': /* use regular character set */ 2607 case 'G': /* use regular character set */
2607 /* unimplemented */ 2608 /* unimplemented */
2608 break; 2609 break;
2614} 2615}
2615/*}}} */ 2616/*}}} */
2616 2617
2617 2618
2618/*{{{ process escape sequences */ 2619/*{{{ process escape sequences */
2619void 2620void ecb_hot
2620rxvt_term::process_escape_seq () 2621rxvt_term::process_escape_seq ()
2621{ 2622{
2622 unicode_t ch = cmd_getc (); 2623 unicode_t ch = cmd_getc ();
2623 2624
2624 if (priv_modes & PrivMode_vt52) 2625 if (priv_modes & PrivMode_vt52)
2627 return; 2628 return;
2628 } 2629 }
2629 2630
2630 switch (ch) 2631 switch (ch)
2631 { 2632 {
2632 /* case 1: do_tek_mode (); break; */
2633 case '#': 2633 case '#':
2634 if (cmd_getc () == '8') 2634 if (cmd_getc () == '8')
2635 scr_E (); 2635 scr_E ();
2636 break; 2636 break;
2637 case '(': 2637 case '(':
2660#if !ENABLE_MINIMAL 2660#if !ENABLE_MINIMAL
2661 case '9': 2661 case '9':
2662 scr_forwardindex (); 2662 scr_forwardindex ();
2663 break; 2663 break;
2664#endif 2664#endif
2665 // DECPAM/DECPNM
2665 case '=': 2666 case '=':
2667 priv_modes |= PrivMode_aplKP;
2668 break;
2666 case '>': 2669 case '>':
2667 set_privmode (PrivMode_aplKP, ch == '='); 2670 priv_modes &= ~PrivMode_aplKP;
2668 break; 2671 break;
2669 2672
2670 case C1_40: 2673 case C1_40:
2671 cmd_getc (); 2674 cmd_getc ();
2672 break; 2675 break;
2676 2679
2677 /* 8.3.87: NEXT LINE */ 2680 /* 8.3.87: NEXT LINE */
2678 case C1_NEL: /* ESC E */ 2681 case C1_NEL: /* ESC E */
2679 { 2682 {
2680 wchar_t nlcr[] = { C0_LF, C0_CR }; 2683 wchar_t nlcr[] = { C0_LF, C0_CR };
2681 scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1); 2684 scr_add_lines (nlcr, ecb_array_length (nlcr), 1);
2682 } 2685 }
2683 break; 2686 break;
2684 2687
2685 /* kidnapped escape sequence: Should be 8.3.48 */ 2688 /* kidnapped escape sequence: Should be 8.3.48 */
2686 case C1_ESA: /* ESC G */ 2689 case C1_ESA: /* ESC G */
2698 case C1_RI: /* ESC M */ 2701 case C1_RI: /* ESC M */
2699 scr_index (DN); 2702 scr_index (DN);
2700 break; 2703 break;
2701 2704
2702 /* 8.3.142: SINGLE-SHIFT TWO */ 2705 /* 8.3.142: SINGLE-SHIFT TWO */
2703 /*case C1_SS2: scr_single_shift (2); break; */ 2706 /* case C1_SS2: break; */
2704 2707
2705 /* 8.3.143: SINGLE-SHIFT THREE */ 2708 /* 8.3.143: SINGLE-SHIFT THREE */
2706 /*case C1_SS3: scr_single_shift (3); break; */ 2709 /* case C1_SS3: break; */
2707 2710
2708 /* 8.3.27: DEVICE CONTROL STRING */ 2711 /* 8.3.27: DEVICE CONTROL STRING */
2709 case C1_DCS: /* ESC P */ 2712 case C1_DCS: /* ESC P */
2710 process_dcs_seq (); 2713 process_dcs_seq ();
2711 break; 2714 break;
2774 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ 2777 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */
2775 make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ 2778 make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */
2776 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */ 2779 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */
2777 }; 2780 };
2778 2781
2779void 2782void ecb_hot
2780rxvt_term::process_csi_seq () 2783rxvt_term::process_csi_seq ()
2781{ 2784{
2782 unicode_t ch, priv, i; 2785 unicode_t ch, priv, i;
2783 unsigned int nargs, p; 2786 unsigned int nargs, p;
2784 int n, ndef; 2787 int n, ndef;
2862 scr_soft_reset (); 2865 scr_soft_reset ();
2863 2866
2864 static const int pm_h[] = { 7, 25 }; 2867 static const int pm_h[] = { 7, 25 };
2865 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; 2868 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 };
2866 2869
2867 process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h); 2870 process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h);
2868 process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l); 2871 process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l);
2869 } 2872 }
2870 break; 2873 break;
2871 } 2874 }
2872 2875
2873 return; 2876 return;
2891 } 2894 }
2892 break; 2895 break;
2893#endif 2896#endif
2894 2897
2895 case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ 2898 case CSI_CUU: /* 8.3.22: (1) CURSOR UP */
2896 case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ 2899 case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */
2897 arg[0] = -arg[0]; 2900 arg[0] = -arg[0];
2898 /* FALLTHROUGH */ 2901 /* FALLTHROUGH */
2899 case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ 2902 case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */
2900 case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ 2903 case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */
2901 scr_gotorc (arg[0], 0, RELATIVE); 2904 scr_gotorc (arg[0], 0, RELATIVE);
2902 break; 2905 break;
2903 2906
2904 case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ 2907 case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */
2905 case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */ 2908 case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */
3138 break; 3141 break;
3139 3142
3140 //case 9: NYI, TODO, restore maximized window or maximize window 3143 //case 9: NYI, TODO, restore maximized window or maximize window
3141 default: 3144 default:
3142 if (args[0] >= 24) /* set height (chars) */ 3145 if (args[0] >= 24) /* set height (chars) */
3143 set_widthheight ((unsigned int)width, 3146 set_widthheight ((unsigned int)vt_width,
3144 (unsigned int) (args[1] * fheight)); 3147 (unsigned int) (args[1] * fheight));
3145 break; 3148 break;
3146 3149
3147 /* 3150 /*
3148 * reports - some output format copied from XTerm 3151 * reports - some output format copied from XTerm
3448#if BG_IMAGE_FROM_FILE 3451#if BG_IMAGE_FROM_FILE
3449 case Rxvt_Pixmap: 3452 case Rxvt_Pixmap:
3450 if (!strcmp (str, "?")) 3453 if (!strcmp (str, "?"))
3451 { 3454 {
3452 char str[256]; 3455 char str[256];
3456 int h_scale = 0, v_scale = 0;
3457 int h_align = 0, v_align = 0;
3458 if (image_vec.size () > 0)
3459 {
3460 h_scale = image_vec[0].h_scale;
3461 v_scale = image_vec[0].v_scale;
3462 h_align = image_vec[0].h_align;
3463 v_align = image_vec[0].v_align;
3464 }
3453 3465
3454 sprintf (str, "[%dx%d+%d+%d]", 3466 sprintf (str, "[%dx%d+%d+%d]",
3455 min (h_scale, 32767), min (v_scale, 32767), 3467 h_scale, v_scale,
3456 min (h_align, 32767), min (v_align, 32767)); 3468 h_align, v_align);
3457 process_xterm_seq (XTerm_title, str, CHAR_ST); 3469 process_xterm_seq (XTerm_title, str, CHAR_ST);
3458 } 3470 }
3459 else 3471 else
3460 { 3472 {
3461 int changed = 0; 3473 bool changed = false;
3462 3474
3463 if (*str != ';') 3475 if (*str != ';')
3464 { 3476 {
3465 if (bg_set_file (str)) /* change pixmap */ 3477 if (image_vec.size () > 0)
3478 changed = image_vec[0].set_file_geometry (str);
3479 else
3466 { 3480 {
3467 changed++; 3481 rxvt_image *image = new_image ();
3468 str = strchr (str, ';'); 3482 if (!image->set_file_geometry (str))
3469 if (str == NULL) 3483 image_vec.pop_back ();
3470 bg_set_default_geometry ();
3471 else 3484 else
3472 bg_set_geometry (str+1); 3485 changed = true;
3473 } 3486 }
3474 } 3487 }
3475 else 3488 else
3476 { 3489 {
3477 str++; 3490 str++;
3491 if (image_vec.size () > 0)
3478 if (bg_set_geometry (str, true)) 3492 changed = image_vec[0].set_geometry (str, true);
3479 changed++;
3480 } 3493 }
3481 3494
3482 if (changed) 3495 if (changed)
3483 { 3496 {
3484 if (bg_window_position_sensitive ()) 3497 if (bg_window_position_sensitive ())
3583 * 's' = save 3596 * 's' = save
3584 * 'r' = restore 3597 * 'r' = restore
3585 * 't' = toggle 3598 * 't' = toggle
3586 * so no need for fancy checking 3599 * so no need for fancy checking
3587 */ 3600 */
3588int 3601int ecb_cold
3589rxvt_term::privcases (int mode, unsigned long bit) 3602rxvt_term::privcases (int mode, unsigned long bit)
3590{ 3603{
3591 int state; 3604 int state;
3592 3605
3593 if (mode == 's') 3606 if (mode == 's')
3594 { 3607 {
3595 SavedModes |= (priv_modes & bit); 3608 if (priv_modes & bit)
3609 SavedModes |= bit;
3610 else
3611 SavedModes &= ~bit;
3596 return -1; 3612 return -1;
3597 } 3613 }
3598 else 3614 else
3599 { 3615 {
3600 if (mode == 'r') 3616 if (mode == 'r')
3601 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3617 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
3602 else 3618 else
3603 state = (mode == 't') ? ! (priv_modes & bit) : mode; 3619 state = (mode == 't') ? ! (priv_modes & bit) : mode;
3604 3620
3605 set_privmode (bit, state); 3621 if (state)
3622 priv_modes |= bit;
3623 else
3624 priv_modes &= ~bit;
3606 } 3625 }
3607 3626
3608 return state; 3627 return state;
3609} 3628}
3610 3629
3611/* we're not using priv _yet_ */ 3630/* we're not using priv _yet_ */
3612void 3631void
3613rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) 3632rxvt_term::process_terminal_mode (int mode, int priv ecb_unused, unsigned int nargs, const int *arg)
3614{ 3633{
3615 unsigned int i, j; 3634 unsigned int i, j;
3616 int state; 3635 int state;
3617 3636
3618 static const struct 3637 static const struct
3619 { 3638 {
3620 const int argval; 3639 const int argval;
3621 const unsigned long bit; 3640 const unsigned long bit;
3622 } argtopriv[] = { 3641 } argtopriv[] = {
3623 { 1, PrivMode_aplCUR }, // DECCKM 3642 { 1, PrivMode_aplCUR }, // DECCKM
3624 { 2, PrivMode_vt52 }, 3643 { 2, PrivMode_vt52 }, // DECANM
3625 { 3, PrivMode_132 }, // DECCOLM 3644 { 3, PrivMode_132 }, // DECCOLM
3626 { 4, PrivMode_smoothScroll }, // DECSCLM 3645 { 4, PrivMode_smoothScroll }, // DECSCLM
3627 { 5, PrivMode_rVideo }, // DECSCNM 3646 { 5, PrivMode_rVideo }, // DECSCNM
3628 { 6, PrivMode_relOrigin }, // DECOM 3647 { 6, PrivMode_relOrigin }, // DECOM
3629 { 7, PrivMode_Autowrap }, // DECAWM 3648 { 7, PrivMode_Autowrap }, // DECAWM
3630 // 8, auto-repeat keys // DECARM 3649 // 8, auto-repeat keys // DECARM
3631 { 9, PrivMode_MouseX10 }, 3650 { 9, PrivMode_MouseX10 },
3632 // 18 end FF to printer after print screen 3651 // 18 end FF to printer after print screen
3633 // 19 Print screen prints full screen/scroll region 3652 // 19 Print screen prints full screen/scroll region
3634 { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis 3653 { 25, PrivMode_VisibleCursor }, // DECTCEM cnorm/cvvis/civis
3635#ifdef scrollBar_esc 3654#ifdef scrollBar_esc
3636 { scrollBar_esc, PrivMode_scrollBar }, 3655 { scrollBar_esc, PrivMode_scrollBar },
3637#endif 3656#endif
3638 { 35, PrivMode_ShiftKeys }, // rxvt extension 3657 { 35, PrivMode_ShiftKeys }, // rxvt extension
3639 // 38, tektronix mode // DECTEK 3658 // 38, tektronix mode // DECTEK
3640 { 40, PrivMode_132OK }, 3659 { 40, PrivMode_132OK },
3641 // 41 xterm more fixes NYI 3660 // 41 xterm more fixes NYI
3642 // 45 margin bell NYI 3661 // 45 margin bell NYI
3643 // 46 start logging 3662 // 46 start logging
3644 { 47, PrivMode_Screen }, 3663 { 47, PrivMode_Screen },
3645 { 66, PrivMode_aplKP }, // DECPAM/DECPNM 3664 { 66, PrivMode_aplKP }, // DECNKM
3646#ifndef NO_BACKSPACE_KEY 3665#ifndef NO_BACKSPACE_KEY
3647 { 67, PrivMode_BackSpace }, // DECBKM 3666 { 67, PrivMode_BackSpace }, // DECBKM
3648#endif 3667#endif
3649 { 1000, PrivMode_MouseX11 }, 3668 { 1000, PrivMode_MouseX11 },
3650 { 1002, PrivMode_MouseBtnEvent }, 3669 { 1002, PrivMode_MouseBtnEvent },
3679 for (i = 0; i < nargs; i++) 3698 for (i = 0; i < nargs; i++)
3680 { 3699 {
3681 state = -1; 3700 state = -1;
3682 3701
3683 /* basic handling */ 3702 /* basic handling */
3684 for (j = 0; j < ARRAY_LENGTH(argtopriv); j++) 3703 for (j = 0; j < ecb_array_length (argtopriv); j++)
3685 if (argtopriv[j].argval == arg[i]) 3704 if (argtopriv[j].argval == arg[i])
3686 { 3705 {
3687 state = privcases (mode, argtopriv[j].bit); 3706 state = privcases (mode, argtopriv[j].bit);
3688 break; 3707 break;
3689 } 3708 }
3715 case 2: /* VT52 mode */ 3734 case 2: /* VT52 mode */
3716 /* oddball mode. should be set regardless of set/reset 3735 /* oddball mode. should be set regardless of set/reset
3717 * parameter. Return from VT52 mode with an ESC < from 3736 * parameter. Return from VT52 mode with an ESC < from
3718 * within VT52 mode 3737 * within VT52 mode
3719 */ 3738 */
3720 set_privmode (PrivMode_vt52, 1); 3739 priv_modes |= PrivMode_vt52;
3721 break; 3740 break;
3722 case 3: /* 80/132 */ 3741 case 3: /* 80/132 */
3723 if (priv_modes & PrivMode_132OK) 3742 if (priv_modes & PrivMode_132OK)
3724 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); 3743 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight);
3725 break; 3744 break;
3740 if (state) /* orthogonal */ 3759 if (state) /* orthogonal */
3741 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3760 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3742 break; 3761 break;
3743#ifdef scrollBar_esc 3762#ifdef scrollBar_esc
3744 case scrollBar_esc: 3763 case scrollBar_esc:
3745 if (scrollBar.map (state)) 3764 scrollBar.map (state);
3746 {
3747 resize_all_windows (0, 0, 0); 3765 resize_all_windows (0, 0, 0);
3748 scr_touch (true); 3766 scr_touch (true);
3749 }
3750 break; 3767 break;
3751#endif 3768#endif
3752 case 25: /* visible/invisible cursor */ 3769 case 25: /* visible/invisible cursor */
3753 scr_cursor_visible (state); 3770 scr_cursor_visible (state);
3754 break; 3771 break;
3809 } 3826 }
3810} 3827}
3811/*}}} */ 3828/*}}} */
3812 3829
3813/*{{{ process sgr sequences */ 3830/*{{{ process sgr sequences */
3814void 3831void ecb_hot
3815rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) 3832rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
3816{ 3833{
3817 unsigned int i; 3834 unsigned int i;
3818 short rendset; 3835 short rendset;
3819 int rendstyle; 3836 int rendstyle;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines