… | |
… | |
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. |
… | |
… | |
64 | |
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
68 | |
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
|
|
72 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
70 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
76 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
73 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
144 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
145 | return; |
149 | |
146 | |
150 | for (;;) |
147 | for (;;) |
151 | { |
148 | { |
152 | const line_t &l = ROW(y - view_start); |
149 | const line_t &l = ROW(y + view_start); |
153 | |
150 | |
154 | text_t t = l.t[x]; |
151 | text_t t = l.t[x]; |
155 | |
152 | |
156 | if (t != NOCHAR || !x) |
153 | if (t != NOCHAR || !x) |
157 | { |
154 | { |
… | |
… | |
268 | mb[0] = ch[0]; |
265 | mb[0] = ch[0]; |
269 | len = 1; |
266 | len = 1; |
270 | } |
267 | } |
271 | |
268 | |
272 | if (len > 0) |
269 | if (len > 0) |
273 | tt_write ((unsigned char *)mb, len); |
270 | tt_write (mb, len); |
274 | else |
271 | else |
275 | scr_bell (); |
272 | scr_bell (); |
276 | } |
273 | } |
277 | |
274 | |
278 | iso14755buf = 0; |
275 | iso14755buf = 0; |
… | |
… | |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
299 | rxvt_term::lookup_key (XKeyEvent &ev) |
303 | { |
300 | { |
304 | int ctrl, meta, shft, len; |
301 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
302 | unsigned int newlen; |
306 | KeySym keysym; |
303 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
304 | int valid_keysym; |
311 | unsigned char kbuf[KBUFSZ]; |
305 | char kbuf[KBUFSZ]; |
312 | |
306 | |
313 | /* |
307 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
308 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
315 | * escape sequence to toggle the Keypad. |
309 | * escape sequence to toggle the Keypad. |
316 | * |
310 | * |
… | |
… | |
334 | Status status_return; |
328 | Status status_return; |
335 | |
329 | |
336 | #if 0 |
330 | #if 0 |
337 | #ifdef X_HAVE_UTF8_STRING |
331 | #ifdef X_HAVE_UTF8_STRING |
338 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
332 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
339 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
333 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
340 | KBUFSZ, &keysym, &status_return); |
334 | KBUFSZ, &keysym, &status_return); |
341 | else |
335 | else |
342 | #endif |
336 | #endif |
343 | #endif |
337 | #endif |
344 | { |
338 | { |
… | |
… | |
381 | || status_return == XLookupBoth; |
375 | || status_return == XLookupBoth; |
382 | } |
376 | } |
383 | else |
377 | else |
384 | #endif |
378 | #endif |
385 | { |
379 | { |
386 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
380 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
387 | valid_keysym = keysym != NoSymbol; |
381 | valid_keysym = keysym != NoSymbol; |
388 | } |
382 | } |
389 | |
383 | |
390 | if (valid_keysym) |
384 | if (valid_keysym) |
391 | { |
385 | { |
… | |
… | |
443 | scr_move_to (0, 1); |
437 | scr_move_to (0, 1); |
444 | return; |
438 | return; |
445 | } |
439 | } |
446 | else if (keysym == XK_End) |
440 | else if (keysym == XK_End) |
447 | { |
441 | { |
448 | scr_move_to (1, 0); |
442 | scr_move_to (1, 1); |
449 | return; |
443 | return; |
450 | } |
444 | } |
451 | } |
445 | } |
452 | #endif |
446 | #endif |
453 | } |
447 | } |
… | |
… | |
464 | { |
458 | { |
465 | switch (keysym) |
459 | switch (keysym) |
466 | { |
460 | { |
467 | /* normal XTerm key bindings */ |
461 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
463 | selection_request (ev.time); |
470 | return; |
464 | return; |
471 | #if TODO |
465 | #if TODO |
472 | /* rxvt extras */ |
466 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
468 | change_font (FONT_UP); |
… | |
… | |
855 | { |
849 | { |
856 | #ifdef META8_OPTION |
850 | #ifdef META8_OPTION |
857 | /* set 8-bit on */ |
851 | /* set 8-bit on */ |
858 | if (meta && (meta_char == 0x80)) |
852 | if (meta && (meta_char == 0x80)) |
859 | { |
853 | { |
860 | unsigned char *ch; |
854 | char *ch; |
861 | |
855 | |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
856 | for (ch = kbuf; ch < kbuf + len; ch++) |
863 | *ch |= 0x80; |
857 | *ch |= 0x80; |
864 | |
858 | |
865 | meta = 0; |
859 | meta = 0; |
866 | } |
860 | } |
867 | #endif |
861 | #endif |
868 | /* nil */ ; |
862 | /* nil */ ; |
869 | } |
863 | } |
870 | } |
864 | } |
|
|
865 | |
|
|
866 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
867 | return; |
871 | |
868 | |
872 | if (len <= 0) |
869 | if (len <= 0) |
873 | return; /* not mapped */ |
870 | return; /* not mapped */ |
874 | |
871 | |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
872 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
898 | #ifdef META8_OPTION |
895 | #ifdef META8_OPTION |
899 | && meta_char == C0_ESC |
896 | && meta_char == C0_ESC |
900 | #endif |
897 | #endif |
901 | ) |
898 | ) |
902 | { |
899 | { |
903 | const unsigned char ch = C0_ESC; |
900 | const char ch = C0_ESC; |
904 | tt_write (&ch, 1); |
901 | tt_write (&ch, 1); |
905 | } |
902 | } |
906 | |
903 | |
907 | #if defined(DEBUG_CMD) |
|
|
908 | /* Display keyboard buffer contents */ |
|
|
909 | unsigned char *p; |
|
|
910 | int i; |
|
|
911 | |
|
|
912 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
913 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
914 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
915 | fprintf (stderr, "'\n"); |
|
|
916 | #endif /* DEBUG_CMD */ |
|
|
917 | tt_write (kbuf, (unsigned int)len); |
904 | tt_write (kbuf, (unsigned int)len); |
918 | } |
905 | } |
919 | /*}}} */ |
906 | /*}}} */ |
920 | |
907 | |
921 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
908 | #if defined (KEYSYM_RESOURCE) |
922 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
923 | /* attempt to `write' count to the input buffer */ |
|
|
924 | unsigned int |
909 | unsigned int |
925 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
910 | rxvt_term::cmd_write (const char *str, unsigned int count) |
926 | { |
911 | { |
927 | unsigned int n, s; |
912 | unsigned int n, s; |
928 | |
913 | |
929 | n = cmdbuf_ptr - cmdbuf_base; |
914 | n = cmdbuf_ptr - cmdbuf_base; |
930 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
915 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
967 | } |
952 | } |
968 | #endif |
953 | #endif |
969 | |
954 | |
970 | if (want_refresh) |
955 | if (want_refresh) |
971 | { |
956 | { |
|
|
957 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
958 | { |
|
|
959 | int row = view_start; |
|
|
960 | int end_row = row + nrow; |
|
|
961 | |
|
|
962 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
963 | --row; |
|
|
964 | |
|
|
965 | do |
|
|
966 | { |
|
|
967 | int start_row = row; |
|
|
968 | line_t *l; |
|
|
969 | |
|
|
970 | do |
|
|
971 | { |
|
|
972 | l = &ROW (row++); |
|
|
973 | |
|
|
974 | if (!(l->f & LINE_FILTERED)) |
|
|
975 | { |
|
|
976 | // line not filtered, mark it as filtered |
|
|
977 | l->f |= LINE_FILTERED; |
|
|
978 | while (l->is_longer ()) |
|
|
979 | { |
|
|
980 | l = &ROW (row++); |
|
|
981 | l->f |= LINE_FILTERED; |
|
|
982 | } |
|
|
983 | |
|
|
984 | // and filter it |
|
|
985 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
986 | |
|
|
987 | break; |
|
|
988 | } |
|
|
989 | } |
|
|
990 | while (l->is_longer () && row < end_row); |
|
|
991 | } |
|
|
992 | while (row < end_row); |
|
|
993 | } |
|
|
994 | |
972 | scr_refresh (refresh_type); |
995 | scr_refresh (); |
973 | scrollbar_show (1); |
996 | scrollbar_show (1); |
974 | #ifdef USE_XIM |
997 | #ifdef USE_XIM |
975 | IMSendSpot (); |
998 | IMSendSpot (); |
976 | #endif |
999 | #endif |
977 | } |
1000 | } |
… | |
… | |
980 | } |
1003 | } |
981 | |
1004 | |
982 | void |
1005 | void |
983 | rxvt_term::check_cb (check_watcher &w) |
1006 | rxvt_term::check_cb (check_watcher &w) |
984 | { |
1007 | { |
985 | SET_R (this); |
1008 | make_current (); |
986 | SET_LOCALE (locale); |
|
|
987 | |
1009 | |
988 | display->flush (); |
1010 | display->flush (); |
989 | |
1011 | |
990 | if (want_refresh && !flush_ev.active) |
1012 | if (want_refresh && !flush_ev.active) |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1013 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
992 | } |
1014 | } |
993 | |
1015 | |
994 | void |
1016 | void |
995 | rxvt_term::flush_cb (time_watcher &w) |
1017 | rxvt_term::flush_cb (time_watcher &w) |
996 | { |
1018 | { |
997 | SET_R (this); |
1019 | make_current (); |
998 | SET_LOCALE (locale); |
|
|
999 | |
1020 | |
1000 | refresh_limit = 1; |
1021 | refresh_limit = 1; |
1001 | refresh_count = 0; |
1022 | refresh_count = 0; |
1002 | flush (); |
1023 | flush (); |
1003 | } |
1024 | } |
… | |
… | |
1007 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1028 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1008 | { |
1029 | { |
1009 | hidden_cursor = !hidden_cursor; |
1030 | hidden_cursor = !hidden_cursor; |
1010 | want_refresh = 1; |
1031 | want_refresh = 1; |
1011 | |
1032 | |
1012 | w.start (w.at + BLINK_INTERVAL); |
1033 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1013 | } |
1034 | } |
1014 | #endif |
1035 | #endif |
1015 | |
1036 | |
1016 | #ifdef TEXT_BLINK |
1037 | #ifdef TEXT_BLINK |
1017 | void |
1038 | void |
… | |
… | |
1031 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1052 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1032 | { |
1053 | { |
1033 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1054 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1034 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1055 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1035 | { |
1056 | { |
1036 | refresh_type |= SMOOTH_REFRESH; |
|
|
1037 | want_refresh = 1; |
1057 | want_refresh = 1; |
1038 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1058 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1039 | } |
1059 | } |
1040 | } |
1060 | } |
1041 | #endif |
1061 | #endif |
… | |
… | |
1045 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1065 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1046 | { |
1066 | { |
1047 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1067 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1048 | { |
1068 | { |
1049 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1069 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1050 | refresh_type |= SMOOTH_REFRESH; |
|
|
1051 | want_refresh = 1; |
1070 | want_refresh = 1; |
1052 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1053 | } |
1072 | } |
1054 | } |
1073 | } |
1055 | #endif |
1074 | #endif |
… | |
… | |
1060 | { |
1079 | { |
1061 | if (mouse_slip_wheel_speed == 0 |
1080 | if (mouse_slip_wheel_speed == 0 |
1062 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1081 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1063 | : scr_page (UP, mouse_slip_wheel_speed)) |
1082 | : scr_page (UP, mouse_slip_wheel_speed)) |
1064 | { |
1083 | { |
1065 | if (view_start == nsaved || |
1084 | if (view_start == top_row || view_start == 0) |
1066 | view_start == 0) |
|
|
1067 | mouse_slip_wheel_speed = 0; |
1085 | mouse_slip_wheel_speed = 0; |
1068 | |
1086 | |
1069 | refresh_type |= SMOOTH_REFRESH; |
|
|
1070 | want_refresh = 1; |
1087 | want_refresh = 1; |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1088 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1072 | } |
1089 | } |
1073 | } |
1090 | } |
1074 | #endif |
1091 | #endif |
… | |
… | |
1104 | |
1121 | |
1105 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1122 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1106 | cmdbuf_ptr = cmdbuf_base; |
1123 | cmdbuf_ptr = cmdbuf_base; |
1107 | cmdbuf_endp = cmdbuf_ptr + n; |
1124 | cmdbuf_endp = cmdbuf_ptr + n; |
1108 | |
1125 | |
1109 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1126 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1110 | |
1127 | |
1111 | if (r > 0) |
1128 | if (r > 0) |
1112 | { |
1129 | { |
1113 | cmdbuf_endp += r; |
1130 | cmdbuf_endp += r; |
1114 | return true; |
1131 | return true; |
… | |
… | |
1132 | } |
1149 | } |
1133 | |
1150 | |
1134 | void |
1151 | void |
1135 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1152 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1136 | { |
1153 | { |
1137 | SET_R (this); |
1154 | make_current (); |
1138 | SET_LOCALE (locale); |
|
|
1139 | |
1155 | |
1140 | if (revents & EVENT_READ) |
1156 | if (revents & EVENT_READ) |
1141 | // loop, but don't allow a single term to monopolize us |
1157 | // loop, but don't allow a single term to monopolize us |
1142 | while (pty_fill ()) |
1158 | while (pty_fill ()) |
1143 | if (cmd_parse ()) |
1159 | if (cmd_parse ()) |
… | |
… | |
1163 | |
1179 | |
1164 | #ifdef POINTER_BLANK |
1180 | #ifdef POINTER_BLANK |
1165 | void |
1181 | void |
1166 | rxvt_term::pointer_blank () |
1182 | rxvt_term::pointer_blank () |
1167 | { |
1183 | { |
1168 | if (! OPTION (Opt_pointerBlank)) |
1184 | if (!OPTION (Opt_pointerBlank)) |
1169 | return; |
1185 | return; |
1170 | |
1186 | |
1171 | XDefineCursor (display->display, vt, display->blank_cursor); |
1187 | XDefineCursor (display->display, vt, display->blank_cursor); |
1172 | XFlush (display->display); |
1188 | XFlush (display->display); |
1173 | |
1189 | |
… | |
… | |
1175 | } |
1191 | } |
1176 | |
1192 | |
1177 | void |
1193 | void |
1178 | rxvt_term::pointer_cb (time_watcher &w) |
1194 | rxvt_term::pointer_cb (time_watcher &w) |
1179 | { |
1195 | { |
1180 | SET_R (this); |
1196 | make_current (); |
1181 | SET_LOCALE (locale); |
|
|
1182 | |
1197 | |
1183 | pointer_blank (); |
1198 | pointer_blank (); |
1184 | } |
1199 | } |
1185 | #endif |
1200 | #endif |
1186 | |
1201 | |
… | |
… | |
1265 | |
1280 | |
1266 | /*{{{ process an X event */ |
1281 | /*{{{ process an X event */ |
1267 | void |
1282 | void |
1268 | rxvt_term::x_cb (XEvent &ev) |
1283 | rxvt_term::x_cb (XEvent &ev) |
1269 | { |
1284 | { |
|
|
1285 | make_current (); |
|
|
1286 | |
1270 | dDisp; |
1287 | dDisp; |
1271 | |
1288 | |
1272 | SET_R (this); |
1289 | if (ev.xany.window == vt |
1273 | SET_LOCALE (locale); |
1290 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1291 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1292 | return; |
1274 | |
1293 | |
1275 | #if defined(CURSOR_BLINK) |
1294 | // for XQueryPointer |
1276 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1277 | { |
|
|
1278 | if (hidden_cursor) |
|
|
1279 | { |
|
|
1280 | hidden_cursor = 0; |
|
|
1281 | want_refresh = 1; |
|
|
1282 | } |
|
|
1283 | |
|
|
1284 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1285 | } |
|
|
1286 | #endif |
|
|
1287 | |
|
|
1288 | #if defined(POINTER_BLANK) |
|
|
1289 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1290 | { |
|
|
1291 | if (ev.type == MotionNotify |
|
|
1292 | || ev.type == ButtonPress |
|
|
1293 | || ev.type == ButtonRelease) |
|
|
1294 | if (hidden_pointer) |
|
|
1295 | pointer_unblank (); |
|
|
1296 | |
|
|
1297 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1298 | pointer_blank (); |
|
|
1299 | } |
|
|
1300 | #endif |
|
|
1301 | |
|
|
1302 | Window unused_root, unused_child; |
1295 | Window unused_root, unused_child; |
1303 | int unused_root_x, unused_root_y; |
1296 | int unused_root_x, unused_root_y; |
1304 | unsigned int unused_mask; |
1297 | unsigned int unused_mask; |
1305 | |
1298 | |
1306 | switch (ev.type) |
1299 | switch (ev.type) |
… | |
… | |
1313 | |
1306 | |
1314 | break; |
1307 | break; |
1315 | |
1308 | |
1316 | case KeyRelease: |
1309 | case KeyRelease: |
1317 | { |
1310 | { |
1318 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1311 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1319 | KeySym ks; |
1312 | KeySym keysym; |
1320 | |
1313 | |
1321 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1314 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1322 | #endif |
1315 | #endif |
1323 | |
1316 | |
1324 | #if ENABLE_FRILLS || ISO_14755 |
1317 | #if ENABLE_FRILLS || ISO_14755 |
1325 | // ISO 14755 support |
1318 | // ISO 14755 support |
1326 | if (iso14755buf) |
1319 | if (iso14755buf) |
… | |
… | |
1331 | # endif |
1324 | # endif |
1332 | # if ISO_14755 |
1325 | # if ISO_14755 |
1333 | // iso14755 part 5.2 handling: release time |
1326 | // iso14755 part 5.2 handling: release time |
1334 | // first: controls |
1327 | // first: controls |
1335 | if ((ev.xkey.state & ControlMask) |
1328 | if ((ev.xkey.state & ControlMask) |
1336 | && ((ks >= 0x40 && ks <= 0x5f) |
1329 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1337 | || (ks >= 0x61 && ks <= 0x7f))) |
1330 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1338 | { |
1331 | { |
1339 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1332 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1340 | commit_iso14755 (); |
1333 | commit_iso14755 (); |
1341 | return; // case-break; |
1334 | goto skip_switch; |
1342 | } |
1335 | } |
1343 | |
1336 | |
1344 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1337 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1345 | if (i[0] == ks) |
1338 | if (i[0] == keysym) |
1346 | { |
1339 | { |
1347 | iso14755buf = ISO_14755_51 | i[1]; |
1340 | iso14755buf = ISO_14755_51 | i[1]; |
1348 | commit_iso14755 (); |
1341 | commit_iso14755 (); |
1349 | return; // case-break; |
1342 | goto skip_switch; |
1350 | } |
1343 | } |
1351 | |
1344 | |
1352 | scr_bell (); |
1345 | scr_bell (); |
1353 | # endif |
1346 | # endif |
1354 | iso14755buf = 0; |
1347 | iso14755buf = 0; |
… | |
… | |
1373 | else |
1366 | else |
1374 | iso14755buf = 0; |
1367 | iso14755buf = 0; |
1375 | } |
1368 | } |
1376 | #endif |
1369 | #endif |
1377 | |
1370 | |
|
|
1371 | if (ev.xany.window == vt |
|
|
1372 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1373 | break; |
|
|
1374 | |
1378 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1375 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1379 | if (!(ev.xkey.state & ControlMask)) |
1376 | if (!(ev.xkey.state & ControlMask)) |
1380 | slip_wheel_ev.stop (); |
1377 | slip_wheel_ev.stop (); |
1381 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1378 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1382 | mouse_slip_wheel_speed = 0; |
1379 | mouse_slip_wheel_speed = 0; |
1383 | #endif |
1380 | #endif |
1384 | break; |
1381 | break; |
1385 | } |
1382 | } |
1386 | |
1383 | |
… | |
… | |
1392 | button_release (ev.xbutton); |
1389 | button_release (ev.xbutton); |
1393 | break; |
1390 | break; |
1394 | |
1391 | |
1395 | case ClientMessage: |
1392 | case ClientMessage: |
1396 | if (ev.xclient.format == 32 |
1393 | if (ev.xclient.format == 32 |
1397 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1394 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1398 | { |
1395 | { |
|
|
1396 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1397 | { |
|
|
1398 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1399 | { |
1399 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1400 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1401 | { |
|
|
1402 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1400 | destroy (); |
1403 | destroy (); |
|
|
1404 | } |
1401 | #if ENABLE_EWMH |
1405 | #if ENABLE_EWMH |
1402 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1406 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1403 | XSendEvent (disp, ev.xclient.window = display->root, |
1407 | XSendEvent (disp, ev.xclient.window = display->root, |
1404 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1408 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1405 | &ev); |
1409 | &ev); |
|
|
1410 | #endif |
|
|
1411 | } |
|
|
1412 | } |
|
|
1413 | #if ENABLE_XEMBED |
|
|
1414 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1415 | { |
|
|
1416 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1417 | focus_in (); |
|
|
1418 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1419 | focus_out (); |
|
|
1420 | } |
1406 | #endif |
1421 | #endif |
1407 | } |
1422 | } |
1408 | #if ENABLE_XEMBED |
|
|
1409 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1410 | { |
|
|
1411 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1412 | focus_in (); |
|
|
1413 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1414 | focus_out (); |
|
|
1415 | } |
|
|
1416 | #endif |
|
|
1417 | #ifdef OFFIX_DND |
|
|
1418 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1419 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1420 | && (ev.xclient.data.l[0] == DndFile |
|
|
1421 | || ev.xclient.data.l[0] == DndDir |
|
|
1422 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1423 | { |
|
|
1424 | /* Get Dnd data */ |
|
|
1425 | Atom ActualType; |
|
|
1426 | int ActualFormat; |
|
|
1427 | unsigned char *data; |
|
|
1428 | unsigned long Size, RemainingBytes; |
|
|
1429 | |
|
|
1430 | XGetWindowProperty (disp, display->root, |
|
|
1431 | xa[XA_DNDSELECTION], |
|
|
1432 | 0L, 1000000L, |
|
|
1433 | False, AnyPropertyType, |
|
|
1434 | &ActualType, &ActualFormat, |
|
|
1435 | &Size, &RemainingBytes, |
|
|
1436 | &data); |
|
|
1437 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1438 | XFree (data); |
|
|
1439 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1440 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1441 | } |
|
|
1442 | #endif /* OFFIX_DND */ |
|
|
1443 | break; |
1423 | break; |
1444 | |
1424 | |
1445 | case MappingNotify: |
1425 | case MappingNotify: |
1446 | XRefreshKeyboardMapping (&ev.xmapping); |
1426 | XRefreshKeyboardMapping (&ev.xmapping); |
1447 | break; |
1427 | break; |
… | |
… | |
1489 | { |
1469 | { |
1490 | seen_resize = 1; |
1470 | seen_resize = 1; |
1491 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1471 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1492 | } |
1472 | } |
1493 | |
1473 | |
|
|
1474 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1475 | |
1494 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1476 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1495 | if (OPTION (Opt_transparent)) |
1477 | if (OPTION (Opt_transparent)) |
1496 | check_our_parents (); |
1478 | check_our_parents (); |
1497 | #endif |
1479 | #endif |
1498 | } |
1480 | } |
1499 | break; |
1481 | break; |
1500 | |
1482 | |
1501 | case PropertyNotify: |
1483 | case PropertyNotify: |
|
|
1484 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1502 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1485 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1503 | && ev.xproperty.state == PropertyNewValue) |
1486 | && ev.xproperty.state == PropertyNewValue) |
1504 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1487 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1505 | |
1488 | |
1506 | break; |
1489 | break; |
1507 | |
1490 | |
1508 | case SelectionClear: |
1491 | case SelectionClear: |
1509 | selection_clear (); |
1492 | selection_clear (); |
… | |
… | |
1514 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1497 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1515 | break; |
1498 | break; |
1516 | |
1499 | |
1517 | case SelectionRequest: |
1500 | case SelectionRequest: |
1518 | selection_send (ev.xselectionrequest); |
1501 | selection_send (ev.xselectionrequest); |
|
|
1502 | break; |
|
|
1503 | |
|
|
1504 | case MapNotify: |
|
|
1505 | mapped = 1; |
|
|
1506 | #ifdef TEXT_BLINK |
|
|
1507 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1508 | #endif |
|
|
1509 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1519 | break; |
1510 | break; |
1520 | |
1511 | |
1521 | case UnmapNotify: |
1512 | case UnmapNotify: |
1522 | mapped = 0; |
1513 | mapped = 0; |
1523 | #ifdef TEXT_BLINK |
1514 | #ifdef TEXT_BLINK |
1524 | text_blink_ev.stop (); |
1515 | text_blink_ev.stop (); |
1525 | #endif |
1516 | #endif |
1526 | break; |
1517 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1527 | |
|
|
1528 | case MapNotify: |
|
|
1529 | mapped = 1; |
|
|
1530 | #ifdef TEXT_BLINK |
|
|
1531 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1532 | #endif |
|
|
1533 | break; |
1518 | break; |
1534 | |
1519 | |
1535 | #ifdef TRANSPARENT |
1520 | #ifdef TRANSPARENT |
1536 | case ReparentNotify: |
1521 | case ReparentNotify: |
1537 | rootwin_cb (ev); |
1522 | rootwin_cb (ev); |
… | |
… | |
1551 | |
1536 | |
1552 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1537 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1553 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1538 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1554 | ev.xexpose.width, ev.xexpose.height, False); |
1539 | ev.xexpose.width, ev.xexpose.height, False); |
1555 | |
1540 | |
1556 | scr_refresh (refresh_type); |
1541 | want_refresh = 1; |
1557 | } |
1542 | } |
1558 | else |
1543 | else |
1559 | { |
1544 | { |
1560 | XEvent unused_event; |
1545 | XEvent unused_event; |
1561 | |
1546 | |
… | |
… | |
1567 | if (isScrollbarWindow (ev.xany.window)) |
1552 | if (isScrollbarWindow (ev.xany.window)) |
1568 | { |
1553 | { |
1569 | scrollBar.setIdle (); |
1554 | scrollBar.setIdle (); |
1570 | scrollbar_show (0); |
1555 | scrollbar_show (0); |
1571 | } |
1556 | } |
1572 | #ifdef MENUBAR |
|
|
1573 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1574 | menubar_expose (); |
|
|
1575 | #endif |
|
|
1576 | |
1557 | |
1577 | #ifdef TRANSPARENT |
1558 | #ifdef TRANSPARENT |
1578 | if (am_transparent && ev.xany.window == parent[0]) |
1559 | if (am_transparent && ev.xany.window == parent[0]) |
1579 | XClearWindow (disp, ev.xany.window); |
1560 | XClearWindow (disp, ev.xany.window); |
1580 | #endif |
1561 | #endif |
… | |
… | |
1584 | case MotionNotify: |
1565 | case MotionNotify: |
1585 | #ifdef POINTER_BLANK |
1566 | #ifdef POINTER_BLANK |
1586 | if (hidden_pointer) |
1567 | if (hidden_pointer) |
1587 | pointer_unblank (); |
1568 | pointer_unblank (); |
1588 | #endif |
1569 | #endif |
1589 | #if MENUBAR |
|
|
1590 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1591 | { |
|
|
1592 | menubar_control (ev.xbutton); |
|
|
1593 | break; |
|
|
1594 | } |
|
|
1595 | #endif |
|
|
1596 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1570 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1597 | break; |
1571 | break; |
1598 | |
1572 | |
1599 | if (ev.xany.window == vt) |
1573 | if (ev.xany.window == vt) |
1600 | { |
1574 | { |
|
|
1575 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1576 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1577 | ; // nop |
1601 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1578 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1602 | { |
1579 | { |
1603 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1580 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1604 | ; |
1581 | ; |
1605 | |
1582 | |
1606 | XQueryPointer (disp, vt, |
1583 | XQueryPointer (disp, vt, |
… | |
… | |
1686 | &unused_root_x, &unused_root_y, |
1663 | &unused_root_x, &unused_root_y, |
1687 | &ev.xbutton.x, &ev.xbutton.y, |
1664 | &ev.xbutton.x, &ev.xbutton.y, |
1688 | &unused_mask); |
1665 | &unused_mask); |
1689 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1666 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1690 | scrollbar_size ()); |
1667 | scrollbar_size ()); |
1691 | scr_refresh (refresh_type); |
1668 | want_refresh = 1; |
1692 | refresh_limit = 0; |
1669 | refresh_limit = 0; |
1693 | scrollbar_show (1); |
1670 | scrollbar_show (1); |
1694 | } |
1671 | } |
1695 | break; |
1672 | break; |
1696 | } |
1673 | } |
|
|
1674 | |
|
|
1675 | skip_switch: ; |
|
|
1676 | |
|
|
1677 | #if defined(CURSOR_BLINK) |
|
|
1678 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1679 | { |
|
|
1680 | if (hidden_cursor) |
|
|
1681 | { |
|
|
1682 | hidden_cursor = 0; |
|
|
1683 | want_refresh = 1; |
|
|
1684 | } |
|
|
1685 | |
|
|
1686 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1687 | } |
|
|
1688 | #endif |
|
|
1689 | |
|
|
1690 | #if defined(POINTER_BLANK) |
|
|
1691 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1692 | { |
|
|
1693 | if (ev.type == MotionNotify |
|
|
1694 | || ev.type == ButtonPress |
|
|
1695 | || ev.type == ButtonRelease) |
|
|
1696 | if (hidden_pointer) |
|
|
1697 | pointer_unblank (); |
|
|
1698 | |
|
|
1699 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1700 | pointer_blank (); |
|
|
1701 | } |
|
|
1702 | #endif |
1697 | } |
1703 | } |
1698 | |
1704 | |
1699 | void |
1705 | void |
1700 | rxvt_term::focus_in () |
1706 | rxvt_term::focus_in () |
1701 | { |
1707 | { |
1702 | if (!focus) |
1708 | if (!focus) |
1703 | { |
1709 | { |
1704 | focus = 1; |
1710 | focus = 1; |
1705 | want_refresh = 1; |
1711 | want_refresh = 1; |
1706 | |
1712 | |
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1713 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1708 | |
1714 | |
1709 | #if USE_XIM |
1715 | #if USE_XIM |
1710 | if (Input_Context != NULL) |
1716 | if (Input_Context != NULL) |
1711 | { |
1717 | { |
1712 | IMSetStatusPosition (); |
1718 | IMSetStatusPosition (); |
1713 | XSetICFocus (Input_Context); |
1719 | XSetICFocus (Input_Context); |
1714 | } |
1720 | } |
1715 | #endif |
1721 | #endif |
1716 | #if CURSOR_BLINK |
1722 | #if CURSOR_BLINK |
1717 | if (OPTION (Opt_cursorBlink)) |
1723 | if (OPTION (Opt_cursorBlink)) |
1718 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1724 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1719 | #endif |
1725 | #endif |
1720 | #if OFF_FOCUS_FADING |
1726 | #if OFF_FOCUS_FADING |
1721 | if (rs[Rs_fade]) |
1727 | if (rs[Rs_fade]) |
1722 | { |
1728 | { |
1723 | pix_colors = pix_colors_focused; |
1729 | pix_colors = pix_colors_focused; |
… | |
… | |
1733 | if (focus) |
1739 | if (focus) |
1734 | { |
1740 | { |
1735 | focus = 0; |
1741 | focus = 0; |
1736 | want_refresh = 1; |
1742 | want_refresh = 1; |
1737 | |
1743 | |
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1744 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1739 | |
1745 | |
1740 | #if ENABLE_FRILLS || ISO_14755 |
1746 | #if ENABLE_FRILLS || ISO_14755 |
1741 | if (iso14755buf) |
1747 | if (iso14755buf) |
1742 | { |
1748 | { |
1743 | iso14755buf = 0; |
1749 | iso14755buf = 0; |
… | |
… | |
1767 | |
1773 | |
1768 | #if TRANSPARENT |
1774 | #if TRANSPARENT |
1769 | void |
1775 | void |
1770 | rxvt_term::rootwin_cb (XEvent &ev) |
1776 | rxvt_term::rootwin_cb (XEvent &ev) |
1771 | { |
1777 | { |
1772 | SET_R (this); |
1778 | make_current (); |
1773 | SET_LOCALE (locale); |
|
|
1774 | |
1779 | |
1775 | switch (ev.type) |
1780 | switch (ev.type) |
1776 | { |
1781 | { |
1777 | case PropertyNotify: |
1782 | case PropertyNotify: |
1778 | /* |
1783 | /* |
… | |
… | |
1805 | /* |
1810 | /* |
1806 | * VT window processing of button press |
1811 | * VT window processing of button press |
1807 | */ |
1812 | */ |
1808 | if (ev.window == vt) |
1813 | if (ev.window == vt) |
1809 | { |
1814 | { |
|
|
1815 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1816 | return; |
|
|
1817 | |
1810 | #if ISO_14755 |
1818 | #if ISO_14755 |
1811 | // 5.4 |
1819 | // 5.4 |
1812 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1820 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1813 | { |
1821 | { |
1814 | iso14755_54 (ev.x, ev.y); |
1822 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1826 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1834 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1827 | if (ev.button == MEvent.button && clickintime) |
1835 | if (ev.button == MEvent.button && clickintime) |
1828 | { |
1836 | { |
1829 | /* same button, within alloted time */ |
1837 | /* same button, within alloted time */ |
1830 | MEvent.clicks++; |
1838 | MEvent.clicks++; |
|
|
1839 | |
1831 | if (MEvent.clicks > 1) |
1840 | if (MEvent.clicks > 1) |
1832 | { |
1841 | { |
1833 | /* only report double clicks */ |
1842 | /* only report double clicks */ |
1834 | MEvent.clicks = 2; |
1843 | MEvent.clicks = 2; |
1835 | mouse_report (ev); |
1844 | mouse_report (ev); |
… | |
… | |
1855 | else |
1864 | else |
1856 | { |
1865 | { |
1857 | if (ev.button != MEvent.button) |
1866 | if (ev.button != MEvent.button) |
1858 | MEvent.clicks = 0; |
1867 | MEvent.clicks = 0; |
1859 | |
1868 | |
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
|
|
1861 | switch (ev.button) |
1869 | switch (ev.button) |
1862 | { |
1870 | { |
1863 | case Button1: |
1871 | case Button1: |
1864 | /* allow meta + click to select rectangular areas */ |
1872 | /* allow meta + click to select rectangular areas */ |
1865 | /* should be done in screen.C */ |
1873 | /* should be done in screen.C */ |
1866 | #if ENABLE_FRILLS |
1874 | #if ENABLE_FRILLS |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1875 | selection.rect = !!(ev.state & ModMetaMask); |
1868 | #else |
1876 | #else |
1869 | selection.rect = false; |
1877 | selection.rect = false; |
1870 | #endif |
1878 | #endif |
1871 | |
1879 | |
1872 | /* allow shift+left click to extend selection */ |
1880 | /* allow shift+left click to extend selection */ |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1881 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1874 | { |
1882 | { |
1875 | if (MEvent.button == Button1 && clickintime) |
1883 | if (MEvent.button == Button1 && clickintime) |
1876 | selection_rotate (ev.x, ev.y); |
1884 | selection_rotate (ev.x, ev.y); |
1877 | else |
1885 | else |
1878 | selection_extend (ev.x, ev.y, 1); |
1886 | selection_extend (ev.x, ev.y, 1); |
1879 | } |
1887 | } |
1880 | else |
1888 | else |
1881 | { |
1889 | { |
1882 | if (MEvent.button == Button1 && clickintime) |
1890 | if (MEvent.button == Button1 && clickintime) |
1883 | MEvent.clicks++; |
1891 | MEvent.clicks++; |
1884 | else |
1892 | else |
1885 | MEvent.clicks = 1; |
1893 | MEvent.clicks = 1; |
1886 | |
1894 | |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1895 | selection_click (MEvent.clicks, ev.x, ev.y); |
1888 | } |
1896 | } |
1889 | |
1897 | |
1890 | MEvent.button = Button1; |
1898 | MEvent.button = Button1; |
1891 | break; |
1899 | break; |
1892 | |
1900 | |
1893 | case Button3: |
1901 | case Button3: |
1894 | if (MEvent.button == Button3 && clickintime) |
1902 | if (MEvent.button == Button3 && clickintime) |
1895 | selection_rotate (ev.x, ev.y); |
1903 | selection_rotate (ev.x, ev.y); |
1896 | else |
1904 | else |
1897 | selection_extend (ev.x, ev.y, 1); |
1905 | selection_extend (ev.x, ev.y, 1); |
1898 | |
1906 | |
1899 | MEvent.button = Button3; |
1907 | MEvent.button = Button3; |
1900 | break; |
1908 | break; |
1901 | } |
1909 | } |
1902 | } |
1910 | } |
1903 | |
1911 | |
1904 | MEvent.time = ev.time; |
1912 | MEvent.time = ev.time; |
1905 | return; |
1913 | return; |
1906 | } |
1914 | } |
1907 | |
1915 | |
… | |
… | |
2043 | } |
2051 | } |
2044 | |
2052 | |
2045 | break; |
2053 | break; |
2046 | } |
2054 | } |
2047 | } |
2055 | } |
|
|
2056 | |
2048 | return; |
2057 | return; |
2049 | } |
2058 | } |
2050 | #if MENUBAR |
|
|
2051 | /* |
|
|
2052 | * Menubar window processing of button press |
|
|
2053 | */ |
|
|
2054 | if (isMenuBarWindow (ev.window)) |
|
|
2055 | menubar_control (ev); |
|
|
2056 | #endif |
|
|
2057 | } |
2059 | } |
2058 | |
2060 | |
2059 | void |
2061 | void |
2060 | rxvt_term::button_release (XButtonEvent &ev) |
2062 | rxvt_term::button_release (XButtonEvent &ev) |
2061 | { |
2063 | { |
… | |
… | |
2067 | |
2069 | |
2068 | if (scrollbar_isUpDn ()) |
2070 | if (scrollbar_isUpDn ()) |
2069 | { |
2071 | { |
2070 | scrollBar.setIdle (); |
2072 | scrollBar.setIdle (); |
2071 | scrollbar_show (0); |
2073 | scrollbar_show (0); |
2072 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2073 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2074 | #endif |
|
|
2075 | } |
2074 | } |
2076 | |
2075 | |
2077 | #ifdef SELECTION_SCROLLING |
2076 | #ifdef SELECTION_SCROLLING |
2078 | if (sel_scroll_ev.active) |
2077 | if (sel_scroll_ev.active) |
2079 | sel_scroll_ev.stop(); |
2078 | sel_scroll_ev.stop(); |
2080 | #endif |
2079 | #endif |
2081 | |
2080 | |
2082 | if (ev.window == vt) |
2081 | if (ev.window == vt) |
2083 | { |
2082 | { |
|
|
2083 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2084 | return; |
|
|
2085 | |
2084 | #if ISO_14755 |
2086 | #if ISO_14755 |
2085 | // 5.4 |
2087 | // 5.4 |
2086 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2088 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2087 | return; |
2089 | return; |
2088 | #endif |
2090 | #endif |
|
|
2091 | |
2089 | if (reportmode) |
2092 | if (reportmode) |
2090 | { |
2093 | { |
2091 | /* mouse report from vt window */ |
2094 | /* mouse report from vt window */ |
2092 | /* don't report release of wheel "buttons" */ |
2095 | /* don't report release of wheel "buttons" */ |
2093 | if (ev.button >= 4) |
2096 | if (ev.button >= 4) |
… | |
… | |
2123 | { |
2126 | { |
2124 | case Button1: |
2127 | case Button1: |
2125 | case Button3: |
2128 | case Button3: |
2126 | selection_make (ev.time); |
2129 | selection_make (ev.time); |
2127 | break; |
2130 | break; |
|
|
2131 | |
2128 | case Button2: |
2132 | case Button2: |
2129 | selection_request (ev.time, ev.x, ev.y); |
2133 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2134 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2130 | break; |
2135 | break; |
|
|
2136 | |
2131 | #ifdef MOUSE_WHEEL |
2137 | #ifdef MOUSE_WHEEL |
2132 | case Button4: |
2138 | case Button4: |
2133 | case Button5: |
2139 | case Button5: |
2134 | { |
2140 | { |
2135 | int i; |
2141 | int i; |
… | |
… | |
2157 | slip_wheel_ev.start (); |
2163 | slip_wheel_ev.start (); |
2158 | } |
2164 | } |
2159 | else |
2165 | else |
2160 | { |
2166 | { |
2161 | # endif |
2167 | # endif |
2162 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2163 | scr_page (v, i); |
2168 | scr_page (v, i); |
2164 | scr_refresh (SMOOTH_REFRESH); |
|
|
2165 | scrollbar_show (1); |
2169 | scrollbar_show (1); |
2166 | # else |
|
|
2167 | while (i--) |
|
|
2168 | { |
|
|
2169 | scr_page (v, 1); |
|
|
2170 | scr_refresh (SMOOTH_REFRESH); |
|
|
2171 | scrollbar_show (1); |
|
|
2172 | } |
|
|
2173 | # endif |
|
|
2174 | # ifdef MOUSE_SLIP_WHEELING |
2170 | # ifdef MOUSE_SLIP_WHEELING |
2175 | } |
2171 | } |
2176 | #endif |
2172 | # endif |
2177 | } |
2173 | } |
2178 | break; |
2174 | break; |
2179 | #endif |
2175 | #endif |
2180 | } |
2176 | } |
2181 | } |
2177 | } |
2182 | #ifdef MENUBAR |
|
|
2183 | else if (isMenuBarWindow (ev.window)) |
|
|
2184 | menubar_control (ev); |
|
|
2185 | #endif |
|
|
2186 | } |
2178 | } |
2187 | |
2179 | |
2188 | #ifdef TRANSPARENT |
2180 | #ifdef TRANSPARENT |
2189 | #if TINTING |
2181 | #if TINTING |
2190 | /* taken from aterm-0.4.2 */ |
2182 | /* taken from aterm-0.4.2 */ |
… | |
… | |
2627 | am_transparent = 0; |
2619 | am_transparent = 0; |
2628 | /* XXX: also turn off Opt_transparent? */ |
2620 | /* XXX: also turn off Opt_transparent? */ |
2629 | } |
2621 | } |
2630 | else |
2622 | else |
2631 | { |
2623 | { |
2632 | #if WAIT_FOR_WM |
|
|
2633 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2634 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2635 | sleep (1); |
|
|
2636 | #endif |
|
|
2637 | for (n = 0; n < (unsigned int)i; n++) |
2624 | for (n = 0; n < (unsigned int)i; n++) |
2638 | { |
2625 | { |
2639 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2626 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2640 | XClearWindow (disp, parent[n]); |
2627 | XClearWindow (disp, parent[n]); |
2641 | } |
2628 | } |
… | |
… | |
2670 | |
2657 | |
2671 | bool |
2658 | bool |
2672 | rxvt_term::cmd_parse () |
2659 | rxvt_term::cmd_parse () |
2673 | { |
2660 | { |
2674 | bool flag = false; |
2661 | bool flag = false; |
2675 | unicode_t ch = NOCHAR; |
2662 | wchar_t ch = NOCHAR; |
2676 | unsigned char *seq_begin; // remember start of esc-sequence here |
2663 | char *seq_begin; // remember start of esc-sequence here |
2677 | |
2664 | |
2678 | for (;;) |
2665 | for (;;) |
2679 | { |
2666 | { |
2680 | if (ch == NOCHAR) |
2667 | if (ch == NOCHAR) |
2681 | { |
2668 | { |
2682 | seq_begin = cmdbuf_ptr; |
2669 | seq_begin = cmdbuf_ptr; |
2683 | ch = next_char (); |
2670 | ch = next_char (); |
2684 | } |
|
|
2685 | |
2671 | |
2686 | if (ch == NOCHAR) // TODO: improve |
2672 | if (ch == NOCHAR) |
2687 | break; |
2673 | break; |
|
|
2674 | } |
2688 | |
2675 | |
2689 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2676 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2690 | { |
2677 | { |
2691 | if (!seen_input) |
2678 | if (!seen_input) |
2692 | { |
2679 | { |
… | |
… | |
2701 | if (seen_resize && cmd_pid) |
2688 | if (seen_resize && cmd_pid) |
2702 | kill (-cmd_pid, SIGWINCH); |
2689 | kill (-cmd_pid, SIGWINCH); |
2703 | } |
2690 | } |
2704 | |
2691 | |
2705 | /* Read a text string from the input buffer */ |
2692 | /* Read a text string from the input buffer */ |
2706 | unicode_t buf[UBUFSIZ]; |
2693 | wchar_t buf[UBUFSIZ]; |
2707 | bool refreshnow = false; |
2694 | bool refreshnow = false; |
2708 | int nlines = 0; |
2695 | int nlines = 0; |
2709 | unicode_t *str = buf; |
2696 | wchar_t *str = buf; |
2710 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2697 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2711 | |
2698 | |
2712 | for (;;) |
2699 | for (;;) |
2713 | { |
2700 | { |
2714 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2701 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2715 | break; |
2702 | break; |
… | |
… | |
2733 | } |
2720 | } |
2734 | |
2721 | |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
2722 | // scr_add_lines only works for nlines <= nrow - 1. |
2736 | if (nlines >= nrow - 1) |
2723 | if (nlines >= nrow - 1) |
2737 | { |
2724 | { |
|
|
2725 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2726 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2738 | scr_add_lines (buf, nlines, str - buf); |
2727 | scr_add_lines (buf, str - buf, nlines); |
|
|
2728 | |
2739 | nlines = 0; |
2729 | nlines = 0; |
2740 | str = buf; |
2730 | str = buf; |
2741 | eol = str + min (ncol, UBUFSIZ); |
2731 | eol = str + min (ncol, UBUFSIZ); |
2742 | } |
2732 | } |
2743 | |
2733 | |
… | |
… | |
2756 | |
2746 | |
2757 | seq_begin = cmdbuf_ptr; |
2747 | seq_begin = cmdbuf_ptr; |
2758 | ch = next_char (); |
2748 | ch = next_char (); |
2759 | } |
2749 | } |
2760 | |
2750 | |
|
|
2751 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2752 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2761 | scr_add_lines (buf, nlines, str - buf); |
2753 | scr_add_lines (buf, str - buf, nlines); |
2762 | |
2754 | |
2763 | /* |
2755 | /* |
2764 | * If there have been a lot of new lines, then update the screen |
2756 | * If there have been a lot of new lines, then update the screen |
2765 | * What the heck I'll cheat and only refresh less than every page-full. |
2757 | * What the heck I'll cheat and only refresh less than every page-full. |
2766 | * the number of pages between refreshes is refresh_limit, which |
2758 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2771 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2763 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2772 | refresh_limit++; |
2764 | refresh_limit++; |
2773 | else |
2765 | else |
2774 | { |
2766 | { |
2775 | flag = true; |
2767 | flag = true; |
2776 | scr_refresh (refresh_type); |
2768 | scr_refresh (); |
2777 | flush_ev.stop (); |
2769 | want_refresh = 1; |
2778 | } |
2770 | } |
2779 | } |
2771 | } |
2780 | |
2772 | |
2781 | } |
2773 | } |
2782 | else |
2774 | else |
… | |
… | |
2797 | } |
2789 | } |
2798 | |
2790 | |
2799 | return flag; |
2791 | return flag; |
2800 | } |
2792 | } |
2801 | |
2793 | |
2802 | // read the next octet |
|
|
2803 | unicode_t |
|
|
2804 | rxvt_term::next_octet () |
|
|
2805 | { |
|
|
2806 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2807 | ? *cmdbuf_ptr++ |
|
|
2808 | : NOCHAR; |
|
|
2809 | } |
|
|
2810 | |
|
|
2811 | // read the next character |
2794 | // read the next character |
2812 | unicode_t |
2795 | wchar_t |
2813 | rxvt_term::next_char () |
2796 | rxvt_term::next_char () NOTHROW |
2814 | { |
2797 | { |
2815 | while (cmdbuf_ptr < cmdbuf_endp) |
2798 | while (cmdbuf_ptr < cmdbuf_endp) |
2816 | { |
2799 | { |
2817 | // assume 7-bit to be ascii ALWAYS |
2800 | // assume 7-bit to be ascii ALWAYS |
2818 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2801 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2819 | return *cmdbuf_ptr++; |
2802 | return *cmdbuf_ptr++; |
2820 | |
2803 | |
2821 | wchar_t wc; |
2804 | wchar_t wc; |
2822 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2805 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2823 | |
2806 | |
2824 | if (len == (size_t)-2) |
2807 | if (len == (size_t)-2) |
2825 | { |
2808 | { |
2826 | // the mbstate stores incomplete sequences. didn't know this :/ |
2809 | // the mbstate stores incomplete sequences. didn't know this :/ |
2827 | cmdbuf_ptr = cmdbuf_endp; |
2810 | cmdbuf_ptr = cmdbuf_endp; |
2828 | break; |
2811 | break; |
2829 | } |
2812 | } |
2830 | |
2813 | |
2831 | if (len == (size_t)-1) |
2814 | if (len == (size_t)-1) |
2832 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2815 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2833 | |
2816 | |
2834 | // assume wchar == unicode |
2817 | // assume wchar == unicode |
2835 | cmdbuf_ptr += len; |
2818 | cmdbuf_ptr += len; |
2836 | return wc & UNICODE_MASK; |
2819 | return wc & UNICODE_MASK; |
2837 | } |
2820 | } |
2838 | |
2821 | |
2839 | return NOCHAR; |
2822 | return NOCHAR; |
2840 | } |
2823 | } |
|
|
2824 | |
|
|
2825 | // read the next octet |
|
|
2826 | uint32_t |
|
|
2827 | rxvt_term::next_octet () NOTHROW |
|
|
2828 | { |
|
|
2829 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2830 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2831 | : NOCHAR; |
|
|
2832 | } |
|
|
2833 | |
|
|
2834 | static class out_of_input out_of_input; |
2841 | |
2835 | |
2842 | /* rxvt_cmd_getc () - Return next input character */ |
2836 | /* rxvt_cmd_getc () - Return next input character */ |
2843 | /* |
2837 | /* |
2844 | * Return the next input character after first passing any keyboard input |
2838 | * Return the next input character after first passing any keyboard input |
2845 | * to the command. |
2839 | * to the command. |
2846 | */ |
2840 | */ |
2847 | unicode_t |
2841 | wchar_t |
2848 | rxvt_term::cmd_getc () |
2842 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2849 | { |
2843 | { |
2850 | unicode_t c = next_char (); |
2844 | wchar_t c = next_char (); |
2851 | |
2845 | |
2852 | if (c == NOCHAR) |
2846 | if (c == NOCHAR) |
2853 | throw out_of_input; |
2847 | throw out_of_input; |
2854 | |
2848 | |
2855 | return c; |
2849 | return c; |
2856 | } |
2850 | } |
2857 | |
2851 | |
2858 | unicode_t |
2852 | uint32_t |
2859 | rxvt_term::cmd_get8 () |
2853 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2860 | { |
2854 | { |
2861 | unicode_t c = next_octet (); |
2855 | uint32_t c = next_octet (); |
2862 | |
2856 | |
2863 | if (c == NOCHAR) |
2857 | if (c == NOCHAR) |
2864 | throw out_of_input; |
2858 | throw out_of_input; |
2865 | |
2859 | |
2866 | return c; |
2860 | return c; |
… | |
… | |
2966 | case C0_ESC: |
2960 | case C0_ESC: |
2967 | process_escape_seq (); |
2961 | process_escape_seq (); |
2968 | break; |
2962 | break; |
2969 | case C0_ENQ: /* terminal Status */ |
2963 | case C0_ENQ: /* terminal Status */ |
2970 | if (rs[Rs_answerbackstring]) |
2964 | if (rs[Rs_answerbackstring]) |
2971 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2965 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2972 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2973 | else |
2966 | else |
2974 | tt_write ((unsigned char *)VT100_ANS, |
2967 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2975 | (unsigned int)strlen (VT100_ANS)); |
|
|
2976 | break; |
2968 | break; |
2977 | case C0_BEL: /* bell */ |
2969 | case C0_BEL: /* bell */ |
2978 | scr_bell (); |
2970 | scr_bell (); |
2979 | break; |
2971 | break; |
2980 | case C0_BS: /* backspace */ |
2972 | case C0_BS: /* backspace */ |
… | |
… | |
3135 | break; |
3127 | break; |
3136 | |
3128 | |
3137 | /* 8.3.87: NEXT LINE */ |
3129 | /* 8.3.87: NEXT LINE */ |
3138 | case C1_NEL: /* ESC E */ |
3130 | case C1_NEL: /* ESC E */ |
3139 | { |
3131 | { |
3140 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3132 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3141 | scr_add_lines (nlcr, 1, 2); |
3133 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3142 | } |
3134 | } |
3143 | break; |
3135 | break; |
3144 | |
3136 | |
3145 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3137 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3146 | case C1_ESA: /* ESC G */ |
3138 | case C1_ESA: /* ESC G */ |
… | |
… | |
3168 | process_dcs_seq (); |
3160 | process_dcs_seq (); |
3169 | break; |
3161 | break; |
3170 | |
3162 | |
3171 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3163 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3172 | case C1_SCI: /* ESC Z */ |
3164 | case C1_SCI: /* ESC Z */ |
3173 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3165 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3174 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3175 | break; /* steal obsolete ESC [ c */ |
3166 | break; /* steal obsolete ESC [ c */ |
3176 | |
3167 | |
3177 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3168 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3178 | case C1_CSI: /* ESC [ */ |
3169 | case C1_CSI: /* ESC [ */ |
3179 | process_csi_seq (); |
3170 | process_csi_seq (); |
… | |
… | |
3288 | ndef = get_byte_array_bit (csi_defaults, i); |
3279 | ndef = get_byte_array_bit (csi_defaults, i); |
3289 | for (p = 0; p < nargs; p++) |
3280 | for (p = 0; p < nargs; p++) |
3290 | if (arg[p] == -1) |
3281 | if (arg[p] == -1) |
3291 | arg[p] = ndef; |
3282 | arg[p] = ndef; |
3292 | |
3283 | |
3293 | #ifdef DEBUG_CMD |
|
|
3294 | fprintf (stderr, "CSI "); |
|
|
3295 | for (p = 0; p < nargs; p++) |
|
|
3296 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3297 | fprintf (stderr, "%c\n", ch); |
|
|
3298 | #endif |
|
|
3299 | |
|
|
3300 | /* |
3284 | /* |
3301 | * private mode handling |
3285 | * private mode handling |
3302 | */ |
3286 | */ |
3303 | if (priv) |
3287 | if (priv) |
3304 | { |
3288 | { |
3305 | switch (priv) |
3289 | switch (priv) |
3306 | { |
3290 | { |
3307 | case '>': |
3291 | case '>': |
3308 | if (ch == CSI_DA) /* secondary device attributes */ |
3292 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3293 | { |
|
|
3294 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3295 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3296 | // |
|
|
3297 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3298 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3299 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3300 | // |
3309 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3301 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3302 | } |
3310 | break; |
3303 | break; |
3311 | case '?': |
3304 | case '?': |
3312 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3305 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3313 | process_terminal_mode (ch, priv, nargs, arg); |
3306 | process_terminal_mode (ch, priv, nargs, arg); |
3314 | break; |
3307 | break; |
… | |
… | |
3423 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3416 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3424 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3417 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3425 | break; |
3418 | break; |
3426 | |
3419 | |
3427 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3420 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3428 | tt_write ((const unsigned char *)VT100_ANS, |
3421 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3429 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3430 | break; |
3422 | break; |
3431 | |
3423 | |
3432 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3424 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3433 | process_sgr_mode (nargs, arg); |
3425 | process_sgr_mode (nargs, arg); |
3434 | break; |
3426 | break; |
… | |
… | |
3636 | /*----------------------------------------------------------------------*/ |
3628 | /*----------------------------------------------------------------------*/ |
3637 | /* |
3629 | /* |
3638 | * get input up until STRING TERMINATOR (or BEL) |
3630 | * get input up until STRING TERMINATOR (or BEL) |
3639 | * ends_how is terminator used. returned input must be free()'d |
3631 | * ends_how is terminator used. returned input must be free()'d |
3640 | */ |
3632 | */ |
3641 | unsigned char * |
3633 | char * |
3642 | rxvt_term::get_to_st (unicode_t &ends_how) |
3634 | rxvt_term::get_to_st (unicode_t &ends_how) |
3643 | { |
3635 | { |
3644 | unicode_t ch; |
3636 | unicode_t ch; |
3645 | bool seen_esc = false; |
3637 | bool seen_esc = false; |
3646 | unsigned int n = 0; |
3638 | unsigned int n = 0; |
… | |
… | |
3679 | |
3671 | |
3680 | string[n++] = '\0'; |
3672 | string[n++] = '\0'; |
3681 | |
3673 | |
3682 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3674 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3683 | |
3675 | |
3684 | return (unsigned char *)rxvt_wcstombs (string); |
3676 | return rxvt_wcstombs (string); |
3685 | } |
3677 | } |
3686 | |
3678 | |
3687 | /*----------------------------------------------------------------------*/ |
3679 | /*----------------------------------------------------------------------*/ |
3688 | /* |
3680 | /* |
3689 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3681 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3690 | */ |
3682 | */ |
3691 | void |
3683 | void |
3692 | rxvt_term::process_dcs_seq () |
3684 | rxvt_term::process_dcs_seq () |
3693 | { |
3685 | { |
3694 | unsigned char *s; |
3686 | char *s; |
3695 | unicode_t eh; |
3687 | unicode_t eh; |
3696 | |
3688 | |
3697 | /* |
3689 | /* |
3698 | * Not handled yet |
3690 | * Not handled yet |
3699 | */ |
3691 | */ |
… | |
… | |
3718 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3710 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3719 | arg = arg * 10 + (ch - '0'); |
3711 | arg = arg * 10 + (ch - '0'); |
3720 | |
3712 | |
3721 | if (ch == ';') |
3713 | if (ch == ';') |
3722 | { |
3714 | { |
3723 | unsigned char *s = get_to_st (eh); |
3715 | char *s = get_to_st (eh); |
3724 | |
3716 | |
3725 | if (s) |
3717 | if (s) |
3726 | { |
3718 | { |
3727 | process_xterm_seq (arg, (char *)s, eh); |
3719 | process_xterm_seq (arg, s, eh); |
3728 | free (s); |
3720 | free (s); |
3729 | } |
3721 | } |
3730 | } |
3722 | } |
3731 | } |
3723 | } |
3732 | |
3724 | |
3733 | void |
3725 | void |
3734 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3726 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3735 | { |
3727 | { |
3736 | if (str[0] == '?' && !str[1]) |
3728 | if (str[0] == '?' && !str[1]) |
3737 | { |
3729 | { |
3738 | unsigned short r, g, b; |
3730 | unsigned short r, g, b; |
3739 | pix_colors_focused[color].get (display, r, g, b); |
3731 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3745 | |
3737 | |
3746 | /* |
3738 | /* |
3747 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3739 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3748 | */ |
3740 | */ |
3749 | void |
3741 | void |
3750 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3742 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3751 | { |
3743 | { |
3752 | int changed = 0; |
|
|
3753 | int color; |
3744 | int color; |
3754 | char *buf, *name; |
3745 | char *buf, *name; |
3755 | bool query = str[0] == '?' && !str[1]; |
3746 | bool query = str[0] == '?' && !str[1]; |
3756 | int saveop = op; |
3747 | int saveop = op; |
3757 | dDisp; |
3748 | dDisp; |
… | |
… | |
3812 | { |
3803 | { |
3813 | if ((name = strchr (buf, ';')) == NULL) |
3804 | if ((name = strchr (buf, ';')) == NULL) |
3814 | break; |
3805 | break; |
3815 | |
3806 | |
3816 | *name++ = '\0'; |
3807 | *name++ = '\0'; |
3817 | color = atoi (buf); |
3808 | color = atoi (buf) + minCOLOR; |
3818 | |
3809 | |
3819 | if (color < 0 || color >= TOTAL_COLORS) |
3810 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3820 | break; |
3811 | break; |
3821 | |
3812 | |
3822 | if ((buf = strchr (name, ';')) != NULL) |
3813 | if ((buf = strchr (name, ';')) != NULL) |
3823 | *buf++ = '\0'; |
3814 | *buf++ = '\0'; |
3824 | |
3815 | |
3825 | if (name[0] == '?' && !name[1]) |
3816 | if (name[0] == '?' && !name[1]) |
3826 | { |
3817 | { |
3827 | unsigned short r, g, b; |
3818 | unsigned short r, g, b; |
3828 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3819 | pix_colors_focused[color].get (display, r, g, b); |
3829 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3820 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3830 | } |
3821 | } |
3831 | else |
3822 | else |
3832 | set_window_color (color + minCOLOR, name); |
3823 | set_window_color (color, name); |
3833 | } |
3824 | } |
3834 | break; |
3825 | break; |
3835 | case XTerm_Color00: |
3826 | case XTerm_Color00: |
3836 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3827 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3837 | break; |
3828 | break; |
3838 | case XTerm_Color01: |
3829 | case XTerm_Color01: |
3839 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3830 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3840 | break; |
3831 | break; |
3841 | #ifndef NO_CURSORCOLOR |
3832 | #ifndef NO_CURSORCOLOR |
3842 | case XTerm_Color_cursor: |
3833 | case XTerm_Color_cursor: |
3843 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3834 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3844 | break; |
3835 | break; |
… | |
… | |
3848 | break; |
3839 | break; |
3849 | case XTerm_Color_pointer_bg: |
3840 | case XTerm_Color_pointer_bg: |
3850 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3841 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3851 | break; |
3842 | break; |
3852 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3843 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3853 | case XTerm_Color_BD: |
|
|
3854 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3855 | break; |
|
|
3856 | case XTerm_Color_UL: |
|
|
3857 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3858 | break; |
|
|
3859 | case XTerm_Color_RV: |
3844 | case XTerm_Color_RV: |
3860 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3845 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3846 | break; |
|
|
3847 | case Rxvt_Color_BD: |
|
|
3848 | case URxvt_Color_BD: |
|
|
3849 | process_color_seq (op, Color_BD, str, resp); |
|
|
3850 | break; |
|
|
3851 | case Rxvt_Color_UL: |
|
|
3852 | case URxvt_Color_UL: |
|
|
3853 | process_color_seq (op, Color_UL, str, resp); |
3861 | break; |
3854 | break; |
3862 | case URxvt_Color_IT: |
3855 | case URxvt_Color_IT: |
3863 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3856 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3864 | break; |
3857 | break; |
3865 | #endif |
3858 | #endif |
… | |
… | |
3870 | if (am_transparent) |
3863 | if (am_transparent) |
3871 | want_full_refresh = want_refresh = 1; |
3864 | want_full_refresh = want_refresh = 1; |
3872 | break; |
3865 | break; |
3873 | #endif |
3866 | #endif |
3874 | |
3867 | |
3875 | case XTerm_Pixmap: |
3868 | case Rxvt_Pixmap: |
|
|
3869 | { |
3876 | if (*str != ';') |
3870 | if (*str != ';') |
3877 | { |
3871 | { |
3878 | #if XPM_BACKGROUND |
3872 | #if XPM_BACKGROUND |
3879 | scale_pixmap (""); /* reset to default scaling */ |
3873 | scale_pixmap (""); /* reset to default scaling */ |
3880 | set_bgPixmap (str); /* change pixmap */ |
3874 | set_bgPixmap (str); /* change pixmap */ |
3881 | #endif |
|
|
3882 | scr_touch (true); |
3875 | scr_touch (true); |
|
|
3876 | #endif |
3883 | } |
3877 | } |
|
|
3878 | |
|
|
3879 | int changed = 0; |
|
|
3880 | |
3884 | while ((str = strchr (str, ';')) != NULL) |
3881 | while ((str = strchr (str, ';')) != NULL) |
3885 | { |
3882 | { |
3886 | str++; |
3883 | str++; |
3887 | #if XPM_BACKGROUND |
3884 | #if XPM_BACKGROUND |
3888 | changed += scale_pixmap (str); |
3885 | changed += scale_pixmap (str); |
3889 | #endif |
3886 | #endif |
3890 | } |
3887 | } |
3891 | |
3888 | |
3892 | if (changed) |
3889 | if (changed) |
3893 | { |
3890 | { |
3894 | #ifdef XPM_BACKGROUND |
3891 | #ifdef XPM_BACKGROUND |
3895 | resize_pixmap (); |
3892 | resize_pixmap (); |
3896 | #endif |
|
|
3897 | scr_touch (true); |
3893 | scr_touch (true); |
|
|
3894 | #endif |
3898 | } |
3895 | } |
|
|
3896 | } |
3899 | break; |
3897 | break; |
3900 | |
3898 | |
3901 | case XTerm_restoreFG: |
3899 | case Rxvt_restoreFG: |
3902 | set_window_color (Color_fg, str); |
3900 | set_window_color (Color_fg, str); |
3903 | break; |
3901 | break; |
3904 | case XTerm_restoreBG: |
3902 | case Rxvt_restoreBG: |
3905 | set_window_color (Color_bg, str); |
3903 | set_window_color (Color_bg, str); |
3906 | break; |
3904 | break; |
3907 | |
3905 | |
3908 | case XTerm_logfile: |
3906 | case XTerm_logfile: |
3909 | // TODO, when secure mode? |
3907 | // TODO, when secure mode? |
3910 | break; |
3908 | break; |
3911 | |
3909 | |
3912 | #ifdef MENUBAR |
|
|
3913 | case URxvt_Menu: |
|
|
3914 | if (OPTION (Opt_insecure)) |
|
|
3915 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3916 | break; |
|
|
3917 | #endif |
|
|
3918 | #if 0 |
3910 | #if 0 |
3919 | case XTerm_dumpscreen: /* no error notices */ |
3911 | case Rxvt_dumpscreen: /* no error notices */ |
3920 | { |
3912 | { |
3921 | int fd; |
3913 | int fd; |
3922 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3914 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3923 | { |
3915 | { |
3924 | scr_dump (fd); |
3916 | scr_dump (fd); |
… | |
… | |
3955 | if (query) |
3947 | if (query) |
3956 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3948 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3957 | else |
3949 | else |
3958 | { |
3950 | { |
3959 | set_locale (str); |
3951 | set_locale (str); |
3960 | pty.set_utf8_mode (enc_utf8); |
3952 | pty->set_utf8_mode (enc_utf8); |
3961 | init_xlocale (); |
3953 | init_xlocale (); |
3962 | } |
3954 | } |
3963 | break; |
3955 | break; |
3964 | |
3956 | |
3965 | case URxvt_view_up: |
3957 | case URxvt_view_up: |
… | |
… | |
3976 | break; |
3968 | break; |
3977 | #endif |
3969 | #endif |
3978 | |
3970 | |
3979 | #if ENABLE_PERL |
3971 | #if ENABLE_PERL |
3980 | case URxvt_perl: |
3972 | case URxvt_perl: |
3981 | if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
3973 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3982 | ; // no responses yet |
3974 | ; // no responses yet |
3983 | break; |
3975 | break; |
3984 | #endif |
3976 | #endif |
3985 | } |
3977 | } |
3986 | } |
3978 | } |
… | |
… | |
4018 | return state; |
4010 | return state; |
4019 | } |
4011 | } |
4020 | |
4012 | |
4021 | /* we're not using priv _yet_ */ |
4013 | /* we're not using priv _yet_ */ |
4022 | void |
4014 | void |
4023 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4015 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4024 | { |
4016 | { |
4025 | unsigned int i, j; |
4017 | unsigned int i, j; |
4026 | int state; |
4018 | int state; |
4027 | |
4019 | |
4028 | static const struct |
4020 | static const struct |
… | |
… | |
4039 | { 5, PrivMode_rVideo }, |
4031 | { 5, PrivMode_rVideo }, |
4040 | { 6, PrivMode_relOrigin }, |
4032 | { 6, PrivMode_relOrigin }, |
4041 | { 7, PrivMode_Autowrap }, |
4033 | { 7, PrivMode_Autowrap }, |
4042 | // 8, bi-directional support mode |
4034 | // 8, bi-directional support mode |
4043 | { 9, PrivMode_MouseX10 }, |
4035 | { 9, PrivMode_MouseX10 }, |
4044 | #ifdef menuBar_esc |
|
|
4045 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4046 | #endif |
|
|
4047 | // 18, 19 printing-related |
4036 | // 18, 19 printing-related |
4048 | { 25, PrivMode_VisibleCursor }, |
4037 | { 25, PrivMode_VisibleCursor }, |
4049 | #ifdef scrollBar_esc |
4038 | #ifdef scrollBar_esc |
4050 | { scrollBar_esc, PrivMode_scrollBar }, |
4039 | { scrollBar_esc, PrivMode_scrollBar }, |
4051 | #endif |
4040 | #endif |
… | |
… | |
4098 | /* extra handling for values with state unkept */ |
4087 | /* extra handling for values with state unkept */ |
4099 | switch (arg[i]) |
4088 | switch (arg[i]) |
4100 | { |
4089 | { |
4101 | #if ENABLE_STYLES |
4090 | #if ENABLE_STYLES |
4102 | case 1021: |
4091 | case 1021: |
4103 | if (mode) |
4092 | set_option (Opt_intensityStyles, mode); |
4104 | SET_OPTION (Opt_intensityStyles); |
|
|
4105 | else |
|
|
4106 | CLR_OPTION (Opt_intensityStyles); |
|
|
4107 | |
4093 | |
4108 | scr_touch (true); |
4094 | scr_touch (true); |
4109 | break; |
4095 | break; |
4110 | #endif |
4096 | #endif |
4111 | case 1048: /* alternative cursor save */ |
4097 | case 1048: /* alternative cursor save */ |
… | |
… | |
4133 | case 3: /* 80/132 */ |
4119 | case 3: /* 80/132 */ |
4134 | if (priv_modes & PrivMode_132OK) |
4120 | if (priv_modes & PrivMode_132OK) |
4135 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4121 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4136 | break; |
4122 | break; |
4137 | case 4: /* smooth scrolling */ |
4123 | case 4: /* smooth scrolling */ |
4138 | if (!state) |
4124 | set_option (Opt_jumpScroll, !state); |
4139 | SET_OPTION (Opt_jumpScroll); |
|
|
4140 | else |
|
|
4141 | CLR_OPTION (Opt_jumpScroll); |
|
|
4142 | break; |
4125 | break; |
4143 | case 5: /* reverse video */ |
4126 | case 5: /* reverse video */ |
4144 | scr_rvideo_mode (state); |
4127 | scr_rvideo_mode (state); |
4145 | break; |
4128 | break; |
4146 | case 6: /* relative/absolute origins */ |
4129 | case 6: /* relative/absolute origins */ |
… | |
… | |
4152 | /* case 8: - auto repeat, can't do on a per window basis */ |
4135 | /* case 8: - auto repeat, can't do on a per window basis */ |
4153 | case 9: /* X10 mouse reporting */ |
4136 | case 9: /* X10 mouse reporting */ |
4154 | if (state) /* orthogonal */ |
4137 | if (state) /* orthogonal */ |
4155 | priv_modes &= ~PrivMode_MouseX11; |
4138 | priv_modes &= ~PrivMode_MouseX11; |
4156 | break; |
4139 | break; |
4157 | #ifdef menuBar_esc |
|
|
4158 | case menuBar_esc: |
|
|
4159 | #ifdef MENUBAR |
|
|
4160 | map_menuBar (state); |
|
|
4161 | #endif |
|
|
4162 | break; |
|
|
4163 | #endif |
|
|
4164 | #ifdef scrollBar_esc |
4140 | #ifdef scrollBar_esc |
4165 | case scrollBar_esc: |
4141 | case scrollBar_esc: |
4166 | if (scrollbar_mapping (state)) |
4142 | if (scrollbar_mapping (state)) |
4167 | { |
4143 | { |
4168 | resize_all_windows (0, 0, 0); |
4144 | resize_all_windows (0, 0, 0); |
… | |
… | |
4187 | #if 0 |
4163 | #if 0 |
4188 | case 1001: |
4164 | case 1001: |
4189 | break; /* X11 mouse highlighting */ |
4165 | break; /* X11 mouse highlighting */ |
4190 | #endif |
4166 | #endif |
4191 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4167 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4192 | if (!state) |
4168 | set_option (Opt_scrollTtyOutput, !state); |
4193 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4194 | else |
|
|
4195 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4196 | break; |
4169 | break; |
4197 | case 1011: /* scroll to bottom on key press */ |
4170 | case 1011: /* scroll to bottom on key press */ |
4198 | if (state) |
4171 | set_option (Opt_scrollTtyKeypress, state); |
4199 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4200 | else |
|
|
4201 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4202 | break; |
4172 | break; |
4203 | case 1047: /* secondary screen w/ clearing last */ |
4173 | case 1047: /* secondary screen w/ clearing last */ |
4204 | if (OPTION (Opt_secondaryScreen)) |
4174 | if (OPTION (Opt_secondaryScreen)) |
4205 | if (current_screen != PRIMARY) |
4175 | if (current_screen != PRIMARY) |
4206 | scr_erase_screen (2); |
4176 | scr_erase_screen (2); |
… | |
… | |
4344 | scr_color (Color_bg, Color_bg); |
4314 | scr_color (Color_bg, Color_bg); |
4345 | break; |
4315 | break; |
4346 | |
4316 | |
4347 | //case 50: // not variable spacing |
4317 | //case 50: // not variable spacing |
4348 | |
4318 | |
4349 | #ifndef NO_BRIGHTCOLOR |
4319 | #if ENABLE_FRILLS |
4350 | case 90: |
4320 | case 90: |
4351 | case 91: /* set bright fg color */ |
4321 | case 91: /* set bright fg color */ |
4352 | case 92: |
4322 | case 92: |
4353 | case 93: |
4323 | case 93: |
4354 | case 94: |
4324 | case 94: |
… | |
… | |
4399 | */ |
4369 | */ |
4400 | void |
4370 | void |
4401 | rxvt_term::tt_printf (const char *fmt,...) |
4371 | rxvt_term::tt_printf (const char *fmt,...) |
4402 | { |
4372 | { |
4403 | va_list arg_ptr; |
4373 | va_list arg_ptr; |
4404 | unsigned char buf[256]; |
4374 | char buf[256]; |
4405 | |
4375 | |
4406 | va_start (arg_ptr, fmt); |
4376 | va_start (arg_ptr, fmt); |
4407 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4377 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4408 | va_end (arg_ptr); |
4378 | va_end (arg_ptr); |
4409 | tt_write (buf, strlen (buf)); |
4379 | tt_write (buf, strlen (buf)); |
… | |
… | |
4414 | * or generated by us in response to a query ESC sequence. |
4384 | * or generated by us in response to a query ESC sequence. |
4415 | */ |
4385 | */ |
4416 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4386 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4417 | |
4387 | |
4418 | void |
4388 | void |
4419 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4389 | rxvt_term::tt_write (const char *data, unsigned int len) |
4420 | { |
4390 | { |
|
|
4391 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4392 | return; |
|
|
4393 | |
|
|
4394 | if (pty->pty < 0) |
|
|
4395 | return; |
|
|
4396 | |
4421 | if (v_buflen == 0) |
4397 | if (v_buflen == 0) |
4422 | { |
4398 | { |
4423 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4399 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4424 | |
4400 | |
4425 | if ((unsigned int)written == len) |
4401 | if ((unsigned int)written == len) |
4426 | return; |
4402 | return; |
4427 | |
4403 | |
4428 | data += written; |
4404 | data += written; |
4429 | len -= written; |
4405 | len -= written; |
4430 | } |
4406 | } |
4431 | |
4407 | |
4432 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4408 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4433 | |
4409 | |
4434 | memcpy (v_buffer + v_buflen, data, len); |
4410 | memcpy (v_buffer + v_buflen, data, len); |
4435 | v_buflen += len; |
4411 | v_buflen += len; |
4436 | |
4412 | |
4437 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4413 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4438 | } |
4414 | } |
4439 | |
4415 | |
4440 | void rxvt_term::pty_write () |
4416 | void rxvt_term::pty_write () |
4441 | { |
4417 | { |
4442 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4418 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4443 | |
4419 | |
4444 | if (written > 0) |
4420 | if (written > 0) |
4445 | { |
4421 | { |
4446 | v_buflen -= written; |
4422 | v_buflen -= written; |
4447 | |
4423 | |