… | |
… | |
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. |
… | |
… | |
50 | #include "rxvtperl.h" |
50 | #include "rxvtperl.h" |
51 | #include "version.h" |
51 | #include "version.h" |
52 | #include "command.h" |
52 | #include "command.h" |
53 | |
53 | |
54 | #if HAVE_SCHED_YIELD |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
55 | # include <sched.h> |
56 | //# include <sched.h> |
56 | #endif |
57 | #endif |
57 | |
58 | |
58 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
59 | # include "keyboard.h" |
60 | # include "keyboard.h" |
60 | #endif |
61 | #endif |
… | |
… | |
62 | #include <csignal> |
63 | #include <csignal> |
63 | |
64 | |
64 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
65 | |
66 | |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | |
|
|
68 | // exception thrown when the command parser runs out of input data |
|
|
69 | class out_of_input { } out_of_input; |
|
|
70 | |
68 | |
71 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
72 | |
70 | |
73 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
74 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
146 | || !IN_RANGE_EXC (y, 0, nrow)) |
144 | || !IN_RANGE_EXC (y, 0, nrow)) |
147 | return; |
145 | return; |
148 | |
146 | |
149 | for (;;) |
147 | for (;;) |
150 | { |
148 | { |
151 | const line_t &l = ROW(y - view_start); |
149 | const line_t &l = ROW(y + view_start); |
152 | |
150 | |
153 | text_t t = l.t[x]; |
151 | text_t t = l.t[x]; |
154 | |
152 | |
155 | if (t != NOCHAR || !x) |
153 | if (t != NOCHAR || !x) |
156 | { |
154 | { |
… | |
… | |
267 | mb[0] = ch[0]; |
265 | mb[0] = ch[0]; |
268 | len = 1; |
266 | len = 1; |
269 | } |
267 | } |
270 | |
268 | |
271 | if (len > 0) |
269 | if (len > 0) |
272 | tt_write ((unsigned char *)mb, len); |
270 | tt_write (mb, len); |
273 | else |
271 | else |
274 | scr_bell (); |
272 | scr_bell (); |
275 | } |
273 | } |
276 | |
274 | |
277 | iso14755buf = 0; |
275 | iso14755buf = 0; |
… | |
… | |
305 | KeySym keysym; |
303 | KeySym keysym; |
306 | #ifdef DEBUG_CMD |
304 | #ifdef DEBUG_CMD |
307 | static int debug_key = 1; /* accessible by a debugger only */ |
305 | static int debug_key = 1; /* accessible by a debugger only */ |
308 | #endif |
306 | #endif |
309 | int valid_keysym; |
307 | int valid_keysym; |
310 | unsigned char kbuf[KBUFSZ]; |
308 | char kbuf[KBUFSZ]; |
311 | |
309 | |
312 | /* |
310 | /* |
313 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
311 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
314 | * escape sequence to toggle the Keypad. |
312 | * escape sequence to toggle the Keypad. |
315 | * |
313 | * |
… | |
… | |
333 | Status status_return; |
331 | Status status_return; |
334 | |
332 | |
335 | #if 0 |
333 | #if 0 |
336 | #ifdef X_HAVE_UTF8_STRING |
334 | #ifdef X_HAVE_UTF8_STRING |
337 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
335 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
336 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
339 | KBUFSZ, &keysym, &status_return); |
337 | KBUFSZ, &keysym, &status_return); |
340 | else |
338 | else |
341 | #endif |
339 | #endif |
342 | #endif |
340 | #endif |
343 | { |
341 | { |
… | |
… | |
380 | || status_return == XLookupBoth; |
378 | || status_return == XLookupBoth; |
381 | } |
379 | } |
382 | else |
380 | else |
383 | #endif |
381 | #endif |
384 | { |
382 | { |
385 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
383 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
386 | valid_keysym = keysym != NoSymbol; |
384 | valid_keysym = keysym != NoSymbol; |
387 | } |
385 | } |
388 | |
386 | |
389 | if (valid_keysym) |
387 | if (valid_keysym) |
390 | { |
388 | { |
… | |
… | |
442 | scr_move_to (0, 1); |
440 | scr_move_to (0, 1); |
443 | return; |
441 | return; |
444 | } |
442 | } |
445 | else if (keysym == XK_End) |
443 | else if (keysym == XK_End) |
446 | { |
444 | { |
447 | scr_move_to (1, 0); |
445 | scr_move_to (1, 1); |
448 | return; |
446 | return; |
449 | } |
447 | } |
450 | } |
448 | } |
451 | #endif |
449 | #endif |
452 | } |
450 | } |
… | |
… | |
463 | { |
461 | { |
464 | switch (keysym) |
462 | switch (keysym) |
465 | { |
463 | { |
466 | /* normal XTerm key bindings */ |
464 | /* normal XTerm key bindings */ |
467 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
465 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
468 | selection_request (ev.time, 0, 0); |
466 | selection_request (ev.time); |
469 | return; |
467 | return; |
470 | #if TODO |
468 | #if TODO |
471 | /* rxvt extras */ |
469 | /* rxvt extras */ |
472 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
470 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
473 | change_font (FONT_UP); |
471 | change_font (FONT_UP); |
… | |
… | |
854 | { |
852 | { |
855 | #ifdef META8_OPTION |
853 | #ifdef META8_OPTION |
856 | /* set 8-bit on */ |
854 | /* set 8-bit on */ |
857 | if (meta && (meta_char == 0x80)) |
855 | if (meta && (meta_char == 0x80)) |
858 | { |
856 | { |
859 | unsigned char *ch; |
857 | char *ch; |
860 | |
858 | |
861 | for (ch = kbuf; ch < kbuf + len; ch++) |
859 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | *ch |= 0x80; |
860 | *ch |= 0x80; |
863 | |
861 | |
864 | meta = 0; |
862 | meta = 0; |
865 | } |
863 | } |
866 | #endif |
864 | #endif |
867 | /* nil */ ; |
865 | /* nil */ ; |
868 | } |
866 | } |
869 | } |
867 | } |
|
|
868 | |
|
|
869 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
870 | return; |
870 | |
871 | |
871 | if (len <= 0) |
872 | if (len <= 0) |
872 | return; /* not mapped */ |
873 | return; /* not mapped */ |
873 | |
874 | |
874 | if (OPTION (Opt_scrollTtyKeypress)) |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
897 | #ifdef META8_OPTION |
898 | #ifdef META8_OPTION |
898 | && meta_char == C0_ESC |
899 | && meta_char == C0_ESC |
899 | #endif |
900 | #endif |
900 | ) |
901 | ) |
901 | { |
902 | { |
902 | const unsigned char ch = C0_ESC; |
903 | const char ch = C0_ESC; |
903 | tt_write (&ch, 1); |
904 | tt_write (&ch, 1); |
904 | } |
905 | } |
905 | |
906 | |
906 | #if defined(DEBUG_CMD) |
907 | #if defined(DEBUG_CMD) |
907 | /* Display keyboard buffer contents */ |
908 | /* Display keyboard buffer contents */ |
… | |
… | |
915 | #endif /* DEBUG_CMD */ |
916 | #endif /* DEBUG_CMD */ |
916 | tt_write (kbuf, (unsigned int)len); |
917 | tt_write (kbuf, (unsigned int)len); |
917 | } |
918 | } |
918 | /*}}} */ |
919 | /*}}} */ |
919 | |
920 | |
920 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
921 | #if defined (KEYSYM_RESOURCE) |
921 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
922 | /* attempt to `write' count to the input buffer */ |
|
|
923 | unsigned int |
922 | unsigned int |
924 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
923 | rxvt_term::cmd_write (const char *str, unsigned int count) |
925 | { |
924 | { |
926 | unsigned int n, s; |
925 | unsigned int n, s; |
927 | |
926 | |
928 | n = cmdbuf_ptr - cmdbuf_base; |
927 | n = cmdbuf_ptr - cmdbuf_base; |
929 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
928 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
966 | } |
965 | } |
967 | #endif |
966 | #endif |
968 | |
967 | |
969 | if (want_refresh) |
968 | if (want_refresh) |
970 | { |
969 | { |
|
|
970 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
971 | { |
|
|
972 | int row = view_start; |
|
|
973 | int end_row = row + nrow; |
|
|
974 | |
|
|
975 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
976 | --row; |
|
|
977 | |
|
|
978 | do |
|
|
979 | { |
|
|
980 | int start_row = row; |
|
|
981 | line_t *l; |
|
|
982 | |
|
|
983 | do |
|
|
984 | { |
|
|
985 | l = &ROW (row++); |
|
|
986 | |
|
|
987 | if (!(l->f & LINE_FILTERED)) |
|
|
988 | { |
|
|
989 | // line not filtered, mark it as filtered |
|
|
990 | l->f |= LINE_FILTERED; |
|
|
991 | while (l->is_longer ()) |
|
|
992 | { |
|
|
993 | l = &ROW (row++); |
|
|
994 | l->f |= LINE_FILTERED; |
|
|
995 | } |
|
|
996 | |
|
|
997 | // and filter it |
|
|
998 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
999 | |
|
|
1000 | break; |
|
|
1001 | } |
|
|
1002 | } |
|
|
1003 | while (l->is_longer () && row < end_row); |
|
|
1004 | } |
|
|
1005 | while (row < end_row); |
|
|
1006 | } |
|
|
1007 | |
971 | scr_refresh (refresh_type); |
1008 | scr_refresh (); |
972 | scrollbar_show (1); |
1009 | scrollbar_show (1); |
973 | #ifdef USE_XIM |
1010 | #ifdef USE_XIM |
974 | IMSendSpot (); |
1011 | IMSendSpot (); |
975 | #endif |
1012 | #endif |
976 | } |
1013 | } |
… | |
… | |
979 | } |
1016 | } |
980 | |
1017 | |
981 | void |
1018 | void |
982 | rxvt_term::check_cb (check_watcher &w) |
1019 | rxvt_term::check_cb (check_watcher &w) |
983 | { |
1020 | { |
984 | SET_R (this); |
1021 | make_current (); |
985 | SET_LOCALE (locale); |
|
|
986 | |
1022 | |
987 | display->flush (); |
1023 | display->flush (); |
988 | |
1024 | |
989 | if (want_refresh && !flush_ev.active) |
1025 | if (want_refresh && !flush_ev.active) |
990 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1026 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
991 | } |
1027 | } |
992 | |
1028 | |
993 | void |
1029 | void |
994 | rxvt_term::flush_cb (time_watcher &w) |
1030 | rxvt_term::flush_cb (time_watcher &w) |
995 | { |
1031 | { |
996 | SET_R (this); |
1032 | make_current (); |
997 | SET_LOCALE (locale); |
|
|
998 | |
1033 | |
999 | refresh_limit = 1; |
1034 | refresh_limit = 1; |
1000 | refresh_count = 0; |
1035 | refresh_count = 0; |
1001 | flush (); |
1036 | flush (); |
1002 | } |
1037 | } |
… | |
… | |
1006 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1041 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1007 | { |
1042 | { |
1008 | hidden_cursor = !hidden_cursor; |
1043 | hidden_cursor = !hidden_cursor; |
1009 | want_refresh = 1; |
1044 | want_refresh = 1; |
1010 | |
1045 | |
1011 | w.start (w.at + BLINK_INTERVAL); |
1046 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1012 | } |
1047 | } |
1013 | #endif |
1048 | #endif |
1014 | |
1049 | |
1015 | #ifdef TEXT_BLINK |
1050 | #ifdef TEXT_BLINK |
1016 | void |
1051 | void |
… | |
… | |
1030 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1065 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1031 | { |
1066 | { |
1032 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1067 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1033 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1068 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1034 | { |
1069 | { |
1035 | refresh_type |= SMOOTH_REFRESH; |
|
|
1036 | want_refresh = 1; |
1070 | want_refresh = 1; |
1037 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1038 | } |
1072 | } |
1039 | } |
1073 | } |
1040 | #endif |
1074 | #endif |
… | |
… | |
1044 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1078 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1045 | { |
1079 | { |
1046 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1080 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1047 | { |
1081 | { |
1048 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1082 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1049 | refresh_type |= SMOOTH_REFRESH; |
|
|
1050 | want_refresh = 1; |
1083 | want_refresh = 1; |
1051 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1084 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1052 | } |
1085 | } |
1053 | } |
1086 | } |
1054 | #endif |
1087 | #endif |
… | |
… | |
1059 | { |
1092 | { |
1060 | if (mouse_slip_wheel_speed == 0 |
1093 | if (mouse_slip_wheel_speed == 0 |
1061 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1094 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1062 | : scr_page (UP, mouse_slip_wheel_speed)) |
1095 | : scr_page (UP, mouse_slip_wheel_speed)) |
1063 | { |
1096 | { |
1064 | if (view_start == nsaved || |
1097 | if (view_start == top_row || view_start == 0) |
1065 | view_start == 0) |
|
|
1066 | mouse_slip_wheel_speed = 0; |
1098 | mouse_slip_wheel_speed = 0; |
1067 | |
1099 | |
1068 | refresh_type |= SMOOTH_REFRESH; |
|
|
1069 | want_refresh = 1; |
1100 | want_refresh = 1; |
1070 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1101 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | } |
1102 | } |
1072 | } |
1103 | } |
1073 | #endif |
1104 | #endif |
… | |
… | |
1095 | { |
1126 | { |
1096 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1127 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | |
1128 | |
1098 | if (CBUFSIZ == n) |
1129 | if (CBUFSIZ == n) |
1099 | { |
1130 | { |
1100 | 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"); |
1101 | n = 0; |
1132 | n = 0; |
1102 | } |
1133 | } |
1103 | |
1134 | |
1104 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1135 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | cmdbuf_ptr = cmdbuf_base; |
1136 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_endp = cmdbuf_ptr + n; |
1137 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | |
1138 | |
1108 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1139 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | |
1140 | |
1110 | if (r > 0) |
1141 | if (r > 0) |
1111 | { |
1142 | { |
1112 | cmdbuf_endp += r; |
1143 | cmdbuf_endp += r; |
1113 | return true; |
1144 | return true; |
… | |
… | |
1131 | } |
1162 | } |
1132 | |
1163 | |
1133 | void |
1164 | void |
1134 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1165 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1135 | { |
1166 | { |
1136 | SET_R (this); |
1167 | make_current (); |
1137 | SET_LOCALE (locale); |
|
|
1138 | |
1168 | |
1139 | if (revents & EVENT_READ) |
1169 | if (revents & EVENT_READ) |
1140 | // loop, but don't allow a single term to monopolize us |
1170 | // loop, but don't allow a single term to monopolize us |
1141 | while (pty_fill ()) |
1171 | while (pty_fill ()) |
1142 | if (cmd_parse ()) |
1172 | if (cmd_parse ()) |
… | |
… | |
1162 | |
1192 | |
1163 | #ifdef POINTER_BLANK |
1193 | #ifdef POINTER_BLANK |
1164 | void |
1194 | void |
1165 | rxvt_term::pointer_blank () |
1195 | rxvt_term::pointer_blank () |
1166 | { |
1196 | { |
1167 | if (! OPTION (Opt_pointerBlank)) |
1197 | if (!OPTION (Opt_pointerBlank)) |
1168 | return; |
1198 | return; |
1169 | |
1199 | |
1170 | XDefineCursor (display->display, vt, display->blank_cursor); |
1200 | XDefineCursor (display->display, vt, display->blank_cursor); |
1171 | XFlush (display->display); |
1201 | XFlush (display->display); |
1172 | |
1202 | |
… | |
… | |
1174 | } |
1204 | } |
1175 | |
1205 | |
1176 | void |
1206 | void |
1177 | rxvt_term::pointer_cb (time_watcher &w) |
1207 | rxvt_term::pointer_cb (time_watcher &w) |
1178 | { |
1208 | { |
1179 | SET_R (this); |
1209 | make_current (); |
1180 | SET_LOCALE (locale); |
|
|
1181 | |
1210 | |
1182 | pointer_blank (); |
1211 | pointer_blank (); |
1183 | } |
1212 | } |
1184 | #endif |
1213 | #endif |
1185 | |
1214 | |
… | |
… | |
1264 | |
1293 | |
1265 | /*{{{ process an X event */ |
1294 | /*{{{ process an X event */ |
1266 | void |
1295 | void |
1267 | rxvt_term::x_cb (XEvent &ev) |
1296 | rxvt_term::x_cb (XEvent &ev) |
1268 | { |
1297 | { |
|
|
1298 | make_current (); |
|
|
1299 | |
1269 | dDisp; |
1300 | dDisp; |
1270 | |
1301 | |
1271 | SET_R (this); |
1302 | if (ev.xany.window == vt |
1272 | SET_LOCALE (locale); |
1303 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1304 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1305 | return; |
1273 | |
1306 | |
1274 | #if defined(CURSOR_BLINK) |
1307 | // for XQueryPointer |
1275 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1276 | { |
|
|
1277 | if (hidden_cursor) |
|
|
1278 | { |
|
|
1279 | hidden_cursor = 0; |
|
|
1280 | want_refresh = 1; |
|
|
1281 | } |
|
|
1282 | |
|
|
1283 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1284 | } |
|
|
1285 | #endif |
|
|
1286 | |
|
|
1287 | #if defined(POINTER_BLANK) |
|
|
1288 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1289 | { |
|
|
1290 | if (ev.type == MotionNotify |
|
|
1291 | || ev.type == ButtonPress |
|
|
1292 | || ev.type == ButtonRelease) |
|
|
1293 | if (hidden_pointer) |
|
|
1294 | pointer_unblank (); |
|
|
1295 | |
|
|
1296 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1297 | pointer_blank (); |
|
|
1298 | } |
|
|
1299 | #endif |
|
|
1300 | |
|
|
1301 | Window unused_root, unused_child; |
1308 | Window unused_root, unused_child; |
1302 | int unused_root_x, unused_root_y; |
1309 | int unused_root_x, unused_root_y; |
1303 | unsigned int unused_mask; |
1310 | unsigned int unused_mask; |
1304 | |
1311 | |
1305 | switch (ev.type) |
1312 | switch (ev.type) |
… | |
… | |
1312 | |
1319 | |
1313 | break; |
1320 | break; |
1314 | |
1321 | |
1315 | case KeyRelease: |
1322 | case KeyRelease: |
1316 | { |
1323 | { |
1317 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1324 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1318 | KeySym ks; |
1325 | KeySym keysym; |
1319 | |
1326 | |
1320 | 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 :/ |
1321 | #endif |
1328 | #endif |
1322 | |
1329 | |
1323 | #if ENABLE_FRILLS || ISO_14755 |
1330 | #if ENABLE_FRILLS || ISO_14755 |
1324 | // ISO 14755 support |
1331 | // ISO 14755 support |
1325 | if (iso14755buf) |
1332 | if (iso14755buf) |
… | |
… | |
1330 | # endif |
1337 | # endif |
1331 | # if ISO_14755 |
1338 | # if ISO_14755 |
1332 | // iso14755 part 5.2 handling: release time |
1339 | // iso14755 part 5.2 handling: release time |
1333 | // first: controls |
1340 | // first: controls |
1334 | if ((ev.xkey.state & ControlMask) |
1341 | if ((ev.xkey.state & ControlMask) |
1335 | && ((ks >= 0x40 && ks <= 0x5f) |
1342 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1336 | || (ks >= 0x61 && ks <= 0x7f))) |
1343 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1337 | { |
1344 | { |
1338 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1345 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1339 | commit_iso14755 (); |
1346 | commit_iso14755 (); |
1340 | return; // case-break; |
1347 | goto skip_switch; |
1341 | } |
1348 | } |
1342 | |
1349 | |
1343 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1350 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1344 | if (i[0] == ks) |
1351 | if (i[0] == keysym) |
1345 | { |
1352 | { |
1346 | iso14755buf = ISO_14755_51 | i[1]; |
1353 | iso14755buf = ISO_14755_51 | i[1]; |
1347 | commit_iso14755 (); |
1354 | commit_iso14755 (); |
1348 | return; // case-break; |
1355 | goto skip_switch; |
1349 | } |
1356 | } |
1350 | |
1357 | |
1351 | scr_bell (); |
1358 | scr_bell (); |
1352 | # endif |
1359 | # endif |
1353 | iso14755buf = 0; |
1360 | iso14755buf = 0; |
… | |
… | |
1372 | else |
1379 | else |
1373 | iso14755buf = 0; |
1380 | iso14755buf = 0; |
1374 | } |
1381 | } |
1375 | #endif |
1382 | #endif |
1376 | |
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 | |
1377 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1388 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1378 | if (!(ev.xkey.state & ControlMask)) |
1389 | if (!(ev.xkey.state & ControlMask)) |
1379 | slip_wheel_ev.stop (); |
1390 | slip_wheel_ev.stop (); |
1380 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1391 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1381 | mouse_slip_wheel_speed = 0; |
1392 | mouse_slip_wheel_speed = 0; |
1382 | #endif |
1393 | #endif |
1383 | break; |
1394 | break; |
1384 | } |
1395 | } |
1385 | |
1396 | |
… | |
… | |
1391 | button_release (ev.xbutton); |
1402 | button_release (ev.xbutton); |
1392 | break; |
1403 | break; |
1393 | |
1404 | |
1394 | case ClientMessage: |
1405 | case ClientMessage: |
1395 | if (ev.xclient.format == 32 |
1406 | if (ev.xclient.format == 32 |
1396 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1407 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1397 | { |
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 | { |
1398 | 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))) |
1399 | destroy (); |
1416 | destroy (); |
|
|
1417 | } |
1400 | #if ENABLE_EWMH |
1418 | #if ENABLE_EWMH |
1401 | 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]) |
1402 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1403 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1404 | &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 | } |
1405 | #endif |
1434 | #endif |
1406 | } |
1435 | } |
1407 | #if ENABLE_XEMBED |
|
|
1408 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1409 | { |
|
|
1410 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1411 | focus_in (); |
|
|
1412 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1413 | focus_out (); |
|
|
1414 | } |
|
|
1415 | #endif |
|
|
1416 | #ifdef OFFIX_DND |
|
|
1417 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1418 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1419 | && (ev.xclient.data.l[0] == DndFile |
|
|
1420 | || ev.xclient.data.l[0] == DndDir |
|
|
1421 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1422 | { |
|
|
1423 | /* Get Dnd data */ |
|
|
1424 | Atom ActualType; |
|
|
1425 | int ActualFormat; |
|
|
1426 | unsigned char *data; |
|
|
1427 | unsigned long Size, RemainingBytes; |
|
|
1428 | |
|
|
1429 | XGetWindowProperty (disp, display->root, |
|
|
1430 | xa[XA_DNDSELECTION], |
|
|
1431 | 0L, 1000000L, |
|
|
1432 | False, AnyPropertyType, |
|
|
1433 | &ActualType, &ActualFormat, |
|
|
1434 | &Size, &RemainingBytes, |
|
|
1435 | &data); |
|
|
1436 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1437 | XFree (data); |
|
|
1438 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1439 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1440 | } |
|
|
1441 | #endif /* OFFIX_DND */ |
|
|
1442 | break; |
1436 | break; |
1443 | |
1437 | |
1444 | case MappingNotify: |
1438 | case MappingNotify: |
1445 | XRefreshKeyboardMapping (&ev.xmapping); |
1439 | XRefreshKeyboardMapping (&ev.xmapping); |
1446 | break; |
1440 | break; |
… | |
… | |
1488 | { |
1482 | { |
1489 | seen_resize = 1; |
1483 | seen_resize = 1; |
1490 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1484 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1491 | } |
1485 | } |
1492 | |
1486 | |
|
|
1487 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1488 | |
1493 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1489 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1494 | if (OPTION (Opt_transparent)) |
1490 | if (OPTION (Opt_transparent)) |
1495 | check_our_parents (); |
1491 | check_our_parents (); |
1496 | #endif |
1492 | #endif |
1497 | } |
1493 | } |
… | |
… | |
1515 | |
1511 | |
1516 | case SelectionRequest: |
1512 | case SelectionRequest: |
1517 | selection_send (ev.xselectionrequest); |
1513 | selection_send (ev.xselectionrequest); |
1518 | break; |
1514 | break; |
1519 | |
1515 | |
|
|
1516 | case MapNotify: |
|
|
1517 | mapped = 1; |
|
|
1518 | #ifdef TEXT_BLINK |
|
|
1519 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1520 | #endif |
|
|
1521 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1522 | break; |
|
|
1523 | |
1520 | case UnmapNotify: |
1524 | case UnmapNotify: |
1521 | mapped = 0; |
1525 | mapped = 0; |
1522 | #ifdef TEXT_BLINK |
1526 | #ifdef TEXT_BLINK |
1523 | text_blink_ev.stop (); |
1527 | text_blink_ev.stop (); |
1524 | #endif |
1528 | #endif |
1525 | break; |
1529 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1526 | |
|
|
1527 | case MapNotify: |
|
|
1528 | mapped = 1; |
|
|
1529 | #ifdef TEXT_BLINK |
|
|
1530 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1531 | #endif |
|
|
1532 | break; |
1530 | break; |
1533 | |
1531 | |
1534 | #ifdef TRANSPARENT |
1532 | #ifdef TRANSPARENT |
1535 | case ReparentNotify: |
1533 | case ReparentNotify: |
1536 | rootwin_cb (ev); |
1534 | rootwin_cb (ev); |
… | |
… | |
1550 | |
1548 | |
1551 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1549 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1552 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1550 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1553 | ev.xexpose.width, ev.xexpose.height, False); |
1551 | ev.xexpose.width, ev.xexpose.height, False); |
1554 | |
1552 | |
1555 | scr_refresh (refresh_type); |
1553 | want_refresh = 1; |
1556 | } |
1554 | } |
1557 | else |
1555 | else |
1558 | { |
1556 | { |
1559 | XEvent unused_event; |
1557 | XEvent unused_event; |
1560 | |
1558 | |
… | |
… | |
1566 | if (isScrollbarWindow (ev.xany.window)) |
1564 | if (isScrollbarWindow (ev.xany.window)) |
1567 | { |
1565 | { |
1568 | scrollBar.setIdle (); |
1566 | scrollBar.setIdle (); |
1569 | scrollbar_show (0); |
1567 | scrollbar_show (0); |
1570 | } |
1568 | } |
1571 | #ifdef MENUBAR |
|
|
1572 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1573 | menubar_expose (); |
|
|
1574 | #endif |
|
|
1575 | |
1569 | |
1576 | #ifdef TRANSPARENT |
1570 | #ifdef TRANSPARENT |
1577 | if (am_transparent && ev.xany.window == parent[0]) |
1571 | if (am_transparent && ev.xany.window == parent[0]) |
1578 | XClearWindow (disp, ev.xany.window); |
1572 | XClearWindow (disp, ev.xany.window); |
1579 | #endif |
1573 | #endif |
… | |
… | |
1583 | case MotionNotify: |
1577 | case MotionNotify: |
1584 | #ifdef POINTER_BLANK |
1578 | #ifdef POINTER_BLANK |
1585 | if (hidden_pointer) |
1579 | if (hidden_pointer) |
1586 | pointer_unblank (); |
1580 | pointer_unblank (); |
1587 | #endif |
1581 | #endif |
1588 | #if MENUBAR |
|
|
1589 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1590 | { |
|
|
1591 | menubar_control (ev.xbutton); |
|
|
1592 | break; |
|
|
1593 | } |
|
|
1594 | #endif |
|
|
1595 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1582 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1596 | break; |
1583 | break; |
1597 | |
1584 | |
1598 | if (ev.xany.window == vt) |
1585 | if (ev.xany.window == vt) |
1599 | { |
1586 | { |
|
|
1587 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1588 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1589 | ; // nop |
1600 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1590 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1601 | { |
1591 | { |
1602 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1592 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1603 | ; |
1593 | ; |
1604 | |
1594 | |
1605 | XQueryPointer (disp, vt, |
1595 | XQueryPointer (disp, vt, |
… | |
… | |
1685 | &unused_root_x, &unused_root_y, |
1675 | &unused_root_x, &unused_root_y, |
1686 | &ev.xbutton.x, &ev.xbutton.y, |
1676 | &ev.xbutton.x, &ev.xbutton.y, |
1687 | &unused_mask); |
1677 | &unused_mask); |
1688 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1678 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1689 | scrollbar_size ()); |
1679 | scrollbar_size ()); |
1690 | scr_refresh (refresh_type); |
1680 | want_refresh = 1; |
1691 | refresh_limit = 0; |
1681 | refresh_limit = 0; |
1692 | scrollbar_show (1); |
1682 | scrollbar_show (1); |
1693 | } |
1683 | } |
1694 | break; |
1684 | break; |
1695 | } |
1685 | } |
|
|
1686 | |
|
|
1687 | skip_switch: ; |
|
|
1688 | |
|
|
1689 | #if defined(CURSOR_BLINK) |
|
|
1690 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1691 | { |
|
|
1692 | if (hidden_cursor) |
|
|
1693 | { |
|
|
1694 | hidden_cursor = 0; |
|
|
1695 | want_refresh = 1; |
|
|
1696 | } |
|
|
1697 | |
|
|
1698 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1699 | } |
|
|
1700 | #endif |
|
|
1701 | |
|
|
1702 | #if defined(POINTER_BLANK) |
|
|
1703 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1704 | { |
|
|
1705 | if (ev.type == MotionNotify |
|
|
1706 | || ev.type == ButtonPress |
|
|
1707 | || ev.type == ButtonRelease) |
|
|
1708 | if (hidden_pointer) |
|
|
1709 | pointer_unblank (); |
|
|
1710 | |
|
|
1711 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1712 | pointer_blank (); |
|
|
1713 | } |
|
|
1714 | #endif |
1696 | } |
1715 | } |
1697 | |
1716 | |
1698 | void |
1717 | void |
1699 | rxvt_term::focus_in () |
1718 | rxvt_term::focus_in () |
1700 | { |
1719 | { |
1701 | if (!focus) |
1720 | if (!focus) |
1702 | { |
1721 | { |
1703 | focus = 1; |
1722 | focus = 1; |
1704 | want_refresh = 1; |
1723 | want_refresh = 1; |
1705 | |
1724 | |
1706 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1725 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1707 | |
1726 | |
1708 | #if USE_XIM |
1727 | #if USE_XIM |
1709 | if (Input_Context != NULL) |
1728 | if (Input_Context != NULL) |
1710 | { |
1729 | { |
1711 | IMSetStatusPosition (); |
1730 | IMSetStatusPosition (); |
1712 | XSetICFocus (Input_Context); |
1731 | XSetICFocus (Input_Context); |
1713 | } |
1732 | } |
1714 | #endif |
1733 | #endif |
1715 | #if CURSOR_BLINK |
1734 | #if CURSOR_BLINK |
1716 | if (OPTION (Opt_cursorBlink)) |
1735 | if (OPTION (Opt_cursorBlink)) |
1717 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1736 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1718 | #endif |
1737 | #endif |
1719 | #if OFF_FOCUS_FADING |
1738 | #if OFF_FOCUS_FADING |
1720 | if (rs[Rs_fade]) |
1739 | if (rs[Rs_fade]) |
1721 | { |
1740 | { |
1722 | pix_colors = pix_colors_focused; |
1741 | pix_colors = pix_colors_focused; |
… | |
… | |
1732 | if (focus) |
1751 | if (focus) |
1733 | { |
1752 | { |
1734 | focus = 0; |
1753 | focus = 0; |
1735 | want_refresh = 1; |
1754 | want_refresh = 1; |
1736 | |
1755 | |
1737 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1756 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1738 | |
1757 | |
1739 | #if ENABLE_FRILLS || ISO_14755 |
1758 | #if ENABLE_FRILLS || ISO_14755 |
1740 | if (iso14755buf) |
1759 | if (iso14755buf) |
1741 | { |
1760 | { |
1742 | iso14755buf = 0; |
1761 | iso14755buf = 0; |
… | |
… | |
1766 | |
1785 | |
1767 | #if TRANSPARENT |
1786 | #if TRANSPARENT |
1768 | void |
1787 | void |
1769 | rxvt_term::rootwin_cb (XEvent &ev) |
1788 | rxvt_term::rootwin_cb (XEvent &ev) |
1770 | { |
1789 | { |
1771 | SET_R (this); |
1790 | make_current (); |
1772 | SET_LOCALE (locale); |
|
|
1773 | |
1791 | |
1774 | switch (ev.type) |
1792 | switch (ev.type) |
1775 | { |
1793 | { |
1776 | case PropertyNotify: |
1794 | case PropertyNotify: |
1777 | /* |
1795 | /* |
… | |
… | |
1825 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1843 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1826 | if (ev.button == MEvent.button && clickintime) |
1844 | if (ev.button == MEvent.button && clickintime) |
1827 | { |
1845 | { |
1828 | /* same button, within alloted time */ |
1846 | /* same button, within alloted time */ |
1829 | MEvent.clicks++; |
1847 | MEvent.clicks++; |
|
|
1848 | |
1830 | if (MEvent.clicks > 1) |
1849 | if (MEvent.clicks > 1) |
1831 | { |
1850 | { |
1832 | /* only report double clicks */ |
1851 | /* only report double clicks */ |
1833 | MEvent.clicks = 2; |
1852 | MEvent.clicks = 2; |
1834 | mouse_report (ev); |
1853 | mouse_report (ev); |
… | |
… | |
1854 | else |
1873 | else |
1855 | { |
1874 | { |
1856 | if (ev.button != MEvent.button) |
1875 | if (ev.button != MEvent.button) |
1857 | MEvent.clicks = 0; |
1876 | MEvent.clicks = 0; |
1858 | |
1877 | |
1859 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
1878 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
1860 | switch (ev.button) |
1879 | switch (ev.button) |
1861 | { |
1880 | { |
1862 | case Button1: |
1881 | case Button1: |
1863 | /* allow meta + click to select rectangular areas */ |
1882 | /* allow meta + click to select rectangular areas */ |
1864 | /* should be done in screen.C */ |
1883 | /* should be done in screen.C */ |
… | |
… | |
1867 | #else |
1886 | #else |
1868 | selection.rect = false; |
1887 | selection.rect = false; |
1869 | #endif |
1888 | #endif |
1870 | |
1889 | |
1871 | /* allow shift+left click to extend selection */ |
1890 | /* allow shift+left click to extend selection */ |
1872 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1891 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1873 | { |
1892 | { |
1874 | if (MEvent.button == Button1 && clickintime) |
1893 | if (MEvent.button == Button1 && clickintime) |
1875 | selection_rotate (ev.x, ev.y); |
1894 | selection_rotate (ev.x, ev.y); |
1876 | else |
1895 | else |
1877 | selection_extend (ev.x, ev.y, 1); |
1896 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2042 | } |
2061 | } |
2043 | |
2062 | |
2044 | break; |
2063 | break; |
2045 | } |
2064 | } |
2046 | } |
2065 | } |
|
|
2066 | |
2047 | return; |
2067 | return; |
2048 | } |
2068 | } |
2049 | #if MENUBAR |
|
|
2050 | /* |
|
|
2051 | * Menubar window processing of button press |
|
|
2052 | */ |
|
|
2053 | if (isMenuBarWindow (ev.window)) |
|
|
2054 | menubar_control (ev); |
|
|
2055 | #endif |
|
|
2056 | } |
2069 | } |
2057 | |
2070 | |
2058 | void |
2071 | void |
2059 | rxvt_term::button_release (XButtonEvent &ev) |
2072 | rxvt_term::button_release (XButtonEvent &ev) |
2060 | { |
2073 | { |
… | |
… | |
2066 | |
2079 | |
2067 | if (scrollbar_isUpDn ()) |
2080 | if (scrollbar_isUpDn ()) |
2068 | { |
2081 | { |
2069 | scrollBar.setIdle (); |
2082 | scrollBar.setIdle (); |
2070 | scrollbar_show (0); |
2083 | scrollbar_show (0); |
2071 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2072 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2073 | #endif |
|
|
2074 | } |
2084 | } |
2075 | |
2085 | |
2076 | #ifdef SELECTION_SCROLLING |
2086 | #ifdef SELECTION_SCROLLING |
2077 | if (sel_scroll_ev.active) |
2087 | if (sel_scroll_ev.active) |
2078 | sel_scroll_ev.stop(); |
2088 | sel_scroll_ev.stop(); |
… | |
… | |
2116 | if (priv_modes & PrivMode_mouse_report |
2126 | if (priv_modes & PrivMode_mouse_report |
2117 | && bypass_keystate |
2127 | && bypass_keystate |
2118 | && ev.button == Button1 && MEvent.clicks <= 1) |
2128 | && ev.button == Button1 && MEvent.clicks <= 1) |
2119 | selection_extend (ev.x, ev.y, 0); |
2129 | selection_extend (ev.x, ev.y, 0); |
2120 | |
2130 | |
|
|
2131 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2132 | return; |
|
|
2133 | |
2121 | switch (ev.button) |
2134 | switch (ev.button) |
2122 | { |
2135 | { |
2123 | case Button1: |
2136 | case Button1: |
2124 | case Button3: |
2137 | case Button3: |
2125 | selection_make (ev.time); |
2138 | selection_make (ev.time); |
2126 | break; |
2139 | break; |
|
|
2140 | |
2127 | case Button2: |
2141 | case Button2: |
2128 | selection_request (ev.time, ev.x, ev.y); |
2142 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2143 | selection_request (ev.time, ev.state & ShiftMask ? Sel_Clipboard : Sel_Primary); |
2129 | break; |
2144 | break; |
|
|
2145 | |
2130 | #ifdef MOUSE_WHEEL |
2146 | #ifdef MOUSE_WHEEL |
2131 | case Button4: |
2147 | case Button4: |
2132 | case Button5: |
2148 | case Button5: |
2133 | { |
2149 | { |
2134 | int i; |
2150 | int i; |
… | |
… | |
2156 | slip_wheel_ev.start (); |
2172 | slip_wheel_ev.start (); |
2157 | } |
2173 | } |
2158 | else |
2174 | else |
2159 | { |
2175 | { |
2160 | # endif |
2176 | # endif |
2161 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2162 | scr_page (v, i); |
2177 | scr_page (v, i); |
2163 | scr_refresh (SMOOTH_REFRESH); |
|
|
2164 | scrollbar_show (1); |
2178 | scrollbar_show (1); |
2165 | # else |
|
|
2166 | while (i--) |
|
|
2167 | { |
|
|
2168 | scr_page (v, 1); |
|
|
2169 | scr_refresh (SMOOTH_REFRESH); |
|
|
2170 | scrollbar_show (1); |
|
|
2171 | } |
|
|
2172 | # endif |
|
|
2173 | # ifdef MOUSE_SLIP_WHEELING |
2179 | # ifdef MOUSE_SLIP_WHEELING |
2174 | } |
2180 | } |
2175 | #endif |
2181 | # endif |
2176 | } |
2182 | } |
2177 | break; |
2183 | break; |
2178 | #endif |
2184 | #endif |
2179 | } |
2185 | } |
2180 | } |
2186 | } |
2181 | #ifdef MENUBAR |
|
|
2182 | else if (isMenuBarWindow (ev.window)) |
|
|
2183 | menubar_control (ev); |
|
|
2184 | #endif |
|
|
2185 | } |
2187 | } |
2186 | |
2188 | |
2187 | #ifdef TRANSPARENT |
2189 | #ifdef TRANSPARENT |
2188 | #if TINTING |
2190 | #if TINTING |
2189 | /* taken from aterm-0.4.2 */ |
2191 | /* taken from aterm-0.4.2 */ |
… | |
… | |
2669 | |
2671 | |
2670 | bool |
2672 | bool |
2671 | rxvt_term::cmd_parse () |
2673 | rxvt_term::cmd_parse () |
2672 | { |
2674 | { |
2673 | bool flag = false; |
2675 | bool flag = false; |
2674 | unicode_t ch = NOCHAR; |
2676 | wchar_t ch = NOCHAR; |
2675 | unsigned char *seq_begin; // remember start of esc-sequence here |
2677 | char *seq_begin; // remember start of esc-sequence here |
2676 | |
2678 | |
2677 | for (;;) |
2679 | for (;;) |
2678 | { |
2680 | { |
2679 | if (ch == NOCHAR) |
2681 | if (ch == NOCHAR) |
2680 | { |
2682 | { |
2681 | seq_begin = cmdbuf_ptr; |
2683 | seq_begin = cmdbuf_ptr; |
2682 | ch = next_char (); |
2684 | ch = next_char (); |
2683 | } |
|
|
2684 | |
2685 | |
2685 | if (ch == NOCHAR) // TODO: improve |
2686 | if (ch == NOCHAR) |
2686 | break; |
2687 | break; |
|
|
2688 | } |
2687 | |
2689 | |
2688 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2690 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2689 | { |
2691 | { |
2690 | if (!seen_input) |
2692 | if (!seen_input) |
2691 | { |
2693 | { |
… | |
… | |
2700 | if (seen_resize && cmd_pid) |
2702 | if (seen_resize && cmd_pid) |
2701 | kill (-cmd_pid, SIGWINCH); |
2703 | kill (-cmd_pid, SIGWINCH); |
2702 | } |
2704 | } |
2703 | |
2705 | |
2704 | /* Read a text string from the input buffer */ |
2706 | /* Read a text string from the input buffer */ |
2705 | unicode_t buf[UBUFSIZ]; |
2707 | wchar_t buf[UBUFSIZ]; |
2706 | bool refreshnow = false; |
2708 | bool refreshnow = false; |
2707 | int nlines = 0; |
2709 | int nlines = 0; |
2708 | unicode_t *str = buf; |
2710 | wchar_t *str = buf; |
2709 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2711 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2710 | |
2712 | |
2711 | for (;;) |
2713 | for (;;) |
2712 | { |
2714 | { |
2713 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2715 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2714 | break; |
2716 | break; |
… | |
… | |
2732 | } |
2734 | } |
2733 | |
2735 | |
2734 | // scr_add_lines only works for nlines <= nrow - 1. |
2736 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | if (nlines >= nrow - 1) |
2737 | if (nlines >= nrow - 1) |
2736 | { |
2738 | { |
|
|
2739 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2740 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2737 | scr_add_lines (buf, nlines, str - buf); |
2741 | scr_add_lines (buf, str - buf, nlines); |
|
|
2742 | |
2738 | nlines = 0; |
2743 | nlines = 0; |
2739 | str = buf; |
2744 | str = buf; |
2740 | eol = str + min (ncol, UBUFSIZ); |
2745 | eol = str + min (ncol, UBUFSIZ); |
2741 | } |
2746 | } |
2742 | |
2747 | |
… | |
… | |
2755 | |
2760 | |
2756 | seq_begin = cmdbuf_ptr; |
2761 | seq_begin = cmdbuf_ptr; |
2757 | ch = next_char (); |
2762 | ch = next_char (); |
2758 | } |
2763 | } |
2759 | |
2764 | |
|
|
2765 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2766 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2760 | scr_add_lines (buf, nlines, str - buf); |
2767 | scr_add_lines (buf, str - buf, nlines); |
2761 | |
2768 | |
2762 | /* |
2769 | /* |
2763 | * If there have been a lot of new lines, then update the screen |
2770 | * If there have been a lot of new lines, then update the screen |
2764 | * What the heck I'll cheat and only refresh less than every page-full. |
2771 | * What the heck I'll cheat and only refresh less than every page-full. |
2765 | * the number of pages between refreshes is refresh_limit, which |
2772 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2770 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2777 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2771 | refresh_limit++; |
2778 | refresh_limit++; |
2772 | else |
2779 | else |
2773 | { |
2780 | { |
2774 | flag = true; |
2781 | flag = true; |
2775 | scr_refresh (refresh_type); |
2782 | scr_refresh (); |
2776 | flush_ev.stop (); |
2783 | want_refresh = 1; |
2777 | } |
2784 | } |
2778 | } |
2785 | } |
2779 | |
2786 | |
2780 | } |
2787 | } |
2781 | else |
2788 | else |
… | |
… | |
2796 | } |
2803 | } |
2797 | |
2804 | |
2798 | return flag; |
2805 | return flag; |
2799 | } |
2806 | } |
2800 | |
2807 | |
2801 | // read the next octet |
|
|
2802 | unicode_t |
|
|
2803 | rxvt_term::next_octet () |
|
|
2804 | { |
|
|
2805 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2806 | ? *cmdbuf_ptr++ |
|
|
2807 | : NOCHAR; |
|
|
2808 | } |
|
|
2809 | |
|
|
2810 | // read the next character |
2808 | // read the next character |
2811 | unicode_t |
2809 | wchar_t |
2812 | rxvt_term::next_char () |
2810 | rxvt_term::next_char () NOTHROW |
2813 | { |
2811 | { |
2814 | while (cmdbuf_ptr < cmdbuf_endp) |
2812 | while (cmdbuf_ptr < cmdbuf_endp) |
2815 | { |
2813 | { |
2816 | // assume 7-bit to be ascii ALWAYS |
2814 | // assume 7-bit to be ascii ALWAYS |
2817 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2815 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2818 | return *cmdbuf_ptr++; |
2816 | return *cmdbuf_ptr++; |
2819 | |
2817 | |
2820 | wchar_t wc; |
2818 | wchar_t wc; |
2821 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2819 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2822 | |
2820 | |
2823 | if (len == (size_t)-2) |
2821 | if (len == (size_t)-2) |
2824 | { |
2822 | { |
2825 | // the mbstate stores incomplete sequences. didn't know this :/ |
2823 | // the mbstate stores incomplete sequences. didn't know this :/ |
2826 | cmdbuf_ptr = cmdbuf_endp; |
2824 | cmdbuf_ptr = cmdbuf_endp; |
2827 | break; |
2825 | break; |
2828 | } |
2826 | } |
2829 | |
2827 | |
2830 | if (len == (size_t)-1) |
2828 | if (len == (size_t)-1) |
2831 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2829 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2832 | |
2830 | |
2833 | // assume wchar == unicode |
2831 | // assume wchar == unicode |
2834 | cmdbuf_ptr += len; |
2832 | cmdbuf_ptr += len; |
2835 | return wc & UNICODE_MASK; |
2833 | return wc & UNICODE_MASK; |
2836 | } |
2834 | } |
2837 | |
2835 | |
2838 | return NOCHAR; |
2836 | return NOCHAR; |
2839 | } |
2837 | } |
|
|
2838 | |
|
|
2839 | // read the next octet |
|
|
2840 | uint32_t |
|
|
2841 | rxvt_term::next_octet () NOTHROW |
|
|
2842 | { |
|
|
2843 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2844 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2845 | : NOCHAR; |
|
|
2846 | } |
|
|
2847 | |
|
|
2848 | static class out_of_input out_of_input; |
2840 | |
2849 | |
2841 | /* rxvt_cmd_getc () - Return next input character */ |
2850 | /* rxvt_cmd_getc () - Return next input character */ |
2842 | /* |
2851 | /* |
2843 | * Return the next input character after first passing any keyboard input |
2852 | * Return the next input character after first passing any keyboard input |
2844 | * to the command. |
2853 | * to the command. |
2845 | */ |
2854 | */ |
2846 | unicode_t |
2855 | wchar_t |
2847 | rxvt_term::cmd_getc () |
2856 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2848 | { |
2857 | { |
2849 | unicode_t c = next_char (); |
2858 | wchar_t c = next_char (); |
2850 | |
2859 | |
2851 | if (c == NOCHAR) |
2860 | if (c == NOCHAR) |
2852 | throw out_of_input; |
2861 | throw out_of_input; |
2853 | |
2862 | |
2854 | return c; |
2863 | return c; |
2855 | } |
2864 | } |
2856 | |
2865 | |
2857 | unicode_t |
2866 | uint32_t |
2858 | rxvt_term::cmd_get8 () |
2867 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2859 | { |
2868 | { |
2860 | unicode_t c = next_octet (); |
2869 | uint32_t c = next_octet (); |
2861 | |
2870 | |
2862 | if (c == NOCHAR) |
2871 | if (c == NOCHAR) |
2863 | throw out_of_input; |
2872 | throw out_of_input; |
2864 | |
2873 | |
2865 | return c; |
2874 | return c; |
… | |
… | |
2965 | case C0_ESC: |
2974 | case C0_ESC: |
2966 | process_escape_seq (); |
2975 | process_escape_seq (); |
2967 | break; |
2976 | break; |
2968 | case C0_ENQ: /* terminal Status */ |
2977 | case C0_ENQ: /* terminal Status */ |
2969 | if (rs[Rs_answerbackstring]) |
2978 | if (rs[Rs_answerbackstring]) |
2970 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2979 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2971 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2972 | else |
2980 | else |
2973 | tt_write ((unsigned char *)VT100_ANS, |
2981 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2974 | (unsigned int)strlen (VT100_ANS)); |
|
|
2975 | break; |
2982 | break; |
2976 | case C0_BEL: /* bell */ |
2983 | case C0_BEL: /* bell */ |
2977 | scr_bell (); |
2984 | scr_bell (); |
2978 | break; |
2985 | break; |
2979 | case C0_BS: /* backspace */ |
2986 | case C0_BS: /* backspace */ |
… | |
… | |
3134 | break; |
3141 | break; |
3135 | |
3142 | |
3136 | /* 8.3.87: NEXT LINE */ |
3143 | /* 8.3.87: NEXT LINE */ |
3137 | case C1_NEL: /* ESC E */ |
3144 | case C1_NEL: /* ESC E */ |
3138 | { |
3145 | { |
3139 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3146 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3140 | scr_add_lines (nlcr, 1, 2); |
3147 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3141 | } |
3148 | } |
3142 | break; |
3149 | break; |
3143 | |
3150 | |
3144 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3151 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3145 | case C1_ESA: /* ESC G */ |
3152 | case C1_ESA: /* ESC G */ |
… | |
… | |
3167 | process_dcs_seq (); |
3174 | process_dcs_seq (); |
3168 | break; |
3175 | break; |
3169 | |
3176 | |
3170 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3177 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3171 | case C1_SCI: /* ESC Z */ |
3178 | case C1_SCI: /* ESC Z */ |
3172 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3179 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3173 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3174 | break; /* steal obsolete ESC [ c */ |
3180 | break; /* steal obsolete ESC [ c */ |
3175 | |
3181 | |
3176 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3182 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3177 | case C1_CSI: /* ESC [ */ |
3183 | case C1_CSI: /* ESC [ */ |
3178 | process_csi_seq (); |
3184 | process_csi_seq (); |
… | |
… | |
3422 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3428 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3423 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3429 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3424 | break; |
3430 | break; |
3425 | |
3431 | |
3426 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3432 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3427 | tt_write ((const unsigned char *)VT100_ANS, |
3433 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3428 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3429 | break; |
3434 | break; |
3430 | |
3435 | |
3431 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3436 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3432 | process_sgr_mode (nargs, arg); |
3437 | process_sgr_mode (nargs, arg); |
3433 | break; |
3438 | break; |
… | |
… | |
3635 | /*----------------------------------------------------------------------*/ |
3640 | /*----------------------------------------------------------------------*/ |
3636 | /* |
3641 | /* |
3637 | * get input up until STRING TERMINATOR (or BEL) |
3642 | * get input up until STRING TERMINATOR (or BEL) |
3638 | * ends_how is terminator used. returned input must be free()'d |
3643 | * ends_how is terminator used. returned input must be free()'d |
3639 | */ |
3644 | */ |
3640 | unsigned char * |
3645 | char * |
3641 | rxvt_term::get_to_st (unicode_t &ends_how) |
3646 | rxvt_term::get_to_st (unicode_t &ends_how) |
3642 | { |
3647 | { |
3643 | unicode_t ch; |
3648 | unicode_t ch; |
3644 | bool seen_esc = false; |
3649 | bool seen_esc = false; |
3645 | unsigned int n = 0; |
3650 | unsigned int n = 0; |
… | |
… | |
3678 | |
3683 | |
3679 | string[n++] = '\0'; |
3684 | string[n++] = '\0'; |
3680 | |
3685 | |
3681 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3686 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3682 | |
3687 | |
3683 | return (unsigned char *)rxvt_wcstombs (string); |
3688 | return rxvt_wcstombs (string); |
3684 | } |
3689 | } |
3685 | |
3690 | |
3686 | /*----------------------------------------------------------------------*/ |
3691 | /*----------------------------------------------------------------------*/ |
3687 | /* |
3692 | /* |
3688 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3693 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3689 | */ |
3694 | */ |
3690 | void |
3695 | void |
3691 | rxvt_term::process_dcs_seq () |
3696 | rxvt_term::process_dcs_seq () |
3692 | { |
3697 | { |
3693 | unsigned char *s; |
3698 | char *s; |
3694 | unicode_t eh; |
3699 | unicode_t eh; |
3695 | |
3700 | |
3696 | /* |
3701 | /* |
3697 | * Not handled yet |
3702 | * Not handled yet |
3698 | */ |
3703 | */ |
… | |
… | |
3717 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3722 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3718 | arg = arg * 10 + (ch - '0'); |
3723 | arg = arg * 10 + (ch - '0'); |
3719 | |
3724 | |
3720 | if (ch == ';') |
3725 | if (ch == ';') |
3721 | { |
3726 | { |
3722 | unsigned char *s = get_to_st (eh); |
3727 | char *s = get_to_st (eh); |
3723 | |
3728 | |
3724 | if (s) |
3729 | if (s) |
3725 | { |
3730 | { |
3726 | process_xterm_seq (arg, (char *)s, eh); |
3731 | process_xterm_seq (arg, s, eh); |
3727 | free (s); |
3732 | free (s); |
3728 | } |
3733 | } |
3729 | } |
3734 | } |
3730 | } |
3735 | } |
3731 | |
3736 | |
3732 | void |
3737 | void |
3733 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3738 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3734 | { |
3739 | { |
3735 | if (str[0] == '?' && !str[1]) |
3740 | if (str[0] == '?' && !str[1]) |
3736 | { |
3741 | { |
3737 | unsigned short r, g, b; |
3742 | unsigned short r, g, b; |
3738 | pix_colors_focused[color].get (display, r, g, b); |
3743 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3744 | |
3749 | |
3745 | /* |
3750 | /* |
3746 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3751 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3747 | */ |
3752 | */ |
3748 | void |
3753 | void |
3749 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3754 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3750 | { |
3755 | { |
3751 | int changed = 0; |
|
|
3752 | int color; |
3756 | int color; |
3753 | char *buf, *name; |
3757 | char *buf, *name; |
3754 | bool query = str[0] == '?' && !str[1]; |
3758 | bool query = str[0] == '?' && !str[1]; |
3755 | int saveop = op; |
3759 | int saveop = op; |
3756 | dDisp; |
3760 | dDisp; |
… | |
… | |
3811 | { |
3815 | { |
3812 | if ((name = strchr (buf, ';')) == NULL) |
3816 | if ((name = strchr (buf, ';')) == NULL) |
3813 | break; |
3817 | break; |
3814 | |
3818 | |
3815 | *name++ = '\0'; |
3819 | *name++ = '\0'; |
3816 | color = atoi (buf); |
3820 | color = atoi (buf) + minCOLOR; |
3817 | |
3821 | |
3818 | if (color < 0 || color >= TOTAL_COLORS) |
3822 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3819 | break; |
3823 | break; |
3820 | |
3824 | |
3821 | if ((buf = strchr (name, ';')) != NULL) |
3825 | if ((buf = strchr (name, ';')) != NULL) |
3822 | *buf++ = '\0'; |
3826 | *buf++ = '\0'; |
3823 | |
3827 | |
3824 | if (name[0] == '?' && !name[1]) |
3828 | if (name[0] == '?' && !name[1]) |
3825 | { |
3829 | { |
3826 | unsigned short r, g, b; |
3830 | unsigned short r, g, b; |
3827 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3831 | pix_colors_focused[color].get (display, r, g, b); |
3828 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3832 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3829 | } |
3833 | } |
3830 | else |
3834 | else |
3831 | set_window_color (color + minCOLOR, name); |
3835 | set_window_color (color, name); |
3832 | } |
3836 | } |
3833 | break; |
3837 | break; |
3834 | case XTerm_Color00: |
3838 | case XTerm_Color00: |
3835 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3839 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3836 | break; |
3840 | break; |
3837 | case XTerm_Color01: |
3841 | case XTerm_Color01: |
3838 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3842 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3839 | break; |
3843 | break; |
3840 | #ifndef NO_CURSORCOLOR |
3844 | #ifndef NO_CURSORCOLOR |
3841 | case XTerm_Color_cursor: |
3845 | case XTerm_Color_cursor: |
3842 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3846 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3843 | break; |
3847 | break; |
… | |
… | |
3847 | break; |
3851 | break; |
3848 | case XTerm_Color_pointer_bg: |
3852 | case XTerm_Color_pointer_bg: |
3849 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3853 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3850 | break; |
3854 | break; |
3851 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3855 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3852 | case XTerm_Color_BD: |
|
|
3853 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3854 | break; |
|
|
3855 | case XTerm_Color_UL: |
|
|
3856 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3857 | break; |
|
|
3858 | case XTerm_Color_RV: |
3856 | case XTerm_Color_RV: |
3859 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3857 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3858 | break; |
|
|
3859 | case Rxvt_Color_BD: |
|
|
3860 | case URxvt_Color_BD: |
|
|
3861 | process_color_seq (op, Color_BD, str, resp); |
|
|
3862 | break; |
|
|
3863 | case Rxvt_Color_UL: |
|
|
3864 | case URxvt_Color_UL: |
|
|
3865 | process_color_seq (op, Color_UL, str, resp); |
3860 | break; |
3866 | break; |
3861 | case URxvt_Color_IT: |
3867 | case URxvt_Color_IT: |
3862 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3868 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3863 | break; |
3869 | break; |
3864 | #endif |
3870 | #endif |
… | |
… | |
3869 | if (am_transparent) |
3875 | if (am_transparent) |
3870 | want_full_refresh = want_refresh = 1; |
3876 | want_full_refresh = want_refresh = 1; |
3871 | break; |
3877 | break; |
3872 | #endif |
3878 | #endif |
3873 | |
3879 | |
3874 | case XTerm_Pixmap: |
3880 | case Rxvt_Pixmap: |
|
|
3881 | { |
3875 | if (*str != ';') |
3882 | if (*str != ';') |
3876 | { |
3883 | { |
3877 | #if XPM_BACKGROUND |
3884 | #if XPM_BACKGROUND |
3878 | scale_pixmap (""); /* reset to default scaling */ |
3885 | scale_pixmap (""); /* reset to default scaling */ |
3879 | set_bgPixmap (str); /* change pixmap */ |
3886 | set_bgPixmap (str); /* change pixmap */ |
3880 | #endif |
|
|
3881 | scr_touch (true); |
3887 | scr_touch (true); |
|
|
3888 | #endif |
3882 | } |
3889 | } |
|
|
3890 | |
|
|
3891 | int changed = 0; |
|
|
3892 | |
3883 | while ((str = strchr (str, ';')) != NULL) |
3893 | while ((str = strchr (str, ';')) != NULL) |
3884 | { |
3894 | { |
3885 | str++; |
3895 | str++; |
3886 | #if XPM_BACKGROUND |
3896 | #if XPM_BACKGROUND |
3887 | changed += scale_pixmap (str); |
3897 | changed += scale_pixmap (str); |
3888 | #endif |
3898 | #endif |
3889 | } |
3899 | } |
3890 | |
3900 | |
3891 | if (changed) |
3901 | if (changed) |
3892 | { |
3902 | { |
3893 | #ifdef XPM_BACKGROUND |
3903 | #ifdef XPM_BACKGROUND |
3894 | resize_pixmap (); |
3904 | resize_pixmap (); |
3895 | #endif |
|
|
3896 | scr_touch (true); |
3905 | scr_touch (true); |
|
|
3906 | #endif |
3897 | } |
3907 | } |
|
|
3908 | } |
3898 | break; |
3909 | break; |
3899 | |
3910 | |
3900 | case XTerm_restoreFG: |
3911 | case Rxvt_restoreFG: |
3901 | set_window_color (Color_fg, str); |
3912 | set_window_color (Color_fg, str); |
3902 | break; |
3913 | break; |
3903 | case XTerm_restoreBG: |
3914 | case Rxvt_restoreBG: |
3904 | set_window_color (Color_bg, str); |
3915 | set_window_color (Color_bg, str); |
3905 | break; |
3916 | break; |
3906 | |
3917 | |
3907 | case XTerm_logfile: |
3918 | case XTerm_logfile: |
3908 | // TODO, when secure mode? |
3919 | // TODO, when secure mode? |
3909 | break; |
3920 | break; |
3910 | |
3921 | |
3911 | #ifdef MENUBAR |
|
|
3912 | case URxvt_Menu: |
|
|
3913 | if (OPTION (Opt_insecure)) |
|
|
3914 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3915 | break; |
|
|
3916 | #endif |
|
|
3917 | #if 0 |
3922 | #if 0 |
3918 | case XTerm_dumpscreen: /* no error notices */ |
3923 | case Rxvt_dumpscreen: /* no error notices */ |
3919 | { |
3924 | { |
3920 | int fd; |
3925 | int fd; |
3921 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3926 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3922 | { |
3927 | { |
3923 | scr_dump (fd); |
3928 | scr_dump (fd); |
… | |
… | |
3954 | if (query) |
3959 | if (query) |
3955 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3960 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3956 | else |
3961 | else |
3957 | { |
3962 | { |
3958 | set_locale (str); |
3963 | set_locale (str); |
3959 | pty.set_utf8_mode (enc_utf8); |
3964 | pty->set_utf8_mode (enc_utf8); |
3960 | init_xlocale (); |
3965 | init_xlocale (); |
3961 | } |
3966 | } |
3962 | break; |
3967 | break; |
3963 | |
3968 | |
3964 | case URxvt_view_up: |
3969 | case URxvt_view_up: |
3965 | case URxvt_view_down: |
3970 | case URxvt_view_down: |
|
|
3971 | { |
3966 | int lines = atoi (str); |
3972 | int lines = atoi (str); |
3967 | |
3973 | |
3968 | if (lines) |
3974 | if (lines) |
3969 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3975 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3970 | else |
3976 | else |
3971 | { |
|
|
3972 | scr_erase_savelines (); |
3977 | scr_erase_savelines (); |
3973 | } |
3978 | } |
3974 | |
3979 | |
|
|
3980 | break; |
|
|
3981 | #endif |
|
|
3982 | |
|
|
3983 | #if ENABLE_PERL |
|
|
3984 | case URxvt_perl: |
|
|
3985 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
3986 | ; // no responses yet |
3975 | break; |
3987 | break; |
3976 | #endif |
3988 | #endif |
3977 | } |
3989 | } |
3978 | } |
3990 | } |
3979 | /*----------------------------------------------------------------------*/ |
3991 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4010 | return state; |
4022 | return state; |
4011 | } |
4023 | } |
4012 | |
4024 | |
4013 | /* we're not using priv _yet_ */ |
4025 | /* we're not using priv _yet_ */ |
4014 | void |
4026 | void |
4015 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4027 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4016 | { |
4028 | { |
4017 | unsigned int i, j; |
4029 | unsigned int i, j; |
4018 | int state; |
4030 | int state; |
4019 | |
4031 | |
4020 | static const struct |
4032 | static const struct |
… | |
… | |
4031 | { 5, PrivMode_rVideo }, |
4043 | { 5, PrivMode_rVideo }, |
4032 | { 6, PrivMode_relOrigin }, |
4044 | { 6, PrivMode_relOrigin }, |
4033 | { 7, PrivMode_Autowrap }, |
4045 | { 7, PrivMode_Autowrap }, |
4034 | // 8, bi-directional support mode |
4046 | // 8, bi-directional support mode |
4035 | { 9, PrivMode_MouseX10 }, |
4047 | { 9, PrivMode_MouseX10 }, |
4036 | #ifdef menuBar_esc |
|
|
4037 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4038 | #endif |
|
|
4039 | // 18, 19 printing-related |
4048 | // 18, 19 printing-related |
4040 | { 25, PrivMode_VisibleCursor }, |
4049 | { 25, PrivMode_VisibleCursor }, |
4041 | #ifdef scrollBar_esc |
4050 | #ifdef scrollBar_esc |
4042 | { scrollBar_esc, PrivMode_scrollBar }, |
4051 | { scrollBar_esc, PrivMode_scrollBar }, |
4043 | #endif |
4052 | #endif |
… | |
… | |
4090 | /* extra handling for values with state unkept */ |
4099 | /* extra handling for values with state unkept */ |
4091 | switch (arg[i]) |
4100 | switch (arg[i]) |
4092 | { |
4101 | { |
4093 | #if ENABLE_STYLES |
4102 | #if ENABLE_STYLES |
4094 | case 1021: |
4103 | case 1021: |
4095 | if (mode) |
4104 | set_option (Opt_intensityStyles, mode); |
4096 | SET_OPTION (Opt_intensityStyles); |
|
|
4097 | else |
|
|
4098 | CLR_OPTION (Opt_intensityStyles); |
|
|
4099 | |
4105 | |
4100 | scr_touch (true); |
4106 | scr_touch (true); |
4101 | break; |
4107 | break; |
4102 | #endif |
4108 | #endif |
4103 | case 1048: /* alternative cursor save */ |
4109 | case 1048: /* alternative cursor save */ |
… | |
… | |
4125 | case 3: /* 80/132 */ |
4131 | case 3: /* 80/132 */ |
4126 | if (priv_modes & PrivMode_132OK) |
4132 | if (priv_modes & PrivMode_132OK) |
4127 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4133 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4128 | break; |
4134 | break; |
4129 | case 4: /* smooth scrolling */ |
4135 | case 4: /* smooth scrolling */ |
4130 | if (!state) |
4136 | set_option (Opt_jumpScroll, !state); |
4131 | SET_OPTION (Opt_jumpScroll); |
|
|
4132 | else |
|
|
4133 | CLR_OPTION (Opt_jumpScroll); |
|
|
4134 | break; |
4137 | break; |
4135 | case 5: /* reverse video */ |
4138 | case 5: /* reverse video */ |
4136 | scr_rvideo_mode (state); |
4139 | scr_rvideo_mode (state); |
4137 | break; |
4140 | break; |
4138 | case 6: /* relative/absolute origins */ |
4141 | case 6: /* relative/absolute origins */ |
… | |
… | |
4144 | /* case 8: - auto repeat, can't do on a per window basis */ |
4147 | /* case 8: - auto repeat, can't do on a per window basis */ |
4145 | case 9: /* X10 mouse reporting */ |
4148 | case 9: /* X10 mouse reporting */ |
4146 | if (state) /* orthogonal */ |
4149 | if (state) /* orthogonal */ |
4147 | priv_modes &= ~PrivMode_MouseX11; |
4150 | priv_modes &= ~PrivMode_MouseX11; |
4148 | break; |
4151 | break; |
4149 | #ifdef menuBar_esc |
|
|
4150 | case menuBar_esc: |
|
|
4151 | #ifdef MENUBAR |
|
|
4152 | map_menuBar (state); |
|
|
4153 | #endif |
|
|
4154 | break; |
|
|
4155 | #endif |
|
|
4156 | #ifdef scrollBar_esc |
4152 | #ifdef scrollBar_esc |
4157 | case scrollBar_esc: |
4153 | case scrollBar_esc: |
4158 | if (scrollbar_mapping (state)) |
4154 | if (scrollbar_mapping (state)) |
4159 | { |
4155 | { |
4160 | resize_all_windows (0, 0, 0); |
4156 | resize_all_windows (0, 0, 0); |
… | |
… | |
4179 | #if 0 |
4175 | #if 0 |
4180 | case 1001: |
4176 | case 1001: |
4181 | break; /* X11 mouse highlighting */ |
4177 | break; /* X11 mouse highlighting */ |
4182 | #endif |
4178 | #endif |
4183 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4179 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4184 | if (!state) |
4180 | set_option (Opt_scrollTtyOutput, !state); |
4185 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4186 | else |
|
|
4187 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4188 | break; |
4181 | break; |
4189 | case 1011: /* scroll to bottom on key press */ |
4182 | case 1011: /* scroll to bottom on key press */ |
4190 | if (state) |
4183 | set_option (Opt_scrollTtyKeypress, state); |
4191 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4192 | else |
|
|
4193 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4194 | break; |
4184 | break; |
4195 | case 1047: /* secondary screen w/ clearing last */ |
4185 | case 1047: /* secondary screen w/ clearing last */ |
4196 | if (OPTION (Opt_secondaryScreen)) |
4186 | if (OPTION (Opt_secondaryScreen)) |
4197 | if (current_screen != PRIMARY) |
4187 | if (current_screen != PRIMARY) |
4198 | scr_erase_screen (2); |
4188 | scr_erase_screen (2); |
… | |
… | |
4336 | scr_color (Color_bg, Color_bg); |
4326 | scr_color (Color_bg, Color_bg); |
4337 | break; |
4327 | break; |
4338 | |
4328 | |
4339 | //case 50: // not variable spacing |
4329 | //case 50: // not variable spacing |
4340 | |
4330 | |
4341 | #ifndef NO_BRIGHTCOLOR |
4331 | #if ENABLE_FRILLS |
4342 | case 90: |
4332 | case 90: |
4343 | case 91: /* set bright fg color */ |
4333 | case 91: /* set bright fg color */ |
4344 | case 92: |
4334 | case 92: |
4345 | case 93: |
4335 | case 93: |
4346 | case 94: |
4336 | case 94: |
… | |
… | |
4391 | */ |
4381 | */ |
4392 | void |
4382 | void |
4393 | rxvt_term::tt_printf (const char *fmt,...) |
4383 | rxvt_term::tt_printf (const char *fmt,...) |
4394 | { |
4384 | { |
4395 | va_list arg_ptr; |
4385 | va_list arg_ptr; |
4396 | unsigned char buf[256]; |
4386 | char buf[256]; |
4397 | |
4387 | |
4398 | va_start (arg_ptr, fmt); |
4388 | va_start (arg_ptr, fmt); |
4399 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4389 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4400 | va_end (arg_ptr); |
4390 | va_end (arg_ptr); |
4401 | tt_write (buf, strlen (buf)); |
4391 | tt_write (buf, strlen (buf)); |
… | |
… | |
4406 | * or generated by us in response to a query ESC sequence. |
4396 | * or generated by us in response to a query ESC sequence. |
4407 | */ |
4397 | */ |
4408 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4398 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4409 | |
4399 | |
4410 | void |
4400 | void |
4411 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4401 | rxvt_term::tt_write (const char *data, unsigned int len) |
4412 | { |
4402 | { |
|
|
4403 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4404 | return; |
|
|
4405 | |
|
|
4406 | if (pty->pty < 0) |
|
|
4407 | return; |
|
|
4408 | |
4413 | if (v_buflen == 0) |
4409 | if (v_buflen == 0) |
4414 | { |
4410 | { |
4415 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4411 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4416 | |
4412 | |
4417 | if ((unsigned int)written == len) |
4413 | if ((unsigned int)written == len) |
4418 | return; |
4414 | return; |
4419 | |
4415 | |
4420 | data += written; |
4416 | data += written; |
4421 | len -= written; |
4417 | len -= written; |
4422 | } |
4418 | } |
4423 | |
4419 | |
4424 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4420 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4425 | |
4421 | |
4426 | memcpy (v_buffer + v_buflen, data, len); |
4422 | memcpy (v_buffer + v_buflen, data, len); |
4427 | v_buflen += len; |
4423 | v_buflen += len; |
4428 | |
4424 | |
4429 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4425 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4430 | } |
4426 | } |
4431 | |
4427 | |
4432 | void rxvt_term::pty_write () |
4428 | void rxvt_term::pty_write () |
4433 | { |
4429 | { |
4434 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4430 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4435 | |
4431 | |
4436 | if (written > 0) |
4432 | if (written > 0) |
4437 | { |
4433 | { |
4438 | v_buflen -= written; |
4434 | v_buflen -= written; |
4439 | |
4435 | |