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