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.388 by ayin, Mon Dec 31 01:16:47 2007 UTC vs.
Revision 1.408 by ayin, Sat Feb 16 13:36:10 2008 UTC

279 } 279 }
280 280
281 iso14755buf = 0; 281 iso14755buf = 0;
282} 282}
283 283
284int 284static int
285rxvt_term::hex_keyval (XKeyEvent &ev) 285hex_keyval (XKeyEvent &ev)
286{ 286{
287 // check wether this event corresponds to a hex digit 287 // check wether this event corresponds to a hex digit
288 // if the modifiers had not been pressed. 288 // if the modifiers had not been pressed.
289 for (int index = 0; index < 8; index++) 289 for (int index = 0; index < 8; index++)
290 { 290 {
298 298
299 return -1; 299 return -1;
300} 300}
301#endif 301#endif
302 302
303static inline KeySym
304translate_keypad (KeySym keysym, bool kp)
305{
306#ifdef XK_KP_Home
307 static const KeySym keypadtrans[] = {
308 XK_KP_7, // XK_KP_Home
309 XK_KP_4, // XK_KP_Left
310 XK_KP_8, // XK_KP_Up
311 XK_KP_6, // XK_KP_Right
312 XK_KP_2, // XK_KP_Down
313# ifndef UNSHIFTED_SCROLLKEYS
314 XK_KP_9, // XK_KP_Prior
315 XK_KP_3, // XK_KP_Next
316# else
317 XK_Prior,
318 XK_Next,
319# endif
320 XK_KP_1, // XK_KP_End
321 XK_KP_5, // XK_KP_Begin
322 };
323
324 if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin))
325 {
326 unsigned int index = keysym - XK_KP_Home;
327 keysym = kp ? keypadtrans[index] : XK_Home + index;
328 }
329 else if (keysym == XK_KP_Insert)
330 keysym = kp ? XK_KP_0 : XK_Insert;
331# ifndef NO_DELETE_KEY
332 else if (keysym == XK_KP_Delete)
333 keysym = kp ? XK_KP_Decimal : XK_Delete;
334# endif
335#endif
336 return keysym;
337}
338
303void 339void
304rxvt_term::key_press (XKeyEvent &ev) 340rxvt_term::key_press (XKeyEvent &ev)
305{ 341{
306 int ctrl, meta, shft, len; 342 int ctrl, meta, shft, len;
307 unsigned int newlen;
308 KeySym keysym; 343 KeySym keysym;
309 int valid_keysym; 344 int valid_keysym;
310 char kbuf[KBUFSZ]; 345 char kbuf[KBUFSZ];
311 346
312#if ISO_14755 347#if ISO_14755
547 } 582 }
548#endif 583#endif
549 584
550 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 585 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
551 { 586 {
552 {
553 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; 587 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
554 newlen = 1; 588 unsigned int newlen = 1;
555#ifdef XK_KP_Home
556 static const KeySym keypadtrans[] = {
557 XK_KP_7, // XK_KP_Home
558 XK_KP_4, // XK_KP_Left
559 XK_KP_8, // XK_KP_Up
560 XK_KP_6, // XK_KP_Right
561 XK_KP_2, // XK_KP_Down
562#ifndef UNSHIFTED_SCROLLKEYS
563 XK_KP_9, // XK_KP_Prior
564 XK_KP_3, // XK_KP_Next
565#else
566 XK_Prior,
567 XK_Next,
568#endif
569 XK_KP_1, // XK_KP_End
570 XK_KP_5, // XK_KP_Begin
571 };
572 589
573 if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) 590 switch (translate_keypad (keysym, kp))
574 {
575 unsigned int index = keysym - XK_KP_Home;
576 keysym = kp ? keypadtrans[index] : XK_Home + index;
577 }
578 else if (keysym == XK_KP_Insert)
579 keysym = kp ? XK_KP_0 : XK_Insert;
580#ifndef NO_DELETE_KEY
581 else if (keysym == XK_KP_Delete)
582 keysym = kp ? XK_KP_Decimal : XK_Delete;
583#endif
584#endif
585 switch (keysym)
586 { 591 {
587#ifndef NO_BACKSPACE_KEY 592#ifndef NO_BACKSPACE_KEY
588 case XK_BackSpace: 593 case XK_BackSpace:
589 if (priv_modes & PrivMode_HaveBackSpace) 594 if (priv_modes & PrivMode_HaveBackSpace)
590 { 595 {
789 break; 794 break;
790 } 795 }
791 796
792 if (newlen) 797 if (newlen)
793 len = strlen (kbuf); 798 len = strlen (kbuf);
794 }
795 799
796 /* 800 /*
797 * Pass meta for all function keys, if 'meta' option set 801 * Pass meta for all function keys, if 'meta' option set
798 */ 802 */
799#ifdef META8_OPTION 803#ifdef META8_OPTION
1079{ 1083{
1080 if (scr_refresh_rend (RS_Blink, RS_Blink)) 1084 if (scr_refresh_rend (RS_Blink, RS_Blink))
1081 { 1085 {
1082 hidden_text = !hidden_text; 1086 hidden_text = !hidden_text;
1083 want_refresh = 1; 1087 want_refresh = 1;
1084 refresh_check (); 1088 refresh_check ();
1085 } 1089 }
1086 else 1090 else
1087 w.stop (); 1091 w.stop ();
1088} 1092}
1089#endif 1093#endif
1090 1094
1091#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1095#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1092void 1096void
1093rxvt_term::cont_scroll_cb (ev::timer &w, int revents) 1097rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1094{ 1098{
1095 if ((scrollbar_isUp () || scrollbar_isDn ()) 1099 if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
1096 && scr_page (scrollbar_isUp () ? UP : DN, 1)) 1100 && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1))
1097 { 1101 {
1098 want_refresh = 1; 1102 want_refresh = 1;
1099 refresh_check (); 1103 refresh_check ();
1100 } 1104 }
1101 else 1105 else
1438 && ev.xfocus.mode != NotifyGrab) 1442 && ev.xfocus.mode != NotifyGrab)
1439 focus_out (); 1443 focus_out ();
1440 break; 1444 break;
1441 1445
1442 case ConfigureNotify: 1446 case ConfigureNotify:
1443 /* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", 1447 /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n",
1444 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, 1448 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y,
1445 szHint.width, szHint.height); */ 1449 szHint.width, szHint.height);*/
1446 if (ev.xconfigure.window == parent[0]) 1450 if (ev.xconfigure.window == parent[0])
1447 { 1451 {
1448 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1452 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1449 ; 1453 ;
1450 1454
1455 } 1459 }
1456 else 1460 else
1457 { 1461 {
1458#ifdef HAVE_BG_PIXMAP 1462#ifdef HAVE_BG_PIXMAP
1459 if (bgPixmap.window_position_sensitive ()) 1463 if (bgPixmap.window_position_sensitive ())
1464 {
1465 if (mapped)
1460 update_background (); 1466 update_background ();
1467 else
1468 bgPixmap.invalidate ();
1469 }
1461#endif 1470#endif
1462 } 1471 }
1463 1472
1464 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1473 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1465 } 1474 }
1485 case SelectionRequest: 1494 case SelectionRequest:
1486 selection_send (ev.xselectionrequest); 1495 selection_send (ev.xselectionrequest);
1487 break; 1496 break;
1488 1497
1489 case MapNotify: 1498 case MapNotify:
1499#ifdef HAVE_BG_PIXMAP
1500 /* This is needed spcifically to fix the case of no window manager or a
1501 * non-reparenting window manager. In those cases we never get first
1502 * ConfigureNotify. Also that speeds startup under normal WM, by taking
1503 * care of multiplicity of ConfigureNotify events arriwing while WM does
1504 * reparenting.
1505 * We should not render background immidiately, as there could be several
1506 * ConfigureNotify's to follow. Lets take care of all of them in one scoop
1507 * by scheduling background redraw as soon as we can, but giving a short
1508 * bit of time for ConfigureNotifies to arrive.
1509 * We should render background PRIOR to drawing any text, but AFTER all
1510 * of ConfigureNotifys for the best results.
1511 */
1512 if (bgPixmap.flags & bgPixmap_t::isInvalid)
1513 update_background_ev.start (0.025);
1514#endif
1490 mapped = 1; 1515 mapped = 1;
1491#ifdef TEXT_BLINK 1516#ifdef TEXT_BLINK
1492 text_blink_ev.start (); 1517 text_blink_ev.start ();
1493#endif 1518#endif
1494 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1519 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1530 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) 1555 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event))
1531 ; 1556 ;
1532 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) 1557 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1533 ; 1558 ;
1534 1559
1535 if (isScrollbarWindow (ev.xany.window)) 1560 if (scrollBar.state && ev.xany.window == scrollBar.win)
1536 { 1561 {
1537 scrollBar.setIdle (); 1562 scrollBar.state = STATE_IDLE;
1538 scrollbar_show (0); 1563 scrollbar_show (0);
1539 } 1564 }
1540 } 1565 }
1541 break; 1566 break;
1542 1567
1630#ifdef MOUSE_THRESHOLD 1655#ifdef MOUSE_THRESHOLD
1631 } 1656 }
1632#endif 1657#endif
1633 } 1658 }
1634 } 1659 }
1635 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1660 else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win)
1636 { 1661 {
1637 while (XCheckTypedWindowEvent (dpy, scrollBar.win, 1662 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1638 MotionNotify, &ev)) 1663 MotionNotify, &ev))
1639 ; 1664 ;
1640 1665
1924 } 1949 }
1925 1950
1926 /* 1951 /*
1927 * Scrollbar window processing of button press 1952 * Scrollbar window processing of button press
1928 */ 1953 */
1929 if (isScrollbarWindow (ev.window)) 1954 if (scrollBar.state && ev.window == scrollBar.win)
1930 { 1955 {
1931 scrollBar.setIdle (); 1956 page_dirn direction = NO_DIR;
1957
1958 if (scrollBar.upButton (ev.y))
1959 direction = UP; /* up */
1960 else if (scrollBar.dnButton (ev.y))
1961 direction = DN; /* down */
1962
1963 scrollBar.state = STATE_IDLE;
1932 /* 1964 /*
1933 * Rxvt-style scrollbar: 1965 * Rxvt-style scrollbar:
1934 * move up if mouse is above slider 1966 * move up if mouse is above slider
1935 * move dn if mouse is below slider 1967 * move dn if mouse is below slider
1936 * 1968 *
1945 /* 1977 /*
1946 * Mouse report disabled scrollbar: 1978 * Mouse report disabled scrollbar:
1947 * arrow buttons - send up/down 1979 * arrow buttons - send up/down
1948 * click on scrollbar - send pageup/down 1980 * click on scrollbar - send pageup/down
1949 */ 1981 */
1950 if ((scrollBar.style == R_SB_NEXT 1982 if (direction == UP)
1951 && scrollbarnext_upButton (ev.y))
1952 || (scrollBar.style == R_SB_RXVT
1953 && scrollbarrxvt_upButton (ev.y)))
1954 tt_printf ("\033[A"); 1983 tt_printf ("\033[A");
1955 else if ((scrollBar.style == R_SB_NEXT 1984 else if (direction == DN)
1956 && scrollbarnext_dnButton (ev.y))
1957 || (scrollBar.style == R_SB_RXVT
1958 && scrollbarrxvt_dnButton (ev.y)))
1959 tt_printf ("\033[B"); 1985 tt_printf ("\033[B");
1960 else 1986 else
1961 switch (ev.button) 1987 switch (ev.button)
1962 { 1988 {
1963 case Button2: 1989 case Button2:
1971 break; 1997 break;
1972 } 1998 }
1973 } 1999 }
1974 else 2000 else
1975#endif /* NO_SCROLLBAR_REPORT */ 2001#endif /* NO_SCROLLBAR_REPORT */
1976
1977 {
1978 char upordown = 0;
1979
1980 if (scrollBar.style == R_SB_NEXT)
1981 { 2002 {
1982 if (scrollbarnext_upButton (ev.y)) 2003 if (direction != NO_DIR)
1983 upordown = -1; /* up */
1984 else if (scrollbarnext_dnButton (ev.y))
1985 upordown = 1; /* down */
1986 }
1987 else if (scrollBar.style == R_SB_RXVT)
1988 {
1989 if (scrollbarrxvt_upButton (ev.y))
1990 upordown = -1; /* up */
1991 else if (scrollbarrxvt_dnButton (ev.y))
1992 upordown = 1; /* down */
1993 }
1994
1995 if (upordown)
1996 { 2004 {
1997#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 2005#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1998 if (!cont_scroll_ev.is_active ()) 2006 if (!cont_scroll_ev.is_active ())
1999 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2007 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2000#endif 2008#endif
2001 if (scr_page (upordown < 0 ? UP : DN, 1)) 2009 if (scr_page (direction, 1))
2002 { 2010 {
2003 if (upordown < 0) 2011 if (direction == UP)
2004 scrollBar.setUp (); 2012 scrollBar.state = STATE_UP;
2005 else 2013 else
2006 scrollBar.setDn (); 2014 scrollBar.state = STATE_DOWN;
2007 } 2015 }
2008 } 2016 }
2009 else 2017 else
2010 switch (ev.button) 2018 switch (ev.button)
2011 { 2019 {
2026 if (scrollBar.style == R_SB_XTERM 2034 if (scrollBar.style == R_SB_XTERM
2027 || scrollbar_above_slider (ev.y) 2035 || scrollbar_above_slider (ev.y)
2028 || scrollbar_below_slider (ev.y)) 2036 || scrollbar_below_slider (ev.y))
2029 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); 2037 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ());
2030 2038
2031 scrollBar.setMotion (); 2039 scrollBar.state = STATE_MOTION;
2032 break; 2040 break;
2033 2041
2034 case Button1: 2042 case Button1:
2035 if (scrollBar.align == R_SB_ALIGN_CENTRE) 2043 if (scrollBar.align == R_SB_ALIGN_CENTRE)
2036 csrO = ev.y - scrollBar.top; 2044 csrO = ev.y - scrollBar.top;
2050 scr_page (DN, nrow - 1); 2058 scr_page (DN, nrow - 1);
2051# else 2059# else
2052 scr_page (DN, nrow / 4); 2060 scr_page (DN, nrow / 4);
2053# endif 2061# endif
2054 else 2062 else
2055 scrollBar.setMotion (); 2063 scrollBar.state = STATE_MOTION;
2056 } 2064 }
2057 else 2065 else
2058 { 2066 {
2059 scr_page ((ev.button == Button1 ? DN : UP), 2067 scr_page ((ev.button == Button1 ? DN : UP),
2060 (nrow 2068 (nrow
2077 2085
2078 csrO = 0; /* reset csr Offset */ 2086 csrO = 0; /* reset csr Offset */
2079 if (!bypass_keystate) 2087 if (!bypass_keystate)
2080 reportmode = !! (priv_modes & PrivMode_mouse_report); 2088 reportmode = !! (priv_modes & PrivMode_mouse_report);
2081 2089
2082 if (scrollbar_isUpDn ()) 2090 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
2083 { 2091 {
2084 scrollBar.setIdle (); 2092 scrollBar.state = STATE_IDLE;
2085 scrollbar_show (0); 2093 scrollbar_show (0);
2086 } 2094 }
2087 2095
2088#ifdef SELECTION_SCROLLING 2096#ifdef SELECTION_SCROLLING
2089 sel_scroll_ev.stop(); 2097 sel_scroll_ev.stop();
2170 2178
2171 if (!slip_wheel_ev.is_active ()) 2179 if (!slip_wheel_ev.is_active ())
2172 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2180 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2173 } 2181 }
2174 else 2182 else
2183# endif
2175 { 2184 {
2176# endif
2177 scr_page (v, i); 2185 scr_page (v, i);
2178 scrollbar_show (1); 2186 scrollbar_show (1);
2179# ifdef MOUSE_SLIP_WHEELING
2180 } 2187 }
2181# endif
2182 } 2188 }
2183 break; 2189 break;
2184#endif 2190#endif
2185 } 2191 }
2186 } 2192 }
2829 // versions. 2835 // versions.
2830 // 2836 //
2831 tt_printf ("\033[>%d;95;0c", 'U'); 2837 tt_printf ("\033[>%d;95;0c", 'U');
2832 } 2838 }
2833 break; 2839 break;
2840
2834 case '?': 2841 case '?':
2835 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2842 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
2836 process_terminal_mode (ch, priv, nargs, arg); 2843 process_terminal_mode (ch, priv, nargs, arg);
2837 break; 2844 break;
2838 } 2845 }
3354 *buf++ = '\0'; 3361 *buf++ = '\0';
3355 3362
3356 process_color_seq (op, color, name, resp); 3363 process_color_seq (op, color, name, resp);
3357 } 3364 }
3358 break; 3365 break;
3366 case Rxvt_restoreFG:
3359 case XTerm_Color00: 3367 case XTerm_Color00:
3360 process_color_seq (op, Color_fg, str, resp); 3368 process_color_seq (op, Color_fg, str, resp);
3361 break; 3369 break;
3370 case Rxvt_restoreBG:
3362 case XTerm_Color01: 3371 case XTerm_Color01:
3363 process_color_seq (op, Color_bg, str, resp); 3372 process_color_seq (op, Color_bg, str, resp);
3364 break; 3373 break;
3365#ifndef NO_CURSORCOLOR 3374#ifndef NO_CURSORCOLOR
3366 case XTerm_Color_cursor: 3375 case XTerm_Color_cursor:
3444 if (changed) 3453 if (changed)
3445 update_background (); 3454 update_background ();
3446 } 3455 }
3447 break; 3456 break;
3448#endif 3457#endif
3449
3450 case Rxvt_restoreFG:
3451 set_window_color (Color_fg, str);
3452 break;
3453 case Rxvt_restoreBG:
3454 set_window_color (Color_bg, str);
3455 break;
3456 3458
3457 case XTerm_logfile: 3459 case XTerm_logfile:
3458 // TODO, when secure mode? 3460 // TODO, when secure mode?
3459 break; 3461 break;
3460 3462
3615 // 1037 send DEL for keypad delete NYI 3617 // 1037 send DEL for keypad delete NYI
3616 { 1047, PrivMode_Screen }, 3618 { 1047, PrivMode_Screen },
3617 // 1048 save and restore cursor 3619 // 1048 save and restore cursor
3618 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ 3620 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
3619 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3621 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3622 { 2004, PrivMode_BracketPaste },
3620 }; 3623 };
3621 3624
3622 if (nargs == 0) 3625 if (nargs == 0)
3623 return; 3626 return;
3624 3627
3672 */ 3675 */
3673 PrivMode (1, PrivMode_vt52); 3676 PrivMode (1, PrivMode_vt52);
3674 break; 3677 break;
3675 case 3: /* 80/132 */ 3678 case 3: /* 80/132 */
3676 if (priv_modes & PrivMode_132OK) 3679 if (priv_modes & PrivMode_132OK)
3680 {
3681 scr_poweron ();
3677 set_widthheight (((state ? 132 : 80) * fwidth), height); 3682 set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight);
3683 }
3678 break; 3684 break;
3679 case 4: /* smooth scrolling */ 3685 case 4: /* smooth scrolling */
3680 set_option (Opt_jumpScroll, !state); 3686 set_option (Opt_jumpScroll, !state);
3681 break; 3687 break;
3682 case 5: /* reverse video */ 3688 case 5: /* reverse video */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines