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.517 by root, Wed Jun 6 08:59:13 2012 UTC vs.
Revision 1.539 by sf-exg, Tue Apr 16 08:44:45 2013 UTC

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>
7 * - original version 7 * - original version
8 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 8 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
9 * - extensive modifications 9 * - extensive modifications
10 * Copyright (c) 1995 Garrett D'Amore <garrett@netcom.com> 10 * Copyright (c) 1995 Garrett D'Amore <garrett@netcom.com>
11 * - vt100 printing 11 * - vt100 printing
12 * Copyright (c) 1995 Steven Hirsch <hirsch@emba.uvm.edu> 12 * Copyright (c) 1995 Steven Hirsch <hirsch@emba.uvm.edu>
13 * - X11 mouse report mode and support for 13 * - X11 mouse report mode and support for
14 * DEC "private mode" save/restore functions. 14 * DEC "private mode" save/restore functions.
20 * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es> 20 * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es>
21 * - modification and cleanups for Solaris 2.x 21 * - modification and cleanups for Solaris 2.x
22 * and Linux 1.2.x 22 * and Linux 1.2.x
23 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 23 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
24 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 24 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
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-2011 Marc Lehmann <schmorp@schmorp.de> 30 * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de>
510#endif 510#endif
511 max_it (lnsppg, 1); 511 max_it (lnsppg, 1);
512 512
513 if (keysym == XK_Prior) 513 if (keysym == XK_Prior)
514 { 514 {
515 scr_page (UP, lnsppg); 515 scr_page (lnsppg);
516 return; 516 return;
517 } 517 }
518 else if (keysym == XK_Next) 518 else if (keysym == XK_Next)
519 { 519 {
520 scr_page (DN, lnsppg); 520 scr_page (-lnsppg);
521 return; 521 return;
522 } 522 }
523 } 523 }
524#ifdef SCROLL_ON_UPDOWN_KEYS 524#ifdef SCROLL_ON_UPDOWN_KEYS
525 if (IS_SCROLL_MOD) 525 if (IS_SCROLL_MOD)
526 { 526 {
527 if (keysym == XK_Up) 527 if (keysym == XK_Up)
528 { 528 {
529 scr_page (UP, 1); 529 scr_page (1);
530 return; 530 return;
531 } 531 }
532 else if (keysym == XK_Down) 532 else if (keysym == XK_Down)
533 { 533 {
534 scr_page (DN, 1); 534 scr_page (-1);
535 return; 535 return;
536 } 536 }
537 } 537 }
538#endif 538#endif
539#ifdef SCROLL_ON_HOMEEND_KEYS 539#ifdef SCROLL_ON_HOMEEND_KEYS
540 if (IS_SCROLL_MOD) 540 if (IS_SCROLL_MOD)
541 { 541 {
542 if (keysym == XK_Home) 542 if (keysym == XK_Home)
543 { 543 {
544 scr_move_to (0, 1); 544 scr_changeview (top_row);
545 return; 545 return;
546 } 546 }
547 else if (keysym == XK_End) 547 else if (keysym == XK_End)
548 { 548 {
549 scr_move_to (1, 1); 549 scr_changeview (0);
550 return; 550 return;
551 } 551 }
552 } 552 }
553#endif 553#endif
554 } 554 }
941void 941void
942rxvt_term::flush () 942rxvt_term::flush ()
943{ 943{
944 flush_ev.stop (); 944 flush_ev.stop ();
945 945
946#ifdef HAVE_BG_PIXMAP 946#ifdef HAVE_IMG
947 if (bg_flags & BG_NEEDS_REFRESH) 947 if (bg_flags & BG_NEEDS_REFRESH)
948 { 948 {
949 bg_flags &= ~BG_NEEDS_REFRESH; 949 bg_flags &= ~BG_NEEDS_REFRESH;
950 scr_touch (false); 950 scr_touch (false);
951 } 951 }
1092 1092
1093#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1093#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1094void 1094void
1095rxvt_term::slip_wheel_cb (ev::timer &w, int revents) 1095rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1096{ 1096{
1097 if (scr_changeview (view_start - mouse_slip_wheel_speed)) 1097 if (scr_page (mouse_slip_wheel_speed))
1098 { 1098 {
1099 want_refresh = 1; 1099 want_refresh = 1;
1100 refresh_check (); 1100 refresh_check ();
1101 } 1101 }
1102 1102
1467 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1467 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1468 ; 1468 ;
1469 1469
1470 bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE); 1470 bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE);
1471 1471
1472 bool moved = false;
1472#ifdef HAVE_BG_PIXMAP 1473#ifdef HAVE_BG_PIXMAP
1473 if (bg_window_position_sensitive ()) 1474 if (bg_window_position_sensitive ())
1475 {
1474 want_position_change = true; 1476 want_position_change = true;
1477 if (bg_img == 0)
1478 moved = true;
1479 }
1475#endif 1480#endif
1476
1477 bool moved = false;
1478 1481
1479 if (want_position_change) 1482 if (want_position_change)
1480 { 1483 {
1481 int x, y; 1484 int x, y;
1482 1485
1488 else 1491 else
1489 get_window_origin (x, y); 1492 get_window_origin (x, y);
1490 1493
1491 if (x != parent_x || y != parent_y) 1494 if (x != parent_x || y != parent_y)
1492 { 1495 {
1493 HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END));
1494 parent_x = x; 1496 parent_x = x;
1495 parent_y = y; 1497 parent_y = y;
1498 HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END));
1499 moved = true;
1496 } 1500 }
1497
1498 if (bg_set_position (x, y)
1499 || !(bg_flags & BG_IS_VALID))
1500 moved = true;
1501 } 1501 }
1502 1502
1503 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1503 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1504 { 1504 {
1505 seen_resize = 1; 1505 seen_resize = 1;
1529 selection_send (ev.xselectionrequest); 1529 selection_send (ev.xselectionrequest);
1530 break; 1530 break;
1531 1531
1532 case MapNotify: 1532 case MapNotify:
1533#ifdef HAVE_BG_PIXMAP 1533#ifdef HAVE_BG_PIXMAP
1534 /* This is needed specifically to fix the case of no window manager or a 1534 // This is needed at startup for the case of no window manager
1535 * non-reparenting window manager. In those cases we never get first 1535 // or a non-reparenting window manager and also because we
1536 * ConfigureNotify. Also that speeds startup under normal WM, by taking 1536 // defer bg image updates if the window is not mapped. The
1537 * care of multiplicity of ConfigureNotify events arriving while WM does 1537 // short delay is to optimize for multiple ConfigureNotify
1538 * reparenting. 1538 // events at startup when the window manager reparents the
1539 * We should not render background immediately, as there could be several 1539 // window, so as to perform the computation after we have
1540 * ConfigureNotify's to follow. Lets take care of all of them in one scoop 1540 // received all of them.
1541 * by scheduling background redraw as soon as we can, but giving a short 1541 if (bg_img == 0)
1542 * bit of time for ConfigureNotifies to arrive.
1543 * We should render background PRIOR to drawing any text, but AFTER all
1544 * of ConfigureNotifys for the best results.
1545 */
1546 if (!(bg_flags & BG_IS_VALID))
1547 update_background_ev.start (0.025); 1542 update_background_ev.start (0.025);
1548#endif 1543#endif
1549 mapped = 1; 1544 mapped = 1;
1550#ifdef TEXT_BLINK 1545#ifdef TEXT_BLINK
1551 text_blink_ev.start (); 1546 text_blink_ev.start ();
1838 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); 1833 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1839 } 1834 }
1840#endif 1835#endif
1841} 1836}
1842 1837
1843#if ENABLE_TRANSPARENCY || ENABLE_PERL 1838#if BG_IMAGE_FROM_ROOT || ENABLE_PERL
1844void ecb_hot 1839void ecb_hot
1845rxvt_term::rootwin_cb (XEvent &ev) 1840rxvt_term::rootwin_cb (XEvent &ev)
1846{ 1841{
1847 make_current (); 1842 make_current ();
1848 1843
1858 * use the property to determine the pixmap. We use it later on. 1853 * use the property to determine the pixmap. We use it later on.
1859 */ 1854 */
1860 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] 1855 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1861 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) 1856 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1862 { 1857 {
1863# if ENABLE_TRANSPARENCY 1858#if BG_IMAGE_FROM_ROOT
1864 bg_set_root_pixmap (); 1859 if (option (Opt_transparent))
1860 {
1861 rxvt_img::new_from_root (this)->replace (root_img);
1865 update_background (); 1862 update_background ();
1863 }
1866#endif 1864#endif
1867#if ENABLE_PERL
1868 HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END)); 1865 HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END));
1869#endif
1870 } 1866 }
1871 1867
1872 break; 1868 break;
1873 } 1869 }
1874 1870
2199 2195
2200#ifdef MOUSE_WHEEL 2196#ifdef MOUSE_WHEEL
2201 case Button4: 2197 case Button4:
2202 case Button5: 2198 case Button5:
2203 { 2199 {
2204 int i; 2200 int lines;
2205 page_dirn v; 2201 page_dirn dirn;
2206 2202
2207 v = ev.button == Button4 ? UP : DN; 2203 dirn = ev.button == Button4 ? UP : DN;
2208 2204
2209 if (ev.state & ShiftMask) 2205 if (ev.state & ShiftMask)
2210 i = 1; 2206 lines = 1;
2211 else if (option (Opt_mouseWheelScrollPage)) 2207 else if (option (Opt_mouseWheelScrollPage))
2212 i = nrow - 1; 2208 lines = nrow - 1;
2213 else 2209 else
2214 i = 5; 2210 lines = 5;
2215 2211
2216# ifdef MOUSE_SLIP_WHEELING 2212# ifdef MOUSE_SLIP_WHEELING
2217 if (ev.state & ControlMask) 2213 if (ev.state & ControlMask)
2218 { 2214 {
2219 mouse_slip_wheel_speed += v ? -1 : 1; 2215 mouse_slip_wheel_speed += dirn;
2220 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2216 clamp_it (mouse_slip_wheel_speed, -nrow, nrow);
2221 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2222 2217
2223 if (!slip_wheel_ev.is_active ()) 2218 if (!slip_wheel_ev.is_active ())
2224 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2219 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2225 } 2220 }
2226 else 2221 else
2227# endif 2222# endif
2228 { 2223 {
2229 scr_page (v, i); 2224 scr_page (dirn, lines);
2230 scrollBar.show (1); 2225 scrollBar.show (1);
2231 } 2226 }
2232 } 2227 }
2233 break; 2228 break;
2234#endif 2229#endif
2387 } 2382 }
2388 2383
2389 if (len == (size_t)-1) 2384 if (len == (size_t)-1)
2390 { 2385 {
2391 mbstate.reset (); // reset now undefined conversion state 2386 mbstate.reset (); // reset now undefined conversion state
2387 // a -1 might indicate that a previous incomplete char is invalid (previous return -2)
2388 // in which case we "erroneously" return the next byte which might be valid.
2392 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2389 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2393 } 2390 }
2394 2391
2395 // assume wchar == unicode 2392 // assume wchar == unicode
2396 cmdbuf_ptr += len; 2393 cmdbuf_ptr += len;
2801 }; 2798 };
2802 2799
2803void ecb_hot 2800void ecb_hot
2804rxvt_term::process_csi_seq () 2801rxvt_term::process_csi_seq ()
2805{ 2802{
2806 unicode_t ch, priv, i; 2803 unicode_t ch, priv, prev_ch, i;
2807 unsigned int nargs, p; 2804 unsigned int nargs, p;
2808 int n, ndef; 2805 int n, ndef;
2809 int arg[ESC_ARGS] = { }; 2806 int arg[ESC_ARGS] = { };
2810 2807
2811 nargs = 0; 2808 nargs = 0;
2817 /* '<' '=' '>' '?' '!' */ 2814 /* '<' '=' '>' '?' '!' */
2818 priv = ch; 2815 priv = ch;
2819 ch = cmd_getc (); 2816 ch = cmd_getc ();
2820 } 2817 }
2821 2818
2819 prev_ch = 0;
2822 /* read any numerical arguments */ 2820 /* read any numerical arguments */
2823 for (n = -1; ch < CSI_ICH; ) 2821 for (n = -1; ch < CSI_ICH; )
2824 { 2822 {
2825 if (isdigit (ch)) 2823 if (isdigit (ch))
2826 { 2824 {
2836 n = -1; 2834 n = -1;
2837 } 2835 }
2838 else if (IS_CONTROL (ch)) 2836 else if (IS_CONTROL (ch))
2839 process_nonprinting (ch); 2837 process_nonprinting (ch);
2840 2838
2839 prev_ch = ch;
2841 ch = cmd_getc (); 2840 ch = cmd_getc ();
2842 } 2841 }
2843 2842
2844 if (ch > CSI_7F) 2843 if (ch > CSI_7F)
2845 return; 2844 return;
3079 scr_insert_mode (1); 3078 scr_insert_mode (1);
3080 else if (arg[0] == 20) 3079 else if (arg[0] == 20)
3081 priv_modes |= PrivMode_LFNL; 3080 priv_modes |= PrivMode_LFNL;
3082 break; 3081 break;
3083 3082
3083 case CSI_71: // DESCUSR: set cursor style
3084 if (prev_ch == ' ')
3085 set_cursor_style (arg[0]);
3086 break;
3087
3084 /* 3088 /*
3085 * PRIVATE USE beyond this point. All CSI_7? sequences here 3089 * PRIVATE USE beyond this point. All CSI_7? sequences here
3086 */ 3090 */
3087 case CSI_72: /* DECSTBM: set top and bottom margins */ 3091 case CSI_72: /* DECSTBM: set top and bottom margins */
3088 if (nargs == 1) 3092 if (nargs == 1)
3451 break; 3455 break;
3452#endif 3456#endif
3453 case URxvt_Color_border: 3457 case URxvt_Color_border:
3454 process_color_seq (op, Color_border, str, resp); 3458 process_color_seq (op, Color_border, str, resp);
3455 break; 3459 break;
3456#if ENABLE_TRANSPARENCY 3460
3461#if BG_IMAGE_FROM_ROOT
3457 case URxvt_Color_tint: 3462 case URxvt_Color_tint:
3458 process_color_seq (op, Color_tint, str, resp); 3463 process_color_seq (op, Color_tint, str, resp);
3459 { 3464 {
3460 bool changed = false; 3465 bool changed = false;
3461 3466
3472#if BG_IMAGE_FROM_FILE 3477#if BG_IMAGE_FROM_FILE
3473 case Rxvt_Pixmap: 3478 case Rxvt_Pixmap:
3474 if (!strcmp (str, "?")) 3479 if (!strcmp (str, "?"))
3475 { 3480 {
3476 char str[256]; 3481 char str[256];
3477 int h_scale = 0, v_scale = 0;
3478 int h_align = 0, v_align = 0;
3479 if (image_vec.size () > 0)
3480 {
3481 h_scale = image_vec[0].h_scale; 3482 int h_scale = fimage.h_scale;
3482 v_scale = image_vec[0].v_scale; 3483 int v_scale = fimage.v_scale;
3483 h_align = image_vec[0].h_align; 3484 int h_align = fimage.h_align;
3484 v_align = image_vec[0].v_align; 3485 int v_align = fimage.v_align;
3485 }
3486 3486
3487 sprintf (str, "[%dx%d+%d+%d]", 3487 sprintf (str, "[%dx%d+%d+%d]",
3488 h_scale, v_scale, 3488 h_scale, v_scale,
3489 h_align, v_align); 3489 h_align, v_align);
3490 process_xterm_seq (XTerm_title, str, CHAR_ST); 3490 process_xterm_seq (XTerm_title, str, CHAR_ST);
3493 { 3493 {
3494 bool changed = false; 3494 bool changed = false;
3495 3495
3496 if (*str != ';') 3496 if (*str != ';')
3497 { 3497 {
3498 if (image_vec.size () > 0)
3499 changed = image_vec[0].set_file_geometry (str);
3500 else 3498 try
3501 { 3499 {
3502 rxvt_image *image = new_image ();
3503 if (!image->set_file_geometry (str)) 3500 fimage.set_file_geometry (this, str);
3504 image_vec.pop_back ();
3505 else
3506 changed = true; 3501 changed = true;
3502 }
3503 catch (const class rxvt_failure_exception &e)
3504 {
3507 } 3505 }
3508 } 3506 }
3509 else 3507 else
3510 { 3508 {
3511 str++; 3509 str++;
3512 if (image_vec.size () > 0)
3513 changed = image_vec[0].set_geometry (str, true); 3510 if (fimage.set_geometry (str, true))
3511 changed = true;
3514 } 3512 }
3515 3513
3516 if (changed) 3514 if (changed)
3517 { 3515 {
3518 if (bg_window_position_sensitive ()) 3516 if (bg_window_position_sensitive ())
3519 { 3517 {
3520 int x, y; 3518 int x, y;
3521 get_window_origin (x, y); 3519 get_window_origin (x, y);
3522 bg_set_position (x, y); 3520 parent_x = x;
3521 parent_y = y;
3523 } 3522 }
3524 update_background (); 3523 update_background ();
3525 } 3524 }
3526 } 3525 }
3527 break; 3526 break;
3998 break; 3997 break;
3999#endif 3998#endif
4000 } 3999 }
4001 } 4000 }
4002} 4001}
4002
4003void
4004rxvt_term::set_cursor_style (int style)
4005{
4006 if (!IN_RANGE_INC (style, 0, 4))
4007 return;
4008
4009 set_option (Opt_cursorUnderline, style >= 3);
4010
4011#ifdef CURSOR_BLINK
4012 set_option (Opt_cursorBlink, !style || (style & 1));
4013 cursor_blink_reset ();
4014#endif
4015
4016 want_refresh = 1;
4017}
4003/*}}} */ 4018/*}}} */
4004 4019
4005/* ------------------------------------------------------------------------- */ 4020/* ------------------------------------------------------------------------- */
4006 4021
4007/* 4022/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines