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.364 by ayin, Mon Nov 12 14:53:13 2007 UTC vs.
Revision 1.381 by root, Fri Dec 14 05:25:23 2007 UTC

25 * - extensive modifications 25 * - extensive modifications
26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
27 * Copyright (c) 2001 Marius Gedminas 27 * Copyright (c) 2001 Marius Gedminas
28 * - Ctrl/Mod4+Tab works like Meta+Tab (options) 28 * - Ctrl/Mod4+Tab works like Meta+Tab (options)
29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> 29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org>
30 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> 30 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
31 * 31 *
32 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU General Public License as published by 33 * it under the terms of the GNU General Public License as published by
34 * the Free Software Foundation; either version 2 of the License, or 34 * the Free Software Foundation; either version 2 of the License, or
35 * (at your option) any later version. 35 * (at your option) any later version.
1041 } 1041 }
1042 1042
1043 display->flush (); 1043 display->flush ();
1044} 1044}
1045 1045
1046/* checks wether a refresh is requested and starts the refresh timer */
1046void 1047void
1047rxvt_term::prepare_cb (ev::prepare &w, int revents) 1048rxvt_term::refresh_check ()
1048{ 1049{
1049 make_current ();
1050
1051 display->flush ();
1052
1053 if (want_refresh && !flush_ev.active) 1050 if (want_refresh && !flush_ev.is_active ())
1054 flush_ev.start (1. / 60.); // refresh at max. 60 hz normally 1051 flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally
1055} 1052}
1056 1053
1057void 1054void
1058rxvt_term::flush_cb (ev::timer &w, int revents) 1055rxvt_term::flush_cb (ev::timer &w, int revents)
1059{ 1056{
1067void 1064void
1068rxvt_term::cursor_blink_cb (ev::timer &w, int revents) 1065rxvt_term::cursor_blink_cb (ev::timer &w, int revents)
1069{ 1066{
1070 hidden_cursor = !hidden_cursor; 1067 hidden_cursor = !hidden_cursor;
1071 want_refresh = 1; 1068 want_refresh = 1;
1069 refresh_check ();
1072} 1070}
1073#endif 1071#endif
1074 1072
1075#ifdef TEXT_BLINK 1073#ifdef TEXT_BLINK
1076void 1074void
1078{ 1076{
1079 if (scr_refresh_rend (RS_Blink, RS_Blink)) 1077 if (scr_refresh_rend (RS_Blink, RS_Blink))
1080 { 1078 {
1081 hidden_text = !hidden_text; 1079 hidden_text = !hidden_text;
1082 want_refresh = 1; 1080 want_refresh = 1;
1081 refresh_check ();
1083 } 1082 }
1083 else
1084 w.stop ();
1084} 1085}
1085#endif 1086#endif
1086 1087
1087#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1088#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1088void 1089void
1089rxvt_term::cont_scroll_cb (ev::timer &w, int revents) 1090rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1090{ 1091{
1091 if ((scrollbar_isUp() || scrollbar_isDn()) && 1092 if ((scrollbar_isUp () || scrollbar_isDn ())
1092 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1093 && scr_page (scrollbar_isUp () ? UP : DN, 1))
1094 {
1093 want_refresh = 1; 1095 want_refresh = 1;
1096 refresh_check ();
1097 }
1094 else 1098 else
1095 w.stop (); 1099 w.stop ();
1096} 1100}
1097#endif 1101#endif
1098 1102
1102{ 1106{
1103 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1107 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1104 { 1108 {
1105 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1109 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1106 want_refresh = 1; 1110 want_refresh = 1;
1111 refresh_check ();
1107 } 1112 }
1108 else 1113 else
1109 w.stop (); 1114 w.stop ();
1110} 1115}
1111#endif 1116#endif
1112 1117
1113#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1118#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1114void 1119void
1115rxvt_term::slip_wheel_cb (ev::timer &w, int revents) 1120rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1116{ 1121{
1117 if (mouse_slip_wheel_speed == 0 1122 if (scr_changeview (view_start - mouse_slip_wheel_speed))
1118 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1119 : scr_page (UP, mouse_slip_wheel_speed))
1120 { 1123 {
1121 if (view_start == top_row || view_start == 0)
1122 mouse_slip_wheel_speed = 0;
1123
1124 want_refresh = 1; 1124 want_refresh = 1;
1125 refresh_check ();
1126 }
1127
1128 if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0)
1125 } 1129 {
1126 else 1130 mouse_slip_wheel_speed = 0;
1127 w.stop (); 1131 w.stop ();
1132 }
1128} 1133}
1129#endif 1134#endif
1130 1135
1131#if LINUX_YIELD_HACK 1136#if LINUX_YIELD_HACK
1132static struct event_handler 1137static struct event_handler
1251 int x, y; 1256 int x, y;
1252 int code = 32; 1257 int code = 32;
1253 1258
1254 x = Pixel2Col (ev.x); 1259 x = Pixel2Col (ev.x);
1255 y = Pixel2Row (ev.y); 1260 y = Pixel2Row (ev.y);
1256 if (ev.type == MotionNotify) { 1261 if (ev.type == MotionNotify)
1262 {
1257 if (x == mouse_row && y == mouse_col) 1263 if (x == mouse_row && y == mouse_col)
1258 return; 1264 return;
1259 mouse_row = x; 1265 mouse_row = x;
1260 mouse_col = y; 1266 mouse_col = y;
1261 code += 32; 1267 code += 32;
1262 } 1268 }
1263 1269
1264 if (MEvent.button == AnyButton) 1270 if (MEvent.button == AnyButton)
1265 button_number = 3; 1271 button_number = 3;
1266 else 1272 else
1267 { 1273 {
1475 break; 1481 break;
1476 1482
1477 case MapNotify: 1483 case MapNotify:
1478 mapped = 1; 1484 mapped = 1;
1479#ifdef TEXT_BLINK 1485#ifdef TEXT_BLINK
1480 text_blink_ev.start (TEXT_BLINK_INTERVAL); 1486 text_blink_ev.start ();
1481#endif 1487#endif
1482 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1488 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1483 break; 1489 break;
1484 1490
1485 case UnmapNotify: 1491 case UnmapNotify:
1506 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1512 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1507 { 1513 {
1508 scr_expose (ev.xexpose.x, ev.xexpose.y, 1514 scr_expose (ev.xexpose.x, ev.xexpose.y,
1509 ev.xexpose.width, ev.xexpose.height, False); 1515 ev.xexpose.width, ev.xexpose.height, False);
1510 } 1516 }
1517
1511 want_refresh = 1; 1518 want_refresh = 1;
1512 } 1519 }
1513 else 1520 else
1514 { 1521 {
1515 XEvent unused_event; 1522 XEvent unused_event;
1576 int dist; 1583 int dist;
1577 1584
1578 /* don't clobber the current delay if we are 1585 /* don't clobber the current delay if we are
1579 * already in the middle of scrolling. 1586 * already in the middle of scrolling.
1580 */ 1587 */
1581 if (!sel_scroll_ev.active) 1588 if (!sel_scroll_ev.is_active ())
1582 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 1589 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1583 1590
1584 /* save the event params so we can highlight 1591 /* save the event params so we can highlight
1585 * the selection in the pending-scroll loop 1592 * the selection in the pending-scroll loop
1586 */ 1593 */
1609 else 1616 else
1610 { 1617 {
1611 /* we are within the text window, so we 1618 /* we are within the text window, so we
1612 * shouldn't be scrolling 1619 * shouldn't be scrolling
1613 */ 1620 */
1614 if (sel_scroll_ev.active)
1615 sel_scroll_ev.stop(); 1621 sel_scroll_ev.stop();
1616 } 1622 }
1617#endif 1623#endif
1618#ifdef MOUSE_THRESHOLD 1624#ifdef MOUSE_THRESHOLD
1619 } 1625 }
1620#endif 1626#endif
1663 1669
1664 if (ev.type == KeyPress && hidden_pointer == 0) 1670 if (ev.type == KeyPress && hidden_pointer == 0)
1665 pointer_blank (); 1671 pointer_blank ();
1666 } 1672 }
1667#endif 1673#endif
1674
1675 refresh_check ();
1668} 1676}
1669 1677
1670void 1678void
1671rxvt_term::focus_in () 1679rxvt_term::focus_in ()
1672{ 1680{
1684 XSetICFocus (Input_Context); 1692 XSetICFocus (Input_Context);
1685 } 1693 }
1686#endif 1694#endif
1687#if CURSOR_BLINK 1695#if CURSOR_BLINK
1688 if (option (Opt_cursorBlink)) 1696 if (option (Opt_cursorBlink))
1689 cursor_blink_ev.start (CURSOR_BLINK_INTERVAL, CURSOR_BLINK_INTERVAL); 1697 cursor_blink_ev.again ();
1690#endif 1698#endif
1691#if OFF_FOCUS_FADING 1699#if OFF_FOCUS_FADING
1692 if (rs[Rs_fade]) 1700 if (rs[Rs_fade])
1693 { 1701 {
1694 pix_colors = pix_colors_focused; 1702 pix_colors = pix_colors_focused;
1785 update_background (); 1793 update_background ();
1786 } 1794 }
1787 break; 1795 break;
1788 } 1796 }
1789# endif 1797# endif
1798
1799 refresh_check ();
1790} 1800}
1791#endif 1801#endif
1792 1802
1793void 1803void
1794rxvt_term::button_press (XButtonEvent &ev) 1804rxvt_term::button_press (XButtonEvent &ev)
1849 mouse_report (ev); 1859 mouse_report (ev);
1850 } 1860 }
1851#else 1861#else
1852 MEvent.button = ev.button; 1862 MEvent.button = ev.button;
1853 mouse_report (ev); 1863 mouse_report (ev);
1854#endif /* MOUSE_REPORT_DOUBLECLICK */ 1864#endif /* MOUSE_REPORT_DOUBLECLICK */
1855 1865
1856 } 1866 }
1857 else 1867 else
1858 { 1868 {
1859 if (ev.button != MEvent.button) 1869 if (ev.button != MEvent.button)
1953 tt_printf ("\033[5~"); 1963 tt_printf ("\033[5~");
1954 break; 1964 break;
1955 } 1965 }
1956 } 1966 }
1957 else 1967 else
1958#endif /* NO_SCROLLBAR_REPORT */ 1968#endif /* NO_SCROLLBAR_REPORT */
1959 1969
1960 { 1970 {
1961 char upordown = 0; 1971 char upordown = 0;
1962 1972
1963 if (scrollBar.style == R_SB_NEXT) 1973 if (scrollBar.style == R_SB_NEXT)
1964 { 1974 {
1965 if (scrollbarnext_upButton (ev.y)) 1975 if (scrollbarnext_upButton (ev.y))
1966 upordown = -1; /* up */ 1976 upordown = -1; /* up */
1972 if (scrollbarrxvt_upButton (ev.y)) 1982 if (scrollbarrxvt_upButton (ev.y))
1973 upordown = -1; /* up */ 1983 upordown = -1; /* up */
1974 else if (scrollbarrxvt_dnButton (ev.y)) 1984 else if (scrollbarrxvt_dnButton (ev.y))
1975 upordown = 1; /* down */ 1985 upordown = 1; /* down */
1976 } 1986 }
1987
1977 if (upordown) 1988 if (upordown)
1978 { 1989 {
1979#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1990#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1991 if (!cont_scroll_ev.is_active ())
1980 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 1992 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1981#endif 1993#endif
1982 if (scr_page (upordown < 0 ? UP : DN, 1)) 1994 if (scr_page (upordown < 0 ? UP : DN, 1))
1983 { 1995 {
1984 if (upordown < 0) 1996 if (upordown < 0)
1985 scrollBar.setUp (); 1997 scrollBar.setUp ();
2065 scrollBar.setIdle (); 2077 scrollBar.setIdle ();
2066 scrollbar_show (0); 2078 scrollbar_show (0);
2067 } 2079 }
2068 2080
2069#ifdef SELECTION_SCROLLING 2081#ifdef SELECTION_SCROLLING
2070 if (sel_scroll_ev.active)
2071 sel_scroll_ev.stop(); 2082 sel_scroll_ev.stop();
2072#endif 2083#endif
2073 2084
2074 if (ev.window == vt) 2085 if (ev.window == vt)
2075 { 2086 {
2076 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) 2087 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2100 mouse_report (ev); 2111 mouse_report (ev);
2101 } 2112 }
2102#else /* MOUSE_REPORT_DOUBLECLICK */ 2113#else /* MOUSE_REPORT_DOUBLECLICK */
2103 MEvent.button = AnyButton; 2114 MEvent.button = AnyButton;
2104 mouse_report (ev); 2115 mouse_report (ev);
2105#endif /* MOUSE_REPORT_DOUBLECLICK */ 2116#endif /* MOUSE_REPORT_DOUBLECLICK */
2106 return; 2117 return;
2107 } 2118 }
2108 2119
2109 /* 2120 /*
2110 * dumb hack to compensate for the failure of click-and-drag 2121 * dumb hack to compensate for the failure of click-and-drag
2148 { 2159 {
2149 mouse_slip_wheel_speed += v ? -1 : 1; 2160 mouse_slip_wheel_speed += v ? -1 : 1;
2150 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2161 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow;
2151 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; 2162 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2152 2163
2164 if (!slip_wheel_ev.is_active ())
2153 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2165 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2154 } 2166 }
2155 else 2167 else
2156 { 2168 {
2157# endif 2169# endif
2158 scr_page (v, i); 2170 scr_page (v, i);
2226 2238
2227 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) 2239 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2228 { 2240 {
2229 refresh_count = 0; 2241 refresh_count = 0;
2230 2242
2231 if (!option (Opt_skipScroll) || ev::ev_time () > ev::now () + 1. / 60.) 2243 if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.)
2232 { 2244 {
2233 refreshnow = true; 2245 refreshnow = true;
2234 ch = NOCHAR; 2246 ch = NOCHAR;
2235 break; 2247 break;
2236 } 2248 }
2296 } 2308 }
2297 2309
2298 ch = NOCHAR; 2310 ch = NOCHAR;
2299 } 2311 }
2300 } 2312 }
2313
2314 refresh_check ();
2301 2315
2302 return flag; 2316 return flag;
2303} 2317}
2304 2318
2305// read the next character 2319// read the next character
2447 } 2461 }
2448 } 2462 }
2449 2463
2450 pclose_printer (fd); 2464 pclose_printer (fd);
2451} 2465}
2452#endif /* PRINTPIPE */ 2466#endif /* PRINTPIPE */
2453/*}}} */ 2467/*}}} */
2454 2468
2455/* *INDENT-OFF* */ 2469/* *INDENT-OFF* */
2456enum { 2470enum {
2457 C1_40 = 0x40, 2471 C1_40 = 0x40,
2750 nargs = 0; 2764 nargs = 0;
2751 2765
2752 priv = 0; 2766 priv = 0;
2753 ch = cmd_getc (); 2767 ch = cmd_getc ();
2754 if (ch >= '<' && ch <= '?') 2768 if (ch >= '<' && ch <= '?')
2769 {
2755 { /* '<' '=' '>' '?' */ 2770 /* '<' '=' '>' '?' */
2756 priv = ch; 2771 priv = ch;
2757 ch = cmd_getc (); 2772 ch = cmd_getc ();
2758 } 2773 }
2759 2774
2760 /* read any numerical arguments */ 2775 /* read any numerical arguments */
3580 { 66, PrivMode_aplKP }, 3595 { 66, PrivMode_aplKP },
3581#ifndef NO_BACKSPACE_KEY 3596#ifndef NO_BACKSPACE_KEY
3582 { 67, PrivMode_BackSpace }, 3597 { 67, PrivMode_BackSpace },
3583#endif 3598#endif
3584 { 1000, PrivMode_MouseX11 }, 3599 { 1000, PrivMode_MouseX11 },
3585 // 1001 Use Hilite Mouse Tracking. NYI, TODO
3586 { 1002, PrivMode_MouseBtnEvent }, 3600 { 1002, PrivMode_MouseBtnEvent },
3587 { 1003, PrivMode_MouseAnyEvent }, 3601 { 1003, PrivMode_MouseAnyEvent },
3588 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3602 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3589 { 1011, PrivMode_Keypress }, // rxvt extension 3603 { 1011, PrivMode_Keypress }, // rxvt extension
3590 // 1035 enable modifiers for alt, numlock NYI 3604 // 1035 enable modifiers for alt, numlock NYI
3691 /* case 67: - backspace key */ 3705 /* case 67: - backspace key */
3692 case 1000: /* X11 mouse reporting */ 3706 case 1000: /* X11 mouse reporting */
3693 if (state) /* orthogonal */ 3707 if (state) /* orthogonal */
3694 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3708 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3695 break; 3709 break;
3696#if 0
3697 case 1001:
3698 break; /* X11 mouse highlighting */
3699#endif
3700 case 1002: 3710 case 1002:
3701 case 1003: 3711 case 1003:
3702 if (state) { 3712 if (state)
3713 {
3703 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); 3714 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3704 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; 3715 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3705 vt_emask_mouse = PointerMotionMask; 3716 vt_emask_mouse = PointerMotionMask;
3717 }
3706 } else 3718 else
3707 vt_emask_mouse = NoEventMask; 3719 vt_emask_mouse = NoEventMask;
3708 vt_select_input (); 3720 vt_select_input ();
3709 break; 3721 break;
3710 case 1010: /* scroll to bottom on TTY output inhibit */ 3722 case 1010: /* scroll to bottom on TTY output inhibit */
3711 set_option (Opt_scrollTtyOutput, !state); 3723 set_option (Opt_scrollTtyOutput, !state);
3891rxvt_term::process_graphics () 3903rxvt_term::process_graphics ()
3892{ 3904{
3893 unicode_t ch, cmd = cmd_getc (); 3905 unicode_t ch, cmd = cmd_getc ();
3894 3906
3895 if (cmd == 'Q') 3907 if (cmd == 'Q')
3908 {
3896 { /* query graphics */ 3909 /* query graphics */
3897 tt_printf ("\033G0\012"); /* no graphics */ 3910 tt_printf ("\033G0\012"); /* no graphics */
3898 return; 3911 return;
3899 } 3912 }
3900 /* swallow other graphics sequences until terminating ':' */ 3913 /* swallow other graphics sequences until terminating ':' */
3901 do 3914 do

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines