… | |
… | |
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 | |
… | |
… | |
131 | valid_keysym = keysym != NoSymbol; |
140 | valid_keysym = keysym != NoSymbol; |
132 | } |
141 | } |
133 | |
142 | |
134 | if (valid_keysym) |
143 | if (valid_keysym) |
135 | { |
144 | { |
136 | /* for some backwards compatibility */ |
|
|
137 | #if defined(HOTKEY_CTRL) || defined(HOTKEY_META) |
|
|
138 | # ifdef HOTKEY_CTRL |
|
|
139 | if (ctrl) |
|
|
140 | # else |
|
|
141 | if (meta) |
|
|
142 | # endif |
|
|
143 | { |
|
|
144 | if (keysym == ks_bigfont) |
|
|
145 | { |
|
|
146 | change_font (FONT_UP); |
|
|
147 | return; |
|
|
148 | } |
|
|
149 | else if (keysym == ks_smallfont) |
|
|
150 | { |
|
|
151 | change_font (FONT_DN); |
|
|
152 | return; |
|
|
153 | } |
|
|
154 | } |
|
|
155 | #endif |
|
|
156 | |
|
|
157 | if (TermWin.saveLines) |
145 | if (TermWin.saveLines) |
158 | { |
146 | { |
159 | #ifdef UNSHIFTED_SCROLLKEYS |
147 | #ifdef UNSHIFTED_SCROLLKEYS |
160 | if (!ctrl && !meta) |
148 | if (!ctrl && !meta) |
161 | { |
149 | { |
… | |
… | |
252 | #ifdef KEYSYM_RESOURCE |
240 | #ifdef KEYSYM_RESOURCE |
253 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
241 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
254 | { |
242 | { |
255 | unsigned int l; |
243 | unsigned int l; |
256 | const unsigned char *kbuf0; |
244 | const unsigned char *kbuf0; |
257 | const unsigned char ch = C0_ESC; |
|
|
258 | |
245 | |
259 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
246 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
260 | l = (unsigned int)*kbuf0++; |
247 | l = (unsigned int)*kbuf0++; |
261 | |
248 | |
262 | /* escape prefix */ |
249 | /* escape prefix */ |
263 | if (meta) |
250 | if (meta |
264 | # ifdef META8_OPTION |
251 | # ifdef META8_OPTION |
265 | if (meta_char == C0_ESC) |
252 | && meta_char == C0_ESC |
266 | # endif |
253 | # endif |
|
|
254 | ) |
|
|
255 | { |
|
|
256 | const unsigned char ch = C0_ESC; |
267 | tt_write (&ch, 1); |
257 | tt_write (&ch, 1); |
|
|
258 | } |
|
|
259 | |
268 | tt_write (kbuf0, l); |
260 | tt_write (kbuf0, l); |
269 | return; |
261 | return; |
270 | } |
262 | } |
271 | else |
263 | else |
272 | #endif |
264 | #endif |
… | |
… | |
282 | ^ !!ctrl) ? '\b' : '\177'; |
274 | ^ !!ctrl) ? '\b' : '\177'; |
283 | kbuf[1] = '\0'; |
275 | kbuf[1] = '\0'; |
284 | } |
276 | } |
285 | else |
277 | else |
286 | STRCPY (kbuf, key_backspace); |
278 | 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; |
279 | break; |
300 | #endif |
280 | #endif |
301 | #ifndef NO_DELETE_KEY |
281 | #ifndef NO_DELETE_KEY |
302 | case XK_Delete: |
282 | case XK_Delete: |
303 | STRCPY (kbuf, key_delete); |
283 | 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; |
284 | break; |
317 | #endif |
285 | #endif |
318 | case XK_Tab: |
286 | case XK_Tab: |
319 | if (shft) |
287 | if (shft) |
320 | STRCPY (kbuf, "\033[Z"); |
288 | STRCPY (kbuf, "\033[Z"); |
… | |
… | |
362 | kbuf[1] = 'O'; |
330 | kbuf[1] = 'O'; |
363 | kbuf[2] = "dacb"[keysym - XK_Left]; |
331 | kbuf[2] = "dacb"[keysym - XK_Left]; |
364 | } |
332 | } |
365 | else if (PrivateModes & PrivMode_aplCUR) |
333 | else if (PrivateModes & PrivMode_aplCUR) |
366 | kbuf[1] = 'O'; |
334 | 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; |
335 | break; |
403 | |
336 | |
404 | #ifndef UNSHIFTED_SCROLLKEYS |
337 | #ifndef UNSHIFTED_SCROLLKEYS |
405 | # ifdef XK_KP_Prior |
338 | # ifdef XK_KP_Prior |
406 | case XK_KP_Prior: |
339 | case XK_KP_Prior: |
… | |
… | |
595 | break; |
528 | break; |
596 | } |
529 | } |
597 | if (newlen) |
530 | if (newlen) |
598 | len = STRLEN (kbuf); |
531 | len = STRLEN (kbuf); |
599 | } |
532 | } |
|
|
533 | |
600 | /* |
534 | /* |
601 | * Pass meta for all function keys, if 'meta' option set |
535 | * Pass meta for all function keys, if 'meta' option set |
602 | */ |
536 | */ |
603 | #ifdef META8_OPTION |
537 | #ifdef META8_OPTION |
604 | if (meta && (meta_char == 0x80) && len > 0) |
538 | if (meta && (meta_char == 0x80) && len > 0) |
… | |
… | |
619 | { |
553 | { |
620 | unsigned char *ch; |
554 | unsigned char *ch; |
621 | |
555 | |
622 | for (ch = kbuf; ch < kbuf + len; ch++) |
556 | for (ch = kbuf; ch < kbuf + len; ch++) |
623 | *ch |= 0x80; |
557 | *ch |= 0x80; |
|
|
558 | |
624 | meta = 0; |
559 | meta = 0; |
625 | } |
560 | } |
626 | #endif |
561 | #endif |
627 | /* nil */ ; |
562 | /* nil */ ; |
628 | } |
563 | } |
… | |
… | |
653 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
588 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
654 | |
589 | |
655 | /* escape prefix */ |
590 | /* escape prefix */ |
656 | if (meta |
591 | if (meta |
657 | #ifdef META8_OPTION |
592 | #ifdef META8_OPTION |
658 | && (meta_char == C0_ESC) |
593 | && meta_char == C0_ESC |
659 | #endif |
594 | #endif |
660 | ) |
595 | ) |
661 | { |
596 | { |
662 | const unsigned char ch = C0_ESC; |
597 | const unsigned char ch = C0_ESC; |
663 | |
|
|
664 | tt_write (&ch, 1); |
598 | tt_write (&ch, 1); |
665 | } |
599 | } |
|
|
600 | |
666 | #ifdef DEBUG_CMD |
601 | #if defined(DEBUG_CMD) |
667 | if (debug_key) |
|
|
668 | { /* Display keyboard buffer contents */ |
602 | /* Display keyboard buffer contents */ |
669 | char *p; |
603 | unsigned char *p; |
670 | int i; |
604 | int i; |
671 | |
605 | |
672 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
606 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
673 | for (i = 0, p = kbuf; i < len; i++, p++) |
607 | for (i = 0, p = kbuf; i < len; i++, p++) |
674 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
608 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
675 | fprintf (stderr, "'\n"); |
609 | fprintf (stderr, "'\n"); |
676 | } |
|
|
677 | #endif /* DEBUG_CMD */ |
610 | #endif /* DEBUG_CMD */ |
678 | tt_write (kbuf, (unsigned int)len); |
611 | tt_write (kbuf, (unsigned int)len); |
679 | } |
612 | } |
680 | /*}}} */ |
613 | /*}}} */ |
681 | |
614 | |
… | |
… | |
687 | { |
620 | { |
688 | unsigned int n, s; |
621 | unsigned int n, s; |
689 | |
622 | |
690 | n = cmdbuf_ptr - cmdbuf_base; |
623 | n = cmdbuf_ptr - cmdbuf_base; |
691 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
624 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
|
|
625 | |
692 | if (n > 0 && s < count) |
626 | if (n > 0 && s < count) |
693 | { |
627 | { |
694 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
628 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
695 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
629 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
696 | cmdbuf_ptr = cmdbuf_base; |
630 | cmdbuf_ptr = cmdbuf_base; |
697 | cmdbuf_endp -= n; |
631 | cmdbuf_endp -= n; |
698 | s += n; |
632 | s += n; |
699 | } |
633 | } |
|
|
634 | |
700 | if (count > s) |
635 | if (count > s) |
701 | { |
636 | { |
702 | rxvt_print_error ("data loss: cmd_write too large"); |
637 | rxvt_print_error ("data loss: cmd_write too large"); |
703 | count = s; |
638 | count = s; |
704 | } |
639 | } |
|
|
640 | |
705 | for (; count--;) |
641 | for (; count--;) |
706 | *cmdbuf_endp++ = *str++; |
642 | *cmdbuf_endp++ = *str++; |
|
|
643 | |
|
|
644 | cmd_parse (); |
|
|
645 | |
707 | return 0; |
646 | return 0; |
708 | } |
647 | } |
709 | #endif /* MENUBAR_MAX */ |
648 | #endif /* MENUBAR_MAX */ |
710 | |
649 | |
711 | void |
650 | void |
… | |
… | |
783 | cmdbuf_endp += n; |
722 | cmdbuf_endp += n; |
784 | return true; |
723 | return true; |
785 | } |
724 | } |
786 | else if (n < 0 && errno != EAGAIN) |
725 | else if (n < 0 && errno != EAGAIN) |
787 | destroy (); |
726 | destroy (); |
788 | |
727 | |
789 | return false; |
728 | return false; |
790 | } |
729 | } |
791 | |
730 | |
792 | void |
731 | void |
793 | rxvt_term::pty_cb (io_watcher &w, short revents) |
732 | rxvt_term::pty_cb (io_watcher &w, short revents) |
… | |
… | |
810 | seen_input = 1; |
749 | seen_input = 1; |
811 | /* once we know the shell is running, send the screen size. Again! */ |
750 | /* once we know the shell is running, send the screen size. Again! */ |
812 | tt_winch (); |
751 | tt_winch (); |
813 | } |
752 | } |
814 | |
753 | |
|
|
754 | if (cmd_parse ()) |
|
|
755 | break; |
|
|
756 | } |
|
|
757 | } |
|
|
758 | } |
|
|
759 | |
|
|
760 | bool |
|
|
761 | rxvt_term::cmd_parse () |
|
|
762 | { |
|
|
763 | bool flag = false; |
815 | uint32_t ch = NOCHAR; |
764 | uint32_t ch = NOCHAR; |
|
|
765 | |
|
|
766 | for (;;) |
|
|
767 | { |
|
|
768 | if (ch == NOCHAR) |
|
|
769 | ch = next_char (); |
|
|
770 | |
|
|
771 | if (ch == NOCHAR) // TODO: improve |
|
|
772 | break; |
|
|
773 | |
|
|
774 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
775 | { |
|
|
776 | /* Read a text string from the input buffer */ |
|
|
777 | uint32_t buf[BUFSIZ]; |
|
|
778 | bool refreshnow = false; |
|
|
779 | int nlines = 0; |
|
|
780 | uint32_t *str = buf; |
|
|
781 | |
|
|
782 | *str++ = ch; |
816 | |
783 | |
817 | for (;;) |
784 | for (;;) |
818 | { |
785 | { |
819 | if (ch == NOCHAR) |
|
|
820 | ch = next_char (); |
786 | ch = next_char (); |
821 | |
787 | |
822 | if (ch == NOCHAR) // TODO: improve |
788 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
823 | break; |
789 | break; |
824 | |
790 | else |
825 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
826 | { |
791 | { |
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; |
792 | *str++ = ch; |
834 | |
793 | |
835 | for (;;) |
794 | if (ch == '\n') |
836 | { |
795 | { |
837 | ch = next_char (); |
|
|
838 | |
|
|
839 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
840 | break; |
|
|
841 | else |
796 | nlines++; |
|
|
797 | refresh_count++; |
|
|
798 | |
|
|
799 | if (! (Options & Opt_jumpScroll) |
|
|
800 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
842 | { |
801 | { |
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; |
802 | refreshnow = true; |
854 | flag = false; |
803 | flag = false; |
855 | ch = NOCHAR; |
804 | ch = NOCHAR; |
856 | break; |
805 | break; |
857 | } |
806 | } |
858 | |
807 | |
859 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
808 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
860 | if (nlines >= TermWin.nrow - 1) |
809 | if (nlines >= TermWin.nrow - 1) |
861 | { |
810 | { |
862 | scr_add_lines (buf, nlines, str - buf); |
811 | scr_add_lines (buf, nlines, str - buf); |
863 | nlines = 0; |
812 | nlines = 0; |
864 | str = buf; |
813 | str = buf; |
865 | } |
|
|
866 | } |
|
|
867 | |
|
|
868 | if (str >= buf + BUFSIZ) |
|
|
869 | { |
|
|
870 | ch = NOCHAR; |
|
|
871 | break; |
|
|
872 | } |
|
|
873 | } |
814 | } |
874 | } |
815 | } |
875 | |
816 | |
876 | scr_add_lines (buf, nlines, str - buf); |
817 | 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 | { |
818 | { |
889 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
819 | ch = NOCHAR; |
890 | refresh_limit++; |
820 | break; |
891 | |
|
|
892 | scr_refresh (refresh_type); |
|
|
893 | } |
821 | } |
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 | } |
822 | } |
912 | } |
823 | } |
|
|
824 | |
|
|
825 | scr_add_lines (buf, nlines, str - buf); |
|
|
826 | |
|
|
827 | /* |
|
|
828 | * If there have been a lot of new lines, then update the screen |
|
|
829 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
830 | * the number of pages between refreshes is refresh_limit, which |
|
|
831 | * is incremented here because we must be doing flat-out scrolling. |
|
|
832 | * |
|
|
833 | * refreshing should be correct for small scrolls, because of the |
|
|
834 | * time-out |
|
|
835 | */ |
|
|
836 | if (refreshnow) |
|
|
837 | { |
|
|
838 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
839 | refresh_limit++; |
|
|
840 | |
|
|
841 | scr_refresh (refresh_type); |
|
|
842 | } |
|
|
843 | |
|
|
844 | } |
|
|
845 | else |
913 | } |
846 | { |
|
|
847 | switch (ch) |
|
|
848 | { |
|
|
849 | default: |
|
|
850 | process_nonprinting (ch); |
|
|
851 | break; |
|
|
852 | case C0_ESC: /* escape char */ |
|
|
853 | process_escape_seq (); |
|
|
854 | break; |
|
|
855 | /*case 0x9b: */ /* CSI */ |
|
|
856 | /* process_csi_seq (); */ |
|
|
857 | } |
|
|
858 | |
|
|
859 | ch = NOCHAR; |
|
|
860 | } |
914 | } |
861 | } |
|
|
862 | |
|
|
863 | return flag; |
915 | } |
864 | } |
916 | |
865 | |
917 | // read the next character, currently handles UTF-8 |
866 | // read the next character, currently handles UTF-8 |
918 | // will probably handle all sorts of other stuff in the future |
867 | // will probably handle all sorts of other stuff in the future |
919 | uint32_t |
868 | uint32_t |
920 | rxvt_term::next_char () |
869 | rxvt_term::next_char () |
921 | { |
870 | { |
922 | while (cmdbuf_ptr < cmdbuf_endp) |
871 | while (cmdbuf_ptr < cmdbuf_endp) |
923 | { |
872 | { |
924 | if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh |
873 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
|
|
874 | if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr) |
|
|
875 | || !*cmdbuf_ptr) |
925 | return *cmdbuf_ptr++; |
876 | return *cmdbuf_ptr++; |
926 | |
877 | |
927 | wchar_t wc; |
878 | wchar_t wc; |
928 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
879 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
929 | |
880 | |
930 | if (len == (size_t)-2) |
881 | if (len == (size_t)-2) |
931 | return NOCHAR; |
882 | { |
|
|
883 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
884 | cmdbuf_ptr = cmdbuf_endp; |
|
|
885 | break; |
|
|
886 | } |
932 | |
887 | |
933 | if (len == (size_t)-1) |
888 | if (len == (size_t)-1) |
934 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
889 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
935 | |
890 | |
936 | // assume wchar == unicode |
891 | // assume wchar == unicode |
… | |
… | |
997 | pointer_blank (); |
952 | pointer_blank (); |
998 | } |
953 | } |
999 | #endif |
954 | #endif |
1000 | |
955 | |
1001 | void |
956 | void |
1002 | rxvt_term::mouse_report (const XButtonEvent &ev) |
957 | rxvt_term::mouse_report (XButtonEvent &ev) |
1003 | { |
958 | { |
1004 | int button_number, key_state = 0; |
959 | int button_number, key_state = 0; |
1005 | int x, y; |
960 | int x, y; |
1006 | |
961 | |
1007 | x = ev.x; |
962 | x = ev.x; |
1008 | y = ev.y; |
963 | y = ev.y; |
1009 | pixel_position (&x, &y); |
964 | pixel_position (&x, &y); |
1010 | |
965 | |
… | |
… | |
1415 | pointer_unblank (); |
1370 | pointer_unblank (); |
1416 | #endif |
1371 | #endif |
1417 | #if MENUBAR |
1372 | #if MENUBAR |
1418 | if (isMenuBarWindow (ev.xany.window)) |
1373 | if (isMenuBarWindow (ev.xany.window)) |
1419 | { |
1374 | { |
1420 | menubar_control (& (ev.xbutton)); |
1375 | menubar_control (ev.xbutton); |
1421 | break; |
1376 | break; |
1422 | } |
1377 | } |
1423 | #endif |
1378 | #endif |
1424 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1379 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1425 | break; |
1380 | break; |
… | |
… | |
1554 | #endif |
1509 | #endif |
1555 | } |
1510 | } |
1556 | } |
1511 | } |
1557 | |
1512 | |
1558 | void |
1513 | void |
1559 | rxvt_term::button_press (const XButtonEvent &ev) |
1514 | rxvt_term::button_press (XButtonEvent &ev) |
1560 | { |
1515 | { |
1561 | int reportmode = 0, clickintime; |
1516 | int reportmode = 0, clickintime; |
1562 | |
1517 | |
1563 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1518 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1564 | if (!bypass_keystate) |
1519 | if (!bypass_keystate) |
… | |
… | |
1792 | menubar_control (ev); |
1747 | menubar_control (ev); |
1793 | #endif |
1748 | #endif |
1794 | } |
1749 | } |
1795 | |
1750 | |
1796 | void |
1751 | void |
1797 | rxvt_term::button_release (const XButtonEvent &ev) |
1752 | rxvt_term::button_release (XButtonEvent &ev) |
1798 | { |
1753 | { |
1799 | int reportmode = 0; |
1754 | int reportmode = 0; |
1800 | |
1755 | |
1801 | csrO = 0; /* reset csr Offset */ |
1756 | csrO = 0; /* reset csr Offset */ |
1802 | if (!bypass_keystate) |
1757 | if (!bypass_keystate) |
… | |
… | |
1964 | if (have_pixmap) |
1919 | if (have_pixmap) |
1965 | { |
1920 | { |
1966 | /* |
1921 | /* |
1967 | * Copy display->root pixmap transparency |
1922 | * Copy display->root pixmap transparency |
1968 | */ |
1923 | */ |
1969 | int sx, sy, nx, ny; |
1924 | int sx, sy, nx, ny; |
1970 | unsigned int nw, nh; |
1925 | unsigned int nw, nh; |
1971 | Window cr; |
1926 | Window cr; |
1972 | XImage *image; |
1927 | XImage *image; |
1973 | GC gc; |
1928 | GC gc; |
1974 | XGCValues gcvalue; |
1929 | XGCValues gcvalue; |
1975 | |
1930 | |
1976 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1931 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1977 | 0, 0, &sx, &sy, &cr); |
1932 | 0, 0, &sx, &sy, &cr); |
1978 | nw = (unsigned int)szHint.width; |
1933 | nw = (unsigned int)szHint.width; |
1979 | nh = (unsigned int)szHint.height; |
1934 | nh = (unsigned int)szHint.height; |
1980 | nx = ny = 0; |
1935 | nx = ny = 0; |
|
|
1936 | |
1981 | if (sx < 0) |
1937 | if (sx < 0) |
1982 | { |
1938 | { |
1983 | nw += sx; |
1939 | nw += sx; |
1984 | nx = -sx; |
1940 | nx = -sx; |
1985 | sx = 0; |
1941 | sx = 0; |
1986 | } |
1942 | } |
|
|
1943 | |
1987 | if (sy < 0) |
1944 | if (sy < 0) |
1988 | { |
1945 | { |
1989 | nh += sy; |
1946 | nh += sy; |
1990 | ny = -sy; |
1947 | ny = -sy; |
1991 | sy = 0; |
1948 | sy = 0; |
1992 | } |
1949 | } |
|
|
1950 | |
1993 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1951 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1994 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1952 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1995 | allowedxerror = -1; |
1953 | allowedxerror = -1; |
1996 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1954 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1997 | ZPixmap); |
1955 | ZPixmap); |
… | |
… | |
2030 | if (!am_transparent || !am_pixmap_trans) |
1988 | if (!am_transparent || !am_pixmap_trans) |
2031 | pchanged = 1; |
1989 | pchanged = 1; |
2032 | am_transparent = am_pixmap_trans = 1; |
1990 | am_transparent = am_pixmap_trans = 1; |
2033 | } |
1991 | } |
2034 | } |
1992 | } |
|
|
1993 | |
2035 | if (!am_pixmap_trans) |
1994 | if (!am_pixmap_trans) |
2036 | { |
1995 | { |
2037 | unsigned int n; |
1996 | unsigned int n; |
2038 | /* |
1997 | /* |
2039 | * InheritPixmap transparency |
1998 | * InheritPixmap transparency |
… | |
… | |
2054 | break; |
2013 | break; |
2055 | } |
2014 | } |
2056 | if (oldp != TermWin.parent[i]) |
2015 | if (oldp != TermWin.parent[i]) |
2057 | pchanged = 1; |
2016 | pchanged = 1; |
2058 | } |
2017 | } |
|
|
2018 | |
2059 | n = 0; |
2019 | n = 0; |
|
|
2020 | |
2060 | if (pchanged) |
2021 | if (pchanged) |
2061 | { |
2022 | { |
2062 | for (; n < (unsigned int)i; n++) |
2023 | for (; n < (unsigned int)i; n++) |
2063 | { |
2024 | { |
2064 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2025 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
… | |
… | |
2068 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2029 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2069 | break; |
2030 | break; |
2070 | } |
2031 | } |
2071 | } |
2032 | } |
2072 | } |
2033 | } |
|
|
2034 | |
2073 | if (n > (int) (sizeof (TermWin.parent) |
2035 | if (n > (int) (sizeof (TermWin.parent) |
2074 | / sizeof (TermWin.parent[0]))) |
2036 | / sizeof (TermWin.parent[0]))) |
2075 | { |
2037 | { |
2076 | D_X ((stderr, "InheritPixmap Turning off")); |
2038 | D_X ((stderr, "InheritPixmap Turning off")); |
2077 | XSetWindowBackground (display->display, TermWin.parent[0], |
2039 | XSetWindowBackground (display->display, TermWin.parent[0], |
… | |
… | |
2100 | ParentRelative); |
2062 | ParentRelative); |
2101 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2063 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2102 | ParentRelative); |
2064 | ParentRelative); |
2103 | am_transparent = 1; |
2065 | am_transparent = 1; |
2104 | } |
2066 | } |
|
|
2067 | |
2105 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2068 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2106 | TermWin.parent[i] = None; |
2069 | TermWin.parent[i] = None; |
2107 | } |
2070 | } |
2108 | return pchanged; |
2071 | return pchanged; |
2109 | } |
2072 | } |
… | |
… | |
2115 | /*----------------------------------------------------------------------*/ |
2078 | /*----------------------------------------------------------------------*/ |
2116 | #ifdef PRINTPIPE |
2079 | #ifdef PRINTPIPE |
2117 | FILE * |
2080 | FILE * |
2118 | rxvt_term::popen_printer () |
2081 | rxvt_term::popen_printer () |
2119 | { |
2082 | { |
2120 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2083 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2121 | |
2084 | |
2122 | if (stream == NULL) |
2085 | if (stream == NULL) |
2123 | rxvt_print_error ("can't open printer pipe"); |
2086 | rxvt_print_error ("can't open printer pipe"); |
2124 | return stream; |
2087 | return stream; |
2125 | } |
2088 | } |
… | |
… | |
2337 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2300 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2338 | break; |
2301 | break; |
2339 | case '+': |
2302 | case '+': |
2340 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2303 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2341 | break; |
2304 | break; |
2342 | #ifdef MULTICHAR_SET |
|
|
2343 | case '$': |
|
|
2344 | scr_charset_set (-2, (unsigned int)cmd_getc ()); |
|
|
2345 | break; |
|
|
2346 | #endif |
|
|
2347 | #ifndef NO_FRILLS |
2305 | #ifndef NO_FRILLS |
2348 | case '6': |
2306 | case '6': |
2349 | scr_backindex (); |
2307 | scr_backindex (); |
2350 | break; |
2308 | break; |
2351 | #endif |
2309 | #endif |
… | |
… | |
2692 | case 7: /* unofficial extension */ |
2650 | case 7: /* unofficial extension */ |
2693 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2651 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2694 | break; |
2652 | break; |
2695 | #endif |
2653 | #endif |
2696 | case 8: /* unofficial extension */ |
2654 | case 8: /* unofficial extension */ |
2697 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
2655 | xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2698 | break; |
2656 | break; |
2699 | } |
2657 | } |
2700 | break; |
2658 | break; |
2701 | |
2659 | |
2702 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
2660 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
2971 | * 19 = change underlined character color |
2929 | * 19 = change underlined character color |
2972 | * 46 = change logfile (not implemented) |
2930 | * 46 = change logfile (not implemented) |
2973 | * 50 = change font |
2931 | * 50 = change font |
2974 | * |
2932 | * |
2975 | * rxvt extensions: |
2933 | * rxvt extensions: |
2976 | * 9 = change locale (NYI) |
|
|
2977 | * 10 = menu (may change in future) |
2934 | * 10 = menu (may change in future) |
2978 | * 20 = bg pixmap |
2935 | * 20 = bg pixmap |
2979 | * 39 = change default fg color |
2936 | * 39 = change default fg color |
2980 | * 49 = change default bg color |
2937 | * 49 = change default bg color |
2981 | * 55 = dump scrollback buffer and all of screen |
2938 | * 55 = dump scrollback buffer and all of screen |
|
|
2939 | * 701 = change locale |
|
|
2940 | * 702 = find font |
2982 | */ |
2941 | */ |
2983 | void |
2942 | void |
2984 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2943 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2985 | { |
2944 | { |
2986 | int changed = 0; |
2945 | int changed = 0; |
… | |
… | |
3074 | case XTerm_logfile: |
3033 | case XTerm_logfile: |
3075 | break; |
3034 | break; |
3076 | case XTerm_font: |
3035 | case XTerm_font: |
3077 | change_font (str); |
3036 | change_font (str); |
3078 | break; |
3037 | break; |
|
|
3038 | #ifndef NO_FRILLS |
3079 | case XTerm_locale: |
3039 | case XTerm_locale: |
3080 | if (str[0] == '?' && !str[1]) |
3040 | if (str[0] == '?' && !str[1]) |
3081 | tt_printf ("%-.250s\n", locale); |
3041 | tt_printf ("%-.250s\n", locale); |
3082 | else |
3042 | else |
3083 | { |
3043 | { |
3084 | set_locale (str); |
3044 | set_locale (str); |
|
|
3045 | # ifdef USE_XIM |
3085 | im_cb (); |
3046 | im_cb (); |
|
|
3047 | # endif |
3086 | } |
3048 | } |
3087 | break; |
3049 | break; |
|
|
3050 | case XTerm_findfont: |
|
|
3051 | { |
|
|
3052 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3053 | tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); |
|
|
3054 | } |
|
|
3055 | break; |
|
|
3056 | #endif |
3088 | #if 0 |
3057 | #if 0 |
3089 | case XTerm_dumpscreen: /* no error notices */ |
3058 | case XTerm_dumpscreen: /* no error notices */ |
3090 | { |
3059 | { |
3091 | int fd; |
3060 | int fd; |
3092 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3061 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3220 | */ |
3189 | */ |
3221 | PrivMode (1, PrivMode_vt52); |
3190 | PrivMode (1, PrivMode_vt52); |
3222 | break; |
3191 | break; |
3223 | case 3: /* 80/132 */ |
3192 | case 3: /* 80/132 */ |
3224 | if (PrivateModes & PrivMode_132OK) |
3193 | if (PrivateModes & PrivMode_132OK) |
3225 | set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), |
3194 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
3226 | (unsigned int)TermWin.height); |
|
|
3227 | break; |
3195 | break; |
3228 | case 4: /* smooth scrolling */ |
3196 | case 4: /* smooth scrolling */ |
3229 | if (state) |
3197 | if (state) |
3230 | Options &= ~Opt_jumpScroll; |
3198 | Options &= ~Opt_jumpScroll; |
3231 | else |
3199 | else |