… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
52 | |
53 | |
|
|
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
53 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
60 | # include "keyboard.h" |
55 | #endif |
61 | #endif |
56 | |
62 | |
57 | #include <csignal> |
63 | #include <csignal> |
58 | |
64 | |
59 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
60 | |
66 | |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | |
|
|
63 | // exception thrown when the command parser runs out of input data |
|
|
64 | class out_of_input { } out_of_input; |
|
|
65 | |
68 | |
66 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
67 | |
70 | |
68 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
69 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
141 | || !IN_RANGE_EXC (y, 0, nrow)) |
144 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | return; |
145 | return; |
143 | |
146 | |
144 | for (;;) |
147 | for (;;) |
145 | { |
148 | { |
146 | const line_t &l = ROW(y - view_start); |
149 | const line_t &l = ROW(y + view_start); |
147 | |
150 | |
148 | text_t t = l.t[x]; |
151 | text_t t = l.t[x]; |
149 | |
152 | |
150 | if (t != NOCHAR || !x) |
153 | if (t != NOCHAR || !x) |
151 | { |
154 | { |
… | |
… | |
155 | } |
158 | } |
156 | |
159 | |
157 | x--; |
160 | x--; |
158 | } |
161 | } |
159 | } |
162 | } |
160 | #endif |
|
|
161 | |
163 | |
162 | void |
164 | void |
163 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
165 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
164 | { |
166 | { |
165 | #if ENABLE_OVERLAY |
|
|
166 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
169 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
170 | int len; |
170 | |
171 | |
… | |
… | |
238 | |
239 | |
239 | # if ENABLE_COMBINING |
240 | # if ENABLE_COMBINING |
240 | if (alloc) |
241 | if (alloc) |
241 | delete [] alloc; |
242 | delete [] alloc; |
242 | # endif |
243 | # endif |
243 | #endif |
|
|
244 | } |
244 | } |
|
|
245 | #endif |
245 | |
246 | |
246 | void |
247 | void |
247 | rxvt_term::commit_iso14755 () |
248 | rxvt_term::commit_iso14755 () |
248 | { |
249 | { |
249 | wchar_t ch[2]; |
250 | wchar_t ch[2]; |
… | |
… | |
264 | mb[0] = ch[0]; |
265 | mb[0] = ch[0]; |
265 | len = 1; |
266 | len = 1; |
266 | } |
267 | } |
267 | |
268 | |
268 | if (len > 0) |
269 | if (len > 0) |
269 | tt_write ((unsigned char *)mb, len); |
270 | tt_write (mb, len); |
270 | else |
271 | else |
271 | scr_bell (); |
272 | scr_bell (); |
272 | } |
273 | } |
273 | |
274 | |
274 | iso14755buf = 0; |
275 | iso14755buf = 0; |
… | |
… | |
302 | KeySym keysym; |
303 | KeySym keysym; |
303 | #ifdef DEBUG_CMD |
304 | #ifdef DEBUG_CMD |
304 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | #endif |
306 | #endif |
306 | int valid_keysym; |
307 | int valid_keysym; |
307 | unsigned char kbuf[KBUFSZ]; |
308 | char kbuf[KBUFSZ]; |
308 | |
309 | |
309 | /* |
310 | /* |
310 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
311 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
311 | * escape sequence to toggle the Keypad. |
312 | * escape sequence to toggle the Keypad. |
312 | * |
313 | * |
… | |
… | |
330 | Status status_return; |
331 | Status status_return; |
331 | |
332 | |
332 | #if 0 |
333 | #if 0 |
333 | #ifdef X_HAVE_UTF8_STRING |
334 | #ifdef X_HAVE_UTF8_STRING |
334 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
335 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
335 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
336 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
336 | KBUFSZ, &keysym, &status_return); |
337 | KBUFSZ, &keysym, &status_return); |
337 | else |
338 | else |
338 | #endif |
339 | #endif |
339 | #endif |
340 | #endif |
340 | { |
341 | { |
… | |
… | |
377 | || status_return == XLookupBoth; |
378 | || status_return == XLookupBoth; |
378 | } |
379 | } |
379 | else |
380 | else |
380 | #endif |
381 | #endif |
381 | { |
382 | { |
382 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
383 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
383 | valid_keysym = keysym != NoSymbol; |
384 | valid_keysym = keysym != NoSymbol; |
384 | } |
385 | } |
385 | |
386 | |
386 | if (valid_keysym) |
387 | if (valid_keysym) |
387 | { |
388 | { |
… | |
… | |
439 | scr_move_to (0, 1); |
440 | scr_move_to (0, 1); |
440 | return; |
441 | return; |
441 | } |
442 | } |
442 | else if (keysym == XK_End) |
443 | else if (keysym == XK_End) |
443 | { |
444 | { |
444 | scr_move_to (1, 0); |
445 | scr_move_to (1, 1); |
445 | return; |
446 | return; |
446 | } |
447 | } |
447 | } |
448 | } |
448 | #endif |
449 | #endif |
449 | } |
450 | } |
… | |
… | |
460 | { |
461 | { |
461 | switch (keysym) |
462 | switch (keysym) |
462 | { |
463 | { |
463 | /* normal XTerm key bindings */ |
464 | /* normal XTerm key bindings */ |
464 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
465 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
465 | selection_request (ev.time, 0, 0); |
466 | selection_request (ev.time); |
466 | return; |
467 | return; |
467 | #if TODO |
468 | #if TODO |
468 | /* rxvt extras */ |
469 | /* rxvt extras */ |
469 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
470 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
470 | change_font (FONT_UP); |
471 | change_font (FONT_UP); |
… | |
… | |
851 | { |
852 | { |
852 | #ifdef META8_OPTION |
853 | #ifdef META8_OPTION |
853 | /* set 8-bit on */ |
854 | /* set 8-bit on */ |
854 | if (meta && (meta_char == 0x80)) |
855 | if (meta && (meta_char == 0x80)) |
855 | { |
856 | { |
856 | unsigned char *ch; |
857 | char *ch; |
857 | |
858 | |
858 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | *ch |= 0x80; |
860 | *ch |= 0x80; |
860 | |
861 | |
861 | meta = 0; |
862 | meta = 0; |
862 | } |
863 | } |
863 | #endif |
864 | #endif |
864 | /* nil */ ; |
865 | /* nil */ ; |
865 | } |
866 | } |
866 | } |
867 | } |
|
|
868 | |
|
|
869 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
870 | return; |
867 | |
871 | |
868 | if (len <= 0) |
872 | if (len <= 0) |
869 | return; /* not mapped */ |
873 | return; /* not mapped */ |
870 | |
874 | |
871 | if (OPTION (Opt_scrollTtyKeypress)) |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
894 | #ifdef META8_OPTION |
898 | #ifdef META8_OPTION |
895 | && meta_char == C0_ESC |
899 | && meta_char == C0_ESC |
896 | #endif |
900 | #endif |
897 | ) |
901 | ) |
898 | { |
902 | { |
899 | const unsigned char ch = C0_ESC; |
903 | const char ch = C0_ESC; |
900 | tt_write (&ch, 1); |
904 | tt_write (&ch, 1); |
901 | } |
905 | } |
902 | |
906 | |
903 | #if defined(DEBUG_CMD) |
907 | #if defined(DEBUG_CMD) |
904 | /* Display keyboard buffer contents */ |
908 | /* Display keyboard buffer contents */ |
… | |
… | |
912 | #endif /* DEBUG_CMD */ |
916 | #endif /* DEBUG_CMD */ |
913 | tt_write (kbuf, (unsigned int)len); |
917 | tt_write (kbuf, (unsigned int)len); |
914 | } |
918 | } |
915 | /*}}} */ |
919 | /*}}} */ |
916 | |
920 | |
917 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
921 | #if defined (KEYSYM_RESOURCE) |
918 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
919 | /* attempt to `write' count to the input buffer */ |
|
|
920 | unsigned int |
922 | unsigned int |
921 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
923 | rxvt_term::cmd_write (const char *str, unsigned int count) |
922 | { |
924 | { |
923 | unsigned int n, s; |
925 | unsigned int n, s; |
924 | |
926 | |
925 | n = cmdbuf_ptr - cmdbuf_base; |
927 | n = cmdbuf_ptr - cmdbuf_base; |
926 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
928 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
963 | } |
965 | } |
964 | #endif |
966 | #endif |
965 | |
967 | |
966 | if (want_refresh) |
968 | if (want_refresh) |
967 | { |
969 | { |
|
|
970 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
971 | { |
|
|
972 | int row = view_start; |
|
|
973 | int end_row = row + nrow; |
|
|
974 | |
|
|
975 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
976 | --row; |
|
|
977 | |
|
|
978 | do |
|
|
979 | { |
|
|
980 | int start_row = row; |
|
|
981 | line_t *l; |
|
|
982 | |
|
|
983 | do |
|
|
984 | { |
|
|
985 | l = &ROW (row++); |
|
|
986 | |
|
|
987 | if (!(l->f & LINE_FILTERED)) |
|
|
988 | { |
|
|
989 | // line not filtered, mark it as filtered |
|
|
990 | l->f |= LINE_FILTERED; |
|
|
991 | while (l->is_longer ()) |
|
|
992 | { |
|
|
993 | l = &ROW (row++); |
|
|
994 | l->f |= LINE_FILTERED; |
|
|
995 | } |
|
|
996 | |
|
|
997 | // and filter it |
|
|
998 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
999 | |
|
|
1000 | break; |
|
|
1001 | } |
|
|
1002 | } |
|
|
1003 | while (l->is_longer () && row < end_row); |
|
|
1004 | } |
|
|
1005 | while (row < end_row); |
|
|
1006 | } |
|
|
1007 | |
968 | scr_refresh (refresh_type); |
1008 | scr_refresh (); |
969 | scrollbar_show (1); |
1009 | scrollbar_show (1); |
970 | #ifdef USE_XIM |
1010 | #ifdef USE_XIM |
971 | IMSendSpot (); |
1011 | IMSendSpot (); |
972 | #endif |
1012 | #endif |
973 | } |
1013 | } |
… | |
… | |
976 | } |
1016 | } |
977 | |
1017 | |
978 | void |
1018 | void |
979 | rxvt_term::check_cb (check_watcher &w) |
1019 | rxvt_term::check_cb (check_watcher &w) |
980 | { |
1020 | { |
981 | SET_R (this); |
1021 | make_current (); |
982 | SET_LOCALE (locale); |
|
|
983 | |
1022 | |
984 | display->flush (); |
1023 | display->flush (); |
985 | |
1024 | |
986 | if (want_refresh && !flush_ev.active) |
1025 | if (want_refresh && !flush_ev.active) |
987 | flush_ev.start (NOW + 0.01); |
1026 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
988 | } |
1027 | } |
989 | |
1028 | |
990 | void |
1029 | void |
991 | rxvt_term::flush_cb (time_watcher &w) |
1030 | rxvt_term::flush_cb (time_watcher &w) |
992 | { |
1031 | { |
993 | SET_R (this); |
1032 | make_current (); |
994 | SET_LOCALE (locale); |
|
|
995 | |
1033 | |
996 | refresh_limit = 1; |
1034 | refresh_limit = 1; |
997 | refresh_count = 0; |
1035 | refresh_count = 0; |
998 | flush (); |
1036 | flush (); |
999 | } |
1037 | } |
… | |
… | |
1003 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1041 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1004 | { |
1042 | { |
1005 | hidden_cursor = !hidden_cursor; |
1043 | hidden_cursor = !hidden_cursor; |
1006 | want_refresh = 1; |
1044 | want_refresh = 1; |
1007 | |
1045 | |
1008 | w.start (w.at + BLINK_INTERVAL); |
1046 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1009 | } |
1047 | } |
1010 | #endif |
1048 | #endif |
1011 | |
1049 | |
1012 | #ifdef TEXT_BLINK |
1050 | #ifdef TEXT_BLINK |
1013 | void |
1051 | void |
… | |
… | |
1027 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1065 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1028 | { |
1066 | { |
1029 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1067 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1030 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1068 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1031 | { |
1069 | { |
1032 | refresh_type |= SMOOTH_REFRESH; |
|
|
1033 | want_refresh = 1; |
1070 | want_refresh = 1; |
1034 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1035 | } |
1072 | } |
1036 | } |
1073 | } |
1037 | #endif |
1074 | #endif |
… | |
… | |
1041 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1078 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1042 | { |
1079 | { |
1043 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1080 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1044 | { |
1081 | { |
1045 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1082 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1046 | refresh_type |= SMOOTH_REFRESH; |
|
|
1047 | want_refresh = 1; |
1083 | want_refresh = 1; |
1048 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1084 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1049 | } |
1085 | } |
1050 | } |
1086 | } |
1051 | #endif |
1087 | #endif |
… | |
… | |
1056 | { |
1092 | { |
1057 | if (mouse_slip_wheel_speed == 0 |
1093 | if (mouse_slip_wheel_speed == 0 |
1058 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1094 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1059 | : scr_page (UP, mouse_slip_wheel_speed)) |
1095 | : scr_page (UP, mouse_slip_wheel_speed)) |
1060 | { |
1096 | { |
1061 | if (view_start == nsaved || |
1097 | if (view_start == top_row || view_start == 0) |
1062 | view_start == 0) |
|
|
1063 | mouse_slip_wheel_speed = 0; |
1098 | mouse_slip_wheel_speed = 0; |
1064 | |
1099 | |
1065 | refresh_type |= SMOOTH_REFRESH; |
|
|
1066 | want_refresh = 1; |
1100 | want_refresh = 1; |
1067 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1101 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1068 | } |
1102 | } |
1069 | } |
1103 | } |
1070 | #endif |
1104 | #endif |
1071 | |
1105 | |
|
|
1106 | #if HAVE_SCHED_YIELD |
|
|
1107 | static struct event_handler |
|
|
1108 | { |
|
|
1109 | check_watcher cw_yield; |
|
|
1110 | |
|
|
1111 | void yield (check_watcher &w) |
|
|
1112 | { |
|
|
1113 | sched_yield (); |
|
|
1114 | w.stop (); |
|
|
1115 | } |
|
|
1116 | |
|
|
1117 | event_handler () |
|
|
1118 | : cw_yield (this, &event_handler::yield) |
|
|
1119 | { |
|
|
1120 | } |
|
|
1121 | } event_handler; |
|
|
1122 | #endif |
|
|
1123 | |
1072 | bool |
1124 | bool |
1073 | rxvt_term::pty_fill () |
1125 | rxvt_term::pty_fill () |
1074 | { |
1126 | { |
1075 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1127 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1076 | |
1128 | |
1077 | if (CBUFSIZ == n) |
1129 | if (CBUFSIZ == n) |
1078 | { |
1130 | { |
1079 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1131 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1080 | n = 0; |
1132 | n = 0; |
1081 | } |
1133 | } |
1082 | |
1134 | |
1083 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1135 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1084 | cmdbuf_ptr = cmdbuf_base; |
1136 | cmdbuf_ptr = cmdbuf_base; |
1085 | cmdbuf_endp = cmdbuf_ptr + n; |
1137 | cmdbuf_endp = cmdbuf_ptr + n; |
1086 | |
1138 | |
1087 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1139 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1088 | |
1140 | |
1089 | if (n > 0) |
1141 | if (r > 0) |
1090 | { |
1142 | { |
1091 | cmdbuf_endp += n; |
1143 | cmdbuf_endp += r; |
1092 | return true; |
1144 | return true; |
1093 | } |
1145 | } |
1094 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1146 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1147 | { |
|
|
1148 | #if HAVE_SCHED_YIELD |
|
|
1149 | if (display->is_local) |
|
|
1150 | event_handler.cw_yield.start (); |
|
|
1151 | #endif |
|
|
1152 | } |
|
|
1153 | else |
1095 | { |
1154 | { |
1096 | pty_ev.stop (); |
1155 | pty_ev.stop (); |
1097 | |
1156 | |
1098 | if (!OPTION (Opt_hold)) |
1157 | if (!OPTION (Opt_hold)) |
1099 | destroy (); |
1158 | destroy (); |
… | |
… | |
1103 | } |
1162 | } |
1104 | |
1163 | |
1105 | void |
1164 | void |
1106 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1165 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1107 | { |
1166 | { |
1108 | SET_R (this); |
1167 | make_current (); |
1109 | SET_LOCALE (locale); |
|
|
1110 | |
1168 | |
1111 | if (revents & EVENT_READ) |
1169 | if (revents & EVENT_READ) |
1112 | // loop, but don't allow a single term to monopolize us |
1170 | // loop, but don't allow a single term to monopolize us |
1113 | while (pty_fill ()) |
1171 | while (pty_fill ()) |
1114 | if (cmd_parse ()) |
1172 | if (cmd_parse ()) |
… | |
… | |
1134 | |
1192 | |
1135 | #ifdef POINTER_BLANK |
1193 | #ifdef POINTER_BLANK |
1136 | void |
1194 | void |
1137 | rxvt_term::pointer_blank () |
1195 | rxvt_term::pointer_blank () |
1138 | { |
1196 | { |
1139 | if (! OPTION (Opt_pointerBlank)) |
1197 | if (!OPTION (Opt_pointerBlank)) |
1140 | return; |
1198 | return; |
1141 | |
1199 | |
1142 | XDefineCursor (display->display, vt, display->blank_cursor); |
1200 | XDefineCursor (display->display, vt, display->blank_cursor); |
1143 | XFlush (display->display); |
1201 | XFlush (display->display); |
1144 | |
1202 | |
… | |
… | |
1146 | } |
1204 | } |
1147 | |
1205 | |
1148 | void |
1206 | void |
1149 | rxvt_term::pointer_cb (time_watcher &w) |
1207 | rxvt_term::pointer_cb (time_watcher &w) |
1150 | { |
1208 | { |
1151 | SET_R (this); |
1209 | make_current (); |
1152 | SET_LOCALE (locale); |
|
|
1153 | |
1210 | |
1154 | pointer_blank (); |
1211 | pointer_blank (); |
1155 | } |
1212 | } |
1156 | #endif |
1213 | #endif |
1157 | |
1214 | |
… | |
… | |
1236 | |
1293 | |
1237 | /*{{{ process an X event */ |
1294 | /*{{{ process an X event */ |
1238 | void |
1295 | void |
1239 | rxvt_term::x_cb (XEvent &ev) |
1296 | rxvt_term::x_cb (XEvent &ev) |
1240 | { |
1297 | { |
|
|
1298 | make_current (); |
|
|
1299 | |
1241 | dDisp; |
1300 | dDisp; |
1242 | |
1301 | |
1243 | SET_R (this); |
1302 | if (ev.xany.window == vt |
1244 | SET_LOCALE (locale); |
1303 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1304 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1305 | return; |
1245 | |
1306 | |
1246 | #if defined(CURSOR_BLINK) |
1307 | // for XQueryPointer |
1247 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1248 | { |
|
|
1249 | if (hidden_cursor) |
|
|
1250 | { |
|
|
1251 | hidden_cursor = 0; |
|
|
1252 | want_refresh = 1; |
|
|
1253 | } |
|
|
1254 | |
|
|
1255 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1256 | } |
|
|
1257 | #endif |
|
|
1258 | |
|
|
1259 | #if defined(POINTER_BLANK) |
|
|
1260 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1261 | { |
|
|
1262 | if (ev.type == MotionNotify |
|
|
1263 | || ev.type == ButtonPress |
|
|
1264 | || ev.type == ButtonRelease) |
|
|
1265 | if (hidden_pointer) |
|
|
1266 | pointer_unblank (); |
|
|
1267 | |
|
|
1268 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1269 | pointer_blank (); |
|
|
1270 | } |
|
|
1271 | #endif |
|
|
1272 | |
|
|
1273 | Window unused_root, unused_child; |
1308 | Window unused_root, unused_child; |
1274 | int unused_root_x, unused_root_y; |
1309 | int unused_root_x, unused_root_y; |
1275 | unsigned int unused_mask; |
1310 | unsigned int unused_mask; |
1276 | |
1311 | |
1277 | switch (ev.type) |
1312 | switch (ev.type) |
… | |
… | |
1284 | |
1319 | |
1285 | break; |
1320 | break; |
1286 | |
1321 | |
1287 | case KeyRelease: |
1322 | case KeyRelease: |
1288 | { |
1323 | { |
1289 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1324 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1290 | KeySym ks; |
1325 | KeySym keysym; |
1291 | |
1326 | |
1292 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1327 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1293 | #endif |
1328 | #endif |
1294 | |
1329 | |
1295 | #if ENABLE_FRILLS || ISO_14755 |
1330 | #if ENABLE_FRILLS || ISO_14755 |
1296 | // ISO 14755 support |
1331 | // ISO 14755 support |
1297 | if (iso14755buf) |
1332 | if (iso14755buf) |
… | |
… | |
1302 | # endif |
1337 | # endif |
1303 | # if ISO_14755 |
1338 | # if ISO_14755 |
1304 | // iso14755 part 5.2 handling: release time |
1339 | // iso14755 part 5.2 handling: release time |
1305 | // first: controls |
1340 | // first: controls |
1306 | if ((ev.xkey.state & ControlMask) |
1341 | if ((ev.xkey.state & ControlMask) |
1307 | && ((ks >= 0x40 && ks <= 0x5f) |
1342 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1308 | || (ks >= 0x61 && ks <= 0x7f))) |
1343 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1309 | { |
1344 | { |
1310 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1345 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1311 | commit_iso14755 (); |
1346 | commit_iso14755 (); |
1312 | return; // case-break; |
1347 | goto skip_switch; |
1313 | } |
1348 | } |
1314 | |
1349 | |
1315 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1350 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1316 | if (i[0] == ks) |
1351 | if (i[0] == keysym) |
1317 | { |
1352 | { |
1318 | iso14755buf = ISO_14755_51 | i[1]; |
1353 | iso14755buf = ISO_14755_51 | i[1]; |
1319 | commit_iso14755 (); |
1354 | commit_iso14755 (); |
1320 | return; // case-break; |
1355 | goto skip_switch; |
1321 | } |
1356 | } |
1322 | |
1357 | |
1323 | scr_bell (); |
1358 | scr_bell (); |
1324 | # endif |
1359 | # endif |
1325 | iso14755buf = 0; |
1360 | iso14755buf = 0; |
… | |
… | |
1344 | else |
1379 | else |
1345 | iso14755buf = 0; |
1380 | iso14755buf = 0; |
1346 | } |
1381 | } |
1347 | #endif |
1382 | #endif |
1348 | |
1383 | |
|
|
1384 | if (ev.xany.window == vt |
|
|
1385 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1386 | break; |
|
|
1387 | |
1349 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1388 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1350 | if (!(ev.xkey.state & ControlMask)) |
1389 | if (!(ev.xkey.state & ControlMask)) |
1351 | slip_wheel_ev.stop (); |
1390 | slip_wheel_ev.stop (); |
1352 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1391 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1353 | mouse_slip_wheel_speed = 0; |
1392 | mouse_slip_wheel_speed = 0; |
1354 | #endif |
1393 | #endif |
1355 | break; |
1394 | break; |
1356 | } |
1395 | } |
1357 | |
1396 | |
… | |
… | |
1363 | button_release (ev.xbutton); |
1402 | button_release (ev.xbutton); |
1364 | break; |
1403 | break; |
1365 | |
1404 | |
1366 | case ClientMessage: |
1405 | case ClientMessage: |
1367 | if (ev.xclient.format == 32 |
1406 | if (ev.xclient.format == 32 |
1368 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1407 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1369 | { |
1408 | { |
|
|
1409 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1410 | { |
|
|
1411 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1412 | { |
1370 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1413 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1414 | { |
|
|
1415 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1371 | destroy (); |
1416 | destroy (); |
|
|
1417 | } |
1372 | #if ENABLE_EWMH |
1418 | #if ENABLE_EWMH |
1373 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1419 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1374 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1375 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1376 | &ev); |
1422 | &ev); |
|
|
1423 | #endif |
|
|
1424 | } |
|
|
1425 | } |
|
|
1426 | #if ENABLE_XEMBED |
|
|
1427 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1428 | { |
|
|
1429 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1430 | focus_in (); |
|
|
1431 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1432 | focus_out (); |
|
|
1433 | } |
1377 | #endif |
1434 | #endif |
1378 | } |
1435 | } |
1379 | #if ENABLE_XEMBED |
|
|
1380 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1381 | { |
|
|
1382 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1383 | focus_in (); |
|
|
1384 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1385 | focus_out (); |
|
|
1386 | } |
|
|
1387 | #endif |
|
|
1388 | #ifdef OFFIX_DND |
|
|
1389 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1390 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1391 | && (ev.xclient.data.l[0] == DndFile |
|
|
1392 | || ev.xclient.data.l[0] == DndDir |
|
|
1393 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1394 | { |
|
|
1395 | /* Get Dnd data */ |
|
|
1396 | Atom ActualType; |
|
|
1397 | int ActualFormat; |
|
|
1398 | unsigned char *data; |
|
|
1399 | unsigned long Size, RemainingBytes; |
|
|
1400 | |
|
|
1401 | XGetWindowProperty (disp, display->root, |
|
|
1402 | xa[XA_DNDSELECTION], |
|
|
1403 | 0L, 1000000L, |
|
|
1404 | False, AnyPropertyType, |
|
|
1405 | &ActualType, &ActualFormat, |
|
|
1406 | &Size, &RemainingBytes, |
|
|
1407 | &data); |
|
|
1408 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1409 | XFree (data); |
|
|
1410 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1411 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1412 | } |
|
|
1413 | #endif /* OFFIX_DND */ |
|
|
1414 | break; |
1436 | break; |
1415 | |
1437 | |
1416 | case MappingNotify: |
1438 | case MappingNotify: |
1417 | XRefreshKeyboardMapping (&ev.xmapping); |
1439 | XRefreshKeyboardMapping (&ev.xmapping); |
1418 | break; |
1440 | break; |
… | |
… | |
1460 | { |
1482 | { |
1461 | seen_resize = 1; |
1483 | seen_resize = 1; |
1462 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1484 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1463 | } |
1485 | } |
1464 | |
1486 | |
|
|
1487 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1488 | |
1465 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1489 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1466 | if (OPTION (Opt_transparent)) |
1490 | if (OPTION (Opt_transparent)) |
1467 | check_our_parents (); |
1491 | check_our_parents (); |
1468 | #endif |
1492 | #endif |
1469 | } |
1493 | } |
1470 | break; |
1494 | break; |
1471 | |
1495 | |
1472 | case PropertyNotify: |
1496 | case PropertyNotify: |
|
|
1497 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1473 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1498 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1474 | && ev.xproperty.state == PropertyNewValue) |
1499 | && ev.xproperty.state == PropertyNewValue) |
1475 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1500 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1476 | |
1501 | |
1477 | break; |
1502 | break; |
1478 | |
1503 | |
1479 | case SelectionClear: |
1504 | case SelectionClear: |
1480 | selection_clear (); |
1505 | selection_clear (); |
… | |
… | |
1485 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1510 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1486 | break; |
1511 | break; |
1487 | |
1512 | |
1488 | case SelectionRequest: |
1513 | case SelectionRequest: |
1489 | selection_send (ev.xselectionrequest); |
1514 | selection_send (ev.xselectionrequest); |
|
|
1515 | break; |
|
|
1516 | |
|
|
1517 | case MapNotify: |
|
|
1518 | mapped = 1; |
|
|
1519 | #ifdef TEXT_BLINK |
|
|
1520 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1521 | #endif |
|
|
1522 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1490 | break; |
1523 | break; |
1491 | |
1524 | |
1492 | case UnmapNotify: |
1525 | case UnmapNotify: |
1493 | mapped = 0; |
1526 | mapped = 0; |
1494 | #ifdef TEXT_BLINK |
1527 | #ifdef TEXT_BLINK |
1495 | text_blink_ev.stop (); |
1528 | text_blink_ev.stop (); |
1496 | #endif |
1529 | #endif |
1497 | break; |
1530 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1498 | |
|
|
1499 | case MapNotify: |
|
|
1500 | mapped = 1; |
|
|
1501 | #ifdef TEXT_BLINK |
|
|
1502 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1503 | #endif |
|
|
1504 | break; |
1531 | break; |
1505 | |
1532 | |
1506 | #ifdef TRANSPARENT |
1533 | #ifdef TRANSPARENT |
1507 | case ReparentNotify: |
1534 | case ReparentNotify: |
1508 | rootwin_cb (ev); |
1535 | rootwin_cb (ev); |
… | |
… | |
1522 | |
1549 | |
1523 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1550 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1524 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1551 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1525 | ev.xexpose.width, ev.xexpose.height, False); |
1552 | ev.xexpose.width, ev.xexpose.height, False); |
1526 | |
1553 | |
1527 | scr_refresh (refresh_type); |
1554 | want_refresh = 1; |
1528 | } |
1555 | } |
1529 | else |
1556 | else |
1530 | { |
1557 | { |
1531 | XEvent unused_event; |
1558 | XEvent unused_event; |
1532 | |
1559 | |
… | |
… | |
1538 | if (isScrollbarWindow (ev.xany.window)) |
1565 | if (isScrollbarWindow (ev.xany.window)) |
1539 | { |
1566 | { |
1540 | scrollBar.setIdle (); |
1567 | scrollBar.setIdle (); |
1541 | scrollbar_show (0); |
1568 | scrollbar_show (0); |
1542 | } |
1569 | } |
1543 | #ifdef MENUBAR |
|
|
1544 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1545 | menubar_expose (); |
|
|
1546 | #endif |
|
|
1547 | |
1570 | |
1548 | #ifdef TRANSPARENT |
1571 | #ifdef TRANSPARENT |
1549 | if (am_transparent && ev.xany.window == parent[0]) |
1572 | if (am_transparent && ev.xany.window == parent[0]) |
1550 | XClearWindow (disp, ev.xany.window); |
1573 | XClearWindow (disp, ev.xany.window); |
1551 | #endif |
1574 | #endif |
… | |
… | |
1555 | case MotionNotify: |
1578 | case MotionNotify: |
1556 | #ifdef POINTER_BLANK |
1579 | #ifdef POINTER_BLANK |
1557 | if (hidden_pointer) |
1580 | if (hidden_pointer) |
1558 | pointer_unblank (); |
1581 | pointer_unblank (); |
1559 | #endif |
1582 | #endif |
1560 | #if MENUBAR |
|
|
1561 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1562 | { |
|
|
1563 | menubar_control (ev.xbutton); |
|
|
1564 | break; |
|
|
1565 | } |
|
|
1566 | #endif |
|
|
1567 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1583 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1584 | break; |
1569 | |
1585 | |
1570 | if (ev.xany.window == vt) |
1586 | if (ev.xany.window == vt) |
1571 | { |
1587 | { |
|
|
1588 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1589 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1590 | ; // nop |
1572 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1591 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1573 | { |
1592 | { |
1574 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1593 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1575 | ; |
1594 | ; |
1576 | |
1595 | |
1577 | XQueryPointer (disp, vt, |
1596 | XQueryPointer (disp, vt, |
… | |
… | |
1657 | &unused_root_x, &unused_root_y, |
1676 | &unused_root_x, &unused_root_y, |
1658 | &ev.xbutton.x, &ev.xbutton.y, |
1677 | &ev.xbutton.x, &ev.xbutton.y, |
1659 | &unused_mask); |
1678 | &unused_mask); |
1660 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1679 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1661 | scrollbar_size ()); |
1680 | scrollbar_size ()); |
1662 | scr_refresh (refresh_type); |
1681 | want_refresh = 1; |
1663 | refresh_limit = 0; |
1682 | refresh_limit = 0; |
1664 | scrollbar_show (1); |
1683 | scrollbar_show (1); |
1665 | } |
1684 | } |
1666 | break; |
1685 | break; |
1667 | } |
1686 | } |
|
|
1687 | |
|
|
1688 | skip_switch: ; |
|
|
1689 | |
|
|
1690 | #if defined(CURSOR_BLINK) |
|
|
1691 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1692 | { |
|
|
1693 | if (hidden_cursor) |
|
|
1694 | { |
|
|
1695 | hidden_cursor = 0; |
|
|
1696 | want_refresh = 1; |
|
|
1697 | } |
|
|
1698 | |
|
|
1699 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1700 | } |
|
|
1701 | #endif |
|
|
1702 | |
|
|
1703 | #if defined(POINTER_BLANK) |
|
|
1704 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1705 | { |
|
|
1706 | if (ev.type == MotionNotify |
|
|
1707 | || ev.type == ButtonPress |
|
|
1708 | || ev.type == ButtonRelease) |
|
|
1709 | if (hidden_pointer) |
|
|
1710 | pointer_unblank (); |
|
|
1711 | |
|
|
1712 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1713 | pointer_blank (); |
|
|
1714 | } |
|
|
1715 | #endif |
1668 | } |
1716 | } |
1669 | |
1717 | |
1670 | void |
1718 | void |
1671 | rxvt_term::focus_in () |
1719 | rxvt_term::focus_in () |
1672 | { |
1720 | { |
1673 | if (!focus) |
1721 | if (!focus) |
1674 | { |
1722 | { |
1675 | focus = 1; |
1723 | focus = 1; |
1676 | want_refresh = 1; |
1724 | want_refresh = 1; |
|
|
1725 | |
|
|
1726 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1727 | |
1677 | #if USE_XIM |
1728 | #if USE_XIM |
1678 | if (Input_Context != NULL) |
1729 | if (Input_Context != NULL) |
1679 | { |
1730 | { |
1680 | IMSetStatusPosition (); |
1731 | IMSetStatusPosition (); |
1681 | XSetICFocus (Input_Context); |
1732 | XSetICFocus (Input_Context); |
1682 | } |
1733 | } |
1683 | #endif |
1734 | #endif |
1684 | #if CURSOR_BLINK |
1735 | #if CURSOR_BLINK |
1685 | if (OPTION (Opt_cursorBlink)) |
1736 | if (OPTION (Opt_cursorBlink)) |
1686 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1737 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1687 | #endif |
1738 | #endif |
1688 | #if OFF_FOCUS_FADING |
1739 | #if OFF_FOCUS_FADING |
1689 | if (rs[Rs_fade]) |
1740 | if (rs[Rs_fade]) |
1690 | { |
1741 | { |
1691 | pix_colors = pix_colors_focused; |
1742 | pix_colors = pix_colors_focused; |
… | |
… | |
1701 | if (focus) |
1752 | if (focus) |
1702 | { |
1753 | { |
1703 | focus = 0; |
1754 | focus = 0; |
1704 | want_refresh = 1; |
1755 | want_refresh = 1; |
1705 | |
1756 | |
|
|
1757 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1758 | |
1706 | #if ENABLE_FRILLS || ISO_14755 |
1759 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1760 | if (iso14755buf) |
|
|
1761 | { |
1707 | iso14755buf = 0; |
1762 | iso14755buf = 0; |
1708 | #endif |
|
|
1709 | #if ENABLE_OVERLAY |
1763 | # if ENABLE_OVERLAY |
1710 | scr_overlay_off (); |
1764 | scr_overlay_off (); |
|
|
1765 | # endif |
|
|
1766 | } |
1711 | #endif |
1767 | #endif |
1712 | #if USE_XIM |
1768 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1769 | if (Input_Context != NULL) |
1714 | XUnsetICFocus (Input_Context); |
1770 | XUnsetICFocus (Input_Context); |
1715 | #endif |
1771 | #endif |
… | |
… | |
1730 | |
1786 | |
1731 | #if TRANSPARENT |
1787 | #if TRANSPARENT |
1732 | void |
1788 | void |
1733 | rxvt_term::rootwin_cb (XEvent &ev) |
1789 | rxvt_term::rootwin_cb (XEvent &ev) |
1734 | { |
1790 | { |
1735 | SET_R (this); |
1791 | make_current (); |
1736 | SET_LOCALE (locale); |
|
|
1737 | |
1792 | |
1738 | switch (ev.type) |
1793 | switch (ev.type) |
1739 | { |
1794 | { |
1740 | case PropertyNotify: |
1795 | case PropertyNotify: |
1741 | /* |
1796 | /* |
… | |
… | |
1759 | rxvt_term::button_press (XButtonEvent &ev) |
1814 | rxvt_term::button_press (XButtonEvent &ev) |
1760 | { |
1815 | { |
1761 | int reportmode = 0, clickintime; |
1816 | int reportmode = 0, clickintime; |
1762 | |
1817 | |
1763 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1818 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1819 | |
1764 | if (!bypass_keystate) |
1820 | if (!bypass_keystate) |
1765 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1821 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1766 | |
1822 | |
1767 | /* |
1823 | /* |
1768 | * VT window processing of button press |
1824 | * VT window processing of button press |
… | |
… | |
1788 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1844 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1789 | if (ev.button == MEvent.button && clickintime) |
1845 | if (ev.button == MEvent.button && clickintime) |
1790 | { |
1846 | { |
1791 | /* same button, within alloted time */ |
1847 | /* same button, within alloted time */ |
1792 | MEvent.clicks++; |
1848 | MEvent.clicks++; |
|
|
1849 | |
1793 | if (MEvent.clicks > 1) |
1850 | if (MEvent.clicks > 1) |
1794 | { |
1851 | { |
1795 | /* only report double clicks */ |
1852 | /* only report double clicks */ |
1796 | MEvent.clicks = 2; |
1853 | MEvent.clicks = 2; |
1797 | mouse_report (ev); |
1854 | mouse_report (ev); |
… | |
… | |
1817 | else |
1874 | else |
1818 | { |
1875 | { |
1819 | if (ev.button != MEvent.button) |
1876 | if (ev.button != MEvent.button) |
1820 | MEvent.clicks = 0; |
1877 | MEvent.clicks = 0; |
1821 | |
1878 | |
|
|
1879 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
1822 | switch (ev.button) |
1880 | switch (ev.button) |
1823 | { |
1881 | { |
1824 | case Button1: |
1882 | case Button1: |
1825 | /* allow meta + click to select rectangular areas */ |
1883 | /* allow meta + click to select rectangular areas */ |
1826 | /* should be done in screen.C */ |
1884 | /* should be done in screen.C */ |
1827 | #if ENABLE_FRILLS |
1885 | #if ENABLE_FRILLS |
1828 | selection.rect = !!(ev.state & ModMetaMask); |
1886 | selection.rect = !!(ev.state & ModMetaMask); |
1829 | #else |
1887 | #else |
1830 | selection.rect = false; |
1888 | selection.rect = false; |
1831 | #endif |
1889 | #endif |
1832 | |
1890 | |
1833 | /* allow shift+left click to extend selection */ |
1891 | /* allow shift+left click to extend selection */ |
1834 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1892 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1835 | { |
1893 | { |
1836 | if (MEvent.button == Button1 && clickintime) |
1894 | if (MEvent.button == Button1 && clickintime) |
1837 | selection_rotate (ev.x, ev.y); |
1895 | selection_rotate (ev.x, ev.y); |
1838 | else |
1896 | else |
1839 | selection_extend (ev.x, ev.y, 1); |
1897 | selection_extend (ev.x, ev.y, 1); |
1840 | } |
1898 | } |
1841 | else |
1899 | else |
1842 | { |
1900 | { |
1843 | if (MEvent.button == Button1 && clickintime) |
1901 | if (MEvent.button == Button1 && clickintime) |
1844 | MEvent.clicks++; |
1902 | MEvent.clicks++; |
1845 | else |
1903 | else |
1846 | MEvent.clicks = 1; |
1904 | MEvent.clicks = 1; |
1847 | |
1905 | |
1848 | selection_click (MEvent.clicks, ev.x, ev.y); |
1906 | selection_click (MEvent.clicks, ev.x, ev.y); |
1849 | } |
1907 | } |
1850 | |
1908 | |
1851 | MEvent.button = Button1; |
1909 | MEvent.button = Button1; |
1852 | break; |
1910 | break; |
1853 | |
1911 | |
1854 | case Button3: |
1912 | case Button3: |
1855 | if (MEvent.button == Button3 && clickintime) |
1913 | if (MEvent.button == Button3 && clickintime) |
1856 | selection_rotate (ev.x, ev.y); |
1914 | selection_rotate (ev.x, ev.y); |
1857 | else |
1915 | else |
1858 | selection_extend (ev.x, ev.y, 1); |
1916 | selection_extend (ev.x, ev.y, 1); |
1859 | |
1917 | |
1860 | MEvent.button = Button3; |
1918 | MEvent.button = Button3; |
1861 | break; |
1919 | break; |
1862 | } |
1920 | } |
1863 | } |
1921 | } |
1864 | |
1922 | |
1865 | MEvent.time = ev.time; |
1923 | MEvent.time = ev.time; |
1866 | return; |
1924 | return; |
1867 | } |
1925 | } |
1868 | |
1926 | |
… | |
… | |
2004 | } |
2062 | } |
2005 | |
2063 | |
2006 | break; |
2064 | break; |
2007 | } |
2065 | } |
2008 | } |
2066 | } |
|
|
2067 | |
2009 | return; |
2068 | return; |
2010 | } |
2069 | } |
2011 | #if MENUBAR |
|
|
2012 | /* |
|
|
2013 | * Menubar window processing of button press |
|
|
2014 | */ |
|
|
2015 | if (isMenuBarWindow (ev.window)) |
|
|
2016 | menubar_control (ev); |
|
|
2017 | #endif |
|
|
2018 | } |
2070 | } |
2019 | |
2071 | |
2020 | void |
2072 | void |
2021 | rxvt_term::button_release (XButtonEvent &ev) |
2073 | rxvt_term::button_release (XButtonEvent &ev) |
2022 | { |
2074 | { |
… | |
… | |
2028 | |
2080 | |
2029 | if (scrollbar_isUpDn ()) |
2081 | if (scrollbar_isUpDn ()) |
2030 | { |
2082 | { |
2031 | scrollBar.setIdle (); |
2083 | scrollBar.setIdle (); |
2032 | scrollbar_show (0); |
2084 | scrollbar_show (0); |
2033 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2034 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2035 | #endif |
|
|
2036 | } |
2085 | } |
2037 | |
2086 | |
2038 | #ifdef SELECTION_SCROLLING |
2087 | #ifdef SELECTION_SCROLLING |
2039 | if (sel_scroll_ev.active) |
2088 | if (sel_scroll_ev.active) |
2040 | sel_scroll_ev.stop(); |
2089 | sel_scroll_ev.stop(); |
… | |
… | |
2078 | if (priv_modes & PrivMode_mouse_report |
2127 | if (priv_modes & PrivMode_mouse_report |
2079 | && bypass_keystate |
2128 | && bypass_keystate |
2080 | && ev.button == Button1 && MEvent.clicks <= 1) |
2129 | && ev.button == Button1 && MEvent.clicks <= 1) |
2081 | selection_extend (ev.x, ev.y, 0); |
2130 | selection_extend (ev.x, ev.y, 0); |
2082 | |
2131 | |
|
|
2132 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2133 | return; |
|
|
2134 | |
2083 | switch (ev.button) |
2135 | switch (ev.button) |
2084 | { |
2136 | { |
2085 | case Button1: |
2137 | case Button1: |
2086 | case Button3: |
2138 | case Button3: |
2087 | selection_make (ev.time); |
2139 | selection_make (ev.time); |
2088 | break; |
2140 | break; |
|
|
2141 | |
2089 | case Button2: |
2142 | case Button2: |
2090 | selection_request (ev.time, ev.x, ev.y); |
2143 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2144 | selection_request (ev.time, ev.state & ShiftMask ? Sel_Clipboard : Sel_Primary); |
2091 | break; |
2145 | break; |
|
|
2146 | |
2092 | #ifdef MOUSE_WHEEL |
2147 | #ifdef MOUSE_WHEEL |
2093 | case Button4: |
2148 | case Button4: |
2094 | case Button5: |
2149 | case Button5: |
2095 | { |
2150 | { |
2096 | int i; |
2151 | int i; |
… | |
… | |
2118 | slip_wheel_ev.start (); |
2173 | slip_wheel_ev.start (); |
2119 | } |
2174 | } |
2120 | else |
2175 | else |
2121 | { |
2176 | { |
2122 | # endif |
2177 | # endif |
2123 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2124 | scr_page (v, i); |
2178 | scr_page (v, i); |
2125 | scr_refresh (SMOOTH_REFRESH); |
|
|
2126 | scrollbar_show (1); |
2179 | scrollbar_show (1); |
2127 | # else |
|
|
2128 | while (i--) |
|
|
2129 | { |
|
|
2130 | scr_page (v, 1); |
|
|
2131 | scr_refresh (SMOOTH_REFRESH); |
|
|
2132 | scrollbar_show (1); |
|
|
2133 | } |
|
|
2134 | # endif |
|
|
2135 | # ifdef MOUSE_SLIP_WHEELING |
2180 | # ifdef MOUSE_SLIP_WHEELING |
2136 | } |
2181 | } |
2137 | #endif |
2182 | # endif |
2138 | } |
2183 | } |
2139 | break; |
2184 | break; |
2140 | #endif |
2185 | #endif |
2141 | } |
2186 | } |
2142 | } |
2187 | } |
2143 | #ifdef MENUBAR |
|
|
2144 | else if (isMenuBarWindow (ev.window)) |
|
|
2145 | menubar_control (ev); |
|
|
2146 | #endif |
|
|
2147 | } |
2188 | } |
2148 | |
2189 | |
2149 | #ifdef TRANSPARENT |
2190 | #ifdef TRANSPARENT |
2150 | #if TINTING |
2191 | #if TINTING |
2151 | /* taken from aterm-0.4.2 */ |
2192 | /* taken from aterm-0.4.2 */ |
… | |
… | |
2631 | |
2672 | |
2632 | bool |
2673 | bool |
2633 | rxvt_term::cmd_parse () |
2674 | rxvt_term::cmd_parse () |
2634 | { |
2675 | { |
2635 | bool flag = false; |
2676 | bool flag = false; |
2636 | unicode_t ch = NOCHAR; |
2677 | wchar_t ch = NOCHAR; |
2637 | unsigned char *seq_begin; // remember start of esc-sequence here |
2678 | char *seq_begin; // remember start of esc-sequence here |
2638 | |
2679 | |
2639 | for (;;) |
2680 | for (;;) |
2640 | { |
2681 | { |
2641 | if (ch == NOCHAR) |
2682 | if (ch == NOCHAR) |
2642 | { |
2683 | { |
2643 | seq_begin = cmdbuf_ptr; |
2684 | seq_begin = cmdbuf_ptr; |
2644 | ch = next_char (); |
2685 | ch = next_char (); |
2645 | } |
|
|
2646 | |
2686 | |
2647 | if (ch == NOCHAR) // TODO: improve |
2687 | if (ch == NOCHAR) |
2648 | break; |
2688 | break; |
|
|
2689 | } |
2649 | |
2690 | |
2650 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2691 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2651 | { |
2692 | { |
2652 | if (!seen_input) |
2693 | if (!seen_input) |
2653 | { |
2694 | { |
… | |
… | |
2662 | if (seen_resize && cmd_pid) |
2703 | if (seen_resize && cmd_pid) |
2663 | kill (-cmd_pid, SIGWINCH); |
2704 | kill (-cmd_pid, SIGWINCH); |
2664 | } |
2705 | } |
2665 | |
2706 | |
2666 | /* Read a text string from the input buffer */ |
2707 | /* Read a text string from the input buffer */ |
2667 | unicode_t buf[UBUFSIZ]; |
2708 | wchar_t buf[UBUFSIZ]; |
2668 | bool refreshnow = false; |
2709 | bool refreshnow = false; |
2669 | int nlines = 0; |
2710 | int nlines = 0; |
2670 | unicode_t *str = buf; |
2711 | wchar_t *str = buf; |
2671 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2712 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2672 | |
2713 | |
2673 | for (;;) |
2714 | for (;;) |
2674 | { |
2715 | { |
2675 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2716 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2676 | break; |
2717 | break; |
… | |
… | |
2686 | |
2727 | |
2687 | if (!OPTION (Opt_jumpScroll) |
2728 | if (!OPTION (Opt_jumpScroll) |
2688 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2729 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2689 | { |
2730 | { |
2690 | refreshnow = true; |
2731 | refreshnow = true; |
|
|
2732 | refresh_count = 0; |
2691 | ch = NOCHAR; |
2733 | ch = NOCHAR; |
2692 | break; |
2734 | break; |
2693 | } |
2735 | } |
2694 | |
2736 | |
2695 | // scr_add_lines only works for nlines <= nrow - 1. |
2737 | // scr_add_lines only works for nlines <= nrow - 1. |
2696 | if (nlines >= nrow - 1) |
2738 | if (nlines >= nrow - 1) |
2697 | { |
2739 | { |
|
|
2740 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2741 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2698 | scr_add_lines (buf, nlines, str - buf); |
2742 | scr_add_lines (buf, str - buf, nlines); |
|
|
2743 | |
2699 | nlines = 0; |
2744 | nlines = 0; |
2700 | str = buf; |
2745 | str = buf; |
2701 | eol = str + min (ncol, UBUFSIZ); |
2746 | eol = str + min (ncol, UBUFSIZ); |
2702 | } |
2747 | } |
2703 | |
2748 | |
… | |
… | |
2716 | |
2761 | |
2717 | seq_begin = cmdbuf_ptr; |
2762 | seq_begin = cmdbuf_ptr; |
2718 | ch = next_char (); |
2763 | ch = next_char (); |
2719 | } |
2764 | } |
2720 | |
2765 | |
|
|
2766 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2767 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2721 | scr_add_lines (buf, nlines, str - buf); |
2768 | scr_add_lines (buf, str - buf, nlines); |
2722 | |
2769 | |
2723 | /* |
2770 | /* |
2724 | * If there have been a lot of new lines, then update the screen |
2771 | * If there have been a lot of new lines, then update the screen |
2725 | * What the heck I'll cheat and only refresh less than every page-full. |
2772 | * What the heck I'll cheat and only refresh less than every page-full. |
2726 | * the number of pages between refreshes is refresh_limit, which |
2773 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2731 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2778 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2732 | refresh_limit++; |
2779 | refresh_limit++; |
2733 | else |
2780 | else |
2734 | { |
2781 | { |
2735 | flag = true; |
2782 | flag = true; |
2736 | scr_refresh (refresh_type); |
2783 | scr_refresh (); |
|
|
2784 | want_refresh = 1; |
2737 | } |
2785 | } |
2738 | } |
2786 | } |
2739 | |
2787 | |
2740 | } |
2788 | } |
2741 | else |
2789 | else |
… | |
… | |
2756 | } |
2804 | } |
2757 | |
2805 | |
2758 | return flag; |
2806 | return flag; |
2759 | } |
2807 | } |
2760 | |
2808 | |
2761 | // read the next octet |
|
|
2762 | unicode_t |
|
|
2763 | rxvt_term::next_octet () |
|
|
2764 | { |
|
|
2765 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2766 | ? *cmdbuf_ptr++ |
|
|
2767 | : NOCHAR; |
|
|
2768 | } |
|
|
2769 | |
|
|
2770 | // read the next character |
2809 | // read the next character |
2771 | unicode_t |
2810 | wchar_t |
2772 | rxvt_term::next_char () |
2811 | rxvt_term::next_char () NOTHROW |
2773 | { |
2812 | { |
2774 | while (cmdbuf_ptr < cmdbuf_endp) |
2813 | while (cmdbuf_ptr < cmdbuf_endp) |
2775 | { |
2814 | { |
2776 | // assume 7-bit to be ascii ALWAYS |
2815 | // assume 7-bit to be ascii ALWAYS |
2777 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2816 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2778 | return *cmdbuf_ptr++; |
2817 | return *cmdbuf_ptr++; |
2779 | |
2818 | |
2780 | wchar_t wc; |
2819 | wchar_t wc; |
2781 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2820 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2782 | |
2821 | |
2783 | if (len == (size_t)-2) |
2822 | if (len == (size_t)-2) |
2784 | { |
2823 | { |
2785 | // the mbstate stores incomplete sequences. didn't know this :/ |
2824 | // the mbstate stores incomplete sequences. didn't know this :/ |
2786 | cmdbuf_ptr = cmdbuf_endp; |
2825 | cmdbuf_ptr = cmdbuf_endp; |
2787 | break; |
2826 | break; |
2788 | } |
2827 | } |
2789 | |
2828 | |
2790 | if (len == (size_t)-1) |
2829 | if (len == (size_t)-1) |
2791 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2830 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2792 | |
2831 | |
2793 | // assume wchar == unicode |
2832 | // assume wchar == unicode |
2794 | cmdbuf_ptr += len; |
2833 | cmdbuf_ptr += len; |
2795 | return wc & UNICODE_MASK; |
2834 | return wc & UNICODE_MASK; |
2796 | } |
2835 | } |
2797 | |
2836 | |
2798 | return NOCHAR; |
2837 | return NOCHAR; |
2799 | } |
2838 | } |
|
|
2839 | |
|
|
2840 | // read the next octet |
|
|
2841 | uint32_t |
|
|
2842 | rxvt_term::next_octet () NOTHROW |
|
|
2843 | { |
|
|
2844 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2845 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2846 | : NOCHAR; |
|
|
2847 | } |
|
|
2848 | |
|
|
2849 | static class out_of_input out_of_input; |
2800 | |
2850 | |
2801 | /* rxvt_cmd_getc () - Return next input character */ |
2851 | /* rxvt_cmd_getc () - Return next input character */ |
2802 | /* |
2852 | /* |
2803 | * Return the next input character after first passing any keyboard input |
2853 | * Return the next input character after first passing any keyboard input |
2804 | * to the command. |
2854 | * to the command. |
2805 | */ |
2855 | */ |
2806 | unicode_t |
2856 | wchar_t |
2807 | rxvt_term::cmd_getc () |
2857 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2808 | { |
2858 | { |
2809 | unicode_t c = next_char (); |
2859 | wchar_t c = next_char (); |
2810 | |
2860 | |
2811 | if (c == NOCHAR) |
2861 | if (c == NOCHAR) |
2812 | throw out_of_input; |
2862 | throw out_of_input; |
2813 | |
2863 | |
2814 | return c; |
2864 | return c; |
2815 | } |
2865 | } |
2816 | |
2866 | |
2817 | unicode_t |
2867 | uint32_t |
2818 | rxvt_term::cmd_get8 () |
2868 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2819 | { |
2869 | { |
2820 | unicode_t c = next_octet (); |
2870 | uint32_t c = next_octet (); |
2821 | |
2871 | |
2822 | if (c == NOCHAR) |
2872 | if (c == NOCHAR) |
2823 | throw out_of_input; |
2873 | throw out_of_input; |
2824 | |
2874 | |
2825 | return c; |
2875 | return c; |
… | |
… | |
2925 | case C0_ESC: |
2975 | case C0_ESC: |
2926 | process_escape_seq (); |
2976 | process_escape_seq (); |
2927 | break; |
2977 | break; |
2928 | case C0_ENQ: /* terminal Status */ |
2978 | case C0_ENQ: /* terminal Status */ |
2929 | if (rs[Rs_answerbackstring]) |
2979 | if (rs[Rs_answerbackstring]) |
2930 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2980 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2931 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2932 | else |
2981 | else |
2933 | tt_write ((unsigned char *)VT100_ANS, |
2982 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2934 | (unsigned int)strlen (VT100_ANS)); |
|
|
2935 | break; |
2983 | break; |
2936 | case C0_BEL: /* bell */ |
2984 | case C0_BEL: /* bell */ |
2937 | scr_bell (); |
2985 | scr_bell (); |
2938 | break; |
2986 | break; |
2939 | case C0_BS: /* backspace */ |
2987 | case C0_BS: /* backspace */ |
… | |
… | |
3094 | break; |
3142 | break; |
3095 | |
3143 | |
3096 | /* 8.3.87: NEXT LINE */ |
3144 | /* 8.3.87: NEXT LINE */ |
3097 | case C1_NEL: /* ESC E */ |
3145 | case C1_NEL: /* ESC E */ |
3098 | { |
3146 | { |
3099 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3147 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3100 | scr_add_lines (nlcr, 1, 2); |
3148 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3101 | } |
3149 | } |
3102 | break; |
3150 | break; |
3103 | |
3151 | |
3104 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3152 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3105 | case C1_ESA: /* ESC G */ |
3153 | case C1_ESA: /* ESC G */ |
… | |
… | |
3127 | process_dcs_seq (); |
3175 | process_dcs_seq (); |
3128 | break; |
3176 | break; |
3129 | |
3177 | |
3130 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3178 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3131 | case C1_SCI: /* ESC Z */ |
3179 | case C1_SCI: /* ESC Z */ |
3132 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3180 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3133 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3134 | break; /* steal obsolete ESC [ c */ |
3181 | break; /* steal obsolete ESC [ c */ |
3135 | |
3182 | |
3136 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3183 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3137 | case C1_CSI: /* ESC [ */ |
3184 | case C1_CSI: /* ESC [ */ |
3138 | process_csi_seq (); |
3185 | process_csi_seq (); |
… | |
… | |
3382 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3429 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3383 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3430 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3384 | break; |
3431 | break; |
3385 | |
3432 | |
3386 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3433 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3387 | tt_write ((const unsigned char *)VT100_ANS, |
3434 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3388 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3389 | break; |
3435 | break; |
3390 | |
3436 | |
3391 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3437 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3392 | process_sgr_mode (nargs, arg); |
3438 | process_sgr_mode (nargs, arg); |
3393 | break; |
3439 | break; |
… | |
… | |
3595 | /*----------------------------------------------------------------------*/ |
3641 | /*----------------------------------------------------------------------*/ |
3596 | /* |
3642 | /* |
3597 | * get input up until STRING TERMINATOR (or BEL) |
3643 | * get input up until STRING TERMINATOR (or BEL) |
3598 | * ends_how is terminator used. returned input must be free()'d |
3644 | * ends_how is terminator used. returned input must be free()'d |
3599 | */ |
3645 | */ |
3600 | unsigned char * |
3646 | char * |
3601 | rxvt_term::get_to_st (unicode_t &ends_how) |
3647 | rxvt_term::get_to_st (unicode_t &ends_how) |
3602 | { |
3648 | { |
3603 | unicode_t ch; |
3649 | unicode_t ch; |
3604 | bool seen_esc = false; |
3650 | bool seen_esc = false; |
3605 | unsigned int n = 0; |
3651 | unsigned int n = 0; |
… | |
… | |
3638 | |
3684 | |
3639 | string[n++] = '\0'; |
3685 | string[n++] = '\0'; |
3640 | |
3686 | |
3641 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3687 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3642 | |
3688 | |
3643 | return (unsigned char *)rxvt_wcstombs (string); |
3689 | return rxvt_wcstombs (string); |
3644 | } |
3690 | } |
3645 | |
3691 | |
3646 | /*----------------------------------------------------------------------*/ |
3692 | /*----------------------------------------------------------------------*/ |
3647 | /* |
3693 | /* |
3648 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3694 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3649 | */ |
3695 | */ |
3650 | void |
3696 | void |
3651 | rxvt_term::process_dcs_seq () |
3697 | rxvt_term::process_dcs_seq () |
3652 | { |
3698 | { |
3653 | unsigned char *s; |
3699 | char *s; |
3654 | unicode_t eh; |
3700 | unicode_t eh; |
3655 | |
3701 | |
3656 | /* |
3702 | /* |
3657 | * Not handled yet |
3703 | * Not handled yet |
3658 | */ |
3704 | */ |
… | |
… | |
3677 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3723 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3678 | arg = arg * 10 + (ch - '0'); |
3724 | arg = arg * 10 + (ch - '0'); |
3679 | |
3725 | |
3680 | if (ch == ';') |
3726 | if (ch == ';') |
3681 | { |
3727 | { |
3682 | unsigned char *s = get_to_st (eh); |
3728 | char *s = get_to_st (eh); |
3683 | |
3729 | |
3684 | if (s) |
3730 | if (s) |
3685 | { |
3731 | { |
3686 | process_xterm_seq (arg, (char *)s, eh); |
3732 | process_xterm_seq (arg, s, eh); |
3687 | free (s); |
3733 | free (s); |
3688 | } |
3734 | } |
3689 | } |
3735 | } |
3690 | } |
3736 | } |
3691 | |
3737 | |
3692 | void |
3738 | void |
3693 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3739 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3694 | { |
3740 | { |
3695 | if (str[0] == '?' && !str[1]) |
3741 | if (str[0] == '?' && !str[1]) |
3696 | { |
3742 | { |
3697 | unsigned short r, g, b; |
3743 | unsigned short r, g, b; |
3698 | pix_colors_focused[color].get (display, r, g, b); |
3744 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3704 | |
3750 | |
3705 | /* |
3751 | /* |
3706 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3752 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3707 | */ |
3753 | */ |
3708 | void |
3754 | void |
3709 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3755 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3710 | { |
3756 | { |
3711 | int changed = 0; |
|
|
3712 | int color; |
3757 | int color; |
3713 | char *buf, *name; |
3758 | char *buf, *name; |
3714 | bool query = str[0] == '?' && !str[1]; |
3759 | bool query = str[0] == '?' && !str[1]; |
3715 | int saveop = op; |
3760 | int saveop = op; |
3716 | dDisp; |
3761 | dDisp; |
… | |
… | |
3771 | { |
3816 | { |
3772 | if ((name = strchr (buf, ';')) == NULL) |
3817 | if ((name = strchr (buf, ';')) == NULL) |
3773 | break; |
3818 | break; |
3774 | |
3819 | |
3775 | *name++ = '\0'; |
3820 | *name++ = '\0'; |
3776 | color = atoi (buf); |
3821 | color = atoi (buf) + minCOLOR; |
3777 | |
3822 | |
3778 | if (color < 0 || color >= TOTAL_COLORS) |
3823 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3779 | break; |
3824 | break; |
3780 | |
3825 | |
3781 | if ((buf = strchr (name, ';')) != NULL) |
3826 | if ((buf = strchr (name, ';')) != NULL) |
3782 | *buf++ = '\0'; |
3827 | *buf++ = '\0'; |
3783 | |
3828 | |
3784 | if (name[0] == '?' && !name[1]) |
3829 | if (name[0] == '?' && !name[1]) |
3785 | { |
3830 | { |
3786 | unsigned short r, g, b; |
3831 | unsigned short r, g, b; |
3787 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3832 | pix_colors_focused[color].get (display, r, g, b); |
3788 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3833 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3789 | } |
3834 | } |
3790 | else |
3835 | else |
3791 | set_window_color (color + minCOLOR, name); |
3836 | set_window_color (color, name); |
3792 | } |
3837 | } |
3793 | break; |
3838 | break; |
3794 | case XTerm_Color00: |
3839 | case XTerm_Color00: |
3795 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3840 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3796 | break; |
3841 | break; |
3797 | case XTerm_Color01: |
3842 | case XTerm_Color01: |
3798 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3843 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3799 | break; |
3844 | break; |
3800 | #ifndef NO_CURSORCOLOR |
3845 | #ifndef NO_CURSORCOLOR |
3801 | case XTerm_Color_cursor: |
3846 | case XTerm_Color_cursor: |
3802 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3847 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3803 | break; |
3848 | break; |
… | |
… | |
3807 | break; |
3852 | break; |
3808 | case XTerm_Color_pointer_bg: |
3853 | case XTerm_Color_pointer_bg: |
3809 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3854 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3810 | break; |
3855 | break; |
3811 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3856 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3812 | case XTerm_Color_BD: |
|
|
3813 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3814 | break; |
|
|
3815 | case XTerm_Color_UL: |
|
|
3816 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3817 | break; |
|
|
3818 | case XTerm_Color_RV: |
3857 | case XTerm_Color_RV: |
3819 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3858 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3859 | break; |
|
|
3860 | case Rxvt_Color_BD: |
|
|
3861 | case URxvt_Color_BD: |
|
|
3862 | process_color_seq (op, Color_BD, str, resp); |
|
|
3863 | break; |
|
|
3864 | case Rxvt_Color_UL: |
|
|
3865 | case URxvt_Color_UL: |
|
|
3866 | process_color_seq (op, Color_UL, str, resp); |
3820 | break; |
3867 | break; |
3821 | case URxvt_Color_IT: |
3868 | case URxvt_Color_IT: |
3822 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3869 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3823 | break; |
3870 | break; |
3824 | #endif |
3871 | #endif |
… | |
… | |
3829 | if (am_transparent) |
3876 | if (am_transparent) |
3830 | want_full_refresh = want_refresh = 1; |
3877 | want_full_refresh = want_refresh = 1; |
3831 | break; |
3878 | break; |
3832 | #endif |
3879 | #endif |
3833 | |
3880 | |
3834 | case XTerm_Pixmap: |
3881 | case Rxvt_Pixmap: |
|
|
3882 | { |
3835 | if (*str != ';') |
3883 | if (*str != ';') |
3836 | { |
3884 | { |
3837 | #if XPM_BACKGROUND |
3885 | #if XPM_BACKGROUND |
3838 | scale_pixmap (""); /* reset to default scaling */ |
3886 | scale_pixmap (""); /* reset to default scaling */ |
3839 | set_bgPixmap (str); /* change pixmap */ |
3887 | set_bgPixmap (str); /* change pixmap */ |
3840 | #endif |
|
|
3841 | scr_touch (true); |
3888 | scr_touch (true); |
|
|
3889 | #endif |
3842 | } |
3890 | } |
|
|
3891 | |
|
|
3892 | int changed = 0; |
|
|
3893 | |
3843 | while ((str = strchr (str, ';')) != NULL) |
3894 | while ((str = strchr (str, ';')) != NULL) |
3844 | { |
3895 | { |
3845 | str++; |
3896 | str++; |
3846 | #if XPM_BACKGROUND |
3897 | #if XPM_BACKGROUND |
3847 | changed += scale_pixmap (str); |
3898 | changed += scale_pixmap (str); |
3848 | #endif |
3899 | #endif |
3849 | } |
3900 | } |
3850 | |
3901 | |
3851 | if (changed) |
3902 | if (changed) |
3852 | { |
3903 | { |
3853 | #ifdef XPM_BACKGROUND |
3904 | #ifdef XPM_BACKGROUND |
3854 | resize_pixmap (); |
3905 | resize_pixmap (); |
3855 | #endif |
|
|
3856 | scr_touch (true); |
3906 | scr_touch (true); |
|
|
3907 | #endif |
3857 | } |
3908 | } |
|
|
3909 | } |
3858 | break; |
3910 | break; |
3859 | |
3911 | |
3860 | case XTerm_restoreFG: |
3912 | case Rxvt_restoreFG: |
3861 | set_window_color (Color_fg, str); |
3913 | set_window_color (Color_fg, str); |
3862 | break; |
3914 | break; |
3863 | case XTerm_restoreBG: |
3915 | case Rxvt_restoreBG: |
3864 | set_window_color (Color_bg, str); |
3916 | set_window_color (Color_bg, str); |
3865 | break; |
3917 | break; |
3866 | |
3918 | |
3867 | case XTerm_logfile: |
3919 | case XTerm_logfile: |
3868 | // TODO, when secure mode? |
3920 | // TODO, when secure mode? |
3869 | break; |
3921 | break; |
3870 | |
3922 | |
3871 | #ifdef MENUBAR |
|
|
3872 | case URxvt_Menu: |
|
|
3873 | if (OPTION (Opt_insecure)) |
|
|
3874 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3875 | break; |
|
|
3876 | #endif |
|
|
3877 | #if 0 |
3923 | #if 0 |
3878 | case XTerm_dumpscreen: /* no error notices */ |
3924 | case Rxvt_dumpscreen: /* no error notices */ |
3879 | { |
3925 | { |
3880 | int fd; |
3926 | int fd; |
3881 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3927 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3882 | { |
3928 | { |
3883 | scr_dump (fd); |
3929 | scr_dump (fd); |
… | |
… | |
3914 | if (query) |
3960 | if (query) |
3915 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3961 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3916 | else |
3962 | else |
3917 | { |
3963 | { |
3918 | set_locale (str); |
3964 | set_locale (str); |
3919 | pty.set_utf8_mode (enc_utf8); |
3965 | pty->set_utf8_mode (enc_utf8); |
3920 | init_xlocale (); |
3966 | init_xlocale (); |
3921 | } |
3967 | } |
3922 | break; |
3968 | break; |
3923 | |
3969 | |
3924 | case URxvt_view_up: |
3970 | case URxvt_view_up: |
3925 | case URxvt_view_down: |
3971 | case URxvt_view_down: |
|
|
3972 | { |
3926 | int lines = atoi (str); |
3973 | int lines = atoi (str); |
3927 | |
3974 | |
3928 | if (lines) |
3975 | if (lines) |
3929 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3976 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3930 | else |
3977 | else |
3931 | { |
|
|
3932 | scr_erase_savelines (); |
3978 | scr_erase_savelines (); |
3933 | } |
3979 | } |
3934 | |
3980 | |
|
|
3981 | break; |
|
|
3982 | #endif |
|
|
3983 | |
|
|
3984 | #if ENABLE_PERL |
|
|
3985 | case URxvt_perl: |
|
|
3986 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
3987 | ; // no responses yet |
3935 | break; |
3988 | break; |
3936 | #endif |
3989 | #endif |
3937 | } |
3990 | } |
3938 | } |
3991 | } |
3939 | /*----------------------------------------------------------------------*/ |
3992 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3970 | return state; |
4023 | return state; |
3971 | } |
4024 | } |
3972 | |
4025 | |
3973 | /* we're not using priv _yet_ */ |
4026 | /* we're not using priv _yet_ */ |
3974 | void |
4027 | void |
3975 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4028 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3976 | { |
4029 | { |
3977 | unsigned int i, j; |
4030 | unsigned int i, j; |
3978 | int state; |
4031 | int state; |
3979 | |
4032 | |
3980 | static const struct |
4033 | static const struct |
… | |
… | |
3991 | { 5, PrivMode_rVideo }, |
4044 | { 5, PrivMode_rVideo }, |
3992 | { 6, PrivMode_relOrigin }, |
4045 | { 6, PrivMode_relOrigin }, |
3993 | { 7, PrivMode_Autowrap }, |
4046 | { 7, PrivMode_Autowrap }, |
3994 | // 8, bi-directional support mode |
4047 | // 8, bi-directional support mode |
3995 | { 9, PrivMode_MouseX10 }, |
4048 | { 9, PrivMode_MouseX10 }, |
3996 | #ifdef menuBar_esc |
|
|
3997 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3998 | #endif |
|
|
3999 | // 18, 19 printing-related |
4049 | // 18, 19 printing-related |
4000 | { 25, PrivMode_VisibleCursor }, |
4050 | { 25, PrivMode_VisibleCursor }, |
4001 | #ifdef scrollBar_esc |
4051 | #ifdef scrollBar_esc |
4002 | { scrollBar_esc, PrivMode_scrollBar }, |
4052 | { scrollBar_esc, PrivMode_scrollBar }, |
4003 | #endif |
4053 | #endif |
… | |
… | |
4048 | } |
4098 | } |
4049 | |
4099 | |
4050 | /* extra handling for values with state unkept */ |
4100 | /* extra handling for values with state unkept */ |
4051 | switch (arg[i]) |
4101 | switch (arg[i]) |
4052 | { |
4102 | { |
|
|
4103 | #if ENABLE_STYLES |
|
|
4104 | case 1021: |
|
|
4105 | set_option (Opt_intensityStyles, mode); |
|
|
4106 | |
|
|
4107 | scr_touch (true); |
|
|
4108 | break; |
|
|
4109 | #endif |
4053 | case 1048: /* alternative cursor save */ |
4110 | case 1048: /* alternative cursor save */ |
4054 | case 1049: |
4111 | case 1049: |
4055 | if (OPTION (Opt_secondaryScreen)) |
4112 | if (OPTION (Opt_secondaryScreen)) |
4056 | if (mode == 0) |
4113 | if (mode == 0) |
4057 | scr_cursor (RESTORE); |
4114 | scr_cursor (RESTORE); |
… | |
… | |
4075 | case 3: /* 80/132 */ |
4132 | case 3: /* 80/132 */ |
4076 | if (priv_modes & PrivMode_132OK) |
4133 | if (priv_modes & PrivMode_132OK) |
4077 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4134 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4078 | break; |
4135 | break; |
4079 | case 4: /* smooth scrolling */ |
4136 | case 4: /* smooth scrolling */ |
4080 | if (!state) |
4137 | set_option (Opt_jumpScroll, !state); |
4081 | SET_OPTION (Opt_jumpScroll); |
|
|
4082 | else |
|
|
4083 | CLR_OPTION (Opt_jumpScroll); |
|
|
4084 | break; |
4138 | break; |
4085 | case 5: /* reverse video */ |
4139 | case 5: /* reverse video */ |
4086 | scr_rvideo_mode (state); |
4140 | scr_rvideo_mode (state); |
4087 | break; |
4141 | break; |
4088 | case 6: /* relative/absolute origins */ |
4142 | case 6: /* relative/absolute origins */ |
… | |
… | |
4094 | /* case 8: - auto repeat, can't do on a per window basis */ |
4148 | /* case 8: - auto repeat, can't do on a per window basis */ |
4095 | case 9: /* X10 mouse reporting */ |
4149 | case 9: /* X10 mouse reporting */ |
4096 | if (state) /* orthogonal */ |
4150 | if (state) /* orthogonal */ |
4097 | priv_modes &= ~PrivMode_MouseX11; |
4151 | priv_modes &= ~PrivMode_MouseX11; |
4098 | break; |
4152 | break; |
4099 | #ifdef menuBar_esc |
|
|
4100 | case menuBar_esc: |
|
|
4101 | #ifdef MENUBAR |
|
|
4102 | map_menuBar (state); |
|
|
4103 | #endif |
|
|
4104 | break; |
|
|
4105 | #endif |
|
|
4106 | #ifdef scrollBar_esc |
4153 | #ifdef scrollBar_esc |
4107 | case scrollBar_esc: |
4154 | case scrollBar_esc: |
4108 | if (scrollbar_mapping (state)) |
4155 | if (scrollbar_mapping (state)) |
4109 | { |
4156 | { |
4110 | resize_all_windows (0, 0, 0); |
4157 | resize_all_windows (0, 0, 0); |
… | |
… | |
4129 | #if 0 |
4176 | #if 0 |
4130 | case 1001: |
4177 | case 1001: |
4131 | break; /* X11 mouse highlighting */ |
4178 | break; /* X11 mouse highlighting */ |
4132 | #endif |
4179 | #endif |
4133 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4180 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4134 | if (!state) |
4181 | set_option (Opt_scrollTtyOutput, !state); |
4135 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4136 | else |
|
|
4137 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4138 | break; |
4182 | break; |
4139 | case 1011: /* scroll to bottom on key press */ |
4183 | case 1011: /* scroll to bottom on key press */ |
4140 | if (state) |
4184 | set_option (Opt_scrollTtyKeypress, state); |
4141 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4142 | else |
|
|
4143 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4144 | break; |
4185 | break; |
4145 | #if ENABLE_STYLES |
|
|
4146 | case 1021: |
|
|
4147 | if (state) |
|
|
4148 | SET_OPTION (Opt_intensityStyles); |
|
|
4149 | else |
|
|
4150 | CLR_OPTION (Opt_intensityStyles); |
|
|
4151 | #endif |
|
|
4152 | case 1047: /* secondary screen w/ clearing last */ |
4186 | case 1047: /* secondary screen w/ clearing last */ |
4153 | if (OPTION (Opt_secondaryScreen)) |
4187 | if (OPTION (Opt_secondaryScreen)) |
4154 | if (current_screen != PRIMARY) |
4188 | if (current_screen != PRIMARY) |
4155 | scr_erase_screen (2); |
4189 | scr_erase_screen (2); |
4156 | scr_change_screen (state); |
4190 | scr_change_screen (state); |
… | |
… | |
4293 | scr_color (Color_bg, Color_bg); |
4327 | scr_color (Color_bg, Color_bg); |
4294 | break; |
4328 | break; |
4295 | |
4329 | |
4296 | //case 50: // not variable spacing |
4330 | //case 50: // not variable spacing |
4297 | |
4331 | |
4298 | #ifndef NO_BRIGHTCOLOR |
4332 | #if ENABLE_FRILLS |
4299 | case 90: |
4333 | case 90: |
4300 | case 91: /* set bright fg color */ |
4334 | case 91: /* set bright fg color */ |
4301 | case 92: |
4335 | case 92: |
4302 | case 93: |
4336 | case 93: |
4303 | case 94: |
4337 | case 94: |
… | |
… | |
4315 | case 106: |
4349 | case 106: |
4316 | case 107: |
4350 | case 107: |
4317 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4351 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4318 | break; |
4352 | break; |
4319 | #endif |
4353 | #endif |
4320 | |
|
|
4321 | } |
4354 | } |
4322 | } |
4355 | } |
4323 | } |
4356 | } |
4324 | /*}}} */ |
4357 | /*}}} */ |
4325 | |
4358 | |
… | |
… | |
4349 | */ |
4382 | */ |
4350 | void |
4383 | void |
4351 | rxvt_term::tt_printf (const char *fmt,...) |
4384 | rxvt_term::tt_printf (const char *fmt,...) |
4352 | { |
4385 | { |
4353 | va_list arg_ptr; |
4386 | va_list arg_ptr; |
4354 | unsigned char buf[256]; |
4387 | char buf[256]; |
4355 | |
4388 | |
4356 | va_start (arg_ptr, fmt); |
4389 | va_start (arg_ptr, fmt); |
4357 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4390 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4358 | va_end (arg_ptr); |
4391 | va_end (arg_ptr); |
4359 | tt_write (buf, strlen (buf)); |
4392 | tt_write (buf, strlen (buf)); |
… | |
… | |
4364 | * or generated by us in response to a query ESC sequence. |
4397 | * or generated by us in response to a query ESC sequence. |
4365 | */ |
4398 | */ |
4366 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4399 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4367 | |
4400 | |
4368 | void |
4401 | void |
4369 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4402 | rxvt_term::tt_write (const char *data, unsigned int len) |
4370 | { |
4403 | { |
|
|
4404 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4405 | return; |
|
|
4406 | |
|
|
4407 | if (pty->pty < 0) |
|
|
4408 | return; |
|
|
4409 | |
4371 | if (v_buflen == 0) |
4410 | if (v_buflen == 0) |
4372 | { |
4411 | { |
4373 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4412 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4374 | |
4413 | |
4375 | if ((unsigned int)written == len) |
4414 | if ((unsigned int)written == len) |
4376 | return; |
4415 | return; |
4377 | |
4416 | |
4378 | data += written; |
4417 | data += written; |
4379 | len -= written; |
4418 | len -= written; |
4380 | } |
4419 | } |
4381 | |
4420 | |
4382 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4421 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4383 | |
4422 | |
4384 | memcpy (v_buffer + v_buflen, data, len); |
4423 | memcpy (v_buffer + v_buflen, data, len); |
4385 | v_buflen += len; |
4424 | v_buflen += len; |
4386 | |
4425 | |
4387 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4426 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4388 | } |
4427 | } |
4389 | |
4428 | |
4390 | void rxvt_term::pty_write () |
4429 | void rxvt_term::pty_write () |
4391 | { |
4430 | { |
4392 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4431 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4393 | |
4432 | |
4394 | if (written > 0) |
4433 | if (written > 0) |
4395 | { |
4434 | { |
4396 | v_buflen -= written; |
4435 | v_buflen -= written; |
4397 | |
4436 | |