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.516 by root, Tue Jun 5 14:46:54 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;
424 ctrl = ev.state & ControlMask; 421 ctrl = ev.state & ControlMask;
425 meta = ev.state & ModMetaMask; 422 meta = ev.state & ModMetaMask;
426 423
427 kbuf[0] = 0; 424 kbuf[0] = 0;
428 425
429#ifdef USE_XIM 426#if USE_XIM
430 if (Input_Context) 427 if (Input_Context)
431 { 428 {
432 Status status_return; 429 Status status_return;
433 430
434#if 0 431#if 0
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
989 while (row < end_row); 987 while (row < end_row);
990 } 988 }
991 989
992 scr_refresh (); 990 scr_refresh ();
993 scrollBar.show (1); 991 scrollBar.show (1);
994#ifdef USE_XIM 992#if 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);
1448 if (ev.xconfigure.window == parent) 1461 if (ev.xconfigure.window == parent)
1449 { 1462 {
1450 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1463 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1451 ; 1464 ;
1452 1465
1466 bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE);
1467
1453#ifdef HAVE_BG_PIXMAP 1468#ifdef HAVE_BG_PIXMAP
1469 if (bg_window_position_sensitive ())
1470 want_position_change = true;
1471#endif
1472
1454 bool moved = false; 1473 bool moved = false;
1455 if (bg_window_position_sensitive ()) 1474
1475 if (want_position_change)
1456 { 1476 {
1457 int x, y; 1477 int x, y;
1478
1458 if (ev.xconfigure.send_event) 1479 if (ev.xconfigure.send_event)
1459 { 1480 {
1460 x = ev.xconfigure.x; 1481 x = ev.xconfigure.x;
1461 y = ev.xconfigure.y; 1482 y = ev.xconfigure.y;
1462 } 1483 }
1463 else 1484 else
1464 get_window_origin (x, y); 1485 get_window_origin (x, y);
1465 1486
1487 if (x != parent_x || y != parent_y)
1488 {
1489 HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END));
1490 parent_x = x;
1491 parent_y = y;
1492 }
1493
1466 if (bg_set_position (x, y) 1494 if (bg_set_position (x, y)
1467 || !(bg_flags & BG_IS_VALID)) 1495 || !(bg_flags & BG_IS_VALID))
1468 moved = true; 1496 moved = true;
1469 } 1497 }
1470#endif
1471 1498
1472 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1499 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1473 { 1500 {
1474 seen_resize = 1; 1501 seen_resize = 1;
1475 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1502 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1476 } 1503 }
1477 else 1504 else
1478 { 1505 {
1479#ifdef HAVE_BG_PIXMAP 1506#ifdef HAVE_BG_PIXMAP
1480 if (moved) 1507 if (moved)
1481 {
1482 if (mapped)
1483 update_background (); 1508 update_background ();
1484 else
1485 bg_invalidate ();
1486 }
1487#endif 1509#endif
1488 } 1510 }
1489 1511
1490 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1512 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1491 } 1513 }
1565 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) 1587 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1566 ; 1588 ;
1567 1589
1568 if (scrollBar.state && ev.xany.window == scrollBar.win) 1590 if (scrollBar.state && ev.xany.window == scrollBar.win)
1569 { 1591 {
1570 scrollBar.state = STATE_IDLE; 1592 scrollBar.state = SB_STATE_IDLE;
1571 scrollBar.show (0); 1593 scrollBar.show (0);
1572 } 1594 }
1573 } 1595 }
1574 break; 1596 break;
1575 1597
1641 dist = int_bwidth - ev.xbutton.y; 1663 dist = int_bwidth - ev.xbutton.y;
1642 } 1664 }
1643 else 1665 else
1644 { 1666 {
1645 scroll_selection_dir = DN; 1667 scroll_selection_dir = DN;
1646 dist = ev.xbutton.y - (int_bwidth + height); 1668 dist = ev.xbutton.y - (int_bwidth + vt_height);
1647 } 1669 }
1648 1670
1649 scroll_selection_lines = Pixel2Height (dist) 1671 scroll_selection_lines = Pixel2Height (dist)
1650 / SELECTION_SCROLL_LINE_SPEEDUP 1672 / SELECTION_SCROLL_LINE_SPEEDUP
1651 + 1; 1673 + 1;
1663#ifdef MOUSE_THRESHOLD 1685#ifdef MOUSE_THRESHOLD
1664 } 1686 }
1665#endif 1687#endif
1666 } 1688 }
1667 } 1689 }
1668 else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) 1690 else if (scrollBar.state == SB_STATE_MOTION && ev.xany.window == scrollBar.win)
1669 { 1691 {
1670 while (XCheckTypedWindowEvent (dpy, scrollBar.win, 1692 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1671 MotionNotify, &ev)) 1693 MotionNotify, &ev))
1672 ; 1694 ;
1673 1695
1674 XQueryPointer (dpy, scrollBar.win, 1696 XQueryPointer (dpy, scrollBar.win,
1675 &unused_root, &unused_child, 1697 &unused_root, &unused_child,
1676 &unused_root_x, &unused_root_y, 1698 &unused_root_x, &unused_root_y,
1677 &ev.xbutton.x, &ev.xbutton.y, 1699 &ev.xbutton.x, &ev.xbutton.y,
1678 &unused_mask); 1700 &unused_mask);
1679 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1701 scr_move_to (scrollBar.position (ev.xbutton.y) - csrO,
1680 scrollBar.size ()); 1702 scrollBar.size ());
1681 want_refresh = 1; 1703 want_refresh = 1;
1682 scrollBar.show (1); 1704 scrollBar.show (1);
1683 } 1705 }
1684 break; 1706 break;
1685 } 1707 }
1686 1708
1687#if defined(CURSOR_BLINK) 1709#if defined(CURSOR_BLINK)
1688 if (option (Opt_cursorBlink) && ev.type == KeyPress) 1710 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 (); 1711 cursor_blink_reset ();
1697 }
1698#endif 1712#endif
1699 1713
1700#if defined(POINTER_BLANK) 1714#if defined(POINTER_BLANK)
1701 if (option (Opt_pointerBlank) && pointerBlankDelay > 0) 1715 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1702 { 1716 {
1713 1727
1714 refresh_check (); 1728 refresh_check ();
1715} 1729}
1716 1730
1717#if ENABLE_FRILLS 1731#if ENABLE_FRILLS
1718void 1732void ecb_cold
1719rxvt_term::set_urgency (bool enable) 1733rxvt_term::set_urgency (bool enable)
1720{ 1734{
1721 if (enable == urgency_hint) 1735 if (enable == urgency_hint)
1722 return; 1736 return;
1723 1737
1724 if (XWMHints *h = XGetWMHints (dpy, parent)) 1738 if (XWMHints *h = XGetWMHints (dpy, parent))
1725 { 1739 {
1726 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); 1740 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1727 XSetWMHints (dpy, parent, h); 1741 XSetWMHints (dpy, parent, h);
1728 urgency_hint = enable; 1742 urgency_hint = enable;
1743 XFree (h);
1729 } 1744 }
1730} 1745}
1731#endif 1746#endif
1732 1747
1733void 1748void ecb_cold
1734rxvt_term::focus_in () 1749rxvt_term::focus_in ()
1735{ 1750{
1736 if (!focus) 1751 if (!focus)
1737 { 1752 {
1738 focus = 1; 1753 focus = 1;
1739 want_refresh = 1; 1754 want_refresh = 1;
1740 1755
1741#if USE_XIM 1756#if USE_XIM
1742 if (Input_Context != NULL) 1757 if (Input_Context != NULL)
1743 { 1758 {
1744 IMSetPosition (); 1759 im_set_position ();
1745 XSetICFocus (Input_Context); 1760 XSetICFocus (Input_Context);
1746 } 1761 }
1747#endif 1762#endif
1748#if CURSOR_BLINK 1763#if CURSOR_BLINK
1749 if (option (Opt_cursorBlink)) 1764 if (option (Opt_cursorBlink))
1763 1778
1764 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); 1779 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1765 } 1780 }
1766} 1781}
1767 1782
1768void 1783void ecb_cold
1769rxvt_term::focus_out () 1784rxvt_term::focus_out ()
1770{ 1785{
1771 if (focus) 1786 if (focus)
1772 { 1787 {
1773 focus = 0; 1788 focus = 0;
1806 1821
1807 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1822 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1808 } 1823 }
1809} 1824}
1810 1825
1811void 1826void ecb_cold
1812rxvt_term::update_fade_color (unsigned int idx) 1827rxvt_term::update_fade_color (unsigned int idx)
1813{ 1828{
1814#if OFF_FOCUS_FADING 1829#if OFF_FOCUS_FADING
1815 if (rs[Rs_fade]) 1830 if (rs[Rs_fade])
1816 { 1831 {
1820 } 1835 }
1821#endif 1836#endif
1822} 1837}
1823 1838
1824#if ENABLE_TRANSPARENCY || ENABLE_PERL 1839#if ENABLE_TRANSPARENCY || ENABLE_PERL
1825void 1840void ecb_hot
1826rxvt_term::rootwin_cb (XEvent &ev) 1841rxvt_term::rootwin_cb (XEvent &ev)
1827{ 1842{
1828 make_current (); 1843 make_current ();
1829 1844
1830 if (SHOULD_INVOKE (HOOK_ROOT_EVENT) 1845 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1831 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) 1846 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1832 return; 1847 return;
1833 1848
1834# if ENABLE_TRANSPARENCY
1835 switch (ev.type) 1849 switch (ev.type)
1836 { 1850 {
1837 case PropertyNotify: 1851 case PropertyNotify:
1838 /* 1852 /*
1839 * if user used some Esetroot compatible prog to set the root bg, 1853 * if user used some Esetroot compatible prog to set the root bg,
1840 * use the property to determine the pixmap. We use it later on. 1854 * use the property to determine the pixmap. We use it later on.
1841 */ 1855 */
1842 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] 1856 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1843 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) 1857 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1844 { 1858 {
1859# if ENABLE_TRANSPARENCY
1845 bg_set_root_pixmap (); 1860 bg_set_root_pixmap ();
1846 update_background (); 1861 update_background ();
1862#endif
1863#if ENABLE_PERL
1864 HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END));
1865#endif
1847 } 1866 }
1848 1867
1849 break; 1868 break;
1850 } 1869 }
1851# endif
1852 1870
1853 refresh_check (); 1871 refresh_check ();
1854} 1872}
1855#endif 1873#endif
1856 1874
1980 if (scrollBar.upButton (ev.y)) 1998 if (scrollBar.upButton (ev.y))
1981 direction = UP; /* up */ 1999 direction = UP; /* up */
1982 else if (scrollBar.dnButton (ev.y)) 2000 else if (scrollBar.dnButton (ev.y))
1983 direction = DN; /* down */ 2001 direction = DN; /* down */
1984 2002
1985 scrollBar.state = STATE_IDLE; 2003 scrollBar.state = SB_STATE_IDLE;
1986 /* 2004 /*
1987 * Rxvt-style scrollbar: 2005 * Rxvt-style scrollbar:
1988 * move up if mouse is above slider 2006 * move up if mouse is above slider
1989 * move dn if mouse is below slider 2007 * move dn if mouse is below slider
1990 * 2008 *
2029 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2047 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2030#endif 2048#endif
2031 if (scr_page (direction, 1)) 2049 if (scr_page (direction, 1))
2032 { 2050 {
2033 if (direction == UP) 2051 if (direction == UP)
2034 scrollBar.state = STATE_UP; 2052 scrollBar.state = SB_STATE_UP;
2035 else 2053 else
2036 scrollBar.state = STATE_DOWN; 2054 scrollBar.state = SB_STATE_DOWN;
2037 } 2055 }
2038 } 2056 }
2039 else 2057 else
2040 switch (ev.button) 2058 switch (ev.button)
2041 { 2059 {
2042 case Button2: 2060 case Button2:
2043 switch (scrollBar.align) 2061 switch (scrollBar.align)
2044 { 2062 {
2045 case R_SB_ALIGN_TOP: 2063 case SB_ALIGN_TOP:
2046 csrO = 0; 2064 csrO = 0;
2047 break; 2065 break;
2048 case R_SB_ALIGN_CENTRE: 2066 case SB_ALIGN_CENTRE:
2049 csrO = (scrollBar.bot - scrollBar.top) / 2; 2067 csrO = (scrollBar.bot - scrollBar.top) / 2;
2050 break; 2068 break;
2051 case R_SB_ALIGN_BOTTOM: 2069 case SB_ALIGN_BOTTOM:
2052 csrO = scrollBar.bot - scrollBar.top; 2070 csrO = scrollBar.bot - scrollBar.top;
2053 break; 2071 break;
2054 } 2072 }
2055 2073
2056 if (scrollBar.style == R_SB_XTERM 2074 if (scrollBar.style == SB_STYLE_XTERM
2057 || scrollbar_above_slider (ev.y) 2075 || scrollBar.above_slider (ev.y)
2058 || scrollbar_below_slider (ev.y)) 2076 || scrollBar.below_slider (ev.y))
2059 scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ()); 2077 scr_move_to (scrollBar.position (ev.y) - csrO, scrollBar.size ());
2060 2078
2061 scrollBar.state = STATE_MOTION; 2079 scrollBar.state = SB_STATE_MOTION;
2062 break; 2080 break;
2063 2081
2064 case Button1: 2082 case Button1:
2065 if (scrollBar.align == R_SB_ALIGN_CENTRE) 2083 if (scrollBar.align == SB_ALIGN_CENTRE)
2066 csrO = ev.y - scrollBar.top; 2084 csrO = ev.y - scrollBar.top;
2067 /* FALLTHROUGH */ 2085 /* FALLTHROUGH */
2068 2086
2069 case Button3: 2087 case Button3:
2070 if (scrollBar.style != R_SB_XTERM) 2088 if (scrollBar.style != SB_STYLE_XTERM)
2071 { 2089 {
2072 if (scrollbar_above_slider (ev.y)) 2090 if (scrollBar.above_slider (ev.y))
2073# ifdef RXVT_SCROLL_FULL 2091# ifdef RXVT_SCROLL_FULL
2074 scr_page (UP, nrow - 1); 2092 scr_page (UP, nrow - 1);
2075# else 2093# else
2076 scr_page (UP, nrow / 4); 2094 scr_page (UP, nrow / 4);
2077# endif 2095# endif
2078 else if (scrollbar_below_slider (ev.y)) 2096 else if (scrollBar.below_slider (ev.y))
2079# ifdef RXVT_SCROLL_FULL 2097# ifdef RXVT_SCROLL_FULL
2080 scr_page (DN, nrow - 1); 2098 scr_page (DN, nrow - 1);
2081# else 2099# else
2082 scr_page (DN, nrow / 4); 2100 scr_page (DN, nrow / 4);
2083# endif 2101# endif
2084 else 2102 else
2085 scrollBar.state = STATE_MOTION; 2103 scrollBar.state = SB_STATE_MOTION;
2086 } 2104 }
2087 else 2105 else
2088 { 2106 {
2089 scr_page ((ev.button == Button1 ? DN : UP), 2107 scr_page ((ev.button == Button1 ? DN : UP),
2090 (nrow 2108 (nrow
2091 * scrollbar_position (ev.y) 2109 * scrollBar.position (ev.y)
2092 / scrollBar.size ())); 2110 / scrollBar.size ()));
2093 } 2111 }
2094 2112
2095 break; 2113 break;
2096 } 2114 }
2107 2125
2108 csrO = 0; /* reset csr Offset */ 2126 csrO = 0; /* reset csr Offset */
2109 if (!bypass_keystate) 2127 if (!bypass_keystate)
2110 reportmode = !! (priv_modes & PrivMode_mouse_report); 2128 reportmode = !! (priv_modes & PrivMode_mouse_report);
2111 2129
2112 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) 2130 if (scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN)
2113 { 2131 {
2114 scrollBar.state = STATE_IDLE; 2132 scrollBar.state = SB_STATE_IDLE;
2115 scrollBar.show (0); 2133 scrollBar.show (0);
2116 } 2134 }
2117 2135
2118#ifdef SELECTION_SCROLLING 2136#ifdef SELECTION_SCROLLING
2119 sel_scroll_ev.stop(); 2137 sel_scroll_ev.stop();
2169 case Button3: 2187 case Button3:
2170 selection_make (ev.time); 2188 selection_make (ev.time);
2171 break; 2189 break;
2172 2190
2173 case Button2: 2191 case Button2:
2174 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? 2192 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); 2193 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
2176 break; 2194 break;
2177 2195
2178#ifdef MOUSE_WHEEL 2196#ifdef MOUSE_WHEEL
2179 case Button4: 2197 case Button4:
2214 } 2232 }
2215} 2233}
2216 2234
2217/*}}} */ 2235/*}}} */
2218 2236
2219void 2237void ecb_hot
2220rxvt_term::cmd_parse () 2238rxvt_term::cmd_parse ()
2221{ 2239{
2222 wchar_t ch = NOCHAR; 2240 wchar_t ch = NOCHAR;
2223 char *seq_begin; // remember start of esc-sequence here 2241 char *seq_begin; // remember start of esc-sequence here
2224 2242
2225 for (;;) 2243 for (;;)
2226 { 2244 {
2227 if (expect_false (ch == NOCHAR)) 2245 if (ecb_unlikely (ch == NOCHAR))
2228 { 2246 {
2229 seq_begin = cmdbuf_ptr; 2247 seq_begin = cmdbuf_ptr;
2230 ch = next_char (); 2248 ch = next_char ();
2231 2249
2232 if (ch == NOCHAR) 2250 if (ch == NOCHAR)
2233 break; 2251 break;
2234 } 2252 }
2235 2253
2236 if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) 2254 if (ecb_likely (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
2237 { 2255 {
2238 if (expect_false (!seen_input)) 2256 if (ecb_unlikely (!seen_input))
2239 { 2257 {
2240 seen_input = 1; 2258 seen_input = 1;
2241 // many badly-written programs (e.g. jed) contain a race condition: 2259 // many badly-written programs (e.g. jed) contain a race condition:
2242 // they first read the screensize and then install a SIGWINCH handler. 2260 // they first read the screensize and then install a SIGWINCH handler.
2243 // some window managers resize the window early, and these programs 2261 // some window managers resize the window early, and these programs
2256 wchar_t *str = buf; 2274 wchar_t *str = buf;
2257 wchar_t *eol = str + min (ncol, UBUFSIZ); 2275 wchar_t *eol = str + min (ncol, UBUFSIZ);
2258 2276
2259 for (;;) 2277 for (;;)
2260 { 2278 {
2261 if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) 2279 if (ecb_unlikely (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
2262 break; 2280 break;
2263 2281
2264 *str++ = ch; 2282 *str++ = ch;
2265 2283
2266 if (expect_false (ch == C0_LF || str >= eol)) 2284 if (ecb_unlikely (ch == C0_LF || str >= eol))
2267 { 2285 {
2268 if (ch == C0_LF) 2286 if (ch == C0_LF)
2269 nlines++; 2287 nlines++;
2270 2288
2271 refresh_count++; 2289 refresh_count++;
2343 } 2361 }
2344 } 2362 }
2345} 2363}
2346 2364
2347// read the next character 2365// read the next character
2348wchar_t 2366wchar_t ecb_hot
2349rxvt_term::next_char () NOTHROW 2367rxvt_term::next_char () NOTHROW
2350{ 2368{
2351 while (cmdbuf_ptr < cmdbuf_endp) 2369 while (cmdbuf_ptr < cmdbuf_endp)
2352 { 2370 {
2353 // assume 7-bit to be ascii ALWAYS 2371 // assume 7-bit to be ascii ALWAYS
2354 if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) 2372 if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
2355 return *cmdbuf_ptr++; 2373 return *cmdbuf_ptr++;
2356 2374
2357 wchar_t wc; 2375 wchar_t wc;
2358 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 2376 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
2359 2377
2377 2395
2378 return NOCHAR; 2396 return NOCHAR;
2379} 2397}
2380 2398
2381// read the next octet 2399// read the next octet
2382uint32_t 2400uint32_t ecb_hot
2383rxvt_term::next_octet () NOTHROW 2401rxvt_term::next_octet () NOTHROW
2384{ 2402{
2385 return cmdbuf_ptr < cmdbuf_endp 2403 return cmdbuf_ptr < cmdbuf_endp
2386 ? (unsigned char)*cmdbuf_ptr++ 2404 ? (unsigned char)*cmdbuf_ptr++
2387 : NOCHAR; 2405 : NOCHAR;
2388} 2406}
2389 2407
2390static class out_of_input out_of_input; 2408static class out_of_input out_of_input;
2391 2409
2392wchar_t 2410wchar_t ecb_hot
2393rxvt_term::cmd_getc () THROW ((class out_of_input)) 2411rxvt_term::cmd_getc () THROW ((class out_of_input))
2394{ 2412{
2395 wchar_t c = next_char (); 2413 wchar_t c = next_char ();
2396 2414
2397 if (c == NOCHAR) 2415 if (c == NOCHAR)
2398 throw out_of_input; 2416 throw out_of_input;
2399 2417
2400 return c; 2418 return c;
2401} 2419}
2402 2420
2403uint32_t 2421uint32_t ecb_hot
2404rxvt_term::cmd_get8 () THROW ((class out_of_input)) 2422rxvt_term::cmd_get8 () THROW ((class out_of_input))
2405{ 2423{
2406 uint32_t c = next_octet (); 2424 uint32_t c = next_octet ();
2407 2425
2408 if (c == NOCHAR) 2426 if (c == NOCHAR)
2412} 2430}
2413 2431
2414/*{{{ print pipe */ 2432/*{{{ print pipe */
2415/*----------------------------------------------------------------------*/ 2433/*----------------------------------------------------------------------*/
2416#ifdef PRINTPIPE 2434#ifdef PRINTPIPE
2417FILE * 2435FILE * ecb_cold
2418rxvt_term::popen_printer () 2436rxvt_term::popen_printer ()
2419{ 2437{
2420 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); 2438 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w");
2421 2439
2422 if (stream == NULL) 2440 if (stream == NULL)
2423 rxvt_warn ("can't open printer pipe, not printing.\n"); 2441 rxvt_warn ("can't open printer pipe, not printing.\n");
2424 2442
2425 return stream; 2443 return stream;
2426} 2444}
2427 2445
2428int 2446int ecb_cold
2429rxvt_term::pclose_printer (FILE *stream) 2447rxvt_term::pclose_printer (FILE *stream)
2430{ 2448{
2431 fflush (stream); 2449 fflush (stream);
2432 return pclose (stream); 2450 return pclose (stream);
2433} 2451}
2434 2452
2435/* 2453/*
2436 * simulate attached vt100 printer 2454 * simulate attached vt100 printer
2437 */ 2455 */
2438void 2456void ecb_cold
2439rxvt_term::process_print_pipe () 2457rxvt_term::process_print_pipe ()
2440{ 2458{
2441 FILE *fd = popen_printer (); 2459 FILE *fd = popen_printer ();
2442 2460
2443 if (!fd) 2461 if (!fd)
2498 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, 2516 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, 2517 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC,
2500}; 2518};
2501 2519
2502/*{{{ process non-printing single characters */ 2520/*{{{ process non-printing single characters */
2503void 2521void ecb_hot
2504rxvt_term::process_nonprinting (unicode_t ch) 2522rxvt_term::process_nonprinting (unicode_t ch)
2505{ 2523{
2506 switch (ch) 2524 switch (ch)
2507 { 2525 {
2508 case C0_ESC: 2526 case C0_ESC:
2554} 2572}
2555/*}}} */ 2573/*}}} */
2556 2574
2557 2575
2558/*{{{ process VT52 escape sequences */ 2576/*{{{ process VT52 escape sequences */
2559void 2577void ecb_cold
2560rxvt_term::process_escape_vt52 (unicode_t ch) 2578rxvt_term::process_escape_vt52 (unicode_t ch)
2561{ 2579{
2562 int row, col; 2580 int row, col;
2563 2581
2564 switch (ch) 2582 switch (ch)
2598 break; 2616 break;
2599 case 'Z': /* identify the terminal type */ 2617 case 'Z': /* identify the terminal type */
2600 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ 2618 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */
2601 break; 2619 break;
2602 case '<': /* turn off VT52 mode */ 2620 case '<': /* turn off VT52 mode */
2603 set_privmode (PrivMode_vt52, 0); 2621 priv_modes &= ~PrivMode_vt52;
2604 break; 2622 break;
2605 case 'F': /* use special graphics character set */ 2623 case 'F': /* use special graphics character set */
2606 case 'G': /* use regular character set */ 2624 case 'G': /* use regular character set */
2607 /* unimplemented */ 2625 /* unimplemented */
2608 break; 2626 break;
2614} 2632}
2615/*}}} */ 2633/*}}} */
2616 2634
2617 2635
2618/*{{{ process escape sequences */ 2636/*{{{ process escape sequences */
2619void 2637void ecb_hot
2620rxvt_term::process_escape_seq () 2638rxvt_term::process_escape_seq ()
2621{ 2639{
2622 unicode_t ch = cmd_getc (); 2640 unicode_t ch = cmd_getc ();
2623 2641
2624 if (priv_modes & PrivMode_vt52) 2642 if (priv_modes & PrivMode_vt52)
2627 return; 2645 return;
2628 } 2646 }
2629 2647
2630 switch (ch) 2648 switch (ch)
2631 { 2649 {
2632 /* case 1: do_tek_mode (); break; */
2633 case '#': 2650 case '#':
2634 if (cmd_getc () == '8') 2651 if (cmd_getc () == '8')
2635 scr_E (); 2652 scr_E ();
2636 break; 2653 break;
2637 case '(': 2654 case '(':
2660#if !ENABLE_MINIMAL 2677#if !ENABLE_MINIMAL
2661 case '9': 2678 case '9':
2662 scr_forwardindex (); 2679 scr_forwardindex ();
2663 break; 2680 break;
2664#endif 2681#endif
2682 // DECPAM/DECPNM
2665 case '=': 2683 case '=':
2684 priv_modes |= PrivMode_aplKP;
2685 break;
2666 case '>': 2686 case '>':
2667 set_privmode (PrivMode_aplKP, ch == '='); 2687 priv_modes &= ~PrivMode_aplKP;
2668 break; 2688 break;
2669 2689
2670 case C1_40: 2690 case C1_40:
2671 cmd_getc (); 2691 cmd_getc ();
2672 break; 2692 break;
2676 2696
2677 /* 8.3.87: NEXT LINE */ 2697 /* 8.3.87: NEXT LINE */
2678 case C1_NEL: /* ESC E */ 2698 case C1_NEL: /* ESC E */
2679 { 2699 {
2680 wchar_t nlcr[] = { C0_LF, C0_CR }; 2700 wchar_t nlcr[] = { C0_LF, C0_CR };
2681 scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1); 2701 scr_add_lines (nlcr, ecb_array_length (nlcr), 1);
2682 } 2702 }
2683 break; 2703 break;
2684 2704
2685 /* kidnapped escape sequence: Should be 8.3.48 */ 2705 /* kidnapped escape sequence: Should be 8.3.48 */
2686 case C1_ESA: /* ESC G */ 2706 case C1_ESA: /* ESC G */
2698 case C1_RI: /* ESC M */ 2718 case C1_RI: /* ESC M */
2699 scr_index (DN); 2719 scr_index (DN);
2700 break; 2720 break;
2701 2721
2702 /* 8.3.142: SINGLE-SHIFT TWO */ 2722 /* 8.3.142: SINGLE-SHIFT TWO */
2703 /*case C1_SS2: scr_single_shift (2); break; */ 2723 /* case C1_SS2: break; */
2704 2724
2705 /* 8.3.143: SINGLE-SHIFT THREE */ 2725 /* 8.3.143: SINGLE-SHIFT THREE */
2706 /*case C1_SS3: scr_single_shift (3); break; */ 2726 /* case C1_SS3: break; */
2707 2727
2708 /* 8.3.27: DEVICE CONTROL STRING */ 2728 /* 8.3.27: DEVICE CONTROL STRING */
2709 case C1_DCS: /* ESC P */ 2729 case C1_DCS: /* ESC P */
2710 process_dcs_seq (); 2730 process_dcs_seq ();
2711 break; 2731 break;
2774 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ 2794 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, */ 2795 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, {, |, }, ~, */ 2796 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */
2777 }; 2797 };
2778 2798
2779void 2799void ecb_hot
2780rxvt_term::process_csi_seq () 2800rxvt_term::process_csi_seq ()
2781{ 2801{
2782 unicode_t ch, priv, i; 2802 unicode_t ch, priv, i;
2783 unsigned int nargs, p; 2803 unsigned int nargs, p;
2784 int n, ndef; 2804 int n, ndef;
2862 scr_soft_reset (); 2882 scr_soft_reset ();
2863 2883
2864 static const int pm_h[] = { 7, 25 }; 2884 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 }; 2885 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 };
2866 2886
2867 process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h); 2887 process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h);
2868 process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l); 2888 process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l);
2869 } 2889 }
2870 break; 2890 break;
2871 } 2891 }
2872 2892
2873 return; 2893 return;
2891 } 2911 }
2892 break; 2912 break;
2893#endif 2913#endif
2894 2914
2895 case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ 2915 case CSI_CUU: /* 8.3.22: (1) CURSOR UP */
2896 case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ 2916 case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */
2897 arg[0] = -arg[0]; 2917 arg[0] = -arg[0];
2898 /* FALLTHROUGH */ 2918 /* FALLTHROUGH */
2899 case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ 2919 case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */
2900 case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ 2920 case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */
2901 scr_gotorc (arg[0], 0, RELATIVE); 2921 scr_gotorc (arg[0], 0, RELATIVE);
2902 break; 2922 break;
2903 2923
2904 case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */ 2924 case CSI_CUB: /* 8.3.18: (1) CURSOR LEFT */
2905 case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */ 2925 case CSI_HPB: /* 8.3.59: (1) CHARACTER POSITION BACKWARD */
3138 break; 3158 break;
3139 3159
3140 //case 9: NYI, TODO, restore maximized window or maximize window 3160 //case 9: NYI, TODO, restore maximized window or maximize window
3141 default: 3161 default:
3142 if (args[0] >= 24) /* set height (chars) */ 3162 if (args[0] >= 24) /* set height (chars) */
3143 set_widthheight ((unsigned int)width, 3163 set_widthheight ((unsigned int)vt_width,
3144 (unsigned int) (args[1] * fheight)); 3164 (unsigned int) (args[1] * fheight));
3145 break; 3165 break;
3146 3166
3147 /* 3167 /*
3148 * reports - some output format copied from XTerm 3168 * reports - some output format copied from XTerm
3434 process_color_seq (op, Color_tint, str, resp); 3454 process_color_seq (op, Color_tint, str, resp);
3435 { 3455 {
3436 bool changed = false; 3456 bool changed = false;
3437 3457
3438 if (ISSET_PIXCOLOR (Color_tint)) 3458 if (ISSET_PIXCOLOR (Color_tint))
3439 changed = bg_set_tint (pix_colors_focused [Color_tint]); 3459 changed = root_effects.set_tint (pix_colors_focused [Color_tint]);
3440 3460
3441 if (changed) 3461 if (changed)
3442 update_background (); 3462 update_background ();
3443 } 3463 }
3444 3464
3448#if BG_IMAGE_FROM_FILE 3468#if BG_IMAGE_FROM_FILE
3449 case Rxvt_Pixmap: 3469 case Rxvt_Pixmap:
3450 if (!strcmp (str, "?")) 3470 if (!strcmp (str, "?"))
3451 { 3471 {
3452 char str[256]; 3472 char str[256];
3473 int h_scale = 0, v_scale = 0;
3474 int h_align = 0, v_align = 0;
3475 if (image_vec.size () > 0)
3476 {
3477 h_scale = image_vec[0].h_scale;
3478 v_scale = image_vec[0].v_scale;
3479 h_align = image_vec[0].h_align;
3480 v_align = image_vec[0].v_align;
3481 }
3453 3482
3454 sprintf (str, "[%dx%d+%d+%d]", 3483 sprintf (str, "[%dx%d+%d+%d]",
3455 min (h_scale, 32767), min (v_scale, 32767), 3484 h_scale, v_scale,
3456 min (h_align, 32767), min (v_align, 32767)); 3485 h_align, v_align);
3457 process_xterm_seq (XTerm_title, str, CHAR_ST); 3486 process_xterm_seq (XTerm_title, str, CHAR_ST);
3458 } 3487 }
3459 else 3488 else
3460 { 3489 {
3461 int changed = 0; 3490 bool changed = false;
3462 3491
3463 if (*str != ';') 3492 if (*str != ';')
3464 { 3493 {
3465 if (bg_set_file (str)) /* change pixmap */ 3494 if (image_vec.size () > 0)
3495 changed = image_vec[0].set_file_geometry (str);
3496 else
3466 { 3497 {
3467 changed++; 3498 rxvt_image *image = new_image ();
3468 str = strchr (str, ';'); 3499 if (!image->set_file_geometry (str))
3469 if (str == NULL) 3500 image_vec.pop_back ();
3470 bg_set_default_geometry ();
3471 else 3501 else
3472 bg_set_geometry (str+1); 3502 changed = true;
3473 } 3503 }
3474 } 3504 }
3475 else 3505 else
3476 { 3506 {
3477 str++; 3507 str++;
3508 if (image_vec.size () > 0)
3478 if (bg_set_geometry (str, true)) 3509 changed = image_vec[0].set_geometry (str, true);
3479 changed++;
3480 } 3510 }
3481 3511
3482 if (changed) 3512 if (changed)
3483 { 3513 {
3484 if (bg_window_position_sensitive ()) 3514 if (bg_window_position_sensitive ())
3583 * 's' = save 3613 * 's' = save
3584 * 'r' = restore 3614 * 'r' = restore
3585 * 't' = toggle 3615 * 't' = toggle
3586 * so no need for fancy checking 3616 * so no need for fancy checking
3587 */ 3617 */
3588int 3618int ecb_cold
3589rxvt_term::privcases (int mode, unsigned long bit) 3619rxvt_term::privcases (int mode, unsigned long bit)
3590{ 3620{
3591 int state; 3621 int state;
3592 3622
3593 if (mode == 's') 3623 if (mode == 's')
3594 { 3624 {
3595 SavedModes |= (priv_modes & bit); 3625 if (priv_modes & bit)
3626 SavedModes |= bit;
3627 else
3628 SavedModes &= ~bit;
3596 return -1; 3629 return -1;
3597 } 3630 }
3598 else 3631 else
3599 { 3632 {
3600 if (mode == 'r') 3633 if (mode == 'r')
3601 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3634 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
3602 else 3635 else
3603 state = (mode == 't') ? ! (priv_modes & bit) : mode; 3636 state = (mode == 't') ? ! (priv_modes & bit) : mode;
3604 3637
3605 set_privmode (bit, state); 3638 if (state)
3639 priv_modes |= bit;
3640 else
3641 priv_modes &= ~bit;
3606 } 3642 }
3607 3643
3608 return state; 3644 return state;
3609} 3645}
3610 3646
3611/* we're not using priv _yet_ */ 3647/* we're not using priv _yet_ */
3612void 3648void
3613rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) 3649rxvt_term::process_terminal_mode (int mode, int priv ecb_unused, unsigned int nargs, const int *arg)
3614{ 3650{
3615 unsigned int i, j; 3651 unsigned int i, j;
3616 int state; 3652 int state;
3617 3653
3618 static const struct 3654 static const struct
3619 { 3655 {
3620 const int argval; 3656 const int argval;
3621 const unsigned long bit; 3657 const unsigned long bit;
3622 } argtopriv[] = { 3658 } argtopriv[] = {
3623 { 1, PrivMode_aplCUR }, // DECCKM 3659 { 1, PrivMode_aplCUR }, // DECCKM
3624 { 2, PrivMode_vt52 }, 3660 { 2, PrivMode_vt52 }, // DECANM
3625 { 3, PrivMode_132 }, // DECCOLM 3661 { 3, PrivMode_132 }, // DECCOLM
3626 { 4, PrivMode_smoothScroll }, // DECSCLM 3662 { 4, PrivMode_smoothScroll }, // DECSCLM
3627 { 5, PrivMode_rVideo }, // DECSCNM 3663 { 5, PrivMode_rVideo }, // DECSCNM
3628 { 6, PrivMode_relOrigin }, // DECOM 3664 { 6, PrivMode_relOrigin }, // DECOM
3629 { 7, PrivMode_Autowrap }, // DECAWM 3665 { 7, PrivMode_Autowrap }, // DECAWM
3630 // 8, auto-repeat keys // DECARM 3666 // 8, auto-repeat keys // DECARM
3631 { 9, PrivMode_MouseX10 }, 3667 { 9, PrivMode_MouseX10 },
3632 // 18 end FF to printer after print screen 3668 // 18 end FF to printer after print screen
3633 // 19 Print screen prints full screen/scroll region 3669 // 19 Print screen prints full screen/scroll region
3634 { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis 3670 { 25, PrivMode_VisibleCursor }, // DECTCEM cnorm/cvvis/civis
3635#ifdef scrollBar_esc 3671#ifdef scrollBar_esc
3636 { scrollBar_esc, PrivMode_scrollBar }, 3672 { scrollBar_esc, PrivMode_scrollBar },
3637#endif 3673#endif
3638 { 35, PrivMode_ShiftKeys }, // rxvt extension 3674 { 35, PrivMode_ShiftKeys }, // rxvt extension
3639 // 38, tektronix mode // DECTEK 3675 // 38, tektronix mode // DECTEK
3640 { 40, PrivMode_132OK }, 3676 { 40, PrivMode_132OK },
3641 // 41 xterm more fixes NYI 3677 // 41 xterm more fixes NYI
3642 // 45 margin bell NYI 3678 // 45 margin bell NYI
3643 // 46 start logging 3679 // 46 start logging
3644 { 47, PrivMode_Screen }, 3680 { 47, PrivMode_Screen },
3645 { 66, PrivMode_aplKP }, // DECPAM/DECPNM 3681 { 66, PrivMode_aplKP }, // DECNKM
3646#ifndef NO_BACKSPACE_KEY 3682#ifndef NO_BACKSPACE_KEY
3647 { 67, PrivMode_BackSpace }, // DECBKM 3683 { 67, PrivMode_BackSpace }, // DECBKM
3648#endif 3684#endif
3649 { 1000, PrivMode_MouseX11 }, 3685 { 1000, PrivMode_MouseX11 },
3650 { 1002, PrivMode_MouseBtnEvent }, 3686 { 1002, PrivMode_MouseBtnEvent },
3679 for (i = 0; i < nargs; i++) 3715 for (i = 0; i < nargs; i++)
3680 { 3716 {
3681 state = -1; 3717 state = -1;
3682 3718
3683 /* basic handling */ 3719 /* basic handling */
3684 for (j = 0; j < ARRAY_LENGTH(argtopriv); j++) 3720 for (j = 0; j < ecb_array_length (argtopriv); j++)
3685 if (argtopriv[j].argval == arg[i]) 3721 if (argtopriv[j].argval == arg[i])
3686 { 3722 {
3687 state = privcases (mode, argtopriv[j].bit); 3723 state = privcases (mode, argtopriv[j].bit);
3688 break; 3724 break;
3689 } 3725 }
3715 case 2: /* VT52 mode */ 3751 case 2: /* VT52 mode */
3716 /* oddball mode. should be set regardless of set/reset 3752 /* oddball mode. should be set regardless of set/reset
3717 * parameter. Return from VT52 mode with an ESC < from 3753 * parameter. Return from VT52 mode with an ESC < from
3718 * within VT52 mode 3754 * within VT52 mode
3719 */ 3755 */
3720 set_privmode (PrivMode_vt52, 1); 3756 priv_modes |= PrivMode_vt52;
3721 break; 3757 break;
3722 case 3: /* 80/132 */ 3758 case 3: /* 80/132 */
3723 if (priv_modes & PrivMode_132OK) 3759 if (priv_modes & PrivMode_132OK)
3724 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); 3760 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight);
3725 break; 3761 break;
3740 if (state) /* orthogonal */ 3776 if (state) /* orthogonal */
3741 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3777 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3742 break; 3778 break;
3743#ifdef scrollBar_esc 3779#ifdef scrollBar_esc
3744 case scrollBar_esc: 3780 case scrollBar_esc:
3745 if (scrollBar.map (state)) 3781 scrollBar.map (state);
3746 {
3747 resize_all_windows (0, 0, 0); 3782 resize_all_windows (0, 0, 0);
3748 scr_touch (true); 3783 scr_touch (true);
3749 }
3750 break; 3784 break;
3751#endif 3785#endif
3752 case 25: /* visible/invisible cursor */ 3786 case 25: /* visible/invisible cursor */
3753 scr_cursor_visible (state); 3787 scr_cursor_visible (state);
3754 break; 3788 break;
3809 } 3843 }
3810} 3844}
3811/*}}} */ 3845/*}}} */
3812 3846
3813/*{{{ process sgr sequences */ 3847/*{{{ process sgr sequences */
3814void 3848void ecb_hot
3815rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) 3849rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg)
3816{ 3850{
3817 unsigned int i; 3851 unsigned int i;
3818 short rendset; 3852 short rendset;
3819 int rendstyle; 3853 int rendstyle;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines