… | |
… | |
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 | #define HAVE_SCHED_YIELD 1 //D//TODO//FIXME |
|
|
60 | #if HAVE_SCHED_YIELD |
|
|
61 | # include <sched.h> |
|
|
62 | #endif |
|
|
63 | |
|
|
64 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
65 | |
66 | |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | |
|
|
68 | // exception thrown when the command parser runs out of input data |
|
|
69 | class out_of_input { } out_of_input; |
|
|
70 | |
68 | |
71 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
72 | |
70 | |
73 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
74 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
146 | || !IN_RANGE_EXC (y, 0, nrow)) |
144 | || !IN_RANGE_EXC (y, 0, nrow)) |
147 | return; |
145 | return; |
148 | |
146 | |
149 | for (;;) |
147 | for (;;) |
150 | { |
148 | { |
151 | const line_t &l = ROW(y - view_start); |
149 | const line_t &l = ROW(y + view_start); |
152 | |
150 | |
153 | text_t t = l.t[x]; |
151 | text_t t = l.t[x]; |
154 | |
152 | |
155 | if (t != NOCHAR || !x) |
153 | if (t != NOCHAR || !x) |
156 | { |
154 | { |
… | |
… | |
267 | mb[0] = ch[0]; |
265 | mb[0] = ch[0]; |
268 | len = 1; |
266 | len = 1; |
269 | } |
267 | } |
270 | |
268 | |
271 | if (len > 0) |
269 | if (len > 0) |
272 | tt_write ((unsigned char *)mb, len); |
270 | tt_write (mb, len); |
273 | else |
271 | else |
274 | scr_bell (); |
272 | scr_bell (); |
275 | } |
273 | } |
276 | |
274 | |
277 | iso14755buf = 0; |
275 | iso14755buf = 0; |
… | |
… | |
305 | KeySym keysym; |
303 | KeySym keysym; |
306 | #ifdef DEBUG_CMD |
304 | #ifdef DEBUG_CMD |
307 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | static int debug_key = 1; /* accessible by a debugger only */ |
308 | #endif |
306 | #endif |
309 | int valid_keysym; |
307 | int valid_keysym; |
310 | unsigned char kbuf[KBUFSZ]; |
308 | char kbuf[KBUFSZ]; |
311 | |
309 | |
312 | /* |
310 | /* |
313 | * 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 |
314 | * escape sequence to toggle the Keypad. |
312 | * escape sequence to toggle the Keypad. |
315 | * |
313 | * |
… | |
… | |
333 | Status status_return; |
331 | Status status_return; |
334 | |
332 | |
335 | #if 0 |
333 | #if 0 |
336 | #ifdef X_HAVE_UTF8_STRING |
334 | #ifdef X_HAVE_UTF8_STRING |
337 | 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 |
338 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
336 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
339 | KBUFSZ, &keysym, &status_return); |
337 | KBUFSZ, &keysym, &status_return); |
340 | else |
338 | else |
341 | #endif |
339 | #endif |
342 | #endif |
340 | #endif |
343 | { |
341 | { |
… | |
… | |
380 | || status_return == XLookupBoth; |
378 | || status_return == XLookupBoth; |
381 | } |
379 | } |
382 | else |
380 | else |
383 | #endif |
381 | #endif |
384 | { |
382 | { |
385 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
383 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
386 | valid_keysym = keysym != NoSymbol; |
384 | valid_keysym = keysym != NoSymbol; |
387 | } |
385 | } |
388 | |
386 | |
389 | if (valid_keysym) |
387 | if (valid_keysym) |
390 | { |
388 | { |
… | |
… | |
442 | scr_move_to (0, 1); |
440 | scr_move_to (0, 1); |
443 | return; |
441 | return; |
444 | } |
442 | } |
445 | else if (keysym == XK_End) |
443 | else if (keysym == XK_End) |
446 | { |
444 | { |
447 | scr_move_to (1, 0); |
445 | scr_move_to (1, 1); |
448 | return; |
446 | return; |
449 | } |
447 | } |
450 | } |
448 | } |
451 | #endif |
449 | #endif |
452 | } |
450 | } |
… | |
… | |
463 | { |
461 | { |
464 | switch (keysym) |
462 | switch (keysym) |
465 | { |
463 | { |
466 | /* normal XTerm key bindings */ |
464 | /* normal XTerm key bindings */ |
467 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
465 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
468 | selection_request (ev.time, 0, 0); |
466 | selection_request (ev.time); |
469 | return; |
467 | return; |
470 | #if TODO |
468 | #if TODO |
471 | /* rxvt extras */ |
469 | /* rxvt extras */ |
472 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
470 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
473 | change_font (FONT_UP); |
471 | change_font (FONT_UP); |
… | |
… | |
854 | { |
852 | { |
855 | #ifdef META8_OPTION |
853 | #ifdef META8_OPTION |
856 | /* set 8-bit on */ |
854 | /* set 8-bit on */ |
857 | if (meta && (meta_char == 0x80)) |
855 | if (meta && (meta_char == 0x80)) |
858 | { |
856 | { |
859 | unsigned char *ch; |
857 | char *ch; |
860 | |
858 | |
861 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | *ch |= 0x80; |
860 | *ch |= 0x80; |
863 | |
861 | |
864 | meta = 0; |
862 | meta = 0; |
865 | } |
863 | } |
866 | #endif |
864 | #endif |
867 | /* nil */ ; |
865 | /* nil */ ; |
868 | } |
866 | } |
869 | } |
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; |
870 | |
871 | |
871 | if (len <= 0) |
872 | if (len <= 0) |
872 | return; /* not mapped */ |
873 | return; /* not mapped */ |
873 | |
874 | |
874 | if (OPTION (Opt_scrollTtyKeypress)) |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
897 | #ifdef META8_OPTION |
898 | #ifdef META8_OPTION |
898 | && meta_char == C0_ESC |
899 | && meta_char == C0_ESC |
899 | #endif |
900 | #endif |
900 | ) |
901 | ) |
901 | { |
902 | { |
902 | const unsigned char ch = C0_ESC; |
903 | const char ch = C0_ESC; |
903 | tt_write (&ch, 1); |
904 | tt_write (&ch, 1); |
904 | } |
905 | } |
905 | |
906 | |
906 | #if defined(DEBUG_CMD) |
907 | #if defined(DEBUG_CMD) |
907 | /* Display keyboard buffer contents */ |
908 | /* Display keyboard buffer contents */ |
… | |
… | |
915 | #endif /* DEBUG_CMD */ |
916 | #endif /* DEBUG_CMD */ |
916 | tt_write (kbuf, (unsigned int)len); |
917 | tt_write (kbuf, (unsigned int)len); |
917 | } |
918 | } |
918 | /*}}} */ |
919 | /*}}} */ |
919 | |
920 | |
920 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
921 | #if defined (KEYSYM_RESOURCE) |
921 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
922 | /* attempt to `write' count to the input buffer */ |
|
|
923 | unsigned int |
922 | unsigned int |
924 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
923 | rxvt_term::cmd_write (const char *str, unsigned int count) |
925 | { |
924 | { |
926 | unsigned int n, s; |
925 | unsigned int n, s; |
927 | |
926 | |
928 | n = cmdbuf_ptr - cmdbuf_base; |
927 | n = cmdbuf_ptr - cmdbuf_base; |
929 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
928 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
966 | } |
965 | } |
967 | #endif |
966 | #endif |
968 | |
967 | |
969 | if (want_refresh) |
968 | if (want_refresh) |
970 | { |
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 | |
971 | scr_refresh (refresh_type); |
1008 | scr_refresh (); |
972 | scrollbar_show (1); |
1009 | scrollbar_show (1); |
973 | #ifdef USE_XIM |
1010 | #ifdef USE_XIM |
974 | IMSendSpot (); |
1011 | IMSendSpot (); |
975 | #endif |
1012 | #endif |
976 | } |
1013 | } |
… | |
… | |
979 | } |
1016 | } |
980 | |
1017 | |
981 | void |
1018 | void |
982 | rxvt_term::check_cb (check_watcher &w) |
1019 | rxvt_term::check_cb (check_watcher &w) |
983 | { |
1020 | { |
984 | SET_R (this); |
1021 | make_current (); |
985 | SET_LOCALE (locale); |
|
|
986 | |
1022 | |
987 | display->flush (); |
1023 | display->flush (); |
988 | |
1024 | |
989 | if (want_refresh && !flush_ev.active) |
1025 | if (want_refresh && !flush_ev.active) |
990 | flush_ev.start (NOW + 0.01); |
1026 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
991 | } |
1027 | } |
992 | |
1028 | |
993 | void |
1029 | void |
994 | rxvt_term::flush_cb (time_watcher &w) |
1030 | rxvt_term::flush_cb (time_watcher &w) |
995 | { |
1031 | { |
996 | SET_R (this); |
1032 | make_current (); |
997 | SET_LOCALE (locale); |
|
|
998 | |
1033 | |
999 | refresh_limit = 1; |
1034 | refresh_limit = 1; |
1000 | refresh_count = 0; |
1035 | refresh_count = 0; |
1001 | flush (); |
1036 | flush (); |
1002 | } |
1037 | } |
… | |
… | |
1006 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1041 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1007 | { |
1042 | { |
1008 | hidden_cursor = !hidden_cursor; |
1043 | hidden_cursor = !hidden_cursor; |
1009 | want_refresh = 1; |
1044 | want_refresh = 1; |
1010 | |
1045 | |
1011 | w.start (w.at + BLINK_INTERVAL); |
1046 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1012 | } |
1047 | } |
1013 | #endif |
1048 | #endif |
1014 | |
1049 | |
1015 | #ifdef TEXT_BLINK |
1050 | #ifdef TEXT_BLINK |
1016 | void |
1051 | void |
… | |
… | |
1030 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1065 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1031 | { |
1066 | { |
1032 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1067 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1033 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1068 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1034 | { |
1069 | { |
1035 | refresh_type |= SMOOTH_REFRESH; |
|
|
1036 | want_refresh = 1; |
1070 | want_refresh = 1; |
1037 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1038 | } |
1072 | } |
1039 | } |
1073 | } |
1040 | #endif |
1074 | #endif |
… | |
… | |
1044 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1078 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1045 | { |
1079 | { |
1046 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1080 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1047 | { |
1081 | { |
1048 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1082 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1049 | refresh_type |= SMOOTH_REFRESH; |
|
|
1050 | want_refresh = 1; |
1083 | want_refresh = 1; |
1051 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1084 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1052 | } |
1085 | } |
1053 | } |
1086 | } |
1054 | #endif |
1087 | #endif |
… | |
… | |
1059 | { |
1092 | { |
1060 | if (mouse_slip_wheel_speed == 0 |
1093 | if (mouse_slip_wheel_speed == 0 |
1061 | || 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) |
1062 | : scr_page (UP, mouse_slip_wheel_speed)) |
1095 | : scr_page (UP, mouse_slip_wheel_speed)) |
1063 | { |
1096 | { |
1064 | if (view_start == nsaved || |
1097 | if (view_start == top_row || view_start == 0) |
1065 | view_start == 0) |
|
|
1066 | mouse_slip_wheel_speed = 0; |
1098 | mouse_slip_wheel_speed = 0; |
1067 | |
1099 | |
1068 | refresh_type |= SMOOTH_REFRESH; |
|
|
1069 | want_refresh = 1; |
1100 | want_refresh = 1; |
1070 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1101 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | } |
1102 | } |
1072 | } |
1103 | } |
1073 | #endif |
1104 | #endif |
1074 | |
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 | |
1075 | bool |
1124 | bool |
1076 | rxvt_term::pty_fill () |
1125 | rxvt_term::pty_fill () |
1077 | { |
1126 | { |
1078 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1127 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1079 | |
1128 | |
1080 | if (CBUFSIZ == n) |
1129 | if (CBUFSIZ == n) |
1081 | { |
1130 | { |
1082 | 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"); |
1083 | n = 0; |
1132 | n = 0; |
1084 | } |
1133 | } |
1085 | |
1134 | |
1086 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1135 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1087 | cmdbuf_ptr = cmdbuf_base; |
1136 | cmdbuf_ptr = cmdbuf_base; |
1088 | cmdbuf_endp = cmdbuf_ptr + n; |
1137 | cmdbuf_endp = cmdbuf_ptr + n; |
1089 | |
1138 | |
1090 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1139 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1091 | |
1140 | |
1092 | if (r > 0) |
1141 | if (r > 0) |
1093 | { |
1142 | { |
1094 | cmdbuf_endp += r; |
1143 | cmdbuf_endp += r; |
1095 | return true; |
1144 | return true; |
1096 | } |
1145 | } |
1097 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1146 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1098 | { |
1147 | { |
1099 | #if HAVE_SCHED_YIELD |
1148 | #if HAVE_SCHED_YIELD |
1100 | sched_yield (); |
1149 | if (display->is_local) |
|
|
1150 | event_handler.cw_yield.start (); |
1101 | #endif |
1151 | #endif |
1102 | } |
1152 | } |
1103 | else |
1153 | else |
1104 | { |
1154 | { |
1105 | pty_ev.stop (); |
1155 | pty_ev.stop (); |
… | |
… | |
1112 | } |
1162 | } |
1113 | |
1163 | |
1114 | void |
1164 | void |
1115 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1165 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1116 | { |
1166 | { |
1117 | SET_R (this); |
1167 | make_current (); |
1118 | SET_LOCALE (locale); |
|
|
1119 | |
1168 | |
1120 | if (revents & EVENT_READ) |
1169 | if (revents & EVENT_READ) |
1121 | // loop, but don't allow a single term to monopolize us |
1170 | // loop, but don't allow a single term to monopolize us |
1122 | while (pty_fill ()) |
1171 | while (pty_fill ()) |
1123 | if (cmd_parse ()) |
1172 | if (cmd_parse ()) |
… | |
… | |
1143 | |
1192 | |
1144 | #ifdef POINTER_BLANK |
1193 | #ifdef POINTER_BLANK |
1145 | void |
1194 | void |
1146 | rxvt_term::pointer_blank () |
1195 | rxvt_term::pointer_blank () |
1147 | { |
1196 | { |
1148 | if (! OPTION (Opt_pointerBlank)) |
1197 | if (!OPTION (Opt_pointerBlank)) |
1149 | return; |
1198 | return; |
1150 | |
1199 | |
1151 | XDefineCursor (display->display, vt, display->blank_cursor); |
1200 | XDefineCursor (display->display, vt, display->blank_cursor); |
1152 | XFlush (display->display); |
1201 | XFlush (display->display); |
1153 | |
1202 | |
… | |
… | |
1155 | } |
1204 | } |
1156 | |
1205 | |
1157 | void |
1206 | void |
1158 | rxvt_term::pointer_cb (time_watcher &w) |
1207 | rxvt_term::pointer_cb (time_watcher &w) |
1159 | { |
1208 | { |
1160 | SET_R (this); |
1209 | make_current (); |
1161 | SET_LOCALE (locale); |
|
|
1162 | |
1210 | |
1163 | pointer_blank (); |
1211 | pointer_blank (); |
1164 | } |
1212 | } |
1165 | #endif |
1213 | #endif |
1166 | |
1214 | |
… | |
… | |
1245 | |
1293 | |
1246 | /*{{{ process an X event */ |
1294 | /*{{{ process an X event */ |
1247 | void |
1295 | void |
1248 | rxvt_term::x_cb (XEvent &ev) |
1296 | rxvt_term::x_cb (XEvent &ev) |
1249 | { |
1297 | { |
|
|
1298 | make_current (); |
|
|
1299 | |
1250 | dDisp; |
1300 | dDisp; |
1251 | |
1301 | |
1252 | SET_R (this); |
1302 | if (ev.xany.window == vt |
1253 | SET_LOCALE (locale); |
1303 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1304 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1305 | return; |
1254 | |
1306 | |
1255 | #if defined(CURSOR_BLINK) |
1307 | // for XQueryPointer |
1256 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1257 | { |
|
|
1258 | if (hidden_cursor) |
|
|
1259 | { |
|
|
1260 | hidden_cursor = 0; |
|
|
1261 | want_refresh = 1; |
|
|
1262 | } |
|
|
1263 | |
|
|
1264 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1265 | } |
|
|
1266 | #endif |
|
|
1267 | |
|
|
1268 | #if defined(POINTER_BLANK) |
|
|
1269 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1270 | { |
|
|
1271 | if (ev.type == MotionNotify |
|
|
1272 | || ev.type == ButtonPress |
|
|
1273 | || ev.type == ButtonRelease) |
|
|
1274 | if (hidden_pointer) |
|
|
1275 | pointer_unblank (); |
|
|
1276 | |
|
|
1277 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1278 | pointer_blank (); |
|
|
1279 | } |
|
|
1280 | #endif |
|
|
1281 | |
|
|
1282 | Window unused_root, unused_child; |
1308 | Window unused_root, unused_child; |
1283 | int unused_root_x, unused_root_y; |
1309 | int unused_root_x, unused_root_y; |
1284 | unsigned int unused_mask; |
1310 | unsigned int unused_mask; |
1285 | |
1311 | |
1286 | switch (ev.type) |
1312 | switch (ev.type) |
… | |
… | |
1293 | |
1319 | |
1294 | break; |
1320 | break; |
1295 | |
1321 | |
1296 | case KeyRelease: |
1322 | case KeyRelease: |
1297 | { |
1323 | { |
1298 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1324 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1299 | KeySym ks; |
1325 | KeySym keysym; |
1300 | |
1326 | |
1301 | 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 :/ |
1302 | #endif |
1328 | #endif |
1303 | |
1329 | |
1304 | #if ENABLE_FRILLS || ISO_14755 |
1330 | #if ENABLE_FRILLS || ISO_14755 |
1305 | // ISO 14755 support |
1331 | // ISO 14755 support |
1306 | if (iso14755buf) |
1332 | if (iso14755buf) |
… | |
… | |
1311 | # endif |
1337 | # endif |
1312 | # if ISO_14755 |
1338 | # if ISO_14755 |
1313 | // iso14755 part 5.2 handling: release time |
1339 | // iso14755 part 5.2 handling: release time |
1314 | // first: controls |
1340 | // first: controls |
1315 | if ((ev.xkey.state & ControlMask) |
1341 | if ((ev.xkey.state & ControlMask) |
1316 | && ((ks >= 0x40 && ks <= 0x5f) |
1342 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1317 | || (ks >= 0x61 && ks <= 0x7f))) |
1343 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1318 | { |
1344 | { |
1319 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1345 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1320 | commit_iso14755 (); |
1346 | commit_iso14755 (); |
1321 | return; // case-break; |
1347 | goto skip_switch; |
1322 | } |
1348 | } |
1323 | |
1349 | |
1324 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1350 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1325 | if (i[0] == ks) |
1351 | if (i[0] == keysym) |
1326 | { |
1352 | { |
1327 | iso14755buf = ISO_14755_51 | i[1]; |
1353 | iso14755buf = ISO_14755_51 | i[1]; |
1328 | commit_iso14755 (); |
1354 | commit_iso14755 (); |
1329 | return; // case-break; |
1355 | goto skip_switch; |
1330 | } |
1356 | } |
1331 | |
1357 | |
1332 | scr_bell (); |
1358 | scr_bell (); |
1333 | # endif |
1359 | # endif |
1334 | iso14755buf = 0; |
1360 | iso14755buf = 0; |
… | |
… | |
1353 | else |
1379 | else |
1354 | iso14755buf = 0; |
1380 | iso14755buf = 0; |
1355 | } |
1381 | } |
1356 | #endif |
1382 | #endif |
1357 | |
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 | |
1358 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1388 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1359 | if (!(ev.xkey.state & ControlMask)) |
1389 | if (!(ev.xkey.state & ControlMask)) |
1360 | slip_wheel_ev.stop (); |
1390 | slip_wheel_ev.stop (); |
1361 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1391 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1362 | mouse_slip_wheel_speed = 0; |
1392 | mouse_slip_wheel_speed = 0; |
1363 | #endif |
1393 | #endif |
1364 | break; |
1394 | break; |
1365 | } |
1395 | } |
1366 | |
1396 | |
… | |
… | |
1372 | button_release (ev.xbutton); |
1402 | button_release (ev.xbutton); |
1373 | break; |
1403 | break; |
1374 | |
1404 | |
1375 | case ClientMessage: |
1405 | case ClientMessage: |
1376 | if (ev.xclient.format == 32 |
1406 | if (ev.xclient.format == 32 |
1377 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1407 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1378 | { |
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 | { |
1379 | 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))) |
1380 | destroy (); |
1416 | destroy (); |
|
|
1417 | } |
1381 | #if ENABLE_EWMH |
1418 | #if ENABLE_EWMH |
1382 | 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]) |
1383 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1384 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1385 | &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 | } |
1386 | #endif |
1434 | #endif |
1387 | } |
1435 | } |
1388 | #if ENABLE_XEMBED |
|
|
1389 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1390 | { |
|
|
1391 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1392 | focus_in (); |
|
|
1393 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1394 | focus_out (); |
|
|
1395 | } |
|
|
1396 | #endif |
|
|
1397 | #ifdef OFFIX_DND |
|
|
1398 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1399 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1400 | && (ev.xclient.data.l[0] == DndFile |
|
|
1401 | || ev.xclient.data.l[0] == DndDir |
|
|
1402 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1403 | { |
|
|
1404 | /* Get Dnd data */ |
|
|
1405 | Atom ActualType; |
|
|
1406 | int ActualFormat; |
|
|
1407 | unsigned char *data; |
|
|
1408 | unsigned long Size, RemainingBytes; |
|
|
1409 | |
|
|
1410 | XGetWindowProperty (disp, display->root, |
|
|
1411 | xa[XA_DNDSELECTION], |
|
|
1412 | 0L, 1000000L, |
|
|
1413 | False, AnyPropertyType, |
|
|
1414 | &ActualType, &ActualFormat, |
|
|
1415 | &Size, &RemainingBytes, |
|
|
1416 | &data); |
|
|
1417 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1418 | XFree (data); |
|
|
1419 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1420 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1421 | } |
|
|
1422 | #endif /* OFFIX_DND */ |
|
|
1423 | break; |
1436 | break; |
1424 | |
1437 | |
1425 | case MappingNotify: |
1438 | case MappingNotify: |
1426 | XRefreshKeyboardMapping (&ev.xmapping); |
1439 | XRefreshKeyboardMapping (&ev.xmapping); |
1427 | break; |
1440 | break; |
… | |
… | |
1469 | { |
1482 | { |
1470 | seen_resize = 1; |
1483 | seen_resize = 1; |
1471 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1484 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1472 | } |
1485 | } |
1473 | |
1486 | |
|
|
1487 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1488 | |
1474 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1489 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1475 | if (OPTION (Opt_transparent)) |
1490 | if (OPTION (Opt_transparent)) |
1476 | check_our_parents (); |
1491 | check_our_parents (); |
1477 | #endif |
1492 | #endif |
1478 | } |
1493 | } |
1479 | break; |
1494 | break; |
1480 | |
1495 | |
1481 | case PropertyNotify: |
1496 | case PropertyNotify: |
|
|
1497 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1482 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1498 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1483 | && ev.xproperty.state == PropertyNewValue) |
1499 | && ev.xproperty.state == PropertyNewValue) |
1484 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1500 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1485 | |
1501 | |
1486 | break; |
1502 | break; |
1487 | |
1503 | |
1488 | case SelectionClear: |
1504 | case SelectionClear: |
1489 | selection_clear (); |
1505 | selection_clear (); |
… | |
… | |
1494 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1510 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1495 | break; |
1511 | break; |
1496 | |
1512 | |
1497 | case SelectionRequest: |
1513 | case SelectionRequest: |
1498 | 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)); |
1499 | break; |
1523 | break; |
1500 | |
1524 | |
1501 | case UnmapNotify: |
1525 | case UnmapNotify: |
1502 | mapped = 0; |
1526 | mapped = 0; |
1503 | #ifdef TEXT_BLINK |
1527 | #ifdef TEXT_BLINK |
1504 | text_blink_ev.stop (); |
1528 | text_blink_ev.stop (); |
1505 | #endif |
1529 | #endif |
1506 | break; |
1530 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1507 | |
|
|
1508 | case MapNotify: |
|
|
1509 | mapped = 1; |
|
|
1510 | #ifdef TEXT_BLINK |
|
|
1511 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1512 | #endif |
|
|
1513 | break; |
1531 | break; |
1514 | |
1532 | |
1515 | #ifdef TRANSPARENT |
1533 | #ifdef TRANSPARENT |
1516 | case ReparentNotify: |
1534 | case ReparentNotify: |
1517 | rootwin_cb (ev); |
1535 | rootwin_cb (ev); |
… | |
… | |
1531 | |
1549 | |
1532 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1550 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1533 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1551 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1534 | ev.xexpose.width, ev.xexpose.height, False); |
1552 | ev.xexpose.width, ev.xexpose.height, False); |
1535 | |
1553 | |
1536 | scr_refresh (refresh_type); |
1554 | want_refresh = 1; |
1537 | } |
1555 | } |
1538 | else |
1556 | else |
1539 | { |
1557 | { |
1540 | XEvent unused_event; |
1558 | XEvent unused_event; |
1541 | |
1559 | |
… | |
… | |
1547 | if (isScrollbarWindow (ev.xany.window)) |
1565 | if (isScrollbarWindow (ev.xany.window)) |
1548 | { |
1566 | { |
1549 | scrollBar.setIdle (); |
1567 | scrollBar.setIdle (); |
1550 | scrollbar_show (0); |
1568 | scrollbar_show (0); |
1551 | } |
1569 | } |
1552 | #ifdef MENUBAR |
|
|
1553 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1554 | menubar_expose (); |
|
|
1555 | #endif |
|
|
1556 | |
1570 | |
1557 | #ifdef TRANSPARENT |
1571 | #ifdef TRANSPARENT |
1558 | if (am_transparent && ev.xany.window == parent[0]) |
1572 | if (am_transparent && ev.xany.window == parent[0]) |
1559 | XClearWindow (disp, ev.xany.window); |
1573 | XClearWindow (disp, ev.xany.window); |
1560 | #endif |
1574 | #endif |
… | |
… | |
1564 | case MotionNotify: |
1578 | case MotionNotify: |
1565 | #ifdef POINTER_BLANK |
1579 | #ifdef POINTER_BLANK |
1566 | if (hidden_pointer) |
1580 | if (hidden_pointer) |
1567 | pointer_unblank (); |
1581 | pointer_unblank (); |
1568 | #endif |
1582 | #endif |
1569 | #if MENUBAR |
|
|
1570 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1571 | { |
|
|
1572 | menubar_control (ev.xbutton); |
|
|
1573 | break; |
|
|
1574 | } |
|
|
1575 | #endif |
|
|
1576 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1583 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1577 | break; |
1584 | break; |
1578 | |
1585 | |
1579 | if (ev.xany.window == vt) |
1586 | if (ev.xany.window == vt) |
1580 | { |
1587 | { |
|
|
1588 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1589 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1590 | ; // nop |
1581 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1591 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1582 | { |
1592 | { |
1583 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1593 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1584 | ; |
1594 | ; |
1585 | |
1595 | |
1586 | XQueryPointer (disp, vt, |
1596 | XQueryPointer (disp, vt, |
… | |
… | |
1666 | &unused_root_x, &unused_root_y, |
1676 | &unused_root_x, &unused_root_y, |
1667 | &ev.xbutton.x, &ev.xbutton.y, |
1677 | &ev.xbutton.x, &ev.xbutton.y, |
1668 | &unused_mask); |
1678 | &unused_mask); |
1669 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1679 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1670 | scrollbar_size ()); |
1680 | scrollbar_size ()); |
1671 | scr_refresh (refresh_type); |
1681 | want_refresh = 1; |
1672 | refresh_limit = 0; |
1682 | refresh_limit = 0; |
1673 | scrollbar_show (1); |
1683 | scrollbar_show (1); |
1674 | } |
1684 | } |
1675 | break; |
1685 | break; |
1676 | } |
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 |
1677 | } |
1716 | } |
1678 | |
1717 | |
1679 | void |
1718 | void |
1680 | rxvt_term::focus_in () |
1719 | rxvt_term::focus_in () |
1681 | { |
1720 | { |
1682 | if (!focus) |
1721 | if (!focus) |
1683 | { |
1722 | { |
1684 | focus = 1; |
1723 | focus = 1; |
1685 | want_refresh = 1; |
1724 | want_refresh = 1; |
|
|
1725 | |
|
|
1726 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1727 | |
1686 | #if USE_XIM |
1728 | #if USE_XIM |
1687 | if (Input_Context != NULL) |
1729 | if (Input_Context != NULL) |
1688 | { |
1730 | { |
1689 | IMSetStatusPosition (); |
1731 | IMSetStatusPosition (); |
1690 | XSetICFocus (Input_Context); |
1732 | XSetICFocus (Input_Context); |
1691 | } |
1733 | } |
1692 | #endif |
1734 | #endif |
1693 | #if CURSOR_BLINK |
1735 | #if CURSOR_BLINK |
1694 | if (OPTION (Opt_cursorBlink)) |
1736 | if (OPTION (Opt_cursorBlink)) |
1695 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1737 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1696 | #endif |
1738 | #endif |
1697 | #if OFF_FOCUS_FADING |
1739 | #if OFF_FOCUS_FADING |
1698 | if (rs[Rs_fade]) |
1740 | if (rs[Rs_fade]) |
1699 | { |
1741 | { |
1700 | pix_colors = pix_colors_focused; |
1742 | pix_colors = pix_colors_focused; |
… | |
… | |
1710 | if (focus) |
1752 | if (focus) |
1711 | { |
1753 | { |
1712 | focus = 0; |
1754 | focus = 0; |
1713 | want_refresh = 1; |
1755 | want_refresh = 1; |
1714 | |
1756 | |
|
|
1757 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1758 | |
1715 | #if ENABLE_FRILLS || ISO_14755 |
1759 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1760 | if (iso14755buf) |
|
|
1761 | { |
1716 | iso14755buf = 0; |
1762 | iso14755buf = 0; |
1717 | #endif |
|
|
1718 | #if ENABLE_OVERLAY |
1763 | # if ENABLE_OVERLAY |
1719 | scr_overlay_off (); |
1764 | scr_overlay_off (); |
|
|
1765 | # endif |
|
|
1766 | } |
1720 | #endif |
1767 | #endif |
1721 | #if USE_XIM |
1768 | #if USE_XIM |
1722 | if (Input_Context != NULL) |
1769 | if (Input_Context != NULL) |
1723 | XUnsetICFocus (Input_Context); |
1770 | XUnsetICFocus (Input_Context); |
1724 | #endif |
1771 | #endif |
… | |
… | |
1739 | |
1786 | |
1740 | #if TRANSPARENT |
1787 | #if TRANSPARENT |
1741 | void |
1788 | void |
1742 | rxvt_term::rootwin_cb (XEvent &ev) |
1789 | rxvt_term::rootwin_cb (XEvent &ev) |
1743 | { |
1790 | { |
1744 | SET_R (this); |
1791 | make_current (); |
1745 | SET_LOCALE (locale); |
|
|
1746 | |
1792 | |
1747 | switch (ev.type) |
1793 | switch (ev.type) |
1748 | { |
1794 | { |
1749 | case PropertyNotify: |
1795 | case PropertyNotify: |
1750 | /* |
1796 | /* |
… | |
… | |
1768 | rxvt_term::button_press (XButtonEvent &ev) |
1814 | rxvt_term::button_press (XButtonEvent &ev) |
1769 | { |
1815 | { |
1770 | int reportmode = 0, clickintime; |
1816 | int reportmode = 0, clickintime; |
1771 | |
1817 | |
1772 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1818 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1819 | |
1773 | if (!bypass_keystate) |
1820 | if (!bypass_keystate) |
1774 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1821 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1775 | |
1822 | |
1776 | /* |
1823 | /* |
1777 | * VT window processing of button press |
1824 | * VT window processing of button press |
1778 | */ |
1825 | */ |
1779 | if (ev.window == vt) |
1826 | if (ev.window == vt) |
1780 | { |
1827 | { |
|
|
1828 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1829 | return; |
|
|
1830 | |
1781 | #if ISO_14755 |
1831 | #if ISO_14755 |
1782 | // 5.4 |
1832 | // 5.4 |
1783 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1833 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1784 | { |
1834 | { |
1785 | iso14755_54 (ev.x, ev.y); |
1835 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1797 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1847 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1798 | if (ev.button == MEvent.button && clickintime) |
1848 | if (ev.button == MEvent.button && clickintime) |
1799 | { |
1849 | { |
1800 | /* same button, within alloted time */ |
1850 | /* same button, within alloted time */ |
1801 | MEvent.clicks++; |
1851 | MEvent.clicks++; |
|
|
1852 | |
1802 | if (MEvent.clicks > 1) |
1853 | if (MEvent.clicks > 1) |
1803 | { |
1854 | { |
1804 | /* only report double clicks */ |
1855 | /* only report double clicks */ |
1805 | MEvent.clicks = 2; |
1856 | MEvent.clicks = 2; |
1806 | mouse_report (ev); |
1857 | mouse_report (ev); |
… | |
… | |
1838 | #else |
1889 | #else |
1839 | selection.rect = false; |
1890 | selection.rect = false; |
1840 | #endif |
1891 | #endif |
1841 | |
1892 | |
1842 | /* allow shift+left click to extend selection */ |
1893 | /* allow shift+left click to extend selection */ |
1843 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1894 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1844 | { |
1895 | { |
1845 | if (MEvent.button == Button1 && clickintime) |
1896 | if (MEvent.button == Button1 && clickintime) |
1846 | selection_rotate (ev.x, ev.y); |
1897 | selection_rotate (ev.x, ev.y); |
1847 | else |
1898 | else |
1848 | selection_extend (ev.x, ev.y, 1); |
1899 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2013 | } |
2064 | } |
2014 | |
2065 | |
2015 | break; |
2066 | break; |
2016 | } |
2067 | } |
2017 | } |
2068 | } |
|
|
2069 | |
2018 | return; |
2070 | return; |
2019 | } |
2071 | } |
2020 | #if MENUBAR |
|
|
2021 | /* |
|
|
2022 | * Menubar window processing of button press |
|
|
2023 | */ |
|
|
2024 | if (isMenuBarWindow (ev.window)) |
|
|
2025 | menubar_control (ev); |
|
|
2026 | #endif |
|
|
2027 | } |
2072 | } |
2028 | |
2073 | |
2029 | void |
2074 | void |
2030 | rxvt_term::button_release (XButtonEvent &ev) |
2075 | rxvt_term::button_release (XButtonEvent &ev) |
2031 | { |
2076 | { |
… | |
… | |
2037 | |
2082 | |
2038 | if (scrollbar_isUpDn ()) |
2083 | if (scrollbar_isUpDn ()) |
2039 | { |
2084 | { |
2040 | scrollBar.setIdle (); |
2085 | scrollBar.setIdle (); |
2041 | scrollbar_show (0); |
2086 | scrollbar_show (0); |
2042 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2043 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2044 | #endif |
|
|
2045 | } |
2087 | } |
2046 | |
2088 | |
2047 | #ifdef SELECTION_SCROLLING |
2089 | #ifdef SELECTION_SCROLLING |
2048 | if (sel_scroll_ev.active) |
2090 | if (sel_scroll_ev.active) |
2049 | sel_scroll_ev.stop(); |
2091 | sel_scroll_ev.stop(); |
2050 | #endif |
2092 | #endif |
2051 | |
2093 | |
2052 | if (ev.window == vt) |
2094 | if (ev.window == vt) |
2053 | { |
2095 | { |
|
|
2096 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2097 | return; |
|
|
2098 | |
2054 | #if ISO_14755 |
2099 | #if ISO_14755 |
2055 | // 5.4 |
2100 | // 5.4 |
2056 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2101 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2057 | return; |
2102 | return; |
2058 | #endif |
2103 | #endif |
|
|
2104 | |
2059 | if (reportmode) |
2105 | if (reportmode) |
2060 | { |
2106 | { |
2061 | /* mouse report from vt window */ |
2107 | /* mouse report from vt window */ |
2062 | /* don't report release of wheel "buttons" */ |
2108 | /* don't report release of wheel "buttons" */ |
2063 | if (ev.button >= 4) |
2109 | if (ev.button >= 4) |
… | |
… | |
2093 | { |
2139 | { |
2094 | case Button1: |
2140 | case Button1: |
2095 | case Button3: |
2141 | case Button3: |
2096 | selection_make (ev.time); |
2142 | selection_make (ev.time); |
2097 | break; |
2143 | break; |
|
|
2144 | |
2098 | case Button2: |
2145 | case Button2: |
2099 | selection_request (ev.time, ev.x, ev.y); |
2146 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2147 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2100 | break; |
2148 | break; |
|
|
2149 | |
2101 | #ifdef MOUSE_WHEEL |
2150 | #ifdef MOUSE_WHEEL |
2102 | case Button4: |
2151 | case Button4: |
2103 | case Button5: |
2152 | case Button5: |
2104 | { |
2153 | { |
2105 | int i; |
2154 | int i; |
… | |
… | |
2127 | slip_wheel_ev.start (); |
2176 | slip_wheel_ev.start (); |
2128 | } |
2177 | } |
2129 | else |
2178 | else |
2130 | { |
2179 | { |
2131 | # endif |
2180 | # endif |
2132 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2133 | scr_page (v, i); |
2181 | scr_page (v, i); |
2134 | scr_refresh (SMOOTH_REFRESH); |
|
|
2135 | scrollbar_show (1); |
2182 | scrollbar_show (1); |
2136 | # else |
|
|
2137 | while (i--) |
|
|
2138 | { |
|
|
2139 | scr_page (v, 1); |
|
|
2140 | scr_refresh (SMOOTH_REFRESH); |
|
|
2141 | scrollbar_show (1); |
|
|
2142 | } |
|
|
2143 | # endif |
|
|
2144 | # ifdef MOUSE_SLIP_WHEELING |
2183 | # ifdef MOUSE_SLIP_WHEELING |
2145 | } |
2184 | } |
2146 | #endif |
2185 | # endif |
2147 | } |
2186 | } |
2148 | break; |
2187 | break; |
2149 | #endif |
2188 | #endif |
2150 | } |
2189 | } |
2151 | } |
2190 | } |
2152 | #ifdef MENUBAR |
|
|
2153 | else if (isMenuBarWindow (ev.window)) |
|
|
2154 | menubar_control (ev); |
|
|
2155 | #endif |
|
|
2156 | } |
2191 | } |
2157 | |
2192 | |
2158 | #ifdef TRANSPARENT |
2193 | #ifdef TRANSPARENT |
2159 | #if TINTING |
2194 | #if TINTING |
2160 | /* taken from aterm-0.4.2 */ |
2195 | /* taken from aterm-0.4.2 */ |
… | |
… | |
2597 | am_transparent = 0; |
2632 | am_transparent = 0; |
2598 | /* XXX: also turn off Opt_transparent? */ |
2633 | /* XXX: also turn off Opt_transparent? */ |
2599 | } |
2634 | } |
2600 | else |
2635 | else |
2601 | { |
2636 | { |
2602 | #if WAIT_FOR_WM |
|
|
2603 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2604 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2605 | sleep (1); |
|
|
2606 | #endif |
|
|
2607 | for (n = 0; n < (unsigned int)i; n++) |
2637 | for (n = 0; n < (unsigned int)i; n++) |
2608 | { |
2638 | { |
2609 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2639 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2610 | XClearWindow (disp, parent[n]); |
2640 | XClearWindow (disp, parent[n]); |
2611 | } |
2641 | } |
… | |
… | |
2640 | |
2670 | |
2641 | bool |
2671 | bool |
2642 | rxvt_term::cmd_parse () |
2672 | rxvt_term::cmd_parse () |
2643 | { |
2673 | { |
2644 | bool flag = false; |
2674 | bool flag = false; |
2645 | unicode_t ch = NOCHAR; |
2675 | wchar_t ch = NOCHAR; |
2646 | unsigned char *seq_begin; // remember start of esc-sequence here |
2676 | char *seq_begin; // remember start of esc-sequence here |
2647 | |
2677 | |
2648 | for (;;) |
2678 | for (;;) |
2649 | { |
2679 | { |
2650 | if (ch == NOCHAR) |
2680 | if (ch == NOCHAR) |
2651 | { |
2681 | { |
2652 | seq_begin = cmdbuf_ptr; |
2682 | seq_begin = cmdbuf_ptr; |
2653 | ch = next_char (); |
2683 | ch = next_char (); |
2654 | } |
|
|
2655 | |
2684 | |
2656 | if (ch == NOCHAR) // TODO: improve |
2685 | if (ch == NOCHAR) |
2657 | break; |
2686 | break; |
|
|
2687 | } |
2658 | |
2688 | |
2659 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2689 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2660 | { |
2690 | { |
2661 | if (!seen_input) |
2691 | if (!seen_input) |
2662 | { |
2692 | { |
… | |
… | |
2671 | if (seen_resize && cmd_pid) |
2701 | if (seen_resize && cmd_pid) |
2672 | kill (-cmd_pid, SIGWINCH); |
2702 | kill (-cmd_pid, SIGWINCH); |
2673 | } |
2703 | } |
2674 | |
2704 | |
2675 | /* Read a text string from the input buffer */ |
2705 | /* Read a text string from the input buffer */ |
2676 | unicode_t buf[UBUFSIZ]; |
2706 | wchar_t buf[UBUFSIZ]; |
2677 | bool refreshnow = false; |
2707 | bool refreshnow = false; |
2678 | int nlines = 0; |
2708 | int nlines = 0; |
2679 | unicode_t *str = buf; |
2709 | wchar_t *str = buf; |
2680 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2710 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2681 | |
2711 | |
2682 | for (;;) |
2712 | for (;;) |
2683 | { |
2713 | { |
2684 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2714 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2685 | break; |
2715 | break; |
… | |
… | |
2695 | |
2725 | |
2696 | if (!OPTION (Opt_jumpScroll) |
2726 | if (!OPTION (Opt_jumpScroll) |
2697 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2727 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2698 | { |
2728 | { |
2699 | refreshnow = true; |
2729 | refreshnow = true; |
|
|
2730 | refresh_count = 0; |
2700 | ch = NOCHAR; |
2731 | ch = NOCHAR; |
2701 | break; |
2732 | break; |
2702 | } |
2733 | } |
2703 | |
2734 | |
2704 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
2705 | if (nlines >= nrow - 1) |
2736 | if (nlines >= nrow - 1) |
2706 | { |
2737 | { |
|
|
2738 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2739 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2707 | scr_add_lines (buf, nlines, str - buf); |
2740 | scr_add_lines (buf, str - buf, nlines); |
|
|
2741 | |
2708 | nlines = 0; |
2742 | nlines = 0; |
2709 | str = buf; |
2743 | str = buf; |
2710 | eol = str + min (ncol, UBUFSIZ); |
2744 | eol = str + min (ncol, UBUFSIZ); |
2711 | } |
2745 | } |
2712 | |
2746 | |
… | |
… | |
2725 | |
2759 | |
2726 | seq_begin = cmdbuf_ptr; |
2760 | seq_begin = cmdbuf_ptr; |
2727 | ch = next_char (); |
2761 | ch = next_char (); |
2728 | } |
2762 | } |
2729 | |
2763 | |
|
|
2764 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2765 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2730 | scr_add_lines (buf, nlines, str - buf); |
2766 | scr_add_lines (buf, str - buf, nlines); |
2731 | |
2767 | |
2732 | /* |
2768 | /* |
2733 | * If there have been a lot of new lines, then update the screen |
2769 | * If there have been a lot of new lines, then update the screen |
2734 | * What the heck I'll cheat and only refresh less than every page-full. |
2770 | * What the heck I'll cheat and only refresh less than every page-full. |
2735 | * the number of pages between refreshes is refresh_limit, which |
2771 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2740 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2776 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2741 | refresh_limit++; |
2777 | refresh_limit++; |
2742 | else |
2778 | else |
2743 | { |
2779 | { |
2744 | flag = true; |
2780 | flag = true; |
2745 | scr_refresh (refresh_type); |
2781 | scr_refresh (); |
|
|
2782 | want_refresh = 1; |
2746 | } |
2783 | } |
2747 | } |
2784 | } |
2748 | |
2785 | |
2749 | } |
2786 | } |
2750 | else |
2787 | else |
… | |
… | |
2765 | } |
2802 | } |
2766 | |
2803 | |
2767 | return flag; |
2804 | return flag; |
2768 | } |
2805 | } |
2769 | |
2806 | |
2770 | // read the next octet |
|
|
2771 | unicode_t |
|
|
2772 | rxvt_term::next_octet () |
|
|
2773 | { |
|
|
2774 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2775 | ? *cmdbuf_ptr++ |
|
|
2776 | : NOCHAR; |
|
|
2777 | } |
|
|
2778 | |
|
|
2779 | // read the next character |
2807 | // read the next character |
2780 | unicode_t |
2808 | wchar_t |
2781 | rxvt_term::next_char () |
2809 | rxvt_term::next_char () NOTHROW |
2782 | { |
2810 | { |
2783 | while (cmdbuf_ptr < cmdbuf_endp) |
2811 | while (cmdbuf_ptr < cmdbuf_endp) |
2784 | { |
2812 | { |
2785 | // assume 7-bit to be ascii ALWAYS |
2813 | // assume 7-bit to be ascii ALWAYS |
2786 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2814 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2787 | return *cmdbuf_ptr++; |
2815 | return *cmdbuf_ptr++; |
2788 | |
2816 | |
2789 | wchar_t wc; |
2817 | wchar_t wc; |
2790 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2818 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2791 | |
2819 | |
2792 | if (len == (size_t)-2) |
2820 | if (len == (size_t)-2) |
2793 | { |
2821 | { |
2794 | // the mbstate stores incomplete sequences. didn't know this :/ |
2822 | // the mbstate stores incomplete sequences. didn't know this :/ |
2795 | cmdbuf_ptr = cmdbuf_endp; |
2823 | cmdbuf_ptr = cmdbuf_endp; |
2796 | break; |
2824 | break; |
2797 | } |
2825 | } |
2798 | |
2826 | |
2799 | if (len == (size_t)-1) |
2827 | if (len == (size_t)-1) |
2800 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2828 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2801 | |
2829 | |
2802 | // assume wchar == unicode |
2830 | // assume wchar == unicode |
2803 | cmdbuf_ptr += len; |
2831 | cmdbuf_ptr += len; |
2804 | return wc & UNICODE_MASK; |
2832 | return wc & UNICODE_MASK; |
2805 | } |
2833 | } |
2806 | |
2834 | |
2807 | return NOCHAR; |
2835 | return NOCHAR; |
2808 | } |
2836 | } |
|
|
2837 | |
|
|
2838 | // read the next octet |
|
|
2839 | uint32_t |
|
|
2840 | rxvt_term::next_octet () NOTHROW |
|
|
2841 | { |
|
|
2842 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2843 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2844 | : NOCHAR; |
|
|
2845 | } |
|
|
2846 | |
|
|
2847 | static class out_of_input out_of_input; |
2809 | |
2848 | |
2810 | /* rxvt_cmd_getc () - Return next input character */ |
2849 | /* rxvt_cmd_getc () - Return next input character */ |
2811 | /* |
2850 | /* |
2812 | * Return the next input character after first passing any keyboard input |
2851 | * Return the next input character after first passing any keyboard input |
2813 | * to the command. |
2852 | * to the command. |
2814 | */ |
2853 | */ |
2815 | unicode_t |
2854 | wchar_t |
2816 | rxvt_term::cmd_getc () |
2855 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2817 | { |
2856 | { |
2818 | unicode_t c = next_char (); |
2857 | wchar_t c = next_char (); |
2819 | |
2858 | |
2820 | if (c == NOCHAR) |
2859 | if (c == NOCHAR) |
2821 | throw out_of_input; |
2860 | throw out_of_input; |
2822 | |
2861 | |
2823 | return c; |
2862 | return c; |
2824 | } |
2863 | } |
2825 | |
2864 | |
2826 | unicode_t |
2865 | uint32_t |
2827 | rxvt_term::cmd_get8 () |
2866 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2828 | { |
2867 | { |
2829 | unicode_t c = next_octet (); |
2868 | uint32_t c = next_octet (); |
2830 | |
2869 | |
2831 | if (c == NOCHAR) |
2870 | if (c == NOCHAR) |
2832 | throw out_of_input; |
2871 | throw out_of_input; |
2833 | |
2872 | |
2834 | return c; |
2873 | return c; |
… | |
… | |
2934 | case C0_ESC: |
2973 | case C0_ESC: |
2935 | process_escape_seq (); |
2974 | process_escape_seq (); |
2936 | break; |
2975 | break; |
2937 | case C0_ENQ: /* terminal Status */ |
2976 | case C0_ENQ: /* terminal Status */ |
2938 | if (rs[Rs_answerbackstring]) |
2977 | if (rs[Rs_answerbackstring]) |
2939 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2978 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2940 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2941 | else |
2979 | else |
2942 | tt_write ((unsigned char *)VT100_ANS, |
2980 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2943 | (unsigned int)strlen (VT100_ANS)); |
|
|
2944 | break; |
2981 | break; |
2945 | case C0_BEL: /* bell */ |
2982 | case C0_BEL: /* bell */ |
2946 | scr_bell (); |
2983 | scr_bell (); |
2947 | break; |
2984 | break; |
2948 | case C0_BS: /* backspace */ |
2985 | case C0_BS: /* backspace */ |
… | |
… | |
3103 | break; |
3140 | break; |
3104 | |
3141 | |
3105 | /* 8.3.87: NEXT LINE */ |
3142 | /* 8.3.87: NEXT LINE */ |
3106 | case C1_NEL: /* ESC E */ |
3143 | case C1_NEL: /* ESC E */ |
3107 | { |
3144 | { |
3108 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3145 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3109 | scr_add_lines (nlcr, 1, 2); |
3146 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3110 | } |
3147 | } |
3111 | break; |
3148 | break; |
3112 | |
3149 | |
3113 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3150 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3114 | case C1_ESA: /* ESC G */ |
3151 | case C1_ESA: /* ESC G */ |
… | |
… | |
3136 | process_dcs_seq (); |
3173 | process_dcs_seq (); |
3137 | break; |
3174 | break; |
3138 | |
3175 | |
3139 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3176 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3140 | case C1_SCI: /* ESC Z */ |
3177 | case C1_SCI: /* ESC Z */ |
3141 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3178 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3142 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3143 | break; /* steal obsolete ESC [ c */ |
3179 | break; /* steal obsolete ESC [ c */ |
3144 | |
3180 | |
3145 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3181 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3146 | case C1_CSI: /* ESC [ */ |
3182 | case C1_CSI: /* ESC [ */ |
3147 | process_csi_seq (); |
3183 | process_csi_seq (); |
… | |
… | |
3272 | { |
3308 | { |
3273 | switch (priv) |
3309 | switch (priv) |
3274 | { |
3310 | { |
3275 | case '>': |
3311 | case '>': |
3276 | if (ch == CSI_DA) /* secondary device attributes */ |
3312 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3313 | { |
|
|
3314 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3315 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3316 | // |
|
|
3317 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3318 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3319 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3320 | // |
3277 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3321 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3322 | } |
3278 | break; |
3323 | break; |
3279 | case '?': |
3324 | case '?': |
3280 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3325 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3281 | process_terminal_mode (ch, priv, nargs, arg); |
3326 | process_terminal_mode (ch, priv, nargs, arg); |
3282 | break; |
3327 | break; |
… | |
… | |
3391 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3436 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3392 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3437 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3393 | break; |
3438 | break; |
3394 | |
3439 | |
3395 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3440 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3396 | tt_write ((const unsigned char *)VT100_ANS, |
3441 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3397 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3398 | break; |
3442 | break; |
3399 | |
3443 | |
3400 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3444 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3401 | process_sgr_mode (nargs, arg); |
3445 | process_sgr_mode (nargs, arg); |
3402 | break; |
3446 | break; |
… | |
… | |
3604 | /*----------------------------------------------------------------------*/ |
3648 | /*----------------------------------------------------------------------*/ |
3605 | /* |
3649 | /* |
3606 | * get input up until STRING TERMINATOR (or BEL) |
3650 | * get input up until STRING TERMINATOR (or BEL) |
3607 | * ends_how is terminator used. returned input must be free()'d |
3651 | * ends_how is terminator used. returned input must be free()'d |
3608 | */ |
3652 | */ |
3609 | unsigned char * |
3653 | char * |
3610 | rxvt_term::get_to_st (unicode_t &ends_how) |
3654 | rxvt_term::get_to_st (unicode_t &ends_how) |
3611 | { |
3655 | { |
3612 | unicode_t ch; |
3656 | unicode_t ch; |
3613 | bool seen_esc = false; |
3657 | bool seen_esc = false; |
3614 | unsigned int n = 0; |
3658 | unsigned int n = 0; |
… | |
… | |
3647 | |
3691 | |
3648 | string[n++] = '\0'; |
3692 | string[n++] = '\0'; |
3649 | |
3693 | |
3650 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3694 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3651 | |
3695 | |
3652 | return (unsigned char *)rxvt_wcstombs (string); |
3696 | return rxvt_wcstombs (string); |
3653 | } |
3697 | } |
3654 | |
3698 | |
3655 | /*----------------------------------------------------------------------*/ |
3699 | /*----------------------------------------------------------------------*/ |
3656 | /* |
3700 | /* |
3657 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3701 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3658 | */ |
3702 | */ |
3659 | void |
3703 | void |
3660 | rxvt_term::process_dcs_seq () |
3704 | rxvt_term::process_dcs_seq () |
3661 | { |
3705 | { |
3662 | unsigned char *s; |
3706 | char *s; |
3663 | unicode_t eh; |
3707 | unicode_t eh; |
3664 | |
3708 | |
3665 | /* |
3709 | /* |
3666 | * Not handled yet |
3710 | * Not handled yet |
3667 | */ |
3711 | */ |
… | |
… | |
3686 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3730 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3687 | arg = arg * 10 + (ch - '0'); |
3731 | arg = arg * 10 + (ch - '0'); |
3688 | |
3732 | |
3689 | if (ch == ';') |
3733 | if (ch == ';') |
3690 | { |
3734 | { |
3691 | unsigned char *s = get_to_st (eh); |
3735 | char *s = get_to_st (eh); |
3692 | |
3736 | |
3693 | if (s) |
3737 | if (s) |
3694 | { |
3738 | { |
3695 | process_xterm_seq (arg, (char *)s, eh); |
3739 | process_xterm_seq (arg, s, eh); |
3696 | free (s); |
3740 | free (s); |
3697 | } |
3741 | } |
3698 | } |
3742 | } |
3699 | } |
3743 | } |
3700 | |
3744 | |
3701 | void |
3745 | void |
3702 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3746 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3703 | { |
3747 | { |
3704 | if (str[0] == '?' && !str[1]) |
3748 | if (str[0] == '?' && !str[1]) |
3705 | { |
3749 | { |
3706 | unsigned short r, g, b; |
3750 | unsigned short r, g, b; |
3707 | pix_colors_focused[color].get (display, r, g, b); |
3751 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3713 | |
3757 | |
3714 | /* |
3758 | /* |
3715 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3759 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3716 | */ |
3760 | */ |
3717 | void |
3761 | void |
3718 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3762 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3719 | { |
3763 | { |
3720 | int changed = 0; |
|
|
3721 | int color; |
3764 | int color; |
3722 | char *buf, *name; |
3765 | char *buf, *name; |
3723 | bool query = str[0] == '?' && !str[1]; |
3766 | bool query = str[0] == '?' && !str[1]; |
3724 | int saveop = op; |
3767 | int saveop = op; |
3725 | dDisp; |
3768 | dDisp; |
… | |
… | |
3780 | { |
3823 | { |
3781 | if ((name = strchr (buf, ';')) == NULL) |
3824 | if ((name = strchr (buf, ';')) == NULL) |
3782 | break; |
3825 | break; |
3783 | |
3826 | |
3784 | *name++ = '\0'; |
3827 | *name++ = '\0'; |
3785 | color = atoi (buf); |
3828 | color = atoi (buf) + minCOLOR; |
3786 | |
3829 | |
3787 | if (color < 0 || color >= TOTAL_COLORS) |
3830 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3788 | break; |
3831 | break; |
3789 | |
3832 | |
3790 | if ((buf = strchr (name, ';')) != NULL) |
3833 | if ((buf = strchr (name, ';')) != NULL) |
3791 | *buf++ = '\0'; |
3834 | *buf++ = '\0'; |
3792 | |
3835 | |
3793 | if (name[0] == '?' && !name[1]) |
3836 | if (name[0] == '?' && !name[1]) |
3794 | { |
3837 | { |
3795 | unsigned short r, g, b; |
3838 | unsigned short r, g, b; |
3796 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3839 | pix_colors_focused[color].get (display, r, g, b); |
3797 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3840 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3798 | } |
3841 | } |
3799 | else |
3842 | else |
3800 | set_window_color (color + minCOLOR, name); |
3843 | set_window_color (color, name); |
3801 | } |
3844 | } |
3802 | break; |
3845 | break; |
3803 | case XTerm_Color00: |
3846 | case XTerm_Color00: |
3804 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3847 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3805 | break; |
3848 | break; |
3806 | case XTerm_Color01: |
3849 | case XTerm_Color01: |
3807 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3850 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3808 | break; |
3851 | break; |
3809 | #ifndef NO_CURSORCOLOR |
3852 | #ifndef NO_CURSORCOLOR |
3810 | case XTerm_Color_cursor: |
3853 | case XTerm_Color_cursor: |
3811 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3854 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3812 | break; |
3855 | break; |
… | |
… | |
3816 | break; |
3859 | break; |
3817 | case XTerm_Color_pointer_bg: |
3860 | case XTerm_Color_pointer_bg: |
3818 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3861 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3819 | break; |
3862 | break; |
3820 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3863 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3821 | case XTerm_Color_BD: |
|
|
3822 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3823 | break; |
|
|
3824 | case XTerm_Color_UL: |
|
|
3825 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3826 | break; |
|
|
3827 | case XTerm_Color_RV: |
3864 | case XTerm_Color_RV: |
3828 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3865 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3866 | break; |
|
|
3867 | case Rxvt_Color_BD: |
|
|
3868 | case URxvt_Color_BD: |
|
|
3869 | process_color_seq (op, Color_BD, str, resp); |
|
|
3870 | break; |
|
|
3871 | case Rxvt_Color_UL: |
|
|
3872 | case URxvt_Color_UL: |
|
|
3873 | process_color_seq (op, Color_UL, str, resp); |
3829 | break; |
3874 | break; |
3830 | case URxvt_Color_IT: |
3875 | case URxvt_Color_IT: |
3831 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3876 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3832 | break; |
3877 | break; |
3833 | #endif |
3878 | #endif |
… | |
… | |
3838 | if (am_transparent) |
3883 | if (am_transparent) |
3839 | want_full_refresh = want_refresh = 1; |
3884 | want_full_refresh = want_refresh = 1; |
3840 | break; |
3885 | break; |
3841 | #endif |
3886 | #endif |
3842 | |
3887 | |
3843 | case XTerm_Pixmap: |
3888 | case Rxvt_Pixmap: |
|
|
3889 | { |
3844 | if (*str != ';') |
3890 | if (*str != ';') |
3845 | { |
3891 | { |
3846 | #if XPM_BACKGROUND |
3892 | #if XPM_BACKGROUND |
3847 | scale_pixmap (""); /* reset to default scaling */ |
3893 | scale_pixmap (""); /* reset to default scaling */ |
3848 | set_bgPixmap (str); /* change pixmap */ |
3894 | set_bgPixmap (str); /* change pixmap */ |
3849 | #endif |
|
|
3850 | scr_touch (true); |
3895 | scr_touch (true); |
|
|
3896 | #endif |
3851 | } |
3897 | } |
|
|
3898 | |
|
|
3899 | int changed = 0; |
|
|
3900 | |
3852 | while ((str = strchr (str, ';')) != NULL) |
3901 | while ((str = strchr (str, ';')) != NULL) |
3853 | { |
3902 | { |
3854 | str++; |
3903 | str++; |
3855 | #if XPM_BACKGROUND |
3904 | #if XPM_BACKGROUND |
3856 | changed += scale_pixmap (str); |
3905 | changed += scale_pixmap (str); |
3857 | #endif |
3906 | #endif |
3858 | } |
3907 | } |
3859 | |
3908 | |
3860 | if (changed) |
3909 | if (changed) |
3861 | { |
3910 | { |
3862 | #ifdef XPM_BACKGROUND |
3911 | #ifdef XPM_BACKGROUND |
3863 | resize_pixmap (); |
3912 | resize_pixmap (); |
3864 | #endif |
|
|
3865 | scr_touch (true); |
3913 | scr_touch (true); |
|
|
3914 | #endif |
3866 | } |
3915 | } |
|
|
3916 | } |
3867 | break; |
3917 | break; |
3868 | |
3918 | |
3869 | case XTerm_restoreFG: |
3919 | case Rxvt_restoreFG: |
3870 | set_window_color (Color_fg, str); |
3920 | set_window_color (Color_fg, str); |
3871 | break; |
3921 | break; |
3872 | case XTerm_restoreBG: |
3922 | case Rxvt_restoreBG: |
3873 | set_window_color (Color_bg, str); |
3923 | set_window_color (Color_bg, str); |
3874 | break; |
3924 | break; |
3875 | |
3925 | |
3876 | case XTerm_logfile: |
3926 | case XTerm_logfile: |
3877 | // TODO, when secure mode? |
3927 | // TODO, when secure mode? |
3878 | break; |
3928 | break; |
3879 | |
3929 | |
3880 | #ifdef MENUBAR |
|
|
3881 | case URxvt_Menu: |
|
|
3882 | if (OPTION (Opt_insecure)) |
|
|
3883 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3884 | break; |
|
|
3885 | #endif |
|
|
3886 | #if 0 |
3930 | #if 0 |
3887 | case XTerm_dumpscreen: /* no error notices */ |
3931 | case Rxvt_dumpscreen: /* no error notices */ |
3888 | { |
3932 | { |
3889 | int fd; |
3933 | int fd; |
3890 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3934 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3891 | { |
3935 | { |
3892 | scr_dump (fd); |
3936 | scr_dump (fd); |
… | |
… | |
3923 | if (query) |
3967 | if (query) |
3924 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3968 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3925 | else |
3969 | else |
3926 | { |
3970 | { |
3927 | set_locale (str); |
3971 | set_locale (str); |
3928 | pty.set_utf8_mode (enc_utf8); |
3972 | pty->set_utf8_mode (enc_utf8); |
3929 | init_xlocale (); |
3973 | init_xlocale (); |
3930 | } |
3974 | } |
3931 | break; |
3975 | break; |
3932 | |
3976 | |
3933 | case URxvt_view_up: |
3977 | case URxvt_view_up: |
3934 | case URxvt_view_down: |
3978 | case URxvt_view_down: |
|
|
3979 | { |
3935 | int lines = atoi (str); |
3980 | int lines = atoi (str); |
3936 | |
3981 | |
3937 | if (lines) |
3982 | if (lines) |
3938 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3983 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3939 | else |
3984 | else |
3940 | { |
|
|
3941 | scr_erase_savelines (); |
3985 | scr_erase_savelines (); |
3942 | } |
3986 | } |
3943 | |
3987 | |
|
|
3988 | break; |
|
|
3989 | #endif |
|
|
3990 | |
|
|
3991 | #if ENABLE_PERL |
|
|
3992 | case URxvt_perl: |
|
|
3993 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
3994 | ; // no responses yet |
3944 | break; |
3995 | break; |
3945 | #endif |
3996 | #endif |
3946 | } |
3997 | } |
3947 | } |
3998 | } |
3948 | /*----------------------------------------------------------------------*/ |
3999 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3979 | return state; |
4030 | return state; |
3980 | } |
4031 | } |
3981 | |
4032 | |
3982 | /* we're not using priv _yet_ */ |
4033 | /* we're not using priv _yet_ */ |
3983 | void |
4034 | void |
3984 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4035 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3985 | { |
4036 | { |
3986 | unsigned int i, j; |
4037 | unsigned int i, j; |
3987 | int state; |
4038 | int state; |
3988 | |
4039 | |
3989 | static const struct |
4040 | static const struct |
… | |
… | |
4000 | { 5, PrivMode_rVideo }, |
4051 | { 5, PrivMode_rVideo }, |
4001 | { 6, PrivMode_relOrigin }, |
4052 | { 6, PrivMode_relOrigin }, |
4002 | { 7, PrivMode_Autowrap }, |
4053 | { 7, PrivMode_Autowrap }, |
4003 | // 8, bi-directional support mode |
4054 | // 8, bi-directional support mode |
4004 | { 9, PrivMode_MouseX10 }, |
4055 | { 9, PrivMode_MouseX10 }, |
4005 | #ifdef menuBar_esc |
|
|
4006 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4007 | #endif |
|
|
4008 | // 18, 19 printing-related |
4056 | // 18, 19 printing-related |
4009 | { 25, PrivMode_VisibleCursor }, |
4057 | { 25, PrivMode_VisibleCursor }, |
4010 | #ifdef scrollBar_esc |
4058 | #ifdef scrollBar_esc |
4011 | { scrollBar_esc, PrivMode_scrollBar }, |
4059 | { scrollBar_esc, PrivMode_scrollBar }, |
4012 | #endif |
4060 | #endif |
… | |
… | |
4059 | /* extra handling for values with state unkept */ |
4107 | /* extra handling for values with state unkept */ |
4060 | switch (arg[i]) |
4108 | switch (arg[i]) |
4061 | { |
4109 | { |
4062 | #if ENABLE_STYLES |
4110 | #if ENABLE_STYLES |
4063 | case 1021: |
4111 | case 1021: |
4064 | if (mode) |
4112 | set_option (Opt_intensityStyles, mode); |
4065 | SET_OPTION (Opt_intensityStyles); |
|
|
4066 | else |
|
|
4067 | CLR_OPTION (Opt_intensityStyles); |
|
|
4068 | |
4113 | |
4069 | want_refresh = 1; |
4114 | scr_touch (true); |
4070 | want_full_refresh = 1; |
|
|
4071 | break; |
4115 | break; |
4072 | #endif |
4116 | #endif |
4073 | case 1048: /* alternative cursor save */ |
4117 | case 1048: /* alternative cursor save */ |
4074 | case 1049: |
4118 | case 1049: |
4075 | if (OPTION (Opt_secondaryScreen)) |
4119 | if (OPTION (Opt_secondaryScreen)) |
… | |
… | |
4095 | case 3: /* 80/132 */ |
4139 | case 3: /* 80/132 */ |
4096 | if (priv_modes & PrivMode_132OK) |
4140 | if (priv_modes & PrivMode_132OK) |
4097 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4141 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4098 | break; |
4142 | break; |
4099 | case 4: /* smooth scrolling */ |
4143 | case 4: /* smooth scrolling */ |
4100 | if (!state) |
4144 | set_option (Opt_jumpScroll, !state); |
4101 | SET_OPTION (Opt_jumpScroll); |
|
|
4102 | else |
|
|
4103 | CLR_OPTION (Opt_jumpScroll); |
|
|
4104 | break; |
4145 | break; |
4105 | case 5: /* reverse video */ |
4146 | case 5: /* reverse video */ |
4106 | scr_rvideo_mode (state); |
4147 | scr_rvideo_mode (state); |
4107 | break; |
4148 | break; |
4108 | case 6: /* relative/absolute origins */ |
4149 | case 6: /* relative/absolute origins */ |
… | |
… | |
4114 | /* case 8: - auto repeat, can't do on a per window basis */ |
4155 | /* case 8: - auto repeat, can't do on a per window basis */ |
4115 | case 9: /* X10 mouse reporting */ |
4156 | case 9: /* X10 mouse reporting */ |
4116 | if (state) /* orthogonal */ |
4157 | if (state) /* orthogonal */ |
4117 | priv_modes &= ~PrivMode_MouseX11; |
4158 | priv_modes &= ~PrivMode_MouseX11; |
4118 | break; |
4159 | break; |
4119 | #ifdef menuBar_esc |
|
|
4120 | case menuBar_esc: |
|
|
4121 | #ifdef MENUBAR |
|
|
4122 | map_menuBar (state); |
|
|
4123 | #endif |
|
|
4124 | break; |
|
|
4125 | #endif |
|
|
4126 | #ifdef scrollBar_esc |
4160 | #ifdef scrollBar_esc |
4127 | case scrollBar_esc: |
4161 | case scrollBar_esc: |
4128 | if (scrollbar_mapping (state)) |
4162 | if (scrollbar_mapping (state)) |
4129 | { |
4163 | { |
4130 | resize_all_windows (0, 0, 0); |
4164 | resize_all_windows (0, 0, 0); |
… | |
… | |
4149 | #if 0 |
4183 | #if 0 |
4150 | case 1001: |
4184 | case 1001: |
4151 | break; /* X11 mouse highlighting */ |
4185 | break; /* X11 mouse highlighting */ |
4152 | #endif |
4186 | #endif |
4153 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4187 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4154 | if (!state) |
4188 | set_option (Opt_scrollTtyOutput, !state); |
4155 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4156 | else |
|
|
4157 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4158 | break; |
4189 | break; |
4159 | case 1011: /* scroll to bottom on key press */ |
4190 | case 1011: /* scroll to bottom on key press */ |
4160 | if (state) |
4191 | set_option (Opt_scrollTtyKeypress, state); |
4161 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4162 | else |
|
|
4163 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4164 | break; |
4192 | break; |
4165 | case 1047: /* secondary screen w/ clearing last */ |
4193 | case 1047: /* secondary screen w/ clearing last */ |
4166 | if (OPTION (Opt_secondaryScreen)) |
4194 | if (OPTION (Opt_secondaryScreen)) |
4167 | if (current_screen != PRIMARY) |
4195 | if (current_screen != PRIMARY) |
4168 | scr_erase_screen (2); |
4196 | scr_erase_screen (2); |
… | |
… | |
4306 | scr_color (Color_bg, Color_bg); |
4334 | scr_color (Color_bg, Color_bg); |
4307 | break; |
4335 | break; |
4308 | |
4336 | |
4309 | //case 50: // not variable spacing |
4337 | //case 50: // not variable spacing |
4310 | |
4338 | |
4311 | #ifndef NO_BRIGHTCOLOR |
4339 | #if ENABLE_FRILLS |
4312 | case 90: |
4340 | case 90: |
4313 | case 91: /* set bright fg color */ |
4341 | case 91: /* set bright fg color */ |
4314 | case 92: |
4342 | case 92: |
4315 | case 93: |
4343 | case 93: |
4316 | case 94: |
4344 | case 94: |
… | |
… | |
4361 | */ |
4389 | */ |
4362 | void |
4390 | void |
4363 | rxvt_term::tt_printf (const char *fmt,...) |
4391 | rxvt_term::tt_printf (const char *fmt,...) |
4364 | { |
4392 | { |
4365 | va_list arg_ptr; |
4393 | va_list arg_ptr; |
4366 | unsigned char buf[256]; |
4394 | char buf[256]; |
4367 | |
4395 | |
4368 | va_start (arg_ptr, fmt); |
4396 | va_start (arg_ptr, fmt); |
4369 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4397 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4370 | va_end (arg_ptr); |
4398 | va_end (arg_ptr); |
4371 | tt_write (buf, strlen (buf)); |
4399 | tt_write (buf, strlen (buf)); |
… | |
… | |
4376 | * or generated by us in response to a query ESC sequence. |
4404 | * or generated by us in response to a query ESC sequence. |
4377 | */ |
4405 | */ |
4378 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4406 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4379 | |
4407 | |
4380 | void |
4408 | void |
4381 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4409 | rxvt_term::tt_write (const char *data, unsigned int len) |
4382 | { |
4410 | { |
|
|
4411 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4412 | return; |
|
|
4413 | |
|
|
4414 | if (pty->pty < 0) |
|
|
4415 | return; |
|
|
4416 | |
4383 | if (v_buflen == 0) |
4417 | if (v_buflen == 0) |
4384 | { |
4418 | { |
4385 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4419 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4386 | |
4420 | |
4387 | if ((unsigned int)written == len) |
4421 | if ((unsigned int)written == len) |
4388 | return; |
4422 | return; |
4389 | |
4423 | |
4390 | data += written; |
4424 | data += written; |
4391 | len -= written; |
4425 | len -= written; |
4392 | } |
4426 | } |
4393 | |
4427 | |
4394 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4428 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4395 | |
4429 | |
4396 | memcpy (v_buffer + v_buflen, data, len); |
4430 | memcpy (v_buffer + v_buflen, data, len); |
4397 | v_buflen += len; |
4431 | v_buflen += len; |
4398 | |
4432 | |
4399 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4433 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4400 | } |
4434 | } |
4401 | |
4435 | |
4402 | void rxvt_term::pty_write () |
4436 | void rxvt_term::pty_write () |
4403 | { |
4437 | { |
4404 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4438 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4405 | |
4439 | |
4406 | if (written > 0) |
4440 | if (written > 0) |
4407 | { |
4441 | { |
4408 | v_buflen -= written; |
4442 | v_buflen -= written; |
4409 | |
4443 | |