… | |
… | |
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; |
… | |
… | |
301 | rxvt_term::lookup_key (XKeyEvent &ev) |
299 | rxvt_term::lookup_key (XKeyEvent &ev) |
302 | { |
300 | { |
303 | int ctrl, meta, shft, len; |
301 | int ctrl, meta, shft, len; |
304 | unsigned int newlen; |
302 | unsigned int newlen; |
305 | KeySym keysym; |
303 | KeySym keysym; |
306 | #ifdef DEBUG_CMD |
|
|
307 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
308 | #endif |
|
|
309 | int valid_keysym; |
304 | int valid_keysym; |
310 | unsigned char kbuf[KBUFSZ]; |
305 | char kbuf[KBUFSZ]; |
311 | |
306 | |
312 | /* |
307 | /* |
313 | * 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 |
314 | * escape sequence to toggle the Keypad. |
309 | * escape sequence to toggle the Keypad. |
315 | * |
310 | * |
… | |
… | |
333 | Status status_return; |
328 | Status status_return; |
334 | |
329 | |
335 | #if 0 |
330 | #if 0 |
336 | #ifdef X_HAVE_UTF8_STRING |
331 | #ifdef X_HAVE_UTF8_STRING |
337 | 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 |
338 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
333 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
339 | KBUFSZ, &keysym, &status_return); |
334 | KBUFSZ, &keysym, &status_return); |
340 | else |
335 | else |
341 | #endif |
336 | #endif |
342 | #endif |
337 | #endif |
343 | { |
338 | { |
… | |
… | |
380 | || status_return == XLookupBoth; |
375 | || status_return == XLookupBoth; |
381 | } |
376 | } |
382 | else |
377 | else |
383 | #endif |
378 | #endif |
384 | { |
379 | { |
385 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
380 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
386 | valid_keysym = keysym != NoSymbol; |
381 | valid_keysym = keysym != NoSymbol; |
387 | } |
382 | } |
388 | |
383 | |
389 | if (valid_keysym) |
384 | if (valid_keysym) |
390 | { |
385 | { |
… | |
… | |
442 | scr_move_to (0, 1); |
437 | scr_move_to (0, 1); |
443 | return; |
438 | return; |
444 | } |
439 | } |
445 | else if (keysym == XK_End) |
440 | else if (keysym == XK_End) |
446 | { |
441 | { |
447 | scr_move_to (1, 0); |
442 | scr_move_to (1, 1); |
448 | return; |
443 | return; |
449 | } |
444 | } |
450 | } |
445 | } |
451 | #endif |
446 | #endif |
452 | } |
447 | } |
… | |
… | |
463 | { |
458 | { |
464 | switch (keysym) |
459 | switch (keysym) |
465 | { |
460 | { |
466 | /* normal XTerm key bindings */ |
461 | /* normal XTerm key bindings */ |
467 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
468 | selection_request (ev.time, 0, 0); |
463 | selection_request (ev.time); |
469 | return; |
464 | return; |
470 | #if TODO |
465 | #if TODO |
471 | /* rxvt extras */ |
466 | /* rxvt extras */ |
472 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
473 | change_font (FONT_UP); |
468 | change_font (FONT_UP); |
… | |
… | |
854 | { |
849 | { |
855 | #ifdef META8_OPTION |
850 | #ifdef META8_OPTION |
856 | /* set 8-bit on */ |
851 | /* set 8-bit on */ |
857 | if (meta && (meta_char == 0x80)) |
852 | if (meta && (meta_char == 0x80)) |
858 | { |
853 | { |
859 | unsigned char *ch; |
854 | char *ch; |
860 | |
855 | |
861 | for (ch = kbuf; ch < kbuf + len; ch++) |
856 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | *ch |= 0x80; |
857 | *ch |= 0x80; |
863 | |
858 | |
864 | meta = 0; |
859 | meta = 0; |
865 | } |
860 | } |
866 | #endif |
861 | #endif |
867 | /* nil */ ; |
862 | /* nil */ ; |
868 | } |
863 | } |
869 | } |
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; |
870 | |
868 | |
871 | if (len <= 0) |
869 | if (len <= 0) |
872 | return; /* not mapped */ |
870 | return; /* not mapped */ |
873 | |
871 | |
874 | if (OPTION (Opt_scrollTtyKeypress)) |
872 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
897 | #ifdef META8_OPTION |
895 | #ifdef META8_OPTION |
898 | && meta_char == C0_ESC |
896 | && meta_char == C0_ESC |
899 | #endif |
897 | #endif |
900 | ) |
898 | ) |
901 | { |
899 | { |
902 | const unsigned char ch = C0_ESC; |
900 | const char ch = C0_ESC; |
903 | tt_write (&ch, 1); |
901 | tt_write (&ch, 1); |
904 | } |
902 | } |
905 | |
903 | |
906 | #if defined(DEBUG_CMD) |
|
|
907 | /* Display keyboard buffer contents */ |
|
|
908 | unsigned char *p; |
|
|
909 | int i; |
|
|
910 | |
|
|
911 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
912 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
913 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
914 | fprintf (stderr, "'\n"); |
|
|
915 | #endif /* DEBUG_CMD */ |
|
|
916 | tt_write (kbuf, (unsigned int)len); |
904 | tt_write (kbuf, (unsigned int)len); |
917 | } |
905 | } |
918 | /*}}} */ |
906 | /*}}} */ |
919 | |
907 | |
920 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
908 | #if defined (KEYSYM_RESOURCE) |
921 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
922 | /* attempt to `write' count to the input buffer */ |
|
|
923 | unsigned int |
909 | unsigned int |
924 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
910 | rxvt_term::cmd_write (const char *str, unsigned int count) |
925 | { |
911 | { |
926 | unsigned int n, s; |
912 | unsigned int n, s; |
927 | |
913 | |
928 | n = cmdbuf_ptr - cmdbuf_base; |
914 | n = cmdbuf_ptr - cmdbuf_base; |
929 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
915 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
966 | } |
952 | } |
967 | #endif |
953 | #endif |
968 | |
954 | |
969 | if (want_refresh) |
955 | if (want_refresh) |
970 | { |
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 | |
971 | scr_refresh (refresh_type); |
995 | scr_refresh (); |
972 | scrollbar_show (1); |
996 | scrollbar_show (1); |
973 | #ifdef USE_XIM |
997 | #ifdef USE_XIM |
974 | IMSendSpot (); |
998 | IMSendSpot (); |
975 | #endif |
999 | #endif |
976 | } |
1000 | } |
… | |
… | |
979 | } |
1003 | } |
980 | |
1004 | |
981 | void |
1005 | void |
982 | rxvt_term::check_cb (check_watcher &w) |
1006 | rxvt_term::check_cb (check_watcher &w) |
983 | { |
1007 | { |
984 | SET_R (this); |
1008 | make_current (); |
985 | SET_LOCALE (locale); |
|
|
986 | |
1009 | |
987 | display->flush (); |
1010 | display->flush (); |
988 | |
1011 | |
989 | if (want_refresh && !flush_ev.active) |
1012 | if (want_refresh && !flush_ev.active) |
990 | 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 |
991 | } |
1014 | } |
992 | |
1015 | |
993 | void |
1016 | void |
994 | rxvt_term::flush_cb (time_watcher &w) |
1017 | rxvt_term::flush_cb (time_watcher &w) |
995 | { |
1018 | { |
996 | SET_R (this); |
1019 | make_current (); |
997 | SET_LOCALE (locale); |
|
|
998 | |
1020 | |
999 | refresh_limit = 1; |
1021 | refresh_limit = 1; |
1000 | refresh_count = 0; |
1022 | refresh_count = 0; |
1001 | flush (); |
1023 | flush (); |
1002 | } |
1024 | } |
… | |
… | |
1006 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1028 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1007 | { |
1029 | { |
1008 | hidden_cursor = !hidden_cursor; |
1030 | hidden_cursor = !hidden_cursor; |
1009 | want_refresh = 1; |
1031 | want_refresh = 1; |
1010 | |
1032 | |
1011 | w.start (w.at + BLINK_INTERVAL); |
1033 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1012 | } |
1034 | } |
1013 | #endif |
1035 | #endif |
1014 | |
1036 | |
1015 | #ifdef TEXT_BLINK |
1037 | #ifdef TEXT_BLINK |
1016 | void |
1038 | void |
… | |
… | |
1030 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1052 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1031 | { |
1053 | { |
1032 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1054 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1033 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1055 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1034 | { |
1056 | { |
1035 | refresh_type |= SMOOTH_REFRESH; |
|
|
1036 | want_refresh = 1; |
1057 | want_refresh = 1; |
1037 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1058 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1038 | } |
1059 | } |
1039 | } |
1060 | } |
1040 | #endif |
1061 | #endif |
… | |
… | |
1044 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1065 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1045 | { |
1066 | { |
1046 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1067 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1047 | { |
1068 | { |
1048 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1069 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1049 | refresh_type |= SMOOTH_REFRESH; |
|
|
1050 | want_refresh = 1; |
1070 | want_refresh = 1; |
1051 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1052 | } |
1072 | } |
1053 | } |
1073 | } |
1054 | #endif |
1074 | #endif |
… | |
… | |
1059 | { |
1079 | { |
1060 | if (mouse_slip_wheel_speed == 0 |
1080 | if (mouse_slip_wheel_speed == 0 |
1061 | || 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) |
1062 | : scr_page (UP, mouse_slip_wheel_speed)) |
1082 | : scr_page (UP, mouse_slip_wheel_speed)) |
1063 | { |
1083 | { |
1064 | if (view_start == nsaved || |
1084 | if (view_start == top_row || view_start == 0) |
1065 | view_start == 0) |
|
|
1066 | mouse_slip_wheel_speed = 0; |
1085 | mouse_slip_wheel_speed = 0; |
1067 | |
1086 | |
1068 | refresh_type |= SMOOTH_REFRESH; |
|
|
1069 | want_refresh = 1; |
1087 | want_refresh = 1; |
1070 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1088 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | } |
1089 | } |
1072 | } |
1090 | } |
1073 | #endif |
1091 | #endif |
… | |
… | |
1095 | { |
1113 | { |
1096 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1114 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | |
1115 | |
1098 | if (CBUFSIZ == n) |
1116 | if (CBUFSIZ == n) |
1099 | { |
1117 | { |
1100 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1118 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1101 | n = 0; |
1119 | n = 0; |
1102 | } |
1120 | } |
1103 | |
1121 | |
1104 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1122 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | cmdbuf_ptr = cmdbuf_base; |
1123 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_endp = cmdbuf_ptr + n; |
1124 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | |
1125 | |
1108 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1126 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | |
1127 | |
1110 | if (r > 0) |
1128 | if (r > 0) |
1111 | { |
1129 | { |
1112 | cmdbuf_endp += r; |
1130 | cmdbuf_endp += r; |
1113 | return true; |
1131 | return true; |
… | |
… | |
1131 | } |
1149 | } |
1132 | |
1150 | |
1133 | void |
1151 | void |
1134 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1152 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1135 | { |
1153 | { |
1136 | SET_R (this); |
1154 | make_current (); |
1137 | SET_LOCALE (locale); |
|
|
1138 | |
1155 | |
1139 | if (revents & EVENT_READ) |
1156 | if (revents & EVENT_READ) |
1140 | // loop, but don't allow a single term to monopolize us |
1157 | // loop, but don't allow a single term to monopolize us |
1141 | while (pty_fill ()) |
1158 | while (pty_fill ()) |
1142 | if (cmd_parse ()) |
1159 | if (cmd_parse ()) |
… | |
… | |
1147 | } |
1164 | } |
1148 | |
1165 | |
1149 | void |
1166 | void |
1150 | rxvt_term::pointer_unblank () |
1167 | rxvt_term::pointer_unblank () |
1151 | { |
1168 | { |
1152 | XDefineCursor (display->display, vt, TermWin_cursor); |
1169 | XDefineCursor (xdisp, vt, TermWin_cursor); |
1153 | recolour_cursor (); |
1170 | recolour_cursor (); |
1154 | |
1171 | |
1155 | #ifdef POINTER_BLANK |
1172 | #ifdef POINTER_BLANK |
1156 | hidden_pointer = 0; |
1173 | hidden_pointer = 0; |
1157 | |
1174 | |
… | |
… | |
1162 | |
1179 | |
1163 | #ifdef POINTER_BLANK |
1180 | #ifdef POINTER_BLANK |
1164 | void |
1181 | void |
1165 | rxvt_term::pointer_blank () |
1182 | rxvt_term::pointer_blank () |
1166 | { |
1183 | { |
1167 | if (! OPTION (Opt_pointerBlank)) |
1184 | if (!OPTION (Opt_pointerBlank)) |
1168 | return; |
1185 | return; |
1169 | |
1186 | |
1170 | XDefineCursor (display->display, vt, display->blank_cursor); |
1187 | XDefineCursor (xdisp, vt, display->blank_cursor); |
1171 | XFlush (display->display); |
1188 | XFlush (xdisp); |
1172 | |
1189 | |
1173 | hidden_pointer = 1; |
1190 | hidden_pointer = 1; |
1174 | } |
1191 | } |
1175 | |
1192 | |
1176 | void |
1193 | void |
1177 | rxvt_term::pointer_cb (time_watcher &w) |
1194 | rxvt_term::pointer_cb (time_watcher &w) |
1178 | { |
1195 | { |
1179 | SET_R (this); |
1196 | make_current (); |
1180 | SET_LOCALE (locale); |
|
|
1181 | |
1197 | |
1182 | pointer_blank (); |
1198 | pointer_blank (); |
1183 | } |
1199 | } |
1184 | #endif |
1200 | #endif |
1185 | |
1201 | |
… | |
… | |
1250 | (32 + button_number + key_state), |
1266 | (32 + button_number + key_state), |
1251 | (32 + x + 1), |
1267 | (32 + x + 1), |
1252 | (32 + y + 1)); |
1268 | (32 + y + 1)); |
1253 | } |
1269 | } |
1254 | |
1270 | |
1255 | #ifdef USING_W11LIB |
|
|
1256 | void |
|
|
1257 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1258 | { |
|
|
1259 | rxvt_t *r = rxvt_get_r (); |
|
|
1260 | |
|
|
1261 | x_cb (*ev); |
|
|
1262 | } |
|
|
1263 | #endif |
|
|
1264 | |
|
|
1265 | /*{{{ process an X event */ |
1271 | /*{{{ process an X event */ |
1266 | void |
1272 | void |
1267 | rxvt_term::x_cb (XEvent &ev) |
1273 | rxvt_term::x_cb (XEvent &ev) |
1268 | { |
1274 | { |
1269 | dDisp; |
1275 | make_current (); |
1270 | |
1276 | |
1271 | SET_R (this); |
1277 | dLocal (Display *, xdisp); |
1272 | SET_LOCALE (locale); |
|
|
1273 | |
1278 | |
1274 | #if defined(CURSOR_BLINK) |
1279 | if (ev.xany.window == vt |
1275 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1280 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1276 | { |
1281 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1277 | if (hidden_cursor) |
1282 | return; |
1278 | { |
|
|
1279 | hidden_cursor = 0; |
|
|
1280 | want_refresh = 1; |
|
|
1281 | } |
|
|
1282 | |
1283 | |
1283 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1284 | // for XQueryPointer |
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; |
1285 | Window unused_root, unused_child; |
1302 | int unused_root_x, unused_root_y; |
1286 | int unused_root_x, unused_root_y; |
1303 | unsigned int unused_mask; |
1287 | unsigned int unused_mask; |
1304 | |
1288 | |
1305 | switch (ev.type) |
1289 | switch (ev.type) |
… | |
… | |
1312 | |
1296 | |
1313 | break; |
1297 | break; |
1314 | |
1298 | |
1315 | case KeyRelease: |
1299 | case KeyRelease: |
1316 | { |
1300 | { |
1317 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1301 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1318 | KeySym ks; |
1302 | KeySym keysym; |
1319 | |
1303 | |
1320 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1304 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1321 | #endif |
1305 | #endif |
1322 | |
1306 | |
1323 | #if ENABLE_FRILLS || ISO_14755 |
1307 | #if ENABLE_FRILLS || ISO_14755 |
1324 | // ISO 14755 support |
1308 | // ISO 14755 support |
1325 | if (iso14755buf) |
1309 | if (iso14755buf) |
… | |
… | |
1330 | # endif |
1314 | # endif |
1331 | # if ISO_14755 |
1315 | # if ISO_14755 |
1332 | // iso14755 part 5.2 handling: release time |
1316 | // iso14755 part 5.2 handling: release time |
1333 | // first: controls |
1317 | // first: controls |
1334 | if ((ev.xkey.state & ControlMask) |
1318 | if ((ev.xkey.state & ControlMask) |
1335 | && ((ks >= 0x40 && ks <= 0x5f) |
1319 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1336 | || (ks >= 0x61 && ks <= 0x7f))) |
1320 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1337 | { |
1321 | { |
1338 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1322 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1339 | commit_iso14755 (); |
1323 | commit_iso14755 (); |
1340 | return; // case-break; |
1324 | goto skip_switch; |
1341 | } |
1325 | } |
1342 | |
1326 | |
1343 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1327 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1344 | if (i[0] == ks) |
1328 | if (i[0] == keysym) |
1345 | { |
1329 | { |
1346 | iso14755buf = ISO_14755_51 | i[1]; |
1330 | iso14755buf = ISO_14755_51 | i[1]; |
1347 | commit_iso14755 (); |
1331 | commit_iso14755 (); |
1348 | return; // case-break; |
1332 | goto skip_switch; |
1349 | } |
1333 | } |
1350 | |
1334 | |
1351 | scr_bell (); |
1335 | scr_bell (); |
1352 | # endif |
1336 | # endif |
1353 | iso14755buf = 0; |
1337 | iso14755buf = 0; |
… | |
… | |
1372 | else |
1356 | else |
1373 | iso14755buf = 0; |
1357 | iso14755buf = 0; |
1374 | } |
1358 | } |
1375 | #endif |
1359 | #endif |
1376 | |
1360 | |
|
|
1361 | if (ev.xany.window == vt |
|
|
1362 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1363 | break; |
|
|
1364 | |
1377 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1365 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1378 | if (!(ev.xkey.state & ControlMask)) |
1366 | if (!(ev.xkey.state & ControlMask)) |
1379 | slip_wheel_ev.stop (); |
1367 | slip_wheel_ev.stop (); |
1380 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1368 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1381 | mouse_slip_wheel_speed = 0; |
1369 | mouse_slip_wheel_speed = 0; |
1382 | #endif |
1370 | #endif |
1383 | break; |
1371 | break; |
1384 | } |
1372 | } |
1385 | |
1373 | |
… | |
… | |
1391 | button_release (ev.xbutton); |
1379 | button_release (ev.xbutton); |
1392 | break; |
1380 | break; |
1393 | |
1381 | |
1394 | case ClientMessage: |
1382 | case ClientMessage: |
1395 | if (ev.xclient.format == 32 |
1383 | if (ev.xclient.format == 32 |
1396 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1384 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1397 | { |
1385 | { |
|
|
1386 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1387 | { |
|
|
1388 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1389 | { |
1398 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1390 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1391 | { |
|
|
1392 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1399 | destroy (); |
1393 | destroy (); |
|
|
1394 | } |
1400 | #if ENABLE_EWMH |
1395 | #if ENABLE_EWMH |
1401 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1396 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1402 | XSendEvent (disp, ev.xclient.window = display->root, |
1397 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1403 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1398 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1404 | &ev); |
1399 | &ev); |
|
|
1400 | #endif |
|
|
1401 | } |
|
|
1402 | } |
|
|
1403 | #if ENABLE_XEMBED |
|
|
1404 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1405 | { |
|
|
1406 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1407 | focus_in (); |
|
|
1408 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1409 | focus_out (); |
|
|
1410 | } |
1405 | #endif |
1411 | #endif |
1406 | } |
1412 | } |
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; |
1413 | break; |
1443 | |
1414 | |
1444 | case MappingNotify: |
1415 | case MappingNotify: |
1445 | XRefreshKeyboardMapping (&ev.xmapping); |
1416 | XRefreshKeyboardMapping (&ev.xmapping); |
1446 | break; |
1417 | break; |
… | |
… | |
1479 | break; |
1450 | break; |
1480 | |
1451 | |
1481 | case ConfigureNotify: |
1452 | case ConfigureNotify: |
1482 | if (ev.xconfigure.window == parent[0]) |
1453 | if (ev.xconfigure.window == parent[0]) |
1483 | { |
1454 | { |
1484 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1455 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1485 | ; |
1456 | ; |
1486 | |
1457 | |
1487 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1458 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1488 | { |
1459 | { |
1489 | seen_resize = 1; |
1460 | seen_resize = 1; |
1490 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1461 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1491 | } |
1462 | } |
1492 | |
1463 | |
|
|
1464 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1465 | |
1493 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1466 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1494 | if (OPTION (Opt_transparent)) |
1467 | if (OPTION (Opt_transparent)) |
1495 | check_our_parents (); |
1468 | check_our_parents (); |
1496 | #endif |
1469 | #endif |
1497 | } |
1470 | } |
1498 | break; |
1471 | break; |
1499 | |
1472 | |
1500 | case PropertyNotify: |
1473 | case PropertyNotify: |
|
|
1474 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1501 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1475 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1502 | && ev.xproperty.state == PropertyNewValue) |
1476 | && ev.xproperty.state == PropertyNewValue) |
1503 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1477 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1504 | |
1478 | |
1505 | break; |
1479 | break; |
1506 | |
1480 | |
1507 | case SelectionClear: |
1481 | case SelectionClear: |
1508 | selection_clear (); |
1482 | selection_clear (); |
… | |
… | |
1513 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1487 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1514 | break; |
1488 | break; |
1515 | |
1489 | |
1516 | case SelectionRequest: |
1490 | case SelectionRequest: |
1517 | selection_send (ev.xselectionrequest); |
1491 | selection_send (ev.xselectionrequest); |
|
|
1492 | break; |
|
|
1493 | |
|
|
1494 | case MapNotify: |
|
|
1495 | mapped = 1; |
|
|
1496 | #ifdef TEXT_BLINK |
|
|
1497 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1498 | #endif |
|
|
1499 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1518 | break; |
1500 | break; |
1519 | |
1501 | |
1520 | case UnmapNotify: |
1502 | case UnmapNotify: |
1521 | mapped = 0; |
1503 | mapped = 0; |
1522 | #ifdef TEXT_BLINK |
1504 | #ifdef TEXT_BLINK |
1523 | text_blink_ev.stop (); |
1505 | text_blink_ev.stop (); |
1524 | #endif |
1506 | #endif |
1525 | break; |
1507 | 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; |
1508 | break; |
1533 | |
1509 | |
1534 | #ifdef TRANSPARENT |
1510 | #ifdef TRANSPARENT |
1535 | case ReparentNotify: |
1511 | case ReparentNotify: |
1536 | rootwin_cb (ev); |
1512 | rootwin_cb (ev); |
… | |
… | |
1542 | if (ev.xany.window == vt) |
1518 | if (ev.xany.window == vt) |
1543 | { |
1519 | { |
1544 | do |
1520 | do |
1545 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1521 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1546 | ev.xexpose.width, ev.xexpose.height, False); |
1522 | ev.xexpose.width, ev.xexpose.height, False); |
1547 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1523 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1548 | |
1524 | |
1549 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1525 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1550 | |
1526 | |
1551 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1527 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1552 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1528 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1553 | ev.xexpose.width, ev.xexpose.height, False); |
1529 | ev.xexpose.width, ev.xexpose.height, False); |
1554 | |
1530 | |
1555 | scr_refresh (refresh_type); |
1531 | want_refresh = 1; |
1556 | } |
1532 | } |
1557 | else |
1533 | else |
1558 | { |
1534 | { |
1559 | XEvent unused_event; |
1535 | XEvent unused_event; |
1560 | |
1536 | |
1561 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1537 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1562 | ; |
1538 | ; |
1563 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1539 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1564 | ; |
1540 | ; |
1565 | |
1541 | |
1566 | if (isScrollbarWindow (ev.xany.window)) |
1542 | if (isScrollbarWindow (ev.xany.window)) |
1567 | { |
1543 | { |
1568 | scrollBar.setIdle (); |
1544 | scrollBar.setIdle (); |
1569 | scrollbar_show (0); |
1545 | scrollbar_show (0); |
1570 | } |
1546 | } |
1571 | #ifdef MENUBAR |
|
|
1572 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1573 | menubar_expose (); |
|
|
1574 | #endif |
|
|
1575 | |
1547 | |
1576 | #ifdef TRANSPARENT |
1548 | #ifdef TRANSPARENT |
1577 | if (am_transparent && ev.xany.window == parent[0]) |
1549 | if (am_transparent && ev.xany.window == parent[0]) |
1578 | XClearWindow (disp, ev.xany.window); |
1550 | XClearWindow (xdisp, ev.xany.window); |
1579 | #endif |
1551 | #endif |
1580 | } |
1552 | } |
1581 | break; |
1553 | break; |
1582 | |
1554 | |
1583 | case MotionNotify: |
1555 | case MotionNotify: |
1584 | #ifdef POINTER_BLANK |
1556 | #ifdef POINTER_BLANK |
1585 | if (hidden_pointer) |
1557 | if (hidden_pointer) |
1586 | pointer_unblank (); |
1558 | pointer_unblank (); |
1587 | #endif |
1559 | #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) |
1560 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1596 | break; |
1561 | break; |
1597 | |
1562 | |
1598 | if (ev.xany.window == vt) |
1563 | if (ev.xany.window == vt) |
1599 | { |
1564 | { |
|
|
1565 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1566 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1567 | ; // nop |
1600 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1568 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1601 | { |
1569 | { |
1602 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1570 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1603 | ; |
1571 | ; |
1604 | |
1572 | |
1605 | XQueryPointer (disp, vt, |
1573 | XQueryPointer (xdisp, vt, |
1606 | &unused_root, &unused_child, |
1574 | &unused_root, &unused_child, |
1607 | &unused_root_x, &unused_root_y, |
1575 | &unused_root_x, &unused_root_y, |
1608 | &ev.xbutton.x, &ev.xbutton.y, |
1576 | &ev.xbutton.x, &ev.xbutton.y, |
1609 | &ev.xbutton.state); |
1577 | &ev.xbutton.state); |
1610 | #ifdef MOUSE_THRESHOLD |
1578 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1674 | #endif |
1642 | #endif |
1675 | } |
1643 | } |
1676 | } |
1644 | } |
1677 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1645 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1678 | { |
1646 | { |
1679 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1647 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1680 | MotionNotify, &ev)) |
1648 | MotionNotify, &ev)) |
1681 | ; |
1649 | ; |
1682 | |
1650 | |
1683 | XQueryPointer (disp, scrollBar.win, |
1651 | XQueryPointer (xdisp, scrollBar.win, |
1684 | &unused_root, &unused_child, |
1652 | &unused_root, &unused_child, |
1685 | &unused_root_x, &unused_root_y, |
1653 | &unused_root_x, &unused_root_y, |
1686 | &ev.xbutton.x, &ev.xbutton.y, |
1654 | &ev.xbutton.x, &ev.xbutton.y, |
1687 | &unused_mask); |
1655 | &unused_mask); |
1688 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1656 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1689 | scrollbar_size ()); |
1657 | scrollbar_size ()); |
1690 | scr_refresh (refresh_type); |
1658 | want_refresh = 1; |
1691 | refresh_limit = 0; |
1659 | refresh_limit = 0; |
1692 | scrollbar_show (1); |
1660 | scrollbar_show (1); |
1693 | } |
1661 | } |
1694 | break; |
1662 | break; |
1695 | } |
1663 | } |
|
|
1664 | |
|
|
1665 | skip_switch: ; |
|
|
1666 | |
|
|
1667 | #if defined(CURSOR_BLINK) |
|
|
1668 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1669 | { |
|
|
1670 | if (hidden_cursor) |
|
|
1671 | { |
|
|
1672 | hidden_cursor = 0; |
|
|
1673 | want_refresh = 1; |
|
|
1674 | } |
|
|
1675 | |
|
|
1676 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1677 | } |
|
|
1678 | #endif |
|
|
1679 | |
|
|
1680 | #if defined(POINTER_BLANK) |
|
|
1681 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1682 | { |
|
|
1683 | if (ev.type == MotionNotify |
|
|
1684 | || ev.type == ButtonPress |
|
|
1685 | || ev.type == ButtonRelease) |
|
|
1686 | if (hidden_pointer) |
|
|
1687 | pointer_unblank (); |
|
|
1688 | |
|
|
1689 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1690 | pointer_blank (); |
|
|
1691 | } |
|
|
1692 | #endif |
1696 | } |
1693 | } |
1697 | |
1694 | |
1698 | void |
1695 | void |
1699 | rxvt_term::focus_in () |
1696 | rxvt_term::focus_in () |
1700 | { |
1697 | { |
1701 | if (!focus) |
1698 | if (!focus) |
1702 | { |
1699 | { |
1703 | focus = 1; |
1700 | focus = 1; |
1704 | want_refresh = 1; |
1701 | want_refresh = 1; |
1705 | |
1702 | |
1706 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1703 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1707 | |
1704 | |
1708 | #if USE_XIM |
1705 | #if USE_XIM |
1709 | if (Input_Context != NULL) |
1706 | if (Input_Context != NULL) |
1710 | { |
1707 | { |
1711 | IMSetStatusPosition (); |
1708 | IMSetStatusPosition (); |
1712 | XSetICFocus (Input_Context); |
1709 | XSetICFocus (Input_Context); |
1713 | } |
1710 | } |
1714 | #endif |
1711 | #endif |
1715 | #if CURSOR_BLINK |
1712 | #if CURSOR_BLINK |
1716 | if (OPTION (Opt_cursorBlink)) |
1713 | if (OPTION (Opt_cursorBlink)) |
1717 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1714 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1718 | #endif |
1715 | #endif |
1719 | #if OFF_FOCUS_FADING |
1716 | #if OFF_FOCUS_FADING |
1720 | if (rs[Rs_fade]) |
1717 | if (rs[Rs_fade]) |
1721 | { |
1718 | { |
1722 | pix_colors = pix_colors_focused; |
1719 | pix_colors = pix_colors_focused; |
… | |
… | |
1732 | if (focus) |
1729 | if (focus) |
1733 | { |
1730 | { |
1734 | focus = 0; |
1731 | focus = 0; |
1735 | want_refresh = 1; |
1732 | want_refresh = 1; |
1736 | |
1733 | |
1737 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1734 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1738 | |
1735 | |
1739 | #if ENABLE_FRILLS || ISO_14755 |
1736 | #if ENABLE_FRILLS || ISO_14755 |
1740 | if (iso14755buf) |
1737 | if (iso14755buf) |
1741 | { |
1738 | { |
1742 | iso14755buf = 0; |
1739 | iso14755buf = 0; |
… | |
… | |
1766 | |
1763 | |
1767 | #if TRANSPARENT |
1764 | #if TRANSPARENT |
1768 | void |
1765 | void |
1769 | rxvt_term::rootwin_cb (XEvent &ev) |
1766 | rxvt_term::rootwin_cb (XEvent &ev) |
1770 | { |
1767 | { |
1771 | SET_R (this); |
1768 | make_current (); |
1772 | SET_LOCALE (locale); |
|
|
1773 | |
1769 | |
1774 | switch (ev.type) |
1770 | switch (ev.type) |
1775 | { |
1771 | { |
1776 | case PropertyNotify: |
1772 | case PropertyNotify: |
1777 | /* |
1773 | /* |
… | |
… | |
1804 | /* |
1800 | /* |
1805 | * VT window processing of button press |
1801 | * VT window processing of button press |
1806 | */ |
1802 | */ |
1807 | if (ev.window == vt) |
1803 | if (ev.window == vt) |
1808 | { |
1804 | { |
|
|
1805 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1806 | return; |
|
|
1807 | |
1809 | #if ISO_14755 |
1808 | #if ISO_14755 |
1810 | // 5.4 |
1809 | // 5.4 |
1811 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1812 | { |
1811 | { |
1813 | iso14755_54 (ev.x, ev.y); |
1812 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1825 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1824 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1826 | if (ev.button == MEvent.button && clickintime) |
1825 | if (ev.button == MEvent.button && clickintime) |
1827 | { |
1826 | { |
1828 | /* same button, within alloted time */ |
1827 | /* same button, within alloted time */ |
1829 | MEvent.clicks++; |
1828 | MEvent.clicks++; |
|
|
1829 | |
1830 | if (MEvent.clicks > 1) |
1830 | if (MEvent.clicks > 1) |
1831 | { |
1831 | { |
1832 | /* only report double clicks */ |
1832 | /* only report double clicks */ |
1833 | MEvent.clicks = 2; |
1833 | MEvent.clicks = 2; |
1834 | mouse_report (ev); |
1834 | mouse_report (ev); |
… | |
… | |
1854 | else |
1854 | else |
1855 | { |
1855 | { |
1856 | if (ev.button != MEvent.button) |
1856 | if (ev.button != MEvent.button) |
1857 | MEvent.clicks = 0; |
1857 | MEvent.clicks = 0; |
1858 | |
1858 | |
1859 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
|
|
1860 | switch (ev.button) |
1859 | switch (ev.button) |
1861 | { |
1860 | { |
1862 | case Button1: |
1861 | case Button1: |
1863 | /* allow meta + click to select rectangular areas */ |
1862 | /* allow meta + click to select rectangular areas */ |
1864 | /* should be done in screen.C */ |
1863 | /* should be done in screen.C */ |
1865 | #if ENABLE_FRILLS |
1864 | #if ENABLE_FRILLS |
1866 | selection.rect = !!(ev.state & ModMetaMask); |
1865 | selection.rect = !!(ev.state & ModMetaMask); |
1867 | #else |
1866 | #else |
1868 | selection.rect = false; |
1867 | selection.rect = false; |
1869 | #endif |
1868 | #endif |
1870 | |
1869 | |
1871 | /* allow shift+left click to extend selection */ |
1870 | /* allow shift+left click to extend selection */ |
1872 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1871 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1873 | { |
1872 | { |
1874 | if (MEvent.button == Button1 && clickintime) |
1873 | if (MEvent.button == Button1 && clickintime) |
1875 | selection_rotate (ev.x, ev.y); |
1874 | selection_rotate (ev.x, ev.y); |
1876 | else |
1875 | else |
1877 | selection_extend (ev.x, ev.y, 1); |
1876 | selection_extend (ev.x, ev.y, 1); |
1878 | } |
1877 | } |
1879 | else |
1878 | else |
1880 | { |
1879 | { |
1881 | if (MEvent.button == Button1 && clickintime) |
1880 | if (MEvent.button == Button1 && clickintime) |
1882 | MEvent.clicks++; |
1881 | MEvent.clicks++; |
1883 | else |
1882 | else |
1884 | MEvent.clicks = 1; |
1883 | MEvent.clicks = 1; |
1885 | |
1884 | |
1886 | selection_click (MEvent.clicks, ev.x, ev.y); |
1885 | selection_click (MEvent.clicks, ev.x, ev.y); |
1887 | } |
1886 | } |
1888 | |
1887 | |
1889 | MEvent.button = Button1; |
1888 | MEvent.button = Button1; |
1890 | break; |
1889 | break; |
1891 | |
1890 | |
1892 | case Button3: |
1891 | case Button3: |
1893 | if (MEvent.button == Button3 && clickintime) |
1892 | if (MEvent.button == Button3 && clickintime) |
1894 | selection_rotate (ev.x, ev.y); |
1893 | selection_rotate (ev.x, ev.y); |
1895 | else |
1894 | else |
1896 | selection_extend (ev.x, ev.y, 1); |
1895 | selection_extend (ev.x, ev.y, 1); |
1897 | |
1896 | |
1898 | MEvent.button = Button3; |
1897 | MEvent.button = Button3; |
1899 | break; |
1898 | break; |
1900 | } |
1899 | } |
1901 | } |
1900 | } |
1902 | |
1901 | |
1903 | MEvent.time = ev.time; |
1902 | MEvent.time = ev.time; |
1904 | return; |
1903 | return; |
1905 | } |
1904 | } |
1906 | |
1905 | |
… | |
… | |
2042 | } |
2041 | } |
2043 | |
2042 | |
2044 | break; |
2043 | break; |
2045 | } |
2044 | } |
2046 | } |
2045 | } |
|
|
2046 | |
2047 | return; |
2047 | return; |
2048 | } |
2048 | } |
2049 | #if MENUBAR |
|
|
2050 | /* |
|
|
2051 | * Menubar window processing of button press |
|
|
2052 | */ |
|
|
2053 | if (isMenuBarWindow (ev.window)) |
|
|
2054 | menubar_control (ev); |
|
|
2055 | #endif |
|
|
2056 | } |
2049 | } |
2057 | |
2050 | |
2058 | void |
2051 | void |
2059 | rxvt_term::button_release (XButtonEvent &ev) |
2052 | rxvt_term::button_release (XButtonEvent &ev) |
2060 | { |
2053 | { |
… | |
… | |
2066 | |
2059 | |
2067 | if (scrollbar_isUpDn ()) |
2060 | if (scrollbar_isUpDn ()) |
2068 | { |
2061 | { |
2069 | scrollBar.setIdle (); |
2062 | scrollBar.setIdle (); |
2070 | scrollbar_show (0); |
2063 | scrollbar_show (0); |
2071 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2072 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2073 | #endif |
|
|
2074 | } |
2064 | } |
2075 | |
2065 | |
2076 | #ifdef SELECTION_SCROLLING |
2066 | #ifdef SELECTION_SCROLLING |
2077 | if (sel_scroll_ev.active) |
2067 | if (sel_scroll_ev.active) |
2078 | sel_scroll_ev.stop(); |
2068 | sel_scroll_ev.stop(); |
2079 | #endif |
2069 | #endif |
2080 | |
2070 | |
2081 | if (ev.window == vt) |
2071 | if (ev.window == vt) |
2082 | { |
2072 | { |
|
|
2073 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2074 | return; |
|
|
2075 | |
2083 | #if ISO_14755 |
2076 | #if ISO_14755 |
2084 | // 5.4 |
2077 | // 5.4 |
2085 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2078 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2086 | return; |
2079 | return; |
2087 | #endif |
2080 | #endif |
|
|
2081 | |
2088 | if (reportmode) |
2082 | if (reportmode) |
2089 | { |
2083 | { |
2090 | /* mouse report from vt window */ |
2084 | /* mouse report from vt window */ |
2091 | /* don't report release of wheel "buttons" */ |
2085 | /* don't report release of wheel "buttons" */ |
2092 | if (ev.button >= 4) |
2086 | if (ev.button >= 4) |
… | |
… | |
2122 | { |
2116 | { |
2123 | case Button1: |
2117 | case Button1: |
2124 | case Button3: |
2118 | case Button3: |
2125 | selection_make (ev.time); |
2119 | selection_make (ev.time); |
2126 | break; |
2120 | break; |
|
|
2121 | |
2127 | case Button2: |
2122 | case Button2: |
2128 | selection_request (ev.time, ev.x, ev.y); |
2123 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2124 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2129 | break; |
2125 | break; |
|
|
2126 | |
2130 | #ifdef MOUSE_WHEEL |
2127 | #ifdef MOUSE_WHEEL |
2131 | case Button4: |
2128 | case Button4: |
2132 | case Button5: |
2129 | case Button5: |
2133 | { |
2130 | { |
2134 | int i; |
2131 | int i; |
… | |
… | |
2156 | slip_wheel_ev.start (); |
2153 | slip_wheel_ev.start (); |
2157 | } |
2154 | } |
2158 | else |
2155 | else |
2159 | { |
2156 | { |
2160 | # endif |
2157 | # endif |
2161 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2162 | scr_page (v, i); |
2158 | scr_page (v, i); |
2163 | scr_refresh (SMOOTH_REFRESH); |
|
|
2164 | scrollbar_show (1); |
2159 | 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 |
2160 | # ifdef MOUSE_SLIP_WHEELING |
2174 | } |
2161 | } |
2175 | #endif |
2162 | # endif |
2176 | } |
2163 | } |
2177 | break; |
2164 | break; |
2178 | #endif |
2165 | #endif |
2179 | } |
2166 | } |
2180 | } |
2167 | } |
2181 | #ifdef MENUBAR |
|
|
2182 | else if (isMenuBarWindow (ev.window)) |
|
|
2183 | menubar_control (ev); |
|
|
2184 | #endif |
|
|
2185 | } |
2168 | } |
2186 | |
2169 | |
2187 | #ifdef TRANSPARENT |
2170 | #ifdef TRANSPARENT |
2188 | #if TINTING |
2171 | #if TINTING |
2189 | /* taken from aterm-0.4.2 */ |
2172 | /* taken from aterm-0.4.2 */ |
2190 | |
2173 | |
2191 | typedef uint32_t RUINT32T; |
2174 | typedef uint32_t RUINT32T; |
2192 | |
2175 | |
2193 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
2176 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
2194 | { |
2177 | { |
2195 | int sh_r, sh_g, sh_b; |
2178 | int sh_r, sh_g, sh_b; |
2196 | RUINT32T mask_r, mask_g, mask_b; |
2179 | RUINT32T mask_r, mask_g, mask_b; |
2197 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2180 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2198 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2181 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2199 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2182 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2200 | int i; |
2183 | int i; |
2201 | |
2184 | |
2202 | Visual *visual = display->visual; |
2185 | Visual *visual = term->visual; |
2203 | |
2186 | |
2204 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2187 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2205 | |
2188 | |
2206 | /* for convenience */ |
2189 | /* for convenience */ |
2207 | mask_r = visual->red_mask; |
2190 | mask_r = visual->red_mask; |
… | |
… | |
2428 | Atom atype; |
2411 | Atom atype; |
2429 | unsigned char *prop = NULL; |
2412 | unsigned char *prop = NULL; |
2430 | Window root, oldp, *list; |
2413 | Window root, oldp, *list; |
2431 | Pixmap rootpixmap = None; |
2414 | Pixmap rootpixmap = None; |
2432 | XWindowAttributes wattr, wrootattr; |
2415 | XWindowAttributes wattr, wrootattr; |
2433 | dDisp; |
|
|
2434 | |
2416 | |
2435 | pchanged = 0; |
2417 | pchanged = 0; |
2436 | |
2418 | |
2437 | if (!OPTION (Opt_transparent)) |
2419 | if (!OPTION (Opt_transparent)) |
2438 | return pchanged; /* Don't try any more */ |
2420 | return pchanged; /* Don't try any more */ |
2439 | |
2421 | |
2440 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2422 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
2441 | rootdepth = wrootattr.depth; |
2423 | rootdepth = wrootattr.depth; |
2442 | |
2424 | |
2443 | XGetWindowAttributes (disp, parent[0], &wattr); |
2425 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
2444 | |
2426 | |
2445 | if (rootdepth != wattr.depth) |
2427 | if (rootdepth != wattr.depth) |
2446 | { |
2428 | { |
2447 | if (am_transparent) |
2429 | if (am_transparent) |
2448 | { |
2430 | { |
2449 | pchanged = 1; |
2431 | pchanged = 1; |
2450 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2432 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2451 | am_transparent = am_pixmap_trans = 0; |
2433 | am_transparent = am_pixmap_trans = 0; |
2452 | } |
2434 | } |
2453 | |
2435 | |
2454 | return pchanged; /* Don't try any more */ |
2436 | return pchanged; /* Don't try any more */ |
2455 | } |
2437 | } |
2456 | |
2438 | |
2457 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2439 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2458 | XSync (disp, False); |
2440 | XSync (xdisp, False); |
2459 | |
2441 | |
2460 | /* |
2442 | /* |
2461 | * Make the frame window set by the window manager have |
2443 | * Make the frame window set by the window manager have |
2462 | * the root background. Some window managers put multiple nested frame |
2444 | * the root background. Some window managers put multiple nested frame |
2463 | * windows for each client, so we have to take care about that. |
2445 | * windows for each client, so we have to take care about that. |
2464 | */ |
2446 | */ |
2465 | i = (xa[XA_XROOTPMAP_ID] |
2447 | i = (xa[XA_XROOTPMAP_ID] |
2466 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2448 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
2467 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2449 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2468 | &nitems, &bytes_after, &prop) == Success); |
2450 | &nitems, &bytes_after, &prop) == Success); |
2469 | |
2451 | |
2470 | if (!i || prop == NULL) |
2452 | if (!i || prop == NULL) |
2471 | i = (xa[XA_ESETROOT_PMAP_ID] |
2453 | i = (xa[XA_ESETROOT_PMAP_ID] |
2472 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2454 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2473 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2455 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2474 | &nitems, &bytes_after, &prop) == Success); |
2456 | &nitems, &bytes_after, &prop) == Success); |
2475 | |
2457 | |
2476 | if (!i || prop == NULL |
2458 | if (!i || prop == NULL |
2477 | #if TINTING |
2459 | #if TINTING |
… | |
… | |
2496 | Window cr; |
2478 | Window cr; |
2497 | XImage *image; |
2479 | XImage *image; |
2498 | GC gc; |
2480 | GC gc; |
2499 | XGCValues gcvalue; |
2481 | XGCValues gcvalue; |
2500 | |
2482 | |
2501 | XTranslateCoordinates (disp, parent[0], display->root, |
2483 | XTranslateCoordinates (xdisp, parent[0], display->root, |
2502 | 0, 0, &sx, &sy, &cr); |
2484 | 0, 0, &sx, &sy, &cr); |
2503 | nw = (unsigned int)szHint.width; |
2485 | nw = (unsigned int)szHint.width; |
2504 | nh = (unsigned int)szHint.height; |
2486 | nh = (unsigned int)szHint.height; |
2505 | nx = ny = 0; |
2487 | nx = ny = 0; |
2506 | |
2488 | |
… | |
… | |
2519 | } |
2501 | } |
2520 | |
2502 | |
2521 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2503 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2522 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2504 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2523 | |
2505 | |
2524 | XSync (disp, False); |
2506 | XSync (xdisp, False); |
2525 | allowedxerror = -1; |
2507 | allowedxerror = -1; |
2526 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2508 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2527 | |
2509 | |
2528 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2510 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2529 | /* XXX: may need a delay here? */ |
2511 | /* XXX: may need a delay here? */ |
2530 | allowedxerror = 0; |
2512 | allowedxerror = 0; |
2531 | |
2513 | |
… | |
… | |
2534 | if (am_transparent && am_pixmap_trans) |
2516 | if (am_transparent && am_pixmap_trans) |
2535 | { |
2517 | { |
2536 | pchanged = 1; |
2518 | pchanged = 1; |
2537 | if (pixmap != None) |
2519 | if (pixmap != None) |
2538 | { |
2520 | { |
2539 | XFreePixmap (disp, pixmap); |
2521 | XFreePixmap (xdisp, pixmap); |
2540 | pixmap = None; |
2522 | pixmap = None; |
2541 | } |
2523 | } |
2542 | } |
2524 | } |
2543 | |
2525 | |
2544 | am_pixmap_trans = 0; |
2526 | am_pixmap_trans = 0; |
2545 | } |
2527 | } |
2546 | else |
2528 | else |
2547 | { |
2529 | { |
2548 | if (pixmap != None) |
2530 | if (pixmap != None) |
2549 | XFreePixmap (disp, pixmap); |
2531 | XFreePixmap (xdisp, pixmap); |
2550 | |
2532 | |
2551 | #if TINTING |
2533 | #if TINTING |
2552 | if (ISSET_PIXCOLOR (Color_tint)) |
2534 | if (ISSET_PIXCOLOR (Color_tint)) |
2553 | { |
2535 | { |
2554 | unsigned short rm, gm, bm; |
2536 | unsigned short rm, gm, bm; |
2555 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2537 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2556 | |
2538 | |
2557 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
2539 | pix_colors_focused[Color_tint].get (this, rm, gm, bm); |
2558 | |
2540 | |
2559 | ShadeXImage (display, image, shade, rm, gm, bm); |
2541 | ShadeXImage (this, image, shade, rm, gm, bm); |
2560 | } |
2542 | } |
2561 | #endif |
2543 | #endif |
2562 | |
2544 | |
2563 | pixmap = XCreatePixmap (disp, vt, |
2545 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
2564 | szHint.width, szHint.height, image->depth); |
|
|
2565 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
2546 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
2566 | XPutImage (disp, pixmap, gc, image, 0, 0, |
2547 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
2567 | nx, ny, image->width, image->height); |
2548 | nx, ny, image->width, image->height); |
2568 | XFreeGC (disp, gc); |
2549 | XFreeGC (xdisp, gc); |
2569 | XDestroyImage (image); |
2550 | XDestroyImage (image); |
2570 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
2551 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
2571 | XClearWindow (disp, parent[0]); |
2552 | XClearWindow (xdisp, parent[0]); |
2572 | |
2553 | |
2573 | if (!am_transparent || !am_pixmap_trans) |
2554 | if (!am_transparent || !am_pixmap_trans) |
2574 | pchanged = 1; |
2555 | pchanged = 1; |
2575 | |
2556 | |
2576 | am_transparent = am_pixmap_trans = 1; |
2557 | am_transparent = am_pixmap_trans = 1; |
2577 | } |
2558 | } |
2578 | } |
2559 | } |
2579 | |
2560 | |
2580 | if (am_pixmap_trans) |
2561 | if (am_pixmap_trans) |
2581 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2562 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2582 | else |
2563 | else |
2583 | { |
2564 | { |
2584 | unsigned int n; |
2565 | unsigned int n; |
2585 | /* |
2566 | /* |
2586 | * InheritPixmap transparency |
2567 | * InheritPixmap transparency |
2587 | */ |
2568 | */ |
2588 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2569 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2589 | { |
2570 | { |
2590 | oldp = parent[i]; |
2571 | oldp = parent[i]; |
2591 | XQueryTree (disp, parent[i - 1], &root, |
2572 | XQueryTree (xdisp, parent[i - 1], &root, |
2592 | &parent[i], &list, &n); |
2573 | &parent[i], &list, &n); |
2593 | XFree (list); |
2574 | XFree (list); |
2594 | |
2575 | |
2595 | if (parent[i] == display->root) |
2576 | if (parent[i] == display->root) |
2596 | { |
2577 | { |
… | |
… | |
2608 | |
2589 | |
2609 | if (pchanged) |
2590 | if (pchanged) |
2610 | { |
2591 | { |
2611 | for (; n < (unsigned int)i; n++) |
2592 | for (; n < (unsigned int)i; n++) |
2612 | { |
2593 | { |
2613 | XGetWindowAttributes (disp, parent[n], &wattr); |
2594 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
2614 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2595 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2615 | { |
2596 | { |
2616 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2597 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2617 | break; |
2598 | break; |
2618 | } |
2599 | } |
2619 | } |
2600 | } |
2620 | } |
2601 | } |
2621 | |
2602 | |
2622 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2603 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2623 | { |
2604 | { |
2624 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
2605 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
2625 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2606 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2626 | am_transparent = 0; |
2607 | am_transparent = 0; |
2627 | /* XXX: also turn off Opt_transparent? */ |
2608 | /* XXX: also turn off Opt_transparent? */ |
2628 | } |
2609 | } |
2629 | else |
2610 | else |
2630 | { |
2611 | { |
2631 | #if WAIT_FOR_WM |
|
|
2632 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2633 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2634 | sleep (1); |
|
|
2635 | #endif |
|
|
2636 | for (n = 0; n < (unsigned int)i; n++) |
2612 | for (n = 0; n < (unsigned int)i; n++) |
2637 | { |
2613 | { |
2638 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2614 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
2639 | XClearWindow (disp, parent[n]); |
2615 | XClearWindow (xdisp, parent[n]); |
2640 | } |
2616 | } |
2641 | |
2617 | |
2642 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2618 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2643 | am_transparent = 1; |
2619 | am_transparent = 1; |
2644 | } |
2620 | } |
2645 | |
2621 | |
2646 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2622 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2647 | parent[i] = None; |
2623 | parent[i] = None; |
2648 | } |
2624 | } |
2649 | |
2625 | |
2650 | if (scrollBar.win) |
2626 | if (scrollBar.win) |
2651 | { |
2627 | { |
2652 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2628 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
2653 | scrollBar.setIdle (); |
2629 | scrollBar.setIdle (); |
2654 | scrollbar_show (0); |
2630 | scrollbar_show (0); |
2655 | } |
2631 | } |
2656 | |
2632 | |
2657 | if (am_transparent) |
2633 | if (am_transparent) |
… | |
… | |
2669 | |
2645 | |
2670 | bool |
2646 | bool |
2671 | rxvt_term::cmd_parse () |
2647 | rxvt_term::cmd_parse () |
2672 | { |
2648 | { |
2673 | bool flag = false; |
2649 | bool flag = false; |
2674 | unicode_t ch = NOCHAR; |
2650 | wchar_t ch = NOCHAR; |
2675 | unsigned char *seq_begin; // remember start of esc-sequence here |
2651 | char *seq_begin; // remember start of esc-sequence here |
2676 | |
2652 | |
2677 | for (;;) |
2653 | for (;;) |
2678 | { |
2654 | { |
2679 | if (ch == NOCHAR) |
2655 | if (ch == NOCHAR) |
2680 | { |
2656 | { |
2681 | seq_begin = cmdbuf_ptr; |
2657 | seq_begin = cmdbuf_ptr; |
2682 | ch = next_char (); |
2658 | ch = next_char (); |
2683 | } |
|
|
2684 | |
2659 | |
2685 | if (ch == NOCHAR) // TODO: improve |
2660 | if (ch == NOCHAR) |
2686 | break; |
2661 | break; |
|
|
2662 | } |
2687 | |
2663 | |
2688 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2664 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2689 | { |
2665 | { |
2690 | if (!seen_input) |
2666 | if (!seen_input) |
2691 | { |
2667 | { |
… | |
… | |
2700 | if (seen_resize && cmd_pid) |
2676 | if (seen_resize && cmd_pid) |
2701 | kill (-cmd_pid, SIGWINCH); |
2677 | kill (-cmd_pid, SIGWINCH); |
2702 | } |
2678 | } |
2703 | |
2679 | |
2704 | /* Read a text string from the input buffer */ |
2680 | /* Read a text string from the input buffer */ |
2705 | unicode_t buf[UBUFSIZ]; |
2681 | wchar_t buf[UBUFSIZ]; |
2706 | bool refreshnow = false; |
2682 | bool refreshnow = false; |
2707 | int nlines = 0; |
2683 | int nlines = 0; |
2708 | unicode_t *str = buf; |
2684 | wchar_t *str = buf; |
2709 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2685 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2710 | |
2686 | |
2711 | for (;;) |
2687 | for (;;) |
2712 | { |
2688 | { |
2713 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2689 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2714 | break; |
2690 | break; |
… | |
… | |
2732 | } |
2708 | } |
2733 | |
2709 | |
2734 | // scr_add_lines only works for nlines <= nrow - 1. |
2710 | // scr_add_lines only works for nlines <= nrow - 1. |
2735 | if (nlines >= nrow - 1) |
2711 | if (nlines >= nrow - 1) |
2736 | { |
2712 | { |
|
|
2713 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2714 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2737 | scr_add_lines (buf, nlines, str - buf); |
2715 | scr_add_lines (buf, str - buf, nlines); |
|
|
2716 | |
2738 | nlines = 0; |
2717 | nlines = 0; |
2739 | str = buf; |
2718 | str = buf; |
2740 | eol = str + min (ncol, UBUFSIZ); |
2719 | eol = str + min (ncol, UBUFSIZ); |
2741 | } |
2720 | } |
2742 | |
2721 | |
… | |
… | |
2755 | |
2734 | |
2756 | seq_begin = cmdbuf_ptr; |
2735 | seq_begin = cmdbuf_ptr; |
2757 | ch = next_char (); |
2736 | ch = next_char (); |
2758 | } |
2737 | } |
2759 | |
2738 | |
|
|
2739 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2740 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2760 | scr_add_lines (buf, nlines, str - buf); |
2741 | scr_add_lines (buf, str - buf, nlines); |
2761 | |
2742 | |
2762 | /* |
2743 | /* |
2763 | * If there have been a lot of new lines, then update the screen |
2744 | * 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. |
2745 | * 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 |
2746 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2770 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2751 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2771 | refresh_limit++; |
2752 | refresh_limit++; |
2772 | else |
2753 | else |
2773 | { |
2754 | { |
2774 | flag = true; |
2755 | flag = true; |
2775 | scr_refresh (refresh_type); |
2756 | scr_refresh (); |
2776 | flush_ev.stop (); |
2757 | want_refresh = 1; |
2777 | } |
2758 | } |
2778 | } |
2759 | } |
2779 | |
2760 | |
2780 | } |
2761 | } |
2781 | else |
2762 | else |
… | |
… | |
2796 | } |
2777 | } |
2797 | |
2778 | |
2798 | return flag; |
2779 | return flag; |
2799 | } |
2780 | } |
2800 | |
2781 | |
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 |
2782 | // read the next character |
2811 | unicode_t |
2783 | wchar_t |
2812 | rxvt_term::next_char () |
2784 | rxvt_term::next_char () NOTHROW |
2813 | { |
2785 | { |
2814 | while (cmdbuf_ptr < cmdbuf_endp) |
2786 | while (cmdbuf_ptr < cmdbuf_endp) |
2815 | { |
2787 | { |
2816 | // assume 7-bit to be ascii ALWAYS |
2788 | // assume 7-bit to be ascii ALWAYS |
2817 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2789 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2818 | return *cmdbuf_ptr++; |
2790 | return *cmdbuf_ptr++; |
2819 | |
2791 | |
2820 | wchar_t wc; |
2792 | wchar_t wc; |
2821 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2793 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2822 | |
2794 | |
2823 | if (len == (size_t)-2) |
2795 | if (len == (size_t)-2) |
2824 | { |
2796 | { |
2825 | // the mbstate stores incomplete sequences. didn't know this :/ |
2797 | // the mbstate stores incomplete sequences. didn't know this :/ |
2826 | cmdbuf_ptr = cmdbuf_endp; |
2798 | cmdbuf_ptr = cmdbuf_endp; |
2827 | break; |
2799 | break; |
2828 | } |
2800 | } |
2829 | |
2801 | |
2830 | if (len == (size_t)-1) |
2802 | if (len == (size_t)-1) |
2831 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2803 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2832 | |
2804 | |
2833 | // assume wchar == unicode |
2805 | // assume wchar == unicode |
2834 | cmdbuf_ptr += len; |
2806 | cmdbuf_ptr += len; |
2835 | return wc & UNICODE_MASK; |
2807 | return wc & UNICODE_MASK; |
2836 | } |
2808 | } |
2837 | |
2809 | |
2838 | return NOCHAR; |
2810 | return NOCHAR; |
2839 | } |
2811 | } |
|
|
2812 | |
|
|
2813 | // read the next octet |
|
|
2814 | uint32_t |
|
|
2815 | rxvt_term::next_octet () NOTHROW |
|
|
2816 | { |
|
|
2817 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2818 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2819 | : NOCHAR; |
|
|
2820 | } |
|
|
2821 | |
|
|
2822 | static class out_of_input out_of_input; |
2840 | |
2823 | |
2841 | /* rxvt_cmd_getc () - Return next input character */ |
2824 | /* rxvt_cmd_getc () - Return next input character */ |
2842 | /* |
2825 | /* |
2843 | * Return the next input character after first passing any keyboard input |
2826 | * Return the next input character after first passing any keyboard input |
2844 | * to the command. |
2827 | * to the command. |
2845 | */ |
2828 | */ |
2846 | unicode_t |
2829 | wchar_t |
2847 | rxvt_term::cmd_getc () |
2830 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2848 | { |
2831 | { |
2849 | unicode_t c = next_char (); |
2832 | wchar_t c = next_char (); |
2850 | |
2833 | |
2851 | if (c == NOCHAR) |
2834 | if (c == NOCHAR) |
2852 | throw out_of_input; |
2835 | throw out_of_input; |
2853 | |
2836 | |
2854 | return c; |
2837 | return c; |
2855 | } |
2838 | } |
2856 | |
2839 | |
2857 | unicode_t |
2840 | uint32_t |
2858 | rxvt_term::cmd_get8 () |
2841 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2859 | { |
2842 | { |
2860 | unicode_t c = next_octet (); |
2843 | uint32_t c = next_octet (); |
2861 | |
2844 | |
2862 | if (c == NOCHAR) |
2845 | if (c == NOCHAR) |
2863 | throw out_of_input; |
2846 | throw out_of_input; |
2864 | |
2847 | |
2865 | return c; |
2848 | return c; |
… | |
… | |
2965 | case C0_ESC: |
2948 | case C0_ESC: |
2966 | process_escape_seq (); |
2949 | process_escape_seq (); |
2967 | break; |
2950 | break; |
2968 | case C0_ENQ: /* terminal Status */ |
2951 | case C0_ENQ: /* terminal Status */ |
2969 | if (rs[Rs_answerbackstring]) |
2952 | if (rs[Rs_answerbackstring]) |
2970 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2953 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2971 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2972 | else |
2954 | else |
2973 | tt_write ((unsigned char *)VT100_ANS, |
2955 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2974 | (unsigned int)strlen (VT100_ANS)); |
|
|
2975 | break; |
2956 | break; |
2976 | case C0_BEL: /* bell */ |
2957 | case C0_BEL: /* bell */ |
2977 | scr_bell (); |
2958 | scr_bell (); |
2978 | break; |
2959 | break; |
2979 | case C0_BS: /* backspace */ |
2960 | case C0_BS: /* backspace */ |
… | |
… | |
3134 | break; |
3115 | break; |
3135 | |
3116 | |
3136 | /* 8.3.87: NEXT LINE */ |
3117 | /* 8.3.87: NEXT LINE */ |
3137 | case C1_NEL: /* ESC E */ |
3118 | case C1_NEL: /* ESC E */ |
3138 | { |
3119 | { |
3139 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3120 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3140 | scr_add_lines (nlcr, 1, 2); |
3121 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3141 | } |
3122 | } |
3142 | break; |
3123 | break; |
3143 | |
3124 | |
3144 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3125 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3145 | case C1_ESA: /* ESC G */ |
3126 | case C1_ESA: /* ESC G */ |
… | |
… | |
3167 | process_dcs_seq (); |
3148 | process_dcs_seq (); |
3168 | break; |
3149 | break; |
3169 | |
3150 | |
3170 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3151 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3171 | case C1_SCI: /* ESC Z */ |
3152 | case C1_SCI: /* ESC Z */ |
3172 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3153 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3173 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3174 | break; /* steal obsolete ESC [ c */ |
3154 | break; /* steal obsolete ESC [ c */ |
3175 | |
3155 | |
3176 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3156 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3177 | case C1_CSI: /* ESC [ */ |
3157 | case C1_CSI: /* ESC [ */ |
3178 | process_csi_seq (); |
3158 | process_csi_seq (); |
… | |
… | |
3287 | ndef = get_byte_array_bit (csi_defaults, i); |
3267 | ndef = get_byte_array_bit (csi_defaults, i); |
3288 | for (p = 0; p < nargs; p++) |
3268 | for (p = 0; p < nargs; p++) |
3289 | if (arg[p] == -1) |
3269 | if (arg[p] == -1) |
3290 | arg[p] = ndef; |
3270 | arg[p] = ndef; |
3291 | |
3271 | |
3292 | #ifdef DEBUG_CMD |
|
|
3293 | fprintf (stderr, "CSI "); |
|
|
3294 | for (p = 0; p < nargs; p++) |
|
|
3295 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3296 | fprintf (stderr, "%c\n", ch); |
|
|
3297 | #endif |
|
|
3298 | |
|
|
3299 | /* |
3272 | /* |
3300 | * private mode handling |
3273 | * private mode handling |
3301 | */ |
3274 | */ |
3302 | if (priv) |
3275 | if (priv) |
3303 | { |
3276 | { |
3304 | switch (priv) |
3277 | switch (priv) |
3305 | { |
3278 | { |
3306 | case '>': |
3279 | case '>': |
3307 | if (ch == CSI_DA) /* secondary device attributes */ |
3280 | if (ch == CSI_DA) /* secondary device attributes */ |
3308 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3281 | { |
|
|
3282 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3283 | // 'U' for rxvt-unicode <= 7.2. |
|
|
3284 | // |
|
|
3285 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3286 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3287 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3288 | // |
|
|
3289 | tt_printf ("\033[>0;94;0c"); |
|
|
3290 | } |
3309 | break; |
3291 | break; |
3310 | case '?': |
3292 | case '?': |
3311 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3293 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3312 | process_terminal_mode (ch, priv, nargs, arg); |
3294 | process_terminal_mode (ch, priv, nargs, arg); |
3313 | break; |
3295 | break; |
… | |
… | |
3422 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3404 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3423 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3405 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3424 | break; |
3406 | break; |
3425 | |
3407 | |
3426 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3408 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3427 | tt_write ((const unsigned char *)VT100_ANS, |
3409 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3428 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3429 | break; |
3410 | break; |
3430 | |
3411 | |
3431 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3412 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3432 | process_sgr_mode (nargs, arg); |
3413 | process_sgr_mode (nargs, arg); |
3433 | break; |
3414 | break; |
… | |
… | |
3542 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3523 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3543 | { |
3524 | { |
3544 | int x, y; |
3525 | int x, y; |
3545 | XWindowAttributes wattr; |
3526 | XWindowAttributes wattr; |
3546 | Window wdummy; |
3527 | Window wdummy; |
3547 | dDisp; |
3528 | |
|
|
3529 | dLocal (Display *, xdisp); |
3548 | |
3530 | |
3549 | if (nargs == 0) |
3531 | if (nargs == 0) |
3550 | return; |
3532 | return; |
3551 | |
3533 | |
3552 | switch (args[0]) |
3534 | switch (args[0]) |
3553 | { |
3535 | { |
3554 | /* |
3536 | /* |
3555 | * commands |
3537 | * commands |
3556 | */ |
3538 | */ |
3557 | case 1: /* deiconify window */ |
3539 | case 1: /* deiconify window */ |
3558 | XMapWindow (disp, parent[0]); |
3540 | XMapWindow (xdisp, parent[0]); |
3559 | break; |
3541 | break; |
3560 | case 2: /* iconify window */ |
3542 | case 2: /* iconify window */ |
3561 | XIconifyWindow (disp, parent[0], display->screen); |
3543 | XIconifyWindow (xdisp, parent[0], display->screen); |
3562 | break; |
3544 | break; |
3563 | case 3: /* set position (pixels) */ |
3545 | case 3: /* set position (pixels) */ |
3564 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3546 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3565 | break; |
3547 | break; |
3566 | case 4: /* set size (pixels) */ |
3548 | case 4: /* set size (pixels) */ |
3567 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3549 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3568 | break; |
3550 | break; |
3569 | case 5: /* raise window */ |
3551 | case 5: /* raise window */ |
3570 | XRaiseWindow (disp, parent[0]); |
3552 | XRaiseWindow (xdisp, parent[0]); |
3571 | break; |
3553 | break; |
3572 | case 6: /* lower window */ |
3554 | case 6: /* lower window */ |
3573 | XLowerWindow (disp, parent[0]); |
3555 | XLowerWindow (xdisp, parent[0]); |
3574 | break; |
3556 | break; |
3575 | case 7: /* refresh window */ |
3557 | case 7: /* refresh window */ |
3576 | scr_touch (true); |
3558 | scr_touch (true); |
3577 | break; |
3559 | break; |
3578 | case 8: /* set size (chars) */ |
3560 | case 8: /* set size (chars) */ |
… | |
… | |
3590 | |
3572 | |
3591 | /* |
3573 | /* |
3592 | * reports - some output format copied from XTerm |
3574 | * reports - some output format copied from XTerm |
3593 | */ |
3575 | */ |
3594 | case 11: /* report window state */ |
3576 | case 11: /* report window state */ |
3595 | XGetWindowAttributes (disp, parent[0], &wattr); |
3577 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3596 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3578 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3597 | break; |
3579 | break; |
3598 | case 13: /* report window position */ |
3580 | case 13: /* report window position */ |
3599 | XGetWindowAttributes (disp, parent[0], &wattr); |
3581 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3600 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3582 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3601 | -wattr.border_width, -wattr.border_width, |
3583 | -wattr.border_width, -wattr.border_width, |
3602 | &x, &y, &wdummy); |
3584 | &x, &y, &wdummy); |
3603 | tt_printf ("\033[3;%d;%dt", x, y); |
3585 | tt_printf ("\033[3;%d;%dt", x, y); |
3604 | break; |
3586 | break; |
3605 | case 14: /* report window size (pixels) */ |
3587 | case 14: /* report window size (pixels) */ |
3606 | XGetWindowAttributes (disp, parent[0], &wattr); |
3588 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3607 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3589 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3608 | break; |
3590 | break; |
3609 | case 18: /* report text area size (chars) */ |
3591 | case 18: /* report text area size (chars) */ |
3610 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3592 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3611 | break; |
3593 | break; |
… | |
… | |
3613 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3595 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3614 | break; |
3596 | break; |
3615 | case 20: /* report icon label */ |
3597 | case 20: /* report icon label */ |
3616 | { |
3598 | { |
3617 | char *s; |
3599 | char *s; |
3618 | XGetIconName (disp, parent[0], &s); |
3600 | XGetIconName (xdisp, parent[0], &s); |
3619 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3601 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3620 | XFree (s); |
3602 | XFree (s); |
3621 | } |
3603 | } |
3622 | break; |
3604 | break; |
3623 | case 21: /* report window title */ |
3605 | case 21: /* report window title */ |
3624 | { |
3606 | { |
3625 | char *s; |
3607 | char *s; |
3626 | XFetchName (disp, parent[0], &s); |
3608 | XFetchName (xdisp, parent[0], &s); |
3627 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3609 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3628 | XFree (s); |
3610 | XFree (s); |
3629 | } |
3611 | } |
3630 | break; |
3612 | break; |
3631 | } |
3613 | } |
… | |
… | |
3635 | /*----------------------------------------------------------------------*/ |
3617 | /*----------------------------------------------------------------------*/ |
3636 | /* |
3618 | /* |
3637 | * get input up until STRING TERMINATOR (or BEL) |
3619 | * get input up until STRING TERMINATOR (or BEL) |
3638 | * ends_how is terminator used. returned input must be free()'d |
3620 | * ends_how is terminator used. returned input must be free()'d |
3639 | */ |
3621 | */ |
3640 | unsigned char * |
3622 | char * |
3641 | rxvt_term::get_to_st (unicode_t &ends_how) |
3623 | rxvt_term::get_to_st (unicode_t &ends_how) |
3642 | { |
3624 | { |
3643 | unicode_t ch; |
3625 | unicode_t ch; |
3644 | bool seen_esc = false; |
3626 | bool seen_esc = false; |
3645 | unsigned int n = 0; |
3627 | unsigned int n = 0; |
… | |
… | |
3678 | |
3660 | |
3679 | string[n++] = '\0'; |
3661 | string[n++] = '\0'; |
3680 | |
3662 | |
3681 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3663 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3682 | |
3664 | |
3683 | return (unsigned char *)rxvt_wcstombs (string); |
3665 | return rxvt_wcstombs (string); |
3684 | } |
3666 | } |
3685 | |
3667 | |
3686 | /*----------------------------------------------------------------------*/ |
3668 | /*----------------------------------------------------------------------*/ |
3687 | /* |
3669 | /* |
3688 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3670 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3689 | */ |
3671 | */ |
3690 | void |
3672 | void |
3691 | rxvt_term::process_dcs_seq () |
3673 | rxvt_term::process_dcs_seq () |
3692 | { |
3674 | { |
3693 | unsigned char *s; |
3675 | char *s; |
3694 | unicode_t eh; |
3676 | unicode_t eh; |
3695 | |
3677 | |
3696 | /* |
3678 | /* |
3697 | * Not handled yet |
3679 | * Not handled yet |
3698 | */ |
3680 | */ |
… | |
… | |
3717 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3699 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3718 | arg = arg * 10 + (ch - '0'); |
3700 | arg = arg * 10 + (ch - '0'); |
3719 | |
3701 | |
3720 | if (ch == ';') |
3702 | if (ch == ';') |
3721 | { |
3703 | { |
3722 | unsigned char *s = get_to_st (eh); |
3704 | char *s = get_to_st (eh); |
3723 | |
3705 | |
3724 | if (s) |
3706 | if (s) |
3725 | { |
3707 | { |
3726 | process_xterm_seq (arg, (char *)s, eh); |
3708 | process_xterm_seq (arg, s, eh); |
3727 | free (s); |
3709 | free (s); |
3728 | } |
3710 | } |
3729 | } |
3711 | } |
3730 | } |
3712 | } |
3731 | |
3713 | |
3732 | void |
3714 | void |
3733 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3715 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3734 | { |
3716 | { |
3735 | if (str[0] == '?' && !str[1]) |
3717 | if (str[0] == '?' && !str[1]) |
3736 | { |
3718 | { |
3737 | unsigned short r, g, b; |
3719 | unsigned short r, g, b; |
3738 | pix_colors_focused[color].get (display, r, g, b); |
3720 | pix_colors_focused[color].get (this, r, g, b); |
3739 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3721 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3740 | } |
3722 | } |
3741 | else |
3723 | else |
3742 | set_window_color (color, str); |
3724 | set_window_color (color, str); |
3743 | } |
3725 | } |
3744 | |
3726 | |
3745 | /* |
3727 | /* |
3746 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3728 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3747 | */ |
3729 | */ |
3748 | void |
3730 | void |
3749 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3731 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3750 | { |
3732 | { |
3751 | int changed = 0; |
|
|
3752 | int color; |
3733 | int color; |
3753 | char *buf, *name; |
3734 | char *buf, *name; |
3754 | bool query = str[0] == '?' && !str[1]; |
3735 | bool query = str[0] == '?' && !str[1]; |
3755 | int saveop = op; |
3736 | int saveop = op; |
3756 | dDisp; |
3737 | |
|
|
3738 | dLocal (Display *, xdisp); |
3757 | |
3739 | |
3758 | assert (str != NULL); |
3740 | assert (str != NULL); |
3759 | switch (op) |
3741 | switch (op) |
3760 | { |
3742 | { |
3761 | case XTerm_name: |
3743 | case XTerm_name: |
… | |
… | |
3777 | unsigned long bytes_after; |
3759 | unsigned long bytes_after; |
3778 | unsigned char *value = 0; |
3760 | unsigned char *value = 0; |
3779 | const char *str = ""; |
3761 | const char *str = ""; |
3780 | |
3762 | |
3781 | if (prop |
3763 | if (prop |
3782 | && XGetWindowProperty (disp, parent[0], |
3764 | && XGetWindowProperty (xdisp, parent[0], |
3783 | prop, 0, 1<<16, 0, AnyPropertyType, |
3765 | prop, 0, 1<<16, 0, AnyPropertyType, |
3784 | &actual_type, &actual_format, |
3766 | &actual_type, &actual_format, |
3785 | &nitems, &bytes_after, &value) == Success |
3767 | &nitems, &bytes_after, &value) == Success |
3786 | && actual_type != None |
3768 | && actual_type != None |
3787 | && actual_format == 8) |
3769 | && actual_format == 8) |
… | |
… | |
3799 | { |
3781 | { |
3800 | *eq = 0; |
3782 | *eq = 0; |
3801 | set_utf8_property (display->atom (str), eq + 1); |
3783 | set_utf8_property (display->atom (str), eq + 1); |
3802 | } |
3784 | } |
3803 | else |
3785 | else |
3804 | XDeleteProperty (disp, parent[0], |
3786 | XDeleteProperty (xdisp, parent[0], |
3805 | display->atom (str)); |
3787 | display->atom (str)); |
3806 | } |
3788 | } |
3807 | break; |
3789 | break; |
3808 | |
3790 | |
3809 | case XTerm_Color: |
3791 | case XTerm_Color: |
… | |
… | |
3811 | { |
3793 | { |
3812 | if ((name = strchr (buf, ';')) == NULL) |
3794 | if ((name = strchr (buf, ';')) == NULL) |
3813 | break; |
3795 | break; |
3814 | |
3796 | |
3815 | *name++ = '\0'; |
3797 | *name++ = '\0'; |
3816 | color = atoi (buf); |
3798 | color = atoi (buf) + minCOLOR; |
3817 | |
3799 | |
3818 | if (color < 0 || color >= TOTAL_COLORS) |
3800 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3819 | break; |
3801 | break; |
3820 | |
3802 | |
3821 | if ((buf = strchr (name, ';')) != NULL) |
3803 | if ((buf = strchr (name, ';')) != NULL) |
3822 | *buf++ = '\0'; |
3804 | *buf++ = '\0'; |
3823 | |
3805 | |
3824 | if (name[0] == '?' && !name[1]) |
3806 | if (name[0] == '?' && !name[1]) |
3825 | { |
3807 | { |
3826 | unsigned short r, g, b; |
3808 | unsigned short r, g, b; |
3827 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3809 | pix_colors_focused[color].get (this, r, g, b); |
3828 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3810 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3829 | } |
3811 | } |
3830 | else |
3812 | else |
3831 | set_window_color (color + minCOLOR, name); |
3813 | set_window_color (color, name); |
3832 | } |
3814 | } |
3833 | break; |
3815 | break; |
3834 | case XTerm_Color00: |
3816 | case XTerm_Color00: |
3835 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3817 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3836 | break; |
3818 | break; |
3837 | case XTerm_Color01: |
3819 | case XTerm_Color01: |
3838 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3820 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3839 | break; |
3821 | break; |
3840 | #ifndef NO_CURSORCOLOR |
3822 | #ifndef NO_CURSORCOLOR |
3841 | case XTerm_Color_cursor: |
3823 | case XTerm_Color_cursor: |
3842 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3824 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3843 | break; |
3825 | break; |
… | |
… | |
3847 | break; |
3829 | break; |
3848 | case XTerm_Color_pointer_bg: |
3830 | case XTerm_Color_pointer_bg: |
3849 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3831 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3850 | break; |
3832 | break; |
3851 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3833 | #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: |
3834 | case XTerm_Color_RV: |
3859 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3835 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3836 | break; |
|
|
3837 | case Rxvt_Color_BD: |
|
|
3838 | case URxvt_Color_BD: |
|
|
3839 | process_color_seq (op, Color_BD, str, resp); |
|
|
3840 | break; |
|
|
3841 | case Rxvt_Color_UL: |
|
|
3842 | case URxvt_Color_UL: |
|
|
3843 | process_color_seq (op, Color_UL, str, resp); |
3860 | break; |
3844 | break; |
3861 | case URxvt_Color_IT: |
3845 | case URxvt_Color_IT: |
3862 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3846 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3863 | break; |
3847 | break; |
3864 | #endif |
3848 | #endif |
… | |
… | |
3869 | if (am_transparent) |
3853 | if (am_transparent) |
3870 | want_full_refresh = want_refresh = 1; |
3854 | want_full_refresh = want_refresh = 1; |
3871 | break; |
3855 | break; |
3872 | #endif |
3856 | #endif |
3873 | |
3857 | |
3874 | case XTerm_Pixmap: |
3858 | case Rxvt_Pixmap: |
|
|
3859 | { |
3875 | if (*str != ';') |
3860 | if (*str != ';') |
3876 | { |
3861 | { |
3877 | #if XPM_BACKGROUND |
3862 | #if XPM_BACKGROUND |
3878 | scale_pixmap (""); /* reset to default scaling */ |
3863 | scale_pixmap (""); /* reset to default scaling */ |
3879 | set_bgPixmap (str); /* change pixmap */ |
3864 | set_bgPixmap (str); /* change pixmap */ |
3880 | #endif |
|
|
3881 | scr_touch (true); |
3865 | scr_touch (true); |
|
|
3866 | #endif |
3882 | } |
3867 | } |
|
|
3868 | |
|
|
3869 | int changed = 0; |
|
|
3870 | |
3883 | while ((str = strchr (str, ';')) != NULL) |
3871 | while ((str = strchr (str, ';')) != NULL) |
3884 | { |
3872 | { |
3885 | str++; |
3873 | str++; |
3886 | #if XPM_BACKGROUND |
3874 | #if XPM_BACKGROUND |
3887 | changed += scale_pixmap (str); |
3875 | changed += scale_pixmap (str); |
3888 | #endif |
3876 | #endif |
3889 | } |
3877 | } |
3890 | |
3878 | |
3891 | if (changed) |
3879 | if (changed) |
3892 | { |
3880 | { |
3893 | #ifdef XPM_BACKGROUND |
3881 | #ifdef XPM_BACKGROUND |
3894 | resize_pixmap (); |
3882 | resize_pixmap (); |
3895 | #endif |
|
|
3896 | scr_touch (true); |
3883 | scr_touch (true); |
|
|
3884 | #endif |
3897 | } |
3885 | } |
|
|
3886 | } |
3898 | break; |
3887 | break; |
3899 | |
3888 | |
3900 | case XTerm_restoreFG: |
3889 | case Rxvt_restoreFG: |
3901 | set_window_color (Color_fg, str); |
3890 | set_window_color (Color_fg, str); |
3902 | break; |
3891 | break; |
3903 | case XTerm_restoreBG: |
3892 | case Rxvt_restoreBG: |
3904 | set_window_color (Color_bg, str); |
3893 | set_window_color (Color_bg, str); |
3905 | break; |
3894 | break; |
3906 | |
3895 | |
3907 | case XTerm_logfile: |
3896 | case XTerm_logfile: |
3908 | // TODO, when secure mode? |
3897 | // TODO, when secure mode? |
3909 | break; |
3898 | break; |
3910 | |
3899 | |
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 |
3900 | #if 0 |
3918 | case XTerm_dumpscreen: /* no error notices */ |
3901 | case Rxvt_dumpscreen: /* no error notices */ |
3919 | { |
3902 | { |
3920 | int fd; |
3903 | int fd; |
3921 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3904 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3922 | { |
3905 | { |
3923 | scr_dump (fd); |
3906 | scr_dump (fd); |
… | |
… | |
3947 | allocated.push_back ((void *)res); |
3930 | allocated.push_back ((void *)res); |
3948 | set_fonts (); |
3931 | set_fonts (); |
3949 | } |
3932 | } |
3950 | break; |
3933 | break; |
3951 | |
3934 | |
|
|
3935 | case URxvt_version: |
|
|
3936 | if (query) |
|
|
3937 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3938 | URxvt_version, |
|
|
3939 | rs[Rs_name], |
|
|
3940 | VERSION[0], VERSION[2], |
|
|
3941 | resp); |
|
|
3942 | break; |
|
|
3943 | |
3952 | #if ENABLE_FRILLS |
3944 | #if ENABLE_FRILLS |
3953 | case URxvt_locale: |
3945 | case URxvt_locale: |
3954 | if (query) |
3946 | if (query) |
3955 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3947 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3956 | else |
3948 | else |
3957 | { |
3949 | { |
3958 | set_locale (str); |
3950 | set_locale (str); |
3959 | pty.set_utf8_mode (enc_utf8); |
3951 | pty->set_utf8_mode (enc_utf8); |
3960 | init_xlocale (); |
3952 | init_xlocale (); |
3961 | } |
3953 | } |
3962 | break; |
3954 | break; |
3963 | |
3955 | |
3964 | case URxvt_view_up: |
3956 | case URxvt_view_up: |
3965 | case URxvt_view_down: |
3957 | case URxvt_view_down: |
|
|
3958 | { |
3966 | int lines = atoi (str); |
3959 | int lines = atoi (str); |
3967 | |
3960 | |
3968 | if (lines) |
3961 | if (lines) |
3969 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3962 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3970 | else |
3963 | else |
3971 | { |
|
|
3972 | scr_erase_savelines (); |
3964 | scr_erase_savelines (); |
3973 | } |
3965 | } |
3974 | |
3966 | |
|
|
3967 | break; |
|
|
3968 | #endif |
|
|
3969 | |
|
|
3970 | #if ENABLE_PERL |
|
|
3971 | case URxvt_perl: |
|
|
3972 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
3973 | ; // no responses yet |
3975 | break; |
3974 | break; |
3976 | #endif |
3975 | #endif |
3977 | } |
3976 | } |
3978 | } |
3977 | } |
3979 | /*----------------------------------------------------------------------*/ |
3978 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4010 | return state; |
4009 | return state; |
4011 | } |
4010 | } |
4012 | |
4011 | |
4013 | /* we're not using priv _yet_ */ |
4012 | /* we're not using priv _yet_ */ |
4014 | void |
4013 | void |
4015 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4014 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4016 | { |
4015 | { |
4017 | unsigned int i, j; |
4016 | unsigned int i, j; |
4018 | int state; |
4017 | int state; |
4019 | |
4018 | |
4020 | static const struct |
4019 | static const struct |
… | |
… | |
4031 | { 5, PrivMode_rVideo }, |
4030 | { 5, PrivMode_rVideo }, |
4032 | { 6, PrivMode_relOrigin }, |
4031 | { 6, PrivMode_relOrigin }, |
4033 | { 7, PrivMode_Autowrap }, |
4032 | { 7, PrivMode_Autowrap }, |
4034 | // 8, bi-directional support mode |
4033 | // 8, bi-directional support mode |
4035 | { 9, PrivMode_MouseX10 }, |
4034 | { 9, PrivMode_MouseX10 }, |
4036 | #ifdef menuBar_esc |
|
|
4037 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4038 | #endif |
|
|
4039 | // 18, 19 printing-related |
4035 | // 18, 19 printing-related |
4040 | { 25, PrivMode_VisibleCursor }, |
4036 | { 25, PrivMode_VisibleCursor }, |
4041 | #ifdef scrollBar_esc |
4037 | #ifdef scrollBar_esc |
4042 | { scrollBar_esc, PrivMode_scrollBar }, |
4038 | { scrollBar_esc, PrivMode_scrollBar }, |
4043 | #endif |
4039 | #endif |
… | |
… | |
4090 | /* extra handling for values with state unkept */ |
4086 | /* extra handling for values with state unkept */ |
4091 | switch (arg[i]) |
4087 | switch (arg[i]) |
4092 | { |
4088 | { |
4093 | #if ENABLE_STYLES |
4089 | #if ENABLE_STYLES |
4094 | case 1021: |
4090 | case 1021: |
4095 | if (mode) |
4091 | set_option (Opt_intensityStyles, mode); |
4096 | SET_OPTION (Opt_intensityStyles); |
|
|
4097 | else |
|
|
4098 | CLR_OPTION (Opt_intensityStyles); |
|
|
4099 | |
4092 | |
4100 | scr_touch (true); |
4093 | scr_touch (true); |
4101 | break; |
4094 | break; |
4102 | #endif |
4095 | #endif |
4103 | case 1048: /* alternative cursor save */ |
4096 | case 1048: /* alternative cursor save */ |
… | |
… | |
4125 | case 3: /* 80/132 */ |
4118 | case 3: /* 80/132 */ |
4126 | if (priv_modes & PrivMode_132OK) |
4119 | if (priv_modes & PrivMode_132OK) |
4127 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4120 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4128 | break; |
4121 | break; |
4129 | case 4: /* smooth scrolling */ |
4122 | case 4: /* smooth scrolling */ |
4130 | if (!state) |
4123 | set_option (Opt_jumpScroll, !state); |
4131 | SET_OPTION (Opt_jumpScroll); |
|
|
4132 | else |
|
|
4133 | CLR_OPTION (Opt_jumpScroll); |
|
|
4134 | break; |
4124 | break; |
4135 | case 5: /* reverse video */ |
4125 | case 5: /* reverse video */ |
4136 | scr_rvideo_mode (state); |
4126 | scr_rvideo_mode (state); |
4137 | break; |
4127 | break; |
4138 | case 6: /* relative/absolute origins */ |
4128 | case 6: /* relative/absolute origins */ |
… | |
… | |
4144 | /* case 8: - auto repeat, can't do on a per window basis */ |
4134 | /* case 8: - auto repeat, can't do on a per window basis */ |
4145 | case 9: /* X10 mouse reporting */ |
4135 | case 9: /* X10 mouse reporting */ |
4146 | if (state) /* orthogonal */ |
4136 | if (state) /* orthogonal */ |
4147 | priv_modes &= ~PrivMode_MouseX11; |
4137 | priv_modes &= ~PrivMode_MouseX11; |
4148 | break; |
4138 | 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 |
4139 | #ifdef scrollBar_esc |
4157 | case scrollBar_esc: |
4140 | case scrollBar_esc: |
4158 | if (scrollbar_mapping (state)) |
4141 | if (scrollbar_mapping (state)) |
4159 | { |
4142 | { |
4160 | resize_all_windows (0, 0, 0); |
4143 | resize_all_windows (0, 0, 0); |
… | |
… | |
4179 | #if 0 |
4162 | #if 0 |
4180 | case 1001: |
4163 | case 1001: |
4181 | break; /* X11 mouse highlighting */ |
4164 | break; /* X11 mouse highlighting */ |
4182 | #endif |
4165 | #endif |
4183 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4166 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4184 | if (!state) |
4167 | set_option (Opt_scrollTtyOutput, !state); |
4185 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4186 | else |
|
|
4187 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4188 | break; |
4168 | break; |
4189 | case 1011: /* scroll to bottom on key press */ |
4169 | case 1011: /* scroll to bottom on key press */ |
4190 | if (state) |
4170 | set_option (Opt_scrollTtyKeypress, state); |
4191 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4192 | else |
|
|
4193 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4194 | break; |
4171 | break; |
4195 | case 1047: /* secondary screen w/ clearing last */ |
4172 | case 1047: /* secondary screen w/ clearing last */ |
4196 | if (OPTION (Opt_secondaryScreen)) |
4173 | if (OPTION (Opt_secondaryScreen)) |
4197 | if (current_screen != PRIMARY) |
4174 | if (current_screen != PRIMARY) |
4198 | scr_erase_screen (2); |
4175 | scr_erase_screen (2); |
… | |
… | |
4336 | scr_color (Color_bg, Color_bg); |
4313 | scr_color (Color_bg, Color_bg); |
4337 | break; |
4314 | break; |
4338 | |
4315 | |
4339 | //case 50: // not variable spacing |
4316 | //case 50: // not variable spacing |
4340 | |
4317 | |
4341 | #ifndef NO_BRIGHTCOLOR |
4318 | #if ENABLE_FRILLS |
4342 | case 90: |
4319 | case 90: |
4343 | case 91: /* set bright fg color */ |
4320 | case 91: /* set bright fg color */ |
4344 | case 92: |
4321 | case 92: |
4345 | case 93: |
4322 | case 93: |
4346 | case 94: |
4323 | case 94: |
… | |
… | |
4391 | */ |
4368 | */ |
4392 | void |
4369 | void |
4393 | rxvt_term::tt_printf (const char *fmt,...) |
4370 | rxvt_term::tt_printf (const char *fmt,...) |
4394 | { |
4371 | { |
4395 | va_list arg_ptr; |
4372 | va_list arg_ptr; |
4396 | unsigned char buf[256]; |
4373 | char buf[256]; |
4397 | |
4374 | |
4398 | va_start (arg_ptr, fmt); |
4375 | va_start (arg_ptr, fmt); |
4399 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4376 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4400 | va_end (arg_ptr); |
4377 | va_end (arg_ptr); |
4401 | tt_write (buf, strlen (buf)); |
4378 | tt_write (buf, strlen (buf)); |
… | |
… | |
4406 | * or generated by us in response to a query ESC sequence. |
4383 | * or generated by us in response to a query ESC sequence. |
4407 | */ |
4384 | */ |
4408 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4385 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4409 | |
4386 | |
4410 | void |
4387 | void |
4411 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4388 | rxvt_term::tt_write (const char *data, unsigned int len) |
4412 | { |
4389 | { |
|
|
4390 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4391 | return; |
|
|
4392 | |
|
|
4393 | if (pty->pty < 0) |
|
|
4394 | return; |
|
|
4395 | |
4413 | if (v_buflen == 0) |
4396 | if (v_buflen == 0) |
4414 | { |
4397 | { |
4415 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4398 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4416 | |
4399 | |
4417 | if ((unsigned int)written == len) |
4400 | if ((unsigned int)written == len) |
4418 | return; |
4401 | return; |
4419 | |
4402 | |
4420 | data += written; |
4403 | data += written; |
4421 | len -= written; |
4404 | len -= written; |
4422 | } |
4405 | } |
4423 | |
4406 | |
4424 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4407 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4425 | |
4408 | |
4426 | memcpy (v_buffer + v_buflen, data, len); |
4409 | memcpy (v_buffer + v_buflen, data, len); |
4427 | v_buflen += len; |
4410 | v_buflen += len; |
4428 | |
4411 | |
4429 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4412 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4430 | } |
4413 | } |
4431 | |
4414 | |
4432 | void rxvt_term::pty_write () |
4415 | void rxvt_term::pty_write () |
4433 | { |
4416 | { |
4434 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4417 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4435 | |
4418 | |
4436 | if (written > 0) |
4419 | if (written > 0) |
4437 | { |
4420 | { |
4438 | v_buflen -= written; |
4421 | v_buflen -= written; |
4439 | |
4422 | |