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.533 by sf-exg, Fri Feb 1 11:26:40 2013 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
1638 1662
1639#ifdef SELECTION_SCROLLING 1663#ifdef SELECTION_SCROLLING
1640 if (ev.xbutton.y < int_bwidth 1664 if (ev.xbutton.y < int_bwidth
1641 || Pixel2Row (ev.xbutton.y) > (nrow-1)) 1665 || Pixel2Row (ev.xbutton.y) > (nrow-1))
1642 { 1666 {
1667 page_dirn scroll_selection_dir;
1643 int dist; 1668 int dist;
1644 1669
1645 /* don't clobber the current delay if we are 1670 /* don't clobber the current delay if we are
1646 * already in the middle of scrolling. 1671 * already in the middle of scrolling.
1647 */ 1672 */
1670 scroll_selection_lines = Pixel2Height (dist) 1695 scroll_selection_lines = Pixel2Height (dist)
1671 / SELECTION_SCROLL_LINE_SPEEDUP 1696 / SELECTION_SCROLL_LINE_SPEEDUP
1672 + 1; 1697 + 1;
1673 min_it (scroll_selection_lines, 1698 min_it (scroll_selection_lines,
1674 SELECTION_SCROLL_MAX_LINES); 1699 SELECTION_SCROLL_MAX_LINES);
1700 scroll_selection_lines *= scroll_selection_dir;
1675 } 1701 }
1676 else 1702 else
1677 { 1703 {
1678 /* we are within the text window, so we 1704 /* we are within the text window, so we
1679 * shouldn't be scrolling 1705 * shouldn't be scrolling
2195 2221
2196#ifdef MOUSE_WHEEL 2222#ifdef MOUSE_WHEEL
2197 case Button4: 2223 case Button4:
2198 case Button5: 2224 case Button5:
2199 { 2225 {
2200 int i; 2226 int lines;
2201 page_dirn v; 2227 page_dirn dirn;
2202 2228
2203 v = ev.button == Button4 ? UP : DN; 2229 dirn = ev.button == Button4 ? UP : DN;
2204 2230
2205 if (ev.state & ShiftMask) 2231 if (ev.state & ShiftMask)
2206 i = 1; 2232 lines = 1;
2207 else if (option (Opt_mouseWheelScrollPage)) 2233 else if (option (Opt_mouseWheelScrollPage))
2208 i = nrow - 1; 2234 lines = nrow - 1;
2209 else 2235 else
2210 i = 5; 2236 lines = 5;
2211 2237
2212# ifdef MOUSE_SLIP_WHEELING 2238# ifdef MOUSE_SLIP_WHEELING
2213 if (ev.state & ControlMask) 2239 if (ev.state & ControlMask)
2214 { 2240 {
2215 mouse_slip_wheel_speed += v ? -1 : 1; 2241 mouse_slip_wheel_speed += dirn;
2216 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2242 clamp_it (mouse_slip_wheel_speed, -nrow, nrow);
2217 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2218 2243
2219 if (!slip_wheel_ev.is_active ()) 2244 if (!slip_wheel_ev.is_active ())
2220 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); 2245 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2221 } 2246 }
2222 else 2247 else
2223# endif 2248# endif
2224 { 2249 {
2225 scr_page (v, i); 2250 scr_page (dirn, lines);
2226 scrollBar.show (1); 2251 scrollBar.show (1);
2227 } 2252 }
2228 } 2253 }
2229 break; 2254 break;
2230#endif 2255#endif
2799 }; 2824 };
2800 2825
2801void ecb_hot 2826void ecb_hot
2802rxvt_term::process_csi_seq () 2827rxvt_term::process_csi_seq ()
2803{ 2828{
2804 unicode_t ch, priv, i; 2829 unicode_t ch, priv, prev_ch, i;
2805 unsigned int nargs, p; 2830 unsigned int nargs, p;
2806 int n, ndef; 2831 int n, ndef;
2807 int arg[ESC_ARGS] = { }; 2832 int arg[ESC_ARGS] = { };
2808 2833
2809 nargs = 0; 2834 nargs = 0;
2815 /* '<' '=' '>' '?' '!' */ 2840 /* '<' '=' '>' '?' '!' */
2816 priv = ch; 2841 priv = ch;
2817 ch = cmd_getc (); 2842 ch = cmd_getc ();
2818 } 2843 }
2819 2844
2845 prev_ch = 0;
2820 /* read any numerical arguments */ 2846 /* read any numerical arguments */
2821 for (n = -1; ch < CSI_ICH; ) 2847 for (n = -1; ch < CSI_ICH; )
2822 { 2848 {
2823 if (isdigit (ch)) 2849 if (isdigit (ch))
2824 { 2850 {
2834 n = -1; 2860 n = -1;
2835 } 2861 }
2836 else if (IS_CONTROL (ch)) 2862 else if (IS_CONTROL (ch))
2837 process_nonprinting (ch); 2863 process_nonprinting (ch);
2838 2864
2865 prev_ch = ch;
2839 ch = cmd_getc (); 2866 ch = cmd_getc ();
2840 } 2867 }
2841 2868
2842 if (ch > CSI_7F) 2869 if (ch > CSI_7F)
2843 return; 2870 return;
3077 scr_insert_mode (1); 3104 scr_insert_mode (1);
3078 else if (arg[0] == 20) 3105 else if (arg[0] == 20)
3079 priv_modes |= PrivMode_LFNL; 3106 priv_modes |= PrivMode_LFNL;
3080 break; 3107 break;
3081 3108
3109 case CSI_71: // DESCUSR: set cursor style
3110 if (prev_ch == ' ')
3111 set_cursor_style (arg[0]);
3112 break;
3113
3082 /* 3114 /*
3083 * PRIVATE USE beyond this point. All CSI_7? sequences here 3115 * PRIVATE USE beyond this point. All CSI_7? sequences here
3084 */ 3116 */
3085 case CSI_72: /* DECSTBM: set top and bottom margins */ 3117 case CSI_72: /* DECSTBM: set top and bottom margins */
3086 if (nargs == 1) 3118 if (nargs == 1)
3219rxvt_term::get_to_st (unicode_t &ends_how) 3251rxvt_term::get_to_st (unicode_t &ends_how)
3220{ 3252{
3221 unicode_t ch; 3253 unicode_t ch;
3222 bool seen_esc = false; 3254 bool seen_esc = false;
3223 unsigned int n = 0; 3255 unsigned int n = 0;
3224 wchar_t string[STRING_MAX]; 3256 wchar_t string[CBUFSIZ];
3225 3257
3226 while ((ch = cmd_getc ()) != NOCHAR) 3258 while ((ch = cmd_getc ()) != NOCHAR)
3227 { 3259 {
3228 if (seen_esc) 3260 if (seen_esc)
3229 { 3261 {
3244 else if (ch < 0x20) 3276 else if (ch < 0x20)
3245 return NULL; /* other control character - exit */ 3277 return NULL; /* other control character - exit */
3246 3278
3247 seen_esc = false; 3279 seen_esc = false;
3248 3280
3249 if (n >= STRING_MAX - 1) 3281 if (n >= sizeof (string) - 1)
3250 // stop at some sane length 3282 // stop at some sane length
3251 return NULL; 3283 return NULL;
3252 3284
3253 string[n++] = ch; 3285 string[n++] = ch;
3254 } 3286 }
3371 &nitems, &bytes_after, &value) == Success 3403 &nitems, &bytes_after, &value) == Success
3372 && actual_type != None 3404 && actual_type != None
3373 && actual_format == 8) 3405 && actual_format == 8)
3374 str = (const char *)(value); 3406 str = (const char *)(value);
3375 3407
3376 tt_printf ("\033]%d;%s%c", op, str, resp); 3408 tt_printf ("\033]%d;%s%c", op, option (Opt_insecure) ? str : "", resp);
3377 3409
3378 XFree (value); 3410 XFree (value);
3379 } 3411 }
3380 else 3412 else
3381 { 3413 {
3991 break; 4023 break;
3992#endif 4024#endif
3993 } 4025 }
3994 } 4026 }
3995} 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}
3996/*}}} */ 4044/*}}} */
3997 4045
3998/* ------------------------------------------------------------------------- */ 4046/* ------------------------------------------------------------------------- */
3999 4047
4000/* 4048/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines