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.528 by sf-exg, Sat Dec 29 15:59:51 2012 UTC vs.
Revision 1.543 by sf-exg, Sat Apr 26 14:07:36 2014 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-2011 Marc Lehmann <schmorp@schmorp.de> 30 * Copyright (c) 2003-2014 Marc Lehmann <schmorp@schmorp.de>
31 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> 31 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it>
32 * 32 *
33 * This program is free software; you can redistribute it and/or modify 33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by 34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or 35 * the Free Software Foundation; either version 2 of the License, or
400 break; 400 break;
401 } 401 }
402 return param; 402 return param;
403} 403}
404 404
405static inline wchar_t *
406rxvt_wcsdup (const wchar_t *str, int len)
407{
408 wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t));
409 memcpy (r, str, len * sizeof (wchar_t));
410 r[len] = 0;
411 return r;
412}
413
405void ecb_cold 414void ecb_cold
406rxvt_term::key_press (XKeyEvent &ev) 415rxvt_term::key_press (XKeyEvent &ev)
407{ 416{
408 int ctrl, meta, shft, len; 417 int ctrl, meta, shft, len;
409 KeySym keysym; 418 KeySym keysym;
510#endif 519#endif
511 max_it (lnsppg, 1); 520 max_it (lnsppg, 1);
512 521
513 if (keysym == XK_Prior) 522 if (keysym == XK_Prior)
514 { 523 {
515 scr_page (UP, lnsppg); 524 scr_page (lnsppg);
516 return; 525 return;
517 } 526 }
518 else if (keysym == XK_Next) 527 else if (keysym == XK_Next)
519 { 528 {
520 scr_page (DN, lnsppg); 529 scr_page (-lnsppg);
521 return; 530 return;
522 } 531 }
523 } 532 }
524#ifdef SCROLL_ON_UPDOWN_KEYS 533#ifdef SCROLL_ON_UPDOWN_KEYS
525 if (IS_SCROLL_MOD) 534 if (IS_SCROLL_MOD)
526 { 535 {
527 if (keysym == XK_Up) 536 if (keysym == XK_Up)
528 { 537 {
529 scr_page (UP, 1); 538 scr_page (1);
530 return; 539 return;
531 } 540 }
532 else if (keysym == XK_Down) 541 else if (keysym == XK_Down)
533 { 542 {
534 scr_page (DN, 1); 543 scr_page (-1);
535 return; 544 return;
536 } 545 }
537 } 546 }
538#endif 547#endif
539#ifdef SCROLL_ON_HOMEEND_KEYS 548#ifdef SCROLL_ON_HOMEEND_KEYS
540 if (IS_SCROLL_MOD) 549 if (IS_SCROLL_MOD)
541 { 550 {
542 if (keysym == XK_Home) 551 if (keysym == XK_Home)
543 { 552 {
544 scr_move_to (0, 1); 553 scr_changeview (top_row);
545 return; 554 return;
546 } 555 }
547 else if (keysym == XK_End) 556 else if (keysym == XK_End)
548 { 557 {
549 scr_move_to (1, 1); 558 scr_changeview (0);
550 return; 559 return;
551 } 560 }
552 } 561 }
553#endif 562#endif
554 } 563 }
576 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ 585 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */
577 return; 586 return;
578#endif 587#endif
579 } 588 }
580 } 589 }
590 }
591
592 if (ctrl && meta && (keysym == XK_c || keysym == XK_v))
593 {
594 if (keysym == XK_v)
595 selection_request (ev.time, Sel_Clipboard);
596 else if (selection.len > 0)
597 {
598 free (selection.clip_text);
599 selection.clip_text = rxvt_wcsdup (selection.text, selection.len);
600 selection.clip_len = selection.len;
601 selection_grab (CurrentTime, true);
602 }
603
604 return;
581 } 605 }
582 606
583#if ENABLE_FRILLS || ISO_14755 607#if ENABLE_FRILLS || ISO_14755
584 // ISO 14755 support 608 // ISO 14755 support
585 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51)) 609 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51))
1077 1101
1078#ifdef SELECTION_SCROLLING 1102#ifdef SELECTION_SCROLLING
1079void 1103void
1080rxvt_term::sel_scroll_cb (ev::timer &w, int revents) 1104rxvt_term::sel_scroll_cb (ev::timer &w, int revents)
1081{ 1105{
1082 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1106 if (scr_page (scroll_selection_lines))
1083 { 1107 {
1084 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1108 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1085 want_refresh = 1; 1109 want_refresh = 1;
1086 refresh_check (); 1110 refresh_check ();
1087 } 1111 }
1092 1116
1093#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1117#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1094void 1118void
1095rxvt_term::slip_wheel_cb (ev::timer &w, int revents) 1119rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1096{ 1120{
1097 if (scr_changeview (view_start - mouse_slip_wheel_speed)) 1121 if (scr_page (mouse_slip_wheel_speed))
1098 { 1122 {
1099 want_refresh = 1; 1123 want_refresh = 1;
1100 refresh_check (); 1124 refresh_check ();
1101 } 1125 }
1102 1126
1472 bool moved = false; 1496 bool moved = false;
1473#ifdef HAVE_BG_PIXMAP 1497#ifdef HAVE_BG_PIXMAP
1474 if (bg_window_position_sensitive ()) 1498 if (bg_window_position_sensitive ())
1475 { 1499 {
1476 want_position_change = true; 1500 want_position_change = true;
1477 if (!(bg_flags & BG_IS_VALID)) 1501 if (bg_img == 0)
1478 moved = true; 1502 moved = true;
1479 } 1503 }
1480#endif 1504#endif
1481 1505
1482 if (want_position_change) 1506 if (want_position_change)
1529 selection_send (ev.xselectionrequest); 1553 selection_send (ev.xselectionrequest);
1530 break; 1554 break;
1531 1555
1532 case MapNotify: 1556 case MapNotify:
1533#ifdef HAVE_BG_PIXMAP 1557#ifdef HAVE_BG_PIXMAP
1534 /* This is needed specifically to fix the case of no window manager or a 1558 // This is needed at startup for the case of no window manager
1535 * non-reparenting window manager. In those cases we never get first 1559 // or a non-reparenting window manager and also because we
1536 * ConfigureNotify. Also that speeds startup under normal WM, by taking 1560 // defer bg image updates if the window is not mapped. The
1537 * care of multiplicity of ConfigureNotify events arriving while WM does 1561 // short delay is to optimize for multiple ConfigureNotify
1538 * reparenting. 1562 // events at startup when the window manager reparents the
1539 * We should not render background immediately, as there could be several 1563 // 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 1564 // received all of them.
1541 * by scheduling background redraw as soon as we can, but giving a short 1565 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); 1566 update_background_ev.start (0.025);
1548#endif 1567#endif
1549 mapped = 1; 1568 mapped = 1;
1550#ifdef TEXT_BLINK 1569#ifdef TEXT_BLINK
1551 text_blink_ev.start (); 1570 text_blink_ev.start ();
1643 1662
1644#ifdef SELECTION_SCROLLING 1663#ifdef SELECTION_SCROLLING
1645 if (ev.xbutton.y < int_bwidth 1664 if (ev.xbutton.y < int_bwidth
1646 || Pixel2Row (ev.xbutton.y) > (nrow-1)) 1665 || Pixel2Row (ev.xbutton.y) > (nrow-1))
1647 { 1666 {
1667 page_dirn scroll_selection_dir;
1648 int dist; 1668 int dist;
1649 1669
1650 /* don't clobber the current delay if we are 1670 /* don't clobber the current delay if we are
1651 * already in the middle of scrolling. 1671 * already in the middle of scrolling.
1652 */ 1672 */
1675 scroll_selection_lines = Pixel2Height (dist) 1695 scroll_selection_lines = Pixel2Height (dist)
1676 / SELECTION_SCROLL_LINE_SPEEDUP 1696 / SELECTION_SCROLL_LINE_SPEEDUP
1677 + 1; 1697 + 1;
1678 min_it (scroll_selection_lines, 1698 min_it (scroll_selection_lines,
1679 SELECTION_SCROLL_MAX_LINES); 1699 SELECTION_SCROLL_MAX_LINES);
1700 scroll_selection_lines *= scroll_selection_dir;
1680 } 1701 }
1681 else 1702 else
1682 { 1703 {
1683 /* we are within the text window, so we 1704 /* we are within the text window, so we
1684 * shouldn't be scrolling 1705 * shouldn't be scrolling
1859 */ 1880 */
1860 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] 1881 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1861 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) 1882 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1862 { 1883 {
1863#if BG_IMAGE_FROM_ROOT 1884#if BG_IMAGE_FROM_ROOT
1864 bg_set_root_pixmap (); 1885 if (option (Opt_transparent))
1886 {
1887 rxvt_img::new_from_root (this)->replace (root_img);
1865 update_background (); 1888 update_background ();
1889 }
1866#endif 1890#endif
1867#if ENABLE_PERL
1868 HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END)); 1891 HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END));
1869#endif
1870 } 1892 }
1871 1893
1872 break; 1894 break;
1873 } 1895 }
1874 1896
2199 2221
2200#ifdef MOUSE_WHEEL 2222#ifdef MOUSE_WHEEL
2201 case Button4: 2223 case Button4:
2202 case Button5: 2224 case Button5:
2203 { 2225 {
2204 int i; 2226 int lines;
2205 page_dirn v; 2227 page_dirn dirn;
2206 2228
2207 v = ev.button == Button4 ? UP : DN; 2229 dirn = ev.button == Button4 ? UP : DN;
2208 2230
2209 if (ev.state & ShiftMask) 2231 if (ev.state & ShiftMask)
2210 i = 1; 2232 lines = 1;
2211 else if (option (Opt_mouseWheelScrollPage)) 2233 else if (option (Opt_mouseWheelScrollPage))
2212 i = nrow - 1; 2234 lines = nrow - 1;
2213 else 2235 else
2214 i = 5; 2236 lines = 5;
2215 2237
2216# ifdef MOUSE_SLIP_WHEELING 2238# ifdef MOUSE_SLIP_WHEELING
2217 if (ev.state & ControlMask) 2239 if (ev.state & ControlMask)
2218 { 2240 {
2219 mouse_slip_wheel_speed += v ? -1 : 1; 2241 mouse_slip_wheel_speed += dirn;
2220 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2242 clamp_it (mouse_slip_wheel_speed, -nrow, nrow);
2221 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2222 2243
2223 if (!slip_wheel_ev.is_active ()) 2244 if (!slip_wheel_ev.is_active ())
2224 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2245 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2225 } 2246 }
2226 else 2247 else
2227# endif 2248# endif
2228 { 2249 {
2229 scr_page (v, i); 2250 scr_page (dirn, lines);
2230 scrollBar.show (1); 2251 scrollBar.show (1);
2231 } 2252 }
2232 } 2253 }
2233 break; 2254 break;
2234#endif 2255#endif
2803 }; 2824 };
2804 2825
2805void ecb_hot 2826void ecb_hot
2806rxvt_term::process_csi_seq () 2827rxvt_term::process_csi_seq ()
2807{ 2828{
2808 unicode_t ch, priv, i; 2829 unicode_t ch, priv, prev_ch, i;
2809 unsigned int nargs, p; 2830 unsigned int nargs, p;
2810 int n, ndef; 2831 int n, ndef;
2811 int arg[ESC_ARGS] = { }; 2832 int arg[ESC_ARGS] = { };
2812 2833
2813 nargs = 0; 2834 nargs = 0;
2819 /* '<' '=' '>' '?' '!' */ 2840 /* '<' '=' '>' '?' '!' */
2820 priv = ch; 2841 priv = ch;
2821 ch = cmd_getc (); 2842 ch = cmd_getc ();
2822 } 2843 }
2823 2844
2845 prev_ch = 0;
2824 /* read any numerical arguments */ 2846 /* read any numerical arguments */
2825 for (n = -1; ch < CSI_ICH; ) 2847 for (n = -1; ch < CSI_ICH; )
2826 { 2848 {
2827 if (isdigit (ch)) 2849 if (isdigit (ch))
2828 { 2850 {
2838 n = -1; 2860 n = -1;
2839 } 2861 }
2840 else if (IS_CONTROL (ch)) 2862 else if (IS_CONTROL (ch))
2841 process_nonprinting (ch); 2863 process_nonprinting (ch);
2842 2864
2865 prev_ch = ch;
2843 ch = cmd_getc (); 2866 ch = cmd_getc ();
2844 } 2867 }
2845 2868
2846 if (ch > CSI_7F) 2869 if (ch > CSI_7F)
2847 return; 2870 return;
3081 scr_insert_mode (1); 3104 scr_insert_mode (1);
3082 else if (arg[0] == 20) 3105 else if (arg[0] == 20)
3083 priv_modes |= PrivMode_LFNL; 3106 priv_modes |= PrivMode_LFNL;
3084 break; 3107 break;
3085 3108
3109 case CSI_71: // DESCUSR: set cursor style
3110 if (prev_ch == ' ')
3111 set_cursor_style (arg[0]);
3112 break;
3113
3086 /* 3114 /*
3087 * PRIVATE USE beyond this point. All CSI_7? sequences here 3115 * PRIVATE USE beyond this point. All CSI_7? sequences here
3088 */ 3116 */
3089 case CSI_72: /* DECSTBM: set top and bottom margins */ 3117 case CSI_72: /* DECSTBM: set top and bottom margins */
3090 if (nargs == 1) 3118 if (nargs == 1)
3223rxvt_term::get_to_st (unicode_t &ends_how) 3251rxvt_term::get_to_st (unicode_t &ends_how)
3224{ 3252{
3225 unicode_t ch; 3253 unicode_t ch;
3226 bool seen_esc = false; 3254 bool seen_esc = false;
3227 unsigned int n = 0; 3255 unsigned int n = 0;
3228 wchar_t string[STRING_MAX]; 3256 wchar_t string[CBUFSIZ];
3229 3257
3230 while ((ch = cmd_getc ()) != NOCHAR) 3258 while ((ch = cmd_getc ()) != NOCHAR)
3231 { 3259 {
3232 if (seen_esc) 3260 if (seen_esc)
3233 { 3261 {
3248 else if (ch < 0x20) 3276 else if (ch < 0x20)
3249 return NULL; /* other control character - exit */ 3277 return NULL; /* other control character - exit */
3250 3278
3251 seen_esc = false; 3279 seen_esc = false;
3252 3280
3253 if (n >= STRING_MAX - 1) 3281 if (n >= sizeof (string) - 1)
3254 // stop at some sane length 3282 // stop at some sane length
3255 return NULL; 3283 return NULL;
3256 3284
3257 string[n++] = ch; 3285 string[n++] = ch;
3258 } 3286 }
3375 &nitems, &bytes_after, &value) == Success 3403 &nitems, &bytes_after, &value) == Success
3376 && actual_type != None 3404 && actual_type != None
3377 && actual_format == 8) 3405 && actual_format == 8)
3378 str = (const char *)(value); 3406 str = (const char *)(value);
3379 3407
3380 tt_printf ("\033]%d;%s%c", op, str, resp); 3408 tt_printf ("\033]%d;%s%c", op, option (Opt_insecure) ? str : "", resp);
3381 3409
3382 XFree (value); 3410 XFree (value);
3383 } 3411 }
3384 else 3412 else
3385 { 3413 {
3995 break; 4023 break;
3996#endif 4024#endif
3997 } 4025 }
3998 } 4026 }
3999} 4027}
4028
4029void
4030rxvt_term::set_cursor_style (int style)
4031{
4032 if (!IN_RANGE_INC (style, 0, 4))
4033 return;
4034
4035 set_option (Opt_cursorUnderline, style >= 3);
4036
4037#ifdef CURSOR_BLINK
4038 set_option (Opt_cursorBlink, !style || (style & 1));
4039 cursor_blink_reset ();
4040#endif
4041
4042 want_refresh = 1;
4043}
4000/*}}} */ 4044/*}}} */
4001 4045
4002/* ------------------------------------------------------------------------- */ 4046/* ------------------------------------------------------------------------- */
4003 4047
4004/* 4048/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines