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.307 by root, Sat Feb 11 10:53:37 2006 UTC vs.
Revision 1.322 by ayin, Wed May 2 23:06:32 2007 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: command.C 2 * File: command.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
877 return; 877 return;
878 878
879 if (len <= 0) 879 if (len <= 0)
880 return; /* not mapped */ 880 return; /* not mapped */
881 881
882 if (OPTION (Opt_scrollTtyKeypress)) 882 if (option (Opt_scrollTtyKeypress))
883 if (view_start) 883 if (view_start)
884 { 884 {
885 view_start = 0; 885 view_start = 0;
886 want_refresh = 1; 886 want_refresh = 1;
887 } 887 }
1232 } 1232 }
1233 else 1233 else
1234 { 1234 {
1235 pty_ev.stop (); 1235 pty_ev.stop ();
1236 1236
1237 if (!OPTION (Opt_hold)) 1237 if (!option (Opt_hold))
1238 destroy (); 1238 destroy ();
1239 } 1239 }
1240 1240
1241 return false; 1241 return false;
1242} 1242}
1263 recolour_cursor (); 1263 recolour_cursor ();
1264 1264
1265#ifdef POINTER_BLANK 1265#ifdef POINTER_BLANK
1266 hidden_pointer = 0; 1266 hidden_pointer = 0;
1267 1267
1268 if (OPTION (Opt_pointerBlank)) 1268 if (option (Opt_pointerBlank))
1269 pointer_ev.start (NOW + pointerBlankDelay); 1269 pointer_ev.start (NOW + pointerBlankDelay);
1270#endif 1270#endif
1271} 1271}
1272 1272
1273#ifdef POINTER_BLANK 1273#ifdef POINTER_BLANK
1274void 1274void
1275rxvt_term::pointer_blank () 1275rxvt_term::pointer_blank ()
1276{ 1276{
1277 if (!OPTION (Opt_pointerBlank)) 1277 if (!option (Opt_pointerBlank))
1278 return; 1278 return;
1279 1279
1280 XDefineCursor (dpy, vt, display->blank_cursor); 1280 XDefineCursor (dpy, vt, display->blank_cursor);
1281 XFlush (dpy); 1281 XFlush (dpy);
1282 1282
1458 break; 1458 break;
1459 } 1459 }
1460 break; 1460 break;
1461 1461
1462 case FocusIn: 1462 case FocusIn:
1463 if (ev.xfocus.detail != NotifyInferior
1464 && ev.xfocus.detail != NotifyPointer
1465 && ev.xfocus.mode != NotifyGrab)
1463 focus_in (); 1466 focus_in ();
1464 break; 1467 break;
1465 1468
1466 case FocusOut: 1469 case FocusOut:
1470 if (ev.xfocus.detail != NotifyInferior
1471 && ev.xfocus.detail != NotifyPointer
1472 && ev.xfocus.mode != NotifyGrab)
1467 focus_out (); 1473 focus_out ();
1468 break; 1474 break;
1469 1475
1470 case ConfigureNotify: 1476 case ConfigureNotify:
1471 if (ev.xconfigure.window == parent[0]) 1477 if (ev.xconfigure.window == parent[0])
1472 { 1478 {
1479 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1485 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1480 } 1486 }
1481 1487
1482 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1488 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1483 1489
1484#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1490#ifdef TRANSPARENT
1485 if (OPTION (Opt_transparent)) 1491 if (option (Opt_transparent))
1486 check_our_parents (); 1492 check_our_parents ();
1487#endif 1493#endif
1488 } 1494 }
1489 break; 1495 break;
1490 1496
1679 } 1685 }
1680 break; 1686 break;
1681 } 1687 }
1682 1688
1683#if defined(CURSOR_BLINK) 1689#if defined(CURSOR_BLINK)
1684 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) 1690 if (option (Opt_cursorBlink) && ev.type == KeyPress)
1685 { 1691 {
1686 if (hidden_cursor) 1692 if (hidden_cursor)
1687 { 1693 {
1688 hidden_cursor = 0; 1694 hidden_cursor = 0;
1689 want_refresh = 1; 1695 want_refresh = 1;
1692 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1698 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1693 } 1699 }
1694#endif 1700#endif
1695 1701
1696#if defined(POINTER_BLANK) 1702#if defined(POINTER_BLANK)
1697 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) 1703 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1698 { 1704 {
1699 if (ev.type == MotionNotify 1705 if (ev.type == MotionNotify
1700 || ev.type == ButtonPress 1706 || ev.type == ButtonPress
1701 || ev.type == ButtonRelease) 1707 || ev.type == ButtonRelease)
1702 if (hidden_pointer) 1708 if (hidden_pointer)
1714 if (!focus) 1720 if (!focus)
1715 { 1721 {
1716 focus = 1; 1722 focus = 1;
1717 want_refresh = 1; 1723 want_refresh = 1;
1718 1724
1719 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1725 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1720 1726
1721#if USE_XIM 1727#if USE_XIM
1722 if (Input_Context != NULL) 1728 if (Input_Context != NULL)
1723 { 1729 {
1724 IMSetPosition (); 1730 IMSetPosition ();
1725 XSetICFocus (Input_Context); 1731 XSetICFocus (Input_Context);
1726 } 1732 }
1727#endif 1733#endif
1728#if CURSOR_BLINK 1734#if CURSOR_BLINK
1729 if (OPTION (Opt_cursorBlink)) 1735 if (option (Opt_cursorBlink))
1730 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1736 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1731#endif 1737#endif
1732#if OFF_FOCUS_FADING 1738#if OFF_FOCUS_FADING
1733 if (rs[Rs_fade]) 1739 if (rs[Rs_fade])
1734 { 1740 {
1735 pix_colors = pix_colors_focused; 1741 pix_colors = pix_colors_focused;
1736 scr_recolour (); 1742 scr_recolour ();
1743 }
1744#endif
1745#if ENABLE_FRILLS
1746 if (option (Opt_urgentOnBell))
1747 {
1748 XWMHints *h;
1749
1750 h = XGetWMHints(dpy, parent[0]);
1751 if (h != NULL)
1752 {
1753 h->flags &= ~XUrgencyHint;
1754 XSetWMHints(dpy, parent[0], h);
1755 }
1737 } 1756 }
1738#endif 1757#endif
1739 } 1758 }
1740} 1759}
1741 1760
1761#if USE_XIM 1780#if USE_XIM
1762 if (Input_Context != NULL) 1781 if (Input_Context != NULL)
1763 XUnsetICFocus (Input_Context); 1782 XUnsetICFocus (Input_Context);
1764#endif 1783#endif
1765#if CURSOR_BLINK 1784#if CURSOR_BLINK
1766 if (OPTION (Opt_cursorBlink)) 1785 if (option (Opt_cursorBlink))
1767 cursor_blink_ev.stop (); 1786 cursor_blink_ev.stop ();
1768 hidden_cursor = 0; 1787 hidden_cursor = 0;
1769#endif 1788#endif
1770#if OFF_FOCUS_FADING 1789#if OFF_FOCUS_FADING
1771 if (rs[Rs_fade]) 1790 if (rs[Rs_fade])
1775 } 1794 }
1776#endif 1795#endif
1777 } 1796 }
1778} 1797}
1779 1798
1780#if TRANSPARENT 1799void
1800rxvt_term::update_fade_color (unsigned int idx)
1801{
1802#if OFF_FOCUS_FADING
1803 if (rs[Rs_fade])
1804 {
1805 rgba c;
1806 pix_colors [Color_fade].get (c);
1807 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1808 }
1809#endif
1810}
1811
1812#if TRANSPARENT || ENABLE_PERL
1781void 1813void
1782rxvt_term::rootwin_cb (XEvent &ev) 1814rxvt_term::rootwin_cb (XEvent &ev)
1783{ 1815{
1784 make_current (); 1816 make_current ();
1785 1817
1818 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1819 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1820 return;
1821
1822# if TRANSPARENT
1786 switch (ev.type) 1823 switch (ev.type)
1787 { 1824 {
1788 case PropertyNotify: 1825 case PropertyNotify:
1789 /* 1826 /*
1790 * if user used some Esetroot compatible prog to set the root bg, 1827 * if user used some Esetroot compatible prog to set the root bg,
1794 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1831 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID])
1795 return; 1832 return;
1796 1833
1797 /* FALLTHROUGH */ 1834 /* FALLTHROUGH */
1798 case ReparentNotify: 1835 case ReparentNotify:
1799 if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) 1836 if (option (Opt_transparent) && check_our_parents () && am_transparent)
1800 want_refresh = want_full_refresh = 1; 1837 want_refresh = want_full_refresh = 1;
1801 break; 1838 break;
1802 } 1839 }
1840# endif
1803} 1841}
1804#endif 1842#endif
1805 1843
1806void 1844void
1807rxvt_term::button_press (XButtonEvent &ev) 1845rxvt_term::button_press (XButtonEvent &ev)
2135 selection_make (ev.time); 2173 selection_make (ev.time);
2136 break; 2174 break;
2137 2175
2138 case Button2: 2176 case Button2:
2139 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? 2177 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window?
2140 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); 2178 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
2141 break; 2179 break;
2142 2180
2143#ifdef MOUSE_WHEEL 2181#ifdef MOUSE_WHEEL
2144 case Button4: 2182 case Button4:
2145 case Button5: 2183 case Button5:
2149 2187
2150 v = ev.button == Button4 ? UP : DN; 2188 v = ev.button == Button4 ? UP : DN;
2151 2189
2152 if (ev.state & ShiftMask) 2190 if (ev.state & ShiftMask)
2153 i = 1; 2191 i = 1;
2154 else if (OPTION (Opt_mouseWheelScrollPage)) 2192 else if (option (Opt_mouseWheelScrollPage))
2155 i = nrow - 1; 2193 i = nrow - 1;
2156 else 2194 else
2157 i = 5; 2195 i = 5;
2158 2196
2159# ifdef MOUSE_SLIP_WHEELING 2197# ifdef MOUSE_SLIP_WHEELING
2430 Pixmap rootpixmap = None; 2468 Pixmap rootpixmap = None;
2431 XWindowAttributes wattr, wrootattr; 2469 XWindowAttributes wattr, wrootattr;
2432 2470
2433 pchanged = 0; 2471 pchanged = 0;
2434 2472
2435 if (!OPTION (Opt_transparent)) 2473 if (!option (Opt_transparent))
2436 return pchanged; /* Don't try any more */ 2474 return pchanged; /* Don't try any more */
2437 2475
2438 XGetWindowAttributes (dpy, display->root, &wrootattr); 2476 XGetWindowAttributes (dpy, display->root, &wrootattr);
2439 rootdepth = wrootattr.depth; 2477 rootdepth = wrootattr.depth;
2440 2478
2710 if (ch == C0_LF) 2748 if (ch == C0_LF)
2711 nlines++; 2749 nlines++;
2712 2750
2713 refresh_count++; 2751 refresh_count++;
2714 2752
2715 if (!OPTION (Opt_jumpScroll) 2753 if (!option (Opt_jumpScroll)
2716 || (refresh_count >= refresh_limit * (nrow - 1))) 2754 || (refresh_count >= refresh_limit * (nrow - 1)))
2717 { 2755 {
2718 refreshnow = true; 2756 refreshnow = true;
2719 refresh_count = 0; 2757 refresh_count = 0;
2720 ch = NOCHAR; 2758 ch = NOCHAR;
2760 * the number of pages between refreshes is refresh_limit, which 2798 * the number of pages between refreshes is refresh_limit, which
2761 * is incremented here because we must be doing flat-out scrolling. 2799 * is incremented here because we must be doing flat-out scrolling.
2762 */ 2800 */
2763 if (refreshnow) 2801 if (refreshnow)
2764 { 2802 {
2765 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2803 if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2766 refresh_limit++; 2804 refresh_limit++;
2767 else 2805 else
2768 { 2806 {
2769 flag = true; 2807 flag = true;
2808 //TODO: due to popular request, implement "skipscroll" option here
2770 scr_refresh (); 2809 scr_refresh ();
2771 want_refresh = 1; 2810 want_refresh = 1;
2772 } 2811 }
2773 } 2812 }
2774 2813
3435 break; 3474 break;
3436 case 6: /* CPR requested */ 3475 case 6: /* CPR requested */
3437 scr_report_position (); 3476 scr_report_position ();
3438 break; 3477 break;
3439 case 7: /* unofficial extension */ 3478 case 7: /* unofficial extension */
3440 if (OPTION (Opt_insecure)) 3479 if (option (Opt_insecure))
3441 tt_printf ("%-.250s\012", rs[Rs_display_name]); 3480 tt_printf ("%-.250s\012", rs[Rs_display_name]);
3442 break; 3481 break;
3443 case 8: /* unofficial extension */ 3482 case 8: /* unofficial extension */
3444 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 3483 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
3445 break; 3484 break;
3609 break; 3648 break;
3610 case 20: /* report icon label */ 3649 case 20: /* report icon label */
3611 { 3650 {
3612 char *s; 3651 char *s;
3613 XGetIconName (dpy, parent[0], &s); 3652 XGetIconName (dpy, parent[0], &s);
3614 tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3653 tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3615 XFree (s); 3654 XFree (s);
3616 } 3655 }
3617 break; 3656 break;
3618 case 21: /* report window title */ 3657 case 21: /* report window title */
3619 { 3658 {
3620 char *s; 3659 char *s;
3621 XFetchName (dpy, parent[0], &s); 3660 XFetchName (dpy, parent[0], &s);
3622 tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3661 tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3623 XFree (s); 3662 XFree (s);
3624 } 3663 }
3625 break; 3664 break;
3626 } 3665 }
3627} 3666}
3654 seen_esc = true; 3693 seen_esc = true;
3655 continue; 3694 continue;
3656 } 3695 }
3657 else if (ch == C0_BEL || ch == CHAR_ST) 3696 else if (ch == C0_BEL || ch == CHAR_ST)
3658 break; 3697 break;
3698 else if (ch == C0_SYN)
3699 ch = cmd_get8 ();
3659 else if (ch < 0x20) 3700 else if (ch < 0x20)
3660 return NULL; /* other control character - exit */ 3701 return NULL; /* other control character - exit */
3661 3702
3662 seen_esc = false; 3703 seen_esc = false;
3663 3704
3664 if (n >= STRING_MAX - 1) 3705 if (n >= STRING_MAX - 1)
3665 // stop at some sane length 3706 // stop at some sane length
3666 return NULL; 3707 return NULL;
3667 3708
3668 if (ch == C0_SYN)
3669 string[n++] = cmd_get8 ();
3670 else
3671 string[n++] = ch; 3709 string[n++] = ch;
3672 } 3710 }
3673 3711
3674 string[n++] = '\0'; 3712 string[n++] = '\0';
3675 3713
3676 ends_how = (ch == 0x5c ? C0_ESC : ch); 3714 ends_how = (ch == 0x5c ? C0_ESC : ch);
3755 int saveop = op; 3793 int saveop = op;
3756 3794
3757 dLocal (Display *, dpy); 3795 dLocal (Display *, dpy);
3758 3796
3759 assert (str != NULL); 3797 assert (str != NULL);
3798
3799 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3800 return;
3801
3760 switch (op) 3802 switch (op)
3761 { 3803 {
3762 case XTerm_name: 3804 case XTerm_name:
3763 set_title (str); 3805 set_title (str);
3764 /* FALLTHROUGH */ 3806 /* FALLTHROUGH */
3932 case URxvt_italicFont: 3974 case URxvt_italicFont:
3933 case URxvt_boldItalicFont: 3975 case URxvt_boldItalicFont:
3934#endif 3976#endif
3935 if (query) 3977 if (query)
3936 tt_printf ("\33]%d;%-.250s%c", saveop, 3978 tt_printf ("\33]%d;%-.250s%c", saveop,
3937 OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc 3979 option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc
3938 ? fontset[op - URxvt_font]->fontdesc : "", 3980 ? fontset[op - URxvt_font]->fontdesc : "",
3939 resp); 3981 resp);
3940 else 3982 else
3941 { 3983 {
3942 const char *&res = rs[Rs_font + (op - URxvt_font)]; 3984 const char *&res = rs[Rs_font + (op - URxvt_font)];
3956 break; 3998 break;
3957 3999
3958#if !ENABLE_MINIMAL 4000#if !ENABLE_MINIMAL
3959 case URxvt_locale: 4001 case URxvt_locale:
3960 if (query) 4002 if (query)
3961 tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); 4003 tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp);
3962 else 4004 else
3963 { 4005 {
3964 set_locale (str); 4006 set_locale (str);
3965 pty->set_utf8_mode (enc_utf8); 4007 pty->set_utf8_mode (enc_utf8);
3966 init_xlocale (); 4008 init_xlocale ();
3981 break; 4023 break;
3982#endif 4024#endif
3983 4025
3984#if ENABLE_PERL 4026#if ENABLE_PERL
3985 case URxvt_perl: 4027 case URxvt_perl:
3986 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) 4028 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END)))
3987 ; // no responses yet 4029 ; // no responses yet
3988 break; 4030 break;
3989#endif 4031#endif
3990 } 4032 }
3991} 4033}
4107 scr_touch (true); 4149 scr_touch (true);
4108 break; 4150 break;
4109#endif 4151#endif
4110 case 1048: /* alternative cursor save */ 4152 case 1048: /* alternative cursor save */
4111 case 1049: 4153 case 1049:
4112 if (OPTION (Opt_secondaryScreen)) 4154 if (option (Opt_secondaryScreen))
4113 if (mode == 0) 4155 if (mode == 0)
4114 scr_cursor (RESTORE); 4156 scr_cursor (RESTORE);
4115 else if (mode == 1) 4157 else if (mode == 1)
4116 scr_cursor (SAVE); 4158 scr_cursor (SAVE);
4117 break; 4159 break;
4182 break; 4224 break;
4183 case 1011: /* scroll to bottom on key press */ 4225 case 1011: /* scroll to bottom on key press */
4184 set_option (Opt_scrollTtyKeypress, state); 4226 set_option (Opt_scrollTtyKeypress, state);
4185 break; 4227 break;
4186 case 1047: /* secondary screen w/ clearing last */ 4228 case 1047: /* secondary screen w/ clearing last */
4187 if (OPTION (Opt_secondaryScreen)) 4229 if (option (Opt_secondaryScreen))
4188 if (current_screen != PRIMARY) 4230 if (current_screen != PRIMARY)
4189 scr_erase_screen (2); 4231 scr_erase_screen (2);
4190 scr_change_screen (state); 4232 scr_change_screen (state);
4191 break; 4233 break;
4192 case 1049: /* secondary screen w/ clearing first */ 4234 case 1049: /* secondary screen w/ clearing first */
4193 scr_change_screen (state); 4235 scr_change_screen (state);
4194 if (OPTION (Opt_secondaryScreen)) 4236 if (option (Opt_secondaryScreen))
4195 if (current_screen != PRIMARY) 4237 if (current_screen != PRIMARY)
4196 scr_erase_screen (2); 4238 scr_erase_screen (2);
4197 break; 4239 break;
4198 default: 4240 default:
4199 break; 4241 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines