… | |
… | |
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 |
… | |
… | |
282 | ^ !!ctrl) ? '\b' : '\177'; |
291 | ^ !!ctrl) ? '\b' : '\177'; |
283 | kbuf[1] = '\0'; |
292 | kbuf[1] = '\0'; |
284 | } |
293 | } |
285 | else |
294 | else |
286 | STRCPY (kbuf, key_backspace); |
295 | STRCPY (kbuf, key_backspace); |
287 | # ifdef MULTICHAR_SET |
|
|
288 | if ((Options & Opt_mc_hack) && screen.cur.col > 0) |
|
|
289 | { |
|
|
290 | int col, row; |
|
|
291 | |
|
|
292 | newlen = STRLEN (kbuf); |
|
|
293 | col = screen.cur.col - 1; |
|
|
294 | row = screen.cur.row + TermWin.saveLines; |
|
|
295 | if (IS_MULTI2 (screen.rend[row][col])) |
|
|
296 | MEMMOVE (kbuf + newlen, kbuf, newlen + 1); |
|
|
297 | } |
|
|
298 | # endif |
|
|
299 | break; |
296 | break; |
300 | #endif |
297 | #endif |
301 | #ifndef NO_DELETE_KEY |
298 | #ifndef NO_DELETE_KEY |
302 | case XK_Delete: |
299 | case XK_Delete: |
303 | STRCPY (kbuf, key_delete); |
300 | STRCPY (kbuf, key_delete); |
304 | # ifdef MULTICHAR_SET |
|
|
305 | if (Options & Opt_mc_hack) |
|
|
306 | { |
|
|
307 | int col, row; |
|
|
308 | |
|
|
309 | newlen = STRLEN (kbuf); |
|
|
310 | col = screen.cur.col; |
|
|
311 | row = screen.cur.row + TermWin.saveLines; |
|
|
312 | if (IS_MULTI1 (screen.rend[row][col])) |
|
|
313 | MEMMOVE (kbuf + newlen, kbuf, newlen + 1); |
|
|
314 | } |
|
|
315 | # endif |
|
|
316 | break; |
301 | break; |
317 | #endif |
302 | #endif |
318 | case XK_Tab: |
303 | case XK_Tab: |
319 | if (shft) |
304 | if (shft) |
320 | STRCPY (kbuf, "\033[Z"); |
305 | STRCPY (kbuf, "\033[Z"); |
… | |
… | |
362 | kbuf[1] = 'O'; |
347 | kbuf[1] = 'O'; |
363 | kbuf[2] = "dacb"[keysym - XK_Left]; |
348 | kbuf[2] = "dacb"[keysym - XK_Left]; |
364 | } |
349 | } |
365 | else if (PrivateModes & PrivMode_aplCUR) |
350 | else if (PrivateModes & PrivMode_aplCUR) |
366 | kbuf[1] = 'O'; |
351 | kbuf[1] = 'O'; |
367 | #ifdef MULTICHAR_SET |
|
|
368 | //TODO: ?? |
|
|
369 | if (Options & Opt_mc_hack) |
|
|
370 | { |
|
|
371 | int col, row, m; |
|
|
372 | |
|
|
373 | col = screen.cur.col; |
|
|
374 | row = screen.cur.row + TermWin.saveLines; |
|
|
375 | m = 0; |
|
|
376 | if (keysym == XK_Right |
|
|
377 | && IS_MULTI1 (screen.rend[row][col])) |
|
|
378 | m = 1; |
|
|
379 | else if (keysym == XK_Left) |
|
|
380 | { |
|
|
381 | if (col > 0) |
|
|
382 | { |
|
|
383 | if (IS_MULTI2 (screen.rend[row][col - 1])) |
|
|
384 | m = 1; |
|
|
385 | } |
|
|
386 | else if (screen.cur.row > 0) |
|
|
387 | { |
|
|
388 | col = screen.tlen[--row]; |
|
|
389 | if (col == -1) |
|
|
390 | col = TermWin.ncol - 1; |
|
|
391 | else |
|
|
392 | col--; |
|
|
393 | if (col > 0 |
|
|
394 | && IS_MULTI2 (screen.rend[row][col])) |
|
|
395 | m = 1; |
|
|
396 | } |
|
|
397 | } |
|
|
398 | if (m) |
|
|
399 | MEMMOVE (kbuf + 3, kbuf, 3 + 1); |
|
|
400 | } |
|
|
401 | #endif |
|
|
402 | break; |
352 | break; |
403 | |
353 | |
404 | #ifndef UNSHIFTED_SCROLLKEYS |
354 | #ifndef UNSHIFTED_SCROLLKEYS |
405 | # ifdef XK_KP_Prior |
355 | # ifdef XK_KP_Prior |
406 | case XK_KP_Prior: |
356 | case XK_KP_Prior: |
… | |
… | |
653 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
603 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
654 | |
604 | |
655 | /* escape prefix */ |
605 | /* escape prefix */ |
656 | if (meta |
606 | if (meta |
657 | #ifdef META8_OPTION |
607 | #ifdef META8_OPTION |
658 | && (meta_char == C0_ESC) |
608 | && meta_char == C0_ESC |
659 | #endif |
609 | #endif |
660 | ) |
610 | ) |
661 | { |
611 | { |
662 | const unsigned char ch = C0_ESC; |
612 | const unsigned char ch = C0_ESC; |
663 | |
|
|
664 | tt_write (&ch, 1); |
613 | tt_write (&ch, 1); |
665 | } |
614 | } |
|
|
615 | |
666 | #ifdef DEBUG_CMD |
616 | #if defined(DEBUG_CMD) |
667 | if (debug_key) |
|
|
668 | { /* Display keyboard buffer contents */ |
617 | /* Display keyboard buffer contents */ |
669 | char *p; |
618 | unsigned char *p; |
670 | int i; |
619 | int i; |
671 | |
620 | |
672 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
621 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
673 | for (i = 0, p = kbuf; i < len; i++, p++) |
622 | for (i = 0, p = kbuf; i < len; i++, p++) |
674 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
623 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
675 | fprintf (stderr, "'\n"); |
624 | fprintf (stderr, "'\n"); |
676 | } |
|
|
677 | #endif /* DEBUG_CMD */ |
625 | #endif /* DEBUG_CMD */ |
678 | tt_write (kbuf, (unsigned int)len); |
626 | tt_write (kbuf, (unsigned int)len); |
679 | } |
627 | } |
680 | /*}}} */ |
628 | /*}}} */ |
681 | |
629 | |
… | |
… | |
687 | { |
635 | { |
688 | unsigned int n, s; |
636 | unsigned int n, s; |
689 | |
637 | |
690 | n = cmdbuf_ptr - cmdbuf_base; |
638 | n = cmdbuf_ptr - cmdbuf_base; |
691 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
639 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
|
|
640 | |
692 | if (n > 0 && s < count) |
641 | if (n > 0 && s < count) |
693 | { |
642 | { |
694 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
643 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
695 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
644 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
696 | cmdbuf_ptr = cmdbuf_base; |
645 | cmdbuf_ptr = cmdbuf_base; |
697 | cmdbuf_endp -= n; |
646 | cmdbuf_endp -= n; |
698 | s += n; |
647 | s += n; |
699 | } |
648 | } |
|
|
649 | |
700 | if (count > s) |
650 | if (count > s) |
701 | { |
651 | { |
702 | rxvt_print_error ("data loss: cmd_write too large"); |
652 | rxvt_print_error ("data loss: cmd_write too large"); |
703 | count = s; |
653 | count = s; |
704 | } |
654 | } |
|
|
655 | |
705 | for (; count--;) |
656 | for (; count--;) |
706 | *cmdbuf_endp++ = *str++; |
657 | *cmdbuf_endp++ = *str++; |
|
|
658 | |
|
|
659 | cmd_parse (); |
|
|
660 | |
707 | return 0; |
661 | return 0; |
708 | } |
662 | } |
709 | #endif /* MENUBAR_MAX */ |
663 | #endif /* MENUBAR_MAX */ |
710 | |
664 | |
711 | void |
665 | void |
… | |
… | |
783 | cmdbuf_endp += n; |
737 | cmdbuf_endp += n; |
784 | return true; |
738 | return true; |
785 | } |
739 | } |
786 | else if (n < 0 && errno != EAGAIN) |
740 | else if (n < 0 && errno != EAGAIN) |
787 | destroy (); |
741 | destroy (); |
788 | |
742 | |
789 | return false; |
743 | return false; |
790 | } |
744 | } |
791 | |
745 | |
792 | void |
746 | void |
793 | rxvt_term::pty_cb (io_watcher &w, short revents) |
747 | rxvt_term::pty_cb (io_watcher &w, short revents) |
… | |
… | |
810 | seen_input = 1; |
764 | seen_input = 1; |
811 | /* once we know the shell is running, send the screen size. Again! */ |
765 | /* once we know the shell is running, send the screen size. Again! */ |
812 | tt_winch (); |
766 | tt_winch (); |
813 | } |
767 | } |
814 | |
768 | |
|
|
769 | if (cmd_parse ()) |
|
|
770 | break; |
|
|
771 | } |
|
|
772 | } |
|
|
773 | } |
|
|
774 | |
|
|
775 | bool |
|
|
776 | rxvt_term::cmd_parse () |
|
|
777 | { |
|
|
778 | bool flag = false; |
815 | uint32_t ch = NOCHAR; |
779 | uint32_t ch = NOCHAR; |
|
|
780 | |
|
|
781 | for (;;) |
|
|
782 | { |
|
|
783 | if (ch == NOCHAR) |
|
|
784 | ch = next_char (); |
|
|
785 | |
|
|
786 | if (ch == NOCHAR) // TODO: improve |
|
|
787 | break; |
|
|
788 | |
|
|
789 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
790 | { |
|
|
791 | /* Read a text string from the input buffer */ |
|
|
792 | uint32_t buf[BUFSIZ]; |
|
|
793 | bool refreshnow = false; |
|
|
794 | int nlines = 0; |
|
|
795 | uint32_t *str = buf; |
|
|
796 | |
|
|
797 | *str++ = ch; |
816 | |
798 | |
817 | for (;;) |
799 | for (;;) |
818 | { |
800 | { |
819 | if (ch == NOCHAR) |
|
|
820 | ch = next_char (); |
801 | ch = next_char (); |
821 | |
802 | |
822 | if (ch == NOCHAR) // TODO: improve |
803 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
823 | break; |
804 | break; |
824 | |
805 | else |
825 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
826 | { |
806 | { |
827 | /* Read a text string from the input buffer */ |
|
|
828 | uint32_t buf[BUFSIZ]; |
|
|
829 | bool refreshnow = false; |
|
|
830 | int nlines = 0; |
|
|
831 | uint32_t *str = buf; |
|
|
832 | |
|
|
833 | *str++ = ch; |
807 | *str++ = ch; |
834 | |
808 | |
835 | for (;;) |
809 | if (ch == '\n') |
836 | { |
810 | { |
837 | ch = next_char (); |
|
|
838 | |
|
|
839 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
840 | break; |
|
|
841 | else |
811 | nlines++; |
|
|
812 | refresh_count++; |
|
|
813 | |
|
|
814 | if (! (Options & Opt_jumpScroll) |
|
|
815 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
842 | { |
816 | { |
843 | *str++ = ch; |
|
|
844 | |
|
|
845 | if (ch == '\n') |
|
|
846 | { |
|
|
847 | nlines++; |
|
|
848 | refresh_count++; |
|
|
849 | |
|
|
850 | if (! (Options & Opt_jumpScroll) |
|
|
851 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
|
|
852 | { |
|
|
853 | refreshnow = true; |
817 | refreshnow = true; |
854 | flag = false; |
818 | flag = false; |
855 | ch = NOCHAR; |
819 | ch = NOCHAR; |
856 | break; |
820 | break; |
857 | } |
821 | } |
858 | |
822 | |
859 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
823 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
860 | if (nlines >= TermWin.nrow - 1) |
824 | if (nlines >= TermWin.nrow - 1) |
861 | { |
825 | { |
862 | scr_add_lines (buf, nlines, str - buf); |
826 | scr_add_lines (buf, nlines, str - buf); |
863 | nlines = 0; |
827 | nlines = 0; |
864 | str = buf; |
828 | str = buf; |
865 | } |
|
|
866 | } |
|
|
867 | |
|
|
868 | if (str >= buf + BUFSIZ) |
|
|
869 | { |
|
|
870 | ch = NOCHAR; |
|
|
871 | break; |
|
|
872 | } |
|
|
873 | } |
829 | } |
874 | } |
830 | } |
875 | |
831 | |
876 | scr_add_lines (buf, nlines, str - buf); |
832 | if (str >= buf + BUFSIZ) |
877 | |
|
|
878 | /* |
|
|
879 | * If there have been a lot of new lines, then update the screen |
|
|
880 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
881 | * the number of pages between refreshes is refresh_limit, which |
|
|
882 | * is incremented here because we must be doing flat-out scrolling. |
|
|
883 | * |
|
|
884 | * refreshing should be correct for small scrolls, because of the |
|
|
885 | * time-out |
|
|
886 | */ |
|
|
887 | if (refreshnow) |
|
|
888 | { |
833 | { |
889 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
834 | ch = NOCHAR; |
890 | refresh_limit++; |
835 | break; |
891 | |
|
|
892 | scr_refresh (refresh_type); |
|
|
893 | } |
836 | } |
894 | |
|
|
895 | } |
|
|
896 | else |
|
|
897 | { |
|
|
898 | switch (ch) |
|
|
899 | { |
|
|
900 | default: |
|
|
901 | process_nonprinting (ch); |
|
|
902 | break; |
|
|
903 | case C0_ESC: /* escape char */ |
|
|
904 | process_escape_seq (); |
|
|
905 | break; |
|
|
906 | /*case 0x9b: */ /* CSI */ |
|
|
907 | /* process_csi_seq (); */ |
|
|
908 | } |
|
|
909 | |
|
|
910 | ch = NOCHAR; |
|
|
911 | } |
837 | } |
912 | } |
838 | } |
|
|
839 | |
|
|
840 | scr_add_lines (buf, nlines, str - buf); |
|
|
841 | |
|
|
842 | /* |
|
|
843 | * If there have been a lot of new lines, then update the screen |
|
|
844 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
845 | * the number of pages between refreshes is refresh_limit, which |
|
|
846 | * is incremented here because we must be doing flat-out scrolling. |
|
|
847 | * |
|
|
848 | * refreshing should be correct for small scrolls, because of the |
|
|
849 | * time-out |
|
|
850 | */ |
|
|
851 | if (refreshnow) |
|
|
852 | { |
|
|
853 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
854 | refresh_limit++; |
|
|
855 | |
|
|
856 | scr_refresh (refresh_type); |
|
|
857 | } |
|
|
858 | |
|
|
859 | } |
|
|
860 | else |
913 | } |
861 | { |
|
|
862 | switch (ch) |
|
|
863 | { |
|
|
864 | default: |
|
|
865 | process_nonprinting (ch); |
|
|
866 | break; |
|
|
867 | case C0_ESC: /* escape char */ |
|
|
868 | process_escape_seq (); |
|
|
869 | break; |
|
|
870 | /*case 0x9b: */ /* CSI */ |
|
|
871 | /* process_csi_seq (); */ |
|
|
872 | } |
|
|
873 | |
|
|
874 | ch = NOCHAR; |
|
|
875 | } |
914 | } |
876 | } |
|
|
877 | |
|
|
878 | return flag; |
915 | } |
879 | } |
916 | |
880 | |
917 | // read the next character, currently handles UTF-8 |
881 | // read the next character, currently handles UTF-8 |
918 | // will probably handle all sorts of other stuff in the future |
882 | // will probably handle all sorts of other stuff in the future |
919 | uint32_t |
883 | uint32_t |
920 | rxvt_term::next_char () |
884 | rxvt_term::next_char () |
921 | { |
885 | { |
922 | while (cmdbuf_ptr < cmdbuf_endp) |
886 | while (cmdbuf_ptr < cmdbuf_endp) |
923 | { |
887 | { |
924 | if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh |
888 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
|
|
889 | if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr) |
|
|
890 | || !*cmdbuf_ptr) |
925 | return *cmdbuf_ptr++; |
891 | return *cmdbuf_ptr++; |
926 | |
892 | |
927 | wchar_t wc; |
893 | wchar_t wc; |
928 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
894 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
929 | |
895 | |
930 | if (len == (size_t)-2) |
896 | if (len == (size_t)-2) |
931 | return NOCHAR; |
897 | { |
|
|
898 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
899 | cmdbuf_ptr = cmdbuf_endp; |
|
|
900 | break; |
|
|
901 | } |
932 | |
902 | |
933 | if (len == (size_t)-1) |
903 | if (len == (size_t)-1) |
934 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
904 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
935 | |
905 | |
936 | // assume wchar == unicode |
906 | // assume wchar == unicode |
… | |
… | |
997 | pointer_blank (); |
967 | pointer_blank (); |
998 | } |
968 | } |
999 | #endif |
969 | #endif |
1000 | |
970 | |
1001 | void |
971 | void |
1002 | rxvt_term::mouse_report (const XButtonEvent &ev) |
972 | rxvt_term::mouse_report (XButtonEvent &ev) |
1003 | { |
973 | { |
1004 | int button_number, key_state = 0; |
974 | int button_number, key_state = 0; |
1005 | int x, y; |
975 | int x, y; |
1006 | |
976 | |
1007 | x = ev.x; |
977 | x = ev.x; |
1008 | y = ev.y; |
978 | y = ev.y; |
1009 | pixel_position (&x, &y); |
979 | pixel_position (&x, &y); |
1010 | |
980 | |
… | |
… | |
1415 | pointer_unblank (); |
1385 | pointer_unblank (); |
1416 | #endif |
1386 | #endif |
1417 | #if MENUBAR |
1387 | #if MENUBAR |
1418 | if (isMenuBarWindow (ev.xany.window)) |
1388 | if (isMenuBarWindow (ev.xany.window)) |
1419 | { |
1389 | { |
1420 | menubar_control (& (ev.xbutton)); |
1390 | menubar_control (ev.xbutton); |
1421 | break; |
1391 | break; |
1422 | } |
1392 | } |
1423 | #endif |
1393 | #endif |
1424 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1394 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1425 | break; |
1395 | break; |
… | |
… | |
1554 | #endif |
1524 | #endif |
1555 | } |
1525 | } |
1556 | } |
1526 | } |
1557 | |
1527 | |
1558 | void |
1528 | void |
1559 | rxvt_term::button_press (const XButtonEvent &ev) |
1529 | rxvt_term::button_press (XButtonEvent &ev) |
1560 | { |
1530 | { |
1561 | int reportmode = 0, clickintime; |
1531 | int reportmode = 0, clickintime; |
1562 | |
1532 | |
1563 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1533 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1564 | if (!bypass_keystate) |
1534 | if (!bypass_keystate) |
… | |
… | |
1792 | menubar_control (ev); |
1762 | menubar_control (ev); |
1793 | #endif |
1763 | #endif |
1794 | } |
1764 | } |
1795 | |
1765 | |
1796 | void |
1766 | void |
1797 | rxvt_term::button_release (const XButtonEvent &ev) |
1767 | rxvt_term::button_release (XButtonEvent &ev) |
1798 | { |
1768 | { |
1799 | int reportmode = 0; |
1769 | int reportmode = 0; |
1800 | |
1770 | |
1801 | csrO = 0; /* reset csr Offset */ |
1771 | csrO = 0; /* reset csr Offset */ |
1802 | if (!bypass_keystate) |
1772 | if (!bypass_keystate) |
… | |
… | |
1964 | if (have_pixmap) |
1934 | if (have_pixmap) |
1965 | { |
1935 | { |
1966 | /* |
1936 | /* |
1967 | * Copy display->root pixmap transparency |
1937 | * Copy display->root pixmap transparency |
1968 | */ |
1938 | */ |
1969 | int sx, sy, nx, ny; |
1939 | int sx, sy, nx, ny; |
1970 | unsigned int nw, nh; |
1940 | unsigned int nw, nh; |
1971 | Window cr; |
1941 | Window cr; |
1972 | XImage *image; |
1942 | XImage *image; |
1973 | GC gc; |
1943 | GC gc; |
1974 | XGCValues gcvalue; |
1944 | XGCValues gcvalue; |
1975 | |
1945 | |
1976 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1946 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1977 | 0, 0, &sx, &sy, &cr); |
1947 | 0, 0, &sx, &sy, &cr); |
1978 | nw = (unsigned int)szHint.width; |
1948 | nw = (unsigned int)szHint.width; |
1979 | nh = (unsigned int)szHint.height; |
1949 | nh = (unsigned int)szHint.height; |
1980 | nx = ny = 0; |
1950 | nx = ny = 0; |
|
|
1951 | |
1981 | if (sx < 0) |
1952 | if (sx < 0) |
1982 | { |
1953 | { |
1983 | nw += sx; |
1954 | nw += sx; |
1984 | nx = -sx; |
1955 | nx = -sx; |
1985 | sx = 0; |
1956 | sx = 0; |
1986 | } |
1957 | } |
|
|
1958 | |
1987 | if (sy < 0) |
1959 | if (sy < 0) |
1988 | { |
1960 | { |
1989 | nh += sy; |
1961 | nh += sy; |
1990 | ny = -sy; |
1962 | ny = -sy; |
1991 | sy = 0; |
1963 | sy = 0; |
1992 | } |
1964 | } |
|
|
1965 | |
1993 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1966 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1994 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1967 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1995 | allowedxerror = -1; |
1968 | allowedxerror = -1; |
1996 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1969 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1997 | ZPixmap); |
1970 | ZPixmap); |
… | |
… | |
2030 | if (!am_transparent || !am_pixmap_trans) |
2003 | if (!am_transparent || !am_pixmap_trans) |
2031 | pchanged = 1; |
2004 | pchanged = 1; |
2032 | am_transparent = am_pixmap_trans = 1; |
2005 | am_transparent = am_pixmap_trans = 1; |
2033 | } |
2006 | } |
2034 | } |
2007 | } |
|
|
2008 | |
2035 | if (!am_pixmap_trans) |
2009 | if (!am_pixmap_trans) |
2036 | { |
2010 | { |
2037 | unsigned int n; |
2011 | unsigned int n; |
2038 | /* |
2012 | /* |
2039 | * InheritPixmap transparency |
2013 | * InheritPixmap transparency |
… | |
… | |
2054 | break; |
2028 | break; |
2055 | } |
2029 | } |
2056 | if (oldp != TermWin.parent[i]) |
2030 | if (oldp != TermWin.parent[i]) |
2057 | pchanged = 1; |
2031 | pchanged = 1; |
2058 | } |
2032 | } |
|
|
2033 | |
2059 | n = 0; |
2034 | n = 0; |
|
|
2035 | |
2060 | if (pchanged) |
2036 | if (pchanged) |
2061 | { |
2037 | { |
2062 | for (; n < (unsigned int)i; n++) |
2038 | for (; n < (unsigned int)i; n++) |
2063 | { |
2039 | { |
2064 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2040 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
… | |
… | |
2068 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2044 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2069 | break; |
2045 | break; |
2070 | } |
2046 | } |
2071 | } |
2047 | } |
2072 | } |
2048 | } |
|
|
2049 | |
2073 | if (n > (int) (sizeof (TermWin.parent) |
2050 | if (n > (int) (sizeof (TermWin.parent) |
2074 | / sizeof (TermWin.parent[0]))) |
2051 | / sizeof (TermWin.parent[0]))) |
2075 | { |
2052 | { |
2076 | D_X ((stderr, "InheritPixmap Turning off")); |
2053 | D_X ((stderr, "InheritPixmap Turning off")); |
2077 | XSetWindowBackground (display->display, TermWin.parent[0], |
2054 | XSetWindowBackground (display->display, TermWin.parent[0], |
… | |
… | |
2100 | ParentRelative); |
2077 | ParentRelative); |
2101 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2078 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2102 | ParentRelative); |
2079 | ParentRelative); |
2103 | am_transparent = 1; |
2080 | am_transparent = 1; |
2104 | } |
2081 | } |
|
|
2082 | |
2105 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2083 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2106 | TermWin.parent[i] = None; |
2084 | TermWin.parent[i] = None; |
2107 | } |
2085 | } |
2108 | return pchanged; |
2086 | return pchanged; |
2109 | } |
2087 | } |
… | |
… | |
2115 | /*----------------------------------------------------------------------*/ |
2093 | /*----------------------------------------------------------------------*/ |
2116 | #ifdef PRINTPIPE |
2094 | #ifdef PRINTPIPE |
2117 | FILE * |
2095 | FILE * |
2118 | rxvt_term::popen_printer () |
2096 | rxvt_term::popen_printer () |
2119 | { |
2097 | { |
2120 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2098 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2121 | |
2099 | |
2122 | if (stream == NULL) |
2100 | if (stream == NULL) |
2123 | rxvt_print_error ("can't open printer pipe"); |
2101 | rxvt_print_error ("can't open printer pipe"); |
2124 | return stream; |
2102 | return stream; |
2125 | } |
2103 | } |
… | |
… | |
2337 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2315 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2338 | break; |
2316 | break; |
2339 | case '+': |
2317 | case '+': |
2340 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2318 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2341 | break; |
2319 | break; |
2342 | #ifdef MULTICHAR_SET |
|
|
2343 | case '$': |
|
|
2344 | scr_charset_set (-2, (unsigned int)cmd_getc ()); |
|
|
2345 | break; |
|
|
2346 | #endif |
|
|
2347 | #ifndef NO_FRILLS |
2320 | #ifndef NO_FRILLS |
2348 | case '6': |
2321 | case '6': |
2349 | scr_backindex (); |
2322 | scr_backindex (); |
2350 | break; |
2323 | break; |
2351 | #endif |
2324 | #endif |
… | |
… | |
2692 | case 7: /* unofficial extension */ |
2665 | case 7: /* unofficial extension */ |
2693 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2666 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2694 | break; |
2667 | break; |
2695 | #endif |
2668 | #endif |
2696 | case 8: /* unofficial extension */ |
2669 | case 8: /* unofficial extension */ |
2697 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
2670 | xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2698 | break; |
2671 | break; |
2699 | } |
2672 | } |
2700 | break; |
2673 | break; |
2701 | |
2674 | |
2702 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
2675 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
2976 | * 10 = menu (may change in future) |
2949 | * 10 = menu (may change in future) |
2977 | * 20 = bg pixmap |
2950 | * 20 = bg pixmap |
2978 | * 39 = change default fg color |
2951 | * 39 = change default fg color |
2979 | * 49 = change default bg color |
2952 | * 49 = change default bg color |
2980 | * 55 = dump scrollback buffer and all of screen |
2953 | * 55 = dump scrollback buffer and all of screen |
|
|
2954 | * 701 = change locale |
|
|
2955 | * 702 = find font |
2981 | */ |
2956 | */ |
2982 | void |
2957 | void |
2983 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2958 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2984 | { |
2959 | { |
2985 | int changed = 0; |
2960 | int changed = 0; |
… | |
… | |
3071 | set_window_color (Color_bg, str); |
3046 | set_window_color (Color_bg, str); |
3072 | break; |
3047 | break; |
3073 | case XTerm_logfile: |
3048 | case XTerm_logfile: |
3074 | break; |
3049 | break; |
3075 | case XTerm_font: |
3050 | case XTerm_font: |
3076 | change_font (0, str); |
3051 | change_font (str); |
3077 | break; |
3052 | break; |
|
|
3053 | #ifndef NO_FRILLS |
|
|
3054 | case XTerm_locale: |
|
|
3055 | if (str[0] == '?' && !str[1]) |
|
|
3056 | tt_printf ("%-.250s\n", locale); |
|
|
3057 | else |
|
|
3058 | { |
|
|
3059 | set_locale (str); |
|
|
3060 | # ifdef USE_XIM |
|
|
3061 | im_cb (); |
|
|
3062 | # endif |
|
|
3063 | } |
|
|
3064 | break; |
|
|
3065 | case XTerm_findfont: |
|
|
3066 | { |
|
|
3067 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3068 | tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); |
|
|
3069 | } |
|
|
3070 | break; |
|
|
3071 | #endif |
3078 | #if 0 |
3072 | #if 0 |
3079 | case XTerm_dumpscreen: /* no error notices */ |
3073 | case XTerm_dumpscreen: /* no error notices */ |
3080 | { |
3074 | { |
3081 | int fd; |
3075 | int fd; |
3082 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3076 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3210 | */ |
3204 | */ |
3211 | PrivMode (1, PrivMode_vt52); |
3205 | PrivMode (1, PrivMode_vt52); |
3212 | break; |
3206 | break; |
3213 | case 3: /* 80/132 */ |
3207 | case 3: /* 80/132 */ |
3214 | if (PrivateModes & PrivMode_132OK) |
3208 | if (PrivateModes & PrivMode_132OK) |
3215 | set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), |
3209 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
3216 | (unsigned int)TermWin.height); |
|
|
3217 | break; |
3210 | break; |
3218 | case 4: /* smooth scrolling */ |
3211 | case 4: /* smooth scrolling */ |
3219 | if (state) |
3212 | if (state) |
3220 | Options &= ~Opt_jumpScroll; |
3213 | Options &= ~Opt_jumpScroll; |
3221 | else |
3214 | else |