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.329 by ayin, Mon Jun 11 19:57:28 2007 UTC vs.
Revision 1.396 by ayin, Sun Jan 20 14:12:39 2008 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-2006 Marc Lehmann <pcg@goof.com> 30 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
31 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it>
31 * 32 *
32 * 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
33 * 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
34 * the Free Software Foundation; either version 2 of the License, or 35 * the Free Software Foundation; either version 2 of the License, or
35 * (at your option) any later version. 36 * (at your option) any later version.
95 XK_Shift_L, 0x21e7, 96 XK_Shift_L, 0x21e7,
96 XK_Shift_R, 0x21e7, 97 XK_Shift_R, 0x21e7,
97 98
98 XK_Shift_Lock, 0x21eb, 99 XK_Shift_Lock, 0x21eb,
99 XK_ISO_Lock, 0x21eb, 100 XK_ISO_Lock, 0x21eb,
100 XK_ISO_Lock, 0x21eb,
101 XK_Caps_Lock, 0x21ec, 101 XK_Caps_Lock, 0x21ec,
102 XK_Num_Lock, 0x21ed, 102 XK_Num_Lock, 0x21ed,
103 XK_ISO_Level3_Shift, 0x21ee, 103 XK_ISO_Level3_Shift, 0x21ee,
104 XK_ISO_Level3_Lock, 0x21ef, 104 XK_ISO_Level3_Lock, 0x21ef,
105 XK_ISO_Group_Lock, 0x21f0, 105 XK_ISO_Group_Lock, 0x21f0,
199 r & RS_Uline ? " uline" : "", 199 r & RS_Uline ? " uline" : "",
200 r & RS_Careful ? " careful" : ""); 200 r & RS_Careful ? " careful" : "");
201 201
202 int width = wcswidth (fname, wcslen (fname)); 202 int width = wcswidth (fname, wcslen (fname));
203 203
204 max_it (width, 8+5); // for char + hey 204 max_it (width, 8+5); // for char + hex
205 max_it (width, strlen (attr)); 205 max_it (width, strlen (attr));
206 206
207 if (y >= 0) 207 if (y >= 0)
208 { 208 {
209 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; 209 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1;
221 ch = *chr++; 221 ch = *chr++;
222 222
223 sprintf (buf, "%8x", ch); 223 sprintf (buf, "%8x", ch);
224 scr_overlay_set (0, y, buf); 224 scr_overlay_set (0, y, buf);
225 scr_overlay_set (9, y, '='); 225 scr_overlay_set (9, y, '=');
226# if !UNICODE3 226# if !UNICODE_3
227 if (ch >= 0x10000) 227 if (ch >= 0x10000)
228 ch = 0xfffd; 228 ch = 0xfffd;
229# endif 229# endif
230 scr_overlay_set (11, y, ch, r); 230 scr_overlay_set (11, y, ch, r);
231 231
519# endif 519# endif
520 return; 520 return;
521 } 521 }
522 else 522 else
523 { 523 {
524# if ENABLE_OVERLAY 524# if ISO_14755
525 scr_overlay_off (); 525 scr_overlay_off ();
526# endif 526# endif
527 iso14755buf = 0; 527 iso14755buf = 0;
528 } 528 }
529 } 529 }
530 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 530 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
531 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 531 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
532 if (!(iso14755buf & ISO_14755_STARTED)) 532 if (!(iso14755buf & ISO_14755_STARTED))
533 { 533 {
534 iso14755buf |= ISO_14755_STARTED; 534 iso14755buf |= ISO_14755_STARTED;
535# if ENABLE_OVERLAY 535# if ISO_14755
536 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 536 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
537 scr_overlay_set (0, 0, "ISO 14755 mode"); 537 scr_overlay_set (0, 0, "ISO 14755 mode");
538# endif 538# endif
539 } 539 }
540#endif 540#endif
548#endif 548#endif
549 549
550 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 550 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
551 { 551 {
552 { 552 {
553 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
553 newlen = 1; 554 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
573 if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin))
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
554 switch (keysym) 585 switch (keysym)
555 { 586 {
556#ifndef NO_BACKSPACE_KEY 587#ifndef NO_BACKSPACE_KEY
557 case XK_BackSpace: 588 case XK_BackSpace:
558 if (priv_modes & PrivMode_HaveBackSpace) 589 if (priv_modes & PrivMode_HaveBackSpace)
560 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) 591 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace)
561 ^ !!ctrl) ? '\b' : '\177'; 592 ^ !!ctrl) ? '\b' : '\177';
562 kbuf[1] = '\0'; 593 kbuf[1] = '\0';
563 } 594 }
564 else 595 else
565 strcpy (kbuf, key_backspace); 596 strcpy (kbuf, rs[Rs_backspace_key]);
566 break; 597 break;
567#endif 598#endif
568#ifndef NO_DELETE_KEY 599#ifndef NO_DELETE_KEY
569# ifdef XK_KP_Prior
570 case XK_KP_Delete:
571 /* allow shift to override */
572 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
573 {
574 strcpy (kbuf, "\033On");
575 break;
576 }
577 /* FALLTHROUGH */
578# endif
579 case XK_Delete: 600 case XK_Delete:
580 strcpy (kbuf, key_delete); 601 strcpy (kbuf, rs[Rs_delete_key]);
581 break; 602 break;
582#endif 603#endif
583 case XK_Tab: 604 case XK_Tab:
584 if (shft) 605 if (shft)
585 strcpy (kbuf, "\033[Z"); 606 strcpy (kbuf, "\033[Z");
595#endif 616#endif
596 newlen = 0; 617 newlen = 0;
597 } 618 }
598 break; 619 break;
599 620
600#ifdef XK_KP_Left
601 case XK_KP_Up: /* \033Ox or standard */
602 case XK_KP_Down: /* \033Or or standard */
603 case XK_KP_Right: /* \033Ov or standard */
604 case XK_KP_Left: /* \033Ot or standard */
605 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
606 {
607 strcpy (kbuf, "\033OZ");
608 kbuf[2] = "txvr"[keysym - XK_KP_Left];
609 break;
610 }
611 else
612 /* translate to std. cursor key */
613 keysym = XK_Left + (keysym - XK_KP_Left);
614 /* FALLTHROUGH */
615#endif
616 case XK_Up: /* "\033[A" */ 621 case XK_Up: /* "\033[A" */
617 case XK_Down: /* "\033[B" */ 622 case XK_Down: /* "\033[B" */
618 case XK_Right: /* "\033[C" */ 623 case XK_Right: /* "\033[C" */
619 case XK_Left: /* "\033[D" */ 624 case XK_Left: /* "\033[D" */
620 strcpy (kbuf, "\033[Z"); 625 strcpy (kbuf, "\033[Z");
630 else if (priv_modes & PrivMode_aplCUR) 635 else if (priv_modes & PrivMode_aplCUR)
631 kbuf[1] = 'O'; 636 kbuf[1] = 'O';
632 break; 637 break;
633 638
634#ifndef UNSHIFTED_SCROLLKEYS 639#ifndef UNSHIFTED_SCROLLKEYS
635# ifdef XK_KP_Prior
636 case XK_KP_Prior:
637 /* allow shift to override */
638 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
639 {
640 strcpy (kbuf, "\033Oy");
641 break;
642 }
643 /* FALLTHROUGH */
644# endif
645 case XK_Prior: 640 case XK_Prior:
646 strcpy (kbuf, "\033[5~"); 641 strcpy (kbuf, "\033[5~");
647 break; 642 break;
648# ifdef XK_KP_Next
649 case XK_KP_Next:
650 /* allow shift to override */
651 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
652 {
653 strcpy (kbuf, "\033Os");
654 break;
655 }
656 /* FALLTHROUGH */
657# endif
658 case XK_Next: 643 case XK_Next:
659 strcpy (kbuf, "\033[6~"); 644 strcpy (kbuf, "\033[6~");
660 break; 645 break;
661#endif 646#endif
662 case XK_KP_Enter: 647 case XK_KP_Enter:
663 /* allow shift to override */ 648 /* allow shift to override */
664 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 649 if (kp)
665 { 650 {
666 strcpy (kbuf, "\033OM"); 651 strcpy (kbuf, "\033OM");
667 break; 652 break;
668 } 653 }
669 654
681 kbuf[0] = '\015'; 666 kbuf[0] = '\015';
682 kbuf[1] = '\0'; 667 kbuf[1] = '\0';
683 } 668 }
684 break; 669 break;
685 670
686#ifdef XK_KP_Begin
687 case XK_KP_Begin:
688 strcpy (kbuf, "\033Ou");
689 break;
690
691#endif
692 case XK_KP_F1: /* "\033OP" */ 671 case XK_KP_F1: /* "\033OP" */
693 case XK_KP_F2: /* "\033OQ" */ 672 case XK_KP_F2: /* "\033OQ" */
694 case XK_KP_F3: /* "\033OR" */ 673 case XK_KP_F3: /* "\033OR" */
695 case XK_KP_F4: /* "\033OS" */ 674 case XK_KP_F4: /* "\033OS" */
696 strcpy (kbuf, "\033OP"); 675 strcpy (kbuf, "\033OP");
712 case XK_KP_6: /* "\033Ov" : "6" */ 691 case XK_KP_6: /* "\033Ov" : "6" */
713 case XK_KP_7: /* "\033Ow" : "7" */ 692 case XK_KP_7: /* "\033Ow" : "7" */
714 case XK_KP_8: /* "\033Ox" : "8" */ 693 case XK_KP_8: /* "\033Ox" : "8" */
715 case XK_KP_9: /* "\033Oy" : "9" */ 694 case XK_KP_9: /* "\033Oy" : "9" */
716 /* allow shift to override */ 695 /* allow shift to override */
717 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 696 if (kp)
718 { 697 {
719 strcpy (kbuf, "\033Oj"); 698 strcpy (kbuf, "\033Oj");
720 kbuf[2] += (keysym - XK_KP_Multiply); 699 kbuf[2] += (keysym - XK_KP_Multiply);
721 } 700 }
722 else 701 else
728 707
729 case XK_Find: 708 case XK_Find:
730 strcpy (kbuf, "\033[1~"); 709 strcpy (kbuf, "\033[1~");
731 break; 710 break;
732 711
733#ifdef XK_KP_End
734 case XK_KP_Insert:
735 /* allow shift to override */
736 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
737 {
738 strcpy (kbuf, "\033Op");
739 break;
740 }
741 /* FALLTHROUGH */
742#endif
743 case XK_Insert: 712 case XK_Insert:
744 strcpy (kbuf, "\033[2~"); 713 strcpy (kbuf, "\033[2~");
745 break; 714 break;
746#ifdef DXK_Remove /* support for DEC remove like key */ 715#ifdef DXK_Remove /* support for DEC remove like key */
747 case DXK_Remove: 716 case DXK_Remove:
751 strcpy (kbuf, "\033[3~"); 720 strcpy (kbuf, "\033[3~");
752 break; 721 break;
753 case XK_Select: 722 case XK_Select:
754 strcpy (kbuf, "\033[4~"); 723 strcpy (kbuf, "\033[4~");
755 break; 724 break;
756#ifdef XK_KP_End
757 case XK_KP_End:
758 /* allow shift to override */
759 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
760 {
761 strcpy (kbuf, "\033Oq");
762 break;
763 }
764 /* FALLTHROUGH */
765#endif
766 case XK_End: 725 case XK_End:
767 strcpy (kbuf, KS_END); 726 strcpy (kbuf, KS_END);
768 break; 727 break;
769#ifdef XK_KP_Home
770 case XK_KP_Home:
771 /* allow shift to override */
772 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
773 {
774 strcpy (kbuf, "\033Ow");
775 break;
776 }
777 /* FALLTHROUGH */
778#endif
779 case XK_Home: 728 case XK_Home:
780 strcpy (kbuf, KS_HOME); 729 strcpy (kbuf, KS_HOME);
781 break; 730 break;
782 731
783#define FKEY(n, fkey) \ 732#define FKEY(n, fkey) \
934#if ENABLE_FRILLS || ISO_14755 883#if ENABLE_FRILLS || ISO_14755
935 // ISO 14755 support 884 // ISO 14755 support
936 if (iso14755buf) 885 if (iso14755buf)
937 if (iso14755buf & ISO_14755_52) 886 if (iso14755buf & ISO_14755_52)
938 { 887 {
939# if ENABLE_OVERLAY 888# if ISO_14755
940 scr_overlay_off (); 889 scr_overlay_off ();
941# endif 890# endif
942# if ISO_14755 891# if ISO_14755
943 // iso14755 part 5.2 handling: release time 892 // iso14755 part 5.2 handling: release time
944 // first: controls 893 // first: controls
967 916
968 return; 917 return;
969 } 918 }
970 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) 919 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
971 { 920 {
972# if ENABLE_OVERLAY 921# if ISO_14755
973 scr_overlay_off (); 922 scr_overlay_off ();
974# endif 923# endif
975 if (iso14755buf & ISO_14755_51) 924 if (iso14755buf & ISO_14755_51)
976 commit_iso14755 (); 925 commit_iso14755 ();
977#if ISO_14755 926#if ISO_14755
1035void 984void
1036rxvt_term::flush () 985rxvt_term::flush ()
1037{ 986{
1038 flush_ev.stop (); 987 flush_ev.stop ();
1039 988
1040#ifdef TRANSPARENT 989#ifdef HAVE_BG_PIXMAP
1041 if (want_full_refresh) 990 if (bgPixmap.check_clearChanged ())
1042 { 991 {
1043 want_full_refresh = 0; 992// scr_clear (true); This needs to be researched further!
1044 scr_clear ();
1045 scr_touch (false); 993 scr_touch (false);
1046 } 994 }
1047#endif 995#endif
1048 996
1049 if (want_refresh) 997 if (want_refresh)
1094 } 1042 }
1095 1043
1096 display->flush (); 1044 display->flush ();
1097} 1045}
1098 1046
1047/* checks wether a refresh is requested and starts the refresh timer */
1099void 1048void
1100rxvt_term::check_cb (check_watcher &w) 1049rxvt_term::refresh_check ()
1050{
1051 if (want_refresh && !flush_ev.is_active ())
1052 flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally
1053
1054 display->flush ();
1055}
1056
1057void
1058rxvt_term::flush_cb (ev::timer &w, int revents)
1101{ 1059{
1102 make_current (); 1060 make_current ();
1103 1061
1104 display->flush ();
1105
1106 if (want_refresh && !flush_ev.active)
1107 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
1108}
1109
1110void
1111rxvt_term::flush_cb (time_watcher &w)
1112{
1113 make_current ();
1114
1115 refresh_limit = 1;
1116 refresh_count = 0; 1062 refresh_count = 0;
1117 flush (); 1063 flush ();
1118} 1064}
1119 1065
1120#ifdef CURSOR_BLINK 1066#ifdef CURSOR_BLINK
1121void 1067void
1122rxvt_term::cursor_blink_cb (time_watcher &w) 1068rxvt_term::cursor_blink_cb (ev::timer &w, int revents)
1123{ 1069{
1124 hidden_cursor = !hidden_cursor; 1070 hidden_cursor = !hidden_cursor;
1125 want_refresh = 1; 1071 want_refresh = 1;
1126 1072 refresh_check ();
1127 w.start (w.at + CURSOR_BLINK_INTERVAL);
1128} 1073}
1129#endif 1074#endif
1130 1075
1131#ifdef TEXT_BLINK 1076#ifdef TEXT_BLINK
1132void 1077void
1133rxvt_term::text_blink_cb (time_watcher &w) 1078rxvt_term::text_blink_cb (ev::timer &w, int revents)
1134{ 1079{
1135 if (scr_refresh_rend (RS_Blink, RS_Blink)) 1080 if (scr_refresh_rend (RS_Blink, RS_Blink))
1136 { 1081 {
1137 hidden_text = !hidden_text; 1082 hidden_text = !hidden_text;
1138 want_refresh = 1; 1083 want_refresh = 1;
1139 w.start (w.at + TEXT_BLINK_INTERVAL); 1084 refresh_check ();
1140 } 1085 }
1086 else
1087 w.stop ();
1141} 1088}
1142#endif 1089#endif
1143 1090
1144#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1091#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1145void 1092void
1146rxvt_term::cont_scroll_cb (time_watcher &w) 1093rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1147{ 1094{
1148 if ((scrollbar_isUp() || scrollbar_isDn()) && 1095 if ((scrollbar_isUp () || scrollbar_isDn ())
1149 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1096 && scr_page (scrollbar_isUp () ? UP : DN, 1))
1150 { 1097 {
1151 want_refresh = 1; 1098 want_refresh = 1;
1152 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1099 refresh_check ();
1153 } 1100 }
1101 else
1102 w.stop ();
1154} 1103}
1155#endif 1104#endif
1156 1105
1157#ifdef SELECTION_SCROLLING 1106#ifdef SELECTION_SCROLLING
1158void 1107void
1159rxvt_term::sel_scroll_cb (time_watcher &w) 1108rxvt_term::sel_scroll_cb (ev::timer &w, int revents)
1160{ 1109{
1161 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1110 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1162 { 1111 {
1163 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1112 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1164 want_refresh = 1; 1113 want_refresh = 1;
1165 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1114 refresh_check ();
1166 } 1115 }
1116 else
1117 w.stop ();
1167} 1118}
1168#endif 1119#endif
1169 1120
1170#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1121#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1171void 1122void
1172rxvt_term::slip_wheel_cb (time_watcher &w) 1123rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1173{ 1124{
1174 if (mouse_slip_wheel_speed == 0 1125 if (scr_changeview (view_start - mouse_slip_wheel_speed))
1175 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1176 : scr_page (UP, mouse_slip_wheel_speed))
1177 { 1126 {
1178 if (view_start == top_row || view_start == 0)
1179 mouse_slip_wheel_speed = 0;
1180
1181 want_refresh = 1; 1127 want_refresh = 1;
1182 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1128 refresh_check ();
1129 }
1130
1131 if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0)
1132 {
1133 mouse_slip_wheel_speed = 0;
1134 w.stop ();
1183 } 1135 }
1184} 1136}
1185#endif 1137#endif
1186 1138
1187#if LINUX_YIELD_HACK 1139#if LINUX_YIELD_HACK
1188static struct event_handler 1140static struct event_handler
1189{ 1141{
1190 check_watcher yield_ev; 1142 ev::prepare yield_ev;
1191 1143
1192 void yield_cb (check_watcher &w) 1144 void yield_cb (ev::prepare &w, int revents)
1193 { 1145 {
1194 // this should really be sched_yield(), but the linux guys thought 1146 // this should really be sched_yield(), but the linux guys thought
1195 // that giving a process calling sched_yield () less cpu time than 1147 // that giving a process calling sched_yield () less cpu time than
1196 // ones with high nice levels is a useful thing to do. It surely is is 1148 // ones with high nice levels is a useful thing to do. It surely is is
1197 // allowed by the sus... as is returning ENOSYS. 1149 // allowed by the sus... as is returning ENOSYS.
1248 1200
1249 return false; 1201 return false;
1250} 1202}
1251 1203
1252void 1204void
1253rxvt_term::pty_cb (io_watcher &w, short revents) 1205rxvt_term::pty_cb (ev::io &w, int revents)
1254{ 1206{
1255 make_current (); 1207 make_current ();
1256 1208
1257 if (revents & EVENT_READ) 1209 if (revents & ev::READ)
1258 // loop, but don't allow a single term to monopolize us 1210 // loop, but don't allow a single term to monopolize us
1259 while (pty_fill ()) 1211 while (pty_fill ())
1260 if (cmd_parse ()) 1212 if (cmd_parse ())
1261 break; 1213 break;
1262 1214
1263 if (revents & EVENT_WRITE) 1215 if (revents & ev::WRITE)
1264 pty_write (); 1216 pty_write ();
1217
1218 refresh_check ();
1265} 1219}
1266 1220
1267void 1221void
1268rxvt_term::pointer_unblank () 1222rxvt_term::pointer_unblank ()
1269{ 1223{
1272 1226
1273#ifdef POINTER_BLANK 1227#ifdef POINTER_BLANK
1274 hidden_pointer = 0; 1228 hidden_pointer = 0;
1275 1229
1276 if (option (Opt_pointerBlank)) 1230 if (option (Opt_pointerBlank))
1277 pointer_ev.start (NOW + pointerBlankDelay); 1231 pointer_ev.start (pointerBlankDelay);
1278#endif 1232#endif
1279} 1233}
1280 1234
1281#ifdef POINTER_BLANK 1235#ifdef POINTER_BLANK
1282void 1236void
1290 1244
1291 hidden_pointer = 1; 1245 hidden_pointer = 1;
1292} 1246}
1293 1247
1294void 1248void
1295rxvt_term::pointer_cb (time_watcher &w) 1249rxvt_term::pointer_cb (ev::timer &w, int revents)
1296{ 1250{
1297 make_current (); 1251 make_current ();
1298 1252
1299 pointer_blank (); 1253 pointer_blank ();
1300} 1254}
1303void 1257void
1304rxvt_term::mouse_report (XButtonEvent &ev) 1258rxvt_term::mouse_report (XButtonEvent &ev)
1305{ 1259{
1306 int button_number, key_state = 0; 1260 int button_number, key_state = 0;
1307 int x, y; 1261 int x, y;
1262 int code = 32;
1308 1263
1309 x = ev.x; 1264 x = Pixel2Col (ev.x);
1310 y = ev.y; 1265 y = Pixel2Row (ev.y);
1311 pixel_position (&x, &y); 1266 if (ev.type == MotionNotify)
1267 {
1268 if (x == mouse_row && y == mouse_col)
1269 return;
1270 mouse_row = x;
1271 mouse_col = y;
1272 code += 32;
1273 }
1312 1274
1313 if (MEvent.button == AnyButton) 1275 if (MEvent.button == AnyButton)
1314 button_number = 3; 1276 button_number = 3;
1315 else 1277 else
1316 { 1278 {
1362 x + 1, 1324 x + 1,
1363 y + 1); 1325 y + 1);
1364#endif 1326#endif
1365 1327
1366 tt_printf ("\033[M%c%c%c", 1328 tt_printf ("\033[M%c%c%c",
1367 (32 + button_number + key_state), 1329 (code + button_number + key_state),
1368 (32 + x + 1), 1330 (32 + x + 1),
1369 (32 + y + 1)); 1331 (32 + y + 1));
1370} 1332}
1371 1333
1372/*{{{ process an X event */ 1334/*{{{ process an X event */
1434 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) 1396 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1435 focus_out (); 1397 focus_out ();
1436 } 1398 }
1437#endif 1399#endif
1438 } 1400 }
1439 break;
1440
1441 case MappingNotify:
1442 XRefreshKeyboardMapping (&ev.xmapping);
1443 break; 1401 break;
1444 1402
1445 /* 1403 /*
1446 * XXX: this is not the _current_ arrangement 1404 * XXX: this is not the _current_ arrangement
1447 * Here's my conclusion: 1405 * Here's my conclusion:
1480 && ev.xfocus.mode != NotifyGrab) 1438 && ev.xfocus.mode != NotifyGrab)
1481 focus_out (); 1439 focus_out ();
1482 break; 1440 break;
1483 1441
1484 case ConfigureNotify: 1442 case ConfigureNotify:
1443 /*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,
1445 szHint.width, szHint.height); */
1485 if (ev.xconfigure.window == parent[0]) 1446 if (ev.xconfigure.window == parent[0])
1486 { 1447 {
1487 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1448 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1488 ; 1449 ;
1489 1450
1490 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1451 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1491 { 1452 {
1492 seen_resize = 1; 1453 seen_resize = 1;
1493 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1454 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1494#ifdef XPM_BACKGROUND 1455 }
1495 if (!option (Opt_transparent) && bgPixmap.auto_resize) 1456 else
1457 {
1458#ifdef HAVE_BG_PIXMAP
1459 if (bgPixmap.window_position_sensitive ())
1496 { 1460 {
1461 if (mapped)
1462 update_background ();
1497 resize_pixmap (); 1463 else
1498 scr_touch (true); 1464 bgPixmap.invalidate ();
1499 } 1465 }
1500#endif 1466#endif
1501 } 1467 }
1502 1468
1503 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1469 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1504
1505#ifdef TRANSPARENT
1506 if (option (Opt_transparent))
1507 check_our_parents ();
1508#endif
1509 } 1470 }
1510 break; 1471 break;
1511 1472
1512 case PropertyNotify: 1473 case PropertyNotify:
1513 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) 1474 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)))
1529 case SelectionRequest: 1490 case SelectionRequest:
1530 selection_send (ev.xselectionrequest); 1491 selection_send (ev.xselectionrequest);
1531 break; 1492 break;
1532 1493
1533 case MapNotify: 1494 case MapNotify:
1495#ifdef HAVE_BG_PIXMAP
1496 /* This is needed spcifically to fix the case of no window manager or a
1497 * non-reparenting window manager. In those cases we never get first
1498 * ConfigureNotify. Also that speeds startup under normal WM, by taking
1499 * care of multiplicity of ConfigureNotify events arriwing while WM does
1500 * reparenting.
1501 * We should not render background immidiately, as there could be several
1502 * ConfigureNotify's to follow. Lets take care of all of them in one scoop
1503 * by scheduling background redraw as soon as we can, but giving a short
1504 * bit of time for ConfigureNotifies to arrive.
1505 * We should render background PRIOR to drawing any text, but AFTER all
1506 * of ConfigureNotifys for the best results.
1507 */
1508 if (bgPixmap.flags & bgPixmap_t::isInvalid)
1509 update_background_ev.start (0.025);
1510#endif
1534 mapped = 1; 1511 mapped = 1;
1535#ifdef TEXT_BLINK 1512#ifdef TEXT_BLINK
1536 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 1513 text_blink_ev.start ();
1537#endif 1514#endif
1538 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1515 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1539 break; 1516 break;
1540 1517
1541 case UnmapNotify: 1518 case UnmapNotify:
1543#ifdef TEXT_BLINK 1520#ifdef TEXT_BLINK
1544 text_blink_ev.stop (); 1521 text_blink_ev.stop ();
1545#endif 1522#endif
1546 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1523 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1547 break; 1524 break;
1548
1549#ifdef TRANSPARENT
1550 case ReparentNotify:
1551 rootwin_cb (ev);
1552 break;
1553#endif /* TRANSPARENT */
1554 1525
1555 case GraphicsExpose: 1526 case GraphicsExpose:
1556 case Expose: 1527 case Expose:
1557 if (ev.xany.window == vt) 1528 if (ev.xany.window == vt)
1558 { 1529 {
1559 do 1530 do
1531 {
1560 scr_expose (ev.xexpose.x, ev.xexpose.y, 1532 scr_expose (ev.xexpose.x, ev.xexpose.y,
1561 ev.xexpose.width, ev.xexpose.height, False); 1533 ev.xexpose.width, ev.xexpose.height, False);
1534 }
1562 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); 1535 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1563 1536
1564 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1537 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1565 1538
1566 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1539 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1540 {
1567 scr_expose (ev.xexpose.x, ev.xexpose.y, 1541 scr_expose (ev.xexpose.x, ev.xexpose.y,
1568 ev.xexpose.width, ev.xexpose.height, False); 1542 ev.xexpose.width, ev.xexpose.height, False);
1543 }
1569 1544
1570 want_refresh = 1; 1545 want_refresh = 1;
1571 } 1546 }
1572 else 1547 else
1573 { 1548 {
1576 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) 1551 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event))
1577 ; 1552 ;
1578 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) 1553 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1579 ; 1554 ;
1580 1555
1581 if (isScrollbarWindow (ev.xany.window)) 1556 if (scrollBar.state && ev.xany.window == scrollBar.win)
1582 { 1557 {
1583 scrollBar.setIdle (); 1558 scrollBar.setIdle ();
1584 scrollbar_show (0); 1559 scrollbar_show (0);
1585 } 1560 }
1586
1587#ifdef TRANSPARENT
1588 if (am_transparent && ev.xany.window == parent[0])
1589 XClearWindow (dpy, ev.xany.window);
1590#endif
1591 } 1561 }
1592 break; 1562 break;
1593 1563
1594 case MotionNotify: 1564 case MotionNotify:
1595#ifdef POINTER_BLANK 1565#ifdef POINTER_BLANK
1596 if (hidden_pointer) 1566 if (hidden_pointer)
1597 pointer_unblank (); 1567 pointer_unblank ();
1598#endif 1568#endif
1569 if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask))
1570 || priv_modes & PrivMode_MouseAnyEvent)
1571 mouse_report (ev.xbutton);
1599 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1572 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1600 break; 1573 break;
1601 1574
1602 if (ev.xany.window == vt) 1575 if (ev.xany.window == vt)
1603 { 1576 {
1637 int dist; 1610 int dist;
1638 1611
1639 /* don't clobber the current delay if we are 1612 /* don't clobber the current delay if we are
1640 * already in the middle of scrolling. 1613 * already in the middle of scrolling.
1641 */ 1614 */
1642 if (!sel_scroll_ev.active) 1615 if (!sel_scroll_ev.is_active ())
1643 sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 1616 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1644 1617
1645 /* save the event params so we can highlight 1618 /* save the event params so we can highlight
1646 * the selection in the pending-scroll loop 1619 * the selection in the pending-scroll loop
1647 */ 1620 */
1648 selection_save_x = ev.xbutton.x; 1621 selection_save_x = ev.xbutton.x;
1670 else 1643 else
1671 { 1644 {
1672 /* we are within the text window, so we 1645 /* we are within the text window, so we
1673 * shouldn't be scrolling 1646 * shouldn't be scrolling
1674 */ 1647 */
1675 if (sel_scroll_ev.active)
1676 sel_scroll_ev.stop(); 1648 sel_scroll_ev.stop();
1677 } 1649 }
1678#endif 1650#endif
1679#ifdef MOUSE_THRESHOLD 1651#ifdef MOUSE_THRESHOLD
1680 } 1652 }
1681#endif 1653#endif
1682 } 1654 }
1683 } 1655 }
1684 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1656 else if (scrollbar_isMotion () && ev.xany.window == scrollBar.win)
1685 { 1657 {
1686 while (XCheckTypedWindowEvent (dpy, scrollBar.win, 1658 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1687 MotionNotify, &ev)) 1659 MotionNotify, &ev))
1688 ; 1660 ;
1689 1661
1693 &ev.xbutton.x, &ev.xbutton.y, 1665 &ev.xbutton.x, &ev.xbutton.y,
1694 &unused_mask); 1666 &unused_mask);
1695 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1667 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1696 scrollbar_size ()); 1668 scrollbar_size ());
1697 want_refresh = 1; 1669 want_refresh = 1;
1698 refresh_limit = 0;
1699 scrollbar_show (1); 1670 scrollbar_show (1);
1700 } 1671 }
1701 break; 1672 break;
1702 } 1673 }
1703 1674
1708 { 1679 {
1709 hidden_cursor = 0; 1680 hidden_cursor = 0;
1710 want_refresh = 1; 1681 want_refresh = 1;
1711 } 1682 }
1712 1683
1713 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1684 cursor_blink_ev.again ();
1714 } 1685 }
1715#endif 1686#endif
1716 1687
1717#if defined(POINTER_BLANK) 1688#if defined(POINTER_BLANK)
1718 if (option (Opt_pointerBlank) && pointerBlankDelay > 0) 1689 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1725 1696
1726 if (ev.type == KeyPress && hidden_pointer == 0) 1697 if (ev.type == KeyPress && hidden_pointer == 0)
1727 pointer_blank (); 1698 pointer_blank ();
1728 } 1699 }
1729#endif 1700#endif
1701
1702 refresh_check ();
1730} 1703}
1731 1704
1732void 1705void
1733rxvt_term::focus_in () 1706rxvt_term::focus_in ()
1734{ 1707{
1746 XSetICFocus (Input_Context); 1719 XSetICFocus (Input_Context);
1747 } 1720 }
1748#endif 1721#endif
1749#if CURSOR_BLINK 1722#if CURSOR_BLINK
1750 if (option (Opt_cursorBlink)) 1723 if (option (Opt_cursorBlink))
1751 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1724 cursor_blink_ev.again ();
1752#endif 1725#endif
1753#if OFF_FOCUS_FADING 1726#if OFF_FOCUS_FADING
1754 if (rs[Rs_fade]) 1727 if (rs[Rs_fade])
1755 { 1728 {
1756 pix_colors = pix_colors_focused; 1729 pix_colors = pix_colors_focused;
1758 } 1731 }
1759#endif 1732#endif
1760#if ENABLE_FRILLS 1733#if ENABLE_FRILLS
1761 if (option (Opt_urgentOnBell)) 1734 if (option (Opt_urgentOnBell))
1762 { 1735 {
1763 XWMHints *h;
1764
1765 h = XGetWMHints(dpy, parent[0]); 1736 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1766 if (h != NULL)
1767 { 1737 {
1768 h->flags &= ~XUrgencyHint; 1738 h->flags &= ~XUrgencyHint;
1769 XSetWMHints(dpy, parent[0], h); 1739 XSetWMHints (dpy, parent[0], h);
1770 } 1740 }
1771 } 1741 }
1772#endif 1742#endif
1773 } 1743 }
1774} 1744}
1785 1755
1786#if ENABLE_FRILLS || ISO_14755 1756#if ENABLE_FRILLS || ISO_14755
1787 if (iso14755buf) 1757 if (iso14755buf)
1788 { 1758 {
1789 iso14755buf = 0; 1759 iso14755buf = 0;
1790# if ENABLE_OVERLAY 1760# if ISO_14755
1791 scr_overlay_off (); 1761 scr_overlay_off ();
1792# endif 1762# endif
1793 } 1763 }
1794#endif 1764#endif
1795#if USE_XIM 1765#if USE_XIM
1797 XUnsetICFocus (Input_Context); 1767 XUnsetICFocus (Input_Context);
1798#endif 1768#endif
1799#if CURSOR_BLINK 1769#if CURSOR_BLINK
1800 if (option (Opt_cursorBlink)) 1770 if (option (Opt_cursorBlink))
1801 cursor_blink_ev.stop (); 1771 cursor_blink_ev.stop ();
1772
1802 hidden_cursor = 0; 1773 hidden_cursor = 0;
1803#endif 1774#endif
1804#if OFF_FOCUS_FADING 1775#if OFF_FOCUS_FADING
1805 if (rs[Rs_fade]) 1776 if (rs[Rs_fade])
1806 { 1777 {
1822 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); 1793 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1823 } 1794 }
1824#endif 1795#endif
1825} 1796}
1826 1797
1827#if TRANSPARENT || ENABLE_PERL 1798#if ENABLE_TRANSPARENCY || ENABLE_PERL
1828void 1799void
1829rxvt_term::rootwin_cb (XEvent &ev) 1800rxvt_term::rootwin_cb (XEvent &ev)
1830{ 1801{
1831 make_current (); 1802 make_current ();
1832 1803
1833 if (SHOULD_INVOKE (HOOK_ROOT_EVENT) 1804 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1834 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) 1805 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1835 return; 1806 return;
1836 1807
1837# if TRANSPARENT 1808# if ENABLE_TRANSPARENCY
1838 switch (ev.type) 1809 switch (ev.type)
1839 { 1810 {
1840 case PropertyNotify: 1811 case PropertyNotify:
1841 /* 1812 /*
1842 * if user used some Esetroot compatible prog to set the root bg, 1813 * if user used some Esetroot compatible prog to set the root bg,
1843 * use the property to determine the pixmap. We use it later on. 1814 * use the property to determine the pixmap. We use it later on.
1844 */ 1815 */
1845 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] 1816 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1846 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1817 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1847 return; 1818 {
1819 bgPixmap.set_root_pixmap ();
1820 update_background ();
1821 }
1848 1822
1849 /* FALLTHROUGH */
1850 case ReparentNotify:
1851 if (option (Opt_transparent))
1852 check_our_parents ();
1853 break; 1823 break;
1854 } 1824 }
1855# endif 1825# endif
1826
1827 refresh_check ();
1856} 1828}
1857#endif 1829#endif
1858 1830
1859void 1831void
1860rxvt_term::button_press (XButtonEvent &ev) 1832rxvt_term::button_press (XButtonEvent &ev)
1915 mouse_report (ev); 1887 mouse_report (ev);
1916 } 1888 }
1917#else 1889#else
1918 MEvent.button = ev.button; 1890 MEvent.button = ev.button;
1919 mouse_report (ev); 1891 mouse_report (ev);
1920#endif /* MOUSE_REPORT_DOUBLECLICK */ 1892#endif /* MOUSE_REPORT_DOUBLECLICK */
1921 1893
1922 } 1894 }
1923 else 1895 else
1924 { 1896 {
1925 if (ev.button != MEvent.button) 1897 if (ev.button != MEvent.button)
1973 } 1945 }
1974 1946
1975 /* 1947 /*
1976 * Scrollbar window processing of button press 1948 * Scrollbar window processing of button press
1977 */ 1949 */
1978 if (isScrollbarWindow (ev.window)) 1950 if (scrollBar.state && ev.window == scrollBar.win)
1979 { 1951 {
1980 scrollBar.setIdle (); 1952 scrollBar.setIdle ();
1981 /* 1953 /*
1982 * Rxvt-style scrollbar: 1954 * Rxvt-style scrollbar:
1983 * move up if mouse is above slider 1955 * move up if mouse is above slider
2019 tt_printf ("\033[5~"); 1991 tt_printf ("\033[5~");
2020 break; 1992 break;
2021 } 1993 }
2022 } 1994 }
2023 else 1995 else
2024#endif /* NO_SCROLLBAR_REPORT */ 1996#endif /* NO_SCROLLBAR_REPORT */
2025 1997
2026 { 1998 {
2027 char upordown = 0; 1999 char upordown = 0;
2028 2000
2029 if (scrollBar.style == R_SB_NEXT) 2001 if (scrollBar.style == R_SB_NEXT)
2030 { 2002 {
2031 if (scrollbarnext_upButton (ev.y)) 2003 if (scrollbarnext_upButton (ev.y))
2032 upordown = -1; /* up */ 2004 upordown = -1; /* up */
2038 if (scrollbarrxvt_upButton (ev.y)) 2010 if (scrollbarrxvt_upButton (ev.y))
2039 upordown = -1; /* up */ 2011 upordown = -1; /* up */
2040 else if (scrollbarrxvt_dnButton (ev.y)) 2012 else if (scrollbarrxvt_dnButton (ev.y))
2041 upordown = 1; /* down */ 2013 upordown = 1; /* down */
2042 } 2014 }
2015
2043 if (upordown) 2016 if (upordown)
2044 { 2017 {
2045#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 2018#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
2019 if (!cont_scroll_ev.is_active ())
2046 cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 2020 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2047#endif 2021#endif
2048 if (scr_page (upordown < 0 ? UP : DN, 1)) 2022 if (scr_page (upordown < 0 ? UP : DN, 1))
2049 { 2023 {
2050 if (upordown < 0) 2024 if (upordown < 0)
2051 scrollBar.setUp (); 2025 scrollBar.setUp ();
2055 } 2029 }
2056 else 2030 else
2057 switch (ev.button) 2031 switch (ev.button)
2058 { 2032 {
2059 case Button2: 2033 case Button2:
2060 switch (scrollbar_align) 2034 switch (scrollBar.align)
2061 { 2035 {
2062 case R_SB_ALIGN_TOP: 2036 case R_SB_ALIGN_TOP:
2063 csrO = 0; 2037 csrO = 0;
2064 break; 2038 break;
2065 case R_SB_ALIGN_CENTRE: 2039 case R_SB_ALIGN_CENTRE:
2077 2051
2078 scrollBar.setMotion (); 2052 scrollBar.setMotion ();
2079 break; 2053 break;
2080 2054
2081 case Button1: 2055 case Button1:
2082 if (scrollbar_align == R_SB_ALIGN_CENTRE) 2056 if (scrollBar.align == R_SB_ALIGN_CENTRE)
2083 csrO = ev.y - scrollBar.top; 2057 csrO = ev.y - scrollBar.top;
2084 /* FALLTHROUGH */ 2058 /* FALLTHROUGH */
2085 2059
2086 case Button3: 2060 case Button3:
2087 if (scrollBar.style != R_SB_XTERM) 2061 if (scrollBar.style != R_SB_XTERM)
2131 scrollBar.setIdle (); 2105 scrollBar.setIdle ();
2132 scrollbar_show (0); 2106 scrollbar_show (0);
2133 } 2107 }
2134 2108
2135#ifdef SELECTION_SCROLLING 2109#ifdef SELECTION_SCROLLING
2136 if (sel_scroll_ev.active)
2137 sel_scroll_ev.stop(); 2110 sel_scroll_ev.stop();
2138#endif 2111#endif
2139 2112
2140 if (ev.window == vt) 2113 if (ev.window == vt)
2141 { 2114 {
2142 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) 2115 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2166 mouse_report (ev); 2139 mouse_report (ev);
2167 } 2140 }
2168#else /* MOUSE_REPORT_DOUBLECLICK */ 2141#else /* MOUSE_REPORT_DOUBLECLICK */
2169 MEvent.button = AnyButton; 2142 MEvent.button = AnyButton;
2170 mouse_report (ev); 2143 mouse_report (ev);
2171#endif /* MOUSE_REPORT_DOUBLECLICK */ 2144#endif /* MOUSE_REPORT_DOUBLECLICK */
2172 return; 2145 return;
2173 } 2146 }
2174 2147
2175 /* 2148 /*
2176 * dumb hack to compensate for the failure of click-and-drag 2149 * dumb hack to compensate for the failure of click-and-drag
2214 { 2187 {
2215 mouse_slip_wheel_speed += v ? -1 : 1; 2188 mouse_slip_wheel_speed += v ? -1 : 1;
2216 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2189 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow;
2217 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; 2190 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2218 2191
2219 if (slip_wheel_ev.at < NOW) 2192 if (!slip_wheel_ev.is_active ())
2220 slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; 2193 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2221
2222 slip_wheel_ev.start ();
2223 } 2194 }
2224 else 2195 else
2196# endif
2225 { 2197 {
2226# endif
2227 scr_page (v, i); 2198 scr_page (v, i);
2228 scrollbar_show (1); 2199 scrollbar_show (1);
2229# ifdef MOUSE_SLIP_WHEELING
2230 } 2200 }
2231# endif
2232 } 2201 }
2233 break; 2202 break;
2234#endif 2203#endif
2235 } 2204 }
2236 } 2205 }
2291 if (ch == C0_LF) 2260 if (ch == C0_LF)
2292 nlines++; 2261 nlines++;
2293 2262
2294 refresh_count++; 2263 refresh_count++;
2295 2264
2296 if (!option (Opt_jumpScroll) 2265 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2297 || (refresh_count >= refresh_limit * (nrow - 1)))
2298 { 2266 {
2299 refreshnow = true;
2300 refresh_count = 0; 2267 refresh_count = 0;
2268
2269 if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.)
2270 {
2271 refreshnow = true;
2301 ch = NOCHAR; 2272 ch = NOCHAR;
2302 break; 2273 break;
2274 }
2303 } 2275 }
2304 2276
2305 // scr_add_lines only works for nlines <= nrow - 1. 2277 // scr_add_lines only works for nlines <= nrow - 1.
2306 if (nlines >= nrow - 1) 2278 if (nlines >= nrow - 1)
2307 { 2279 {
2335 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) 2307 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2336 scr_add_lines (buf, str - buf, nlines); 2308 scr_add_lines (buf, str - buf, nlines);
2337 2309
2338 /* 2310 /*
2339 * If there have been a lot of new lines, then update the screen 2311 * If there have been a lot of new lines, then update the screen
2340 * What the heck I'll cheat and only refresh less than every page-full. 2312 * What the heck we'll cheat and only refresh less than every page-full.
2341 * the number of pages between refreshes is refresh_limit, which 2313 * if skipScroll is enabled.
2342 * is incremented here because we must be doing flat-out scrolling.
2343 */ 2314 */
2344 if (refreshnow) 2315 if (refreshnow)
2345 { 2316 {
2346 if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2347 refresh_limit++;
2348 else
2349 {
2350 flag = true; 2317 flag = true;
2351 //TODO: due to popular request, implement "skipscroll" option here
2352 scr_refresh (); 2318 scr_refresh ();
2353 want_refresh = 1; 2319 want_refresh = 1;
2354 }
2355 } 2320 }
2356 2321
2357 } 2322 }
2358 else 2323 else
2359 { 2324 {
2520 } 2485 }
2521 } 2486 }
2522 2487
2523 pclose_printer (fd); 2488 pclose_printer (fd);
2524} 2489}
2525#endif /* PRINTPIPE */ 2490#endif /* PRINTPIPE */
2526/*}}} */ 2491/*}}} */
2527 2492
2528/* *INDENT-OFF* */ 2493/* *INDENT-OFF* */
2529enum { 2494enum {
2530 C1_40 = 0x40, 2495 C1_40 = 0x40,
2580 process_dcs_seq (); 2545 process_dcs_seq ();
2581 break; 2546 break;
2582 case 0x9b: /* CSI */ 2547 case 0x9b: /* CSI */
2583 process_csi_seq (); 2548 process_csi_seq ();
2584 break; 2549 break;
2585 case 0x9d: /* CSI */ 2550 case 0x9d: /* OSC */
2586 process_osc_seq (); 2551 process_osc_seq ();
2587 break; 2552 break;
2588#endif 2553#endif
2589 } 2554 }
2590} 2555}
2816rxvt_term::process_csi_seq () 2781rxvt_term::process_csi_seq ()
2817{ 2782{
2818 unicode_t ch, priv, i; 2783 unicode_t ch, priv, i;
2819 unsigned int nargs, p; 2784 unsigned int nargs, p;
2820 int n, ndef; 2785 int n, ndef;
2821 int arg[ESC_ARGS]; 2786 int arg[ESC_ARGS] = { };
2822 2787
2823 for (nargs = ESC_ARGS; nargs > 0;) 2788 nargs = 0;
2824 arg[--nargs] = 0;
2825 2789
2826 priv = 0; 2790 priv = 0;
2827 ch = cmd_getc (); 2791 ch = cmd_getc ();
2828 if (ch >= '<' && ch <= '?') 2792 if (ch >= '<' && ch <= '?')
2793 {
2829 { /* '<' '=' '>' '?' */ 2794 /* '<' '=' '>' '?' */
2830 priv = ch; 2795 priv = ch;
2831 ch = cmd_getc (); 2796 ch = cmd_getc ();
2832 } 2797 }
2833 2798
2834 /* read any numerical arguments */ 2799 /* read any numerical arguments */
2873 switch (priv) 2838 switch (priv)
2874 { 2839 {
2875 case '>': 2840 case '>':
2876 if (ch == CSI_DA) /* secondary device attributes */ 2841 if (ch == CSI_DA) /* secondary device attributes */
2877 { 2842 {
2878 // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, 2843 // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt,
2879 // 'U' for rxvt-unicode != 7.[34] (where it was broken). 2844 // 'U' for rxvt-unicode != 7.[34] (where it was broken).
2880 // 2845 //
2881 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt 2846 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt
2882 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify 2847 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later
2883 // that we do not support xterm mouse reporting (should be 95 when we do). 2848 // versions.
2884 // 2849 //
2885 tt_printf ("\033[>%d;94;0c", 'U'); 2850 tt_printf ("\033[>%d;95;0c", 'U');
2886 } 2851 }
2887 break; 2852 break;
2853
2888 case '?': 2854 case '?':
2889 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2855 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
2890 process_terminal_mode (ch, priv, nargs, arg); 2856 process_terminal_mode (ch, priv, nargs, arg);
2891 break; 2857 break;
2892 } 2858 }
3408 *buf++ = '\0'; 3374 *buf++ = '\0';
3409 3375
3410 process_color_seq (op, color, name, resp); 3376 process_color_seq (op, color, name, resp);
3411 } 3377 }
3412 break; 3378 break;
3379 case Rxvt_restoreFG:
3413 case XTerm_Color00: 3380 case XTerm_Color00:
3414 process_color_seq (op, Color_fg, str, resp); 3381 process_color_seq (op, Color_fg, str, resp);
3415 break; 3382 break;
3383 case Rxvt_restoreBG:
3416 case XTerm_Color01: 3384 case XTerm_Color01:
3417 process_color_seq (op, Color_bg, str, resp); 3385 process_color_seq (op, Color_bg, str, resp);
3418 break; 3386 break;
3419#ifndef NO_CURSORCOLOR 3387#ifndef NO_CURSORCOLOR
3420 case XTerm_Color_cursor: 3388 case XTerm_Color_cursor:
3441 break; 3409 break;
3442 case URxvt_Color_IT: 3410 case URxvt_Color_IT:
3443 process_color_seq (op, Color_IT, str, resp); 3411 process_color_seq (op, Color_IT, str, resp);
3444 break; 3412 break;
3445#endif 3413#endif
3446#if TRANSPARENT && TINTING 3414#if ENABLE_TRANSPARENCY
3447 case URxvt_Color_tint: 3415 case URxvt_Color_tint:
3448 process_color_seq (op, Color_tint, str, resp); 3416 process_color_seq (op, Color_tint, str, resp);
3417 {
3418 bool changed = false;
3449 3419
3450 check_our_parents (); 3420 if (ISSET_PIXCOLOR (Color_tint))
3421 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]);
3422 else
3423 changed = bgPixmap.unset_tint ();
3451 3424
3452 if (am_transparent) 3425 if (changed)
3453 want_full_refresh = want_refresh = 1; 3426 update_background ();
3427 }
3454 3428
3455 break; 3429 break;
3456#endif 3430#endif
3457 3431
3432#if BG_IMAGE_FROM_FILE
3458 case Rxvt_Pixmap: 3433 case Rxvt_Pixmap:
3459 { 3434 if (!strcmp (str, "?"))
3460 if (*str != ';')
3461 { 3435 {
3462#if XPM_BACKGROUND 3436 char str[256];
3463 scale_pixmap (""); /* reset to default scaling */ 3437
3464 set_bgPixmap (str); /* change pixmap */ 3438 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
3465 scr_touch (true); 3439 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767),
3466#endif 3440 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767));
3441 process_xterm_seq (XTerm_title, str, CHAR_ST);
3467 } 3442 }
3468 3443 else
3444 {
3469 int changed = 0; 3445 int changed = 0;
3470 3446
3471 while ((str = strchr (str, ';')) != NULL) 3447 if (*str != ';')
3472 { 3448 {
3449 /* reset to default scaling :*/
3450 bgPixmap.unset_geometry ();
3451 if (bgPixmap.set_file (str)) /* change pixmap */
3452 changed++;
3453 str = strchr (str, ';');
3454 if (str == NULL)
3455 bgPixmap.set_defaultGeometry ();
3456 }
3457
3458 while (str)
3459 {
3473 str++; 3460 str++;
3474#if XPM_BACKGROUND 3461 if (bgPixmap.set_geometry (str))
3475 changed += scale_pixmap (str); 3462 changed++;
3476#endif 3463 str = strchr (str, ';');
3477 } 3464 }
3478 3465
3479 if (changed) 3466 if (changed)
3480 { 3467 update_background ();
3481#ifdef XPM_BACKGROUND
3482 resize_pixmap ();
3483 scr_touch (true);
3484#endif
3485 } 3468 }
3486#if TRANSPARENT && defined(HAVE_AFTERIMAGE)
3487 if (option (Opt_transparent))
3488 check_our_parents ();
3489#endif
3490 }
3491 break; 3469 break;
3492 3470#endif
3493 case Rxvt_restoreFG:
3494 set_window_color (Color_fg, str);
3495 break;
3496 case Rxvt_restoreBG:
3497 set_window_color (Color_bg, str);
3498 break;
3499 3471
3500 case XTerm_logfile: 3472 case XTerm_logfile:
3501 // TODO, when secure mode? 3473 // TODO, when secure mode?
3502 break; 3474 break;
3503 3475
3618{ 3590{
3619 unsigned int i, j; 3591 unsigned int i, j;
3620 int state; 3592 int state;
3621 3593
3622 static const struct 3594 static const struct
3623 { 3595 {
3624 const int argval; 3596 const int argval;
3625 const unsigned long bit; 3597 const unsigned long bit;
3626 }
3627
3628 argtopriv[] = { 3598 } argtopriv[] = {
3629 { 1, PrivMode_aplCUR }, 3599 { 1, PrivMode_aplCUR },
3630 { 2, PrivMode_vt52 }, 3600 { 2, PrivMode_vt52 },
3631 { 3, PrivMode_132 }, 3601 { 3, PrivMode_132 },
3632 { 4, PrivMode_smoothScroll }, 3602 { 4, PrivMode_smoothScroll },
3633 { 5, PrivMode_rVideo }, 3603 { 5, PrivMode_rVideo },
3649 { 66, PrivMode_aplKP }, 3619 { 66, PrivMode_aplKP },
3650#ifndef NO_BACKSPACE_KEY 3620#ifndef NO_BACKSPACE_KEY
3651 { 67, PrivMode_BackSpace }, 3621 { 67, PrivMode_BackSpace },
3652#endif 3622#endif
3653 { 1000, PrivMode_MouseX11 }, 3623 { 1000, PrivMode_MouseX11 },
3654 // 1001 Use Hilite Mouse Tracking. NYI, TODO 3624 { 1002, PrivMode_MouseBtnEvent },
3655 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO 3625 { 1003, PrivMode_MouseAnyEvent },
3656 // 1003 Use All Motion Mouse Tracking. NYI, TODO
3657 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3626 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3658 { 1011, PrivMode_Keypress }, // rxvt extension 3627 { 1011, PrivMode_Keypress }, // rxvt extension
3659 // 1035 enable modifiers for alt, numlock NYI 3628 // 1035 enable modifiers for alt, numlock NYI
3660 // 1036 send ESC for meta keys NYI 3629 // 1036 send ESC for meta keys NYI
3661 // 1037 send DEL for keypad delete NYI 3630 // 1037 send DEL for keypad delete NYI
3662 { 1047, PrivMode_Screen }, 3631 { 1047, PrivMode_Screen },
3663 // 1048 save and restore cursor 3632 // 1048 save and restore cursor
3664 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ 3633 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
3665 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3634 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3635 { 2004, PrivMode_BracketPaste },
3666 }; 3636 };
3667 3637
3668 if (nargs == 0) 3638 if (nargs == 0)
3669 return; 3639 return;
3670 3640
3718 */ 3688 */
3719 PrivMode (1, PrivMode_vt52); 3689 PrivMode (1, PrivMode_vt52);
3720 break; 3690 break;
3721 case 3: /* 80/132 */ 3691 case 3: /* 80/132 */
3722 if (priv_modes & PrivMode_132OK) 3692 if (priv_modes & PrivMode_132OK)
3693 {
3694 scr_poweron ();
3723 set_widthheight (((state ? 132 : 80) * fwidth), height); 3695 set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight);
3696 }
3724 break; 3697 break;
3725 case 4: /* smooth scrolling */ 3698 case 4: /* smooth scrolling */
3726 set_option (Opt_jumpScroll, !state); 3699 set_option (Opt_jumpScroll, !state);
3727 break; 3700 break;
3728 case 5: /* reverse video */ 3701 case 5: /* reverse video */
3735 scr_autowrap (state); 3708 scr_autowrap (state);
3736 break; 3709 break;
3737 /* case 8: - auto repeat, can't do on a per window basis */ 3710 /* case 8: - auto repeat, can't do on a per window basis */
3738 case 9: /* X10 mouse reporting */ 3711 case 9: /* X10 mouse reporting */
3739 if (state) /* orthogonal */ 3712 if (state) /* orthogonal */
3740 priv_modes &= ~PrivMode_MouseX11; 3713 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3741 break; 3714 break;
3742#ifdef scrollBar_esc 3715#ifdef scrollBar_esc
3743 case scrollBar_esc: 3716 case scrollBar_esc:
3744 if (scrollbar_mapping (state)) 3717 if (scrollbar_mapping (state))
3745 { 3718 {
3758 break; 3731 break;
3759 /* case 66: - application key pad */ 3732 /* case 66: - application key pad */
3760 /* case 67: - backspace key */ 3733 /* case 67: - backspace key */
3761 case 1000: /* X11 mouse reporting */ 3734 case 1000: /* X11 mouse reporting */
3762 if (state) /* orthogonal */ 3735 if (state) /* orthogonal */
3763 priv_modes &= ~PrivMode_MouseX10; 3736 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3764 break; 3737 break;
3765#if 0
3766 case 1001: 3738 case 1002:
3767 break; /* X11 mouse highlighting */ 3739 case 1003:
3768#endif 3740 if (state)
3741 {
3742 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3743 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3744 vt_emask_mouse = PointerMotionMask;
3745 }
3746 else
3747 vt_emask_mouse = NoEventMask;
3748 vt_select_input ();
3749 break;
3769 case 1010: /* scroll to bottom on TTY output inhibit */ 3750 case 1010: /* scroll to bottom on TTY output inhibit */
3770 set_option (Opt_scrollTtyOutput, !state); 3751 set_option (Opt_scrollTtyOutput, !state);
3771 break; 3752 break;
3772 case 1011: /* scroll to bottom on key press */ 3753 case 1011: /* scroll to bottom on key press */
3773 set_option (Opt_scrollTtyKeypress, state); 3754 set_option (Opt_scrollTtyKeypress, state);
3950rxvt_term::process_graphics () 3931rxvt_term::process_graphics ()
3951{ 3932{
3952 unicode_t ch, cmd = cmd_getc (); 3933 unicode_t ch, cmd = cmd_getc ();
3953 3934
3954 if (cmd == 'Q') 3935 if (cmd == 'Q')
3936 {
3955 { /* query graphics */ 3937 /* query graphics */
3956 tt_printf ("\033G0\012"); /* no graphics */ 3938 tt_printf ("\033G0\012"); /* no graphics */
3957 return; 3939 return;
3958 } 3940 }
3959 /* swallow other graphics sequences until terminating ':' */ 3941 /* swallow other graphics sequences until terminating ':' */
3960 do 3942 do
4010 v_buffer = (char *)realloc (v_buffer, v_buflen + len); 3992 v_buffer = (char *)realloc (v_buffer, v_buflen + len);
4011 3993
4012 memcpy (v_buffer + v_buflen, data, len); 3994 memcpy (v_buffer + v_buflen, data, len);
4013 v_buflen += len; 3995 v_buflen += len;
4014 3996
4015 pty_ev.set (EVENT_READ | EVENT_WRITE); 3997 pty_ev.set (ev::READ | ev::WRITE);
4016} 3998}
4017 3999
4018void rxvt_term::pty_write () 4000void rxvt_term::pty_write ()
4019{ 4001{
4020 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 4002 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4025 4007
4026 if (v_buflen == 0) 4008 if (v_buflen == 0)
4027 { 4009 {
4028 free (v_buffer); 4010 free (v_buffer);
4029 v_buffer = 0; 4011 v_buffer = 0;
4030 v_buflen = 0;
4031 4012
4032 pty_ev.set (EVENT_READ); 4013 pty_ev.set (ev::READ);
4033 return; 4014 return;
4034 } 4015 }
4035 4016
4036 memmove (v_buffer, v_buffer + written, v_buflen); 4017 memmove (v_buffer, v_buffer + written, v_buflen);
4037 } 4018 }
4038 else if (written != -1 || (errno != EAGAIN && errno != EINTR)) 4019 else if (written != -1 || (errno != EAGAIN && errno != EINTR))
4039 pty_ev.set (EVENT_READ); 4020 pty_ev.set (ev::READ);
4040} 4021}
4041 4022
4042/*----------------------- end-of-file (C source) -----------------------*/ 4023/*----------------------- end-of-file (C source) -----------------------*/
4043 4024

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines