… | |
… | |
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 | { |
… | |
… | |
262 | mb[0] = ch[0]; |
265 | mb[0] = ch[0]; |
263 | len = 1; |
266 | len = 1; |
264 | } |
267 | } |
265 | |
268 | |
266 | if (len > 0) |
269 | if (len > 0) |
267 | tt_write ((unsigned char *)mb, len); |
270 | tt_write (mb, len); |
268 | else |
271 | else |
269 | scr_bell (); |
272 | scr_bell (); |
270 | } |
273 | } |
271 | |
274 | |
272 | iso14755buf = 0; |
275 | iso14755buf = 0; |
… | |
… | |
300 | KeySym keysym; |
303 | KeySym keysym; |
301 | #ifdef DEBUG_CMD |
304 | #ifdef DEBUG_CMD |
302 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | static int debug_key = 1; /* accessible by a debugger only */ |
303 | #endif |
306 | #endif |
304 | int valid_keysym; |
307 | int valid_keysym; |
305 | unsigned char kbuf[KBUFSZ]; |
308 | char kbuf[KBUFSZ]; |
306 | |
309 | |
307 | /* |
310 | /* |
308 | * 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 |
309 | * escape sequence to toggle the Keypad. |
312 | * escape sequence to toggle the Keypad. |
310 | * |
313 | * |
… | |
… | |
328 | Status status_return; |
331 | Status status_return; |
329 | |
332 | |
330 | #if 0 |
333 | #if 0 |
331 | #ifdef X_HAVE_UTF8_STRING |
334 | #ifdef X_HAVE_UTF8_STRING |
332 | 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 |
333 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
336 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
334 | KBUFSZ, &keysym, &status_return); |
337 | KBUFSZ, &keysym, &status_return); |
335 | else |
338 | else |
336 | #endif |
339 | #endif |
337 | #endif |
340 | #endif |
338 | { |
341 | { |
… | |
… | |
375 | || status_return == XLookupBoth; |
378 | || status_return == XLookupBoth; |
376 | } |
379 | } |
377 | else |
380 | else |
378 | #endif |
381 | #endif |
379 | { |
382 | { |
380 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
383 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
381 | valid_keysym = keysym != NoSymbol; |
384 | valid_keysym = keysym != NoSymbol; |
382 | } |
385 | } |
383 | |
386 | |
384 | if (valid_keysym) |
387 | if (valid_keysym) |
385 | { |
388 | { |
… | |
… | |
437 | scr_move_to (0, 1); |
440 | scr_move_to (0, 1); |
438 | return; |
441 | return; |
439 | } |
442 | } |
440 | else if (keysym == XK_End) |
443 | else if (keysym == XK_End) |
441 | { |
444 | { |
442 | scr_move_to (1, 0); |
445 | scr_move_to (1, 1); |
443 | return; |
446 | return; |
444 | } |
447 | } |
445 | } |
448 | } |
446 | #endif |
449 | #endif |
447 | } |
450 | } |
… | |
… | |
458 | { |
461 | { |
459 | switch (keysym) |
462 | switch (keysym) |
460 | { |
463 | { |
461 | /* normal XTerm key bindings */ |
464 | /* normal XTerm key bindings */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
465 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
463 | selection_request (ev.time, 0, 0); |
466 | selection_request (ev.time); |
464 | return; |
467 | return; |
465 | #if TODO |
468 | #if TODO |
466 | /* rxvt extras */ |
469 | /* rxvt extras */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
470 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
468 | change_font (FONT_UP); |
471 | change_font (FONT_UP); |
… | |
… | |
849 | { |
852 | { |
850 | #ifdef META8_OPTION |
853 | #ifdef META8_OPTION |
851 | /* set 8-bit on */ |
854 | /* set 8-bit on */ |
852 | if (meta && (meta_char == 0x80)) |
855 | if (meta && (meta_char == 0x80)) |
853 | { |
856 | { |
854 | unsigned char *ch; |
857 | char *ch; |
855 | |
858 | |
856 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | for (ch = kbuf; ch < kbuf + len; ch++) |
857 | *ch |= 0x80; |
860 | *ch |= 0x80; |
858 | |
861 | |
859 | meta = 0; |
862 | meta = 0; |
860 | } |
863 | } |
861 | #endif |
864 | #endif |
862 | /* nil */ ; |
865 | /* nil */ ; |
863 | } |
866 | } |
864 | } |
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; |
865 | |
871 | |
866 | if (len <= 0) |
872 | if (len <= 0) |
867 | return; /* not mapped */ |
873 | return; /* not mapped */ |
868 | |
874 | |
869 | if (OPTION (Opt_scrollTtyKeypress)) |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
892 | #ifdef META8_OPTION |
898 | #ifdef META8_OPTION |
893 | && meta_char == C0_ESC |
899 | && meta_char == C0_ESC |
894 | #endif |
900 | #endif |
895 | ) |
901 | ) |
896 | { |
902 | { |
897 | const unsigned char ch = C0_ESC; |
903 | const char ch = C0_ESC; |
898 | tt_write (&ch, 1); |
904 | tt_write (&ch, 1); |
899 | } |
905 | } |
900 | |
906 | |
901 | #if defined(DEBUG_CMD) |
907 | #if defined(DEBUG_CMD) |
902 | /* Display keyboard buffer contents */ |
908 | /* Display keyboard buffer contents */ |
… | |
… | |
910 | #endif /* DEBUG_CMD */ |
916 | #endif /* DEBUG_CMD */ |
911 | tt_write (kbuf, (unsigned int)len); |
917 | tt_write (kbuf, (unsigned int)len); |
912 | } |
918 | } |
913 | /*}}} */ |
919 | /*}}} */ |
914 | |
920 | |
915 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
921 | #if defined (KEYSYM_RESOURCE) |
916 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
917 | /* attempt to `write' count to the input buffer */ |
|
|
918 | unsigned int |
922 | unsigned int |
919 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
923 | rxvt_term::cmd_write (const char *str, unsigned int count) |
920 | { |
924 | { |
921 | unsigned int n, s; |
925 | unsigned int n, s; |
922 | |
926 | |
923 | n = cmdbuf_ptr - cmdbuf_base; |
927 | n = cmdbuf_ptr - cmdbuf_base; |
924 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
928 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
961 | } |
965 | } |
962 | #endif |
966 | #endif |
963 | |
967 | |
964 | if (want_refresh) |
968 | if (want_refresh) |
965 | { |
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 | |
966 | scr_refresh (refresh_type); |
1008 | scr_refresh (); |
967 | scrollbar_show (1); |
1009 | scrollbar_show (1); |
968 | #ifdef USE_XIM |
1010 | #ifdef USE_XIM |
969 | IMSendSpot (); |
1011 | IMSendSpot (); |
970 | #endif |
1012 | #endif |
971 | } |
1013 | } |
… | |
… | |
974 | } |
1016 | } |
975 | |
1017 | |
976 | void |
1018 | void |
977 | rxvt_term::check_cb (check_watcher &w) |
1019 | rxvt_term::check_cb (check_watcher &w) |
978 | { |
1020 | { |
979 | SET_R (this); |
1021 | make_current (); |
980 | SET_LOCALE (locale); |
|
|
981 | |
1022 | |
982 | display->flush (); |
1023 | display->flush (); |
983 | |
1024 | |
984 | if (want_refresh && !flush_ev.active) |
1025 | if (want_refresh && !flush_ev.active) |
985 | flush_ev.start (NOW + 0.01); |
1026 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
986 | } |
1027 | } |
987 | |
1028 | |
988 | void |
1029 | void |
989 | rxvt_term::flush_cb (time_watcher &w) |
1030 | rxvt_term::flush_cb (time_watcher &w) |
990 | { |
1031 | { |
991 | SET_R (this); |
1032 | make_current (); |
992 | SET_LOCALE (locale); |
|
|
993 | |
1033 | |
994 | refresh_limit = 1; |
1034 | refresh_limit = 1; |
995 | refresh_count = 0; |
1035 | refresh_count = 0; |
996 | flush (); |
1036 | flush (); |
997 | } |
1037 | } |
… | |
… | |
1001 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1041 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1002 | { |
1042 | { |
1003 | hidden_cursor = !hidden_cursor; |
1043 | hidden_cursor = !hidden_cursor; |
1004 | want_refresh = 1; |
1044 | want_refresh = 1; |
1005 | |
1045 | |
1006 | w.start (w.at + BLINK_INTERVAL); |
1046 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1007 | } |
1047 | } |
1008 | #endif |
1048 | #endif |
1009 | |
1049 | |
1010 | #ifdef TEXT_BLINK |
1050 | #ifdef TEXT_BLINK |
1011 | void |
1051 | void |
… | |
… | |
1025 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1065 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1026 | { |
1066 | { |
1027 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1067 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1028 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1068 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1029 | { |
1069 | { |
1030 | refresh_type |= SMOOTH_REFRESH; |
|
|
1031 | want_refresh = 1; |
1070 | want_refresh = 1; |
1032 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1033 | } |
1072 | } |
1034 | } |
1073 | } |
1035 | #endif |
1074 | #endif |
… | |
… | |
1039 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1078 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1040 | { |
1079 | { |
1041 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1080 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1042 | { |
1081 | { |
1043 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1082 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1044 | refresh_type |= SMOOTH_REFRESH; |
|
|
1045 | want_refresh = 1; |
1083 | want_refresh = 1; |
1046 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1084 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1047 | } |
1085 | } |
1048 | } |
1086 | } |
1049 | #endif |
1087 | #endif |
… | |
… | |
1054 | { |
1092 | { |
1055 | if (mouse_slip_wheel_speed == 0 |
1093 | if (mouse_slip_wheel_speed == 0 |
1056 | || 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) |
1057 | : scr_page (UP, mouse_slip_wheel_speed)) |
1095 | : scr_page (UP, mouse_slip_wheel_speed)) |
1058 | { |
1096 | { |
1059 | if (view_start == nsaved || |
1097 | if (view_start == top_row || view_start == 0) |
1060 | view_start == 0) |
|
|
1061 | mouse_slip_wheel_speed = 0; |
1098 | mouse_slip_wheel_speed = 0; |
1062 | |
1099 | |
1063 | refresh_type |= SMOOTH_REFRESH; |
|
|
1064 | want_refresh = 1; |
1100 | want_refresh = 1; |
1065 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1101 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1066 | } |
1102 | } |
1067 | } |
1103 | } |
1068 | #endif |
1104 | #endif |
1069 | |
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 | |
1070 | bool |
1124 | bool |
1071 | rxvt_term::pty_fill () |
1125 | rxvt_term::pty_fill () |
1072 | { |
1126 | { |
1073 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1127 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1074 | |
1128 | |
1075 | if (CBUFSIZ == n) |
1129 | if (CBUFSIZ == n) |
1076 | { |
1130 | { |
1077 | 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"); |
1078 | n = 0; |
1132 | n = 0; |
1079 | } |
1133 | } |
1080 | |
1134 | |
1081 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1135 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1082 | cmdbuf_ptr = cmdbuf_base; |
1136 | cmdbuf_ptr = cmdbuf_base; |
1083 | cmdbuf_endp = cmdbuf_ptr + n; |
1137 | cmdbuf_endp = cmdbuf_ptr + n; |
1084 | |
1138 | |
1085 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1139 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1086 | |
1140 | |
1087 | if (n > 0) |
1141 | if (r > 0) |
1088 | { |
1142 | { |
1089 | cmdbuf_endp += n; |
1143 | cmdbuf_endp += r; |
1090 | return true; |
1144 | return true; |
1091 | } |
1145 | } |
1092 | 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 |
1093 | { |
1154 | { |
1094 | pty_ev.stop (); |
1155 | pty_ev.stop (); |
1095 | |
1156 | |
1096 | if (!OPTION (Opt_hold)) |
1157 | if (!OPTION (Opt_hold)) |
1097 | destroy (); |
1158 | destroy (); |
… | |
… | |
1101 | } |
1162 | } |
1102 | |
1163 | |
1103 | void |
1164 | void |
1104 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1165 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1105 | { |
1166 | { |
1106 | SET_R (this); |
1167 | make_current (); |
1107 | SET_LOCALE (locale); |
|
|
1108 | |
1168 | |
1109 | if (revents & EVENT_READ) |
1169 | if (revents & EVENT_READ) |
1110 | // loop, but don't allow a single term to monopolize us |
1170 | // loop, but don't allow a single term to monopolize us |
1111 | while (pty_fill ()) |
1171 | while (pty_fill ()) |
1112 | if (cmd_parse ()) |
1172 | if (cmd_parse ()) |
… | |
… | |
1132 | |
1192 | |
1133 | #ifdef POINTER_BLANK |
1193 | #ifdef POINTER_BLANK |
1134 | void |
1194 | void |
1135 | rxvt_term::pointer_blank () |
1195 | rxvt_term::pointer_blank () |
1136 | { |
1196 | { |
1137 | if (! OPTION (Opt_pointerBlank)) |
1197 | if (!OPTION (Opt_pointerBlank)) |
1138 | return; |
1198 | return; |
1139 | |
1199 | |
1140 | XDefineCursor (display->display, vt, display->blank_cursor); |
1200 | XDefineCursor (display->display, vt, display->blank_cursor); |
1141 | XFlush (display->display); |
1201 | XFlush (display->display); |
1142 | |
1202 | |
… | |
… | |
1144 | } |
1204 | } |
1145 | |
1205 | |
1146 | void |
1206 | void |
1147 | rxvt_term::pointer_cb (time_watcher &w) |
1207 | rxvt_term::pointer_cb (time_watcher &w) |
1148 | { |
1208 | { |
1149 | SET_R (this); |
1209 | make_current (); |
1150 | SET_LOCALE (locale); |
|
|
1151 | |
1210 | |
1152 | pointer_blank (); |
1211 | pointer_blank (); |
1153 | } |
1212 | } |
1154 | #endif |
1213 | #endif |
1155 | |
1214 | |
… | |
… | |
1234 | |
1293 | |
1235 | /*{{{ process an X event */ |
1294 | /*{{{ process an X event */ |
1236 | void |
1295 | void |
1237 | rxvt_term::x_cb (XEvent &ev) |
1296 | rxvt_term::x_cb (XEvent &ev) |
1238 | { |
1297 | { |
|
|
1298 | make_current (); |
|
|
1299 | |
1239 | dDisp; |
1300 | dDisp; |
1240 | |
1301 | |
1241 | SET_R (this); |
1302 | if (ev.xany.window == vt |
1242 | SET_LOCALE (locale); |
1303 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1304 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1305 | return; |
1243 | |
1306 | |
1244 | #if defined(CURSOR_BLINK) |
1307 | // for XQueryPointer |
1245 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1246 | { |
|
|
1247 | if (hidden_cursor) |
|
|
1248 | { |
|
|
1249 | hidden_cursor = 0; |
|
|
1250 | want_refresh = 1; |
|
|
1251 | } |
|
|
1252 | |
|
|
1253 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1254 | } |
|
|
1255 | #endif |
|
|
1256 | |
|
|
1257 | #if defined(POINTER_BLANK) |
|
|
1258 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1259 | { |
|
|
1260 | if (ev.type == MotionNotify |
|
|
1261 | || ev.type == ButtonPress |
|
|
1262 | || ev.type == ButtonRelease) |
|
|
1263 | if (hidden_pointer) |
|
|
1264 | pointer_unblank (); |
|
|
1265 | |
|
|
1266 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1267 | pointer_blank (); |
|
|
1268 | } |
|
|
1269 | #endif |
|
|
1270 | |
|
|
1271 | Window unused_root, unused_child; |
1308 | Window unused_root, unused_child; |
1272 | int unused_root_x, unused_root_y; |
1309 | int unused_root_x, unused_root_y; |
1273 | unsigned int unused_mask; |
1310 | unsigned int unused_mask; |
1274 | |
1311 | |
1275 | switch (ev.type) |
1312 | switch (ev.type) |
… | |
… | |
1282 | |
1319 | |
1283 | break; |
1320 | break; |
1284 | |
1321 | |
1285 | case KeyRelease: |
1322 | case KeyRelease: |
1286 | { |
1323 | { |
1287 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1324 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1288 | KeySym ks; |
1325 | KeySym keysym; |
1289 | |
1326 | |
1290 | 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 :/ |
1291 | #endif |
1328 | #endif |
1292 | |
1329 | |
1293 | #if ENABLE_FRILLS || ISO_14755 |
1330 | #if ENABLE_FRILLS || ISO_14755 |
1294 | // ISO 14755 support |
1331 | // ISO 14755 support |
1295 | if (iso14755buf) |
1332 | if (iso14755buf) |
… | |
… | |
1300 | # endif |
1337 | # endif |
1301 | # if ISO_14755 |
1338 | # if ISO_14755 |
1302 | // iso14755 part 5.2 handling: release time |
1339 | // iso14755 part 5.2 handling: release time |
1303 | // first: controls |
1340 | // first: controls |
1304 | if ((ev.xkey.state & ControlMask) |
1341 | if ((ev.xkey.state & ControlMask) |
1305 | && ((ks >= 0x40 && ks <= 0x5f) |
1342 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1306 | || (ks >= 0x61 && ks <= 0x7f))) |
1343 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1307 | { |
1344 | { |
1308 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1345 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1309 | commit_iso14755 (); |
1346 | commit_iso14755 (); |
1310 | return; // case-break; |
1347 | goto skip_switch; |
1311 | } |
1348 | } |
1312 | |
1349 | |
1313 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1350 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1314 | if (i[0] == ks) |
1351 | if (i[0] == keysym) |
1315 | { |
1352 | { |
1316 | iso14755buf = ISO_14755_51 | i[1]; |
1353 | iso14755buf = ISO_14755_51 | i[1]; |
1317 | commit_iso14755 (); |
1354 | commit_iso14755 (); |
1318 | return; // case-break; |
1355 | goto skip_switch; |
1319 | } |
1356 | } |
1320 | |
1357 | |
1321 | scr_bell (); |
1358 | scr_bell (); |
1322 | # endif |
1359 | # endif |
1323 | iso14755buf = 0; |
1360 | iso14755buf = 0; |
… | |
… | |
1342 | else |
1379 | else |
1343 | iso14755buf = 0; |
1380 | iso14755buf = 0; |
1344 | } |
1381 | } |
1345 | #endif |
1382 | #endif |
1346 | |
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 | |
1347 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1388 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1348 | if (!(ev.xkey.state & ControlMask)) |
1389 | if (!(ev.xkey.state & ControlMask)) |
1349 | slip_wheel_ev.stop (); |
1390 | slip_wheel_ev.stop (); |
1350 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1391 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1351 | mouse_slip_wheel_speed = 0; |
1392 | mouse_slip_wheel_speed = 0; |
1352 | #endif |
1393 | #endif |
1353 | break; |
1394 | break; |
1354 | } |
1395 | } |
1355 | |
1396 | |
… | |
… | |
1361 | button_release (ev.xbutton); |
1402 | button_release (ev.xbutton); |
1362 | break; |
1403 | break; |
1363 | |
1404 | |
1364 | case ClientMessage: |
1405 | case ClientMessage: |
1365 | if (ev.xclient.format == 32 |
1406 | if (ev.xclient.format == 32 |
1366 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1407 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1367 | { |
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 | { |
1368 | 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))) |
1369 | destroy (); |
1416 | destroy (); |
|
|
1417 | } |
1370 | #if ENABLE_EWMH |
1418 | #if ENABLE_EWMH |
1371 | 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]) |
1372 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1373 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1374 | &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 | } |
1375 | #endif |
1434 | #endif |
1376 | } |
1435 | } |
1377 | #if ENABLE_XEMBED |
|
|
1378 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1379 | { |
|
|
1380 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1381 | focus_in (); |
|
|
1382 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1383 | focus_out (); |
|
|
1384 | } |
|
|
1385 | #endif |
|
|
1386 | #ifdef OFFIX_DND |
|
|
1387 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1388 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1389 | && (ev.xclient.data.l[0] == DndFile |
|
|
1390 | || ev.xclient.data.l[0] == DndDir |
|
|
1391 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1392 | { |
|
|
1393 | /* Get Dnd data */ |
|
|
1394 | Atom ActualType; |
|
|
1395 | int ActualFormat; |
|
|
1396 | unsigned char *data; |
|
|
1397 | unsigned long Size, RemainingBytes; |
|
|
1398 | |
|
|
1399 | XGetWindowProperty (disp, display->root, |
|
|
1400 | xa[XA_DNDSELECTION], |
|
|
1401 | 0L, 1000000L, |
|
|
1402 | False, AnyPropertyType, |
|
|
1403 | &ActualType, &ActualFormat, |
|
|
1404 | &Size, &RemainingBytes, |
|
|
1405 | &data); |
|
|
1406 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1407 | XFree (data); |
|
|
1408 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1409 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1410 | } |
|
|
1411 | #endif /* OFFIX_DND */ |
|
|
1412 | break; |
1436 | break; |
1413 | |
1437 | |
1414 | case MappingNotify: |
1438 | case MappingNotify: |
1415 | XRefreshKeyboardMapping (&ev.xmapping); |
1439 | XRefreshKeyboardMapping (&ev.xmapping); |
1416 | break; |
1440 | break; |
… | |
… | |
1458 | { |
1482 | { |
1459 | seen_resize = 1; |
1483 | seen_resize = 1; |
1460 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1484 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1461 | } |
1485 | } |
1462 | |
1486 | |
|
|
1487 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1488 | |
1463 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1489 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1464 | if (OPTION (Opt_transparent)) |
1490 | if (OPTION (Opt_transparent)) |
1465 | check_our_parents (); |
1491 | check_our_parents (); |
1466 | #endif |
1492 | #endif |
1467 | } |
1493 | } |
1468 | break; |
1494 | break; |
1469 | |
1495 | |
1470 | case PropertyNotify: |
1496 | case PropertyNotify: |
|
|
1497 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1471 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1498 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1472 | && ev.xproperty.state == PropertyNewValue) |
1499 | && ev.xproperty.state == PropertyNewValue) |
1473 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1500 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1474 | |
1501 | |
1475 | break; |
1502 | break; |
1476 | |
1503 | |
1477 | case SelectionClear: |
1504 | case SelectionClear: |
1478 | selection_clear (); |
1505 | selection_clear (); |
… | |
… | |
1483 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1510 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1484 | break; |
1511 | break; |
1485 | |
1512 | |
1486 | case SelectionRequest: |
1513 | case SelectionRequest: |
1487 | 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)); |
1488 | break; |
1523 | break; |
1489 | |
1524 | |
1490 | case UnmapNotify: |
1525 | case UnmapNotify: |
1491 | mapped = 0; |
1526 | mapped = 0; |
1492 | #ifdef TEXT_BLINK |
1527 | #ifdef TEXT_BLINK |
1493 | text_blink_ev.stop (); |
1528 | text_blink_ev.stop (); |
1494 | #endif |
1529 | #endif |
1495 | break; |
1530 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1496 | |
|
|
1497 | case MapNotify: |
|
|
1498 | mapped = 1; |
|
|
1499 | #ifdef TEXT_BLINK |
|
|
1500 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1501 | #endif |
|
|
1502 | break; |
1531 | break; |
1503 | |
1532 | |
1504 | #ifdef TRANSPARENT |
1533 | #ifdef TRANSPARENT |
1505 | case ReparentNotify: |
1534 | case ReparentNotify: |
1506 | rootwin_cb (ev); |
1535 | rootwin_cb (ev); |
… | |
… | |
1520 | |
1549 | |
1521 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1550 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1522 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1551 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1523 | ev.xexpose.width, ev.xexpose.height, False); |
1552 | ev.xexpose.width, ev.xexpose.height, False); |
1524 | |
1553 | |
1525 | scr_refresh (refresh_type); |
1554 | want_refresh = 1; |
1526 | } |
1555 | } |
1527 | else |
1556 | else |
1528 | { |
1557 | { |
1529 | XEvent unused_event; |
1558 | XEvent unused_event; |
1530 | |
1559 | |
… | |
… | |
1536 | if (isScrollbarWindow (ev.xany.window)) |
1565 | if (isScrollbarWindow (ev.xany.window)) |
1537 | { |
1566 | { |
1538 | scrollBar.setIdle (); |
1567 | scrollBar.setIdle (); |
1539 | scrollbar_show (0); |
1568 | scrollbar_show (0); |
1540 | } |
1569 | } |
1541 | #ifdef MENUBAR |
|
|
1542 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1543 | menubar_expose (); |
|
|
1544 | #endif |
|
|
1545 | |
1570 | |
1546 | #ifdef TRANSPARENT |
1571 | #ifdef TRANSPARENT |
1547 | if (am_transparent && ev.xany.window == parent[0]) |
1572 | if (am_transparent && ev.xany.window == parent[0]) |
1548 | XClearWindow (disp, ev.xany.window); |
1573 | XClearWindow (disp, ev.xany.window); |
1549 | #endif |
1574 | #endif |
… | |
… | |
1553 | case MotionNotify: |
1578 | case MotionNotify: |
1554 | #ifdef POINTER_BLANK |
1579 | #ifdef POINTER_BLANK |
1555 | if (hidden_pointer) |
1580 | if (hidden_pointer) |
1556 | pointer_unblank (); |
1581 | pointer_unblank (); |
1557 | #endif |
1582 | #endif |
1558 | #if MENUBAR |
|
|
1559 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1560 | { |
|
|
1561 | menubar_control (ev.xbutton); |
|
|
1562 | break; |
|
|
1563 | } |
|
|
1564 | #endif |
|
|
1565 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1583 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1566 | break; |
1584 | break; |
1567 | |
1585 | |
1568 | if (ev.xany.window == vt) |
1586 | if (ev.xany.window == vt) |
1569 | { |
1587 | { |
|
|
1588 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1589 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1590 | ; // nop |
1570 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1591 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1571 | { |
1592 | { |
1572 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1593 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1573 | ; |
1594 | ; |
1574 | |
1595 | |
1575 | XQueryPointer (disp, vt, |
1596 | XQueryPointer (disp, vt, |
… | |
… | |
1655 | &unused_root_x, &unused_root_y, |
1676 | &unused_root_x, &unused_root_y, |
1656 | &ev.xbutton.x, &ev.xbutton.y, |
1677 | &ev.xbutton.x, &ev.xbutton.y, |
1657 | &unused_mask); |
1678 | &unused_mask); |
1658 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1679 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1659 | scrollbar_size ()); |
1680 | scrollbar_size ()); |
1660 | scr_refresh (refresh_type); |
1681 | want_refresh = 1; |
1661 | refresh_limit = 0; |
1682 | refresh_limit = 0; |
1662 | scrollbar_show (1); |
1683 | scrollbar_show (1); |
1663 | } |
1684 | } |
1664 | break; |
1685 | break; |
1665 | } |
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 |
1666 | } |
1716 | } |
1667 | |
1717 | |
1668 | void |
1718 | void |
1669 | rxvt_term::focus_in () |
1719 | rxvt_term::focus_in () |
1670 | { |
1720 | { |
1671 | if (!focus) |
1721 | if (!focus) |
1672 | { |
1722 | { |
1673 | focus = 1; |
1723 | focus = 1; |
1674 | want_refresh = 1; |
1724 | want_refresh = 1; |
|
|
1725 | |
|
|
1726 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1727 | |
1675 | #if USE_XIM |
1728 | #if USE_XIM |
1676 | if (Input_Context != NULL) |
1729 | if (Input_Context != NULL) |
1677 | { |
1730 | { |
1678 | IMSetStatusPosition (); |
1731 | IMSetStatusPosition (); |
1679 | XSetICFocus (Input_Context); |
1732 | XSetICFocus (Input_Context); |
1680 | } |
1733 | } |
1681 | #endif |
1734 | #endif |
1682 | #if CURSOR_BLINK |
1735 | #if CURSOR_BLINK |
1683 | if (OPTION (Opt_cursorBlink)) |
1736 | if (OPTION (Opt_cursorBlink)) |
1684 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1737 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1685 | #endif |
1738 | #endif |
1686 | #if OFF_FOCUS_FADING |
1739 | #if OFF_FOCUS_FADING |
1687 | if (rs[Rs_fade]) |
1740 | if (rs[Rs_fade]) |
1688 | { |
1741 | { |
1689 | pix_colors = pix_colors_focused; |
1742 | pix_colors = pix_colors_focused; |
… | |
… | |
1699 | if (focus) |
1752 | if (focus) |
1700 | { |
1753 | { |
1701 | focus = 0; |
1754 | focus = 0; |
1702 | want_refresh = 1; |
1755 | want_refresh = 1; |
1703 | |
1756 | |
|
|
1757 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1758 | |
1704 | #if ENABLE_FRILLS || ISO_14755 |
1759 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1760 | if (iso14755buf) |
|
|
1761 | { |
1705 | iso14755buf = 0; |
1762 | iso14755buf = 0; |
1706 | #endif |
|
|
1707 | #if ENABLE_OVERLAY |
1763 | # if ENABLE_OVERLAY |
1708 | scr_overlay_off (); |
1764 | scr_overlay_off (); |
|
|
1765 | # endif |
|
|
1766 | } |
1709 | #endif |
1767 | #endif |
1710 | #if USE_XIM |
1768 | #if USE_XIM |
1711 | if (Input_Context != NULL) |
1769 | if (Input_Context != NULL) |
1712 | XUnsetICFocus (Input_Context); |
1770 | XUnsetICFocus (Input_Context); |
1713 | #endif |
1771 | #endif |
… | |
… | |
1728 | |
1786 | |
1729 | #if TRANSPARENT |
1787 | #if TRANSPARENT |
1730 | void |
1788 | void |
1731 | rxvt_term::rootwin_cb (XEvent &ev) |
1789 | rxvt_term::rootwin_cb (XEvent &ev) |
1732 | { |
1790 | { |
1733 | SET_R (this); |
1791 | make_current (); |
1734 | SET_LOCALE (locale); |
|
|
1735 | |
1792 | |
1736 | switch (ev.type) |
1793 | switch (ev.type) |
1737 | { |
1794 | { |
1738 | case PropertyNotify: |
1795 | case PropertyNotify: |
1739 | /* |
1796 | /* |
… | |
… | |
1757 | rxvt_term::button_press (XButtonEvent &ev) |
1814 | rxvt_term::button_press (XButtonEvent &ev) |
1758 | { |
1815 | { |
1759 | int reportmode = 0, clickintime; |
1816 | int reportmode = 0, clickintime; |
1760 | |
1817 | |
1761 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1818 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1819 | |
1762 | if (!bypass_keystate) |
1820 | if (!bypass_keystate) |
1763 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1821 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1764 | |
1822 | |
1765 | /* |
1823 | /* |
1766 | * VT window processing of button press |
1824 | * VT window processing of button press |
1767 | */ |
1825 | */ |
1768 | if (ev.window == vt) |
1826 | if (ev.window == vt) |
1769 | { |
1827 | { |
|
|
1828 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1829 | return; |
|
|
1830 | |
1770 | #if ISO_14755 |
1831 | #if ISO_14755 |
1771 | // 5.4 |
1832 | // 5.4 |
1772 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1833 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1773 | { |
1834 | { |
1774 | iso14755_54 (ev.x, ev.y); |
1835 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1786 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1847 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1787 | if (ev.button == MEvent.button && clickintime) |
1848 | if (ev.button == MEvent.button && clickintime) |
1788 | { |
1849 | { |
1789 | /* same button, within alloted time */ |
1850 | /* same button, within alloted time */ |
1790 | MEvent.clicks++; |
1851 | MEvent.clicks++; |
|
|
1852 | |
1791 | if (MEvent.clicks > 1) |
1853 | if (MEvent.clicks > 1) |
1792 | { |
1854 | { |
1793 | /* only report double clicks */ |
1855 | /* only report double clicks */ |
1794 | MEvent.clicks = 2; |
1856 | MEvent.clicks = 2; |
1795 | mouse_report (ev); |
1857 | mouse_report (ev); |
… | |
… | |
1827 | #else |
1889 | #else |
1828 | selection.rect = false; |
1890 | selection.rect = false; |
1829 | #endif |
1891 | #endif |
1830 | |
1892 | |
1831 | /* allow shift+left click to extend selection */ |
1893 | /* allow shift+left click to extend selection */ |
1832 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1894 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1833 | { |
1895 | { |
1834 | if (MEvent.button == Button1 && clickintime) |
1896 | if (MEvent.button == Button1 && clickintime) |
1835 | selection_rotate (ev.x, ev.y); |
1897 | selection_rotate (ev.x, ev.y); |
1836 | else |
1898 | else |
1837 | selection_extend (ev.x, ev.y, 1); |
1899 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2002 | } |
2064 | } |
2003 | |
2065 | |
2004 | break; |
2066 | break; |
2005 | } |
2067 | } |
2006 | } |
2068 | } |
|
|
2069 | |
2007 | return; |
2070 | return; |
2008 | } |
2071 | } |
2009 | #if MENUBAR |
|
|
2010 | /* |
|
|
2011 | * Menubar window processing of button press |
|
|
2012 | */ |
|
|
2013 | if (isMenuBarWindow (ev.window)) |
|
|
2014 | menubar_control (ev); |
|
|
2015 | #endif |
|
|
2016 | } |
2072 | } |
2017 | |
2073 | |
2018 | void |
2074 | void |
2019 | rxvt_term::button_release (XButtonEvent &ev) |
2075 | rxvt_term::button_release (XButtonEvent &ev) |
2020 | { |
2076 | { |
… | |
… | |
2026 | |
2082 | |
2027 | if (scrollbar_isUpDn ()) |
2083 | if (scrollbar_isUpDn ()) |
2028 | { |
2084 | { |
2029 | scrollBar.setIdle (); |
2085 | scrollBar.setIdle (); |
2030 | scrollbar_show (0); |
2086 | scrollbar_show (0); |
2031 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2032 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2033 | #endif |
|
|
2034 | } |
2087 | } |
2035 | |
2088 | |
2036 | #ifdef SELECTION_SCROLLING |
2089 | #ifdef SELECTION_SCROLLING |
2037 | if (sel_scroll_ev.active) |
2090 | if (sel_scroll_ev.active) |
2038 | sel_scroll_ev.stop(); |
2091 | sel_scroll_ev.stop(); |
2039 | #endif |
2092 | #endif |
2040 | |
2093 | |
2041 | if (ev.window == vt) |
2094 | if (ev.window == vt) |
2042 | { |
2095 | { |
|
|
2096 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2097 | return; |
|
|
2098 | |
2043 | #if ISO_14755 |
2099 | #if ISO_14755 |
2044 | // 5.4 |
2100 | // 5.4 |
2045 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2101 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2046 | return; |
2102 | return; |
2047 | #endif |
2103 | #endif |
|
|
2104 | |
2048 | if (reportmode) |
2105 | if (reportmode) |
2049 | { |
2106 | { |
2050 | /* mouse report from vt window */ |
2107 | /* mouse report from vt window */ |
2051 | /* don't report release of wheel "buttons" */ |
2108 | /* don't report release of wheel "buttons" */ |
2052 | if (ev.button >= 4) |
2109 | if (ev.button >= 4) |
… | |
… | |
2082 | { |
2139 | { |
2083 | case Button1: |
2140 | case Button1: |
2084 | case Button3: |
2141 | case Button3: |
2085 | selection_make (ev.time); |
2142 | selection_make (ev.time); |
2086 | break; |
2143 | break; |
|
|
2144 | |
2087 | case Button2: |
2145 | case Button2: |
2088 | 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); |
2089 | break; |
2148 | break; |
|
|
2149 | |
2090 | #ifdef MOUSE_WHEEL |
2150 | #ifdef MOUSE_WHEEL |
2091 | case Button4: |
2151 | case Button4: |
2092 | case Button5: |
2152 | case Button5: |
2093 | { |
2153 | { |
2094 | int i; |
2154 | int i; |
… | |
… | |
2116 | slip_wheel_ev.start (); |
2176 | slip_wheel_ev.start (); |
2117 | } |
2177 | } |
2118 | else |
2178 | else |
2119 | { |
2179 | { |
2120 | # endif |
2180 | # endif |
2121 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2122 | scr_page (v, i); |
2181 | scr_page (v, i); |
2123 | scr_refresh (SMOOTH_REFRESH); |
|
|
2124 | scrollbar_show (1); |
2182 | scrollbar_show (1); |
2125 | # else |
|
|
2126 | while (i--) |
|
|
2127 | { |
|
|
2128 | scr_page (v, 1); |
|
|
2129 | scr_refresh (SMOOTH_REFRESH); |
|
|
2130 | scrollbar_show (1); |
|
|
2131 | } |
|
|
2132 | # endif |
|
|
2133 | # ifdef MOUSE_SLIP_WHEELING |
2183 | # ifdef MOUSE_SLIP_WHEELING |
2134 | } |
2184 | } |
2135 | #endif |
2185 | # endif |
2136 | } |
2186 | } |
2137 | break; |
2187 | break; |
2138 | #endif |
2188 | #endif |
2139 | } |
2189 | } |
2140 | } |
2190 | } |
2141 | #ifdef MENUBAR |
|
|
2142 | else if (isMenuBarWindow (ev.window)) |
|
|
2143 | menubar_control (ev); |
|
|
2144 | #endif |
|
|
2145 | } |
2191 | } |
2146 | |
2192 | |
2147 | #ifdef TRANSPARENT |
2193 | #ifdef TRANSPARENT |
2148 | #if TINTING |
2194 | #if TINTING |
2149 | /* taken from aterm-0.4.2 */ |
2195 | /* taken from aterm-0.4.2 */ |
… | |
… | |
2586 | am_transparent = 0; |
2632 | am_transparent = 0; |
2587 | /* XXX: also turn off Opt_transparent? */ |
2633 | /* XXX: also turn off Opt_transparent? */ |
2588 | } |
2634 | } |
2589 | else |
2635 | else |
2590 | { |
2636 | { |
2591 | #if WAIT_FOR_WM |
|
|
2592 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2593 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2594 | sleep (1); |
|
|
2595 | #endif |
|
|
2596 | for (n = 0; n < (unsigned int)i; n++) |
2637 | for (n = 0; n < (unsigned int)i; n++) |
2597 | { |
2638 | { |
2598 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2639 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2599 | XClearWindow (disp, parent[n]); |
2640 | XClearWindow (disp, parent[n]); |
2600 | } |
2641 | } |
… | |
… | |
2629 | |
2670 | |
2630 | bool |
2671 | bool |
2631 | rxvt_term::cmd_parse () |
2672 | rxvt_term::cmd_parse () |
2632 | { |
2673 | { |
2633 | bool flag = false; |
2674 | bool flag = false; |
2634 | unicode_t ch = NOCHAR; |
2675 | wchar_t ch = NOCHAR; |
2635 | unsigned char *seq_begin; // remember start of esc-sequence here |
2676 | char *seq_begin; // remember start of esc-sequence here |
2636 | |
2677 | |
2637 | for (;;) |
2678 | for (;;) |
2638 | { |
2679 | { |
2639 | if (ch == NOCHAR) |
2680 | if (ch == NOCHAR) |
2640 | { |
2681 | { |
2641 | seq_begin = cmdbuf_ptr; |
2682 | seq_begin = cmdbuf_ptr; |
2642 | ch = next_char (); |
2683 | ch = next_char (); |
2643 | } |
|
|
2644 | |
2684 | |
2645 | if (ch == NOCHAR) // TODO: improve |
2685 | if (ch == NOCHAR) |
2646 | break; |
2686 | break; |
|
|
2687 | } |
2647 | |
2688 | |
2648 | 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) |
2649 | { |
2690 | { |
2650 | if (!seen_input) |
2691 | if (!seen_input) |
2651 | { |
2692 | { |
… | |
… | |
2660 | if (seen_resize && cmd_pid) |
2701 | if (seen_resize && cmd_pid) |
2661 | kill (-cmd_pid, SIGWINCH); |
2702 | kill (-cmd_pid, SIGWINCH); |
2662 | } |
2703 | } |
2663 | |
2704 | |
2664 | /* Read a text string from the input buffer */ |
2705 | /* Read a text string from the input buffer */ |
2665 | unicode_t buf[UBUFSIZ]; |
2706 | wchar_t buf[UBUFSIZ]; |
2666 | bool refreshnow = false; |
2707 | bool refreshnow = false; |
2667 | int nlines = 0; |
2708 | int nlines = 0; |
2668 | unicode_t *str = buf; |
2709 | wchar_t *str = buf; |
2669 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2710 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2670 | |
2711 | |
2671 | for (;;) |
2712 | for (;;) |
2672 | { |
2713 | { |
2673 | 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)) |
2674 | break; |
2715 | break; |
… | |
… | |
2684 | |
2725 | |
2685 | if (!OPTION (Opt_jumpScroll) |
2726 | if (!OPTION (Opt_jumpScroll) |
2686 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2727 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2687 | { |
2728 | { |
2688 | refreshnow = true; |
2729 | refreshnow = true; |
|
|
2730 | refresh_count = 0; |
2689 | ch = NOCHAR; |
2731 | ch = NOCHAR; |
2690 | break; |
2732 | break; |
2691 | } |
2733 | } |
2692 | |
2734 | |
2693 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
2694 | if (nlines >= nrow - 1) |
2736 | if (nlines >= nrow - 1) |
2695 | { |
2737 | { |
|
|
2738 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2739 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2696 | scr_add_lines (buf, nlines, str - buf); |
2740 | scr_add_lines (buf, str - buf, nlines); |
|
|
2741 | |
2697 | nlines = 0; |
2742 | nlines = 0; |
2698 | str = buf; |
2743 | str = buf; |
2699 | eol = str + min (ncol, UBUFSIZ); |
2744 | eol = str + min (ncol, UBUFSIZ); |
2700 | } |
2745 | } |
2701 | |
2746 | |
… | |
… | |
2714 | |
2759 | |
2715 | seq_begin = cmdbuf_ptr; |
2760 | seq_begin = cmdbuf_ptr; |
2716 | ch = next_char (); |
2761 | ch = next_char (); |
2717 | } |
2762 | } |
2718 | |
2763 | |
|
|
2764 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2765 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2719 | scr_add_lines (buf, nlines, str - buf); |
2766 | scr_add_lines (buf, str - buf, nlines); |
2720 | |
2767 | |
2721 | /* |
2768 | /* |
2722 | * 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 |
2723 | * 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. |
2724 | * the number of pages between refreshes is refresh_limit, which |
2771 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2729 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2776 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2730 | refresh_limit++; |
2777 | refresh_limit++; |
2731 | else |
2778 | else |
2732 | { |
2779 | { |
2733 | flag = true; |
2780 | flag = true; |
2734 | scr_refresh (refresh_type); |
2781 | scr_refresh (); |
|
|
2782 | want_refresh = 1; |
2735 | } |
2783 | } |
2736 | } |
2784 | } |
2737 | |
2785 | |
2738 | } |
2786 | } |
2739 | else |
2787 | else |
… | |
… | |
2754 | } |
2802 | } |
2755 | |
2803 | |
2756 | return flag; |
2804 | return flag; |
2757 | } |
2805 | } |
2758 | |
2806 | |
2759 | // read the next octet |
|
|
2760 | unicode_t |
|
|
2761 | rxvt_term::next_octet () |
|
|
2762 | { |
|
|
2763 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2764 | ? *cmdbuf_ptr++ |
|
|
2765 | : NOCHAR; |
|
|
2766 | } |
|
|
2767 | |
|
|
2768 | // read the next character |
2807 | // read the next character |
2769 | unicode_t |
2808 | wchar_t |
2770 | rxvt_term::next_char () |
2809 | rxvt_term::next_char () NOTHROW |
2771 | { |
2810 | { |
2772 | while (cmdbuf_ptr < cmdbuf_endp) |
2811 | while (cmdbuf_ptr < cmdbuf_endp) |
2773 | { |
2812 | { |
2774 | // assume 7-bit to be ascii ALWAYS |
2813 | // assume 7-bit to be ascii ALWAYS |
2775 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2814 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2776 | return *cmdbuf_ptr++; |
2815 | return *cmdbuf_ptr++; |
2777 | |
2816 | |
2778 | wchar_t wc; |
2817 | wchar_t wc; |
2779 | 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); |
2780 | |
2819 | |
2781 | if (len == (size_t)-2) |
2820 | if (len == (size_t)-2) |
2782 | { |
2821 | { |
2783 | // the mbstate stores incomplete sequences. didn't know this :/ |
2822 | // the mbstate stores incomplete sequences. didn't know this :/ |
2784 | cmdbuf_ptr = cmdbuf_endp; |
2823 | cmdbuf_ptr = cmdbuf_endp; |
2785 | break; |
2824 | break; |
2786 | } |
2825 | } |
2787 | |
2826 | |
2788 | if (len == (size_t)-1) |
2827 | if (len == (size_t)-1) |
2789 | 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 |
2790 | |
2829 | |
2791 | // assume wchar == unicode |
2830 | // assume wchar == unicode |
2792 | cmdbuf_ptr += len; |
2831 | cmdbuf_ptr += len; |
2793 | return wc & UNICODE_MASK; |
2832 | return wc & UNICODE_MASK; |
2794 | } |
2833 | } |
2795 | |
2834 | |
2796 | return NOCHAR; |
2835 | return NOCHAR; |
2797 | } |
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; |
2798 | |
2848 | |
2799 | /* rxvt_cmd_getc () - Return next input character */ |
2849 | /* rxvt_cmd_getc () - Return next input character */ |
2800 | /* |
2850 | /* |
2801 | * Return the next input character after first passing any keyboard input |
2851 | * Return the next input character after first passing any keyboard input |
2802 | * to the command. |
2852 | * to the command. |
2803 | */ |
2853 | */ |
2804 | unicode_t |
2854 | wchar_t |
2805 | rxvt_term::cmd_getc () |
2855 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2806 | { |
2856 | { |
2807 | unicode_t c = next_char (); |
2857 | wchar_t c = next_char (); |
2808 | |
2858 | |
2809 | if (c == NOCHAR) |
2859 | if (c == NOCHAR) |
2810 | throw out_of_input; |
2860 | throw out_of_input; |
2811 | |
2861 | |
2812 | return c; |
2862 | return c; |
2813 | } |
2863 | } |
2814 | |
2864 | |
2815 | unicode_t |
2865 | uint32_t |
2816 | rxvt_term::cmd_get8 () |
2866 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2817 | { |
2867 | { |
2818 | unicode_t c = next_octet (); |
2868 | uint32_t c = next_octet (); |
2819 | |
2869 | |
2820 | if (c == NOCHAR) |
2870 | if (c == NOCHAR) |
2821 | throw out_of_input; |
2871 | throw out_of_input; |
2822 | |
2872 | |
2823 | return c; |
2873 | return c; |
… | |
… | |
2923 | case C0_ESC: |
2973 | case C0_ESC: |
2924 | process_escape_seq (); |
2974 | process_escape_seq (); |
2925 | break; |
2975 | break; |
2926 | case C0_ENQ: /* terminal Status */ |
2976 | case C0_ENQ: /* terminal Status */ |
2927 | if (rs[Rs_answerbackstring]) |
2977 | if (rs[Rs_answerbackstring]) |
2928 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2978 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2929 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2930 | else |
2979 | else |
2931 | tt_write ((unsigned char *)VT100_ANS, |
2980 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2932 | (unsigned int)strlen (VT100_ANS)); |
|
|
2933 | break; |
2981 | break; |
2934 | case C0_BEL: /* bell */ |
2982 | case C0_BEL: /* bell */ |
2935 | scr_bell (); |
2983 | scr_bell (); |
2936 | break; |
2984 | break; |
2937 | case C0_BS: /* backspace */ |
2985 | case C0_BS: /* backspace */ |
… | |
… | |
3092 | break; |
3140 | break; |
3093 | |
3141 | |
3094 | /* 8.3.87: NEXT LINE */ |
3142 | /* 8.3.87: NEXT LINE */ |
3095 | case C1_NEL: /* ESC E */ |
3143 | case C1_NEL: /* ESC E */ |
3096 | { |
3144 | { |
3097 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3145 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3098 | scr_add_lines (nlcr, 1, 2); |
3146 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3099 | } |
3147 | } |
3100 | break; |
3148 | break; |
3101 | |
3149 | |
3102 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3150 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3103 | case C1_ESA: /* ESC G */ |
3151 | case C1_ESA: /* ESC G */ |
… | |
… | |
3125 | process_dcs_seq (); |
3173 | process_dcs_seq (); |
3126 | break; |
3174 | break; |
3127 | |
3175 | |
3128 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3176 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3129 | case C1_SCI: /* ESC Z */ |
3177 | case C1_SCI: /* ESC Z */ |
3130 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3178 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3131 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3132 | break; /* steal obsolete ESC [ c */ |
3179 | break; /* steal obsolete ESC [ c */ |
3133 | |
3180 | |
3134 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3181 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3135 | case C1_CSI: /* ESC [ */ |
3182 | case C1_CSI: /* ESC [ */ |
3136 | process_csi_seq (); |
3183 | process_csi_seq (); |
… | |
… | |
3380 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3427 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3381 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3428 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3382 | break; |
3429 | break; |
3383 | |
3430 | |
3384 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3431 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3385 | tt_write ((const unsigned char *)VT100_ANS, |
3432 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3386 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3387 | break; |
3433 | break; |
3388 | |
3434 | |
3389 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3435 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3390 | process_sgr_mode (nargs, arg); |
3436 | process_sgr_mode (nargs, arg); |
3391 | break; |
3437 | break; |
… | |
… | |
3593 | /*----------------------------------------------------------------------*/ |
3639 | /*----------------------------------------------------------------------*/ |
3594 | /* |
3640 | /* |
3595 | * get input up until STRING TERMINATOR (or BEL) |
3641 | * get input up until STRING TERMINATOR (or BEL) |
3596 | * ends_how is terminator used. returned input must be free()'d |
3642 | * ends_how is terminator used. returned input must be free()'d |
3597 | */ |
3643 | */ |
3598 | unsigned char * |
3644 | char * |
3599 | rxvt_term::get_to_st (unicode_t &ends_how) |
3645 | rxvt_term::get_to_st (unicode_t &ends_how) |
3600 | { |
3646 | { |
3601 | unicode_t ch; |
3647 | unicode_t ch; |
3602 | bool seen_esc = false; |
3648 | bool seen_esc = false; |
3603 | unsigned int n = 0; |
3649 | unsigned int n = 0; |
… | |
… | |
3636 | |
3682 | |
3637 | string[n++] = '\0'; |
3683 | string[n++] = '\0'; |
3638 | |
3684 | |
3639 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3685 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3640 | |
3686 | |
3641 | return (unsigned char *)rxvt_wcstombs (string); |
3687 | return rxvt_wcstombs (string); |
3642 | } |
3688 | } |
3643 | |
3689 | |
3644 | /*----------------------------------------------------------------------*/ |
3690 | /*----------------------------------------------------------------------*/ |
3645 | /* |
3691 | /* |
3646 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3692 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3647 | */ |
3693 | */ |
3648 | void |
3694 | void |
3649 | rxvt_term::process_dcs_seq () |
3695 | rxvt_term::process_dcs_seq () |
3650 | { |
3696 | { |
3651 | unsigned char *s; |
3697 | char *s; |
3652 | unicode_t eh; |
3698 | unicode_t eh; |
3653 | |
3699 | |
3654 | /* |
3700 | /* |
3655 | * Not handled yet |
3701 | * Not handled yet |
3656 | */ |
3702 | */ |
… | |
… | |
3675 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3721 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3676 | arg = arg * 10 + (ch - '0'); |
3722 | arg = arg * 10 + (ch - '0'); |
3677 | |
3723 | |
3678 | if (ch == ';') |
3724 | if (ch == ';') |
3679 | { |
3725 | { |
3680 | unsigned char *s = get_to_st (eh); |
3726 | char *s = get_to_st (eh); |
3681 | |
3727 | |
3682 | if (s) |
3728 | if (s) |
3683 | { |
3729 | { |
3684 | process_xterm_seq (arg, (char *)s, eh); |
3730 | process_xterm_seq (arg, s, eh); |
3685 | free (s); |
3731 | free (s); |
3686 | } |
3732 | } |
3687 | } |
3733 | } |
3688 | } |
3734 | } |
3689 | |
3735 | |
3690 | void |
3736 | void |
3691 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3737 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3692 | { |
3738 | { |
3693 | if (str[0] == '?' && !str[1]) |
3739 | if (str[0] == '?' && !str[1]) |
3694 | { |
3740 | { |
3695 | unsigned short r, g, b; |
3741 | unsigned short r, g, b; |
3696 | pix_colors_focused[color].get (display, r, g, b); |
3742 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3702 | |
3748 | |
3703 | /* |
3749 | /* |
3704 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3750 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3705 | */ |
3751 | */ |
3706 | void |
3752 | void |
3707 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3753 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3708 | { |
3754 | { |
3709 | int changed = 0; |
|
|
3710 | int color; |
3755 | int color; |
3711 | char *buf, *name; |
3756 | char *buf, *name; |
3712 | bool query = str[0] == '?' && !str[1]; |
3757 | bool query = str[0] == '?' && !str[1]; |
3713 | int saveop = op; |
3758 | int saveop = op; |
3714 | dDisp; |
3759 | dDisp; |
… | |
… | |
3769 | { |
3814 | { |
3770 | if ((name = strchr (buf, ';')) == NULL) |
3815 | if ((name = strchr (buf, ';')) == NULL) |
3771 | break; |
3816 | break; |
3772 | |
3817 | |
3773 | *name++ = '\0'; |
3818 | *name++ = '\0'; |
3774 | color = atoi (buf); |
3819 | color = atoi (buf) + minCOLOR; |
3775 | |
3820 | |
3776 | if (color < 0 || color >= TOTAL_COLORS) |
3821 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3777 | break; |
3822 | break; |
3778 | |
3823 | |
3779 | if ((buf = strchr (name, ';')) != NULL) |
3824 | if ((buf = strchr (name, ';')) != NULL) |
3780 | *buf++ = '\0'; |
3825 | *buf++ = '\0'; |
3781 | |
3826 | |
3782 | if (name[0] == '?' && !name[1]) |
3827 | if (name[0] == '?' && !name[1]) |
3783 | { |
3828 | { |
3784 | unsigned short r, g, b; |
3829 | unsigned short r, g, b; |
3785 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3830 | pix_colors_focused[color].get (display, r, g, b); |
3786 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3831 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3787 | } |
3832 | } |
3788 | else |
3833 | else |
3789 | set_window_color (color + minCOLOR, name); |
3834 | set_window_color (color, name); |
3790 | } |
3835 | } |
3791 | break; |
3836 | break; |
3792 | case XTerm_Color00: |
3837 | case XTerm_Color00: |
3793 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3838 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3794 | break; |
3839 | break; |
3795 | case XTerm_Color01: |
3840 | case XTerm_Color01: |
3796 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3841 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3797 | break; |
3842 | break; |
3798 | #ifndef NO_CURSORCOLOR |
3843 | #ifndef NO_CURSORCOLOR |
3799 | case XTerm_Color_cursor: |
3844 | case XTerm_Color_cursor: |
3800 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3845 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3801 | break; |
3846 | break; |
… | |
… | |
3805 | break; |
3850 | break; |
3806 | case XTerm_Color_pointer_bg: |
3851 | case XTerm_Color_pointer_bg: |
3807 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3852 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3808 | break; |
3853 | break; |
3809 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3854 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3810 | case XTerm_Color_BD: |
|
|
3811 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3812 | break; |
|
|
3813 | case XTerm_Color_UL: |
|
|
3814 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3815 | break; |
|
|
3816 | case XTerm_Color_RV: |
3855 | case XTerm_Color_RV: |
3817 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3856 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3857 | break; |
|
|
3858 | case Rxvt_Color_BD: |
|
|
3859 | case URxvt_Color_BD: |
|
|
3860 | process_color_seq (op, Color_BD, str, resp); |
|
|
3861 | break; |
|
|
3862 | case Rxvt_Color_UL: |
|
|
3863 | case URxvt_Color_UL: |
|
|
3864 | process_color_seq (op, Color_UL, str, resp); |
3818 | break; |
3865 | break; |
3819 | case URxvt_Color_IT: |
3866 | case URxvt_Color_IT: |
3820 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3867 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3821 | break; |
3868 | break; |
3822 | #endif |
3869 | #endif |
… | |
… | |
3827 | if (am_transparent) |
3874 | if (am_transparent) |
3828 | want_full_refresh = want_refresh = 1; |
3875 | want_full_refresh = want_refresh = 1; |
3829 | break; |
3876 | break; |
3830 | #endif |
3877 | #endif |
3831 | |
3878 | |
3832 | case XTerm_Pixmap: |
3879 | case Rxvt_Pixmap: |
|
|
3880 | { |
3833 | if (*str != ';') |
3881 | if (*str != ';') |
3834 | { |
3882 | { |
3835 | #if XPM_BACKGROUND |
3883 | #if XPM_BACKGROUND |
3836 | scale_pixmap (""); /* reset to default scaling */ |
3884 | scale_pixmap (""); /* reset to default scaling */ |
3837 | set_bgPixmap (str); /* change pixmap */ |
3885 | set_bgPixmap (str); /* change pixmap */ |
3838 | #endif |
|
|
3839 | scr_touch (true); |
3886 | scr_touch (true); |
|
|
3887 | #endif |
3840 | } |
3888 | } |
|
|
3889 | |
|
|
3890 | int changed = 0; |
|
|
3891 | |
3841 | while ((str = strchr (str, ';')) != NULL) |
3892 | while ((str = strchr (str, ';')) != NULL) |
3842 | { |
3893 | { |
3843 | str++; |
3894 | str++; |
3844 | #if XPM_BACKGROUND |
3895 | #if XPM_BACKGROUND |
3845 | changed += scale_pixmap (str); |
3896 | changed += scale_pixmap (str); |
3846 | #endif |
3897 | #endif |
3847 | } |
3898 | } |
3848 | |
3899 | |
3849 | if (changed) |
3900 | if (changed) |
3850 | { |
3901 | { |
3851 | #ifdef XPM_BACKGROUND |
3902 | #ifdef XPM_BACKGROUND |
3852 | resize_pixmap (); |
3903 | resize_pixmap (); |
3853 | #endif |
|
|
3854 | scr_touch (true); |
3904 | scr_touch (true); |
|
|
3905 | #endif |
3855 | } |
3906 | } |
|
|
3907 | } |
3856 | break; |
3908 | break; |
3857 | |
3909 | |
3858 | case XTerm_restoreFG: |
3910 | case Rxvt_restoreFG: |
3859 | set_window_color (Color_fg, str); |
3911 | set_window_color (Color_fg, str); |
3860 | break; |
3912 | break; |
3861 | case XTerm_restoreBG: |
3913 | case Rxvt_restoreBG: |
3862 | set_window_color (Color_bg, str); |
3914 | set_window_color (Color_bg, str); |
3863 | break; |
3915 | break; |
3864 | |
3916 | |
3865 | case XTerm_logfile: |
3917 | case XTerm_logfile: |
3866 | // TODO, when secure mode? |
3918 | // TODO, when secure mode? |
3867 | break; |
3919 | break; |
3868 | |
3920 | |
3869 | #ifdef MENUBAR |
|
|
3870 | case URxvt_Menu: |
|
|
3871 | if (OPTION (Opt_insecure)) |
|
|
3872 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3873 | break; |
|
|
3874 | #endif |
|
|
3875 | #if 0 |
3921 | #if 0 |
3876 | case XTerm_dumpscreen: /* no error notices */ |
3922 | case Rxvt_dumpscreen: /* no error notices */ |
3877 | { |
3923 | { |
3878 | int fd; |
3924 | int fd; |
3879 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3925 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3880 | { |
3926 | { |
3881 | scr_dump (fd); |
3927 | scr_dump (fd); |
… | |
… | |
3912 | if (query) |
3958 | if (query) |
3913 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3959 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3914 | else |
3960 | else |
3915 | { |
3961 | { |
3916 | set_locale (str); |
3962 | set_locale (str); |
3917 | pty.set_utf8_mode (enc_utf8); |
3963 | pty->set_utf8_mode (enc_utf8); |
3918 | init_xlocale (); |
3964 | init_xlocale (); |
3919 | } |
3965 | } |
3920 | break; |
3966 | break; |
3921 | |
3967 | |
3922 | case URxvt_view_up: |
3968 | case URxvt_view_up: |
3923 | case URxvt_view_down: |
3969 | case URxvt_view_down: |
|
|
3970 | { |
3924 | int lines = atoi (str); |
3971 | int lines = atoi (str); |
3925 | |
3972 | |
3926 | if (lines) |
3973 | if (lines) |
3927 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3974 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3928 | else |
3975 | else |
3929 | { |
|
|
3930 | scr_erase_savelines (); |
3976 | scr_erase_savelines (); |
3931 | } |
3977 | } |
3932 | |
3978 | |
|
|
3979 | break; |
|
|
3980 | #endif |
|
|
3981 | |
|
|
3982 | #if ENABLE_PERL |
|
|
3983 | case URxvt_perl: |
|
|
3984 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
3985 | ; // no responses yet |
3933 | break; |
3986 | break; |
3934 | #endif |
3987 | #endif |
3935 | } |
3988 | } |
3936 | } |
3989 | } |
3937 | /*----------------------------------------------------------------------*/ |
3990 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3968 | return state; |
4021 | return state; |
3969 | } |
4022 | } |
3970 | |
4023 | |
3971 | /* we're not using priv _yet_ */ |
4024 | /* we're not using priv _yet_ */ |
3972 | void |
4025 | void |
3973 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4026 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3974 | { |
4027 | { |
3975 | unsigned int i, j; |
4028 | unsigned int i, j; |
3976 | int state; |
4029 | int state; |
3977 | |
4030 | |
3978 | static const struct |
4031 | static const struct |
… | |
… | |
3989 | { 5, PrivMode_rVideo }, |
4042 | { 5, PrivMode_rVideo }, |
3990 | { 6, PrivMode_relOrigin }, |
4043 | { 6, PrivMode_relOrigin }, |
3991 | { 7, PrivMode_Autowrap }, |
4044 | { 7, PrivMode_Autowrap }, |
3992 | // 8, bi-directional support mode |
4045 | // 8, bi-directional support mode |
3993 | { 9, PrivMode_MouseX10 }, |
4046 | { 9, PrivMode_MouseX10 }, |
3994 | #ifdef menuBar_esc |
|
|
3995 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3996 | #endif |
|
|
3997 | // 18, 19 printing-related |
4047 | // 18, 19 printing-related |
3998 | { 25, PrivMode_VisibleCursor }, |
4048 | { 25, PrivMode_VisibleCursor }, |
3999 | #ifdef scrollBar_esc |
4049 | #ifdef scrollBar_esc |
4000 | { scrollBar_esc, PrivMode_scrollBar }, |
4050 | { scrollBar_esc, PrivMode_scrollBar }, |
4001 | #endif |
4051 | #endif |
… | |
… | |
4048 | /* extra handling for values with state unkept */ |
4098 | /* extra handling for values with state unkept */ |
4049 | switch (arg[i]) |
4099 | switch (arg[i]) |
4050 | { |
4100 | { |
4051 | #if ENABLE_STYLES |
4101 | #if ENABLE_STYLES |
4052 | case 1021: |
4102 | case 1021: |
4053 | if (mode) |
4103 | set_option (Opt_intensityStyles, mode); |
4054 | SET_OPTION (Opt_intensityStyles); |
|
|
4055 | else |
|
|
4056 | CLR_OPTION (Opt_intensityStyles); |
|
|
4057 | |
4104 | |
4058 | want_refresh = 1; |
4105 | scr_touch (true); |
4059 | want_full_refresh = 1; |
|
|
4060 | break; |
4106 | break; |
4061 | #endif |
4107 | #endif |
4062 | case 1048: /* alternative cursor save */ |
4108 | case 1048: /* alternative cursor save */ |
4063 | case 1049: |
4109 | case 1049: |
4064 | if (OPTION (Opt_secondaryScreen)) |
4110 | if (OPTION (Opt_secondaryScreen)) |
… | |
… | |
4084 | case 3: /* 80/132 */ |
4130 | case 3: /* 80/132 */ |
4085 | if (priv_modes & PrivMode_132OK) |
4131 | if (priv_modes & PrivMode_132OK) |
4086 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4132 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4087 | break; |
4133 | break; |
4088 | case 4: /* smooth scrolling */ |
4134 | case 4: /* smooth scrolling */ |
4089 | if (!state) |
4135 | set_option (Opt_jumpScroll, !state); |
4090 | SET_OPTION (Opt_jumpScroll); |
|
|
4091 | else |
|
|
4092 | CLR_OPTION (Opt_jumpScroll); |
|
|
4093 | break; |
4136 | break; |
4094 | case 5: /* reverse video */ |
4137 | case 5: /* reverse video */ |
4095 | scr_rvideo_mode (state); |
4138 | scr_rvideo_mode (state); |
4096 | break; |
4139 | break; |
4097 | case 6: /* relative/absolute origins */ |
4140 | case 6: /* relative/absolute origins */ |
… | |
… | |
4103 | /* case 8: - auto repeat, can't do on a per window basis */ |
4146 | /* case 8: - auto repeat, can't do on a per window basis */ |
4104 | case 9: /* X10 mouse reporting */ |
4147 | case 9: /* X10 mouse reporting */ |
4105 | if (state) /* orthogonal */ |
4148 | if (state) /* orthogonal */ |
4106 | priv_modes &= ~PrivMode_MouseX11; |
4149 | priv_modes &= ~PrivMode_MouseX11; |
4107 | break; |
4150 | break; |
4108 | #ifdef menuBar_esc |
|
|
4109 | case menuBar_esc: |
|
|
4110 | #ifdef MENUBAR |
|
|
4111 | map_menuBar (state); |
|
|
4112 | #endif |
|
|
4113 | break; |
|
|
4114 | #endif |
|
|
4115 | #ifdef scrollBar_esc |
4151 | #ifdef scrollBar_esc |
4116 | case scrollBar_esc: |
4152 | case scrollBar_esc: |
4117 | if (scrollbar_mapping (state)) |
4153 | if (scrollbar_mapping (state)) |
4118 | { |
4154 | { |
4119 | resize_all_windows (0, 0, 0); |
4155 | resize_all_windows (0, 0, 0); |
… | |
… | |
4138 | #if 0 |
4174 | #if 0 |
4139 | case 1001: |
4175 | case 1001: |
4140 | break; /* X11 mouse highlighting */ |
4176 | break; /* X11 mouse highlighting */ |
4141 | #endif |
4177 | #endif |
4142 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4178 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4143 | if (!state) |
4179 | set_option (Opt_scrollTtyOutput, !state); |
4144 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4145 | else |
|
|
4146 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4147 | break; |
4180 | break; |
4148 | case 1011: /* scroll to bottom on key press */ |
4181 | case 1011: /* scroll to bottom on key press */ |
4149 | if (state) |
4182 | set_option (Opt_scrollTtyKeypress, state); |
4150 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4151 | else |
|
|
4152 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4153 | break; |
4183 | break; |
4154 | case 1047: /* secondary screen w/ clearing last */ |
4184 | case 1047: /* secondary screen w/ clearing last */ |
4155 | if (OPTION (Opt_secondaryScreen)) |
4185 | if (OPTION (Opt_secondaryScreen)) |
4156 | if (current_screen != PRIMARY) |
4186 | if (current_screen != PRIMARY) |
4157 | scr_erase_screen (2); |
4187 | scr_erase_screen (2); |
… | |
… | |
4295 | scr_color (Color_bg, Color_bg); |
4325 | scr_color (Color_bg, Color_bg); |
4296 | break; |
4326 | break; |
4297 | |
4327 | |
4298 | //case 50: // not variable spacing |
4328 | //case 50: // not variable spacing |
4299 | |
4329 | |
4300 | #ifndef NO_BRIGHTCOLOR |
4330 | #if ENABLE_FRILLS |
4301 | case 90: |
4331 | case 90: |
4302 | case 91: /* set bright fg color */ |
4332 | case 91: /* set bright fg color */ |
4303 | case 92: |
4333 | case 92: |
4304 | case 93: |
4334 | case 93: |
4305 | case 94: |
4335 | case 94: |
… | |
… | |
4350 | */ |
4380 | */ |
4351 | void |
4381 | void |
4352 | rxvt_term::tt_printf (const char *fmt,...) |
4382 | rxvt_term::tt_printf (const char *fmt,...) |
4353 | { |
4383 | { |
4354 | va_list arg_ptr; |
4384 | va_list arg_ptr; |
4355 | unsigned char buf[256]; |
4385 | char buf[256]; |
4356 | |
4386 | |
4357 | va_start (arg_ptr, fmt); |
4387 | va_start (arg_ptr, fmt); |
4358 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4388 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4359 | va_end (arg_ptr); |
4389 | va_end (arg_ptr); |
4360 | tt_write (buf, strlen (buf)); |
4390 | tt_write (buf, strlen (buf)); |
… | |
… | |
4365 | * or generated by us in response to a query ESC sequence. |
4395 | * or generated by us in response to a query ESC sequence. |
4366 | */ |
4396 | */ |
4367 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4397 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4368 | |
4398 | |
4369 | void |
4399 | void |
4370 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4400 | rxvt_term::tt_write (const char *data, unsigned int len) |
4371 | { |
4401 | { |
|
|
4402 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4403 | return; |
|
|
4404 | |
|
|
4405 | if (pty->pty < 0) |
|
|
4406 | return; |
|
|
4407 | |
4372 | if (v_buflen == 0) |
4408 | if (v_buflen == 0) |
4373 | { |
4409 | { |
4374 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4410 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4375 | |
4411 | |
4376 | if ((unsigned int)written == len) |
4412 | if ((unsigned int)written == len) |
4377 | return; |
4413 | return; |
4378 | |
4414 | |
4379 | data += written; |
4415 | data += written; |
4380 | len -= written; |
4416 | len -= written; |
4381 | } |
4417 | } |
4382 | |
4418 | |
4383 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4419 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4384 | |
4420 | |
4385 | memcpy (v_buffer + v_buflen, data, len); |
4421 | memcpy (v_buffer + v_buflen, data, len); |
4386 | v_buflen += len; |
4422 | v_buflen += len; |
4387 | |
4423 | |
4388 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4424 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4389 | } |
4425 | } |
4390 | |
4426 | |
4391 | void rxvt_term::pty_write () |
4427 | void rxvt_term::pty_write () |
4392 | { |
4428 | { |
4393 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4429 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4394 | |
4430 | |
4395 | if (written > 0) |
4431 | if (written > 0) |
4396 | { |
4432 | { |
4397 | v_buflen -= written; |
4433 | v_buflen -= written; |
4398 | |
4434 | |