… | |
… | |
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 | |
… | |
… | |
279 | } |
279 | } |
280 | |
280 | |
281 | iso14755buf = 0; |
281 | iso14755buf = 0; |
282 | } |
282 | } |
283 | |
283 | |
284 | int |
284 | static int |
285 | rxvt_term::hex_keyval (XKeyEvent &ev) |
285 | hex_keyval (XKeyEvent &ev) |
286 | { |
286 | { |
287 | // check wether this event corresponds to a hex digit |
287 | // check wether this event corresponds to a hex digit |
288 | // if the modifiers had not been pressed. |
288 | // if the modifiers had not been pressed. |
289 | for (int index = 0; index < 8; index++) |
289 | for (int index = 0; index < 8; index++) |
290 | { |
290 | { |
… | |
… | |
298 | |
298 | |
299 | return -1; |
299 | return -1; |
300 | } |
300 | } |
301 | #endif |
301 | #endif |
302 | |
302 | |
|
|
303 | static inline KeySym |
|
|
304 | translate_keypad (KeySym keysym, bool kp) |
|
|
305 | { |
|
|
306 | #ifdef XK_KP_Home |
|
|
307 | static const KeySym keypadtrans[] = { |
|
|
308 | XK_KP_7, // XK_KP_Home |
|
|
309 | XK_KP_4, // XK_KP_Left |
|
|
310 | XK_KP_8, // XK_KP_Up |
|
|
311 | XK_KP_6, // XK_KP_Right |
|
|
312 | XK_KP_2, // XK_KP_Down |
|
|
313 | # ifndef UNSHIFTED_SCROLLKEYS |
|
|
314 | XK_KP_9, // XK_KP_Prior |
|
|
315 | XK_KP_3, // XK_KP_Next |
|
|
316 | # else |
|
|
317 | XK_Prior, |
|
|
318 | XK_Next, |
|
|
319 | # endif |
|
|
320 | XK_KP_1, // XK_KP_End |
|
|
321 | XK_KP_5, // XK_KP_Begin |
|
|
322 | }; |
|
|
323 | |
|
|
324 | if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) |
|
|
325 | { |
|
|
326 | unsigned int index = keysym - XK_KP_Home; |
|
|
327 | keysym = kp ? keypadtrans[index] : XK_Home + index; |
|
|
328 | } |
|
|
329 | else if (keysym == XK_KP_Insert) |
|
|
330 | keysym = kp ? XK_KP_0 : XK_Insert; |
|
|
331 | # ifndef NO_DELETE_KEY |
|
|
332 | else if (keysym == XK_KP_Delete) |
|
|
333 | keysym = kp ? XK_KP_Decimal : XK_Delete; |
|
|
334 | # endif |
|
|
335 | #endif |
|
|
336 | return keysym; |
|
|
337 | } |
|
|
338 | |
303 | void |
339 | void |
304 | rxvt_term::key_press (XKeyEvent &ev) |
340 | rxvt_term::key_press (XKeyEvent &ev) |
305 | { |
341 | { |
306 | int ctrl, meta, shft, len; |
342 | int ctrl, meta, shft, len; |
307 | unsigned int newlen; |
|
|
308 | KeySym keysym; |
343 | KeySym keysym; |
309 | int valid_keysym; |
344 | int valid_keysym; |
310 | char kbuf[KBUFSZ]; |
345 | char kbuf[KBUFSZ]; |
311 | |
346 | |
312 | #if ISO_14755 |
347 | #if ISO_14755 |
… | |
… | |
519 | # endif |
554 | # endif |
520 | return; |
555 | return; |
521 | } |
556 | } |
522 | else |
557 | else |
523 | { |
558 | { |
524 | # if ENABLE_OVERLAY |
559 | # if ISO_14755 |
525 | scr_overlay_off (); |
560 | scr_overlay_off (); |
526 | # endif |
561 | # endif |
527 | iso14755buf = 0; |
562 | iso14755buf = 0; |
528 | } |
563 | } |
529 | } |
564 | } |
530 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
565 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
531 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
566 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
532 | if (!(iso14755buf & ISO_14755_STARTED)) |
567 | if (!(iso14755buf & ISO_14755_STARTED)) |
533 | { |
568 | { |
534 | iso14755buf |= ISO_14755_STARTED; |
569 | iso14755buf |= ISO_14755_STARTED; |
535 | # if ENABLE_OVERLAY |
570 | # if ISO_14755 |
536 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
571 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
537 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
572 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
538 | # endif |
573 | # endif |
539 | } |
574 | } |
540 | #endif |
575 | #endif |
… | |
… | |
547 | } |
582 | } |
548 | #endif |
583 | #endif |
549 | |
584 | |
550 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
585 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
551 | { |
586 | { |
552 | { |
587 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
553 | newlen = 1; |
588 | unsigned int newlen = 1; |
554 | switch (keysym) |
589 | |
|
|
590 | switch (translate_keypad (keysym, kp)) |
555 | { |
591 | { |
556 | #ifndef NO_BACKSPACE_KEY |
592 | #ifndef NO_BACKSPACE_KEY |
557 | case XK_BackSpace: |
593 | case XK_BackSpace: |
558 | if (priv_modes & PrivMode_HaveBackSpace) |
594 | if (priv_modes & PrivMode_HaveBackSpace) |
559 | { |
595 | { |
560 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
596 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
561 | ^ !!ctrl) ? '\b' : '\177'; |
597 | ^ !!ctrl) ? '\b' : '\177'; |
562 | kbuf[1] = '\0'; |
598 | kbuf[1] = '\0'; |
563 | } |
599 | } |
564 | else |
600 | else |
565 | strcpy (kbuf, key_backspace); |
601 | strcpy (kbuf, rs[Rs_backspace_key]); |
566 | break; |
602 | break; |
567 | #endif |
603 | #endif |
568 | #ifndef NO_DELETE_KEY |
604 | #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: |
605 | case XK_Delete: |
580 | strcpy (kbuf, key_delete); |
606 | strcpy (kbuf, rs[Rs_delete_key]); |
581 | break; |
607 | break; |
582 | #endif |
608 | #endif |
583 | case XK_Tab: |
609 | case XK_Tab: |
584 | if (shft) |
610 | if (shft) |
585 | strcpy (kbuf, "\033[Z"); |
611 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
595 | #endif |
621 | #endif |
596 | newlen = 0; |
622 | newlen = 0; |
597 | } |
623 | } |
598 | break; |
624 | break; |
599 | |
625 | |
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" */ |
626 | case XK_Up: /* "\033[A" */ |
617 | case XK_Down: /* "\033[B" */ |
627 | case XK_Down: /* "\033[B" */ |
618 | case XK_Right: /* "\033[C" */ |
628 | case XK_Right: /* "\033[C" */ |
619 | case XK_Left: /* "\033[D" */ |
629 | case XK_Left: /* "\033[D" */ |
620 | strcpy (kbuf, "\033[Z"); |
630 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
630 | else if (priv_modes & PrivMode_aplCUR) |
640 | else if (priv_modes & PrivMode_aplCUR) |
631 | kbuf[1] = 'O'; |
641 | kbuf[1] = 'O'; |
632 | break; |
642 | break; |
633 | |
643 | |
634 | #ifndef UNSHIFTED_SCROLLKEYS |
644 | #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: |
645 | case XK_Prior: |
646 | strcpy (kbuf, "\033[5~"); |
646 | strcpy (kbuf, "\033[5~"); |
647 | break; |
647 | 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: |
648 | case XK_Next: |
659 | strcpy (kbuf, "\033[6~"); |
649 | strcpy (kbuf, "\033[6~"); |
660 | break; |
650 | break; |
661 | #endif |
651 | #endif |
662 | case XK_KP_Enter: |
652 | case XK_KP_Enter: |
663 | /* allow shift to override */ |
653 | /* allow shift to override */ |
664 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
654 | if (kp) |
665 | { |
655 | { |
666 | strcpy (kbuf, "\033OM"); |
656 | strcpy (kbuf, "\033OM"); |
667 | break; |
657 | break; |
668 | } |
658 | } |
669 | |
659 | |
… | |
… | |
681 | kbuf[0] = '\015'; |
671 | kbuf[0] = '\015'; |
682 | kbuf[1] = '\0'; |
672 | kbuf[1] = '\0'; |
683 | } |
673 | } |
684 | break; |
674 | break; |
685 | |
675 | |
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" */ |
676 | case XK_KP_F1: /* "\033OP" */ |
693 | case XK_KP_F2: /* "\033OQ" */ |
677 | case XK_KP_F2: /* "\033OQ" */ |
694 | case XK_KP_F3: /* "\033OR" */ |
678 | case XK_KP_F3: /* "\033OR" */ |
695 | case XK_KP_F4: /* "\033OS" */ |
679 | case XK_KP_F4: /* "\033OS" */ |
696 | strcpy (kbuf, "\033OP"); |
680 | strcpy (kbuf, "\033OP"); |
… | |
… | |
712 | case XK_KP_6: /* "\033Ov" : "6" */ |
696 | case XK_KP_6: /* "\033Ov" : "6" */ |
713 | case XK_KP_7: /* "\033Ow" : "7" */ |
697 | case XK_KP_7: /* "\033Ow" : "7" */ |
714 | case XK_KP_8: /* "\033Ox" : "8" */ |
698 | case XK_KP_8: /* "\033Ox" : "8" */ |
715 | case XK_KP_9: /* "\033Oy" : "9" */ |
699 | case XK_KP_9: /* "\033Oy" : "9" */ |
716 | /* allow shift to override */ |
700 | /* allow shift to override */ |
717 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
701 | if (kp) |
718 | { |
702 | { |
719 | strcpy (kbuf, "\033Oj"); |
703 | strcpy (kbuf, "\033Oj"); |
720 | kbuf[2] += (keysym - XK_KP_Multiply); |
704 | kbuf[2] += (keysym - XK_KP_Multiply); |
721 | } |
705 | } |
722 | else |
706 | else |
… | |
… | |
728 | |
712 | |
729 | case XK_Find: |
713 | case XK_Find: |
730 | strcpy (kbuf, "\033[1~"); |
714 | strcpy (kbuf, "\033[1~"); |
731 | break; |
715 | break; |
732 | |
716 | |
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: |
717 | case XK_Insert: |
744 | strcpy (kbuf, "\033[2~"); |
718 | strcpy (kbuf, "\033[2~"); |
745 | break; |
719 | break; |
746 | #ifdef DXK_Remove /* support for DEC remove like key */ |
720 | #ifdef DXK_Remove /* support for DEC remove like key */ |
747 | case DXK_Remove: |
721 | case DXK_Remove: |
… | |
… | |
751 | strcpy (kbuf, "\033[3~"); |
725 | strcpy (kbuf, "\033[3~"); |
752 | break; |
726 | break; |
753 | case XK_Select: |
727 | case XK_Select: |
754 | strcpy (kbuf, "\033[4~"); |
728 | strcpy (kbuf, "\033[4~"); |
755 | break; |
729 | 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: |
730 | case XK_End: |
767 | strcpy (kbuf, KS_END); |
731 | strcpy (kbuf, KS_END); |
768 | break; |
732 | 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: |
733 | case XK_Home: |
780 | strcpy (kbuf, KS_HOME); |
734 | strcpy (kbuf, KS_HOME); |
781 | break; |
735 | break; |
782 | |
736 | |
783 | #define FKEY(n, fkey) \ |
737 | #define FKEY(n, fkey) \ |
… | |
… | |
840 | break; |
794 | break; |
841 | } |
795 | } |
842 | |
796 | |
843 | if (newlen) |
797 | if (newlen) |
844 | len = strlen (kbuf); |
798 | len = strlen (kbuf); |
845 | } |
|
|
846 | |
799 | |
847 | /* |
800 | /* |
848 | * Pass meta for all function keys, if 'meta' option set |
801 | * Pass meta for all function keys, if 'meta' option set |
849 | */ |
802 | */ |
850 | #ifdef META8_OPTION |
803 | #ifdef META8_OPTION |
… | |
… | |
934 | #if ENABLE_FRILLS || ISO_14755 |
887 | #if ENABLE_FRILLS || ISO_14755 |
935 | // ISO 14755 support |
888 | // ISO 14755 support |
936 | if (iso14755buf) |
889 | if (iso14755buf) |
937 | if (iso14755buf & ISO_14755_52) |
890 | if (iso14755buf & ISO_14755_52) |
938 | { |
891 | { |
939 | # if ENABLE_OVERLAY |
892 | # if ISO_14755 |
940 | scr_overlay_off (); |
893 | scr_overlay_off (); |
941 | # endif |
894 | # endif |
942 | # if ISO_14755 |
895 | # if ISO_14755 |
943 | // iso14755 part 5.2 handling: release time |
896 | // iso14755 part 5.2 handling: release time |
944 | // first: controls |
897 | // first: controls |
… | |
… | |
967 | |
920 | |
968 | return; |
921 | return; |
969 | } |
922 | } |
970 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
923 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
971 | { |
924 | { |
972 | # if ENABLE_OVERLAY |
925 | # if ISO_14755 |
973 | scr_overlay_off (); |
926 | scr_overlay_off (); |
974 | # endif |
927 | # endif |
975 | if (iso14755buf & ISO_14755_51) |
928 | if (iso14755buf & ISO_14755_51) |
976 | commit_iso14755 (); |
929 | commit_iso14755 (); |
977 | #if ISO_14755 |
930 | #if ISO_14755 |
… | |
… | |
1035 | void |
988 | void |
1036 | rxvt_term::flush () |
989 | rxvt_term::flush () |
1037 | { |
990 | { |
1038 | flush_ev.stop (); |
991 | flush_ev.stop (); |
1039 | |
992 | |
1040 | #ifdef TRANSPARENT |
993 | #ifdef HAVE_BG_PIXMAP |
1041 | if (want_full_refresh) |
994 | if (bgPixmap.check_clearChanged ()) |
1042 | { |
995 | { |
1043 | want_full_refresh = 0; |
996 | // scr_clear (true); This needs to be researched further! |
1044 | scr_clear (); |
|
|
1045 | scr_touch (false); |
997 | scr_touch (false); |
1046 | } |
998 | } |
1047 | #endif |
999 | #endif |
1048 | |
1000 | |
1049 | if (want_refresh) |
1001 | if (want_refresh) |
… | |
… | |
1094 | } |
1046 | } |
1095 | |
1047 | |
1096 | display->flush (); |
1048 | display->flush (); |
1097 | } |
1049 | } |
1098 | |
1050 | |
|
|
1051 | /* checks wether a refresh is requested and starts the refresh timer */ |
1099 | void |
1052 | void |
1100 | rxvt_term::check_cb (check_watcher &w) |
1053 | rxvt_term::refresh_check () |
|
|
1054 | { |
|
|
1055 | if (want_refresh && !flush_ev.is_active ()) |
|
|
1056 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
|
|
1057 | |
|
|
1058 | display->flush (); |
|
|
1059 | } |
|
|
1060 | |
|
|
1061 | void |
|
|
1062 | rxvt_term::flush_cb (ev::timer &w, int revents) |
1101 | { |
1063 | { |
1102 | make_current (); |
1064 | make_current (); |
1103 | |
1065 | |
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 | |
|
|
1110 | void |
|
|
1111 | rxvt_term::flush_cb (time_watcher &w) |
|
|
1112 | { |
|
|
1113 | make_current (); |
|
|
1114 | |
|
|
1115 | refresh_limit = 1; |
|
|
1116 | refresh_count = 0; |
1066 | refresh_count = 0; |
1117 | flush (); |
1067 | flush (); |
1118 | } |
1068 | } |
1119 | |
1069 | |
1120 | #ifdef CURSOR_BLINK |
1070 | #ifdef CURSOR_BLINK |
1121 | void |
1071 | void |
1122 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1072 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
1123 | { |
1073 | { |
1124 | hidden_cursor = !hidden_cursor; |
1074 | hidden_cursor = !hidden_cursor; |
1125 | want_refresh = 1; |
1075 | want_refresh = 1; |
1126 | |
1076 | refresh_check (); |
1127 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
|
|
1128 | } |
1077 | } |
1129 | #endif |
1078 | #endif |
1130 | |
1079 | |
1131 | #ifdef TEXT_BLINK |
1080 | #ifdef TEXT_BLINK |
1132 | void |
1081 | void |
1133 | rxvt_term::text_blink_cb (time_watcher &w) |
1082 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
1134 | { |
1083 | { |
1135 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1084 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1136 | { |
1085 | { |
1137 | hidden_text = !hidden_text; |
1086 | hidden_text = !hidden_text; |
1138 | want_refresh = 1; |
1087 | want_refresh = 1; |
1139 | w.start (w.at + TEXT_BLINK_INTERVAL); |
1088 | refresh_check (); |
1140 | } |
1089 | } |
|
|
1090 | else |
|
|
1091 | w.stop (); |
1141 | } |
1092 | } |
1142 | #endif |
1093 | #endif |
1143 | |
1094 | |
1144 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1095 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1145 | void |
1096 | void |
1146 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1097 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1147 | { |
1098 | { |
1148 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1099 | if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
1149 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1100 | && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1)) |
1150 | { |
1101 | { |
1151 | want_refresh = 1; |
1102 | want_refresh = 1; |
1152 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1103 | refresh_check (); |
1153 | } |
1104 | } |
|
|
1105 | else |
|
|
1106 | w.stop (); |
1154 | } |
1107 | } |
1155 | #endif |
1108 | #endif |
1156 | |
1109 | |
1157 | #ifdef SELECTION_SCROLLING |
1110 | #ifdef SELECTION_SCROLLING |
1158 | void |
1111 | void |
1159 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1112 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1160 | { |
1113 | { |
1161 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1114 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1162 | { |
1115 | { |
1163 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1116 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1164 | want_refresh = 1; |
1117 | want_refresh = 1; |
1165 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1118 | refresh_check (); |
1166 | } |
1119 | } |
|
|
1120 | else |
|
|
1121 | w.stop (); |
1167 | } |
1122 | } |
1168 | #endif |
1123 | #endif |
1169 | |
1124 | |
1170 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1125 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1171 | void |
1126 | void |
1172 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1127 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1173 | { |
1128 | { |
1174 | if (mouse_slip_wheel_speed == 0 |
1129 | 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 | { |
1130 | { |
1178 | if (view_start == top_row || view_start == 0) |
|
|
1179 | mouse_slip_wheel_speed = 0; |
|
|
1180 | |
|
|
1181 | want_refresh = 1; |
1131 | want_refresh = 1; |
1182 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1132 | refresh_check (); |
|
|
1133 | } |
|
|
1134 | |
|
|
1135 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
|
|
1136 | { |
|
|
1137 | mouse_slip_wheel_speed = 0; |
|
|
1138 | w.stop (); |
1183 | } |
1139 | } |
1184 | } |
1140 | } |
1185 | #endif |
1141 | #endif |
1186 | |
1142 | |
1187 | #if LINUX_YIELD_HACK |
1143 | #if LINUX_YIELD_HACK |
1188 | static struct event_handler |
1144 | static struct event_handler |
1189 | { |
1145 | { |
1190 | check_watcher yield_ev; |
1146 | ev::prepare yield_ev; |
1191 | |
1147 | |
1192 | void yield_cb (check_watcher &w) |
1148 | void yield_cb (ev::prepare &w, int revents) |
1193 | { |
1149 | { |
1194 | // this should really be sched_yield(), but the linux guys thought |
1150 | // this should really be sched_yield(), but the linux guys thought |
1195 | // that giving a process calling sched_yield () less cpu time than |
1151 | // 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 |
1152 | // ones with high nice levels is a useful thing to do. It surely is is |
1197 | // allowed by the sus... as is returning ENOSYS. |
1153 | // allowed by the sus... as is returning ENOSYS. |
… | |
… | |
1248 | |
1204 | |
1249 | return false; |
1205 | return false; |
1250 | } |
1206 | } |
1251 | |
1207 | |
1252 | void |
1208 | void |
1253 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1209 | rxvt_term::pty_cb (ev::io &w, int revents) |
1254 | { |
1210 | { |
1255 | make_current (); |
1211 | make_current (); |
1256 | |
1212 | |
1257 | if (revents & EVENT_READ) |
1213 | if (revents & ev::READ) |
1258 | // loop, but don't allow a single term to monopolize us |
1214 | // loop, but don't allow a single term to monopolize us |
1259 | while (pty_fill ()) |
1215 | while (pty_fill ()) |
1260 | if (cmd_parse ()) |
1216 | if (cmd_parse ()) |
1261 | break; |
1217 | break; |
1262 | |
1218 | |
1263 | if (revents & EVENT_WRITE) |
1219 | if (revents & ev::WRITE) |
1264 | pty_write (); |
1220 | pty_write (); |
|
|
1221 | |
|
|
1222 | refresh_check (); |
1265 | } |
1223 | } |
1266 | |
1224 | |
1267 | void |
1225 | void |
1268 | rxvt_term::pointer_unblank () |
1226 | rxvt_term::pointer_unblank () |
1269 | { |
1227 | { |
… | |
… | |
1272 | |
1230 | |
1273 | #ifdef POINTER_BLANK |
1231 | #ifdef POINTER_BLANK |
1274 | hidden_pointer = 0; |
1232 | hidden_pointer = 0; |
1275 | |
1233 | |
1276 | if (option (Opt_pointerBlank)) |
1234 | if (option (Opt_pointerBlank)) |
1277 | pointer_ev.start (NOW + pointerBlankDelay); |
1235 | pointer_ev.start (pointerBlankDelay); |
1278 | #endif |
1236 | #endif |
1279 | } |
1237 | } |
1280 | |
1238 | |
1281 | #ifdef POINTER_BLANK |
1239 | #ifdef POINTER_BLANK |
1282 | void |
1240 | void |
… | |
… | |
1290 | |
1248 | |
1291 | hidden_pointer = 1; |
1249 | hidden_pointer = 1; |
1292 | } |
1250 | } |
1293 | |
1251 | |
1294 | void |
1252 | void |
1295 | rxvt_term::pointer_cb (time_watcher &w) |
1253 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1296 | { |
1254 | { |
1297 | make_current (); |
1255 | make_current (); |
1298 | |
1256 | |
1299 | pointer_blank (); |
1257 | pointer_blank (); |
1300 | } |
1258 | } |
… | |
… | |
1303 | void |
1261 | void |
1304 | rxvt_term::mouse_report (XButtonEvent &ev) |
1262 | rxvt_term::mouse_report (XButtonEvent &ev) |
1305 | { |
1263 | { |
1306 | int button_number, key_state = 0; |
1264 | int button_number, key_state = 0; |
1307 | int x, y; |
1265 | int x, y; |
|
|
1266 | int code = 32; |
1308 | |
1267 | |
1309 | x = ev.x; |
1268 | x = Pixel2Col (ev.x); |
1310 | y = ev.y; |
1269 | y = Pixel2Row (ev.y); |
1311 | pixel_position (&x, &y); |
1270 | if (ev.type == MotionNotify) |
|
|
1271 | { |
|
|
1272 | if (x == mouse_row && y == mouse_col) |
|
|
1273 | return; |
|
|
1274 | mouse_row = x; |
|
|
1275 | mouse_col = y; |
|
|
1276 | code += 32; |
|
|
1277 | } |
1312 | |
1278 | |
1313 | if (MEvent.button == AnyButton) |
1279 | if (MEvent.button == AnyButton) |
1314 | button_number = 3; |
1280 | button_number = 3; |
1315 | else |
1281 | else |
1316 | { |
1282 | { |
… | |
… | |
1362 | x + 1, |
1328 | x + 1, |
1363 | y + 1); |
1329 | y + 1); |
1364 | #endif |
1330 | #endif |
1365 | |
1331 | |
1366 | tt_printf ("\033[M%c%c%c", |
1332 | tt_printf ("\033[M%c%c%c", |
1367 | (32 + button_number + key_state), |
1333 | (code + button_number + key_state), |
1368 | (32 + x + 1), |
1334 | (32 + x + 1), |
1369 | (32 + y + 1)); |
1335 | (32 + y + 1)); |
1370 | } |
1336 | } |
1371 | |
1337 | |
1372 | /*{{{ process an X event */ |
1338 | /*{{{ process an X event */ |
… | |
… | |
1434 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
1400 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
1435 | focus_out (); |
1401 | focus_out (); |
1436 | } |
1402 | } |
1437 | #endif |
1403 | #endif |
1438 | } |
1404 | } |
1439 | break; |
|
|
1440 | |
|
|
1441 | case MappingNotify: |
|
|
1442 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1443 | break; |
1405 | break; |
1444 | |
1406 | |
1445 | /* |
1407 | /* |
1446 | * XXX: this is not the _current_ arrangement |
1408 | * XXX: this is not the _current_ arrangement |
1447 | * Here's my conclusion: |
1409 | * Here's my conclusion: |
… | |
… | |
1480 | && ev.xfocus.mode != NotifyGrab) |
1442 | && ev.xfocus.mode != NotifyGrab) |
1481 | focus_out (); |
1443 | focus_out (); |
1482 | break; |
1444 | break; |
1483 | |
1445 | |
1484 | case ConfigureNotify: |
1446 | case ConfigureNotify: |
|
|
1447 | /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", |
|
|
1448 | ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, |
|
|
1449 | szHint.width, szHint.height);*/ |
1485 | if (ev.xconfigure.window == parent[0]) |
1450 | if (ev.xconfigure.window == parent[0]) |
1486 | { |
1451 | { |
1487 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1452 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1488 | ; |
1453 | ; |
1489 | |
1454 | |
1490 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1455 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1491 | { |
1456 | { |
1492 | seen_resize = 1; |
1457 | seen_resize = 1; |
1493 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1458 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1494 | #ifdef XPM_BACKGROUND |
1459 | } |
1495 | if (!option (Opt_transparent) && bgPixmap.auto_resize) |
1460 | else |
|
|
1461 | { |
|
|
1462 | #ifdef HAVE_BG_PIXMAP |
|
|
1463 | if (bgPixmap.window_position_sensitive ()) |
1496 | { |
1464 | { |
|
|
1465 | if (mapped) |
|
|
1466 | update_background (); |
1497 | resize_pixmap (); |
1467 | else |
1498 | scr_touch (true); |
1468 | bgPixmap.invalidate (); |
1499 | } |
1469 | } |
1500 | #endif |
1470 | #endif |
1501 | } |
1471 | } |
1502 | |
1472 | |
1503 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1473 | 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 | } |
1474 | } |
1510 | break; |
1475 | break; |
1511 | |
1476 | |
1512 | case PropertyNotify: |
1477 | case PropertyNotify: |
1513 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1478 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
… | |
… | |
1529 | case SelectionRequest: |
1494 | case SelectionRequest: |
1530 | selection_send (ev.xselectionrequest); |
1495 | selection_send (ev.xselectionrequest); |
1531 | break; |
1496 | break; |
1532 | |
1497 | |
1533 | case MapNotify: |
1498 | case MapNotify: |
|
|
1499 | #ifdef HAVE_BG_PIXMAP |
|
|
1500 | /* This is needed spcifically to fix the case of no window manager or a |
|
|
1501 | * non-reparenting window manager. In those cases we never get first |
|
|
1502 | * ConfigureNotify. Also that speeds startup under normal WM, by taking |
|
|
1503 | * care of multiplicity of ConfigureNotify events arriwing while WM does |
|
|
1504 | * reparenting. |
|
|
1505 | * We should not render background immidiately, as there could be several |
|
|
1506 | * ConfigureNotify's to follow. Lets take care of all of them in one scoop |
|
|
1507 | * by scheduling background redraw as soon as we can, but giving a short |
|
|
1508 | * bit of time for ConfigureNotifies to arrive. |
|
|
1509 | * We should render background PRIOR to drawing any text, but AFTER all |
|
|
1510 | * of ConfigureNotifys for the best results. |
|
|
1511 | */ |
|
|
1512 | if (bgPixmap.flags & bgPixmap_t::isInvalid) |
|
|
1513 | update_background_ev.start (0.025); |
|
|
1514 | #endif |
1534 | mapped = 1; |
1515 | mapped = 1; |
1535 | #ifdef TEXT_BLINK |
1516 | #ifdef TEXT_BLINK |
1536 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
1517 | text_blink_ev.start (); |
1537 | #endif |
1518 | #endif |
1538 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1519 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1539 | break; |
1520 | break; |
1540 | |
1521 | |
1541 | case UnmapNotify: |
1522 | case UnmapNotify: |
… | |
… | |
1543 | #ifdef TEXT_BLINK |
1524 | #ifdef TEXT_BLINK |
1544 | text_blink_ev.stop (); |
1525 | text_blink_ev.stop (); |
1545 | #endif |
1526 | #endif |
1546 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1527 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1547 | break; |
1528 | break; |
1548 | |
|
|
1549 | #ifdef TRANSPARENT |
|
|
1550 | case ReparentNotify: |
|
|
1551 | rootwin_cb (ev); |
|
|
1552 | break; |
|
|
1553 | #endif /* TRANSPARENT */ |
|
|
1554 | |
1529 | |
1555 | case GraphicsExpose: |
1530 | case GraphicsExpose: |
1556 | case Expose: |
1531 | case Expose: |
1557 | if (ev.xany.window == vt) |
1532 | if (ev.xany.window == vt) |
1558 | { |
1533 | { |
1559 | do |
1534 | do |
|
|
1535 | { |
1560 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1536 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1561 | ev.xexpose.width, ev.xexpose.height, False); |
1537 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1538 | } |
1562 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1539 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1563 | |
1540 | |
1564 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1541 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1565 | |
1542 | |
1566 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1543 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1544 | { |
1567 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1545 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1568 | ev.xexpose.width, ev.xexpose.height, False); |
1546 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1547 | } |
1569 | |
1548 | |
1570 | want_refresh = 1; |
1549 | want_refresh = 1; |
1571 | } |
1550 | } |
1572 | else |
1551 | else |
1573 | { |
1552 | { |
… | |
… | |
1576 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1555 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1577 | ; |
1556 | ; |
1578 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1557 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1579 | ; |
1558 | ; |
1580 | |
1559 | |
1581 | if (isScrollbarWindow (ev.xany.window)) |
1560 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1582 | { |
1561 | { |
1583 | scrollBar.setIdle (); |
1562 | scrollBar.state = STATE_IDLE; |
1584 | scrollbar_show (0); |
1563 | scrollbar_show (0); |
1585 | } |
1564 | } |
1586 | |
|
|
1587 | #ifdef TRANSPARENT |
|
|
1588 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1589 | XClearWindow (dpy, ev.xany.window); |
|
|
1590 | #endif |
|
|
1591 | } |
1565 | } |
1592 | break; |
1566 | break; |
1593 | |
1567 | |
1594 | case MotionNotify: |
1568 | case MotionNotify: |
1595 | #ifdef POINTER_BLANK |
1569 | #ifdef POINTER_BLANK |
1596 | if (hidden_pointer) |
1570 | if (hidden_pointer) |
1597 | pointer_unblank (); |
1571 | pointer_unblank (); |
1598 | #endif |
1572 | #endif |
|
|
1573 | if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
|
|
1574 | || priv_modes & PrivMode_MouseAnyEvent) |
|
|
1575 | mouse_report (ev.xbutton); |
1599 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1576 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1600 | break; |
1577 | break; |
1601 | |
1578 | |
1602 | if (ev.xany.window == vt) |
1579 | if (ev.xany.window == vt) |
1603 | { |
1580 | { |
… | |
… | |
1637 | int dist; |
1614 | int dist; |
1638 | |
1615 | |
1639 | /* don't clobber the current delay if we are |
1616 | /* don't clobber the current delay if we are |
1640 | * already in the middle of scrolling. |
1617 | * already in the middle of scrolling. |
1641 | */ |
1618 | */ |
1642 | if (!sel_scroll_ev.active) |
1619 | if (!sel_scroll_ev.is_active ()) |
1643 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1620 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1644 | |
1621 | |
1645 | /* save the event params so we can highlight |
1622 | /* save the event params so we can highlight |
1646 | * the selection in the pending-scroll loop |
1623 | * the selection in the pending-scroll loop |
1647 | */ |
1624 | */ |
1648 | selection_save_x = ev.xbutton.x; |
1625 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1670 | else |
1647 | else |
1671 | { |
1648 | { |
1672 | /* we are within the text window, so we |
1649 | /* we are within the text window, so we |
1673 | * shouldn't be scrolling |
1650 | * shouldn't be scrolling |
1674 | */ |
1651 | */ |
1675 | if (sel_scroll_ev.active) |
|
|
1676 | sel_scroll_ev.stop(); |
1652 | sel_scroll_ev.stop(); |
1677 | } |
1653 | } |
1678 | #endif |
1654 | #endif |
1679 | #ifdef MOUSE_THRESHOLD |
1655 | #ifdef MOUSE_THRESHOLD |
1680 | } |
1656 | } |
1681 | #endif |
1657 | #endif |
1682 | } |
1658 | } |
1683 | } |
1659 | } |
1684 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1660 | else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) |
1685 | { |
1661 | { |
1686 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1662 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1687 | MotionNotify, &ev)) |
1663 | MotionNotify, &ev)) |
1688 | ; |
1664 | ; |
1689 | |
1665 | |
… | |
… | |
1693 | &ev.xbutton.x, &ev.xbutton.y, |
1669 | &ev.xbutton.x, &ev.xbutton.y, |
1694 | &unused_mask); |
1670 | &unused_mask); |
1695 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1671 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1696 | scrollbar_size ()); |
1672 | scrollbar_size ()); |
1697 | want_refresh = 1; |
1673 | want_refresh = 1; |
1698 | refresh_limit = 0; |
|
|
1699 | scrollbar_show (1); |
1674 | scrollbar_show (1); |
1700 | } |
1675 | } |
1701 | break; |
1676 | break; |
1702 | } |
1677 | } |
1703 | |
1678 | |
… | |
… | |
1708 | { |
1683 | { |
1709 | hidden_cursor = 0; |
1684 | hidden_cursor = 0; |
1710 | want_refresh = 1; |
1685 | want_refresh = 1; |
1711 | } |
1686 | } |
1712 | |
1687 | |
1713 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1688 | cursor_blink_ev.again (); |
1714 | } |
1689 | } |
1715 | #endif |
1690 | #endif |
1716 | |
1691 | |
1717 | #if defined(POINTER_BLANK) |
1692 | #if defined(POINTER_BLANK) |
1718 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1693 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
… | |
… | |
1725 | |
1700 | |
1726 | if (ev.type == KeyPress && hidden_pointer == 0) |
1701 | if (ev.type == KeyPress && hidden_pointer == 0) |
1727 | pointer_blank (); |
1702 | pointer_blank (); |
1728 | } |
1703 | } |
1729 | #endif |
1704 | #endif |
|
|
1705 | |
|
|
1706 | refresh_check (); |
1730 | } |
1707 | } |
1731 | |
1708 | |
1732 | void |
1709 | void |
1733 | rxvt_term::focus_in () |
1710 | rxvt_term::focus_in () |
1734 | { |
1711 | { |
… | |
… | |
1746 | XSetICFocus (Input_Context); |
1723 | XSetICFocus (Input_Context); |
1747 | } |
1724 | } |
1748 | #endif |
1725 | #endif |
1749 | #if CURSOR_BLINK |
1726 | #if CURSOR_BLINK |
1750 | if (option (Opt_cursorBlink)) |
1727 | if (option (Opt_cursorBlink)) |
1751 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1728 | cursor_blink_ev.again (); |
1752 | #endif |
1729 | #endif |
1753 | #if OFF_FOCUS_FADING |
1730 | #if OFF_FOCUS_FADING |
1754 | if (rs[Rs_fade]) |
1731 | if (rs[Rs_fade]) |
1755 | { |
1732 | { |
1756 | pix_colors = pix_colors_focused; |
1733 | pix_colors = pix_colors_focused; |
… | |
… | |
1758 | } |
1735 | } |
1759 | #endif |
1736 | #endif |
1760 | #if ENABLE_FRILLS |
1737 | #if ENABLE_FRILLS |
1761 | if (option (Opt_urgentOnBell)) |
1738 | if (option (Opt_urgentOnBell)) |
1762 | { |
1739 | { |
1763 | XWMHints *h; |
|
|
1764 | |
|
|
1765 | h = XGetWMHints(dpy, parent[0]); |
1740 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
1766 | if (h != NULL) |
|
|
1767 | { |
1741 | { |
1768 | h->flags &= ~XUrgencyHint; |
1742 | h->flags &= ~XUrgencyHint; |
1769 | XSetWMHints(dpy, parent[0], h); |
1743 | XSetWMHints (dpy, parent[0], h); |
1770 | } |
1744 | } |
1771 | } |
1745 | } |
1772 | #endif |
1746 | #endif |
1773 | } |
1747 | } |
1774 | } |
1748 | } |
… | |
… | |
1785 | |
1759 | |
1786 | #if ENABLE_FRILLS || ISO_14755 |
1760 | #if ENABLE_FRILLS || ISO_14755 |
1787 | if (iso14755buf) |
1761 | if (iso14755buf) |
1788 | { |
1762 | { |
1789 | iso14755buf = 0; |
1763 | iso14755buf = 0; |
1790 | # if ENABLE_OVERLAY |
1764 | # if ISO_14755 |
1791 | scr_overlay_off (); |
1765 | scr_overlay_off (); |
1792 | # endif |
1766 | # endif |
1793 | } |
1767 | } |
1794 | #endif |
1768 | #endif |
1795 | #if USE_XIM |
1769 | #if USE_XIM |
… | |
… | |
1797 | XUnsetICFocus (Input_Context); |
1771 | XUnsetICFocus (Input_Context); |
1798 | #endif |
1772 | #endif |
1799 | #if CURSOR_BLINK |
1773 | #if CURSOR_BLINK |
1800 | if (option (Opt_cursorBlink)) |
1774 | if (option (Opt_cursorBlink)) |
1801 | cursor_blink_ev.stop (); |
1775 | cursor_blink_ev.stop (); |
|
|
1776 | |
1802 | hidden_cursor = 0; |
1777 | hidden_cursor = 0; |
1803 | #endif |
1778 | #endif |
1804 | #if OFF_FOCUS_FADING |
1779 | #if OFF_FOCUS_FADING |
1805 | if (rs[Rs_fade]) |
1780 | if (rs[Rs_fade]) |
1806 | { |
1781 | { |
… | |
… | |
1822 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
1797 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
1823 | } |
1798 | } |
1824 | #endif |
1799 | #endif |
1825 | } |
1800 | } |
1826 | |
1801 | |
1827 | #if TRANSPARENT || ENABLE_PERL |
1802 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1828 | void |
1803 | void |
1829 | rxvt_term::rootwin_cb (XEvent &ev) |
1804 | rxvt_term::rootwin_cb (XEvent &ev) |
1830 | { |
1805 | { |
1831 | make_current (); |
1806 | make_current (); |
1832 | |
1807 | |
1833 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
1808 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
1834 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
1809 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
1835 | return; |
1810 | return; |
1836 | |
1811 | |
1837 | # if TRANSPARENT |
1812 | # if ENABLE_TRANSPARENCY |
1838 | switch (ev.type) |
1813 | switch (ev.type) |
1839 | { |
1814 | { |
1840 | case PropertyNotify: |
1815 | case PropertyNotify: |
1841 | /* |
1816 | /* |
1842 | * if user used some Esetroot compatible prog to set the root bg, |
1817 | * 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. |
1818 | * use the property to determine the pixmap. We use it later on. |
1844 | */ |
1819 | */ |
1845 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1820 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1846 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1821 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1847 | return; |
1822 | { |
|
|
1823 | bgPixmap.set_root_pixmap (); |
|
|
1824 | update_background (); |
|
|
1825 | } |
1848 | |
1826 | |
1849 | /* FALLTHROUGH */ |
|
|
1850 | case ReparentNotify: |
|
|
1851 | if (option (Opt_transparent)) |
|
|
1852 | check_our_parents (); |
|
|
1853 | break; |
1827 | break; |
1854 | } |
1828 | } |
1855 | # endif |
1829 | # endif |
|
|
1830 | |
|
|
1831 | refresh_check (); |
1856 | } |
1832 | } |
1857 | #endif |
1833 | #endif |
1858 | |
1834 | |
1859 | void |
1835 | void |
1860 | rxvt_term::button_press (XButtonEvent &ev) |
1836 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1915 | mouse_report (ev); |
1891 | mouse_report (ev); |
1916 | } |
1892 | } |
1917 | #else |
1893 | #else |
1918 | MEvent.button = ev.button; |
1894 | MEvent.button = ev.button; |
1919 | mouse_report (ev); |
1895 | mouse_report (ev); |
1920 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1896 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1921 | |
1897 | |
1922 | } |
1898 | } |
1923 | else |
1899 | else |
1924 | { |
1900 | { |
1925 | if (ev.button != MEvent.button) |
1901 | if (ev.button != MEvent.button) |
… | |
… | |
1973 | } |
1949 | } |
1974 | |
1950 | |
1975 | /* |
1951 | /* |
1976 | * Scrollbar window processing of button press |
1952 | * Scrollbar window processing of button press |
1977 | */ |
1953 | */ |
1978 | if (isScrollbarWindow (ev.window)) |
1954 | if (scrollBar.state && ev.window == scrollBar.win) |
1979 | { |
1955 | { |
1980 | scrollBar.setIdle (); |
1956 | page_dirn direction = NO_DIR; |
|
|
1957 | |
|
|
1958 | if (scrollBar.upButton (ev.y)) |
|
|
1959 | direction = UP; /* up */ |
|
|
1960 | else if (scrollBar.dnButton (ev.y)) |
|
|
1961 | direction = DN; /* down */ |
|
|
1962 | |
|
|
1963 | scrollBar.state = STATE_IDLE; |
1981 | /* |
1964 | /* |
1982 | * Rxvt-style scrollbar: |
1965 | * Rxvt-style scrollbar: |
1983 | * move up if mouse is above slider |
1966 | * move up if mouse is above slider |
1984 | * move dn if mouse is below slider |
1967 | * move dn if mouse is below slider |
1985 | * |
1968 | * |
… | |
… | |
1994 | /* |
1977 | /* |
1995 | * Mouse report disabled scrollbar: |
1978 | * Mouse report disabled scrollbar: |
1996 | * arrow buttons - send up/down |
1979 | * arrow buttons - send up/down |
1997 | * click on scrollbar - send pageup/down |
1980 | * click on scrollbar - send pageup/down |
1998 | */ |
1981 | */ |
1999 | if ((scrollBar.style == R_SB_NEXT |
1982 | if (direction == UP) |
2000 | && scrollbarnext_upButton (ev.y)) |
|
|
2001 | || (scrollBar.style == R_SB_RXVT |
|
|
2002 | && scrollbarrxvt_upButton (ev.y))) |
|
|
2003 | tt_printf ("\033[A"); |
1983 | tt_printf ("\033[A"); |
2004 | else if ((scrollBar.style == R_SB_NEXT |
1984 | else if (direction == DN) |
2005 | && scrollbarnext_dnButton (ev.y)) |
|
|
2006 | || (scrollBar.style == R_SB_RXVT |
|
|
2007 | && scrollbarrxvt_dnButton (ev.y))) |
|
|
2008 | tt_printf ("\033[B"); |
1985 | tt_printf ("\033[B"); |
2009 | else |
1986 | else |
2010 | switch (ev.button) |
1987 | switch (ev.button) |
2011 | { |
1988 | { |
2012 | case Button2: |
1989 | case Button2: |
… | |
… | |
2019 | tt_printf ("\033[5~"); |
1996 | tt_printf ("\033[5~"); |
2020 | break; |
1997 | break; |
2021 | } |
1998 | } |
2022 | } |
1999 | } |
2023 | else |
2000 | else |
2024 | #endif /* NO_SCROLLBAR_REPORT */ |
2001 | #endif /* NO_SCROLLBAR_REPORT */ |
2025 | |
|
|
2026 | { |
|
|
2027 | char upordown = 0; |
|
|
2028 | |
|
|
2029 | if (scrollBar.style == R_SB_NEXT) |
|
|
2030 | { |
2002 | { |
2031 | if (scrollbarnext_upButton (ev.y)) |
2003 | if (direction != NO_DIR) |
2032 | upordown = -1; /* up */ |
|
|
2033 | else if (scrollbarnext_dnButton (ev.y)) |
|
|
2034 | upordown = 1; /* down */ |
|
|
2035 | } |
|
|
2036 | else if (scrollBar.style == R_SB_RXVT) |
|
|
2037 | { |
|
|
2038 | if (scrollbarrxvt_upButton (ev.y)) |
|
|
2039 | upordown = -1; /* up */ |
|
|
2040 | else if (scrollbarrxvt_dnButton (ev.y)) |
|
|
2041 | upordown = 1; /* down */ |
|
|
2042 | } |
|
|
2043 | if (upordown) |
|
|
2044 | { |
2004 | { |
2045 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
2005 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2006 | if (!cont_scroll_ev.is_active ()) |
2046 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
2007 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2047 | #endif |
2008 | #endif |
2048 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
2009 | if (scr_page (direction, 1)) |
2049 | { |
2010 | { |
2050 | if (upordown < 0) |
2011 | if (direction == UP) |
2051 | scrollBar.setUp (); |
2012 | scrollBar.state = STATE_UP; |
2052 | else |
2013 | else |
2053 | scrollBar.setDn (); |
2014 | scrollBar.state = STATE_DOWN; |
2054 | } |
2015 | } |
2055 | } |
2016 | } |
2056 | else |
2017 | else |
2057 | switch (ev.button) |
2018 | switch (ev.button) |
2058 | { |
2019 | { |
2059 | case Button2: |
2020 | case Button2: |
2060 | switch (scrollbar_align) |
2021 | switch (scrollBar.align) |
2061 | { |
2022 | { |
2062 | case R_SB_ALIGN_TOP: |
2023 | case R_SB_ALIGN_TOP: |
2063 | csrO = 0; |
2024 | csrO = 0; |
2064 | break; |
2025 | break; |
2065 | case R_SB_ALIGN_CENTRE: |
2026 | case R_SB_ALIGN_CENTRE: |
… | |
… | |
2073 | if (scrollBar.style == R_SB_XTERM |
2034 | if (scrollBar.style == R_SB_XTERM |
2074 | || scrollbar_above_slider (ev.y) |
2035 | || scrollbar_above_slider (ev.y) |
2075 | || scrollbar_below_slider (ev.y)) |
2036 | || scrollbar_below_slider (ev.y)) |
2076 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2037 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2077 | |
2038 | |
2078 | scrollBar.setMotion (); |
2039 | scrollBar.state = STATE_MOTION; |
2079 | break; |
2040 | break; |
2080 | |
2041 | |
2081 | case Button1: |
2042 | case Button1: |
2082 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
2043 | if (scrollBar.align == R_SB_ALIGN_CENTRE) |
2083 | csrO = ev.y - scrollBar.top; |
2044 | csrO = ev.y - scrollBar.top; |
2084 | /* FALLTHROUGH */ |
2045 | /* FALLTHROUGH */ |
2085 | |
2046 | |
2086 | case Button3: |
2047 | case Button3: |
2087 | if (scrollBar.style != R_SB_XTERM) |
2048 | if (scrollBar.style != R_SB_XTERM) |
… | |
… | |
2097 | scr_page (DN, nrow - 1); |
2058 | scr_page (DN, nrow - 1); |
2098 | # else |
2059 | # else |
2099 | scr_page (DN, nrow / 4); |
2060 | scr_page (DN, nrow / 4); |
2100 | # endif |
2061 | # endif |
2101 | else |
2062 | else |
2102 | scrollBar.setMotion (); |
2063 | scrollBar.state = STATE_MOTION; |
2103 | } |
2064 | } |
2104 | else |
2065 | else |
2105 | { |
2066 | { |
2106 | scr_page ((ev.button == Button1 ? DN : UP), |
2067 | scr_page ((ev.button == Button1 ? DN : UP), |
2107 | (nrow |
2068 | (nrow |
… | |
… | |
2124 | |
2085 | |
2125 | csrO = 0; /* reset csr Offset */ |
2086 | csrO = 0; /* reset csr Offset */ |
2126 | if (!bypass_keystate) |
2087 | if (!bypass_keystate) |
2127 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2088 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2128 | |
2089 | |
2129 | if (scrollbar_isUpDn ()) |
2090 | if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
2130 | { |
2091 | { |
2131 | scrollBar.setIdle (); |
2092 | scrollBar.state = STATE_IDLE; |
2132 | scrollbar_show (0); |
2093 | scrollbar_show (0); |
2133 | } |
2094 | } |
2134 | |
2095 | |
2135 | #ifdef SELECTION_SCROLLING |
2096 | #ifdef SELECTION_SCROLLING |
2136 | if (sel_scroll_ev.active) |
|
|
2137 | sel_scroll_ev.stop(); |
2097 | sel_scroll_ev.stop(); |
2138 | #endif |
2098 | #endif |
2139 | |
2099 | |
2140 | if (ev.window == vt) |
2100 | if (ev.window == vt) |
2141 | { |
2101 | { |
2142 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
2102 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
… | |
… | |
2166 | mouse_report (ev); |
2126 | mouse_report (ev); |
2167 | } |
2127 | } |
2168 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2128 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2169 | MEvent.button = AnyButton; |
2129 | MEvent.button = AnyButton; |
2170 | mouse_report (ev); |
2130 | mouse_report (ev); |
2171 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2131 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2172 | return; |
2132 | return; |
2173 | } |
2133 | } |
2174 | |
2134 | |
2175 | /* |
2135 | /* |
2176 | * dumb hack to compensate for the failure of click-and-drag |
2136 | * dumb hack to compensate for the failure of click-and-drag |
… | |
… | |
2214 | { |
2174 | { |
2215 | mouse_slip_wheel_speed += v ? -1 : 1; |
2175 | mouse_slip_wheel_speed += v ? -1 : 1; |
2216 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2176 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2217 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2177 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2218 | |
2178 | |
2219 | if (slip_wheel_ev.at < NOW) |
2179 | if (!slip_wheel_ev.is_active ()) |
2220 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
2180 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2221 | |
|
|
2222 | slip_wheel_ev.start (); |
|
|
2223 | } |
2181 | } |
2224 | else |
2182 | else |
|
|
2183 | # endif |
2225 | { |
2184 | { |
2226 | # endif |
|
|
2227 | scr_page (v, i); |
2185 | scr_page (v, i); |
2228 | scrollbar_show (1); |
2186 | scrollbar_show (1); |
2229 | # ifdef MOUSE_SLIP_WHEELING |
|
|
2230 | } |
2187 | } |
2231 | # endif |
|
|
2232 | } |
2188 | } |
2233 | break; |
2189 | break; |
2234 | #endif |
2190 | #endif |
2235 | } |
2191 | } |
2236 | } |
2192 | } |
… | |
… | |
2291 | if (ch == C0_LF) |
2247 | if (ch == C0_LF) |
2292 | nlines++; |
2248 | nlines++; |
2293 | |
2249 | |
2294 | refresh_count++; |
2250 | refresh_count++; |
2295 | |
2251 | |
2296 | if (!option (Opt_jumpScroll) |
2252 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2297 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2298 | { |
2253 | { |
2299 | refreshnow = true; |
|
|
2300 | refresh_count = 0; |
2254 | refresh_count = 0; |
|
|
2255 | |
|
|
2256 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2257 | { |
|
|
2258 | refreshnow = true; |
2301 | ch = NOCHAR; |
2259 | ch = NOCHAR; |
2302 | break; |
2260 | break; |
|
|
2261 | } |
2303 | } |
2262 | } |
2304 | |
2263 | |
2305 | // scr_add_lines only works for nlines <= nrow - 1. |
2264 | // scr_add_lines only works for nlines <= nrow - 1. |
2306 | if (nlines >= nrow - 1) |
2265 | if (nlines >= nrow - 1) |
2307 | { |
2266 | { |
… | |
… | |
2335 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2294 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2336 | scr_add_lines (buf, str - buf, nlines); |
2295 | scr_add_lines (buf, str - buf, nlines); |
2337 | |
2296 | |
2338 | /* |
2297 | /* |
2339 | * If there have been a lot of new lines, then update the screen |
2298 | * 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. |
2299 | * 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 |
2300 | * if skipScroll is enabled. |
2342 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2343 | */ |
2301 | */ |
2344 | if (refreshnow) |
2302 | if (refreshnow) |
2345 | { |
2303 | { |
2346 | if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2347 | refresh_limit++; |
|
|
2348 | else |
|
|
2349 | { |
|
|
2350 | flag = true; |
2304 | flag = true; |
2351 | //TODO: due to popular request, implement "skipscroll" option here |
|
|
2352 | scr_refresh (); |
2305 | scr_refresh (); |
2353 | want_refresh = 1; |
2306 | want_refresh = 1; |
2354 | } |
|
|
2355 | } |
2307 | } |
2356 | |
2308 | |
2357 | } |
2309 | } |
2358 | else |
2310 | else |
2359 | { |
2311 | { |
… | |
… | |
2520 | } |
2472 | } |
2521 | } |
2473 | } |
2522 | |
2474 | |
2523 | pclose_printer (fd); |
2475 | pclose_printer (fd); |
2524 | } |
2476 | } |
2525 | #endif /* PRINTPIPE */ |
2477 | #endif /* PRINTPIPE */ |
2526 | /*}}} */ |
2478 | /*}}} */ |
2527 | |
2479 | |
2528 | /* *INDENT-OFF* */ |
2480 | /* *INDENT-OFF* */ |
2529 | enum { |
2481 | enum { |
2530 | C1_40 = 0x40, |
2482 | C1_40 = 0x40, |
… | |
… | |
2580 | process_dcs_seq (); |
2532 | process_dcs_seq (); |
2581 | break; |
2533 | break; |
2582 | case 0x9b: /* CSI */ |
2534 | case 0x9b: /* CSI */ |
2583 | process_csi_seq (); |
2535 | process_csi_seq (); |
2584 | break; |
2536 | break; |
2585 | case 0x9d: /* CSI */ |
2537 | case 0x9d: /* OSC */ |
2586 | process_osc_seq (); |
2538 | process_osc_seq (); |
2587 | break; |
2539 | break; |
2588 | #endif |
2540 | #endif |
2589 | } |
2541 | } |
2590 | } |
2542 | } |
… | |
… | |
2816 | rxvt_term::process_csi_seq () |
2768 | rxvt_term::process_csi_seq () |
2817 | { |
2769 | { |
2818 | unicode_t ch, priv, i; |
2770 | unicode_t ch, priv, i; |
2819 | unsigned int nargs, p; |
2771 | unsigned int nargs, p; |
2820 | int n, ndef; |
2772 | int n, ndef; |
2821 | int arg[ESC_ARGS]; |
2773 | int arg[ESC_ARGS] = { }; |
2822 | |
2774 | |
2823 | for (nargs = ESC_ARGS; nargs > 0;) |
2775 | nargs = 0; |
2824 | arg[--nargs] = 0; |
|
|
2825 | |
2776 | |
2826 | priv = 0; |
2777 | priv = 0; |
2827 | ch = cmd_getc (); |
2778 | ch = cmd_getc (); |
2828 | if (ch >= '<' && ch <= '?') |
2779 | if (ch >= '<' && ch <= '?') |
|
|
2780 | { |
2829 | { /* '<' '=' '>' '?' */ |
2781 | /* '<' '=' '>' '?' */ |
2830 | priv = ch; |
2782 | priv = ch; |
2831 | ch = cmd_getc (); |
2783 | ch = cmd_getc (); |
2832 | } |
2784 | } |
2833 | |
2785 | |
2834 | /* read any numerical arguments */ |
2786 | /* read any numerical arguments */ |
… | |
… | |
2873 | switch (priv) |
2825 | switch (priv) |
2874 | { |
2826 | { |
2875 | case '>': |
2827 | case '>': |
2876 | if (ch == CSI_DA) /* secondary device attributes */ |
2828 | if (ch == CSI_DA) /* secondary device attributes */ |
2877 | { |
2829 | { |
2878 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
2830 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
2879 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
2831 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
2880 | // |
2832 | // |
2881 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
2833 | // 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 |
2834 | // 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). |
2835 | // versions. |
2884 | // |
2836 | // |
2885 | tt_printf ("\033[>%d;94;0c", 'U'); |
2837 | tt_printf ("\033[>%d;95;0c", 'U'); |
2886 | } |
2838 | } |
2887 | break; |
2839 | break; |
|
|
2840 | |
2888 | case '?': |
2841 | case '?': |
2889 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2842 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2890 | process_terminal_mode (ch, priv, nargs, arg); |
2843 | process_terminal_mode (ch, priv, nargs, arg); |
2891 | break; |
2844 | break; |
2892 | } |
2845 | } |
… | |
… | |
3408 | *buf++ = '\0'; |
3361 | *buf++ = '\0'; |
3409 | |
3362 | |
3410 | process_color_seq (op, color, name, resp); |
3363 | process_color_seq (op, color, name, resp); |
3411 | } |
3364 | } |
3412 | break; |
3365 | break; |
|
|
3366 | case Rxvt_restoreFG: |
3413 | case XTerm_Color00: |
3367 | case XTerm_Color00: |
3414 | process_color_seq (op, Color_fg, str, resp); |
3368 | process_color_seq (op, Color_fg, str, resp); |
3415 | break; |
3369 | break; |
|
|
3370 | case Rxvt_restoreBG: |
3416 | case XTerm_Color01: |
3371 | case XTerm_Color01: |
3417 | process_color_seq (op, Color_bg, str, resp); |
3372 | process_color_seq (op, Color_bg, str, resp); |
3418 | break; |
3373 | break; |
3419 | #ifndef NO_CURSORCOLOR |
3374 | #ifndef NO_CURSORCOLOR |
3420 | case XTerm_Color_cursor: |
3375 | case XTerm_Color_cursor: |
… | |
… | |
3441 | break; |
3396 | break; |
3442 | case URxvt_Color_IT: |
3397 | case URxvt_Color_IT: |
3443 | process_color_seq (op, Color_IT, str, resp); |
3398 | process_color_seq (op, Color_IT, str, resp); |
3444 | break; |
3399 | break; |
3445 | #endif |
3400 | #endif |
3446 | #if TRANSPARENT && TINTING |
3401 | #if ENABLE_TRANSPARENCY |
3447 | case URxvt_Color_tint: |
3402 | case URxvt_Color_tint: |
3448 | process_color_seq (op, Color_tint, str, resp); |
3403 | process_color_seq (op, Color_tint, str, resp); |
|
|
3404 | { |
|
|
3405 | bool changed = false; |
3449 | |
3406 | |
3450 | check_our_parents (); |
3407 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
3408 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
|
|
3409 | else |
|
|
3410 | changed = bgPixmap.unset_tint (); |
3451 | |
3411 | |
3452 | if (am_transparent) |
3412 | if (changed) |
3453 | want_full_refresh = want_refresh = 1; |
3413 | update_background (); |
|
|
3414 | } |
3454 | |
3415 | |
3455 | break; |
3416 | break; |
3456 | #endif |
3417 | #endif |
3457 | |
3418 | |
|
|
3419 | #if BG_IMAGE_FROM_FILE |
3458 | case Rxvt_Pixmap: |
3420 | case Rxvt_Pixmap: |
3459 | { |
3421 | if (!strcmp (str, "?")) |
3460 | if (*str != ';') |
|
|
3461 | { |
3422 | { |
3462 | #if XPM_BACKGROUND |
3423 | char str[256]; |
3463 | scale_pixmap (""); /* reset to default scaling */ |
3424 | |
3464 | set_bgPixmap (str); /* change pixmap */ |
3425 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3465 | scr_touch (true); |
3426 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3466 | #endif |
3427 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3428 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3467 | } |
3429 | } |
3468 | |
3430 | else |
|
|
3431 | { |
3469 | int changed = 0; |
3432 | int changed = 0; |
3470 | |
3433 | |
3471 | while ((str = strchr (str, ';')) != NULL) |
3434 | if (*str != ';') |
3472 | { |
3435 | { |
|
|
3436 | /* reset to default scaling :*/ |
|
|
3437 | bgPixmap.unset_geometry (); |
|
|
3438 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3439 | changed++; |
|
|
3440 | str = strchr (str, ';'); |
|
|
3441 | if (str == NULL) |
|
|
3442 | bgPixmap.set_defaultGeometry (); |
|
|
3443 | } |
|
|
3444 | |
|
|
3445 | while (str) |
|
|
3446 | { |
3473 | str++; |
3447 | str++; |
3474 | #if XPM_BACKGROUND |
3448 | if (bgPixmap.set_geometry (str)) |
3475 | changed += scale_pixmap (str); |
3449 | changed++; |
3476 | #endif |
3450 | str = strchr (str, ';'); |
3477 | } |
3451 | } |
3478 | |
3452 | |
3479 | if (changed) |
3453 | if (changed) |
3480 | { |
3454 | update_background (); |
3481 | #ifdef XPM_BACKGROUND |
|
|
3482 | resize_pixmap (); |
|
|
3483 | scr_touch (true); |
|
|
3484 | #endif |
|
|
3485 | } |
3455 | } |
3486 | #if TRANSPARENT && defined(HAVE_AFTERIMAGE) |
|
|
3487 | if (option (Opt_transparent)) |
|
|
3488 | check_our_parents (); |
|
|
3489 | #endif |
|
|
3490 | } |
|
|
3491 | break; |
3456 | break; |
3492 | |
3457 | #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 | |
3458 | |
3500 | case XTerm_logfile: |
3459 | case XTerm_logfile: |
3501 | // TODO, when secure mode? |
3460 | // TODO, when secure mode? |
3502 | break; |
3461 | break; |
3503 | |
3462 | |
… | |
… | |
3618 | { |
3577 | { |
3619 | unsigned int i, j; |
3578 | unsigned int i, j; |
3620 | int state; |
3579 | int state; |
3621 | |
3580 | |
3622 | static const struct |
3581 | static const struct |
3623 | { |
3582 | { |
3624 | const int argval; |
3583 | const int argval; |
3625 | const unsigned long bit; |
3584 | const unsigned long bit; |
3626 | } |
|
|
3627 | |
|
|
3628 | argtopriv[] = { |
3585 | } argtopriv[] = { |
3629 | { 1, PrivMode_aplCUR }, |
3586 | { 1, PrivMode_aplCUR }, |
3630 | { 2, PrivMode_vt52 }, |
3587 | { 2, PrivMode_vt52 }, |
3631 | { 3, PrivMode_132 }, |
3588 | { 3, PrivMode_132 }, |
3632 | { 4, PrivMode_smoothScroll }, |
3589 | { 4, PrivMode_smoothScroll }, |
3633 | { 5, PrivMode_rVideo }, |
3590 | { 5, PrivMode_rVideo }, |
… | |
… | |
3649 | { 66, PrivMode_aplKP }, |
3606 | { 66, PrivMode_aplKP }, |
3650 | #ifndef NO_BACKSPACE_KEY |
3607 | #ifndef NO_BACKSPACE_KEY |
3651 | { 67, PrivMode_BackSpace }, |
3608 | { 67, PrivMode_BackSpace }, |
3652 | #endif |
3609 | #endif |
3653 | { 1000, PrivMode_MouseX11 }, |
3610 | { 1000, PrivMode_MouseX11 }, |
3654 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3611 | { 1002, PrivMode_MouseBtnEvent }, |
3655 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3612 | { 1003, PrivMode_MouseAnyEvent }, |
3656 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
|
|
3657 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3613 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3658 | { 1011, PrivMode_Keypress }, // rxvt extension |
3614 | { 1011, PrivMode_Keypress }, // rxvt extension |
3659 | // 1035 enable modifiers for alt, numlock NYI |
3615 | // 1035 enable modifiers for alt, numlock NYI |
3660 | // 1036 send ESC for meta keys NYI |
3616 | // 1036 send ESC for meta keys NYI |
3661 | // 1037 send DEL for keypad delete NYI |
3617 | // 1037 send DEL for keypad delete NYI |
3662 | { 1047, PrivMode_Screen }, |
3618 | { 1047, PrivMode_Screen }, |
3663 | // 1048 save and restore cursor |
3619 | // 1048 save and restore cursor |
3664 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3620 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3665 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3621 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
|
|
3622 | { 2004, PrivMode_BracketPaste }, |
3666 | }; |
3623 | }; |
3667 | |
3624 | |
3668 | if (nargs == 0) |
3625 | if (nargs == 0) |
3669 | return; |
3626 | return; |
3670 | |
3627 | |
… | |
… | |
3718 | */ |
3675 | */ |
3719 | PrivMode (1, PrivMode_vt52); |
3676 | PrivMode (1, PrivMode_vt52); |
3720 | break; |
3677 | break; |
3721 | case 3: /* 80/132 */ |
3678 | case 3: /* 80/132 */ |
3722 | if (priv_modes & PrivMode_132OK) |
3679 | if (priv_modes & PrivMode_132OK) |
|
|
3680 | { |
|
|
3681 | scr_poweron (); |
3723 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3682 | set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); |
|
|
3683 | } |
3724 | break; |
3684 | break; |
3725 | case 4: /* smooth scrolling */ |
3685 | case 4: /* smooth scrolling */ |
3726 | set_option (Opt_jumpScroll, !state); |
3686 | set_option (Opt_jumpScroll, !state); |
3727 | break; |
3687 | break; |
3728 | case 5: /* reverse video */ |
3688 | case 5: /* reverse video */ |
… | |
… | |
3735 | scr_autowrap (state); |
3695 | scr_autowrap (state); |
3736 | break; |
3696 | break; |
3737 | /* case 8: - auto repeat, can't do on a per window basis */ |
3697 | /* case 8: - auto repeat, can't do on a per window basis */ |
3738 | case 9: /* X10 mouse reporting */ |
3698 | case 9: /* X10 mouse reporting */ |
3739 | if (state) /* orthogonal */ |
3699 | if (state) /* orthogonal */ |
3740 | priv_modes &= ~PrivMode_MouseX11; |
3700 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
3741 | break; |
3701 | break; |
3742 | #ifdef scrollBar_esc |
3702 | #ifdef scrollBar_esc |
3743 | case scrollBar_esc: |
3703 | case scrollBar_esc: |
3744 | if (scrollbar_mapping (state)) |
3704 | if (scrollbar_mapping (state)) |
3745 | { |
3705 | { |
… | |
… | |
3758 | break; |
3718 | break; |
3759 | /* case 66: - application key pad */ |
3719 | /* case 66: - application key pad */ |
3760 | /* case 67: - backspace key */ |
3720 | /* case 67: - backspace key */ |
3761 | case 1000: /* X11 mouse reporting */ |
3721 | case 1000: /* X11 mouse reporting */ |
3762 | if (state) /* orthogonal */ |
3722 | if (state) /* orthogonal */ |
3763 | priv_modes &= ~PrivMode_MouseX10; |
3723 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
3764 | break; |
3724 | break; |
3765 | #if 0 |
|
|
3766 | case 1001: |
3725 | case 1002: |
3767 | break; /* X11 mouse highlighting */ |
3726 | case 1003: |
3768 | #endif |
3727 | if (state) |
|
|
3728 | { |
|
|
3729 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3730 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3731 | vt_emask_mouse = PointerMotionMask; |
|
|
3732 | } |
|
|
3733 | else |
|
|
3734 | vt_emask_mouse = NoEventMask; |
|
|
3735 | vt_select_input (); |
|
|
3736 | break; |
3769 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3737 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3770 | set_option (Opt_scrollTtyOutput, !state); |
3738 | set_option (Opt_scrollTtyOutput, !state); |
3771 | break; |
3739 | break; |
3772 | case 1011: /* scroll to bottom on key press */ |
3740 | case 1011: /* scroll to bottom on key press */ |
3773 | set_option (Opt_scrollTtyKeypress, state); |
3741 | set_option (Opt_scrollTtyKeypress, state); |
… | |
… | |
3950 | rxvt_term::process_graphics () |
3918 | rxvt_term::process_graphics () |
3951 | { |
3919 | { |
3952 | unicode_t ch, cmd = cmd_getc (); |
3920 | unicode_t ch, cmd = cmd_getc (); |
3953 | |
3921 | |
3954 | if (cmd == 'Q') |
3922 | if (cmd == 'Q') |
|
|
3923 | { |
3955 | { /* query graphics */ |
3924 | /* query graphics */ |
3956 | tt_printf ("\033G0\012"); /* no graphics */ |
3925 | tt_printf ("\033G0\012"); /* no graphics */ |
3957 | return; |
3926 | return; |
3958 | } |
3927 | } |
3959 | /* swallow other graphics sequences until terminating ':' */ |
3928 | /* swallow other graphics sequences until terminating ':' */ |
3960 | do |
3929 | do |
… | |
… | |
4010 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
3979 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4011 | |
3980 | |
4012 | memcpy (v_buffer + v_buflen, data, len); |
3981 | memcpy (v_buffer + v_buflen, data, len); |
4013 | v_buflen += len; |
3982 | v_buflen += len; |
4014 | |
3983 | |
4015 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
3984 | pty_ev.set (ev::READ | ev::WRITE); |
4016 | } |
3985 | } |
4017 | |
3986 | |
4018 | void rxvt_term::pty_write () |
3987 | void rxvt_term::pty_write () |
4019 | { |
3988 | { |
4020 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
3989 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
… | |
… | |
4025 | |
3994 | |
4026 | if (v_buflen == 0) |
3995 | if (v_buflen == 0) |
4027 | { |
3996 | { |
4028 | free (v_buffer); |
3997 | free (v_buffer); |
4029 | v_buffer = 0; |
3998 | v_buffer = 0; |
4030 | v_buflen = 0; |
|
|
4031 | |
3999 | |
4032 | pty_ev.set (EVENT_READ); |
4000 | pty_ev.set (ev::READ); |
4033 | return; |
4001 | return; |
4034 | } |
4002 | } |
4035 | |
4003 | |
4036 | memmove (v_buffer, v_buffer + written, v_buflen); |
4004 | memmove (v_buffer, v_buffer + written, v_buflen); |
4037 | } |
4005 | } |
4038 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4006 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4039 | pty_ev.set (EVENT_READ); |
4007 | pty_ev.set (ev::READ); |
4040 | } |
4008 | } |
4041 | |
4009 | |
4042 | /*----------------------- end-of-file (C source) -----------------------*/ |
4010 | /*----------------------- end-of-file (C source) -----------------------*/ |
4043 | |
4011 | |