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.545 by sf-exg, Sat Apr 26 15:05:17 2014 UTC vs.
Revision 1.552 by sf-exg, Fri Jul 25 17:03:38 2014 UTC

30 * Copyright (c) 2003-2014 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 3 of the License, or
36 * (at your option) any later version. 36 * (at your option) any later version.
37 * 37 *
38 * This program is distributed in the hope that it will be useful, 38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of 39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
413 413
414void ecb_cold 414void ecb_cold
415rxvt_term::key_press (XKeyEvent &ev) 415rxvt_term::key_press (XKeyEvent &ev)
416{ 416{
417 int ctrl, meta, shft, len; 417 int ctrl, meta, shft, len;
418 KeySym keysym; 418 KeySym keysym = NoSymbol;
419 int valid_keysym;
420 char rkbuf[KBUFSZ]; 419 char rkbuf[KBUFSZ + 1];
421 char *kbuf = rkbuf + 1; 420 char *kbuf = rkbuf + 1;
422 421
423#if ISO_14755 422#if ISO_14755
424 if (iso14755buf & ISO_14755_52) 423 if (iso14755buf & ISO_14755_52)
425 return; 424 return;
483 } 482 }
484 } 483 }
485 else 484 else
486 len = 0; 485 len = 0;
487 } 486 }
488
489 valid_keysym = status_return == XLookupKeySym
490 || status_return == XLookupBoth;
491 } 487 }
492 else 488 else
493#endif 489#endif
494 { 490 {
495 len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); 491 len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose);
496 valid_keysym = keysym != NoSymbol;
497 }
498
499 if (valid_keysym)
500 { 492 }
493
494 if (keysym != NoSymbol)
495 {
496 KeySym orig_keysym = keysym;
497
498 /* Shift + F1 - F10 generates F11 - F20 */
499 if (shft && keysym >= XK_F1 && keysym <= XK_F10)
500 {
501 keysym += (XK_F11 - XK_F1);
502 shft = 0; /* turn off Shift */
503 }
504
501 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 505 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
502 { 506 {
503 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; 507 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
504 unsigned int newlen = 1; 508 unsigned int newlen = 1;
505 509
685 meta = 0; 689 meta = 0;
686 } 690 }
687#endif 691#endif
688 /* nil */ ; 692 /* nil */ ;
689 } 693 }
694
695 keysym = orig_keysym;
690 } 696 }
691 697
692 /* escape prefix */ 698 /* escape prefix */
693 if (len && meta 699 if (len && meta
694#ifdef META8_OPTION 700#ifdef META8_OPTION
698 { 704 {
699 *--kbuf = C0_ESC; 705 *--kbuf = C0_ESC;
700 len++; 706 len++;
701 } 707 }
702 708
703 if (valid_keysym) 709 if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END)))
710 return;
711
712 if (keysym != NoSymbol)
704 { 713 {
705#ifdef KEYSYM_RESOURCE 714#ifdef KEYSYM_RESOURCE
706 if (keyboard->dispatch (this, keysym, ev.state, kbuf, len)) 715 if (keyboard->dispatch (this, keysym, ev.state, kbuf, len))
707 return; 716 return;
708#endif 717#endif
767#endif 776#endif
768 } 777 }
769 778
770 if (shft) 779 if (shft)
771 { 780 {
772 /* Shift + F1 - F10 generates F11 - F20 */
773 if (keysym >= XK_F1 && keysym <= XK_F10)
774 {
775 keysym += (XK_F11 - XK_F1);
776 shft = 0; /* turn off Shift */
777 }
778 else if (!ctrl && !meta && (priv_modes & PrivMode_ShiftKeys)) 781 if (!ctrl && !meta && (priv_modes & PrivMode_ShiftKeys))
779 { 782 {
780 switch (keysym) 783 switch (keysym)
781 { 784 {
782 /* normal XTerm key bindings */ 785 /* normal XTerm key bindings */
783 case XK_Insert: /* Shift+Insert = paste mouse selection */ 786 case XK_Insert: /* Shift+Insert = paste mouse selection */
871 return; 874 return;
872 } 875 }
873#endif 876#endif
874 } 877 }
875 878
876 if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END)))
877 return;
878
879 if (len <= 0) 879 if (len <= 0)
880 return; /* not mapped */ 880 return; /* not mapped */
881 881
882 if (option (Opt_scrollTtyKeypress))
883 if (view_start)
884 {
885 view_start = 0;
886 want_refresh = 1;
887 }
888
889 tt_write (kbuf, (unsigned int)len); 882 tt_write_user_input (kbuf, (unsigned int)len);
890} 883}
891 884
892void ecb_cold 885void ecb_cold
893rxvt_term::key_release (XKeyEvent &ev) 886rxvt_term::key_release (XKeyEvent &ev)
894{ 887{
4045 4038
4046 want_refresh = 1; 4039 want_refresh = 1;
4047} 4040}
4048/*}}} */ 4041/*}}} */
4049 4042
4050/* ------------------------------------------------------------------------- */ 4043/* ---------------------------------------------------------------------- */
4044/* Write data to the pty as typed by the user, pasted with the mouse,
4045 * or generated by us in response to a query ESC sequence.
4046 */
4051 4047
4052/* 4048/*
4053 * Send printf () formatted output to the command. 4049 * Send printf () formatted output to the command.
4054 * Only use for small amounts of data. 4050 * Only use for small amounts of data.
4055 */ 4051 */
4063 vsnprintf ((char *)buf, 256, fmt, arg_ptr); 4059 vsnprintf ((char *)buf, 256, fmt, arg_ptr);
4064 va_end (arg_ptr); 4060 va_end (arg_ptr);
4065 tt_write (buf, strlen (buf)); 4061 tt_write (buf, strlen (buf));
4066} 4062}
4067 4063
4068/* ---------------------------------------------------------------------- */
4069/* Write data to the pty as typed by the user, pasted with the mouse, 4064/* Write data to the pty as typed by the user. */
4070 * or generated by us in response to a query ESC sequence. 4065void
4071 */ 4066rxvt_term::tt_write_user_input (const char *data, unsigned int len)
4072static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4067{
4068 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4069 return;
4070
4071 if (option (Opt_scrollTtyKeypress))
4072 if (view_start)
4073 {
4074 view_start = 0;
4075 want_refresh = 1;
4076 }
4077
4078 tt_write_ (data, len);
4079}
4073 4080
4074void 4081void
4075rxvt_term::tt_write (const char *data, unsigned int len) 4082rxvt_term::tt_write (const char *data, unsigned int len)
4076{ 4083{
4077 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) 4084 if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END)))
4078 return; 4085 return;
4079 4086
4087 tt_write_ (data, len);
4088}
4089
4090static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4091
4092void
4093rxvt_term::tt_write_ (const char *data, unsigned int len)
4094{
4080 if (pty->pty < 0) 4095 if (pty->pty < 0)
4081 return; 4096 return;
4082 4097
4083 if (v_buflen == 0) 4098 if (v_buflen == 0)
4084 { 4099 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines