… | |
… | |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #include <wchar.h> |
54 | |
54 | |
55 | /*----------------------------------------------------------------------*/ |
55 | /*----------------------------------------------------------------------*/ |
56 | |
56 | |
|
|
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
|
|
58 | |
|
|
59 | // exception thrown when the command parser runs out of input data |
|
|
60 | class out_of_input { } out_of_input; |
|
|
61 | |
57 | /*{{{ Convert the keypress event into a string */ |
62 | /*{{{ Convert the keypress event into a string */ |
58 | void |
63 | void |
59 | rxvt_term::lookup_key (XKeyEvent &ev) |
64 | rxvt_term::lookup_key (XKeyEvent &ev) |
60 | { |
65 | { |
61 | int ctrl, meta, shft, len; |
66 | int ctrl, meta, shft, len; |
… | |
… | |
88 | #ifdef USE_XIM |
93 | #ifdef USE_XIM |
89 | if (Input_Context) |
94 | if (Input_Context) |
90 | { |
95 | { |
91 | Status status_return; |
96 | Status status_return; |
92 | |
97 | |
|
|
98 | #if 0 |
93 | #ifdef X_HAVE_UTF8_STRING |
99 | #ifdef X_HAVE_UTF8_STRING |
94 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
100 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
95 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
101 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
96 | KBUFSZ, &keysym, &status_return); |
102 | KBUFSZ, &keysym, &status_return); |
97 | else |
103 | else |
|
|
104 | #endif |
98 | #endif |
105 | #endif |
99 | { |
106 | { |
100 | wchar_t wkbuf[KBUFSZ + 1]; |
107 | wchar_t wkbuf[KBUFSZ + 1]; |
101 | |
108 | |
102 | // the XOpenIM manpage lies about hardcoding the locale |
109 | // the XOpenIM manpage lies about hardcoding the locale |
… | |
… | |
110 | SET_LOCALE (locale); |
117 | SET_LOCALE (locale); |
111 | |
118 | |
112 | if (status_return == XLookupChars |
119 | if (status_return == XLookupChars |
113 | || status_return == XLookupBoth) |
120 | || status_return == XLookupBoth) |
114 | { |
121 | { |
|
|
122 | /* make sure the user can type ctrl-@, i.e. NUL */ |
|
|
123 | if (len == 1 && *wkbuf == 0) |
|
|
124 | { |
|
|
125 | kbuf[0] = 0; |
|
|
126 | len = 1; |
|
|
127 | } |
|
|
128 | else |
|
|
129 | { |
115 | wkbuf[len] = 0; |
130 | wkbuf[len] = 0; |
116 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
131 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
117 | if (len < 0) |
132 | if (len < 0) |
118 | len = 0; |
133 | len = 0; |
|
|
134 | } |
119 | } |
135 | } |
120 | else |
136 | else |
121 | len = 0; |
137 | len = 0; |
122 | } |
138 | } |
123 | |
139 | |
… | |
… | |
131 | valid_keysym = keysym != NoSymbol; |
147 | valid_keysym = keysym != NoSymbol; |
132 | } |
148 | } |
133 | |
149 | |
134 | if (valid_keysym) |
150 | if (valid_keysym) |
135 | { |
151 | { |
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) |
152 | if (TermWin.saveLines) |
158 | { |
153 | { |
159 | #ifdef UNSHIFTED_SCROLLKEYS |
154 | #ifdef UNSHIFTED_SCROLLKEYS |
160 | if (!ctrl && !meta) |
155 | if (!ctrl && !meta) |
161 | { |
156 | { |
… | |
… | |
229 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
224 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
230 | selection_request (ev.time, 0, 0); |
225 | selection_request (ev.time, 0, 0); |
231 | return; |
226 | return; |
232 | /* rxvt extras */ |
227 | /* rxvt extras */ |
233 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
228 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
234 | change_font (0, FONT_UP); |
229 | change_font (FONT_UP); |
235 | return; |
230 | return; |
236 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
231 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
237 | change_font (0, FONT_DN); |
232 | change_font (FONT_DN); |
238 | return; |
233 | return; |
239 | } |
234 | } |
240 | } |
235 | } |
241 | } |
236 | } |
242 | #ifdef PRINTPIPE |
237 | #ifdef PRINTPIPE |
243 | if (keysym == XK_Print) |
238 | if (keysym == XK_Print) |
244 | { |
239 | { |
245 | scr_printscreen (ctrl | shft); |
240 | 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; |
241 | return; |
263 | } |
242 | } |
264 | #endif |
243 | #endif |
265 | |
244 | |
266 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
245 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
… | |
… | |
268 | #ifdef KEYSYM_RESOURCE |
247 | #ifdef KEYSYM_RESOURCE |
269 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
248 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
270 | { |
249 | { |
271 | unsigned int l; |
250 | unsigned int l; |
272 | const unsigned char *kbuf0; |
251 | const unsigned char *kbuf0; |
273 | const unsigned char ch = C0_ESC; |
|
|
274 | |
252 | |
275 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
253 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
276 | l = (unsigned int)*kbuf0++; |
254 | l = (unsigned int)*kbuf0++; |
277 | |
255 | |
278 | /* escape prefix */ |
256 | /* escape prefix */ |
279 | if (meta) |
257 | if (meta |
280 | # ifdef META8_OPTION |
258 | # ifdef META8_OPTION |
281 | if (meta_char == C0_ESC) |
259 | && meta_char == C0_ESC |
282 | # endif |
260 | # endif |
|
|
261 | ) |
|
|
262 | { |
|
|
263 | const unsigned char ch = C0_ESC; |
283 | tt_write (&ch, 1); |
264 | tt_write (&ch, 1); |
|
|
265 | } |
|
|
266 | |
284 | tt_write (kbuf0, l); |
267 | tt_write (kbuf0, l); |
285 | return; |
268 | return; |
286 | } |
269 | } |
287 | else |
270 | else |
288 | #endif |
271 | #endif |
… | |
… | |
298 | ^ !!ctrl) ? '\b' : '\177'; |
281 | ^ !!ctrl) ? '\b' : '\177'; |
299 | kbuf[1] = '\0'; |
282 | kbuf[1] = '\0'; |
300 | } |
283 | } |
301 | else |
284 | else |
302 | STRCPY (kbuf, key_backspace); |
285 | 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; |
286 | break; |
316 | #endif |
287 | #endif |
317 | #ifndef NO_DELETE_KEY |
288 | #ifndef NO_DELETE_KEY |
318 | case XK_Delete: |
289 | case XK_Delete: |
319 | STRCPY (kbuf, key_delete); |
290 | 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; |
291 | break; |
333 | #endif |
292 | #endif |
334 | case XK_Tab: |
293 | case XK_Tab: |
335 | if (shft) |
294 | if (shft) |
336 | STRCPY (kbuf, "\033[Z"); |
295 | STRCPY (kbuf, "\033[Z"); |
… | |
… | |
378 | kbuf[1] = 'O'; |
337 | kbuf[1] = 'O'; |
379 | kbuf[2] = "dacb"[keysym - XK_Left]; |
338 | kbuf[2] = "dacb"[keysym - XK_Left]; |
380 | } |
339 | } |
381 | else if (PrivateModes & PrivMode_aplCUR) |
340 | else if (PrivateModes & PrivMode_aplCUR) |
382 | kbuf[1] = 'O'; |
341 | 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; |
342 | break; |
419 | |
343 | |
420 | #ifndef UNSHIFTED_SCROLLKEYS |
344 | #ifndef UNSHIFTED_SCROLLKEYS |
421 | # ifdef XK_KP_Prior |
345 | # ifdef XK_KP_Prior |
422 | case XK_KP_Prior: |
346 | case XK_KP_Prior: |
… | |
… | |
611 | break; |
535 | break; |
612 | } |
536 | } |
613 | if (newlen) |
537 | if (newlen) |
614 | len = STRLEN (kbuf); |
538 | len = STRLEN (kbuf); |
615 | } |
539 | } |
|
|
540 | |
616 | /* |
541 | /* |
617 | * Pass meta for all function keys, if 'meta' option set |
542 | * Pass meta for all function keys, if 'meta' option set |
618 | */ |
543 | */ |
619 | #ifdef META8_OPTION |
544 | #ifdef META8_OPTION |
620 | if (meta && (meta_char == 0x80) && len > 0) |
545 | if (meta && (meta_char == 0x80) && len > 0) |
… | |
… | |
635 | { |
560 | { |
636 | unsigned char *ch; |
561 | unsigned char *ch; |
637 | |
562 | |
638 | for (ch = kbuf; ch < kbuf + len; ch++) |
563 | for (ch = kbuf; ch < kbuf + len; ch++) |
639 | *ch |= 0x80; |
564 | *ch |= 0x80; |
|
|
565 | |
640 | meta = 0; |
566 | meta = 0; |
641 | } |
567 | } |
642 | #endif |
|
|
643 | #ifdef GREEK_SUPPORT |
|
|
644 | if (greek_mode) |
|
|
645 | len = greek_xlat (kbuf, len); |
|
|
646 | #endif |
568 | #endif |
647 | /* nil */ ; |
569 | /* nil */ ; |
648 | } |
570 | } |
649 | } |
571 | } |
650 | |
572 | |
… | |
… | |
673 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
595 | kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); |
674 | |
596 | |
675 | /* escape prefix */ |
597 | /* escape prefix */ |
676 | if (meta |
598 | if (meta |
677 | #ifdef META8_OPTION |
599 | #ifdef META8_OPTION |
678 | && (meta_char == C0_ESC) |
600 | && meta_char == C0_ESC |
679 | #endif |
601 | #endif |
680 | ) |
602 | ) |
681 | { |
603 | { |
682 | const unsigned char ch = C0_ESC; |
604 | const unsigned char ch = C0_ESC; |
683 | |
|
|
684 | tt_write (&ch, 1); |
605 | tt_write (&ch, 1); |
685 | } |
606 | } |
|
|
607 | |
686 | #ifdef DEBUG_CMD |
608 | #if defined(DEBUG_CMD) |
687 | if (debug_key) |
|
|
688 | { /* Display keyboard buffer contents */ |
609 | /* Display keyboard buffer contents */ |
689 | char *p; |
610 | unsigned char *p; |
690 | int i; |
611 | int i; |
691 | |
612 | |
692 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
613 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
693 | for (i = 0, p = kbuf; i < len; i++, p++) |
614 | for (i = 0, p = kbuf; i < len; i++, p++) |
694 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
615 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
695 | fprintf (stderr, "'\n"); |
616 | fprintf (stderr, "'\n"); |
696 | } |
|
|
697 | #endif /* DEBUG_CMD */ |
617 | #endif /* DEBUG_CMD */ |
698 | tt_write (kbuf, (unsigned int)len); |
618 | tt_write (kbuf, (unsigned int)len); |
699 | } |
619 | } |
700 | /*}}} */ |
620 | /*}}} */ |
701 | |
621 | |
… | |
… | |
703 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
623 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
704 | /* attempt to `write' count to the input buffer */ |
624 | /* attempt to `write' count to the input buffer */ |
705 | unsigned int |
625 | unsigned int |
706 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
626 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
707 | { |
627 | { |
708 | unsigned int n, s; |
628 | unsigned int n, s; |
709 | |
629 | |
710 | n = cmdbuf_ptr - cmdbuf_base; |
630 | n = cmdbuf_ptr - cmdbuf_base; |
711 | s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; |
631 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
|
|
632 | |
712 | if (n > 0 && s < count) |
633 | if (n > 0 && s < count) |
713 | { |
634 | { |
714 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
635 | MEMMOVE (cmdbuf_base, cmdbuf_ptr, |
715 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
636 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
716 | cmdbuf_ptr = cmdbuf_base; |
637 | cmdbuf_ptr = cmdbuf_base; |
717 | cmdbuf_endp -= n; |
638 | cmdbuf_endp -= n; |
718 | s += n; |
639 | s += n; |
719 | } |
640 | } |
|
|
641 | |
720 | if (count > s) |
642 | if (count > s) |
721 | { |
643 | { |
722 | rxvt_print_error ("data loss: cmd_write too large"); |
644 | rxvt_warn ("data loss: cmd_write too large, continuing.\n"); |
723 | count = s; |
645 | count = s; |
724 | } |
646 | } |
|
|
647 | |
725 | for (; count--;) |
648 | for (; count--;) |
726 | *cmdbuf_endp++ = *str++; |
649 | *cmdbuf_endp++ = *str++; |
|
|
650 | |
|
|
651 | cmd_parse (); |
|
|
652 | |
727 | return 0; |
653 | return 0; |
728 | } |
654 | } |
729 | #endif /* MENUBAR_MAX */ |
655 | #endif /* MENUBAR_MAX */ |
730 | |
656 | |
731 | void |
657 | void |
… | |
… | |
794 | |
720 | |
795 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
721 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
796 | cmdbuf_ptr = cmdbuf_base; |
722 | cmdbuf_ptr = cmdbuf_base; |
797 | cmdbuf_endp = cmdbuf_ptr + n; |
723 | cmdbuf_endp = cmdbuf_ptr + n; |
798 | |
724 | |
799 | n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n); |
725 | n = read (cmd_fd, cmdbuf_endp, CBUFSIZ - n); |
800 | |
726 | |
801 | if (n > 0) |
727 | if (n > 0) |
802 | { |
728 | { |
803 | cmdbuf_endp += n; |
729 | cmdbuf_endp += n; |
804 | return true; |
730 | return true; |
805 | } |
731 | } |
806 | else if (n < 0 && errno != EAGAIN) |
732 | else if (n < 0 && errno != EAGAIN) |
807 | destroy (); |
733 | destroy (); |
808 | |
734 | |
809 | return false; |
735 | return false; |
810 | } |
736 | } |
811 | |
737 | |
812 | void |
738 | void |
813 | rxvt_term::pty_cb (io_watcher &w, short revents) |
739 | rxvt_term::pty_cb (io_watcher &w, short revents) |
… | |
… | |
817 | |
743 | |
818 | if (revents & EVENT_WRITE) |
744 | if (revents & EVENT_WRITE) |
819 | tt_write (0, 0); |
745 | tt_write (0, 0); |
820 | else if (revents & EVENT_READ) |
746 | else if (revents & EVENT_READ) |
821 | { |
747 | { |
822 | bool flag = true; |
|
|
823 | |
|
|
824 | // loop, but don't allow a single term to monopolize us |
748 | // loop, but don't allow a single term to monopolize us |
825 | // the number of loops is fully arbitrary, and thus wrong |
749 | // the number of loops is fully arbitrary, and thus wrong |
826 | while (flag && pty_fill ()) |
750 | while (pty_fill ()) |
827 | { |
751 | { |
828 | if (!seen_input) |
752 | if (!seen_input) |
829 | { |
753 | { |
830 | seen_input = 1; |
754 | seen_input = 1; |
831 | /* once we know the shell is running, send the screen size. Again! */ |
755 | /* once we know the shell is running, send the screen size. Again! */ |
|
|
756 | // I don't know why, btw. |
832 | tt_winch (); |
757 | tt_winch (); |
833 | } |
758 | } |
834 | |
759 | |
835 | uint32_t ch = NOCHAR; |
760 | if (cmd_parse ()) |
836 | |
|
|
837 | for (;;) |
|
|
838 | { |
|
|
839 | if (ch == NOCHAR) |
|
|
840 | ch = next_char (); |
|
|
841 | |
|
|
842 | if (ch == NOCHAR) // TODO: improve |
|
|
843 | break; |
761 | break; |
844 | |
|
|
845 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
846 | { |
|
|
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; |
|
|
854 | |
|
|
855 | for (;;) |
|
|
856 | { |
|
|
857 | ch = next_char (); |
|
|
858 | |
|
|
859 | if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
860 | break; |
|
|
861 | else |
|
|
862 | { |
|
|
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; |
|
|
874 | flag = false; |
|
|
875 | ch = NOCHAR; |
|
|
876 | break; |
|
|
877 | } |
|
|
878 | |
|
|
879 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
|
|
880 | if (nlines >= TermWin.nrow - 1) |
|
|
881 | { |
|
|
882 | scr_add_lines (buf, nlines, str - buf); |
|
|
883 | nlines = 0; |
|
|
884 | str = buf; |
|
|
885 | } |
|
|
886 | } |
|
|
887 | |
|
|
888 | if (str >= buf + BUFSIZ) |
|
|
889 | { |
|
|
890 | ch = NOCHAR; |
|
|
891 | break; |
|
|
892 | } |
|
|
893 | } |
|
|
894 | } |
|
|
895 | |
|
|
896 | scr_add_lines (buf, nlines, str - buf); |
|
|
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 | { |
|
|
909 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
910 | refresh_limit++; |
|
|
911 | |
|
|
912 | scr_refresh (refresh_type); |
|
|
913 | } |
|
|
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 | } |
|
|
932 | } |
762 | } |
933 | } |
|
|
934 | } |
|
|
935 | } |
|
|
936 | |
|
|
937 | // read the next character, currently handles UTF-8 |
|
|
938 | // will probably handle all sorts of other stuff in the future |
|
|
939 | uint32_t |
|
|
940 | rxvt_term::next_char () |
|
|
941 | { |
|
|
942 | while (cmdbuf_ptr < cmdbuf_endp) |
|
|
943 | { |
|
|
944 | if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh |
|
|
945 | return *cmdbuf_ptr++; |
|
|
946 | |
|
|
947 | wchar_t wc; |
|
|
948 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
|
|
949 | |
|
|
950 | if (len == (size_t)-2) |
|
|
951 | return NOCHAR; |
|
|
952 | |
|
|
953 | if (len == (size_t)-1) |
|
|
954 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
955 | |
|
|
956 | // assume wchar == unicode |
|
|
957 | cmdbuf_ptr += len; |
|
|
958 | return wc; |
|
|
959 | } |
|
|
960 | |
|
|
961 | return NOCHAR; |
|
|
962 | } |
|
|
963 | |
|
|
964 | /* rxvt_cmd_getc () - Return next input character */ |
|
|
965 | /* |
|
|
966 | * Return the next input character after first passing any keyboard input |
|
|
967 | * to the command. |
|
|
968 | */ |
|
|
969 | uint32_t |
|
|
970 | rxvt_term::cmd_getc () |
|
|
971 | { |
|
|
972 | for (;;) |
|
|
973 | { |
|
|
974 | uint32_t c = next_char (); |
|
|
975 | if (c != NOCHAR) |
|
|
976 | return c; |
|
|
977 | |
|
|
978 | // incomplete sequences should occur rarely, still, a better solution |
|
|
979 | // would be preferred. either setjmp/longjmp or better design. |
|
|
980 | fcntl (cmd_fd, F_SETFL, 0); |
|
|
981 | pty_fill (); |
|
|
982 | fcntl (cmd_fd, F_SETFL, O_NONBLOCK); |
|
|
983 | } |
763 | } |
984 | } |
764 | } |
985 | |
765 | |
986 | #ifdef POINTER_BLANK |
766 | #ifdef POINTER_BLANK |
987 | void |
767 | void |
… | |
… | |
1017 | pointer_blank (); |
797 | pointer_blank (); |
1018 | } |
798 | } |
1019 | #endif |
799 | #endif |
1020 | |
800 | |
1021 | void |
801 | void |
1022 | rxvt_term::mouse_report (const XButtonEvent &ev) |
802 | rxvt_term::mouse_report (XButtonEvent &ev) |
1023 | { |
803 | { |
1024 | int button_number, key_state = 0; |
804 | int button_number, key_state = 0; |
1025 | int x, y; |
805 | int x, y; |
1026 | |
806 | |
1027 | x = ev.x; |
807 | x = ev.x; |
1028 | y = ev.y; |
808 | y = ev.y; |
1029 | pixel_position (&x, &y); |
809 | pixel_position (&x, &y); |
1030 | |
810 | |
… | |
… | |
1356 | |
1136 | |
1357 | } |
1137 | } |
1358 | break; |
1138 | break; |
1359 | |
1139 | |
1360 | case SelectionClear: |
1140 | case SelectionClear: |
1361 | display->set_selection_owner (0); |
1141 | selection_clear (); |
1362 | break; |
1142 | break; |
1363 | |
1143 | |
1364 | case SelectionNotify: |
1144 | case SelectionNotify: |
1365 | if (selection_wait == Sel_normal) |
1145 | if (selection_wait == Sel_normal) |
1366 | selection_paste (ev.xselection.requestor, |
1146 | selection_paste (ev.xselection.requestor, |
… | |
… | |
1424 | } |
1204 | } |
1425 | #ifdef MENUBAR |
1205 | #ifdef MENUBAR |
1426 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1206 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1427 | menubar_expose (); |
1207 | menubar_expose (); |
1428 | #endif |
1208 | #endif |
1429 | #ifdef RXVT_GRAPHICS |
|
|
1430 | Gr_expose (ev.xany.window); |
|
|
1431 | #endif |
|
|
1432 | |
|
|
1433 | } |
1209 | } |
1434 | break; |
1210 | break; |
1435 | |
1211 | |
1436 | case MotionNotify: |
1212 | case MotionNotify: |
1437 | #ifdef POINTER_BLANK |
1213 | #ifdef POINTER_BLANK |
… | |
… | |
1439 | pointer_unblank (); |
1215 | pointer_unblank (); |
1440 | #endif |
1216 | #endif |
1441 | #if MENUBAR |
1217 | #if MENUBAR |
1442 | if (isMenuBarWindow (ev.xany.window)) |
1218 | if (isMenuBarWindow (ev.xany.window)) |
1443 | { |
1219 | { |
1444 | menubar_control (& (ev.xbutton)); |
1220 | menubar_control (ev.xbutton); |
1445 | break; |
1221 | break; |
1446 | } |
1222 | } |
1447 | #endif |
1223 | #endif |
1448 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1224 | if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1449 | break; |
1225 | break; |
… | |
… | |
1578 | #endif |
1354 | #endif |
1579 | } |
1355 | } |
1580 | } |
1356 | } |
1581 | |
1357 | |
1582 | void |
1358 | void |
1583 | rxvt_term::button_press (const XButtonEvent &ev) |
1359 | rxvt_term::button_press (XButtonEvent &ev) |
1584 | { |
1360 | { |
1585 | int reportmode = 0, clickintime; |
1361 | int reportmode = 0, clickintime; |
1586 | |
1362 | |
1587 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1363 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1588 | if (!bypass_keystate) |
1364 | if (!bypass_keystate) |
… | |
… | |
1590 | /* |
1366 | /* |
1591 | * VT window processing of button press |
1367 | * VT window processing of button press |
1592 | */ |
1368 | */ |
1593 | if (ev.window == TermWin.vt) |
1369 | if (ev.window == TermWin.vt) |
1594 | { |
1370 | { |
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; |
1371 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1603 | if (reportmode) |
1372 | if (reportmode) |
|
|
1373 | { |
|
|
1374 | /* mouse report from vt window */ |
|
|
1375 | /* save the xbutton state (for ButtonRelease) */ |
|
|
1376 | MEvent.state = ev.state; |
|
|
1377 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1378 | if (ev.button == MEvent.button && clickintime) |
1604 | { |
1379 | { |
1605 | /* mouse report from vt window */ |
1380 | /* same button, within alloted time */ |
1606 | /* save the xbutton state (for ButtonRelease) */ |
1381 | MEvent.clicks++; |
1607 | MEvent.state = ev.state; |
1382 | if (MEvent.clicks > 1) |
1608 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1609 | if (ev.button == MEvent.button && clickintime) |
|
|
1610 | { |
1383 | { |
1611 | /* same button, within alloted time */ |
|
|
1612 | MEvent.clicks++; |
|
|
1613 | if (MEvent.clicks > 1) |
|
|
1614 | { |
|
|
1615 | /* only report double clicks */ |
1384 | /* only report double clicks */ |
1616 | MEvent.clicks = 2; |
1385 | MEvent.clicks = 2; |
1617 | mouse_report (ev); |
1386 | mouse_report (ev); |
1618 | |
1387 | |
1619 | /* don't report the release */ |
1388 | /* don't report the release */ |
1620 | MEvent.clicks = 0; |
1389 | MEvent.clicks = 0; |
1621 | MEvent.button = AnyButton; |
1390 | MEvent.button = AnyButton; |
1622 | } |
|
|
1623 | } |
1391 | } |
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 | } |
1392 | } |
1637 | else |
1393 | else |
1638 | { |
1394 | { |
|
|
1395 | /* different button, or time expired */ |
|
|
1396 | MEvent.clicks = 1; |
|
|
1397 | MEvent.button = ev.button; |
|
|
1398 | mouse_report (ev); |
|
|
1399 | } |
|
|
1400 | #else |
|
|
1401 | MEvent.button = ev.button; |
|
|
1402 | mouse_report (ev); |
|
|
1403 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1404 | |
|
|
1405 | } |
|
|
1406 | else |
|
|
1407 | { |
1639 | if (ev.button != MEvent.button) |
1408 | if (ev.button != MEvent.button) |
1640 | MEvent.clicks = 0; |
1409 | MEvent.clicks = 0; |
1641 | switch (ev.button) |
1410 | switch (ev.button) |
1642 | { |
1411 | { |
1643 | case Button1: |
1412 | case Button1: |
1644 | /* allow shift+left click to extend selection */ |
1413 | /* allow shift+left click to extend selection */ |
1645 | if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) |
1414 | if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) |
1646 | { |
1415 | { |
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) |
1416 | if (MEvent.button == Button1 && clickintime) |
1667 | selection_rotate (ev.x, ev.y); |
1417 | selection_rotate (ev.x, ev.y); |
1668 | else |
1418 | else |
1669 | selection_extend (ev.x, ev.y, 1); |
1419 | selection_extend (ev.x, ev.y, 1); |
|
|
1420 | } |
|
|
1421 | else |
|
|
1422 | { |
|
|
1423 | if (MEvent.button == Button1 && clickintime) |
|
|
1424 | MEvent.clicks++; |
|
|
1425 | else |
|
|
1426 | MEvent.clicks = 1; |
|
|
1427 | |
|
|
1428 | selection_click (MEvent.clicks, ev.x, ev.y); |
|
|
1429 | } |
|
|
1430 | |
|
|
1431 | MEvent.button = Button1; |
|
|
1432 | break; |
|
|
1433 | |
|
|
1434 | case Button3: |
|
|
1435 | if (MEvent.button == Button3 && clickintime) |
|
|
1436 | selection_rotate (ev.x, ev.y); |
|
|
1437 | else |
|
|
1438 | selection_extend (ev.x, ev.y, 1); |
1670 | MEvent.button = Button3; |
1439 | MEvent.button = Button3; |
1671 | break; |
1440 | break; |
1672 | } |
|
|
1673 | } |
1441 | } |
|
|
1442 | } |
1674 | MEvent.time = ev.time; |
1443 | MEvent.time = ev.time; |
1675 | return; |
1444 | return; |
1676 | } |
|
|
1677 | } |
1445 | } |
1678 | |
1446 | |
1679 | /* |
1447 | /* |
1680 | * Scrollbar window processing of button press |
1448 | * Scrollbar window processing of button press |
1681 | */ |
1449 | */ |
… | |
… | |
1824 | menubar_control (ev); |
1592 | menubar_control (ev); |
1825 | #endif |
1593 | #endif |
1826 | } |
1594 | } |
1827 | |
1595 | |
1828 | void |
1596 | void |
1829 | rxvt_term::button_release (const XButtonEvent &ev) |
1597 | rxvt_term::button_release (XButtonEvent &ev) |
1830 | { |
1598 | { |
1831 | int reportmode = 0; |
1599 | int reportmode = 0; |
1832 | |
1600 | |
1833 | csrO = 0; /* reset csr Offset */ |
1601 | csrO = 0; /* reset csr Offset */ |
1834 | if (!bypass_keystate) |
1602 | if (!bypass_keystate) |
… | |
… | |
1846 | #ifdef SELECTION_SCROLLING |
1614 | #ifdef SELECTION_SCROLLING |
1847 | pending_scroll_selection=0; |
1615 | pending_scroll_selection=0; |
1848 | #endif |
1616 | #endif |
1849 | if (ev.window == TermWin.vt) |
1617 | if (ev.window == TermWin.vt) |
1850 | { |
1618 | { |
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) |
1619 | if (reportmode) |
|
|
1620 | { |
|
|
1621 | /* mouse report from vt window */ |
|
|
1622 | /* don't report release of wheel "buttons" */ |
|
|
1623 | if (ev.button >= 4) |
|
|
1624 | return; |
|
|
1625 | #ifdef MOUSE_REPORT_DOUBLECLICK |
|
|
1626 | /* only report the release of 'slow' single clicks */ |
|
|
1627 | if (MEvent.button != AnyButton |
|
|
1628 | && (ev.button != MEvent.button |
|
|
1629 | || (ev.time - MEvent.time |
|
|
1630 | > MULTICLICK_TIME / 2))) |
1859 | { |
1631 | { |
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; |
1632 | MEvent.clicks = 0; |
1872 | MEvent.button = AnyButton; |
|
|
1873 | mouse_report (ev); |
|
|
1874 | } |
|
|
1875 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1876 | MEvent.button = AnyButton; |
1633 | MEvent.button = AnyButton; |
1877 | mouse_report (ev); |
1634 | mouse_report (ev); |
|
|
1635 | } |
|
|
1636 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
|
|
1637 | MEvent.button = AnyButton; |
|
|
1638 | mouse_report (ev); |
1878 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1639 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1879 | return; |
1640 | return; |
1880 | } |
1641 | } |
1881 | /* |
1642 | /* |
1882 | * dumb hack to compensate for the failure of click-and-drag |
1643 | * dumb hack to compensate for the failure of click-and-drag |
1883 | * when overriding mouse reporting |
1644 | * when overriding mouse reporting |
1884 | */ |
1645 | */ |
1885 | if (PrivateModes & PrivMode_mouse_report |
1646 | if (PrivateModes & PrivMode_mouse_report |
1886 | && bypass_keystate |
1647 | && bypass_keystate |
1887 | && ev.button == Button1 && MEvent.clicks <= 1) |
1648 | && ev.button == Button1 && MEvent.clicks <= 1) |
1888 | selection_extend (ev.x, ev.y, 0); |
1649 | selection_extend (ev.x, ev.y, 0); |
1889 | |
1650 | |
1890 | switch (ev.button) |
1651 | switch (ev.button) |
|
|
1652 | { |
|
|
1653 | case Button1: |
|
|
1654 | case Button3: |
|
|
1655 | selection_make (ev.time); |
|
|
1656 | break; |
|
|
1657 | case Button2: |
|
|
1658 | selection_request (ev.time, ev.x, ev.y); |
|
|
1659 | break; |
|
|
1660 | #ifdef MOUSE_WHEEL |
|
|
1661 | case Button4: |
|
|
1662 | case Button5: |
1891 | { |
1663 | { |
1892 | case Button1: |
1664 | int i; |
1893 | case Button3: |
1665 | page_dirn v; |
1894 | selection_make (ev.time); |
1666 | |
|
|
1667 | v = (ev.button == Button4) ? UP : DN; |
|
|
1668 | if (ev.state & ShiftMask) |
1895 | break; |
1669 | i = 1; |
1896 | case Button2: |
1670 | else if ((Options & Opt_mouseWheelScrollPage)) |
1897 | selection_request (ev.time, ev.x, ev.y); |
1671 | i = TermWin.nrow - 1; |
|
|
1672 | else |
1898 | break; |
1673 | i = 5; |
1899 | #ifdef MOUSE_WHEEL |
1674 | # ifdef MOUSE_SLIP_WHEELING |
1900 | case Button4: |
1675 | if (ev.state & ControlMask) |
1901 | case Button5: |
|
|
1902 | { |
1676 | { |
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); |
1677 | mouse_slip_wheel_speed += (v ? -1 : 1); |
1917 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1678 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1918 | } |
1679 | } |
1919 | # endif |
1680 | # endif |
1920 | # ifdef JUMP_MOUSE_WHEEL |
1681 | # ifdef JUMP_MOUSE_WHEEL |
|
|
1682 | scr_page (v, i); |
|
|
1683 | scr_refresh (SMOOTH_REFRESH); |
|
|
1684 | scrollbar_show (1); |
|
|
1685 | # else |
|
|
1686 | while (i--) |
|
|
1687 | { |
1921 | scr_page (v, i); |
1688 | scr_page (v, 1); |
1922 | scr_refresh (SMOOTH_REFRESH); |
1689 | scr_refresh (SMOOTH_REFRESH); |
1923 | scrollbar_show (1); |
1690 | scrollbar_show (1); |
1924 | # else |
|
|
1925 | while (i--) |
|
|
1926 | { |
|
|
1927 | scr_page (v, 1); |
|
|
1928 | scr_refresh (SMOOTH_REFRESH); |
|
|
1929 | scrollbar_show (1); |
|
|
1930 | } |
1691 | } |
1931 | # endif |
1692 | # endif |
1932 | |
1693 | |
1933 | } |
|
|
1934 | break; |
|
|
1935 | #endif |
|
|
1936 | |
|
|
1937 | } |
1694 | } |
|
|
1695 | break; |
|
|
1696 | #endif |
|
|
1697 | |
1938 | } |
1698 | } |
1939 | } |
1699 | } |
1940 | #ifdef MENUBAR |
1700 | #ifdef MENUBAR |
1941 | else if (isMenuBarWindow (ev.window)) |
1701 | else if (isMenuBarWindow (ev.window)) |
1942 | menubar_control (ev); |
1702 | menubar_control (ev); |
… | |
… | |
2004 | if (have_pixmap) |
1764 | if (have_pixmap) |
2005 | { |
1765 | { |
2006 | /* |
1766 | /* |
2007 | * Copy display->root pixmap transparency |
1767 | * Copy display->root pixmap transparency |
2008 | */ |
1768 | */ |
2009 | int sx, sy, nx, ny; |
1769 | int sx, sy, nx, ny; |
2010 | unsigned int nw, nh; |
1770 | unsigned int nw, nh; |
2011 | Window cr; |
1771 | Window cr; |
2012 | XImage *image; |
1772 | XImage *image; |
2013 | GC gc; |
1773 | GC gc; |
2014 | XGCValues gcvalue; |
1774 | XGCValues gcvalue; |
2015 | |
1775 | |
2016 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
1776 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2017 | 0, 0, &sx, &sy, &cr); |
1777 | 0, 0, &sx, &sy, &cr); |
2018 | nw = (unsigned int)szHint.width; |
1778 | nw = (unsigned int)szHint.width; |
2019 | nh = (unsigned int)szHint.height; |
1779 | nh = (unsigned int)szHint.height; |
2020 | nx = ny = 0; |
1780 | nx = ny = 0; |
|
|
1781 | |
2021 | if (sx < 0) |
1782 | if (sx < 0) |
2022 | { |
1783 | { |
2023 | nw += sx; |
1784 | nw += sx; |
2024 | nx = -sx; |
1785 | nx = -sx; |
2025 | sx = 0; |
1786 | sx = 0; |
2026 | } |
1787 | } |
|
|
1788 | |
2027 | if (sy < 0) |
1789 | if (sy < 0) |
2028 | { |
1790 | { |
2029 | nh += sy; |
1791 | nh += sy; |
2030 | ny = -sy; |
1792 | ny = -sy; |
2031 | sy = 0; |
1793 | sy = 0; |
2032 | } |
1794 | } |
|
|
1795 | |
2033 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
1796 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2034 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
1797 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2035 | allowedxerror = -1; |
1798 | allowedxerror = -1; |
2036 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
1799 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, |
2037 | ZPixmap); |
1800 | ZPixmap); |
… | |
… | |
2070 | if (!am_transparent || !am_pixmap_trans) |
1833 | if (!am_transparent || !am_pixmap_trans) |
2071 | pchanged = 1; |
1834 | pchanged = 1; |
2072 | am_transparent = am_pixmap_trans = 1; |
1835 | am_transparent = am_pixmap_trans = 1; |
2073 | } |
1836 | } |
2074 | } |
1837 | } |
|
|
1838 | |
2075 | if (!am_pixmap_trans) |
1839 | if (!am_pixmap_trans) |
2076 | { |
1840 | { |
2077 | unsigned int n; |
1841 | unsigned int n; |
2078 | /* |
1842 | /* |
2079 | * InheritPixmap transparency |
1843 | * InheritPixmap transparency |
… | |
… | |
2094 | break; |
1858 | break; |
2095 | } |
1859 | } |
2096 | if (oldp != TermWin.parent[i]) |
1860 | if (oldp != TermWin.parent[i]) |
2097 | pchanged = 1; |
1861 | pchanged = 1; |
2098 | } |
1862 | } |
|
|
1863 | |
2099 | n = 0; |
1864 | n = 0; |
|
|
1865 | |
2100 | if (pchanged) |
1866 | if (pchanged) |
2101 | { |
1867 | { |
2102 | for (; n < (unsigned int)i; n++) |
1868 | for (; n < (unsigned int)i; n++) |
2103 | { |
1869 | { |
2104 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
1870 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
… | |
… | |
2108 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
1874 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2109 | break; |
1875 | break; |
2110 | } |
1876 | } |
2111 | } |
1877 | } |
2112 | } |
1878 | } |
|
|
1879 | |
2113 | if (n > (int) (sizeof (TermWin.parent) |
1880 | if (n > (int) (sizeof (TermWin.parent) |
2114 | / sizeof (TermWin.parent[0]))) |
1881 | / sizeof (TermWin.parent[0]))) |
2115 | { |
1882 | { |
2116 | D_X ((stderr, "InheritPixmap Turning off")); |
1883 | D_X ((stderr, "InheritPixmap Turning off")); |
2117 | XSetWindowBackground (display->display, TermWin.parent[0], |
1884 | XSetWindowBackground (display->display, TermWin.parent[0], |
… | |
… | |
2140 | ParentRelative); |
1907 | ParentRelative); |
2141 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
1908 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2142 | ParentRelative); |
1909 | ParentRelative); |
2143 | am_transparent = 1; |
1910 | am_transparent = 1; |
2144 | } |
1911 | } |
|
|
1912 | |
2145 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
1913 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2146 | TermWin.parent[i] = None; |
1914 | TermWin.parent[i] = None; |
2147 | } |
1915 | } |
2148 | return pchanged; |
1916 | return pchanged; |
2149 | } |
1917 | } |
2150 | #endif |
1918 | #endif |
2151 | |
1919 | |
2152 | /*}}} */ |
1920 | /*}}} */ |
|
|
1921 | |
|
|
1922 | bool |
|
|
1923 | rxvt_term::cmd_parse () |
|
|
1924 | { |
|
|
1925 | bool flag = false; |
|
|
1926 | unicode_t ch = NOCHAR; |
|
|
1927 | unsigned char *seq_begin; // remember start of esc-sequence here |
|
|
1928 | |
|
|
1929 | for (;;) |
|
|
1930 | { |
|
|
1931 | if (ch == NOCHAR) |
|
|
1932 | { |
|
|
1933 | seq_begin = cmdbuf_ptr; |
|
|
1934 | ch = next_char (); |
|
|
1935 | } |
|
|
1936 | |
|
|
1937 | if (ch == NOCHAR) // TODO: improve |
|
|
1938 | break; |
|
|
1939 | |
|
|
1940 | if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') |
|
|
1941 | { |
|
|
1942 | /* Read a text string from the input buffer */ |
|
|
1943 | unicode_t buf[UBUFSIZ]; |
|
|
1944 | bool refreshnow = false; |
|
|
1945 | int nlines = 0; |
|
|
1946 | unicode_t *str = buf; |
|
|
1947 | |
|
|
1948 | *str++ = ch; |
|
|
1949 | |
|
|
1950 | for (;;) |
|
|
1951 | { |
|
|
1952 | seq_begin = cmdbuf_ptr; |
|
|
1953 | ch = next_char (); |
|
|
1954 | |
|
|
1955 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) |
|
|
1956 | break; |
|
|
1957 | |
|
|
1958 | *str++ = ch; |
|
|
1959 | |
|
|
1960 | if (ch == '\n') |
|
|
1961 | { |
|
|
1962 | nlines++; |
|
|
1963 | refresh_count++; |
|
|
1964 | |
|
|
1965 | if (! (Options & Opt_jumpScroll) |
|
|
1966 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
|
|
1967 | { |
|
|
1968 | refreshnow = true; |
|
|
1969 | flag = true; |
|
|
1970 | ch = NOCHAR; |
|
|
1971 | break; |
|
|
1972 | } |
|
|
1973 | |
|
|
1974 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
|
|
1975 | if (nlines >= TermWin.nrow - 1) |
|
|
1976 | { |
|
|
1977 | scr_add_lines (buf, nlines, str - buf); |
|
|
1978 | nlines = 0; |
|
|
1979 | str = buf; |
|
|
1980 | } |
|
|
1981 | } |
|
|
1982 | |
|
|
1983 | if (str >= buf + UBUFSIZ) |
|
|
1984 | { |
|
|
1985 | ch = NOCHAR; |
|
|
1986 | break; |
|
|
1987 | } |
|
|
1988 | } |
|
|
1989 | |
|
|
1990 | scr_add_lines (buf, nlines, str - buf); |
|
|
1991 | |
|
|
1992 | /* |
|
|
1993 | * If there have been a lot of new lines, then update the screen |
|
|
1994 | * What the heck I'll cheat and only refresh less than every page-full. |
|
|
1995 | * the number of pages between refreshes is refresh_limit, which |
|
|
1996 | * is incremented here because we must be doing flat-out scrolling. |
|
|
1997 | * |
|
|
1998 | * refreshing should be correct for small scrolls, because of the |
|
|
1999 | * time-out |
|
|
2000 | */ |
|
|
2001 | if (refreshnow) |
|
|
2002 | { |
|
|
2003 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2004 | refresh_limit++; |
|
|
2005 | |
|
|
2006 | scr_refresh (refresh_type); |
|
|
2007 | } |
|
|
2008 | |
|
|
2009 | } |
|
|
2010 | else |
|
|
2011 | { |
|
|
2012 | try |
|
|
2013 | { |
|
|
2014 | process_nonprinting (ch); |
|
|
2015 | } |
|
|
2016 | catch (const class out_of_input &o) |
|
|
2017 | { |
|
|
2018 | // we ran out of input, retry later |
|
|
2019 | cmdbuf_ptr = seq_begin; |
|
|
2020 | break; |
|
|
2021 | } |
|
|
2022 | |
|
|
2023 | ch = NOCHAR; |
|
|
2024 | } |
|
|
2025 | } |
|
|
2026 | |
|
|
2027 | return flag; |
|
|
2028 | } |
|
|
2029 | |
|
|
2030 | // read the next character |
|
|
2031 | unicode_t |
|
|
2032 | rxvt_term::next_char () |
|
|
2033 | { |
|
|
2034 | while (cmdbuf_ptr < cmdbuf_endp) |
|
|
2035 | { |
|
|
2036 | // assume 7-bit to be ascii ALWAYS |
|
|
2037 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
|
|
2038 | return *cmdbuf_ptr++; |
|
|
2039 | |
|
|
2040 | wchar_t wc; |
|
|
2041 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
|
|
2042 | |
|
|
2043 | if (len == (size_t)-2) |
|
|
2044 | { |
|
|
2045 | // the mbstate stores incomplete sequences. didn't know this :/ |
|
|
2046 | cmdbuf_ptr = cmdbuf_endp; |
|
|
2047 | break; |
|
|
2048 | } |
|
|
2049 | |
|
|
2050 | if (len == (size_t)-1) |
|
|
2051 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
2052 | |
|
|
2053 | // assume wchar == unicode |
|
|
2054 | cmdbuf_ptr += len; |
|
|
2055 | return wc; |
|
|
2056 | } |
|
|
2057 | |
|
|
2058 | return NOCHAR; |
|
|
2059 | } |
|
|
2060 | |
|
|
2061 | /* rxvt_cmd_getc () - Return next input character */ |
|
|
2062 | /* |
|
|
2063 | * Return the next input character after first passing any keyboard input |
|
|
2064 | * to the command. |
|
|
2065 | */ |
|
|
2066 | unicode_t |
|
|
2067 | rxvt_term::cmd_getc () |
|
|
2068 | { |
|
|
2069 | unicode_t c = next_char (); |
|
|
2070 | |
|
|
2071 | if (c == NOCHAR) |
|
|
2072 | throw out_of_input; |
|
|
2073 | |
|
|
2074 | return c; |
|
|
2075 | } |
2153 | |
2076 | |
2154 | /*{{{ print pipe */ |
2077 | /*{{{ print pipe */ |
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_warn ("can't open printer pipe, not printing.\n"); |
|
|
2087 | |
2164 | return stream; |
2088 | return stream; |
2165 | } |
2089 | } |
2166 | |
2090 | |
2167 | int |
2091 | int |
2168 | rxvt_term::pclose_printer (FILE *stream) |
2092 | rxvt_term::pclose_printer (FILE *stream) |
2169 | { |
2093 | { |
2170 | fflush (stream); |
2094 | fflush (stream); |
2171 | /* pclose () reported not to work on SunOS 4.1.3 */ |
|
|
2172 | # if defined (__sun__) /* TODO: RESOLVE THIS */ |
|
|
2173 | /* pclose works provided SIGCHLD handler uses waitpid */ |
|
|
2174 | return pclose (stream); /* return fclose (stream); */ |
|
|
2175 | # else |
|
|
2176 | return pclose (stream); |
2095 | return pclose (stream); |
2177 | # endif |
|
|
2178 | } |
2096 | } |
2179 | |
2097 | |
2180 | /* |
2098 | /* |
2181 | * simulate attached vt100 printer |
2099 | * simulate attached vt100 printer |
2182 | */ |
2100 | */ |
2183 | void |
2101 | void |
2184 | rxvt_term::process_print_pipe () |
2102 | rxvt_term::process_print_pipe () |
2185 | { |
2103 | { |
2186 | int done; |
2104 | int done; |
2187 | FILE *fd; |
2105 | FILE *fd; |
2188 | |
2106 | |
2189 | if ((fd = popen_printer ()) == NULL) |
2107 | if ((fd = popen_printer ()) == NULL) |
2190 | return; |
2108 | return; |
2191 | |
2109 | |
2192 | /* |
2110 | /* |
2193 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2111 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2194 | * is received. |
2112 | * is received. |
2195 | */ |
2113 | */ |
2196 | for (done = 0; !done;) |
2114 | for (done = 0; !done;) |
2197 | { |
2115 | { |
2198 | unsigned char buf[8]; |
2116 | unsigned char buf[8]; |
2199 | unsigned char ch; |
2117 | unicode_t ch; |
2200 | unsigned int i, len; |
2118 | unsigned int i, len; |
2201 | |
2119 | |
2202 | if ((ch = cmd_getc ()) != C0_ESC) |
2120 | if ((ch = cmd_getc ()) != C0_ESC) |
2203 | { |
2121 | { |
2204 | if (putc (ch, fd) == EOF) |
2122 | if (putc (ch, fd) == EOF) |
2205 | break; /* done = 1 */ |
2123 | break; /* done = 1 */ |
… | |
… | |
2220 | { |
2138 | { |
2221 | if ((buf[len++] = cmd_getc ()) == 'i') |
2139 | if ((buf[len++] = cmd_getc ()) == 'i') |
2222 | break; /* done = 1 */ |
2140 | break; /* done = 1 */ |
2223 | } |
2141 | } |
2224 | } |
2142 | } |
|
|
2143 | |
2225 | for (i = 0; i < len; i++) |
2144 | for (i = 0; i < len; i++) |
2226 | if (putc (buf[i], fd) == EOF) |
2145 | if (putc (buf[i], fd) == EOF) |
2227 | { |
2146 | { |
2228 | done = 1; |
2147 | done = 1; |
2229 | break; |
2148 | break; |
2230 | } |
2149 | } |
2231 | } |
2150 | } |
2232 | } |
2151 | } |
|
|
2152 | |
2233 | pclose_printer (fd); |
2153 | pclose_printer (fd); |
2234 | } |
2154 | } |
2235 | #endif /* PRINTPIPE */ |
2155 | #endif /* PRINTPIPE */ |
2236 | /*}}} */ |
2156 | /*}}} */ |
2237 | |
2157 | |
… | |
… | |
2245 | }; |
2165 | }; |
2246 | /* *INDENT-ON* */ |
2166 | /* *INDENT-ON* */ |
2247 | |
2167 | |
2248 | /*{{{ process non-printing single characters */ |
2168 | /*{{{ process non-printing single characters */ |
2249 | void |
2169 | void |
2250 | rxvt_term::process_nonprinting (unsigned char ch) |
2170 | rxvt_term::process_nonprinting (unicode_t ch) |
2251 | { |
2171 | { |
2252 | switch (ch) |
2172 | switch (ch) |
2253 | { |
2173 | { |
|
|
2174 | case C0_ESC: |
|
|
2175 | process_escape_seq (); |
|
|
2176 | break; |
2254 | case C0_ENQ: /* terminal Status */ |
2177 | case C0_ENQ: /* terminal Status */ |
2255 | if (rs[Rs_answerbackstring]) |
2178 | if (rs[Rs_answerbackstring]) |
2256 | tt_write ( |
2179 | tt_write ( |
2257 | (const unsigned char *)rs[Rs_answerbackstring], |
2180 | (const unsigned char *)rs[Rs_answerbackstring], |
2258 | (unsigned int)STRLEN (rs[Rs_answerbackstring])); |
2181 | (unsigned int)STRLEN (rs[Rs_answerbackstring])); |
… | |
… | |
2281 | scr_charset_choose (1); |
2204 | scr_charset_choose (1); |
2282 | break; |
2205 | break; |
2283 | case C0_SI: /* shift in - acs */ |
2206 | case C0_SI: /* shift in - acs */ |
2284 | scr_charset_choose (0); |
2207 | scr_charset_choose (0); |
2285 | break; |
2208 | break; |
|
|
2209 | |
|
|
2210 | // 8-bit controls |
|
|
2211 | case 0x90: /* DCS */ |
|
|
2212 | process_dcs_seq (); |
|
|
2213 | break; |
|
|
2214 | case 0x9b: /* CSI */ |
|
|
2215 | process_csi_seq (); |
|
|
2216 | break; |
|
|
2217 | case 0x9d: /* CSI */ |
|
|
2218 | process_osc_seq (); |
|
|
2219 | break; |
2286 | } |
2220 | } |
2287 | } |
2221 | } |
2288 | /*}}} */ |
2222 | /*}}} */ |
2289 | |
2223 | |
2290 | |
2224 | |
2291 | /*{{{ process VT52 escape sequences */ |
2225 | /*{{{ process VT52 escape sequences */ |
2292 | void |
2226 | void |
2293 | rxvt_term::process_escape_vt52 (unsigned char ch) |
2227 | rxvt_term::process_escape_vt52 (unicode_t ch) |
2294 | { |
2228 | { |
2295 | int row, col; |
2229 | int row, col; |
2296 | |
2230 | |
2297 | switch (ch) |
2231 | switch (ch) |
2298 | { |
2232 | { |
… | |
… | |
2350 | |
2284 | |
2351 | /*{{{ process escape sequences */ |
2285 | /*{{{ process escape sequences */ |
2352 | void |
2286 | void |
2353 | rxvt_term::process_escape_seq () |
2287 | rxvt_term::process_escape_seq () |
2354 | { |
2288 | { |
2355 | unsigned char ch = cmd_getc (); |
2289 | unicode_t ch = cmd_getc (); |
2356 | |
2290 | |
2357 | if (PrivateModes & PrivMode_vt52) |
2291 | if (PrivateModes & PrivMode_vt52) |
2358 | { |
2292 | { |
2359 | process_escape_vt52 (ch); |
2293 | process_escape_vt52 (ch); |
2360 | return; |
2294 | return; |
… | |
… | |
2377 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2311 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2378 | break; |
2312 | break; |
2379 | case '+': |
2313 | case '+': |
2380 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2314 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2381 | break; |
2315 | break; |
2382 | #ifdef MULTICHAR_SET |
|
|
2383 | case '$': |
|
|
2384 | scr_charset_set (-2, (unsigned int)cmd_getc ()); |
|
|
2385 | break; |
|
|
2386 | #endif |
|
|
2387 | #ifndef NO_FRILLS |
2316 | #ifndef NO_FRILLS |
2388 | case '6': |
2317 | case '6': |
2389 | scr_backindex (); |
2318 | scr_backindex (); |
2390 | break; |
2319 | break; |
2391 | #endif |
2320 | #endif |
… | |
… | |
2413 | break; |
2342 | break; |
2414 | |
2343 | |
2415 | /* 8.3.87: NEXT LINE */ |
2344 | /* 8.3.87: NEXT LINE */ |
2416 | case C1_NEL: /* ESC E */ |
2345 | case C1_NEL: /* ESC E */ |
2417 | { |
2346 | { |
2418 | uint32_t nlcr[] = { '\n', '\r' }; |
2347 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2419 | scr_add_lines (nlcr, 1, 2); |
2348 | scr_add_lines (nlcr, 1, 2); |
2420 | } |
2349 | } |
2421 | break; |
2350 | break; |
2422 | |
2351 | |
2423 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2352 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
2515 | /* *INDENT-ON* */ |
2444 | /* *INDENT-ON* */ |
2516 | |
2445 | |
2517 | void |
2446 | void |
2518 | rxvt_term::process_csi_seq () |
2447 | rxvt_term::process_csi_seq () |
2519 | { |
2448 | { |
2520 | unsigned char ch, priv, i; |
2449 | unicode_t ch, priv, i; |
2521 | unsigned int nargs, p; |
2450 | unsigned int nargs, p; |
2522 | int n, ndef; |
2451 | int n, ndef; |
2523 | int arg[ESC_ARGS]; |
2452 | int arg[ESC_ARGS]; |
2524 | |
2453 | |
2525 | for (nargs = ESC_ARGS; nargs > 0;) |
2454 | for (nargs = ESC_ARGS; nargs > 0;) |
2526 | arg[--nargs] = 0; |
2455 | arg[--nargs] = 0; |
2527 | |
2456 | |
2528 | priv = 0; |
2457 | priv = 0; |
… | |
… | |
2530 | if (ch >= '<' && ch <= '?') |
2459 | if (ch >= '<' && ch <= '?') |
2531 | { /* '<' '=' '>' '?' */ |
2460 | { /* '<' '=' '>' '?' */ |
2532 | priv = ch; |
2461 | priv = ch; |
2533 | ch = cmd_getc (); |
2462 | ch = cmd_getc (); |
2534 | } |
2463 | } |
|
|
2464 | |
2535 | /* read any numerical arguments */ |
2465 | /* read any numerical arguments */ |
2536 | for (n = -1; ch < CSI_ICH; ) |
2466 | for (n = -1; ch < CSI_ICH; ) |
2537 | { |
2467 | { |
2538 | if (isdigit (ch)) |
2468 | if (isdigit (ch)) |
2539 | { |
2469 | { |
… | |
… | |
2546 | { |
2476 | { |
2547 | if (nargs < ESC_ARGS) |
2477 | if (nargs < ESC_ARGS) |
2548 | arg[nargs++] = n; |
2478 | arg[nargs++] = n; |
2549 | n = -1; |
2479 | n = -1; |
2550 | } |
2480 | } |
2551 | else if (ch == '\b') |
2481 | else if (IS_CONTROL (ch)) |
2552 | { |
|
|
2553 | scr_backspace (); |
|
|
2554 | } |
|
|
2555 | else if (ch == C0_ESC) |
|
|
2556 | { |
|
|
2557 | process_escape_seq (); |
|
|
2558 | return; |
|
|
2559 | } |
|
|
2560 | else if (ch < ' ') |
|
|
2561 | { |
|
|
2562 | process_nonprinting (ch); |
2482 | process_nonprinting (ch); |
2563 | } |
2483 | |
2564 | ch = cmd_getc (); |
2484 | ch = cmd_getc (); |
2565 | } |
2485 | } |
2566 | |
2486 | |
2567 | if (ch > CSI_7F) |
2487 | if (ch > CSI_7F) |
2568 | return; |
2488 | return; |
… | |
… | |
2732 | case 7: /* unofficial extension */ |
2652 | case 7: /* unofficial extension */ |
2733 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2653 | tt_printf ("%-.250s\n", rs[Rs_display_name]); |
2734 | break; |
2654 | break; |
2735 | #endif |
2655 | #endif |
2736 | case 8: /* unofficial extension */ |
2656 | case 8: /* unofficial extension */ |
2737 | xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); |
2657 | xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2738 | break; |
2658 | break; |
2739 | } |
2659 | } |
2740 | break; |
2660 | break; |
2741 | |
2661 | |
2742 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
2662 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
2810 | #endif |
2730 | #endif |
2811 | |
2731 | |
2812 | case CSI_78: /* DECREQTPARM */ |
2732 | case CSI_78: /* DECREQTPARM */ |
2813 | if (arg[0] == 0 || arg[0] == 1) |
2733 | if (arg[0] == 0 || arg[0] == 1) |
2814 | tt_printf ("\033[%d;1;1;128;128;1;0x", arg[0] + 2); |
2734 | tt_printf ("\033[%d;1;1;128;128;1;0x", arg[0] + 2); |
2815 | /* FALLTHROUGH */ |
2735 | break; |
2816 | |
2736 | |
2817 | default: |
2737 | default: |
2818 | break; |
2738 | break; |
2819 | } |
2739 | } |
2820 | } |
2740 | } |
… | |
… | |
2823 | #ifndef NO_FRILLS |
2743 | #ifndef NO_FRILLS |
2824 | /* ARGSUSED */ |
2744 | /* ARGSUSED */ |
2825 | void |
2745 | void |
2826 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
2746 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
2827 | { |
2747 | { |
2828 | int x, y; |
2748 | int x, y; |
2829 | #if 0 |
|
|
2830 | char *s; |
|
|
2831 | #endif |
|
|
2832 | XWindowAttributes wattr; |
2749 | XWindowAttributes wattr; |
2833 | Window wdummy; |
2750 | Window wdummy; |
2834 | |
2751 | |
2835 | if (nargs == 0) |
2752 | if (nargs == 0) |
2836 | return; |
2753 | return; |
|
|
2754 | |
2837 | switch (args[0]) |
2755 | switch (args[0]) |
2838 | { |
2756 | { |
2839 | /* |
2757 | /* |
2840 | * commands |
2758 | * commands |
2841 | */ |
2759 | */ |
2842 | case 1: /* deiconify window */ |
2760 | case 1: /* deiconify window */ |
2843 | XMapWindow (display->display, TermWin.parent[0]); |
2761 | XMapWindow (display->display, TermWin.parent[0]); |
2844 | break; |
2762 | break; |
2845 | case 2: /* iconify window */ |
2763 | case 2: /* iconify window */ |
2846 | XIconifyWindow (display->display, TermWin.parent[0], |
2764 | XIconifyWindow (display->display, TermWin.parent[0], |
… | |
… | |
2863 | break; |
2781 | break; |
2864 | case 8: /* set size (chars) */ |
2782 | case 8: /* set size (chars) */ |
2865 | set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), |
2783 | set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), |
2866 | (unsigned int) (args[1] * TermWin.fheight)); |
2784 | (unsigned int) (args[1] * TermWin.fheight)); |
2867 | break; |
2785 | break; |
|
|
2786 | |
|
|
2787 | //case 9: NYI, TODO, restore maximized window or maximize window |
2868 | default: |
2788 | default: |
2869 | if (args[0] >= 24) /* set height (chars) */ |
2789 | if (args[0] >= 24) /* set height (chars) */ |
2870 | set_widthheight ((unsigned int)TermWin.width, |
2790 | set_widthheight ((unsigned int)TermWin.width, |
2871 | (unsigned int) (args[1] * TermWin.fheight)); |
2791 | (unsigned int) (args[1] * TermWin.fheight)); |
2872 | break; |
2792 | break; |
|
|
2793 | |
|
|
2794 | |
2873 | /* |
2795 | /* |
2874 | * reports - some output format copied from XTerm |
2796 | * reports - some output format copied from XTerm |
2875 | */ |
2797 | */ |
2876 | case 11: /* report window state */ |
2798 | case 11: /* report window state */ |
2877 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2799 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2878 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
2800 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
2879 | break; |
2801 | break; |
2880 | case 13: /* report window position */ |
2802 | case 13: /* report window position */ |
… | |
… | |
2886 | break; |
2808 | break; |
2887 | case 14: /* report window size (pixels) */ |
2809 | case 14: /* report window size (pixels) */ |
2888 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2810 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2889 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
2811 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
2890 | break; |
2812 | break; |
2891 | case 18: /* report window size (chars) */ |
2813 | case 18: /* report text area size (chars) */ |
2892 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
2814 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
|
|
2815 | break; |
|
|
2816 | case 19: /* report window size (chars) */ |
|
|
2817 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
2893 | break; |
2818 | break; |
2894 | #if 0 /* XXX: currently disabled due to security concerns */ |
2819 | #if 0 /* XXX: currently disabled due to security concerns */ |
2895 | case 20: /* report icon label */ |
2820 | case 20: /* report icon label */ |
2896 | XGetIconName (display->display, TermWin.parent[0], &s); |
2821 | XGetIconName (display->display, TermWin.parent[0], &s); |
2897 | tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ |
2822 | tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ |
… | |
… | |
2899 | case 21: /* report window title */ |
2824 | case 21: /* report window title */ |
2900 | XFetchName (display->display, TermWin.parent[0], &s); |
2825 | XFetchName (display->display, TermWin.parent[0], &s); |
2901 | tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ |
2826 | tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ |
2902 | break; |
2827 | break; |
2903 | #endif |
2828 | #endif |
2904 | |
|
|
2905 | } |
2829 | } |
2906 | } |
2830 | } |
2907 | #endif |
2831 | #endif |
2908 | |
2832 | |
2909 | /*----------------------------------------------------------------------*/ |
2833 | /*----------------------------------------------------------------------*/ |
2910 | /* |
2834 | /* |
2911 | * get input up until STRING TERMINATOR (or BEL) |
2835 | * get input up until STRING TERMINATOR (or BEL) |
2912 | * ends_how is terminator used. returned input must be free ()d |
2836 | * ends_how is terminator used. returned input must be free ()d |
2913 | */ |
2837 | */ |
2914 | unsigned char * |
2838 | unsigned char * |
2915 | rxvt_term::get_to_st (unsigned char *ends_how) |
2839 | rxvt_term::get_to_st (unicode_t &ends_how) |
2916 | { |
2840 | { |
2917 | int seen_esc = 0; /* seen escape? */ |
2841 | int seen_esc = 0; /* seen escape? */ |
2918 | unsigned int n = 0; |
2842 | unsigned int n = 0; |
2919 | unsigned char *s; |
2843 | unsigned char *s; |
|
|
2844 | unicode_t ch; |
2920 | unsigned char ch, string[STRING_MAX]; |
2845 | unsigned char string[STRING_MAX]; |
2921 | |
2846 | |
2922 | for (; (ch = cmd_getc ());) |
2847 | while ((ch = cmd_getc ())) |
2923 | { |
2848 | { |
2924 | if (ch == C0_BEL |
2849 | if (ch == C0_BEL |
2925 | || ch == CHAR_ST |
2850 | || ch == CHAR_ST |
2926 | || (ch == 0x5c && seen_esc)) /* 7bit ST */ |
2851 | || (ch == 0x5c && seen_esc)) /* 7bit ST */ |
2927 | break; |
2852 | break; |
|
|
2853 | |
2928 | if (ch == C0_ESC) |
2854 | if (ch == C0_ESC) |
2929 | { |
2855 | { |
2930 | seen_esc = 1; |
2856 | seen_esc = 1; |
2931 | continue; |
2857 | continue; |
2932 | } |
2858 | } |
2933 | else if (ch == '\t') |
2859 | else if (ch == '\t') |
2934 | ch = ' '; /* translate '\t' to space */ |
2860 | ch = ' '; /* translate '\t' to space */ |
2935 | else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) |
2861 | else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) |
2936 | return NULL; /* other control character - exit */ |
2862 | return NULL; /* other control character - exit */ |
|
|
2863 | |
2937 | if (n < sizeof (string) - 1) |
2864 | if (n < sizeof (string) - 1) |
2938 | string[n++] = ch; |
2865 | string[n++] = ch; |
|
|
2866 | |
2939 | seen_esc = 0; |
2867 | seen_esc = 0; |
2940 | } |
2868 | } |
|
|
2869 | |
2941 | string[n++] = '\0'; |
2870 | string[n++] = '\0'; |
|
|
2871 | |
2942 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
2872 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
2943 | return NULL; |
2873 | return NULL; |
|
|
2874 | |
2944 | *ends_how = (ch == 0x5c ? C0_ESC : ch); |
2875 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
2945 | STRNCPY (s, string, n); |
2876 | STRNCPY (s, string, n); |
2946 | return s; |
2877 | return s; |
2947 | } |
2878 | } |
2948 | |
2879 | |
2949 | /*----------------------------------------------------------------------*/ |
2880 | /*----------------------------------------------------------------------*/ |
… | |
… | |
2951 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
2882 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
2952 | */ |
2883 | */ |
2953 | void |
2884 | void |
2954 | rxvt_term::process_dcs_seq () |
2885 | rxvt_term::process_dcs_seq () |
2955 | { |
2886 | { |
2956 | unsigned char eh, *s; |
2887 | unsigned char *s; |
|
|
2888 | unicode_t eh; |
|
|
2889 | |
2957 | /* |
2890 | /* |
2958 | * Not handled yet |
2891 | * Not handled yet |
2959 | */ |
2892 | */ |
2960 | s = get_to_st (&eh); |
2893 | s = get_to_st (eh); |
2961 | if (s) |
2894 | if (s) |
2962 | free (s); |
2895 | free (s); |
|
|
2896 | |
2963 | return; |
2897 | return; |
2964 | } |
2898 | } |
2965 | |
2899 | |
2966 | /*----------------------------------------------------------------------*/ |
2900 | /*----------------------------------------------------------------------*/ |
2967 | /* |
2901 | /* |
2968 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
2902 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
2969 | */ |
2903 | */ |
2970 | void |
2904 | void |
2971 | rxvt_term::process_osc_seq () |
2905 | rxvt_term::process_osc_seq () |
2972 | { |
2906 | { |
2973 | unsigned char ch, eh, *s; |
2907 | unicode_t ch, eh; |
2974 | int arg; |
2908 | int arg; |
2975 | |
2909 | |
2976 | ch = cmd_getc (); |
2910 | ch = cmd_getc (); |
2977 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
2911 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
2978 | arg = arg * 10 + (ch - '0'); |
2912 | arg = arg * 10 + (ch - '0'); |
2979 | |
2913 | |
2980 | if (ch == ';') |
2914 | if (ch == ';') |
2981 | { |
2915 | { |
2982 | s = get_to_st (&eh); |
2916 | unsigned char *s = get_to_st (eh); |
|
|
2917 | |
2983 | if (s) |
2918 | if (s) |
2984 | { |
2919 | { |
2985 | /* |
2920 | /* |
2986 | * rxvt_menubar_dispatch () violates the constness of the string, |
2921 | * rxvt_menubar_dispatch () violates the constness of the string, |
2987 | * so do it here |
2922 | * so do it here |
… | |
… | |
2992 | #else |
2927 | #else |
2993 | (void)0; |
2928 | (void)0; |
2994 | #endif |
2929 | #endif |
2995 | else |
2930 | else |
2996 | xterm_seq (arg, (char *)s, eh); |
2931 | xterm_seq (arg, (char *)s, eh); |
|
|
2932 | |
2997 | free (s); |
2933 | free (s); |
2998 | } |
2934 | } |
2999 | } |
2935 | } |
3000 | } |
2936 | } |
3001 | /* |
2937 | /* |
… | |
… | |
3016 | * 10 = menu (may change in future) |
2952 | * 10 = menu (may change in future) |
3017 | * 20 = bg pixmap |
2953 | * 20 = bg pixmap |
3018 | * 39 = change default fg color |
2954 | * 39 = change default fg color |
3019 | * 49 = change default bg color |
2955 | * 49 = change default bg color |
3020 | * 55 = dump scrollback buffer and all of screen |
2956 | * 55 = dump scrollback buffer and all of screen |
|
|
2957 | * 701 = change locale |
|
|
2958 | * 702 = find font |
3021 | */ |
2959 | */ |
3022 | void |
2960 | void |
3023 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
2961 | rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) |
3024 | { |
2962 | { |
3025 | int changed = 0; |
2963 | int changed = 0; |
3026 | int color; |
2964 | int color; |
3027 | char *buf, *name; |
2965 | char *buf, *name; |
3028 | |
2966 | |
3029 | assert (str != NULL); |
2967 | assert (str != NULL); |
3030 | switch (op) |
2968 | switch (op) |
3031 | { |
2969 | { |
3032 | case XTerm_name: |
2970 | case XTerm_name: |
3033 | set_title (str); |
2971 | set_title (str); |
3034 | /* FALLTHROUGH */ |
2972 | /* FALLTHROUGH */ |
3035 | case XTerm_iconName: |
2973 | case XTerm_iconName: |
3036 | set_iconName (str); |
2974 | set_icon_name (str); |
3037 | break; |
2975 | break; |
3038 | case XTerm_title: |
2976 | case XTerm_title: |
3039 | set_title (str); |
2977 | set_title (str); |
3040 | break; |
2978 | break; |
3041 | case XTerm_Color: |
2979 | case XTerm_Color: |
3042 | for (buf = (char *)str; buf && *buf;) |
2980 | for (buf = (char *)str; buf && *buf;) |
3043 | { |
2981 | { |
3044 | if ((name = STRCHR (buf, ';')) == NULL) |
2982 | if ((name = STRCHR (buf, ';')) == NULL) |
3045 | break; |
2983 | break; |
|
|
2984 | |
3046 | *name++ = '\0'; |
2985 | *name++ = '\0'; |
3047 | color = atoi (buf); |
2986 | color = atoi (buf); |
|
|
2987 | |
3048 | if (color < 0 || color >= TOTAL_COLORS) |
2988 | if (color < 0 || color >= TOTAL_COLORS) |
3049 | break; |
2989 | break; |
|
|
2990 | |
3050 | if ((buf = STRCHR (name, ';')) != NULL) |
2991 | if ((buf = STRCHR (name, ';')) != NULL) |
3051 | *buf++ = '\0'; |
2992 | *buf++ = '\0'; |
|
|
2993 | |
3052 | set_window_color (color + minCOLOR, name); |
2994 | set_window_color (color + minCOLOR, name); |
3053 | } |
2995 | } |
3054 | break; |
2996 | break; |
3055 | #ifndef NO_CURSORCOLOR |
2997 | #ifndef NO_CURSORCOLOR |
3056 | case XTerm_Color_cursor: |
2998 | case XTerm_Color_cursor: |
… | |
… | |
3109 | break; |
3051 | break; |
3110 | case XTerm_restoreBG: |
3052 | case XTerm_restoreBG: |
3111 | set_window_color (Color_bg, str); |
3053 | set_window_color (Color_bg, str); |
3112 | break; |
3054 | break; |
3113 | case XTerm_logfile: |
3055 | case XTerm_logfile: |
|
|
3056 | // TODO, when secure mode? |
3114 | break; |
3057 | break; |
3115 | case XTerm_font: |
3058 | case XTerm_font: |
3116 | change_font (0, str); |
3059 | change_font (str); |
3117 | break; |
3060 | break; |
|
|
3061 | #ifndef NO_FRILLS |
|
|
3062 | case XTerm_locale: |
|
|
3063 | if (str[0] == '?' && !str[1]) |
|
|
3064 | tt_printf ("%-.250s\n", locale); |
|
|
3065 | else |
|
|
3066 | { |
|
|
3067 | set_locale (str); |
|
|
3068 | # ifdef USE_XIM |
|
|
3069 | im_cb (); |
|
|
3070 | # endif |
|
|
3071 | } |
|
|
3072 | break; |
|
|
3073 | case XTerm_findfont: |
|
|
3074 | { |
|
|
3075 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3076 | tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); |
|
|
3077 | } |
|
|
3078 | break; |
|
|
3079 | #endif |
3118 | #if 0 |
3080 | #if 0 |
3119 | case XTerm_dumpscreen: /* no error notices */ |
3081 | case XTerm_dumpscreen: /* no error notices */ |
3120 | { |
3082 | { |
3121 | int fd; |
3083 | int fd; |
3122 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3084 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3125 | close (fd); |
3087 | close (fd); |
3126 | } |
3088 | } |
3127 | } |
3089 | } |
3128 | break; |
3090 | break; |
3129 | #endif |
3091 | #endif |
3130 | |
|
|
3131 | } |
3092 | } |
3132 | } |
3093 | } |
3133 | /*----------------------------------------------------------------------*/ |
3094 | /*----------------------------------------------------------------------*/ |
3134 | |
3095 | |
3135 | /*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */ |
3096 | /*{{{ process DEC private mode sequences `ESC [ ? Ps mode' */ |
… | |
… | |
3143 | * so no need for fancy checking |
3104 | * so no need for fancy checking |
3144 | */ |
3105 | */ |
3145 | int |
3106 | int |
3146 | rxvt_term::privcases (int mode, unsigned long bit) |
3107 | rxvt_term::privcases (int mode, unsigned long bit) |
3147 | { |
3108 | { |
3148 | int state; |
3109 | int state; |
3149 | |
3110 | |
3150 | if (mode == 's') |
3111 | if (mode == 's') |
3151 | { |
3112 | { |
3152 | SavedModes |= (PrivateModes & bit); |
3113 | SavedModes |= (PrivateModes & bit); |
3153 | return -1; |
3114 | return -1; |
… | |
… | |
3158 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3119 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3159 | else |
3120 | else |
3160 | state = (mode == 't') ? ! (PrivateModes & bit) : mode; |
3121 | state = (mode == 't') ? ! (PrivateModes & bit) : mode; |
3161 | PrivMode (state, bit); |
3122 | PrivMode (state, bit); |
3162 | } |
3123 | } |
|
|
3124 | |
3163 | return state; |
3125 | return state; |
3164 | } |
3126 | } |
3165 | |
3127 | |
3166 | /* we're not using priv _yet_ */ |
3128 | /* we're not using priv _yet_ */ |
3167 | void |
3129 | void |
3168 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3130 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3169 | { |
3131 | { |
3170 | unsigned int i, j; |
3132 | unsigned int i, j; |
3171 | int state; |
3133 | int state; |
|
|
3134 | |
3172 | static const struct |
3135 | static const struct |
3173 | { |
3136 | { |
3174 | const int argval; |
3137 | const int argval; |
3175 | const unsigned long bit; |
3138 | const unsigned long bit; |
3176 | } |
3139 | } |
|
|
3140 | |
3177 | argtopriv[] = { |
3141 | argtopriv[] = { |
3178 | { 1, PrivMode_aplCUR }, |
3142 | { 1, PrivMode_aplCUR }, |
3179 | { 2, PrivMode_vt52 }, |
3143 | { 2, PrivMode_vt52 }, |
3180 | { 3, PrivMode_132 }, |
3144 | { 3, PrivMode_132 }, |
3181 | { 4, PrivMode_smoothScroll }, |
3145 | { 4, PrivMode_smoothScroll }, |
… | |
… | |
3187 | { menuBar_esc, PrivMode_menuBar }, |
3151 | { menuBar_esc, PrivMode_menuBar }, |
3188 | #endif |
3152 | #endif |
3189 | #ifdef scrollBar_esc |
3153 | #ifdef scrollBar_esc |
3190 | { scrollBar_esc, PrivMode_scrollBar }, |
3154 | { scrollBar_esc, PrivMode_scrollBar }, |
3191 | #endif |
3155 | #endif |
|
|
3156 | // 18, 19 printing-related |
3192 | { 25, PrivMode_VisibleCursor }, |
3157 | { 25, PrivMode_VisibleCursor }, |
|
|
3158 | // 30 show scrollbar rxvt. extension |
3193 | { 35, PrivMode_ShiftKeys }, |
3159 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3194 | { 40, PrivMode_132OK }, |
3160 | { 40, PrivMode_132OK }, |
|
|
3161 | // 41 xterm more fixes NYI |
|
|
3162 | // 45 margin bell NYI |
|
|
3163 | // 46 start logging |
3195 | { 47, PrivMode_Screen }, |
3164 | { 47, PrivMode_Screen }, |
3196 | { 66, PrivMode_aplKP }, |
3165 | { 66, PrivMode_aplKP }, |
3197 | #ifndef NO_BACKSPACE_KEY |
3166 | #ifndef NO_BACKSPACE_KEY |
3198 | { 67, PrivMode_BackSpace }, |
3167 | { 67, PrivMode_BackSpace }, |
3199 | #endif |
3168 | #endif |
3200 | { 1000, PrivMode_MouseX11 }, |
3169 | { 1000, PrivMode_MouseX11 }, |
|
|
3170 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
|
|
3171 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
|
|
3172 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
3201 | { 1010, PrivMode_TtyOutputInh }, |
3173 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3202 | { 1011, PrivMode_Keypress }, |
3174 | { 1011, PrivMode_Keypress }, // rxvt extension |
|
|
3175 | // 1035 enable modifiers for alt, numlock NYI |
|
|
3176 | // 1036 send ESC for meta keys NYI |
|
|
3177 | // 1037 send DEL for keypad delete NYI |
3203 | { 1047, PrivMode_Screen }, |
3178 | { 1047, PrivMode_Screen }, |
|
|
3179 | // 1048 save and restore cursor |
3204 | { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ |
3180 | { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ |
|
|
3181 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3205 | }; |
3182 | }; |
3206 | |
3183 | |
3207 | if (nargs == 0) |
3184 | if (nargs == 0) |
3208 | return; |
3185 | return; |
3209 | |
3186 | |
… | |
… | |
3224 | state = privcases (mode, argtopriv[j].bit); |
3201 | state = privcases (mode, argtopriv[j].bit); |
3225 | break; |
3202 | break; |
3226 | } |
3203 | } |
3227 | |
3204 | |
3228 | /* extra handling for values with state unkept */ |
3205 | /* extra handling for values with state unkept */ |
|
|
3206 | switch (arg[i]) |
|
|
3207 | { |
|
|
3208 | case 1048: /* alternative cursor save */ |
|
|
3209 | case 1049: |
|
|
3210 | if (mode == 0) |
|
|
3211 | scr_cursor (RESTORE); |
|
|
3212 | else if (mode == 1) |
|
|
3213 | scr_cursor (SAVE); |
|
|
3214 | /* FALLTHROUGH */ |
|
|
3215 | } |
|
|
3216 | |
3229 | if (state == -1) |
3217 | if (state >= 0) |
|
|
3218 | /* extra handling for values with valid 0 or 1 state */ |
3230 | switch (arg[i]) |
3219 | switch (arg[i]) |
3231 | { |
3220 | { |
3232 | case 1048: /* alternative cursor save */ |
3221 | /* case 1: - application cursor keys */ |
|
|
3222 | case 2: /* VT52 mode */ |
|
|
3223 | /* oddball mode. should be set regardless of set/reset |
|
|
3224 | * parameter. Return from VT52 mode with an ESC < from |
|
|
3225 | * within VT52 mode |
|
|
3226 | */ |
|
|
3227 | PrivMode (1, PrivMode_vt52); |
|
|
3228 | break; |
|
|
3229 | case 3: /* 80/132 */ |
|
|
3230 | if (PrivateModes & PrivMode_132OK) |
|
|
3231 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
|
|
3232 | break; |
|
|
3233 | case 4: /* smooth scrolling */ |
3233 | if (mode == 0) |
3234 | if (state) |
3234 | scr_cursor (RESTORE); |
3235 | Options &= ~Opt_jumpScroll; |
3235 | else if (mode == 1) |
3236 | else |
3236 | scr_cursor (SAVE); |
3237 | Options |= Opt_jumpScroll; |
|
|
3238 | break; |
|
|
3239 | case 5: /* reverse video */ |
|
|
3240 | scr_rvideo_mode (state); |
|
|
3241 | break; |
|
|
3242 | case 6: /* relative/absolute origins */ |
|
|
3243 | scr_relative_origin (state); |
|
|
3244 | break; |
|
|
3245 | case 7: /* autowrap */ |
|
|
3246 | scr_autowrap (state); |
|
|
3247 | break; |
|
|
3248 | /* case 8: - auto repeat, can't do on a per window basis */ |
|
|
3249 | case 9: /* X10 mouse reporting */ |
|
|
3250 | if (state) /* orthogonal */ |
|
|
3251 | PrivateModes &= ~PrivMode_MouseX11; |
|
|
3252 | break; |
|
|
3253 | #ifdef menuBar_esc |
|
|
3254 | case menuBar_esc: |
|
|
3255 | #ifdef MENUBAR |
|
|
3256 | map_menuBar (state); |
|
|
3257 | #endif |
|
|
3258 | break; |
|
|
3259 | #endif |
|
|
3260 | #ifdef scrollBar_esc |
|
|
3261 | case scrollBar_esc: |
|
|
3262 | if (scrollbar_mapping (state)) |
|
|
3263 | { |
|
|
3264 | resize_all_windows (0, 0, 0); |
|
|
3265 | scr_touch (true); |
|
|
3266 | } |
|
|
3267 | break; |
|
|
3268 | #endif |
|
|
3269 | case 25: /* visible/invisible cursor */ |
|
|
3270 | scr_cursor_visible (state); |
|
|
3271 | break; |
|
|
3272 | /* case 35: - shift keys */ |
|
|
3273 | /* case 40: - 80 <--> 132 mode */ |
|
|
3274 | case 47: /* secondary screen */ |
|
|
3275 | scr_change_screen (state); |
|
|
3276 | break; |
|
|
3277 | /* case 66: - application key pad */ |
|
|
3278 | /* case 67: - backspace key */ |
|
|
3279 | case 1000: /* X11 mouse reporting */ |
|
|
3280 | if (state) /* orthogonal */ |
|
|
3281 | PrivateModes &= ~PrivMode_MouseX10; |
|
|
3282 | break; |
|
|
3283 | #if 0 |
|
|
3284 | case 1001: |
|
|
3285 | break; /* X11 mouse highlighting */ |
|
|
3286 | #endif |
|
|
3287 | case 1010: /* scroll to bottom on TTY output inhibit */ |
|
|
3288 | if (state) |
|
|
3289 | Options &= ~Opt_scrollTtyOutput; |
|
|
3290 | else |
|
|
3291 | Options |= Opt_scrollTtyOutput; |
|
|
3292 | break; |
|
|
3293 | case 1011: /* scroll to bottom on key press */ |
|
|
3294 | if (state) |
|
|
3295 | Options |= Opt_scrollTtyKeypress; |
|
|
3296 | else |
|
|
3297 | Options &= ~Opt_scrollTtyKeypress; |
|
|
3298 | break; |
|
|
3299 | case 1047: /* secondary screen w/ clearing */ |
|
|
3300 | case 1049: /* better secondary screen w/ clearing, but not fully implemented */ |
|
|
3301 | if (current_screen != PRIMARY) |
|
|
3302 | scr_erase_screen (2); |
|
|
3303 | |
|
|
3304 | scr_change_screen (state); |
3237 | /* FALLTHROUGH */ |
3305 | /* FALLTHROUGH */ |
3238 | default: |
3306 | default: |
3239 | continue; /* for (;i;) */ |
3307 | break; |
3240 | } |
3308 | } |
3241 | |
|
|
3242 | /* extra handling for values with valid 0 or 1 state */ |
|
|
3243 | switch (arg[i]) |
|
|
3244 | { |
|
|
3245 | /* case 1: - application cursor keys */ |
|
|
3246 | case 2: /* VT52 mode */ |
|
|
3247 | /* oddball mode. should be set regardless of set/reset |
|
|
3248 | * parameter. Return from VT52 mode with an ESC < from |
|
|
3249 | * within VT52 mode |
|
|
3250 | */ |
|
|
3251 | PrivMode (1, PrivMode_vt52); |
|
|
3252 | break; |
|
|
3253 | case 3: /* 80/132 */ |
|
|
3254 | if (PrivateModes & PrivMode_132OK) |
|
|
3255 | set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), |
|
|
3256 | (unsigned int)TermWin.height); |
|
|
3257 | break; |
|
|
3258 | case 4: /* smooth scrolling */ |
|
|
3259 | if (state) |
|
|
3260 | Options &= ~Opt_jumpScroll; |
|
|
3261 | else |
|
|
3262 | Options |= Opt_jumpScroll; |
|
|
3263 | break; |
|
|
3264 | case 5: /* reverse video */ |
|
|
3265 | scr_rvideo_mode (state); |
|
|
3266 | break; |
|
|
3267 | case 6: /* relative/absolute origins */ |
|
|
3268 | scr_relative_origin (state); |
|
|
3269 | break; |
|
|
3270 | case 7: /* autowrap */ |
|
|
3271 | scr_autowrap (state); |
|
|
3272 | break; |
|
|
3273 | /* case 8: - auto repeat, can't do on a per window basis */ |
|
|
3274 | case 9: /* X10 mouse reporting */ |
|
|
3275 | if (state) /* orthogonal */ |
|
|
3276 | PrivateModes &= ~ (PrivMode_MouseX11); |
|
|
3277 | break; |
|
|
3278 | #ifdef menuBar_esc |
|
|
3279 | case menuBar_esc: |
|
|
3280 | #ifdef MENUBAR |
|
|
3281 | map_menuBar (state); |
|
|
3282 | #endif |
|
|
3283 | break; |
|
|
3284 | #endif |
|
|
3285 | #ifdef scrollBar_esc |
|
|
3286 | case scrollBar_esc: |
|
|
3287 | if (scrollbar_mapping (state)) |
|
|
3288 | { |
|
|
3289 | resize_all_windows (0, 0, 0); |
|
|
3290 | scr_touch (true); |
|
|
3291 | } |
|
|
3292 | break; |
|
|
3293 | #endif |
|
|
3294 | case 25: /* visible/invisible cursor */ |
|
|
3295 | scr_cursor_visible (state); |
|
|
3296 | break; |
|
|
3297 | /* case 35: - shift keys */ |
|
|
3298 | /* case 40: - 80 <--> 132 mode */ |
|
|
3299 | case 47: /* secondary screen */ |
|
|
3300 | scr_change_screen (state); |
|
|
3301 | break; |
|
|
3302 | /* case 66: - application key pad */ |
|
|
3303 | /* case 67: - backspace key */ |
|
|
3304 | case 1000: /* X11 mouse reporting */ |
|
|
3305 | if (state) /* orthogonal */ |
|
|
3306 | PrivateModes &= ~ (PrivMode_MouseX10); |
|
|
3307 | break; |
|
|
3308 | #if 0 |
|
|
3309 | case 1001: |
|
|
3310 | break; /* X11 mouse highlighting */ |
|
|
3311 | #endif |
|
|
3312 | case 1010: /* scroll to bottom on TTY output inhibit */ |
|
|
3313 | if (state) |
|
|
3314 | Options &= ~Opt_scrollTtyOutput; |
|
|
3315 | else |
|
|
3316 | Options |= Opt_scrollTtyOutput; |
|
|
3317 | break; |
|
|
3318 | case 1011: /* scroll to bottom on key press */ |
|
|
3319 | if (state) |
|
|
3320 | Options |= Opt_scrollTtyKeypress; |
|
|
3321 | else |
|
|
3322 | Options &= ~Opt_scrollTtyKeypress; |
|
|
3323 | break; |
|
|
3324 | case 1047: /* secondary screen w/ clearing */ |
|
|
3325 | case 1049: /* better secondary screen w/ clearing, but not fully implemented */ |
|
|
3326 | if (current_screen != PRIMARY) |
|
|
3327 | scr_erase_screen (2); |
|
|
3328 | scr_change_screen (state); |
|
|
3329 | /* FALLTHROUGH */ |
|
|
3330 | default: |
|
|
3331 | break; |
|
|
3332 | } |
|
|
3333 | } |
3309 | } |
3334 | } |
3310 | } |
3335 | /*}}} */ |
3311 | /*}}} */ |
3336 | |
3312 | |
3337 | /*{{{ process sgr sequences */ |
3313 | /*{{{ process sgr sequences */ |
3338 | void |
3314 | void |
3339 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
3315 | rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) |
3340 | { |
3316 | { |
3341 | unsigned int i; |
3317 | unsigned int i; |
3342 | short rendset; |
3318 | short rendset; |
3343 | int rendstyle; |
3319 | int rendstyle; |
3344 | |
3320 | |
3345 | if (nargs == 0) |
3321 | if (nargs == 0) |
3346 | { |
3322 | { |
3347 | scr_rendition (0, ~RS_None); |
3323 | scr_rendition (0, ~RS_None); |
3348 | return; |
3324 | return; |
3349 | } |
3325 | } |
|
|
3326 | |
3350 | for (i = 0; i < nargs; i++) |
3327 | for (i = 0; i < nargs; i++) |
3351 | { |
3328 | { |
3352 | rendset = -1; |
3329 | rendset = -1; |
3353 | switch (arg[i]) |
3330 | switch (arg[i]) |
3354 | { |
3331 | { |
… | |
… | |
3365 | rendset = 1, rendstyle = RS_Blink; |
3342 | rendset = 1, rendstyle = RS_Blink; |
3366 | break; |
3343 | break; |
3367 | case 7: |
3344 | case 7: |
3368 | rendset = 1, rendstyle = RS_RVid; |
3345 | rendset = 1, rendstyle = RS_RVid; |
3369 | break; |
3346 | break; |
|
|
3347 | case 8: |
|
|
3348 | // invisible. NYI |
|
|
3349 | break; |
3370 | case 22: |
3350 | case 22: |
3371 | rendset = 0, rendstyle = RS_Bold; |
3351 | rendset = 0, rendstyle = RS_Bold; |
3372 | break; |
3352 | break; |
3373 | case 24: |
3353 | case 24: |
3374 | rendset = 0, rendstyle = RS_Uline; |
3354 | rendset = 0, rendstyle = RS_Uline; |
… | |
… | |
3377 | rendset = 0, rendstyle = RS_Blink; |
3357 | rendset = 0, rendstyle = RS_Blink; |
3378 | break; |
3358 | break; |
3379 | case 27: |
3359 | case 27: |
3380 | rendset = 0, rendstyle = RS_RVid; |
3360 | rendset = 0, rendstyle = RS_RVid; |
3381 | break; |
3361 | break; |
|
|
3362 | case 28: |
|
|
3363 | // visible. NYI |
|
|
3364 | break; |
3382 | } |
3365 | } |
|
|
3366 | |
3383 | if (rendset != -1) |
3367 | if (rendset != -1) |
3384 | { |
3368 | { |
3385 | scr_rendition (rendset, rendstyle); |
3369 | scr_rendition (rendset, rendstyle); |
3386 | continue; /* for (;i;) */ |
3370 | continue; /* for (;i;) */ |
3387 | } |
3371 | } |
… | |
… | |
3394 | case 33: |
3378 | case 33: |
3395 | case 34: |
3379 | case 34: |
3396 | case 35: |
3380 | case 35: |
3397 | case 36: |
3381 | case 36: |
3398 | case 37: |
3382 | case 37: |
3399 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), |
3383 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
3400 | Color_fg); |
|
|
3401 | break; |
3384 | break; |
3402 | #ifdef TTY_256COLOR |
3385 | #ifdef TTY_256COLOR |
3403 | case 38: |
3386 | case 38: |
3404 | if (nargs > i + 2 && arg[i + 1] == 5) |
3387 | if (nargs > i + 2 && arg[i + 1] == 5) |
3405 | { |
3388 | { |
3406 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), |
3389 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
3407 | Color_fg); |
|
|
3408 | i += 2; |
3390 | i += 2; |
3409 | } |
3391 | } |
3410 | break; |
3392 | break; |
3411 | #endif |
3393 | #endif |
3412 | case 39: /* default fg */ |
3394 | case 39: /* default fg */ |
… | |
… | |
3419 | case 43: |
3401 | case 43: |
3420 | case 44: |
3402 | case 44: |
3421 | case 45: |
3403 | case 45: |
3422 | case 46: |
3404 | case 46: |
3423 | case 47: |
3405 | case 47: |
3424 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), |
3406 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
3425 | Color_bg); |
|
|
3426 | break; |
3407 | break; |
3427 | #ifdef TTY_256COLOR |
3408 | #ifdef TTY_256COLOR |
3428 | case 48: |
3409 | case 48: |
3429 | if (nargs > i + 2 && arg[i + 1] == 5) |
3410 | if (nargs > i + 2 && arg[i + 1] == 5) |
3430 | { |
3411 | { |
3431 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), |
3412 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
3432 | Color_bg); |
|
|
3433 | i += 2; |
3413 | i += 2; |
3434 | } |
3414 | } |
3435 | break; |
3415 | break; |
3436 | #endif |
3416 | #endif |
3437 | case 49: /* default bg */ |
3417 | case 49: /* default bg */ |
… | |
… | |
3470 | |
3450 | |
3471 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3451 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3472 | void |
3452 | void |
3473 | rxvt_term::process_graphics () |
3453 | rxvt_term::process_graphics () |
3474 | { |
3454 | { |
3475 | unsigned char ch, cmd = cmd_getc (); |
3455 | unicode_t ch, cmd = cmd_getc (); |
3476 | |
3456 | |
3477 | #ifndef RXVT_GRAPHICS |
|
|
3478 | if (cmd == 'Q') |
3457 | if (cmd == 'Q') |
3479 | { /* query graphics */ |
3458 | { /* query graphics */ |
3480 | tt_printf ("\033G0\n"); /* no graphics */ |
3459 | tt_printf ("\033G0\n"); /* no graphics */ |
3481 | return; |
3460 | return; |
3482 | } |
3461 | } |
3483 | /* swallow other graphics sequences until terminating ':' */ |
3462 | /* swallow other graphics sequences until terminating ':' */ |
3484 | do |
3463 | do |
3485 | ch = cmd_getc (); |
3464 | ch = cmd_getc (); |
3486 | while (ch != ':'); |
3465 | 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 | } |
3466 | } |
3533 | /*}}} */ |
3467 | /*}}} */ |
3534 | |
3468 | |
3535 | /* ------------------------------------------------------------------------- */ |
3469 | /* ------------------------------------------------------------------------- */ |
3536 | |
3470 | |