… | |
… | |
110 | SET_LOCALE (locale); |
110 | SET_LOCALE (locale); |
111 | |
111 | |
112 | if (status_return == XLookupChars |
112 | if (status_return == XLookupChars |
113 | || status_return == XLookupBoth) |
113 | || status_return == XLookupBoth) |
114 | { |
114 | { |
|
|
115 | /* make sure the user can type ctrl-@, i.e. NUL */ |
|
|
116 | if (len == 1 && *wkbuf == 0) |
|
|
117 | { |
|
|
118 | kbuf[0] = 0; |
|
|
119 | len = 1; |
|
|
120 | } |
|
|
121 | else |
|
|
122 | { |
115 | wkbuf[len] = 0; |
123 | wkbuf[len] = 0; |
116 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
124 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
117 | if (len < 0) |
125 | if (len < 0) |
118 | len = 0; |
126 | len = 0; |
|
|
127 | } |
119 | } |
128 | } |
120 | else |
129 | else |
121 | len = 0; |
130 | len = 0; |
122 | } |
131 | } |
123 | |
132 | |
… | |
… | |
141 | if (meta) |
150 | if (meta) |
142 | # endif |
151 | # endif |
143 | { |
152 | { |
144 | if (keysym == ks_bigfont) |
153 | if (keysym == ks_bigfont) |
145 | { |
154 | { |
146 | change_font (0, FONT_UP); |
155 | change_font (FONT_UP); |
147 | return; |
156 | return; |
148 | } |
157 | } |
149 | else if (keysym == ks_smallfont) |
158 | else if (keysym == ks_smallfont) |
150 | { |
159 | { |
151 | change_font (0, FONT_DN); |
160 | change_font (FONT_DN); |
152 | return; |
161 | return; |
153 | } |
162 | } |
154 | } |
163 | } |
155 | #endif |
164 | #endif |
156 | |
165 | |
… | |
… | |
229 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
238 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
230 | selection_request (ev.time, 0, 0); |
239 | selection_request (ev.time, 0, 0); |
231 | return; |
240 | return; |
232 | /* rxvt extras */ |
241 | /* rxvt extras */ |
233 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
242 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
234 | change_font (0, FONT_UP); |
243 | change_font (FONT_UP); |
235 | return; |
244 | return; |
236 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
245 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
237 | change_font (0, FONT_DN); |
246 | change_font (FONT_DN); |
238 | return; |
247 | return; |
239 | } |
248 | } |
240 | } |
249 | } |
241 | } |
250 | } |
242 | #ifdef PRINTPIPE |
251 | #ifdef PRINTPIPE |
243 | if (keysym == XK_Print) |
252 | if (keysym == XK_Print) |
244 | { |
253 | { |
245 | scr_printscreen (ctrl | shft); |
254 | scr_printscreen (ctrl | shft); |
246 | return; |
|
|
247 | } |
|
|
248 | #endif |
|
|
249 | #ifdef GREEK_SUPPORT |
|
|
250 | if (keysym == ks_greekmodeswith) |
|
|
251 | { |
|
|
252 | greek_mode = !greek_mode; |
|
|
253 | if (greek_mode) |
|
|
254 | { |
|
|
255 | xterm_seq (XTerm_title, |
|
|
256 | (greek_getmode () == GREEK_ELOT928 |
|
|
257 | ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST); |
|
|
258 | greek_reset (); |
|
|
259 | } |
|
|
260 | else |
|
|
261 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
|
|
262 | return; |
255 | return; |
263 | } |
256 | } |
264 | #endif |
257 | #endif |
265 | |
258 | |
266 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
259 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
… | |
… | |
638 | for (ch = kbuf; ch < kbuf + len; ch++) |
631 | for (ch = kbuf; ch < kbuf + len; ch++) |
639 | *ch |= 0x80; |
632 | *ch |= 0x80; |
640 | meta = 0; |
633 | meta = 0; |
641 | } |
634 | } |
642 | #endif |
635 | #endif |
643 | #ifdef GREEK_SUPPORT |
|
|
644 | if (greek_mode) |
|
|
645 | len = greek_xlat (kbuf, len); |
|
|
646 | #endif |
|
|
647 | /* nil */ ; |
636 | /* nil */ ; |
648 | } |
637 | } |
649 | } |
638 | } |
650 | |
639 | |
651 | if (len <= 0) |
640 | if (len <= 0) |
… | |
… | |
673 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
662 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
674 | |
663 | |
675 | /* escape prefix */ |
664 | /* escape prefix */ |
676 | if (meta |
665 | if (meta |
677 | #ifdef META8_OPTION |
666 | #ifdef META8_OPTION |
678 | && (meta_char == C0_ESC) |
667 | && meta_char == C0_ESC |
679 | #endif |
668 | #endif |
680 | ) |
669 | ) |
681 | { |
670 | { |
682 | const unsigned char ch = C0_ESC; |
671 | const unsigned char ch = C0_ESC; |
683 | |
|
|
684 | tt_write (&ch, 1); |
672 | tt_write (&ch, 1); |
685 | } |
673 | } |
|
|
674 | |
686 | #ifdef DEBUG_CMD |
675 | #if defined(DEBUG_CMD) |
687 | if (debug_key) |
|
|
688 | { /* Display keyboard buffer contents */ |
676 | /* Display keyboard buffer contents */ |
689 | char *p; |
677 | unsigned char *p; |
690 | int i; |
678 | int i; |
691 | |
679 | |
692 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
680 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
693 | for (i = 0, p = kbuf; i < len; i++, p++) |
681 | for (i = 0, p = kbuf; i < len; i++, p++) |
694 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
682 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
695 | fprintf (stderr, "'\n"); |
683 | fprintf (stderr, "'\n"); |
696 | } |
|
|
697 | #endif /* DEBUG_CMD */ |
684 | #endif /* DEBUG_CMD */ |
698 | tt_write (kbuf, (unsigned int)len); |
685 | tt_write (kbuf, (unsigned int)len); |
699 | } |
686 | } |
700 | /*}}} */ |
687 | /*}}} */ |
701 | |
688 | |
… | |
… | |
707 | { |
694 | { |
708 | unsigned int n, s; |
695 | unsigned int n, s; |
709 | |
696 | |
710 | n = cmdbuf_ptr - cmdbuf_base; |
697 | n = cmdbuf_ptr - cmdbuf_base; |
711 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
698 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
|
|
699 | |
712 | if (n > 0 && s < count) |
700 | if (n > 0 && s < count) |
713 | { |
701 | { |
714 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
702 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
715 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
703 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
716 | cmdbuf_ptr = cmdbuf_base; |
704 | cmdbuf_ptr = cmdbuf_base; |
717 | cmdbuf_endp -= n; |
705 | cmdbuf_endp -= n; |
718 | s += n; |
706 | s += n; |
719 | } |
707 | } |
|
|
708 | |
720 | if (count > s) |
709 | if (count > s) |
721 | { |
710 | { |
722 | rxvt_print_error ("data loss: cmd_write too large"); |
711 | rxvt_print_error ("data loss: cmd_write too large"); |
723 | count = s; |
712 | count = s; |
724 | } |
713 | } |
|
|
714 | |
725 | for (; count--;) |
715 | for (; count--;) |
726 | *cmdbuf_endp++ = *str++; |
716 | *cmdbuf_endp++ = *str++; |
|
|
717 | |
|
|
718 | cmd_parse (); |
|
|
719 | |
727 | return 0; |
720 | return 0; |
728 | } |
721 | } |
729 | #endif /* MENUBAR_MAX */ |
722 | #endif /* MENUBAR_MAX */ |
730 | |
723 | |
731 | void |
724 | void |
… | |
… | |
803 | cmdbuf_endp += n; |
796 | cmdbuf_endp += n; |
804 | return true; |
797 | return true; |
805 | } |
798 | } |
806 | else if (n < 0 && errno != EAGAIN) |
799 | else if (n < 0 && errno != EAGAIN) |
807 | destroy (); |
800 | destroy (); |
808 | |
801 | |
809 | return false; |
802 | return false; |
810 | } |
803 | } |
811 | |
804 | |
812 | void |
805 | void |
813 | rxvt_term::pty_cb (io_watcher &w, short revents) |
806 | rxvt_term::pty_cb (io_watcher &w, short revents) |
… | |
… | |
830 | seen_input = 1; |
823 | seen_input = 1; |
831 | /* once we know the shell is running, send the screen size. Again! */ |
824 | /* once we know the shell is running, send the screen size. Again! */ |
832 | tt_winch (); |
825 | tt_winch (); |
833 | } |
826 | } |
834 | |
827 | |
|
|
828 | if (cmd_parse ()) |
|
|
829 | break; |
|
|
830 | } |
|
|
831 | } |
|
|
832 | } |
|
|
833 | |
|
|
834 | bool |
|
|
835 | rxvt_term::cmd_parse () |
|
|
836 | { |
|
|
837 | bool flag = false; |
835 | uint32_t ch = NOCHAR; |
838 | uint32_t ch = NOCHAR; |
|
|
839 | |
|
|
840 | for (;;) |
|
|
841 | { |
|
|
842 | if (ch == NOCHAR) |
|
|
843 | ch = next_char (); |
|
|
844 | |
|
|
845 | if (ch == NOCHAR) // TODO: improve |
|
|
846 | break; |
|
|
847 | |
|
|
848 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
849 | { |
|
|
850 | /* Read a text string from the input buffer */ |
|
|
851 | uint32_t buf[BUFSIZ]; |
|
|
852 | bool refreshnow = false; |
|
|
853 | int nlines = 0; |
|
|
854 | uint32_t *str = buf; |
|
|
855 | |
|
|
856 | *str++ = ch; |
836 | |
857 | |
837 | for (;;) |
858 | for (;;) |
838 | { |
859 | { |
839 | if (ch == NOCHAR) |
|
|
840 | ch = next_char (); |
860 | ch = next_char (); |
841 | |
861 | |
842 | if (ch == NOCHAR) // TODO: improve |
862 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
843 | break; |
863 | break; |
844 | |
864 | else |
845 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
846 | { |
865 | { |
847 | /* Read a text string from the input buffer */ |
|
|
848 | uint32_t buf[BUFSIZ]; |
|
|
849 | bool refreshnow = false; |
|
|
850 | int nlines = 0; |
|
|
851 | uint32_t *str = buf; |
|
|
852 | |
|
|
853 | *str++ = ch; |
866 | *str++ = ch; |
854 | |
867 | |
855 | for (;;) |
868 | if (ch == '\n') |
856 | { |
869 | { |
857 | ch = next_char (); |
|
|
858 | |
|
|
859 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
860 | break; |
|
|
861 | else |
870 | nlines++; |
|
|
871 | refresh_count++; |
|
|
872 | |
|
|
873 | if (! (Options & Opt_jumpScroll) |
|
|
874 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
862 | { |
875 | { |
863 | *str++ = ch; |
|
|
864 | |
|
|
865 | if (ch == '\n') |
|
|
866 | { |
|
|
867 | nlines++; |
|
|
868 | refresh_count++; |
|
|
869 | |
|
|
870 | if (! (Options & Opt_jumpScroll) |
|
|
871 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
|
|
872 | { |
|
|
873 | refreshnow = true; |
876 | refreshnow = true; |
874 | flag = false; |
877 | flag = false; |
875 | ch = NOCHAR; |
878 | ch = NOCHAR; |
876 | break; |
879 | break; |
877 | } |
880 | } |
878 | |
881 | |
879 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
882 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
880 | if (nlines >= TermWin.nrow - 1) |
883 | if (nlines >= TermWin.nrow - 1) |
881 | { |
884 | { |
882 | scr_add_lines (buf, nlines, str - buf); |
885 | scr_add_lines (buf, nlines, str - buf); |
883 | nlines = 0; |
886 | nlines = 0; |
884 | str = buf; |
887 | str = buf; |
885 | } |
|
|
886 | } |
|
|
887 | |
|
|
888 | if (str >= buf + BUFSIZ) |
|
|
889 | { |
|
|
890 | ch = NOCHAR; |
|
|
891 | break; |
|
|
892 | } |
|
|
893 | } |
888 | } |
894 | } |
889 | } |
895 | |
890 | |
896 | scr_add_lines (buf, nlines, str - buf); |
891 | if (str >= buf + BUFSIZ) |
897 | |
|
|
898 | /* |
|
|
899 | * If there have been a lot of new lines, then update the screen |
|
|
900 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
901 | * the number of pages between refreshes is refresh_limit, which |
|
|
902 | * is incremented here because we must be doing flat-out scrolling. |
|
|
903 | * |
|
|
904 | * refreshing should be correct for small scrolls, because of the |
|
|
905 | * time-out |
|
|
906 | */ |
|
|
907 | if (refreshnow) |
|
|
908 | { |
892 | { |
909 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
893 | ch = NOCHAR; |
910 | refresh_limit++; |
894 | break; |
911 | |
|
|
912 | scr_refresh (refresh_type); |
|
|
913 | } |
895 | } |
914 | |
|
|
915 | } |
|
|
916 | else |
|
|
917 | { |
|
|
918 | switch (ch) |
|
|
919 | { |
|
|
920 | default: |
|
|
921 | process_nonprinting (ch); |
|
|
922 | break; |
|
|
923 | case C0_ESC: /* escape char */ |
|
|
924 | process_escape_seq (); |
|
|
925 | break; |
|
|
926 | /*case 0x9b: */ /* CSI */ |
|
|
927 | /* process_csi_seq (); */ |
|
|
928 | } |
|
|
929 | |
|
|
930 | ch = NOCHAR; |
|
|
931 | } |
896 | } |
932 | } |
897 | } |
|
|
898 | |
|
|
899 | scr_add_lines (buf, nlines, str - buf); |
|
|
900 | |
|
|
901 | /* |
|
|
902 | * If there have been a lot of new lines, then update the screen |
|
|
903 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
904 | * the number of pages between refreshes is refresh_limit, which |
|
|
905 | * is incremented here because we must be doing flat-out scrolling. |
|
|
906 | * |
|
|
907 | * refreshing should be correct for small scrolls, because of the |
|
|
908 | * time-out |
|
|
909 | */ |
|
|
910 | if (refreshnow) |
|
|
911 | { |
|
|
912 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
913 | refresh_limit++; |
|
|
914 | |
|
|
915 | scr_refresh (refresh_type); |
|
|
916 | } |
|
|
917 | |
|
|
918 | } |
|
|
919 | else |
933 | } |
920 | { |
|
|
921 | switch (ch) |
|
|
922 | { |
|
|
923 | default: |
|
|
924 | process_nonprinting (ch); |
|
|
925 | break; |
|
|
926 | case C0_ESC: /* escape char */ |
|
|
927 | process_escape_seq (); |
|
|
928 | break; |
|
|
929 | /*case 0x9b: */ /* CSI */ |
|
|
930 | /* process_csi_seq (); */ |
|
|
931 | } |
|
|
932 | |
|
|
933 | ch = NOCHAR; |
|
|
934 | } |
934 | } |
935 | } |
|
|
936 | |
|
|
937 | return flag; |
935 | } |
938 | } |
936 | |
939 | |
937 | // read the next character, currently handles UTF-8 |
940 | // read the next character, currently handles UTF-8 |
938 | // will probably handle all sorts of other stuff in the future |
941 | // will probably handle all sorts of other stuff in the future |
939 | uint32_t |
942 | uint32_t |
… | |
… | |
1017 | pointer_blank (); |
1020 | pointer_blank (); |
1018 | } |
1021 | } |
1019 | #endif |
1022 | #endif |
1020 | |
1023 | |
1021 | void |
1024 | void |
1022 | rxvt_term::mouse_report (const XButtonEvent &ev) |
1025 | rxvt_term::mouse_report (XButtonEvent &ev) |
1023 | { |
1026 | { |
1024 | int button_number, key_state = 0; |
1027 | int button_number, key_state = 0; |
1025 | int x, y; |
1028 | int x, y; |
1026 | |
1029 | |
1027 | x = ev.x; |
1030 | x = ev.x; |
1028 | y = ev.y; |
1031 | y = ev.y; |
1029 | pixel_position (&x, &y); |
1032 | pixel_position (&x, &y); |
1030 | |
1033 | |
… | |
… | |
1424 | } |
1427 | } |
1425 | #ifdef MENUBAR |
1428 | #ifdef MENUBAR |
1426 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1429 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1427 | menubar_expose (); |
1430 | menubar_expose (); |
1428 | #endif |
1431 | #endif |
1429 | #ifdef RXVT_GRAPHICS |
|
|
1430 | Gr_expose (ev.xany.window); |
|
|
1431 | #endif |
|
|
1432 | |
|
|
1433 | } |
1432 | } |
1434 | break; |
1433 | break; |
1435 | |
1434 | |
1436 | case MotionNotify: |
1435 | case MotionNotify: |
1437 | #ifdef POINTER_BLANK |
1436 | #ifdef POINTER_BLANK |
… | |
… | |
1439 | pointer_unblank (); |
1438 | pointer_unblank (); |
1440 | #endif |
1439 | #endif |
1441 | #if MENUBAR |
1440 | #if MENUBAR |
1442 | if (isMenuBarWindow (ev.xany.window)) |
1441 | if (isMenuBarWindow (ev.xany.window)) |
1443 | { |
1442 | { |
1444 | menubar_control (& (ev.xbutton)); |
1443 | menubar_control (ev.xbutton); |
1445 | break; |
1444 | break; |
1446 | } |
1445 | } |
1447 | #endif |
1446 | #endif |
1448 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1447 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1449 | break; |
1448 | break; |
… | |
… | |
1578 | #endif |
1577 | #endif |
1579 | } |
1578 | } |
1580 | } |
1579 | } |
1581 | |
1580 | |
1582 | void |
1581 | void |
1583 | rxvt_term::button_press (const XButtonEvent &ev) |
1582 | rxvt_term::button_press (XButtonEvent &ev) |
1584 | { |
1583 | { |
1585 | int reportmode = 0, clickintime; |
1584 | int reportmode = 0, clickintime; |
1586 | |
1585 | |
1587 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1586 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1588 | if (!bypass_keystate) |
1587 | if (!bypass_keystate) |
… | |
… | |
1590 | /* |
1589 | /* |
1591 | * VT window processing of button press |
1590 | * VT window processing of button press |
1592 | */ |
1591 | */ |
1593 | if (ev.window == TermWin.vt) |
1592 | if (ev.window == TermWin.vt) |
1594 | { |
1593 | { |
1595 | #if RXVT_GRAPHICS |
|
|
1596 | if (ev.subwindow != None) |
|
|
1597 | rxvt_Gr_ButtonPress (ev.x, ev.y); |
|
|
1598 | else |
|
|
1599 | #endif |
|
|
1600 | |
|
|
1601 | { |
|
|
1602 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1594 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1603 | if (reportmode) |
1595 | if (reportmode) |
|
|
1596 | { |
|
|
1597 | /* mouse report from vt window */ |
|
|
1598 | /* save the xbutton state (for ButtonRelease) */ |
|
|
1599 | MEvent.state = ev.state; |
|
|
1600 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1601 | if (ev.button == MEvent.button && clickintime) |
1604 | { |
1602 | { |
1605 | /* mouse report from vt window */ |
1603 | /* same button, within alloted time */ |
1606 | /* save the xbutton state (for ButtonRelease) */ |
1604 | MEvent.clicks++; |
1607 | MEvent.state = ev.state; |
1605 | if (MEvent.clicks > 1) |
1608 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1609 | if (ev.button == MEvent.button && clickintime) |
|
|
1610 | { |
1606 | { |
1611 | /* same button, within alloted time */ |
|
|
1612 | MEvent.clicks++; |
|
|
1613 | if (MEvent.clicks > 1) |
|
|
1614 | { |
|
|
1615 | /* only report double clicks */ |
1607 | /* only report double clicks */ |
1616 | MEvent.clicks = 2; |
1608 | MEvent.clicks = 2; |
1617 | mouse_report (ev); |
1609 | mouse_report (ev); |
1618 | |
1610 | |
1619 | /* don't report the release */ |
1611 | /* don't report the release */ |
1620 | MEvent.clicks = 0; |
1612 | MEvent.clicks = 0; |
1621 | MEvent.button = AnyButton; |
1613 | MEvent.button = AnyButton; |
1622 | } |
|
|
1623 | } |
1614 | } |
1624 | else |
|
|
1625 | { |
|
|
1626 | /* different button, or time expired */ |
|
|
1627 | MEvent.clicks = 1; |
|
|
1628 | MEvent.button = ev.button; |
|
|
1629 | mouse_report (ev); |
|
|
1630 | } |
|
|
1631 | #else |
|
|
1632 | MEvent.button = ev.button; |
|
|
1633 | mouse_report (ev); |
|
|
1634 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1635 | |
|
|
1636 | } |
1615 | } |
1637 | else |
1616 | else |
1638 | { |
1617 | { |
|
|
1618 | /* different button, or time expired */ |
|
|
1619 | MEvent.clicks = 1; |
|
|
1620 | MEvent.button = ev.button; |
|
|
1621 | mouse_report (ev); |
|
|
1622 | } |
|
|
1623 | #else |
|
|
1624 | MEvent.button = ev.button; |
|
|
1625 | mouse_report (ev); |
|
|
1626 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1627 | |
|
|
1628 | } |
|
|
1629 | else |
|
|
1630 | { |
1639 | if (ev.button != MEvent.button) |
1631 | if (ev.button != MEvent.button) |
1640 | MEvent.clicks = 0; |
1632 | MEvent.clicks = 0; |
1641 | switch (ev.button) |
1633 | switch (ev.button) |
1642 | { |
1634 | { |
1643 | case Button1: |
1635 | case Button1: |
1644 | /* allow shift+left click to extend selection */ |
1636 | /* allow shift+left click to extend selection */ |
1645 | if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) |
1637 | if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) |
1646 | { |
1638 | { |
1647 | if (MEvent.button == Button1 && clickintime) |
|
|
1648 | selection_rotate (ev.x, ev.y); |
|
|
1649 | else |
|
|
1650 | selection_extend (ev.x, ev.y, 1); |
|
|
1651 | } |
|
|
1652 | else |
|
|
1653 | { |
|
|
1654 | if (MEvent.button == Button1 && clickintime) |
|
|
1655 | MEvent.clicks++; |
|
|
1656 | else |
|
|
1657 | MEvent.clicks = 1; |
|
|
1658 | |
|
|
1659 | selection_click (MEvent.clicks, ev.x, ev.y); |
|
|
1660 | } |
|
|
1661 | |
|
|
1662 | MEvent.button = Button1; |
|
|
1663 | break; |
|
|
1664 | |
|
|
1665 | case Button3: |
|
|
1666 | if (MEvent.button == Button3 && clickintime) |
1639 | if (MEvent.button == Button1 && clickintime) |
1667 | selection_rotate (ev.x, ev.y); |
1640 | selection_rotate (ev.x, ev.y); |
1668 | else |
1641 | else |
1669 | selection_extend (ev.x, ev.y, 1); |
1642 | selection_extend (ev.x, ev.y, 1); |
|
|
1643 | } |
|
|
1644 | else |
|
|
1645 | { |
|
|
1646 | if (MEvent.button == Button1 && clickintime) |
|
|
1647 | MEvent.clicks++; |
|
|
1648 | else |
|
|
1649 | MEvent.clicks = 1; |
|
|
1650 | |
|
|
1651 | selection_click (MEvent.clicks, ev.x, ev.y); |
|
|
1652 | } |
|
|
1653 | |
|
|
1654 | MEvent.button = Button1; |
|
|
1655 | break; |
|
|
1656 | |
|
|
1657 | case Button3: |
|
|
1658 | if (MEvent.button == Button3 && clickintime) |
|
|
1659 | selection_rotate (ev.x, ev.y); |
|
|
1660 | else |
|
|
1661 | selection_extend (ev.x, ev.y, 1); |
1670 | MEvent.button = Button3; |
1662 | MEvent.button = Button3; |
1671 | break; |
1663 | break; |
1672 | } |
|
|
1673 | } |
1664 | } |
|
|
1665 | } |
1674 | MEvent.time = ev.time; |
1666 | MEvent.time = ev.time; |
1675 | return; |
1667 | return; |
1676 | } |
|
|
1677 | } |
1668 | } |
1678 | |
1669 | |
1679 | /* |
1670 | /* |
1680 | * Scrollbar window processing of button press |
1671 | * Scrollbar window processing of button press |
1681 | */ |
1672 | */ |
… | |
… | |
1824 | menubar_control (ev); |
1815 | menubar_control (ev); |
1825 | #endif |
1816 | #endif |
1826 | } |
1817 | } |
1827 | |
1818 | |
1828 | void |
1819 | void |
1829 | rxvt_term::button_release (const XButtonEvent &ev) |
1820 | rxvt_term::button_release (XButtonEvent &ev) |
1830 | { |
1821 | { |
1831 | int reportmode = 0; |
1822 | int reportmode = 0; |
1832 | |
1823 | |
1833 | csrO = 0; /* reset csr Offset */ |
1824 | csrO = 0; /* reset csr Offset */ |
1834 | if (!bypass_keystate) |
1825 | if (!bypass_keystate) |
… | |
… | |
1846 | #ifdef SELECTION_SCROLLING |
1837 | #ifdef SELECTION_SCROLLING |
1847 | pending_scroll_selection=0; |
1838 | pending_scroll_selection=0; |
1848 | #endif |
1839 | #endif |
1849 | if (ev.window == TermWin.vt) |
1840 | if (ev.window == TermWin.vt) |
1850 | { |
1841 | { |
1851 | #ifdef RXVT_GRAPHICS |
|
|
1852 | if (ev.subwindow != None) |
|
|
1853 | rxvt_Gr_ButtonRelease (ev.x, ev.y); |
|
|
1854 | else |
|
|
1855 | #endif |
|
|
1856 | |
|
|
1857 | { |
|
|
1858 | if (reportmode) |
1842 | if (reportmode) |
|
|
1843 | { |
|
|
1844 | /* mouse report from vt window */ |
|
|
1845 | /* don't report release of wheel "buttons" */ |
|
|
1846 | if (ev.button >= 4) |
|
|
1847 | return; |
|
|
1848 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1849 | /* only report the release of 'slow' single clicks */ |
|
|
1850 | if (MEvent.button != AnyButton |
|
|
1851 | && (ev.button != MEvent.button |
|
|
1852 | || (ev.time - MEvent.time |
|
|
1853 | > MULTICLICK_TIME / 2))) |
1859 | { |
1854 | { |
1860 | /* mouse report from vt window */ |
|
|
1861 | /* don't report release of wheel "buttons" */ |
|
|
1862 | if (ev.button >= 4) |
|
|
1863 | return; |
|
|
1864 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1865 | /* only report the release of 'slow' single clicks */ |
|
|
1866 | if (MEvent.button != AnyButton |
|
|
1867 | && (ev.button != MEvent.button |
|
|
1868 | || (ev.time - MEvent.time |
|
|
1869 | > MULTICLICK_TIME / 2))) |
|
|
1870 | { |
|
|
1871 | MEvent.clicks = 0; |
1855 | MEvent.clicks = 0; |
1872 | MEvent.button = AnyButton; |
|
|
1873 | mouse_report (ev); |
|
|
1874 | } |
|
|
1875 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1876 | MEvent.button = AnyButton; |
1856 | MEvent.button = AnyButton; |
1877 | mouse_report (ev); |
1857 | mouse_report (ev); |
|
|
1858 | } |
|
|
1859 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1860 | MEvent.button = AnyButton; |
|
|
1861 | mouse_report (ev); |
1878 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1862 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1879 | return; |
1863 | return; |
1880 | } |
1864 | } |
1881 | /* |
1865 | /* |
1882 | * dumb hack to compensate for the failure of click-and-drag |
1866 | * dumb hack to compensate for the failure of click-and-drag |
1883 | * when overriding mouse reporting |
1867 | * when overriding mouse reporting |
1884 | */ |
1868 | */ |
1885 | if (PrivateModes & PrivMode_mouse_report |
1869 | if (PrivateModes & PrivMode_mouse_report |
1886 | && bypass_keystate |
1870 | && bypass_keystate |
1887 | && ev.button == Button1 && MEvent.clicks <= 1) |
1871 | && ev.button == Button1 && MEvent.clicks <= 1) |
1888 | selection_extend (ev.x, ev.y, 0); |
1872 | selection_extend (ev.x, ev.y, 0); |
1889 | |
1873 | |
1890 | switch (ev.button) |
1874 | switch (ev.button) |
|
|
1875 | { |
|
|
1876 | case Button1: |
|
|
1877 | case Button3: |
|
|
1878 | selection_make (ev.time); |
|
|
1879 | break; |
|
|
1880 | case Button2: |
|
|
1881 | selection_request (ev.time, ev.x, ev.y); |
|
|
1882 | break; |
|
|
1883 | #ifdef MOUSE_WHEEL |
|
|
1884 | case Button4: |
|
|
1885 | case Button5: |
1891 | { |
1886 | { |
1892 | case Button1: |
1887 | int i; |
1893 | case Button3: |
1888 | page_dirn v; |
1894 | selection_make (ev.time); |
1889 | |
|
|
1890 | v = (ev.button == Button4) ? UP : DN; |
|
|
1891 | if (ev.state & ShiftMask) |
1895 | break; |
1892 | i = 1; |
1896 | case Button2: |
1893 | else if ((Options & Opt_mouseWheelScrollPage)) |
1897 | selection_request (ev.time, ev.x, ev.y); |
1894 | i = TermWin.nrow - 1; |
|
|
1895 | else |
1898 | break; |
1896 | i = 5; |
1899 | #ifdef MOUSE_WHEEL |
1897 | # ifdef MOUSE_SLIP_WHEELING |
1900 | case Button4: |
1898 | if (ev.state & ControlMask) |
1901 | case Button5: |
|
|
1902 | { |
1899 | { |
1903 | int i; |
|
|
1904 | page_dirn v; |
|
|
1905 | |
|
|
1906 | v = (ev.button == Button4) ? UP : DN; |
|
|
1907 | if (ev.state & ShiftMask) |
|
|
1908 | i = 1; |
|
|
1909 | else if ((Options & Opt_mouseWheelScrollPage)) |
|
|
1910 | i = TermWin.nrow - 1; |
|
|
1911 | else |
|
|
1912 | i = 5; |
|
|
1913 | # ifdef MOUSE_SLIP_WHEELING |
|
|
1914 | if (ev.state & ControlMask) |
|
|
1915 | { |
|
|
1916 | mouse_slip_wheel_speed += (v ? -1 : 1); |
1900 | mouse_slip_wheel_speed += (v ? -1 : 1); |
1917 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1901 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1918 | } |
1902 | } |
1919 | # endif |
1903 | # endif |
1920 | # ifdef JUMP_MOUSE_WHEEL |
1904 | # ifdef JUMP_MOUSE_WHEEL |
|
|
1905 | scr_page (v, i); |
|
|
1906 | scr_refresh (SMOOTH_REFRESH); |
|
|
1907 | scrollbar_show (1); |
|
|
1908 | # else |
|
|
1909 | while (i--) |
|
|
1910 | { |
1921 | scr_page (v, i); |
1911 | scr_page (v, 1); |
1922 | scr_refresh (SMOOTH_REFRESH); |
1912 | scr_refresh (SMOOTH_REFRESH); |
1923 | scrollbar_show (1); |
1913 | scrollbar_show (1); |
1924 | # else |
|
|
1925 | while (i--) |
|
|
1926 | { |
|
|
1927 | scr_page (v, 1); |
|
|
1928 | scr_refresh (SMOOTH_REFRESH); |
|
|
1929 | scrollbar_show (1); |
|
|
1930 | } |
1914 | } |
1931 | # endif |
1915 | # endif |
1932 | |
1916 | |
1933 | } |
|
|
1934 | break; |
|
|
1935 | #endif |
|
|
1936 | |
|
|
1937 | } |
1917 | } |
|
|
1918 | break; |
|
|
1919 | #endif |
|
|
1920 | |
1938 | } |
1921 | } |
1939 | } |
1922 | } |
1940 | #ifdef MENUBAR |
1923 | #ifdef MENUBAR |
1941 | else if (isMenuBarWindow (ev.window)) |
1924 | else if (isMenuBarWindow (ev.window)) |
1942 | menubar_control (ev); |
1925 | menubar_control (ev); |
… | |
… | |
3011 | * 19 = change underlined character color |
2994 | * 19 = change underlined character color |
3012 | * 46 = change logfile (not implemented) |
2995 | * 46 = change logfile (not implemented) |
3013 | * 50 = change font |
2996 | * 50 = change font |
3014 | * |
2997 | * |
3015 | * rxvt extensions: |
2998 | * rxvt extensions: |
|
|
2999 | * 9 = change locale (NYI) |
3016 | * 10 = menu (may change in future) |
3000 | * 10 = menu (may change in future) |
3017 | * 20 = bg pixmap |
3001 | * 20 = bg pixmap |
3018 | * 39 = change default fg color |
3002 | * 39 = change default fg color |
3019 | * 49 = change default bg color |
3003 | * 49 = change default bg color |
3020 | * 55 = dump scrollback buffer and all of screen |
3004 | * 55 = dump scrollback buffer and all of screen |
… | |
… | |
3111 | set_window_color (Color_bg, str); |
3095 | set_window_color (Color_bg, str); |
3112 | break; |
3096 | break; |
3113 | case XTerm_logfile: |
3097 | case XTerm_logfile: |
3114 | break; |
3098 | break; |
3115 | case XTerm_font: |
3099 | case XTerm_font: |
3116 | change_font (0, str); |
3100 | change_font (str); |
|
|
3101 | break; |
|
|
3102 | case XTerm_locale: |
|
|
3103 | if (str[0] == '?' && !str[1]) |
|
|
3104 | tt_printf ("%-.250s\n", locale); |
|
|
3105 | else |
|
|
3106 | { |
|
|
3107 | set_locale (str); |
|
|
3108 | im_cb (); |
|
|
3109 | |
|
|
3110 | // TODO: call selection_make with the right values set |
|
|
3111 | // to re-fresh the selection. |
|
|
3112 | if (display->selection_owner == this) |
|
|
3113 | display->set_selection_owner (0); |
|
|
3114 | } |
3117 | break; |
3115 | break; |
3118 | #if 0 |
3116 | #if 0 |
3119 | case XTerm_dumpscreen: /* no error notices */ |
3117 | case XTerm_dumpscreen: /* no error notices */ |
3120 | { |
3118 | { |
3121 | int fd; |
3119 | int fd; |
… | |
… | |
3472 | void |
3470 | void |
3473 | rxvt_term::process_graphics () |
3471 | rxvt_term::process_graphics () |
3474 | { |
3472 | { |
3475 | unsigned char ch, cmd = cmd_getc (); |
3473 | unsigned char ch, cmd = cmd_getc (); |
3476 | |
3474 | |
3477 | #ifndef RXVT_GRAPHICS |
|
|
3478 | if (cmd == 'Q') |
3475 | if (cmd == 'Q') |
3479 | { /* query graphics */ |
3476 | { /* query graphics */ |
3480 | tt_printf ("\033G0\n"); /* no graphics */ |
3477 | tt_printf ("\033G0\n"); /* no graphics */ |
3481 | return; |
3478 | return; |
3482 | } |
3479 | } |
3483 | /* swallow other graphics sequences until terminating ':' */ |
3480 | /* swallow other graphics sequences until terminating ':' */ |
3484 | do |
3481 | do |
3485 | ch = cmd_getc (); |
3482 | ch = cmd_getc (); |
3486 | while (ch != ':'); |
3483 | while (ch != ':'); |
3487 | #else |
|
|
3488 | unsigned int nargs; |
|
|
3489 | int args[NGRX_PTS]; |
|
|
3490 | unsigned char *text = NULL; |
|
|
3491 | |
|
|
3492 | if (cmd == 'Q') |
|
|
3493 | { /* query graphics */ |
|
|
3494 | tt_printf ("\033G1\n"); /* yes, graphics (color) */ |
|
|
3495 | return; |
|
|
3496 | } |
|
|
3497 | for (nargs = 0; nargs < (sizeof (args) / sizeof (args[0])) - 1;) |
|
|
3498 | { |
|
|
3499 | int neg; |
|
|
3500 | |
|
|
3501 | ch = cmd_getc (); |
|
|
3502 | neg = (ch == '-'); |
|
|
3503 | if (neg || ch == '+') |
|
|
3504 | ch = cmd_getc (); |
|
|
3505 | |
|
|
3506 | for (args[nargs] = 0; isdigit (ch); ch = cmd_getc ()) |
|
|
3507 | args[nargs] = args[nargs] * 10 + (ch - '0'); |
|
|
3508 | if (neg) |
|
|
3509 | args[nargs] = -args[nargs]; |
|
|
3510 | |
|
|
3511 | nargs++; |
|
|
3512 | args[nargs] = 0; |
|
|
3513 | if (ch != ';') |
|
|
3514 | break; |
|
|
3515 | } |
|
|
3516 | |
|
|
3517 | if ((cmd == 'T') && (nargs >= 5)) |
|
|
3518 | { |
|
|
3519 | int i, len = args[4]; |
|
|
3520 | |
|
|
3521 | text = (unsigned char *)rxvt_malloc ((len + 1) * sizeof (char)); |
|
|
3522 | |
|
|
3523 | if (text != NULL) |
|
|
3524 | { |
|
|
3525 | for (i = 0; i < len; i++) |
|
|
3526 | text[i] = cmd_getc (); |
|
|
3527 | text[len] = '\0'; |
|
|
3528 | } |
|
|
3529 | } |
|
|
3530 | Gr_do_graphics (cmd, nargs, args, text); |
|
|
3531 | #endif |
|
|
3532 | } |
3484 | } |
3533 | /*}}} */ |
3485 | /*}}} */ |
3534 | |
3486 | |
3535 | /* ------------------------------------------------------------------------- */ |
3487 | /* ------------------------------------------------------------------------- */ |
3536 | |
3488 | |