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.384 by ayin, Tue Dec 18 13:07:55 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.
198 r & RS_Uline ? " uline" : "", 198 r & RS_Uline ? " uline" : "",
199 r & RS_Careful ? " careful" : ""); 199 r & RS_Careful ? " careful" : "");
200 200
201 int width = wcswidth (fname, wcslen (fname)); 201 int width = wcswidth (fname, wcslen (fname));
202 202
203 max_it (width, 8+5); // for char + hey 203 max_it (width, 8+5); // for char + hex
204 max_it (width, strlen (attr)); 204 max_it (width, strlen (attr));
205 205
206 if (y >= 0) 206 if (y >= 0)
207 { 207 {
208 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; 208 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1;
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 if (want_refresh && !flush_ev.is_active ())
1051 flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally
1050 1052
1051 display->flush (); 1053 display->flush ();
1052
1053 if (want_refresh && !flush_ev.active)
1054 flush_ev.start (1. / 60.); // refresh at max. 60 hz normally
1055} 1054}
1056 1055
1057void 1056void
1058rxvt_term::flush_cb (ev::timer &w, int revents) 1057rxvt_term::flush_cb (ev::timer &w, int revents)
1059{ 1058{
1067void 1066void
1068rxvt_term::cursor_blink_cb (ev::timer &w, int revents) 1067rxvt_term::cursor_blink_cb (ev::timer &w, int revents)
1069{ 1068{
1070 hidden_cursor = !hidden_cursor; 1069 hidden_cursor = !hidden_cursor;
1071 want_refresh = 1; 1070 want_refresh = 1;
1071 refresh_check ();
1072} 1072}
1073#endif 1073#endif
1074 1074
1075#ifdef TEXT_BLINK 1075#ifdef TEXT_BLINK
1076void 1076void
1078{ 1078{
1079 if (scr_refresh_rend (RS_Blink, RS_Blink)) 1079 if (scr_refresh_rend (RS_Blink, RS_Blink))
1080 { 1080 {
1081 hidden_text = !hidden_text; 1081 hidden_text = !hidden_text;
1082 want_refresh = 1; 1082 want_refresh = 1;
1083 refresh_check ();
1083 } 1084 }
1085 else
1086 w.stop ();
1084} 1087}
1085#endif 1088#endif
1086 1089
1087#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1090#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1088void 1091void
1089rxvt_term::cont_scroll_cb (ev::timer &w, int revents) 1092rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1090{ 1093{
1091 if ((scrollbar_isUp() || scrollbar_isDn()) && 1094 if ((scrollbar_isUp () || scrollbar_isDn ())
1092 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1095 && scr_page (scrollbar_isUp () ? UP : DN, 1))
1096 {
1093 want_refresh = 1; 1097 want_refresh = 1;
1098 refresh_check ();
1099 }
1094 else 1100 else
1095 w.stop (); 1101 w.stop ();
1096} 1102}
1097#endif 1103#endif
1098 1104
1102{ 1108{
1103 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1109 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1104 { 1110 {
1105 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1111 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1106 want_refresh = 1; 1112 want_refresh = 1;
1113 refresh_check ();
1107 } 1114 }
1108 else 1115 else
1109 w.stop (); 1116 w.stop ();
1110} 1117}
1111#endif 1118#endif
1112 1119
1113#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1120#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1114void 1121void
1115rxvt_term::slip_wheel_cb (ev::timer &w, int revents) 1122rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1116{ 1123{
1117 if (mouse_slip_wheel_speed == 0 1124 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 { 1125 {
1121 if (view_start == top_row || view_start == 0)
1122 mouse_slip_wheel_speed = 0;
1123
1124 want_refresh = 1; 1126 want_refresh = 1;
1127 refresh_check ();
1128 }
1129
1130 if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0)
1125 } 1131 {
1126 else 1132 mouse_slip_wheel_speed = 0;
1127 w.stop (); 1133 w.stop ();
1134 }
1128} 1135}
1129#endif 1136#endif
1130 1137
1131#if LINUX_YIELD_HACK 1138#if LINUX_YIELD_HACK
1132static struct event_handler 1139static struct event_handler
1204 if (cmd_parse ()) 1211 if (cmd_parse ())
1205 break; 1212 break;
1206 1213
1207 if (revents & ev::WRITE) 1214 if (revents & ev::WRITE)
1208 pty_write (); 1215 pty_write ();
1216
1217 refresh_check ();
1209} 1218}
1210 1219
1211void 1220void
1212rxvt_term::pointer_unblank () 1221rxvt_term::pointer_unblank ()
1213{ 1222{
1251 int x, y; 1260 int x, y;
1252 int code = 32; 1261 int code = 32;
1253 1262
1254 x = Pixel2Col (ev.x); 1263 x = Pixel2Col (ev.x);
1255 y = Pixel2Row (ev.y); 1264 y = Pixel2Row (ev.y);
1256 if (ev.type == MotionNotify) { 1265 if (ev.type == MotionNotify)
1266 {
1257 if (x == mouse_row && y == mouse_col) 1267 if (x == mouse_row && y == mouse_col)
1258 return; 1268 return;
1259 mouse_row = x; 1269 mouse_row = x;
1260 mouse_col = y; 1270 mouse_col = y;
1261 code += 32; 1271 code += 32;
1262 } 1272 }
1263 1273
1264 if (MEvent.button == AnyButton) 1274 if (MEvent.button == AnyButton)
1265 button_number = 3; 1275 button_number = 3;
1266 else 1276 else
1267 { 1277 {
1475 break; 1485 break;
1476 1486
1477 case MapNotify: 1487 case MapNotify:
1478 mapped = 1; 1488 mapped = 1;
1479#ifdef TEXT_BLINK 1489#ifdef TEXT_BLINK
1480 text_blink_ev.start (TEXT_BLINK_INTERVAL); 1490 text_blink_ev.start ();
1481#endif 1491#endif
1482 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1492 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1483 break; 1493 break;
1484 1494
1485 case UnmapNotify: 1495 case UnmapNotify:
1506 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1516 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1507 { 1517 {
1508 scr_expose (ev.xexpose.x, ev.xexpose.y, 1518 scr_expose (ev.xexpose.x, ev.xexpose.y,
1509 ev.xexpose.width, ev.xexpose.height, False); 1519 ev.xexpose.width, ev.xexpose.height, False);
1510 } 1520 }
1521
1511 want_refresh = 1; 1522 want_refresh = 1;
1512 } 1523 }
1513 else 1524 else
1514 { 1525 {
1515 XEvent unused_event; 1526 XEvent unused_event;
1576 int dist; 1587 int dist;
1577 1588
1578 /* don't clobber the current delay if we are 1589 /* don't clobber the current delay if we are
1579 * already in the middle of scrolling. 1590 * already in the middle of scrolling.
1580 */ 1591 */
1581 if (!sel_scroll_ev.active) 1592 if (!sel_scroll_ev.is_active ())
1582 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 1593 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1583 1594
1584 /* save the event params so we can highlight 1595 /* save the event params so we can highlight
1585 * the selection in the pending-scroll loop 1596 * the selection in the pending-scroll loop
1586 */ 1597 */
1609 else 1620 else
1610 { 1621 {
1611 /* we are within the text window, so we 1622 /* we are within the text window, so we
1612 * shouldn't be scrolling 1623 * shouldn't be scrolling
1613 */ 1624 */
1614 if (sel_scroll_ev.active)
1615 sel_scroll_ev.stop(); 1625 sel_scroll_ev.stop();
1616 } 1626 }
1617#endif 1627#endif
1618#ifdef MOUSE_THRESHOLD 1628#ifdef MOUSE_THRESHOLD
1619 } 1629 }
1620#endif 1630#endif
1663 1673
1664 if (ev.type == KeyPress && hidden_pointer == 0) 1674 if (ev.type == KeyPress && hidden_pointer == 0)
1665 pointer_blank (); 1675 pointer_blank ();
1666 } 1676 }
1667#endif 1677#endif
1678
1679 refresh_check ();
1668} 1680}
1669 1681
1670void 1682void
1671rxvt_term::focus_in () 1683rxvt_term::focus_in ()
1672{ 1684{
1684 XSetICFocus (Input_Context); 1696 XSetICFocus (Input_Context);
1685 } 1697 }
1686#endif 1698#endif
1687#if CURSOR_BLINK 1699#if CURSOR_BLINK
1688 if (option (Opt_cursorBlink)) 1700 if (option (Opt_cursorBlink))
1689 cursor_blink_ev.start (CURSOR_BLINK_INTERVAL, CURSOR_BLINK_INTERVAL); 1701 cursor_blink_ev.again ();
1690#endif 1702#endif
1691#if OFF_FOCUS_FADING 1703#if OFF_FOCUS_FADING
1692 if (rs[Rs_fade]) 1704 if (rs[Rs_fade])
1693 { 1705 {
1694 pix_colors = pix_colors_focused; 1706 pix_colors = pix_colors_focused;
1785 update_background (); 1797 update_background ();
1786 } 1798 }
1787 break; 1799 break;
1788 } 1800 }
1789# endif 1801# endif
1802
1803 refresh_check ();
1790} 1804}
1791#endif 1805#endif
1792 1806
1793void 1807void
1794rxvt_term::button_press (XButtonEvent &ev) 1808rxvt_term::button_press (XButtonEvent &ev)
1849 mouse_report (ev); 1863 mouse_report (ev);
1850 } 1864 }
1851#else 1865#else
1852 MEvent.button = ev.button; 1866 MEvent.button = ev.button;
1853 mouse_report (ev); 1867 mouse_report (ev);
1854#endif /* MOUSE_REPORT_DOUBLECLICK */ 1868#endif /* MOUSE_REPORT_DOUBLECLICK */
1855 1869
1856 } 1870 }
1857 else 1871 else
1858 { 1872 {
1859 if (ev.button != MEvent.button) 1873 if (ev.button != MEvent.button)
1953 tt_printf ("\033[5~"); 1967 tt_printf ("\033[5~");
1954 break; 1968 break;
1955 } 1969 }
1956 } 1970 }
1957 else 1971 else
1958#endif /* NO_SCROLLBAR_REPORT */ 1972#endif /* NO_SCROLLBAR_REPORT */
1959 1973
1960 { 1974 {
1961 char upordown = 0; 1975 char upordown = 0;
1962 1976
1963 if (scrollBar.style == R_SB_NEXT) 1977 if (scrollBar.style == R_SB_NEXT)
1964 { 1978 {
1965 if (scrollbarnext_upButton (ev.y)) 1979 if (scrollbarnext_upButton (ev.y))
1966 upordown = -1; /* up */ 1980 upordown = -1; /* up */
1972 if (scrollbarrxvt_upButton (ev.y)) 1986 if (scrollbarrxvt_upButton (ev.y))
1973 upordown = -1; /* up */ 1987 upordown = -1; /* up */
1974 else if (scrollbarrxvt_dnButton (ev.y)) 1988 else if (scrollbarrxvt_dnButton (ev.y))
1975 upordown = 1; /* down */ 1989 upordown = 1; /* down */
1976 } 1990 }
1991
1977 if (upordown) 1992 if (upordown)
1978 { 1993 {
1979#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1994#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1995 if (!cont_scroll_ev.is_active ())
1980 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 1996 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1981#endif 1997#endif
1982 if (scr_page (upordown < 0 ? UP : DN, 1)) 1998 if (scr_page (upordown < 0 ? UP : DN, 1))
1983 { 1999 {
1984 if (upordown < 0) 2000 if (upordown < 0)
1985 scrollBar.setUp (); 2001 scrollBar.setUp ();
2065 scrollBar.setIdle (); 2081 scrollBar.setIdle ();
2066 scrollbar_show (0); 2082 scrollbar_show (0);
2067 } 2083 }
2068 2084
2069#ifdef SELECTION_SCROLLING 2085#ifdef SELECTION_SCROLLING
2070 if (sel_scroll_ev.active)
2071 sel_scroll_ev.stop(); 2086 sel_scroll_ev.stop();
2072#endif 2087#endif
2073 2088
2074 if (ev.window == vt) 2089 if (ev.window == vt)
2075 { 2090 {
2076 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) 2091 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2100 mouse_report (ev); 2115 mouse_report (ev);
2101 } 2116 }
2102#else /* MOUSE_REPORT_DOUBLECLICK */ 2117#else /* MOUSE_REPORT_DOUBLECLICK */
2103 MEvent.button = AnyButton; 2118 MEvent.button = AnyButton;
2104 mouse_report (ev); 2119 mouse_report (ev);
2105#endif /* MOUSE_REPORT_DOUBLECLICK */ 2120#endif /* MOUSE_REPORT_DOUBLECLICK */
2106 return; 2121 return;
2107 } 2122 }
2108 2123
2109 /* 2124 /*
2110 * dumb hack to compensate for the failure of click-and-drag 2125 * dumb hack to compensate for the failure of click-and-drag
2148 { 2163 {
2149 mouse_slip_wheel_speed += v ? -1 : 1; 2164 mouse_slip_wheel_speed += v ? -1 : 1;
2150 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2165 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow;
2151 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; 2166 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2152 2167
2168 if (!slip_wheel_ev.is_active ())
2153 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2169 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2154 } 2170 }
2155 else 2171 else
2156 { 2172 {
2157# endif 2173# endif
2158 scr_page (v, i); 2174 scr_page (v, i);
2226 2242
2227 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) 2243 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2228 { 2244 {
2229 refresh_count = 0; 2245 refresh_count = 0;
2230 2246
2231 if (!option (Opt_skipScroll) || ev::ev_time () > ev::now () + 1. / 60.) 2247 if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.)
2232 { 2248 {
2233 refreshnow = true; 2249 refreshnow = true;
2234 ch = NOCHAR; 2250 ch = NOCHAR;
2235 break; 2251 break;
2236 } 2252 }
2447 } 2463 }
2448 } 2464 }
2449 2465
2450 pclose_printer (fd); 2466 pclose_printer (fd);
2451} 2467}
2452#endif /* PRINTPIPE */ 2468#endif /* PRINTPIPE */
2453/*}}} */ 2469/*}}} */
2454 2470
2455/* *INDENT-OFF* */ 2471/* *INDENT-OFF* */
2456enum { 2472enum {
2457 C1_40 = 0x40, 2473 C1_40 = 0x40,
2750 nargs = 0; 2766 nargs = 0;
2751 2767
2752 priv = 0; 2768 priv = 0;
2753 ch = cmd_getc (); 2769 ch = cmd_getc ();
2754 if (ch >= '<' && ch <= '?') 2770 if (ch >= '<' && ch <= '?')
2771 {
2755 { /* '<' '=' '>' '?' */ 2772 /* '<' '=' '>' '?' */
2756 priv = ch; 2773 priv = ch;
2757 ch = cmd_getc (); 2774 ch = cmd_getc ();
2758 } 2775 }
2759 2776
2760 /* read any numerical arguments */ 2777 /* read any numerical arguments */
3580 { 66, PrivMode_aplKP }, 3597 { 66, PrivMode_aplKP },
3581#ifndef NO_BACKSPACE_KEY 3598#ifndef NO_BACKSPACE_KEY
3582 { 67, PrivMode_BackSpace }, 3599 { 67, PrivMode_BackSpace },
3583#endif 3600#endif
3584 { 1000, PrivMode_MouseX11 }, 3601 { 1000, PrivMode_MouseX11 },
3585 // 1001 Use Hilite Mouse Tracking. NYI, TODO
3586 { 1002, PrivMode_MouseBtnEvent }, 3602 { 1002, PrivMode_MouseBtnEvent },
3587 { 1003, PrivMode_MouseAnyEvent }, 3603 { 1003, PrivMode_MouseAnyEvent },
3588 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3604 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3589 { 1011, PrivMode_Keypress }, // rxvt extension 3605 { 1011, PrivMode_Keypress }, // rxvt extension
3590 // 1035 enable modifiers for alt, numlock NYI 3606 // 1035 enable modifiers for alt, numlock NYI
3691 /* case 67: - backspace key */ 3707 /* case 67: - backspace key */
3692 case 1000: /* X11 mouse reporting */ 3708 case 1000: /* X11 mouse reporting */
3693 if (state) /* orthogonal */ 3709 if (state) /* orthogonal */
3694 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3710 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3695 break; 3711 break;
3696#if 0
3697 case 1001:
3698 break; /* X11 mouse highlighting */
3699#endif
3700 case 1002: 3712 case 1002:
3701 case 1003: 3713 case 1003:
3702 if (state) { 3714 if (state)
3715 {
3703 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); 3716 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3704 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; 3717 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3705 vt_emask_mouse = PointerMotionMask; 3718 vt_emask_mouse = PointerMotionMask;
3719 }
3706 } else 3720 else
3707 vt_emask_mouse = NoEventMask; 3721 vt_emask_mouse = NoEventMask;
3708 vt_select_input (); 3722 vt_select_input ();
3709 break; 3723 break;
3710 case 1010: /* scroll to bottom on TTY output inhibit */ 3724 case 1010: /* scroll to bottom on TTY output inhibit */
3711 set_option (Opt_scrollTtyOutput, !state); 3725 set_option (Opt_scrollTtyOutput, !state);
3891rxvt_term::process_graphics () 3905rxvt_term::process_graphics ()
3892{ 3906{
3893 unicode_t ch, cmd = cmd_getc (); 3907 unicode_t ch, cmd = cmd_getc ();
3894 3908
3895 if (cmd == 'Q') 3909 if (cmd == 'Q')
3910 {
3896 { /* query graphics */ 3911 /* query graphics */
3897 tt_printf ("\033G0\012"); /* no graphics */ 3912 tt_printf ("\033G0\012"); /* no graphics */
3898 return; 3913 return;
3899 } 3914 }
3900 /* swallow other graphics sequences until terminating ':' */ 3915 /* swallow other graphics sequences until terminating ':' */
3901 do 3916 do

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines