… | |
… | |
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 (0, FONT_UP); |
|
|
147 | return; |
|
|
148 | } |
|
|
149 | else if (keysym == ks_smallfont) |
|
|
150 | { |
|
|
151 | change_font (0, 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 | { |
… | |
… | |
229 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
217 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
230 | selection_request (ev.time, 0, 0); |
218 | selection_request (ev.time, 0, 0); |
231 | return; |
219 | return; |
232 | /* rxvt extras */ |
220 | /* rxvt extras */ |
233 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
221 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
234 | change_font (0, FONT_UP); |
222 | change_font (FONT_UP); |
235 | return; |
223 | return; |
236 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
224 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
237 | change_font (0, FONT_DN); |
225 | change_font (FONT_DN); |
238 | return; |
226 | return; |
239 | } |
227 | } |
240 | } |
228 | } |
241 | } |
229 | } |
242 | #ifdef PRINTPIPE |
230 | #ifdef PRINTPIPE |
243 | if (keysym == XK_Print) |
231 | if (keysym == XK_Print) |
244 | { |
232 | { |
245 | scr_printscreen (ctrl | shft); |
233 | 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; |
234 | return; |
263 | } |
235 | } |
264 | #endif |
236 | #endif |
265 | |
237 | |
266 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
238 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
… | |
… | |
268 | #ifdef KEYSYM_RESOURCE |
240 | #ifdef KEYSYM_RESOURCE |
269 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
241 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
270 | { |
242 | { |
271 | unsigned int l; |
243 | unsigned int l; |
272 | const unsigned char *kbuf0; |
244 | const unsigned char *kbuf0; |
273 | const unsigned char ch = C0_ESC; |
|
|
274 | |
245 | |
275 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
246 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
276 | l = (unsigned int)*kbuf0++; |
247 | l = (unsigned int)*kbuf0++; |
277 | |
248 | |
278 | /* escape prefix */ |
249 | /* escape prefix */ |
279 | if (meta) |
250 | if (meta |
280 | # ifdef META8_OPTION |
251 | # ifdef META8_OPTION |
281 | if (meta_char == C0_ESC) |
252 | && meta_char == C0_ESC |
282 | # endif |
253 | # endif |
|
|
254 | ) |
|
|
255 | { |
|
|
256 | const unsigned char ch = C0_ESC; |
283 | tt_write (&ch, 1); |
257 | tt_write (&ch, 1); |
|
|
258 | } |
|
|
259 | |
284 | tt_write (kbuf0, l); |
260 | tt_write (kbuf0, l); |
285 | return; |
261 | return; |
286 | } |
262 | } |
287 | else |
263 | else |
288 | #endif |
264 | #endif |
… | |
… | |
298 | ^ !!ctrl) ? '\b' : '\177'; |
274 | ^ !!ctrl) ? '\b' : '\177'; |
299 | kbuf[1] = '\0'; |
275 | kbuf[1] = '\0'; |
300 | } |
276 | } |
301 | else |
277 | else |
302 | STRCPY (kbuf, key_backspace); |
278 | STRCPY (kbuf, key_backspace); |
303 | # ifdef MULTICHAR_SET |
|
|
304 | if ((Options & Opt_mc_hack) && screen.cur.col > 0) |
|
|
305 | { |
|
|
306 | int col, row; |
|
|
307 | |
|
|
308 | newlen = STRLEN (kbuf); |
|
|
309 | col = screen.cur.col - 1; |
|
|
310 | row = screen.cur.row + TermWin.saveLines; |
|
|
311 | if (IS_MULTI2 (screen.rend[row][col])) |
|
|
312 | MEMMOVE (kbuf + newlen, kbuf, newlen + 1); |
|
|
313 | } |
|
|
314 | # endif |
|
|
315 | break; |
279 | break; |
316 | #endif |
280 | #endif |
317 | #ifndef NO_DELETE_KEY |
281 | #ifndef NO_DELETE_KEY |
318 | case XK_Delete: |
282 | case XK_Delete: |
319 | STRCPY (kbuf, key_delete); |
283 | STRCPY (kbuf, key_delete); |
320 | # ifdef MULTICHAR_SET |
|
|
321 | if (Options & Opt_mc_hack) |
|
|
322 | { |
|
|
323 | int col, row; |
|
|
324 | |
|
|
325 | newlen = STRLEN (kbuf); |
|
|
326 | col = screen.cur.col; |
|
|
327 | row = screen.cur.row + TermWin.saveLines; |
|
|
328 | if (IS_MULTI1 (screen.rend[row][col])) |
|
|
329 | MEMMOVE (kbuf + newlen, kbuf, newlen + 1); |
|
|
330 | } |
|
|
331 | # endif |
|
|
332 | break; |
284 | break; |
333 | #endif |
285 | #endif |
334 | case XK_Tab: |
286 | case XK_Tab: |
335 | if (shft) |
287 | if (shft) |
336 | STRCPY (kbuf, "\033[Z"); |
288 | STRCPY (kbuf, "\033[Z"); |
… | |
… | |
378 | kbuf[1] = 'O'; |
330 | kbuf[1] = 'O'; |
379 | kbuf[2] = "dacb"[keysym - XK_Left]; |
331 | kbuf[2] = "dacb"[keysym - XK_Left]; |
380 | } |
332 | } |
381 | else if (PrivateModes & PrivMode_aplCUR) |
333 | else if (PrivateModes & PrivMode_aplCUR) |
382 | kbuf[1] = 'O'; |
334 | kbuf[1] = 'O'; |
383 | #ifdef MULTICHAR_SET |
|
|
384 | //TODO: ?? |
|
|
385 | if (Options & Opt_mc_hack) |
|
|
386 | { |
|
|
387 | int col, row, m; |
|
|
388 | |
|
|
389 | col = screen.cur.col; |
|
|
390 | row = screen.cur.row + TermWin.saveLines; |
|
|
391 | m = 0; |
|
|
392 | if (keysym == XK_Right |
|
|
393 | && IS_MULTI1 (screen.rend[row][col])) |
|
|
394 | m = 1; |
|
|
395 | else if (keysym == XK_Left) |
|
|
396 | { |
|
|
397 | if (col > 0) |
|
|
398 | { |
|
|
399 | if (IS_MULTI2 (screen.rend[row][col - 1])) |
|
|
400 | m = 1; |
|
|
401 | } |
|
|
402 | else if (screen.cur.row > 0) |
|
|
403 | { |
|
|
404 | col = screen.tlen[--row]; |
|
|
405 | if (col == -1) |
|
|
406 | col = TermWin.ncol - 1; |
|
|
407 | else |
|
|
408 | col--; |
|
|
409 | if (col > 0 |
|
|
410 | && IS_MULTI2 (screen.rend[row][col])) |
|
|
411 | m = 1; |
|
|
412 | } |
|
|
413 | } |
|
|
414 | if (m) |
|
|
415 | MEMMOVE (kbuf + 3, kbuf, 3 + 1); |
|
|
416 | } |
|
|
417 | #endif |
|
|
418 | break; |
335 | break; |
419 | |
336 | |
420 | #ifndef UNSHIFTED_SCROLLKEYS |
337 | #ifndef UNSHIFTED_SCROLLKEYS |
421 | # ifdef XK_KP_Prior |
338 | # ifdef XK_KP_Prior |
422 | case XK_KP_Prior: |
339 | case XK_KP_Prior: |
… | |
… | |
611 | break; |
528 | break; |
612 | } |
529 | } |
613 | if (newlen) |
530 | if (newlen) |
614 | len = STRLEN (kbuf); |
531 | len = STRLEN (kbuf); |
615 | } |
532 | } |
|
|
533 | |
616 | /* |
534 | /* |
617 | * Pass meta for all function keys, if 'meta' option set |
535 | * Pass meta for all function keys, if 'meta' option set |
618 | */ |
536 | */ |
619 | #ifdef META8_OPTION |
537 | #ifdef META8_OPTION |
620 | if (meta && (meta_char == 0x80) && len > 0) |
538 | if (meta && (meta_char == 0x80) && len > 0) |
… | |
… | |
635 | { |
553 | { |
636 | unsigned char *ch; |
554 | unsigned char *ch; |
637 | |
555 | |
638 | for (ch = kbuf; ch < kbuf + len; ch++) |
556 | for (ch = kbuf; ch < kbuf + len; ch++) |
639 | *ch |= 0x80; |
557 | *ch |= 0x80; |
|
|
558 | |
640 | meta = 0; |
559 | meta = 0; |
641 | } |
560 | } |
642 | #endif |
|
|
643 | #ifdef GREEK_SUPPORT |
|
|
644 | if (greek_mode) |
|
|
645 | len = greek_xlat (kbuf, len); |
|
|
646 | #endif |
561 | #endif |
647 | /* nil */ ; |
562 | /* nil */ ; |
648 | } |
563 | } |
649 | } |
564 | } |
650 | |
565 | |
… | |
… | |
673 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
588 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
674 | |
589 | |
675 | /* escape prefix */ |
590 | /* escape prefix */ |
676 | if (meta |
591 | if (meta |
677 | #ifdef META8_OPTION |
592 | #ifdef META8_OPTION |
678 | && (meta_char == C0_ESC) |
593 | && meta_char == C0_ESC |
679 | #endif |
594 | #endif |
680 | ) |
595 | ) |
681 | { |
596 | { |
682 | const unsigned char ch = C0_ESC; |
597 | const unsigned char ch = C0_ESC; |
683 | |
|
|
684 | tt_write (&ch, 1); |
598 | tt_write (&ch, 1); |
685 | } |
599 | } |
|
|
600 | |
686 | #ifdef DEBUG_CMD |
601 | #if defined(DEBUG_CMD) |
687 | if (debug_key) |
|
|
688 | { /* Display keyboard buffer contents */ |
602 | /* Display keyboard buffer contents */ |
689 | char *p; |
603 | unsigned char *p; |
690 | int i; |
604 | int i; |
691 | |
605 | |
692 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
606 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
693 | for (i = 0, p = kbuf; i < len; i++, p++) |
607 | for (i = 0, p = kbuf; i < len; i++, p++) |
694 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
608 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
695 | fprintf (stderr, "'\n"); |
609 | fprintf (stderr, "'\n"); |
696 | } |
|
|
697 | #endif /* DEBUG_CMD */ |
610 | #endif /* DEBUG_CMD */ |
698 | tt_write (kbuf, (unsigned int)len); |
611 | tt_write (kbuf, (unsigned int)len); |
699 | } |
612 | } |
700 | /*}}} */ |
613 | /*}}} */ |
701 | |
614 | |
… | |
… | |
707 | { |
620 | { |
708 | unsigned int n, s; |
621 | unsigned int n, s; |
709 | |
622 | |
710 | n = cmdbuf_ptr - cmdbuf_base; |
623 | n = cmdbuf_ptr - cmdbuf_base; |
711 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
624 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
|
|
625 | |
712 | if (n > 0 && s < count) |
626 | if (n > 0 && s < count) |
713 | { |
627 | { |
714 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
628 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
715 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
629 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
716 | cmdbuf_ptr = cmdbuf_base; |
630 | cmdbuf_ptr = cmdbuf_base; |
717 | cmdbuf_endp -= n; |
631 | cmdbuf_endp -= n; |
718 | s += n; |
632 | s += n; |
719 | } |
633 | } |
|
|
634 | |
720 | if (count > s) |
635 | if (count > s) |
721 | { |
636 | { |
722 | rxvt_print_error ("data loss: cmd_write too large"); |
637 | rxvt_print_error ("data loss: cmd_write too large"); |
723 | count = s; |
638 | count = s; |
724 | } |
639 | } |
|
|
640 | |
725 | for (; count--;) |
641 | for (; count--;) |
726 | *cmdbuf_endp++ = *str++; |
642 | *cmdbuf_endp++ = *str++; |
|
|
643 | |
|
|
644 | cmd_parse (); |
|
|
645 | |
727 | return 0; |
646 | return 0; |
728 | } |
647 | } |
729 | #endif /* MENUBAR_MAX */ |
648 | #endif /* MENUBAR_MAX */ |
730 | |
649 | |
731 | void |
650 | void |
… | |
… | |
803 | cmdbuf_endp += n; |
722 | cmdbuf_endp += n; |
804 | return true; |
723 | return true; |
805 | } |
724 | } |
806 | else if (n < 0 && errno != EAGAIN) |
725 | else if (n < 0 && errno != EAGAIN) |
807 | destroy (); |
726 | destroy (); |
808 | |
727 | |
809 | return false; |
728 | return false; |
810 | } |
729 | } |
811 | |
730 | |
812 | void |
731 | void |
813 | rxvt_term::pty_cb (io_watcher &w, short revents) |
732 | rxvt_term::pty_cb (io_watcher &w, short revents) |
… | |
… | |
830 | seen_input = 1; |
749 | seen_input = 1; |
831 | /* 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! */ |
832 | tt_winch (); |
751 | tt_winch (); |
833 | } |
752 | } |
834 | |
753 | |
|
|
754 | if (cmd_parse ()) |
|
|
755 | break; |
|
|
756 | } |
|
|
757 | } |
|
|
758 | } |
|
|
759 | |
|
|
760 | bool |
|
|
761 | rxvt_term::cmd_parse () |
|
|
762 | { |
|
|
763 | bool flag = false; |
835 | 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; |
836 | |
783 | |
837 | for (;;) |
784 | for (;;) |
838 | { |
785 | { |
839 | if (ch == NOCHAR) |
|
|
840 | ch = next_char (); |
786 | ch = next_char (); |
841 | |
787 | |
842 | if (ch == NOCHAR) // TODO: improve |
788 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
843 | break; |
789 | break; |
844 | |
790 | else |
845 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
846 | { |
791 | { |
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; |
792 | *str++ = ch; |
854 | |
793 | |
855 | for (;;) |
794 | if (ch == '\n') |
856 | { |
795 | { |
857 | ch = next_char (); |
|
|
858 | |
|
|
859 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
860 | break; |
|
|
861 | else |
796 | nlines++; |
|
|
797 | refresh_count++; |
|
|
798 | |
|
|
799 | if (! (Options & Opt_jumpScroll) |
|
|
800 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
862 | { |
801 | { |
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; |
802 | refreshnow = true; |
874 | flag = false; |
803 | flag = false; |
875 | ch = NOCHAR; |
804 | ch = NOCHAR; |
876 | break; |
805 | break; |
877 | } |
806 | } |
878 | |
807 | |
879 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
808 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
880 | if (nlines >= TermWin.nrow - 1) |
809 | if (nlines >= TermWin.nrow - 1) |
881 | { |
810 | { |
882 | scr_add_lines (buf, nlines, str - buf); |
811 | scr_add_lines (buf, nlines, str - buf); |
883 | nlines = 0; |
812 | nlines = 0; |
884 | str = buf; |
813 | str = buf; |
885 | } |
|
|
886 | } |
|
|
887 | |
|
|
888 | if (str >= buf + BUFSIZ) |
|
|
889 | { |
|
|
890 | ch = NOCHAR; |
|
|
891 | break; |
|
|
892 | } |
|
|
893 | } |
814 | } |
894 | } |
815 | } |
895 | |
816 | |
896 | scr_add_lines (buf, nlines, str - buf); |
817 | 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 | { |
818 | { |
909 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
819 | ch = NOCHAR; |
910 | refresh_limit++; |
820 | break; |
911 | |
|
|
912 | scr_refresh (refresh_type); |
|
|
913 | } |
821 | } |
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 | } |
822 | } |
932 | } |
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 |
933 | } |
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 | } |
934 | } |
861 | } |
|
|
862 | |
|
|
863 | return flag; |
935 | } |
864 | } |
936 | |
865 | |
937 | // read the next character, currently handles UTF-8 |
866 | // read the next character, currently handles UTF-8 |
938 | // will probably handle all sorts of other stuff in the future |
867 | // will probably handle all sorts of other stuff in the future |
939 | uint32_t |
868 | uint32_t |
940 | rxvt_term::next_char () |
869 | rxvt_term::next_char () |
941 | { |
870 | { |
942 | while (cmdbuf_ptr < cmdbuf_endp) |
871 | while (cmdbuf_ptr < cmdbuf_endp) |
943 | { |
872 | { |
944 | 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) |
945 | return *cmdbuf_ptr++; |
876 | return *cmdbuf_ptr++; |
946 | |
877 | |
947 | wchar_t wc; |
878 | wchar_t wc; |
948 | 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); |
949 | |
880 | |
950 | if (len == (size_t)-2) |
881 | if (len == (size_t)-2) |
951 | return NOCHAR; |
882 | { |
|
|
883 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
884 | cmdbuf_ptr = cmdbuf_endp; |
|
|
885 | break; |
|
|
886 | } |
952 | |
887 | |
953 | if (len == (size_t)-1) |
888 | if (len == (size_t)-1) |
954 | 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 |
955 | |
890 | |
956 | // assume wchar == unicode |
891 | // assume wchar == unicode |
… | |
… | |
1017 | pointer_blank (); |
952 | pointer_blank (); |
1018 | } |
953 | } |
1019 | #endif |
954 | #endif |
1020 | |
955 | |
1021 | void |
956 | void |
1022 | rxvt_term::mouse_report (const XButtonEvent &ev) |
957 | rxvt_term::mouse_report (XButtonEvent &ev) |
1023 | { |
958 | { |
1024 | int button_number, key_state = 0; |
959 | int button_number, key_state = 0; |
1025 | int x, y; |
960 | int x, y; |
1026 | |
961 | |
1027 | x = ev.x; |
962 | x = ev.x; |
1028 | y = ev.y; |
963 | y = ev.y; |
1029 | pixel_position (&x, &y); |
964 | pixel_position (&x, &y); |
1030 | |
965 | |
… | |
… | |
1424 | } |
1359 | } |
1425 | #ifdef MENUBAR |
1360 | #ifdef MENUBAR |
1426 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1361 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1427 | menubar_expose (); |
1362 | menubar_expose (); |
1428 | #endif |
1363 | #endif |
1429 | #ifdef RXVT_GRAPHICS |
|
|
1430 | Gr_expose (ev.xany.window); |
|
|
1431 | #endif |
|
|
1432 | |
|
|
1433 | } |
1364 | } |
1434 | break; |
1365 | break; |
1435 | |
1366 | |
1436 | case MotionNotify: |
1367 | case MotionNotify: |
1437 | #ifdef POINTER_BLANK |
1368 | #ifdef POINTER_BLANK |
… | |
… | |
1439 | pointer_unblank (); |
1370 | pointer_unblank (); |
1440 | #endif |
1371 | #endif |
1441 | #if MENUBAR |
1372 | #if MENUBAR |
1442 | if (isMenuBarWindow (ev.xany.window)) |
1373 | if (isMenuBarWindow (ev.xany.window)) |
1443 | { |
1374 | { |
1444 | menubar_control (& (ev.xbutton)); |
1375 | menubar_control (ev.xbutton); |
1445 | break; |
1376 | break; |
1446 | } |
1377 | } |
1447 | #endif |
1378 | #endif |
1448 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1379 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1449 | break; |
1380 | break; |
… | |
… | |
1578 | #endif |
1509 | #endif |
1579 | } |
1510 | } |
1580 | } |
1511 | } |
1581 | |
1512 | |
1582 | void |
1513 | void |
1583 | rxvt_term::button_press (const XButtonEvent &ev) |
1514 | rxvt_term::button_press (XButtonEvent &ev) |
1584 | { |
1515 | { |
1585 | int reportmode = 0, clickintime; |
1516 | int reportmode = 0, clickintime; |
1586 | |
1517 | |
1587 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1518 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1588 | if (!bypass_keystate) |
1519 | if (!bypass_keystate) |
… | |
… | |
1590 | /* |
1521 | /* |
1591 | * VT window processing of button press |
1522 | * VT window processing of button press |
1592 | */ |
1523 | */ |
1593 | if (ev.window == TermWin.vt) |
1524 | if (ev.window == TermWin.vt) |
1594 | { |
1525 | { |
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; |
1526 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1603 | if (reportmode) |
1527 | if (reportmode) |
|
|
1528 | { |
|
|
1529 | /* mouse report from vt window */ |
|
|
1530 | /* save the xbutton state (for ButtonRelease) */ |
|
|
1531 | MEvent.state = ev.state; |
|
|
1532 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1533 | if (ev.button == MEvent.button && clickintime) |
1604 | { |
1534 | { |
1605 | /* mouse report from vt window */ |
1535 | /* same button, within alloted time */ |
1606 | /* save the xbutton state (for ButtonRelease) */ |
1536 | MEvent.clicks++; |
1607 | MEvent.state = ev.state; |
1537 | if (MEvent.clicks > 1) |
1608 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1609 | if (ev.button == MEvent.button && clickintime) |
|
|
1610 | { |
1538 | { |
1611 | /* same button, within alloted time */ |
|
|
1612 | MEvent.clicks++; |
|
|
1613 | if (MEvent.clicks > 1) |
|
|
1614 | { |
|
|
1615 | /* only report double clicks */ |
1539 | /* only report double clicks */ |
1616 | MEvent.clicks = 2; |
1540 | MEvent.clicks = 2; |
1617 | mouse_report (ev); |
1541 | mouse_report (ev); |
1618 | |
1542 | |
1619 | /* don't report the release */ |
1543 | /* don't report the release */ |
1620 | MEvent.clicks = 0; |
1544 | MEvent.clicks = 0; |
1621 | MEvent.button = AnyButton; |
1545 | MEvent.button = AnyButton; |
1622 | } |
|
|
1623 | } |
1546 | } |
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 | } |
1547 | } |
1637 | else |
1548 | else |
1638 | { |
1549 | { |
|
|
1550 | /* different button, or time expired */ |
|
|
1551 | MEvent.clicks = 1; |
|
|
1552 | MEvent.button = ev.button; |
|
|
1553 | mouse_report (ev); |
|
|
1554 | } |
|
|
1555 | #else |
|
|
1556 | MEvent.button = ev.button; |
|
|
1557 | mouse_report (ev); |
|
|
1558 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1559 | |
|
|
1560 | } |
|
|
1561 | else |
|
|
1562 | { |
1639 | if (ev.button != MEvent.button) |
1563 | if (ev.button != MEvent.button) |
1640 | MEvent.clicks = 0; |
1564 | MEvent.clicks = 0; |
1641 | switch (ev.button) |
1565 | switch (ev.button) |
1642 | { |
1566 | { |
1643 | case Button1: |
1567 | case Button1: |
1644 | /* allow shift+left click to extend selection */ |
1568 | /* allow shift+left click to extend selection */ |
1645 | if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) |
1569 | if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) |
1646 | { |
1570 | { |
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) |
1571 | if (MEvent.button == Button1 && clickintime) |
1667 | selection_rotate (ev.x, ev.y); |
1572 | selection_rotate (ev.x, ev.y); |
1668 | else |
1573 | else |
1669 | selection_extend (ev.x, ev.y, 1); |
1574 | selection_extend (ev.x, ev.y, 1); |
|
|
1575 | } |
|
|
1576 | else |
|
|
1577 | { |
|
|
1578 | if (MEvent.button == Button1 && clickintime) |
|
|
1579 | MEvent.clicks++; |
|
|
1580 | else |
|
|
1581 | MEvent.clicks = 1; |
|
|
1582 | |
|
|
1583 | selection_click (MEvent.clicks, ev.x, ev.y); |
|
|
1584 | } |
|
|
1585 | |
|
|
1586 | MEvent.button = Button1; |
|
|
1587 | break; |
|
|
1588 | |
|
|
1589 | case Button3: |
|
|
1590 | if (MEvent.button == Button3 && clickintime) |
|
|
1591 | selection_rotate (ev.x, ev.y); |
|
|
1592 | else |
|
|
1593 | selection_extend (ev.x, ev.y, 1); |
1670 | MEvent.button = Button3; |
1594 | MEvent.button = Button3; |
1671 | break; |
1595 | break; |
1672 | } |
|
|
1673 | } |
1596 | } |
|
|
1597 | } |
1674 | MEvent.time = ev.time; |
1598 | MEvent.time = ev.time; |
1675 | return; |
1599 | return; |
1676 | } |
|
|
1677 | } |
1600 | } |
1678 | |
1601 | |
1679 | /* |
1602 | /* |
1680 | * Scrollbar window processing of button press |
1603 | * Scrollbar window processing of button press |
1681 | */ |
1604 | */ |
… | |
… | |
1824 | menubar_control (ev); |
1747 | menubar_control (ev); |
1825 | #endif |
1748 | #endif |
1826 | } |
1749 | } |
1827 | |
1750 | |
1828 | void |
1751 | void |
1829 | rxvt_term::button_release (const XButtonEvent &ev) |
1752 | rxvt_term::button_release (XButtonEvent &ev) |
1830 | { |
1753 | { |
1831 | int reportmode = 0; |
1754 | int reportmode = 0; |
1832 | |
1755 | |
1833 | csrO = 0; /* reset csr Offset */ |
1756 | csrO = 0; /* reset csr Offset */ |
1834 | if (!bypass_keystate) |
1757 | if (!bypass_keystate) |
… | |
… | |
1846 | #ifdef SELECTION_SCROLLING |
1769 | #ifdef SELECTION_SCROLLING |
1847 | pending_scroll_selection=0; |
1770 | pending_scroll_selection=0; |
1848 | #endif |
1771 | #endif |
1849 | if (ev.window == TermWin.vt) |
1772 | if (ev.window == TermWin.vt) |
1850 | { |
1773 | { |
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) |
1774 | if (reportmode) |
|
|
1775 | { |
|
|
1776 | /* mouse report from vt window */ |
|
|
1777 | /* don't report release of wheel "buttons" */ |
|
|
1778 | if (ev.button >= 4) |
|
|
1779 | return; |
|
|
1780 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1781 | /* only report the release of 'slow' single clicks */ |
|
|
1782 | if (MEvent.button != AnyButton |
|
|
1783 | && (ev.button != MEvent.button |
|
|
1784 | || (ev.time - MEvent.time |
|
|
1785 | > MULTICLICK_TIME / 2))) |
1859 | { |
1786 | { |
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; |
1787 | MEvent.clicks = 0; |
1872 | MEvent.button = AnyButton; |
|
|
1873 | mouse_report (ev); |
|
|
1874 | } |
|
|
1875 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1876 | MEvent.button = AnyButton; |
1788 | MEvent.button = AnyButton; |
1877 | mouse_report (ev); |
1789 | mouse_report (ev); |
|
|
1790 | } |
|
|
1791 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1792 | MEvent.button = AnyButton; |
|
|
1793 | mouse_report (ev); |
1878 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1794 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1879 | return; |
1795 | return; |
1880 | } |
1796 | } |
1881 | /* |
1797 | /* |
1882 | * dumb hack to compensate for the failure of click-and-drag |
1798 | * dumb hack to compensate for the failure of click-and-drag |
1883 | * when overriding mouse reporting |
1799 | * when overriding mouse reporting |
1884 | */ |
1800 | */ |
1885 | if (PrivateModes & PrivMode_mouse_report |
1801 | if (PrivateModes & PrivMode_mouse_report |
1886 | && bypass_keystate |
1802 | && bypass_keystate |
1887 | && ev.button == Button1 && MEvent.clicks <= 1) |
1803 | && ev.button == Button1 && MEvent.clicks <= 1) |
1888 | selection_extend (ev.x, ev.y, 0); |
1804 | selection_extend (ev.x, ev.y, 0); |
1889 | |
1805 | |
1890 | switch (ev.button) |
1806 | switch (ev.button) |
|
|
1807 | { |
|
|
1808 | case Button1: |
|
|
1809 | case Button3: |
|
|
1810 | selection_make (ev.time); |
|
|
1811 | break; |
|
|
1812 | case Button2: |
|
|
1813 | selection_request (ev.time, ev.x, ev.y); |
|
|
1814 | break; |
|
|
1815 | #ifdef MOUSE_WHEEL |
|
|
1816 | case Button4: |
|
|
1817 | case Button5: |
1891 | { |
1818 | { |
1892 | case Button1: |
1819 | int i; |
1893 | case Button3: |
1820 | page_dirn v; |
1894 | selection_make (ev.time); |
1821 | |
|
|
1822 | v = (ev.button == Button4) ? UP : DN; |
|
|
1823 | if (ev.state & ShiftMask) |
1895 | break; |
1824 | i = 1; |
1896 | case Button2: |
1825 | else if ((Options & Opt_mouseWheelScrollPage)) |
1897 | selection_request (ev.time, ev.x, ev.y); |
1826 | i = TermWin.nrow - 1; |
|
|
1827 | else |
1898 | break; |
1828 | i = 5; |
1899 | #ifdef MOUSE_WHEEL |
1829 | # ifdef MOUSE_SLIP_WHEELING |
1900 | case Button4: |
1830 | if (ev.state & ControlMask) |
1901 | case Button5: |
|
|
1902 | { |
1831 | { |
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); |
1832 | mouse_slip_wheel_speed += (v ? -1 : 1); |
1917 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1833 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1918 | } |
1834 | } |
1919 | # endif |
1835 | # endif |
1920 | # ifdef JUMP_MOUSE_WHEEL |
1836 | # ifdef JUMP_MOUSE_WHEEL |
|
|
1837 | scr_page (v, i); |
|
|
1838 | scr_refresh (SMOOTH_REFRESH); |
|
|
1839 | scrollbar_show (1); |
|
|
1840 | # else |
|
|
1841 | while (i--) |
|
|
1842 | { |
1921 | scr_page (v, i); |
1843 | scr_page (v, 1); |
1922 | scr_refresh (SMOOTH_REFRESH); |
1844 | scr_refresh (SMOOTH_REFRESH); |
1923 | scrollbar_show (1); |
1845 | scrollbar_show (1); |
1924 | # else |
|
|
1925 | while (i--) |
|
|
1926 | { |
|
|
1927 | scr_page (v, 1); |
|
|
1928 | scr_refresh (SMOOTH_REFRESH); |
|
|
1929 | scrollbar_show (1); |
|
|
1930 | } |
1846 | } |
1931 | # endif |
1847 | # endif |
1932 | |
1848 | |
1933 | } |
|
|
1934 | break; |
|
|
1935 | #endif |
|
|
1936 | |
|
|
1937 | } |
1849 | } |
|
|
1850 | break; |
|
|
1851 | #endif |
|
|
1852 | |
1938 | } |
1853 | } |
1939 | } |
1854 | } |
1940 | #ifdef MENUBAR |
1855 | #ifdef MENUBAR |
1941 | else if (isMenuBarWindow (ev.window)) |
1856 | else if (isMenuBarWindow (ev.window)) |
1942 | menubar_control (ev); |
1857 | menubar_control (ev); |
… | |
… | |
2004 | if (have_pixmap) |
1919 | if (have_pixmap) |
2005 | { |
1920 | { |
2006 | /* |
1921 | /* |
2007 | * Copy display->root pixmap transparency |
1922 | * Copy display->root pixmap transparency |
2008 | */ |
1923 | */ |
2009 | int sx, sy, nx, ny; |
1924 | int sx, sy, nx, ny; |
2010 | unsigned int nw, nh; |
1925 | unsigned int nw, nh; |
2011 | Window cr; |
1926 | Window cr; |
2012 | XImage *image; |
1927 | XImage *image; |
2013 | GC gc; |
1928 | GC gc; |
2014 | XGCValues gcvalue; |
1929 | XGCValues gcvalue; |
2015 | |
1930 | |
2016 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1931 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2017 | 0, 0, &sx, &sy, &cr); |
1932 | 0, 0, &sx, &sy, &cr); |
2018 | nw = (unsigned int)szHint.width; |
1933 | nw = (unsigned int)szHint.width; |
2019 | nh = (unsigned int)szHint.height; |
1934 | nh = (unsigned int)szHint.height; |
2020 | nx = ny = 0; |
1935 | nx = ny = 0; |
|
|
1936 | |
2021 | if (sx < 0) |
1937 | if (sx < 0) |
2022 | { |
1938 | { |
2023 | nw += sx; |
1939 | nw += sx; |
2024 | nx = -sx; |
1940 | nx = -sx; |
2025 | sx = 0; |
1941 | sx = 0; |
2026 | } |
1942 | } |
|
|
1943 | |
2027 | if (sy < 0) |
1944 | if (sy < 0) |
2028 | { |
1945 | { |
2029 | nh += sy; |
1946 | nh += sy; |
2030 | ny = -sy; |
1947 | ny = -sy; |
2031 | sy = 0; |
1948 | sy = 0; |
2032 | } |
1949 | } |
|
|
1950 | |
2033 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1951 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2034 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1952 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2035 | allowedxerror = -1; |
1953 | allowedxerror = -1; |
2036 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1954 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
2037 | ZPixmap); |
1955 | ZPixmap); |
… | |
… | |
2070 | if (!am_transparent || !am_pixmap_trans) |
1988 | if (!am_transparent || !am_pixmap_trans) |
2071 | pchanged = 1; |
1989 | pchanged = 1; |
2072 | am_transparent = am_pixmap_trans = 1; |
1990 | am_transparent = am_pixmap_trans = 1; |
2073 | } |
1991 | } |
2074 | } |
1992 | } |
|
|
1993 | |
2075 | if (!am_pixmap_trans) |
1994 | if (!am_pixmap_trans) |
2076 | { |
1995 | { |
2077 | unsigned int n; |
1996 | unsigned int n; |
2078 | /* |
1997 | /* |
2079 | * InheritPixmap transparency |
1998 | * InheritPixmap transparency |
… | |
… | |
2094 | break; |
2013 | break; |
2095 | } |
2014 | } |
2096 | if (oldp != TermWin.parent[i]) |
2015 | if (oldp != TermWin.parent[i]) |
2097 | pchanged = 1; |
2016 | pchanged = 1; |
2098 | } |
2017 | } |
|
|
2018 | |
2099 | n = 0; |
2019 | n = 0; |
|
|
2020 | |
2100 | if (pchanged) |
2021 | if (pchanged) |
2101 | { |
2022 | { |
2102 | for (; n < (unsigned int)i; n++) |
2023 | for (; n < (unsigned int)i; n++) |
2103 | { |
2024 | { |
2104 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2025 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
… | |
… | |
2108 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2029 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2109 | break; |
2030 | break; |
2110 | } |
2031 | } |
2111 | } |
2032 | } |
2112 | } |
2033 | } |
|
|
2034 | |
2113 | if (n > (int) (sizeof (TermWin.parent) |
2035 | if (n > (int) (sizeof (TermWin.parent) |
2114 | / sizeof (TermWin.parent[0]))) |
2036 | / sizeof (TermWin.parent[0]))) |
2115 | { |
2037 | { |
2116 | D_X ((stderr, "InheritPixmap Turning off")); |
2038 | D_X ((stderr, "InheritPixmap Turning off")); |
2117 | XSetWindowBackground (display->display, TermWin.parent[0], |
2039 | XSetWindowBackground (display->display, TermWin.parent[0], |
… | |
… | |
2140 | ParentRelative); |
2062 | ParentRelative); |
2141 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2063 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2142 | ParentRelative); |
2064 | ParentRelative); |
2143 | am_transparent = 1; |
2065 | am_transparent = 1; |
2144 | } |
2066 | } |
|
|
2067 | |
2145 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2068 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2146 | TermWin.parent[i] = None; |
2069 | TermWin.parent[i] = None; |
2147 | } |
2070 | } |
2148 | return pchanged; |
2071 | return pchanged; |
2149 | } |
2072 | } |
… | |
… | |
2155 | /*----------------------------------------------------------------------*/ |
2078 | /*----------------------------------------------------------------------*/ |
2156 | #ifdef PRINTPIPE |
2079 | #ifdef PRINTPIPE |
2157 | FILE * |
2080 | FILE * |
2158 | rxvt_term::popen_printer () |
2081 | rxvt_term::popen_printer () |
2159 | { |
2082 | { |
2160 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2083 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2161 | |
2084 | |
2162 | if (stream == NULL) |
2085 | if (stream == NULL) |
2163 | rxvt_print_error ("can't open printer pipe"); |
2086 | rxvt_print_error ("can't open printer pipe"); |
2164 | return stream; |
2087 | return stream; |
2165 | } |
2088 | } |
… | |
… | |
2377 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2300 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2378 | break; |
2301 | break; |
2379 | case '+': |
2302 | case '+': |
2380 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2303 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2381 | break; |
2304 | break; |
2382 | #ifdef MULTICHAR_SET |
|
|
2383 | case '$': |
|
|
2384 | scr_charset_set (-2, (unsigned int)cmd_getc ()); |
|
|
2385 | break; |
|
|
2386 | #endif |
|
|
2387 | #ifndef NO_FRILLS |
2305 | #ifndef NO_FRILLS |
2388 | case '6': |
2306 | case '6': |
2389 | scr_backindex (); |
2307 | scr_backindex (); |
2390 | break; |
2308 | break; |
2391 | #endif |
2309 | #endif |
… | |
… | |
2732 | case 7: /* unofficial extension */ |
2650 | case 7: /* unofficial extension */ |
2733 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2651 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2734 | break; |
2652 | break; |
2735 | #endif |
2653 | #endif |
2736 | case 8: /* unofficial extension */ |
2654 | case 8: /* unofficial extension */ |
2737 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
2655 | xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2738 | break; |
2656 | break; |
2739 | } |
2657 | } |
2740 | break; |
2658 | break; |
2741 | |
2659 | |
2742 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
2660 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
3016 | * 10 = menu (may change in future) |
2934 | * 10 = menu (may change in future) |
3017 | * 20 = bg pixmap |
2935 | * 20 = bg pixmap |
3018 | * 39 = change default fg color |
2936 | * 39 = change default fg color |
3019 | * 49 = change default bg color |
2937 | * 49 = change default bg color |
3020 | * 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 |
3021 | */ |
2941 | */ |
3022 | void |
2942 | void |
3023 | 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))) |
3024 | { |
2944 | { |
3025 | int changed = 0; |
2945 | int changed = 0; |
… | |
… | |
3111 | set_window_color (Color_bg, str); |
3031 | set_window_color (Color_bg, str); |
3112 | break; |
3032 | break; |
3113 | case XTerm_logfile: |
3033 | case XTerm_logfile: |
3114 | break; |
3034 | break; |
3115 | case XTerm_font: |
3035 | case XTerm_font: |
3116 | change_font (0, str); |
3036 | change_font (str); |
3117 | break; |
3037 | break; |
|
|
3038 | #ifndef NO_FRILLS |
|
|
3039 | case XTerm_locale: |
|
|
3040 | if (str[0] == '?' && !str[1]) |
|
|
3041 | tt_printf ("%-.250s\n", locale); |
|
|
3042 | else |
|
|
3043 | { |
|
|
3044 | set_locale (str); |
|
|
3045 | # ifdef USE_XIM |
|
|
3046 | im_cb (); |
|
|
3047 | # endif |
|
|
3048 | } |
|
|
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 |
3118 | #if 0 |
3057 | #if 0 |
3119 | case XTerm_dumpscreen: /* no error notices */ |
3058 | case XTerm_dumpscreen: /* no error notices */ |
3120 | { |
3059 | { |
3121 | int fd; |
3060 | int fd; |
3122 | 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) |
… | |
… | |
3250 | */ |
3189 | */ |
3251 | PrivMode (1, PrivMode_vt52); |
3190 | PrivMode (1, PrivMode_vt52); |
3252 | break; |
3191 | break; |
3253 | case 3: /* 80/132 */ |
3192 | case 3: /* 80/132 */ |
3254 | if (PrivateModes & PrivMode_132OK) |
3193 | if (PrivateModes & PrivMode_132OK) |
3255 | set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), |
3194 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
3256 | (unsigned int)TermWin.height); |
|
|
3257 | break; |
3195 | break; |
3258 | case 4: /* smooth scrolling */ |
3196 | case 4: /* smooth scrolling */ |
3259 | if (state) |
3197 | if (state) |
3260 | Options &= ~Opt_jumpScroll; |
3198 | Options &= ~Opt_jumpScroll; |
3261 | else |
3199 | else |
… | |
… | |
3472 | void |
3410 | void |
3473 | rxvt_term::process_graphics () |
3411 | rxvt_term::process_graphics () |
3474 | { |
3412 | { |
3475 | unsigned char ch, cmd = cmd_getc (); |
3413 | unsigned char ch, cmd = cmd_getc (); |
3476 | |
3414 | |
3477 | #ifndef RXVT_GRAPHICS |
|
|
3478 | if (cmd == 'Q') |
3415 | if (cmd == 'Q') |
3479 | { /* query graphics */ |
3416 | { /* query graphics */ |
3480 | tt_printf ("\033G0\n"); /* no graphics */ |
3417 | tt_printf ("\033G0\n"); /* no graphics */ |
3481 | return; |
3418 | return; |
3482 | } |
3419 | } |
3483 | /* swallow other graphics sequences until terminating ':' */ |
3420 | /* swallow other graphics sequences until terminating ':' */ |
3484 | do |
3421 | do |
3485 | ch = cmd_getc (); |
3422 | ch = cmd_getc (); |
3486 | while (ch != ':'); |
3423 | 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 | } |
3424 | } |
3533 | /*}}} */ |
3425 | /*}}} */ |
3534 | |
3426 | |
3535 | /* ------------------------------------------------------------------------- */ |
3427 | /* ------------------------------------------------------------------------- */ |
3536 | |
3428 | |