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.396 by ayin, Sun Jan 20 14:12:39 2008 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
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
1553 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) 1557 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1554 ; 1558 ;
1555 1559
1556 if (scrollBar.state && ev.xany.window == scrollBar.win) 1560 if (scrollBar.state && ev.xany.window == scrollBar.win)
1557 { 1561 {
1558 scrollBar.setIdle (); 1562 scrollBar.state = STATE_IDLE;
1559 scrollbar_show (0); 1563 scrollbar_show (0);
1560 } 1564 }
1561 } 1565 }
1562 break; 1566 break;
1563 1567
1651#ifdef MOUSE_THRESHOLD 1655#ifdef MOUSE_THRESHOLD
1652 } 1656 }
1653#endif 1657#endif
1654 } 1658 }
1655 } 1659 }
1656 else if (scrollbar_isMotion () && ev.xany.window == scrollBar.win) 1660 else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win)
1657 { 1661 {
1658 while (XCheckTypedWindowEvent (dpy, scrollBar.win, 1662 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1659 MotionNotify, &ev)) 1663 MotionNotify, &ev))
1660 ; 1664 ;
1661 1665
1947 /* 1951 /*
1948 * Scrollbar window processing of button press 1952 * Scrollbar window processing of button press
1949 */ 1953 */
1950 if (scrollBar.state && ev.window == scrollBar.win) 1954 if (scrollBar.state && ev.window == scrollBar.win)
1951 { 1955 {
1952 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;
1953 /* 1964 /*
1954 * Rxvt-style scrollbar: 1965 * Rxvt-style scrollbar:
1955 * move up if mouse is above slider 1966 * move up if mouse is above slider
1956 * move dn if mouse is below slider 1967 * move dn if mouse is below slider
1957 * 1968 *
1966 /* 1977 /*
1967 * Mouse report disabled scrollbar: 1978 * Mouse report disabled scrollbar:
1968 * arrow buttons - send up/down 1979 * arrow buttons - send up/down
1969 * click on scrollbar - send pageup/down 1980 * click on scrollbar - send pageup/down
1970 */ 1981 */
1971 if ((scrollBar.style == R_SB_NEXT 1982 if (direction == UP)
1972 && scrollbarnext_upButton (ev.y))
1973 || (scrollBar.style == R_SB_RXVT
1974 && scrollbarrxvt_upButton (ev.y)))
1975 tt_printf ("\033[A"); 1983 tt_printf ("\033[A");
1976 else if ((scrollBar.style == R_SB_NEXT 1984 else if (direction == DN)
1977 && scrollbarnext_dnButton (ev.y))
1978 || (scrollBar.style == R_SB_RXVT
1979 && scrollbarrxvt_dnButton (ev.y)))
1980 tt_printf ("\033[B"); 1985 tt_printf ("\033[B");
1981 else 1986 else
1982 switch (ev.button) 1987 switch (ev.button)
1983 { 1988 {
1984 case Button2: 1989 case Button2:
1992 break; 1997 break;
1993 } 1998 }
1994 } 1999 }
1995 else 2000 else
1996#endif /* NO_SCROLLBAR_REPORT */ 2001#endif /* NO_SCROLLBAR_REPORT */
1997
1998 {
1999 char upordown = 0;
2000
2001 if (scrollBar.style == R_SB_NEXT)
2002 { 2002 {
2003 if (scrollbarnext_upButton (ev.y)) 2003 if (direction != NO_DIR)
2004 upordown = -1; /* up */
2005 else if (scrollbarnext_dnButton (ev.y))
2006 upordown = 1; /* down */
2007 }
2008 else if (scrollBar.style == R_SB_RXVT)
2009 {
2010 if (scrollbarrxvt_upButton (ev.y))
2011 upordown = -1; /* up */
2012 else if (scrollbarrxvt_dnButton (ev.y))
2013 upordown = 1; /* down */
2014 }
2015
2016 if (upordown)
2017 { 2004 {
2018#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 2005#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2019 if (!cont_scroll_ev.is_active ()) 2006 if (!cont_scroll_ev.is_active ())
2020 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2007 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2021#endif 2008#endif
2022 if (scr_page (upordown < 0 ? UP : DN, 1)) 2009 if (scr_page (direction, 1))
2023 { 2010 {
2024 if (upordown < 0) 2011 if (direction == UP)
2025 scrollBar.setUp (); 2012 scrollBar.state = STATE_UP;
2026 else 2013 else
2027 scrollBar.setDn (); 2014 scrollBar.state = STATE_DOWN;
2028 } 2015 }
2029 } 2016 }
2030 else 2017 else
2031 switch (ev.button) 2018 switch (ev.button)
2032 { 2019 {
2047 if (scrollBar.style == R_SB_XTERM 2034 if (scrollBar.style == R_SB_XTERM
2048 || scrollbar_above_slider (ev.y) 2035 || scrollbar_above_slider (ev.y)
2049 || scrollbar_below_slider (ev.y)) 2036 || scrollbar_below_slider (ev.y))
2050 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); 2037 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ());
2051 2038
2052 scrollBar.setMotion (); 2039 scrollBar.state = STATE_MOTION;
2053 break; 2040 break;
2054 2041
2055 case Button1: 2042 case Button1:
2056 if (scrollBar.align == R_SB_ALIGN_CENTRE) 2043 if (scrollBar.align == R_SB_ALIGN_CENTRE)
2057 csrO = ev.y - scrollBar.top; 2044 csrO = ev.y - scrollBar.top;
2071 scr_page (DN, nrow - 1); 2058 scr_page (DN, nrow - 1);
2072# else 2059# else
2073 scr_page (DN, nrow / 4); 2060 scr_page (DN, nrow / 4);
2074# endif 2061# endif
2075 else 2062 else
2076 scrollBar.setMotion (); 2063 scrollBar.state = STATE_MOTION;
2077 } 2064 }
2078 else 2065 else
2079 { 2066 {
2080 scr_page ((ev.button == Button1 ? DN : UP), 2067 scr_page ((ev.button == Button1 ? DN : UP),
2081 (nrow 2068 (nrow
2098 2085
2099 csrO = 0; /* reset csr Offset */ 2086 csrO = 0; /* reset csr Offset */
2100 if (!bypass_keystate) 2087 if (!bypass_keystate)
2101 reportmode = !! (priv_modes & PrivMode_mouse_report); 2088 reportmode = !! (priv_modes & PrivMode_mouse_report);
2102 2089
2103 if (scrollbar_isUpDn ()) 2090 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
2104 { 2091 {
2105 scrollBar.setIdle (); 2092 scrollBar.state = STATE_IDLE;
2106 scrollbar_show (0); 2093 scrollbar_show (0);
2107 } 2094 }
2108 2095
2109#ifdef SELECTION_SCROLLING 2096#ifdef SELECTION_SCROLLING
2110 sel_scroll_ev.stop(); 2097 sel_scroll_ev.stop();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines