… | |
… | |
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. |
… | |
… | |
49 | #include "rxvt.h" |
49 | #include "rxvt.h" |
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 |
|
|
55 | # include <sched.h> |
|
|
56 | #endif |
|
|
57 | |
|
|
58 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
59 | # include "keyboard.h" |
55 | # include "keyboard.h" |
60 | #endif |
56 | #endif |
61 | |
57 | |
62 | #include <csignal> |
58 | #include <csignal> |
63 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
64 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
65 | |
65 | |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #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 | |
67 | |
71 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
72 | |
69 | |
73 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
74 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
146 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
147 | return; |
144 | return; |
148 | |
145 | |
149 | for (;;) |
146 | for (;;) |
150 | { |
147 | { |
151 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
152 | |
149 | |
153 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
154 | |
151 | |
155 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
156 | { |
153 | { |
… | |
… | |
229 | # if !UNICODE3 |
226 | # if !UNICODE3 |
230 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
231 | ch = 0xfffd; |
228 | ch = 0xfffd; |
232 | # endif |
229 | # endif |
233 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
234 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
235 | } |
234 | } |
236 | |
235 | |
|
|
236 | // { |
|
|
237 | // char buf[4+4+3+1]; |
|
|
238 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
239 | // scr_overlay_set (0, 0, buf); |
|
|
240 | // } |
237 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
238 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
239 | |
243 | |
240 | free (fname); |
244 | free (fname); |
241 | |
245 | |
… | |
… | |
267 | mb[0] = ch[0]; |
271 | mb[0] = ch[0]; |
268 | len = 1; |
272 | len = 1; |
269 | } |
273 | } |
270 | |
274 | |
271 | if (len > 0) |
275 | if (len > 0) |
272 | tt_write ((unsigned char *)mb, len); |
276 | tt_write (mb, len); |
273 | else |
277 | else |
274 | scr_bell (); |
278 | scr_bell (); |
275 | } |
279 | } |
276 | |
280 | |
277 | iso14755buf = 0; |
281 | iso14755buf = 0; |
… | |
… | |
301 | rxvt_term::lookup_key (XKeyEvent &ev) |
305 | rxvt_term::lookup_key (XKeyEvent &ev) |
302 | { |
306 | { |
303 | int ctrl, meta, shft, len; |
307 | int ctrl, meta, shft, len; |
304 | unsigned int newlen; |
308 | unsigned int newlen; |
305 | KeySym keysym; |
309 | KeySym keysym; |
306 | #ifdef DEBUG_CMD |
|
|
307 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
308 | #endif |
|
|
309 | int valid_keysym; |
310 | int valid_keysym; |
310 | unsigned char kbuf[KBUFSZ]; |
311 | char kbuf[KBUFSZ]; |
311 | |
312 | |
312 | /* |
313 | /* |
313 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
314 | * escape sequence to toggle the Keypad. |
315 | * escape sequence to toggle the Keypad. |
315 | * |
316 | * |
… | |
… | |
333 | Status status_return; |
334 | Status status_return; |
334 | |
335 | |
335 | #if 0 |
336 | #if 0 |
336 | #ifdef X_HAVE_UTF8_STRING |
337 | #ifdef X_HAVE_UTF8_STRING |
337 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
339 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
339 | KBUFSZ, &keysym, &status_return); |
340 | KBUFSZ, &keysym, &status_return); |
340 | else |
341 | else |
341 | #endif |
342 | #endif |
342 | #endif |
343 | #endif |
343 | { |
344 | { |
… | |
… | |
380 | || status_return == XLookupBoth; |
381 | || status_return == XLookupBoth; |
381 | } |
382 | } |
382 | else |
383 | else |
383 | #endif |
384 | #endif |
384 | { |
385 | { |
385 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
386 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
386 | valid_keysym = keysym != NoSymbol; |
387 | valid_keysym = keysym != NoSymbol; |
387 | } |
388 | } |
388 | |
389 | |
389 | if (valid_keysym) |
390 | if (valid_keysym) |
390 | { |
391 | { |
… | |
… | |
442 | scr_move_to (0, 1); |
443 | scr_move_to (0, 1); |
443 | return; |
444 | return; |
444 | } |
445 | } |
445 | else if (keysym == XK_End) |
446 | else if (keysym == XK_End) |
446 | { |
447 | { |
447 | scr_move_to (1, 0); |
448 | scr_move_to (1, 1); |
448 | return; |
449 | return; |
449 | } |
450 | } |
450 | } |
451 | } |
451 | #endif |
452 | #endif |
452 | } |
453 | } |
… | |
… | |
463 | { |
464 | { |
464 | switch (keysym) |
465 | switch (keysym) |
465 | { |
466 | { |
466 | /* normal XTerm key bindings */ |
467 | /* normal XTerm key bindings */ |
467 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
468 | selection_request (ev.time, 0, 0); |
469 | selection_request (ev.time); |
469 | return; |
470 | return; |
470 | #if TODO |
471 | #if TODO |
471 | /* rxvt extras */ |
472 | /* rxvt extras */ |
472 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
473 | change_font (FONT_UP); |
474 | change_font (FONT_UP); |
… | |
… | |
854 | { |
855 | { |
855 | #ifdef META8_OPTION |
856 | #ifdef META8_OPTION |
856 | /* set 8-bit on */ |
857 | /* set 8-bit on */ |
857 | if (meta && (meta_char == 0x80)) |
858 | if (meta && (meta_char == 0x80)) |
858 | { |
859 | { |
859 | unsigned char *ch; |
860 | char *ch; |
860 | |
861 | |
861 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | *ch |= 0x80; |
863 | *ch |= 0x80; |
863 | |
864 | |
864 | meta = 0; |
865 | meta = 0; |
865 | } |
866 | } |
866 | #endif |
867 | #endif |
867 | /* nil */ ; |
868 | /* nil */ ; |
868 | } |
869 | } |
869 | } |
870 | } |
|
|
871 | |
|
|
872 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
873 | return; |
870 | |
874 | |
871 | if (len <= 0) |
875 | if (len <= 0) |
872 | return; /* not mapped */ |
876 | return; /* not mapped */ |
873 | |
877 | |
874 | if (OPTION (Opt_scrollTtyKeypress)) |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
897 | #ifdef META8_OPTION |
901 | #ifdef META8_OPTION |
898 | && meta_char == C0_ESC |
902 | && meta_char == C0_ESC |
899 | #endif |
903 | #endif |
900 | ) |
904 | ) |
901 | { |
905 | { |
902 | const unsigned char ch = C0_ESC; |
906 | const char ch = C0_ESC; |
903 | tt_write (&ch, 1); |
907 | tt_write (&ch, 1); |
904 | } |
908 | } |
905 | |
909 | |
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); |
910 | tt_write (kbuf, (unsigned int)len); |
917 | } |
911 | } |
918 | /*}}} */ |
912 | /*}}} */ |
919 | |
913 | |
920 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
914 | #if defined (KEYSYM_RESOURCE) |
921 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
922 | /* attempt to `write' count to the input buffer */ |
|
|
923 | unsigned int |
915 | unsigned int |
924 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
916 | rxvt_term::cmd_write (const char *str, unsigned int count) |
925 | { |
917 | { |
926 | unsigned int n, s; |
918 | unsigned int n, s; |
927 | |
919 | |
928 | n = cmdbuf_ptr - cmdbuf_base; |
920 | n = cmdbuf_ptr - cmdbuf_base; |
929 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
921 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
966 | } |
958 | } |
967 | #endif |
959 | #endif |
968 | |
960 | |
969 | if (want_refresh) |
961 | if (want_refresh) |
970 | { |
962 | { |
|
|
963 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
964 | { |
|
|
965 | int row = view_start; |
|
|
966 | int end_row = row + nrow; |
|
|
967 | |
|
|
968 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
969 | --row; |
|
|
970 | |
|
|
971 | do |
|
|
972 | { |
|
|
973 | int start_row = row; |
|
|
974 | line_t *l; |
|
|
975 | |
|
|
976 | do |
|
|
977 | { |
|
|
978 | l = &ROW (row++); |
|
|
979 | |
|
|
980 | if (!(l->f & LINE_FILTERED)) |
|
|
981 | { |
|
|
982 | // line not filtered, mark it as filtered |
|
|
983 | l->f |= LINE_FILTERED; |
|
|
984 | while (l->is_longer ()) |
|
|
985 | { |
|
|
986 | l = &ROW (row++); |
|
|
987 | l->f |= LINE_FILTERED; |
|
|
988 | } |
|
|
989 | |
|
|
990 | // and filter it |
|
|
991 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
992 | |
|
|
993 | break; |
|
|
994 | } |
|
|
995 | } |
|
|
996 | while (l->is_longer () && row < end_row); |
|
|
997 | } |
|
|
998 | while (row < end_row); |
|
|
999 | } |
|
|
1000 | |
971 | scr_refresh (refresh_type); |
1001 | scr_refresh (); |
972 | scrollbar_show (1); |
1002 | scrollbar_show (1); |
973 | #ifdef USE_XIM |
1003 | #ifdef USE_XIM |
974 | IMSendSpot (); |
1004 | IMSendSpot (); |
975 | #endif |
1005 | #endif |
976 | } |
1006 | } |
… | |
… | |
979 | } |
1009 | } |
980 | |
1010 | |
981 | void |
1011 | void |
982 | rxvt_term::check_cb (check_watcher &w) |
1012 | rxvt_term::check_cb (check_watcher &w) |
983 | { |
1013 | { |
984 | SET_R (this); |
1014 | make_current (); |
985 | SET_LOCALE (locale); |
|
|
986 | |
1015 | |
987 | display->flush (); |
1016 | display->flush (); |
988 | |
1017 | |
989 | if (want_refresh && !flush_ev.active) |
1018 | if (want_refresh && !flush_ev.active) |
990 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1019 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
991 | } |
1020 | } |
992 | |
1021 | |
993 | void |
1022 | void |
994 | rxvt_term::flush_cb (time_watcher &w) |
1023 | rxvt_term::flush_cb (time_watcher &w) |
995 | { |
1024 | { |
996 | SET_R (this); |
1025 | make_current (); |
997 | SET_LOCALE (locale); |
|
|
998 | |
1026 | |
999 | refresh_limit = 1; |
1027 | refresh_limit = 1; |
1000 | refresh_count = 0; |
1028 | refresh_count = 0; |
1001 | flush (); |
1029 | flush (); |
1002 | } |
1030 | } |
… | |
… | |
1006 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1034 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1007 | { |
1035 | { |
1008 | hidden_cursor = !hidden_cursor; |
1036 | hidden_cursor = !hidden_cursor; |
1009 | want_refresh = 1; |
1037 | want_refresh = 1; |
1010 | |
1038 | |
1011 | w.start (w.at + BLINK_INTERVAL); |
1039 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1012 | } |
1040 | } |
1013 | #endif |
1041 | #endif |
1014 | |
1042 | |
1015 | #ifdef TEXT_BLINK |
1043 | #ifdef TEXT_BLINK |
1016 | void |
1044 | void |
… | |
… | |
1030 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1058 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1031 | { |
1059 | { |
1032 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1060 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1033 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1061 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1034 | { |
1062 | { |
1035 | refresh_type |= SMOOTH_REFRESH; |
|
|
1036 | want_refresh = 1; |
1063 | want_refresh = 1; |
1037 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1064 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1038 | } |
1065 | } |
1039 | } |
1066 | } |
1040 | #endif |
1067 | #endif |
… | |
… | |
1044 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1071 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1045 | { |
1072 | { |
1046 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1073 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1047 | { |
1074 | { |
1048 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1075 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1049 | refresh_type |= SMOOTH_REFRESH; |
|
|
1050 | want_refresh = 1; |
1076 | want_refresh = 1; |
1051 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1077 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1052 | } |
1078 | } |
1053 | } |
1079 | } |
1054 | #endif |
1080 | #endif |
… | |
… | |
1059 | { |
1085 | { |
1060 | if (mouse_slip_wheel_speed == 0 |
1086 | if (mouse_slip_wheel_speed == 0 |
1061 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1087 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1062 | : scr_page (UP, mouse_slip_wheel_speed)) |
1088 | : scr_page (UP, mouse_slip_wheel_speed)) |
1063 | { |
1089 | { |
1064 | if (view_start == nsaved || |
1090 | if (view_start == top_row || view_start == 0) |
1065 | view_start == 0) |
|
|
1066 | mouse_slip_wheel_speed = 0; |
1091 | mouse_slip_wheel_speed = 0; |
1067 | |
1092 | |
1068 | refresh_type |= SMOOTH_REFRESH; |
|
|
1069 | want_refresh = 1; |
1093 | want_refresh = 1; |
1070 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1094 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | } |
1095 | } |
1072 | } |
1096 | } |
1073 | #endif |
1097 | #endif |
1074 | |
1098 | |
1075 | #if HAVE_SCHED_YIELD |
1099 | #if LINUX_YIELD_HACK |
1076 | static struct event_handler |
1100 | static struct event_handler |
1077 | { |
1101 | { |
1078 | check_watcher cw_yield; |
1102 | check_watcher yield_ev; |
1079 | |
1103 | |
1080 | void yield (check_watcher &w) |
1104 | void yield_cb (check_watcher &w) |
1081 | { |
1105 | { |
1082 | sched_yield (); |
1106 | // this should really be sched_yield(), but the linux guys thought |
|
|
1107 | // that giving a process calling sched_yield () less cpu time than |
|
|
1108 | // ones with high nice levels. |
|
|
1109 | |
|
|
1110 | struct timespec ts = { 0, 0 }; |
|
|
1111 | nanosleep (&ts, 0); |
|
|
1112 | |
1083 | w.stop (); |
1113 | w.stop (); |
1084 | } |
1114 | } |
1085 | |
1115 | |
1086 | event_handler () |
1116 | event_handler () |
1087 | : cw_yield (this, &event_handler::yield) |
1117 | : yield_ev (this, &event_handler::yield_cb) |
1088 | { |
1118 | { |
1089 | } |
1119 | } |
1090 | } event_handler; |
1120 | } event_handler; |
1091 | #endif |
1121 | #endif |
1092 | |
1122 | |
… | |
… | |
1095 | { |
1125 | { |
1096 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1126 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | |
1127 | |
1098 | if (CBUFSIZ == n) |
1128 | if (CBUFSIZ == n) |
1099 | { |
1129 | { |
1100 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1130 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1101 | n = 0; |
1131 | n = 0; |
1102 | } |
1132 | } |
1103 | |
1133 | |
1104 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1134 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | cmdbuf_ptr = cmdbuf_base; |
1135 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_endp = cmdbuf_ptr + n; |
1136 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | |
1137 | |
1108 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1138 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | |
1139 | |
1110 | if (r > 0) |
1140 | if (r > 0) |
1111 | { |
1141 | { |
1112 | cmdbuf_endp += r; |
1142 | cmdbuf_endp += r; |
1113 | return true; |
1143 | return true; |
1114 | } |
1144 | } |
1115 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1145 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1116 | { |
1146 | { |
1117 | #if HAVE_SCHED_YIELD |
1147 | #if LINUX_YIELD_HACK |
|
|
1148 | if (display->is_local) |
1118 | event_handler.cw_yield.start (); |
1149 | event_handler.yield_ev.start (); |
1119 | #endif |
1150 | #endif |
1120 | } |
1151 | } |
1121 | else |
1152 | else |
1122 | { |
1153 | { |
1123 | pty_ev.stop (); |
1154 | pty_ev.stop (); |
… | |
… | |
1130 | } |
1161 | } |
1131 | |
1162 | |
1132 | void |
1163 | void |
1133 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1164 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1134 | { |
1165 | { |
1135 | SET_R (this); |
1166 | make_current (); |
1136 | SET_LOCALE (locale); |
|
|
1137 | |
1167 | |
1138 | if (revents & EVENT_READ) |
1168 | if (revents & EVENT_READ) |
1139 | // loop, but don't allow a single term to monopolize us |
1169 | // loop, but don't allow a single term to monopolize us |
1140 | while (pty_fill ()) |
1170 | while (pty_fill ()) |
1141 | if (cmd_parse ()) |
1171 | if (cmd_parse ()) |
… | |
… | |
1146 | } |
1176 | } |
1147 | |
1177 | |
1148 | void |
1178 | void |
1149 | rxvt_term::pointer_unblank () |
1179 | rxvt_term::pointer_unblank () |
1150 | { |
1180 | { |
1151 | XDefineCursor (display->display, vt, TermWin_cursor); |
1181 | XDefineCursor (xdisp, vt, TermWin_cursor); |
1152 | recolour_cursor (); |
1182 | recolour_cursor (); |
1153 | |
1183 | |
1154 | #ifdef POINTER_BLANK |
1184 | #ifdef POINTER_BLANK |
1155 | hidden_pointer = 0; |
1185 | hidden_pointer = 0; |
1156 | |
1186 | |
… | |
… | |
1161 | |
1191 | |
1162 | #ifdef POINTER_BLANK |
1192 | #ifdef POINTER_BLANK |
1163 | void |
1193 | void |
1164 | rxvt_term::pointer_blank () |
1194 | rxvt_term::pointer_blank () |
1165 | { |
1195 | { |
1166 | if (! OPTION (Opt_pointerBlank)) |
1196 | if (!OPTION (Opt_pointerBlank)) |
1167 | return; |
1197 | return; |
1168 | |
1198 | |
1169 | XDefineCursor (display->display, vt, display->blank_cursor); |
1199 | XDefineCursor (xdisp, vt, display->blank_cursor); |
1170 | XFlush (display->display); |
1200 | XFlush (xdisp); |
1171 | |
1201 | |
1172 | hidden_pointer = 1; |
1202 | hidden_pointer = 1; |
1173 | } |
1203 | } |
1174 | |
1204 | |
1175 | void |
1205 | void |
1176 | rxvt_term::pointer_cb (time_watcher &w) |
1206 | rxvt_term::pointer_cb (time_watcher &w) |
1177 | { |
1207 | { |
1178 | SET_R (this); |
1208 | make_current (); |
1179 | SET_LOCALE (locale); |
|
|
1180 | |
1209 | |
1181 | pointer_blank (); |
1210 | pointer_blank (); |
1182 | } |
1211 | } |
1183 | #endif |
1212 | #endif |
1184 | |
1213 | |
… | |
… | |
1249 | (32 + button_number + key_state), |
1278 | (32 + button_number + key_state), |
1250 | (32 + x + 1), |
1279 | (32 + x + 1), |
1251 | (32 + y + 1)); |
1280 | (32 + y + 1)); |
1252 | } |
1281 | } |
1253 | |
1282 | |
1254 | #ifdef USING_W11LIB |
|
|
1255 | void |
|
|
1256 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1257 | { |
|
|
1258 | rxvt_t *r = rxvt_get_r (); |
|
|
1259 | |
|
|
1260 | x_cb (*ev); |
|
|
1261 | } |
|
|
1262 | #endif |
|
|
1263 | |
|
|
1264 | /*{{{ process an X event */ |
1283 | /*{{{ process an X event */ |
1265 | void |
1284 | void |
1266 | rxvt_term::x_cb (XEvent &ev) |
1285 | rxvt_term::x_cb (XEvent &ev) |
1267 | { |
1286 | { |
1268 | dDisp; |
1287 | make_current (); |
1269 | |
1288 | |
1270 | SET_R (this); |
1289 | dLocal (Display *, xdisp); |
1271 | SET_LOCALE (locale); |
|
|
1272 | |
1290 | |
1273 | #if defined(CURSOR_BLINK) |
1291 | if (ev.xany.window == vt |
1274 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1292 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1275 | { |
1293 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1276 | if (hidden_cursor) |
1294 | return; |
1277 | { |
|
|
1278 | hidden_cursor = 0; |
|
|
1279 | want_refresh = 1; |
|
|
1280 | } |
|
|
1281 | |
1295 | |
1282 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1296 | // for XQueryPointer |
1283 | } |
|
|
1284 | #endif |
|
|
1285 | |
|
|
1286 | #if defined(POINTER_BLANK) |
|
|
1287 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1288 | { |
|
|
1289 | if (ev.type == MotionNotify |
|
|
1290 | || ev.type == ButtonPress |
|
|
1291 | || ev.type == ButtonRelease) |
|
|
1292 | if (hidden_pointer) |
|
|
1293 | pointer_unblank (); |
|
|
1294 | |
|
|
1295 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1296 | pointer_blank (); |
|
|
1297 | } |
|
|
1298 | #endif |
|
|
1299 | |
|
|
1300 | Window unused_root, unused_child; |
1297 | Window unused_root, unused_child; |
1301 | int unused_root_x, unused_root_y; |
1298 | int unused_root_x, unused_root_y; |
1302 | unsigned int unused_mask; |
1299 | unsigned int unused_mask; |
1303 | |
1300 | |
1304 | switch (ev.type) |
1301 | switch (ev.type) |
… | |
… | |
1311 | |
1308 | |
1312 | break; |
1309 | break; |
1313 | |
1310 | |
1314 | case KeyRelease: |
1311 | case KeyRelease: |
1315 | { |
1312 | { |
1316 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1313 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1317 | KeySym ks; |
1314 | KeySym keysym; |
1318 | |
1315 | |
1319 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1316 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1320 | #endif |
1317 | #endif |
1321 | |
1318 | |
1322 | #if ENABLE_FRILLS || ISO_14755 |
1319 | #if ENABLE_FRILLS || ISO_14755 |
1323 | // ISO 14755 support |
1320 | // ISO 14755 support |
1324 | if (iso14755buf) |
1321 | if (iso14755buf) |
… | |
… | |
1329 | # endif |
1326 | # endif |
1330 | # if ISO_14755 |
1327 | # if ISO_14755 |
1331 | // iso14755 part 5.2 handling: release time |
1328 | // iso14755 part 5.2 handling: release time |
1332 | // first: controls |
1329 | // first: controls |
1333 | if ((ev.xkey.state & ControlMask) |
1330 | if ((ev.xkey.state & ControlMask) |
1334 | && ((ks >= 0x40 && ks <= 0x5f) |
1331 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1335 | || (ks >= 0x61 && ks <= 0x7f))) |
1332 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1336 | { |
1333 | { |
1337 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1334 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1338 | commit_iso14755 (); |
1335 | commit_iso14755 (); |
1339 | return; // case-break; |
1336 | goto skip_switch; |
1340 | } |
1337 | } |
1341 | |
1338 | |
1342 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1339 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1343 | if (i[0] == ks) |
1340 | if (i[0] == keysym) |
1344 | { |
1341 | { |
1345 | iso14755buf = ISO_14755_51 | i[1]; |
1342 | iso14755buf = ISO_14755_51 | i[1]; |
1346 | commit_iso14755 (); |
1343 | commit_iso14755 (); |
1347 | return; // case-break; |
1344 | goto skip_switch; |
1348 | } |
1345 | } |
1349 | |
1346 | |
1350 | scr_bell (); |
1347 | scr_bell (); |
1351 | # endif |
1348 | # endif |
1352 | iso14755buf = 0; |
1349 | iso14755buf = 0; |
… | |
… | |
1371 | else |
1368 | else |
1372 | iso14755buf = 0; |
1369 | iso14755buf = 0; |
1373 | } |
1370 | } |
1374 | #endif |
1371 | #endif |
1375 | |
1372 | |
|
|
1373 | if (ev.xany.window == vt |
|
|
1374 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1375 | break; |
|
|
1376 | |
1376 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1377 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1377 | if (!(ev.xkey.state & ControlMask)) |
1378 | if (!(ev.xkey.state & ControlMask)) |
1378 | slip_wheel_ev.stop (); |
1379 | slip_wheel_ev.stop (); |
1379 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1380 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1380 | mouse_slip_wheel_speed = 0; |
1381 | mouse_slip_wheel_speed = 0; |
1381 | #endif |
1382 | #endif |
1382 | break; |
1383 | break; |
1383 | } |
1384 | } |
1384 | |
1385 | |
… | |
… | |
1390 | button_release (ev.xbutton); |
1391 | button_release (ev.xbutton); |
1391 | break; |
1392 | break; |
1392 | |
1393 | |
1393 | case ClientMessage: |
1394 | case ClientMessage: |
1394 | if (ev.xclient.format == 32 |
1395 | if (ev.xclient.format == 32 |
1395 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1396 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1396 | { |
1397 | { |
|
|
1398 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1399 | { |
|
|
1400 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1401 | { |
1397 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1402 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1403 | { |
|
|
1404 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1398 | destroy (); |
1405 | destroy (); |
|
|
1406 | } |
1399 | #if ENABLE_EWMH |
1407 | #if ENABLE_EWMH |
1400 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1408 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1401 | XSendEvent (disp, ev.xclient.window = display->root, |
1409 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1402 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1410 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1403 | &ev); |
1411 | &ev); |
|
|
1412 | #endif |
|
|
1413 | } |
|
|
1414 | } |
|
|
1415 | #if ENABLE_XEMBED |
|
|
1416 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1417 | { |
|
|
1418 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1419 | focus_in (); |
|
|
1420 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1421 | focus_out (); |
|
|
1422 | } |
1404 | #endif |
1423 | #endif |
1405 | } |
1424 | } |
1406 | #if ENABLE_XEMBED |
|
|
1407 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1408 | { |
|
|
1409 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1410 | focus_in (); |
|
|
1411 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1412 | focus_out (); |
|
|
1413 | } |
|
|
1414 | #endif |
|
|
1415 | #ifdef OFFIX_DND |
|
|
1416 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1417 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1418 | && (ev.xclient.data.l[0] == DndFile |
|
|
1419 | || ev.xclient.data.l[0] == DndDir |
|
|
1420 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1421 | { |
|
|
1422 | /* Get Dnd data */ |
|
|
1423 | Atom ActualType; |
|
|
1424 | int ActualFormat; |
|
|
1425 | unsigned char *data; |
|
|
1426 | unsigned long Size, RemainingBytes; |
|
|
1427 | |
|
|
1428 | XGetWindowProperty (disp, display->root, |
|
|
1429 | xa[XA_DNDSELECTION], |
|
|
1430 | 0L, 1000000L, |
|
|
1431 | False, AnyPropertyType, |
|
|
1432 | &ActualType, &ActualFormat, |
|
|
1433 | &Size, &RemainingBytes, |
|
|
1434 | &data); |
|
|
1435 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1436 | XFree (data); |
|
|
1437 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1438 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1439 | } |
|
|
1440 | #endif /* OFFIX_DND */ |
|
|
1441 | break; |
1425 | break; |
1442 | |
1426 | |
1443 | case MappingNotify: |
1427 | case MappingNotify: |
1444 | XRefreshKeyboardMapping (&ev.xmapping); |
1428 | XRefreshKeyboardMapping (&ev.xmapping); |
1445 | break; |
1429 | break; |
… | |
… | |
1478 | break; |
1462 | break; |
1479 | |
1463 | |
1480 | case ConfigureNotify: |
1464 | case ConfigureNotify: |
1481 | if (ev.xconfigure.window == parent[0]) |
1465 | if (ev.xconfigure.window == parent[0]) |
1482 | { |
1466 | { |
1483 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1467 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1484 | ; |
1468 | ; |
1485 | |
1469 | |
1486 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1470 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1487 | { |
1471 | { |
1488 | seen_resize = 1; |
1472 | seen_resize = 1; |
1489 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1473 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1490 | } |
1474 | } |
1491 | |
1475 | |
|
|
1476 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1477 | |
1492 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1478 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1493 | if (OPTION (Opt_transparent)) |
1479 | if (OPTION (Opt_transparent)) |
1494 | check_our_parents (); |
1480 | check_our_parents (); |
1495 | #endif |
1481 | #endif |
1496 | } |
1482 | } |
1497 | break; |
1483 | break; |
1498 | |
1484 | |
1499 | case PropertyNotify: |
1485 | case PropertyNotify: |
|
|
1486 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1500 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1487 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1501 | && ev.xproperty.state == PropertyNewValue) |
1488 | && ev.xproperty.state == PropertyNewValue) |
1502 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1489 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1503 | |
1490 | |
1504 | break; |
1491 | break; |
1505 | |
1492 | |
1506 | case SelectionClear: |
1493 | case SelectionClear: |
1507 | selection_clear (); |
1494 | selection_clear (); |
… | |
… | |
1512 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1499 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1513 | break; |
1500 | break; |
1514 | |
1501 | |
1515 | case SelectionRequest: |
1502 | case SelectionRequest: |
1516 | selection_send (ev.xselectionrequest); |
1503 | selection_send (ev.xselectionrequest); |
|
|
1504 | break; |
|
|
1505 | |
|
|
1506 | case MapNotify: |
|
|
1507 | mapped = 1; |
|
|
1508 | #ifdef TEXT_BLINK |
|
|
1509 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1510 | #endif |
|
|
1511 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1517 | break; |
1512 | break; |
1518 | |
1513 | |
1519 | case UnmapNotify: |
1514 | case UnmapNotify: |
1520 | mapped = 0; |
1515 | mapped = 0; |
1521 | #ifdef TEXT_BLINK |
1516 | #ifdef TEXT_BLINK |
1522 | text_blink_ev.stop (); |
1517 | text_blink_ev.stop (); |
1523 | #endif |
1518 | #endif |
1524 | break; |
1519 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1525 | |
|
|
1526 | case MapNotify: |
|
|
1527 | mapped = 1; |
|
|
1528 | #ifdef TEXT_BLINK |
|
|
1529 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1530 | #endif |
|
|
1531 | break; |
1520 | break; |
1532 | |
1521 | |
1533 | #ifdef TRANSPARENT |
1522 | #ifdef TRANSPARENT |
1534 | case ReparentNotify: |
1523 | case ReparentNotify: |
1535 | rootwin_cb (ev); |
1524 | rootwin_cb (ev); |
… | |
… | |
1541 | if (ev.xany.window == vt) |
1530 | if (ev.xany.window == vt) |
1542 | { |
1531 | { |
1543 | do |
1532 | do |
1544 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1533 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1545 | ev.xexpose.width, ev.xexpose.height, False); |
1534 | ev.xexpose.width, ev.xexpose.height, False); |
1546 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1535 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1547 | |
1536 | |
1548 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1537 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1549 | |
1538 | |
1550 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1539 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1551 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1540 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1552 | ev.xexpose.width, ev.xexpose.height, False); |
1541 | ev.xexpose.width, ev.xexpose.height, False); |
1553 | |
1542 | |
1554 | scr_refresh (refresh_type); |
1543 | want_refresh = 1; |
1555 | } |
1544 | } |
1556 | else |
1545 | else |
1557 | { |
1546 | { |
1558 | XEvent unused_event; |
1547 | XEvent unused_event; |
1559 | |
1548 | |
1560 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1549 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1561 | ; |
1550 | ; |
1562 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1551 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1563 | ; |
1552 | ; |
1564 | |
1553 | |
1565 | if (isScrollbarWindow (ev.xany.window)) |
1554 | if (isScrollbarWindow (ev.xany.window)) |
1566 | { |
1555 | { |
1567 | scrollBar.setIdle (); |
1556 | scrollBar.setIdle (); |
1568 | scrollbar_show (0); |
1557 | scrollbar_show (0); |
1569 | } |
1558 | } |
1570 | #ifdef MENUBAR |
|
|
1571 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1572 | menubar_expose (); |
|
|
1573 | #endif |
|
|
1574 | |
1559 | |
1575 | #ifdef TRANSPARENT |
1560 | #ifdef TRANSPARENT |
1576 | if (am_transparent && ev.xany.window == parent[0]) |
1561 | if (am_transparent && ev.xany.window == parent[0]) |
1577 | XClearWindow (disp, ev.xany.window); |
1562 | XClearWindow (xdisp, ev.xany.window); |
1578 | #endif |
1563 | #endif |
1579 | } |
1564 | } |
1580 | break; |
1565 | break; |
1581 | |
1566 | |
1582 | case MotionNotify: |
1567 | case MotionNotify: |
1583 | #ifdef POINTER_BLANK |
1568 | #ifdef POINTER_BLANK |
1584 | if (hidden_pointer) |
1569 | if (hidden_pointer) |
1585 | pointer_unblank (); |
1570 | pointer_unblank (); |
1586 | #endif |
1571 | #endif |
1587 | #if MENUBAR |
|
|
1588 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1589 | { |
|
|
1590 | menubar_control (ev.xbutton); |
|
|
1591 | break; |
|
|
1592 | } |
|
|
1593 | #endif |
|
|
1594 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1572 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1595 | break; |
1573 | break; |
1596 | |
1574 | |
1597 | if (ev.xany.window == vt) |
1575 | if (ev.xany.window == vt) |
1598 | { |
1576 | { |
|
|
1577 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1578 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1579 | ; // nop |
1599 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1580 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1600 | { |
1581 | { |
1601 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1582 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1602 | ; |
1583 | ; |
1603 | |
1584 | |
1604 | XQueryPointer (disp, vt, |
1585 | XQueryPointer (xdisp, vt, |
1605 | &unused_root, &unused_child, |
1586 | &unused_root, &unused_child, |
1606 | &unused_root_x, &unused_root_y, |
1587 | &unused_root_x, &unused_root_y, |
1607 | &ev.xbutton.x, &ev.xbutton.y, |
1588 | &ev.xbutton.x, &ev.xbutton.y, |
1608 | &ev.xbutton.state); |
1589 | &ev.xbutton.state); |
1609 | #ifdef MOUSE_THRESHOLD |
1590 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1673 | #endif |
1654 | #endif |
1674 | } |
1655 | } |
1675 | } |
1656 | } |
1676 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1657 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1677 | { |
1658 | { |
1678 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1659 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1679 | MotionNotify, &ev)) |
1660 | MotionNotify, &ev)) |
1680 | ; |
1661 | ; |
1681 | |
1662 | |
1682 | XQueryPointer (disp, scrollBar.win, |
1663 | XQueryPointer (xdisp, scrollBar.win, |
1683 | &unused_root, &unused_child, |
1664 | &unused_root, &unused_child, |
1684 | &unused_root_x, &unused_root_y, |
1665 | &unused_root_x, &unused_root_y, |
1685 | &ev.xbutton.x, &ev.xbutton.y, |
1666 | &ev.xbutton.x, &ev.xbutton.y, |
1686 | &unused_mask); |
1667 | &unused_mask); |
1687 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1668 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1688 | scrollbar_size ()); |
1669 | scrollbar_size ()); |
1689 | scr_refresh (refresh_type); |
1670 | want_refresh = 1; |
1690 | refresh_limit = 0; |
1671 | refresh_limit = 0; |
1691 | scrollbar_show (1); |
1672 | scrollbar_show (1); |
1692 | } |
1673 | } |
1693 | break; |
1674 | break; |
1694 | } |
1675 | } |
|
|
1676 | |
|
|
1677 | skip_switch: ; |
|
|
1678 | |
|
|
1679 | #if defined(CURSOR_BLINK) |
|
|
1680 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1681 | { |
|
|
1682 | if (hidden_cursor) |
|
|
1683 | { |
|
|
1684 | hidden_cursor = 0; |
|
|
1685 | want_refresh = 1; |
|
|
1686 | } |
|
|
1687 | |
|
|
1688 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1689 | } |
|
|
1690 | #endif |
|
|
1691 | |
|
|
1692 | #if defined(POINTER_BLANK) |
|
|
1693 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1694 | { |
|
|
1695 | if (ev.type == MotionNotify |
|
|
1696 | || ev.type == ButtonPress |
|
|
1697 | || ev.type == ButtonRelease) |
|
|
1698 | if (hidden_pointer) |
|
|
1699 | pointer_unblank (); |
|
|
1700 | |
|
|
1701 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1702 | pointer_blank (); |
|
|
1703 | } |
|
|
1704 | #endif |
1695 | } |
1705 | } |
1696 | |
1706 | |
1697 | void |
1707 | void |
1698 | rxvt_term::focus_in () |
1708 | rxvt_term::focus_in () |
1699 | { |
1709 | { |
1700 | if (!focus) |
1710 | if (!focus) |
1701 | { |
1711 | { |
1702 | focus = 1; |
1712 | focus = 1; |
1703 | want_refresh = 1; |
1713 | want_refresh = 1; |
1704 | |
1714 | |
1705 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1715 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1706 | |
1716 | |
1707 | #if USE_XIM |
1717 | #if USE_XIM |
1708 | if (Input_Context != NULL) |
1718 | if (Input_Context != NULL) |
1709 | { |
1719 | { |
1710 | IMSetStatusPosition (); |
1720 | IMSetStatusPosition (); |
1711 | XSetICFocus (Input_Context); |
1721 | XSetICFocus (Input_Context); |
1712 | } |
1722 | } |
1713 | #endif |
1723 | #endif |
1714 | #if CURSOR_BLINK |
1724 | #if CURSOR_BLINK |
1715 | if (OPTION (Opt_cursorBlink)) |
1725 | if (OPTION (Opt_cursorBlink)) |
1716 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1726 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1717 | #endif |
1727 | #endif |
1718 | #if OFF_FOCUS_FADING |
1728 | #if OFF_FOCUS_FADING |
1719 | if (rs[Rs_fade]) |
1729 | if (rs[Rs_fade]) |
1720 | { |
1730 | { |
1721 | pix_colors = pix_colors_focused; |
1731 | pix_colors = pix_colors_focused; |
… | |
… | |
1731 | if (focus) |
1741 | if (focus) |
1732 | { |
1742 | { |
1733 | focus = 0; |
1743 | focus = 0; |
1734 | want_refresh = 1; |
1744 | want_refresh = 1; |
1735 | |
1745 | |
1736 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1746 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1737 | |
1747 | |
1738 | #if ENABLE_FRILLS || ISO_14755 |
1748 | #if ENABLE_FRILLS || ISO_14755 |
1739 | if (iso14755buf) |
1749 | if (iso14755buf) |
1740 | { |
1750 | { |
1741 | iso14755buf = 0; |
1751 | iso14755buf = 0; |
… | |
… | |
1765 | |
1775 | |
1766 | #if TRANSPARENT |
1776 | #if TRANSPARENT |
1767 | void |
1777 | void |
1768 | rxvt_term::rootwin_cb (XEvent &ev) |
1778 | rxvt_term::rootwin_cb (XEvent &ev) |
1769 | { |
1779 | { |
1770 | SET_R (this); |
1780 | make_current (); |
1771 | SET_LOCALE (locale); |
|
|
1772 | |
1781 | |
1773 | switch (ev.type) |
1782 | switch (ev.type) |
1774 | { |
1783 | { |
1775 | case PropertyNotify: |
1784 | case PropertyNotify: |
1776 | /* |
1785 | /* |
… | |
… | |
1794 | rxvt_term::button_press (XButtonEvent &ev) |
1803 | rxvt_term::button_press (XButtonEvent &ev) |
1795 | { |
1804 | { |
1796 | int reportmode = 0, clickintime; |
1805 | int reportmode = 0, clickintime; |
1797 | |
1806 | |
1798 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1807 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1808 | |
1799 | if (!bypass_keystate) |
1809 | if (!bypass_keystate) |
1800 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1810 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1801 | |
1811 | |
1802 | /* |
1812 | /* |
1803 | * VT window processing of button press |
1813 | * VT window processing of button press |
1804 | */ |
1814 | */ |
1805 | if (ev.window == vt) |
1815 | if (ev.window == vt) |
1806 | { |
1816 | { |
|
|
1817 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1818 | return; |
|
|
1819 | |
1807 | #if ISO_14755 |
1820 | #if ISO_14755 |
1808 | // 5.4 |
1821 | // 5.4 |
1809 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1822 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | { |
1823 | { |
1811 | iso14755_54 (ev.x, ev.y); |
1824 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1823 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1836 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1824 | if (ev.button == MEvent.button && clickintime) |
1837 | if (ev.button == MEvent.button && clickintime) |
1825 | { |
1838 | { |
1826 | /* same button, within alloted time */ |
1839 | /* same button, within alloted time */ |
1827 | MEvent.clicks++; |
1840 | MEvent.clicks++; |
|
|
1841 | |
1828 | if (MEvent.clicks > 1) |
1842 | if (MEvent.clicks > 1) |
1829 | { |
1843 | { |
1830 | /* only report double clicks */ |
1844 | /* only report double clicks */ |
1831 | MEvent.clicks = 2; |
1845 | MEvent.clicks = 2; |
1832 | mouse_report (ev); |
1846 | mouse_report (ev); |
… | |
… | |
1864 | #else |
1878 | #else |
1865 | selection.rect = false; |
1879 | selection.rect = false; |
1866 | #endif |
1880 | #endif |
1867 | |
1881 | |
1868 | /* allow shift+left click to extend selection */ |
1882 | /* allow shift+left click to extend selection */ |
1869 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1883 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1870 | { |
1884 | { |
1871 | if (MEvent.button == Button1 && clickintime) |
1885 | if (MEvent.button == Button1 && clickintime) |
1872 | selection_rotate (ev.x, ev.y); |
1886 | selection_rotate (ev.x, ev.y); |
1873 | else |
1887 | else |
1874 | selection_extend (ev.x, ev.y, 1); |
1888 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2039 | } |
2053 | } |
2040 | |
2054 | |
2041 | break; |
2055 | break; |
2042 | } |
2056 | } |
2043 | } |
2057 | } |
|
|
2058 | |
2044 | return; |
2059 | return; |
2045 | } |
2060 | } |
2046 | #if MENUBAR |
|
|
2047 | /* |
|
|
2048 | * Menubar window processing of button press |
|
|
2049 | */ |
|
|
2050 | if (isMenuBarWindow (ev.window)) |
|
|
2051 | menubar_control (ev); |
|
|
2052 | #endif |
|
|
2053 | } |
2061 | } |
2054 | |
2062 | |
2055 | void |
2063 | void |
2056 | rxvt_term::button_release (XButtonEvent &ev) |
2064 | rxvt_term::button_release (XButtonEvent &ev) |
2057 | { |
2065 | { |
… | |
… | |
2063 | |
2071 | |
2064 | if (scrollbar_isUpDn ()) |
2072 | if (scrollbar_isUpDn ()) |
2065 | { |
2073 | { |
2066 | scrollBar.setIdle (); |
2074 | scrollBar.setIdle (); |
2067 | scrollbar_show (0); |
2075 | scrollbar_show (0); |
2068 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2069 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2070 | #endif |
|
|
2071 | } |
2076 | } |
2072 | |
2077 | |
2073 | #ifdef SELECTION_SCROLLING |
2078 | #ifdef SELECTION_SCROLLING |
2074 | if (sel_scroll_ev.active) |
2079 | if (sel_scroll_ev.active) |
2075 | sel_scroll_ev.stop(); |
2080 | sel_scroll_ev.stop(); |
2076 | #endif |
2081 | #endif |
2077 | |
2082 | |
2078 | if (ev.window == vt) |
2083 | if (ev.window == vt) |
2079 | { |
2084 | { |
|
|
2085 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2086 | return; |
|
|
2087 | |
2080 | #if ISO_14755 |
2088 | #if ISO_14755 |
2081 | // 5.4 |
2089 | // 5.4 |
2082 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2090 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2083 | return; |
2091 | return; |
2084 | #endif |
2092 | #endif |
|
|
2093 | |
2085 | if (reportmode) |
2094 | if (reportmode) |
2086 | { |
2095 | { |
2087 | /* mouse report from vt window */ |
2096 | /* mouse report from vt window */ |
2088 | /* don't report release of wheel "buttons" */ |
2097 | /* don't report release of wheel "buttons" */ |
2089 | if (ev.button >= 4) |
2098 | if (ev.button >= 4) |
… | |
… | |
2119 | { |
2128 | { |
2120 | case Button1: |
2129 | case Button1: |
2121 | case Button3: |
2130 | case Button3: |
2122 | selection_make (ev.time); |
2131 | selection_make (ev.time); |
2123 | break; |
2132 | break; |
|
|
2133 | |
2124 | case Button2: |
2134 | case Button2: |
2125 | selection_request (ev.time, ev.x, ev.y); |
2135 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2136 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2126 | break; |
2137 | break; |
|
|
2138 | |
2127 | #ifdef MOUSE_WHEEL |
2139 | #ifdef MOUSE_WHEEL |
2128 | case Button4: |
2140 | case Button4: |
2129 | case Button5: |
2141 | case Button5: |
2130 | { |
2142 | { |
2131 | int i; |
2143 | int i; |
… | |
… | |
2153 | slip_wheel_ev.start (); |
2165 | slip_wheel_ev.start (); |
2154 | } |
2166 | } |
2155 | else |
2167 | else |
2156 | { |
2168 | { |
2157 | # endif |
2169 | # endif |
2158 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2159 | scr_page (v, i); |
2170 | scr_page (v, i); |
2160 | scr_refresh (SMOOTH_REFRESH); |
|
|
2161 | scrollbar_show (1); |
2171 | scrollbar_show (1); |
2162 | # else |
|
|
2163 | while (i--) |
|
|
2164 | { |
|
|
2165 | scr_page (v, 1); |
|
|
2166 | scr_refresh (SMOOTH_REFRESH); |
|
|
2167 | scrollbar_show (1); |
|
|
2168 | } |
|
|
2169 | # endif |
|
|
2170 | # ifdef MOUSE_SLIP_WHEELING |
2172 | # ifdef MOUSE_SLIP_WHEELING |
2171 | } |
2173 | } |
2172 | #endif |
2174 | # endif |
2173 | } |
2175 | } |
2174 | break; |
2176 | break; |
2175 | #endif |
2177 | #endif |
2176 | } |
2178 | } |
2177 | } |
2179 | } |
2178 | #ifdef MENUBAR |
|
|
2179 | else if (isMenuBarWindow (ev.window)) |
|
|
2180 | menubar_control (ev); |
|
|
2181 | #endif |
|
|
2182 | } |
2180 | } |
2183 | |
2181 | |
2184 | #ifdef TRANSPARENT |
2182 | #ifdef TRANSPARENT |
2185 | #if TINTING |
2183 | #if TINTING |
2186 | /* taken from aterm-0.4.2 */ |
2184 | /* taken from aterm-0.4.2 */ |
2187 | |
2185 | |
2188 | typedef uint32_t RUINT32T; |
2186 | typedef uint32_t RUINT32T; |
2189 | |
2187 | |
2190 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
2188 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
2191 | { |
2189 | { |
2192 | int sh_r, sh_g, sh_b; |
2190 | int sh_r, sh_g, sh_b; |
2193 | RUINT32T mask_r, mask_g, mask_b; |
2191 | RUINT32T mask_r, mask_g, mask_b; |
2194 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2192 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2195 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2193 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2196 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2194 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2197 | int i; |
2195 | int i; |
2198 | |
2196 | |
2199 | Visual *visual = display->visual; |
2197 | Visual *visual = term->visual; |
2200 | |
2198 | |
2201 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2199 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2202 | |
2200 | |
2203 | /* for convenience */ |
2201 | /* for convenience */ |
2204 | mask_r = visual->red_mask; |
2202 | mask_r = visual->red_mask; |
… | |
… | |
2425 | Atom atype; |
2423 | Atom atype; |
2426 | unsigned char *prop = NULL; |
2424 | unsigned char *prop = NULL; |
2427 | Window root, oldp, *list; |
2425 | Window root, oldp, *list; |
2428 | Pixmap rootpixmap = None; |
2426 | Pixmap rootpixmap = None; |
2429 | XWindowAttributes wattr, wrootattr; |
2427 | XWindowAttributes wattr, wrootattr; |
2430 | dDisp; |
|
|
2431 | |
2428 | |
2432 | pchanged = 0; |
2429 | pchanged = 0; |
2433 | |
2430 | |
2434 | if (!OPTION (Opt_transparent)) |
2431 | if (!OPTION (Opt_transparent)) |
2435 | return pchanged; /* Don't try any more */ |
2432 | return pchanged; /* Don't try any more */ |
2436 | |
2433 | |
2437 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2434 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
2438 | rootdepth = wrootattr.depth; |
2435 | rootdepth = wrootattr.depth; |
2439 | |
2436 | |
2440 | XGetWindowAttributes (disp, parent[0], &wattr); |
2437 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
2441 | |
2438 | |
2442 | if (rootdepth != wattr.depth) |
2439 | if (rootdepth != wattr.depth) |
2443 | { |
2440 | { |
2444 | if (am_transparent) |
2441 | if (am_transparent) |
2445 | { |
2442 | { |
2446 | pchanged = 1; |
2443 | pchanged = 1; |
2447 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2444 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2448 | am_transparent = am_pixmap_trans = 0; |
2445 | am_transparent = am_pixmap_trans = 0; |
2449 | } |
2446 | } |
2450 | |
2447 | |
2451 | return pchanged; /* Don't try any more */ |
2448 | return pchanged; /* Don't try any more */ |
2452 | } |
2449 | } |
2453 | |
2450 | |
2454 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2451 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2455 | XSync (disp, False); |
2452 | XSync (xdisp, False); |
2456 | |
2453 | |
2457 | /* |
2454 | /* |
2458 | * Make the frame window set by the window manager have |
2455 | * Make the frame window set by the window manager have |
2459 | * the root background. Some window managers put multiple nested frame |
2456 | * the root background. Some window managers put multiple nested frame |
2460 | * windows for each client, so we have to take care about that. |
2457 | * windows for each client, so we have to take care about that. |
2461 | */ |
2458 | */ |
2462 | i = (xa[XA_XROOTPMAP_ID] |
2459 | i = (xa[XA_XROOTPMAP_ID] |
2463 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2460 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
2464 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2461 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2465 | &nitems, &bytes_after, &prop) == Success); |
2462 | &nitems, &bytes_after, &prop) == Success); |
2466 | |
2463 | |
2467 | if (!i || prop == NULL) |
2464 | if (!i || prop == NULL) |
2468 | i = (xa[XA_ESETROOT_PMAP_ID] |
2465 | i = (xa[XA_ESETROOT_PMAP_ID] |
2469 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2466 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2470 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2467 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2471 | &nitems, &bytes_after, &prop) == Success); |
2468 | &nitems, &bytes_after, &prop) == Success); |
2472 | |
2469 | |
2473 | if (!i || prop == NULL |
2470 | if (!i || prop == NULL |
2474 | #if TINTING |
2471 | #if TINTING |
2475 | || !rs[Rs_color + Color_tint] |
2472 | || !ISSET_PIXCOLOR (Color_tint) |
2476 | #endif |
2473 | #endif |
2477 | ) |
2474 | ) |
2478 | have_pixmap = 0; |
2475 | have_pixmap = 0; |
2479 | else |
2476 | else |
2480 | { |
2477 | { |
… | |
… | |
2493 | Window cr; |
2490 | Window cr; |
2494 | XImage *image; |
2491 | XImage *image; |
2495 | GC gc; |
2492 | GC gc; |
2496 | XGCValues gcvalue; |
2493 | XGCValues gcvalue; |
2497 | |
2494 | |
2498 | XTranslateCoordinates (disp, parent[0], display->root, |
2495 | XTranslateCoordinates (xdisp, parent[0], display->root, |
2499 | 0, 0, &sx, &sy, &cr); |
2496 | 0, 0, &sx, &sy, &cr); |
2500 | nw = (unsigned int)szHint.width; |
2497 | nw = (unsigned int)szHint.width; |
2501 | nh = (unsigned int)szHint.height; |
2498 | nh = (unsigned int)szHint.height; |
2502 | nx = ny = 0; |
2499 | nx = ny = 0; |
2503 | |
2500 | |
… | |
… | |
2516 | } |
2513 | } |
2517 | |
2514 | |
2518 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2515 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2519 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2516 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2520 | |
2517 | |
2521 | XSync (disp, False); |
2518 | XSync (xdisp, False); |
2522 | allowedxerror = -1; |
2519 | allowedxerror = -1; |
2523 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2520 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2524 | |
2521 | |
2525 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2522 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2526 | /* XXX: may need a delay here? */ |
2523 | /* XXX: may need a delay here? */ |
2527 | allowedxerror = 0; |
2524 | allowedxerror = 0; |
2528 | |
2525 | |
… | |
… | |
2531 | if (am_transparent && am_pixmap_trans) |
2528 | if (am_transparent && am_pixmap_trans) |
2532 | { |
2529 | { |
2533 | pchanged = 1; |
2530 | pchanged = 1; |
2534 | if (pixmap != None) |
2531 | if (pixmap != None) |
2535 | { |
2532 | { |
2536 | XFreePixmap (disp, pixmap); |
2533 | XFreePixmap (xdisp, pixmap); |
2537 | pixmap = None; |
2534 | pixmap = None; |
2538 | } |
2535 | } |
2539 | } |
2536 | } |
2540 | |
2537 | |
2541 | am_pixmap_trans = 0; |
2538 | am_pixmap_trans = 0; |
2542 | } |
2539 | } |
2543 | else |
2540 | else |
2544 | { |
2541 | { |
2545 | if (pixmap != None) |
2542 | if (pixmap != None) |
2546 | XFreePixmap (disp, pixmap); |
2543 | XFreePixmap (xdisp, pixmap); |
2547 | |
2544 | |
2548 | #if TINTING |
2545 | #if TINTING |
2549 | if (ISSET_PIXCOLOR (Color_tint)) |
2546 | if (ISSET_PIXCOLOR (Color_tint)) |
2550 | { |
2547 | { |
2551 | unsigned short rm, gm, bm; |
|
|
2552 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2548 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2553 | |
2549 | |
|
|
2550 | rgba c; |
2554 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
2551 | pix_colors_focused [Color_tint].get (c); |
2555 | |
2552 | |
2556 | ShadeXImage (display, image, shade, rm, gm, bm); |
2553 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2557 | } |
2554 | } |
2558 | #endif |
2555 | #endif |
2559 | |
2556 | |
2560 | pixmap = XCreatePixmap (disp, vt, |
2557 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
2561 | szHint.width, szHint.height, image->depth); |
|
|
2562 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
2558 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
2563 | XPutImage (disp, pixmap, gc, image, 0, 0, |
2559 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
2564 | nx, ny, image->width, image->height); |
2560 | nx, ny, image->width, image->height); |
2565 | XFreeGC (disp, gc); |
2561 | XFreeGC (xdisp, gc); |
2566 | XDestroyImage (image); |
2562 | XDestroyImage (image); |
2567 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
2563 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
2568 | XClearWindow (disp, parent[0]); |
2564 | XClearWindow (xdisp, parent[0]); |
2569 | |
2565 | |
2570 | if (!am_transparent || !am_pixmap_trans) |
2566 | if (!am_transparent || !am_pixmap_trans) |
2571 | pchanged = 1; |
2567 | pchanged = 1; |
2572 | |
2568 | |
2573 | am_transparent = am_pixmap_trans = 1; |
2569 | am_transparent = am_pixmap_trans = 1; |
2574 | } |
2570 | } |
2575 | } |
2571 | } |
2576 | |
2572 | |
2577 | if (am_pixmap_trans) |
2573 | if (am_pixmap_trans) |
2578 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2574 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2579 | else |
2575 | else |
2580 | { |
2576 | { |
2581 | unsigned int n; |
2577 | unsigned int n; |
2582 | /* |
2578 | /* |
2583 | * InheritPixmap transparency |
2579 | * InheritPixmap transparency |
2584 | */ |
2580 | */ |
2585 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2581 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2586 | { |
2582 | { |
2587 | oldp = parent[i]; |
2583 | oldp = parent[i]; |
2588 | XQueryTree (disp, parent[i - 1], &root, |
2584 | XQueryTree (xdisp, parent[i - 1], &root, &parent[i], &list, &n); |
2589 | &parent[i], &list, &n); |
|
|
2590 | XFree (list); |
2585 | XFree (list); |
2591 | |
2586 | |
2592 | if (parent[i] == display->root) |
2587 | if (parent[i] == display->root) |
2593 | { |
2588 | { |
2594 | if (oldp != None) |
2589 | if (oldp != None) |
… | |
… | |
2602 | } |
2597 | } |
2603 | |
2598 | |
2604 | n = 0; |
2599 | n = 0; |
2605 | |
2600 | |
2606 | if (pchanged) |
2601 | if (pchanged) |
2607 | { |
|
|
2608 | for (; n < (unsigned int)i; n++) |
2602 | for (; n < (unsigned int)i; n++) |
2609 | { |
2603 | { |
2610 | XGetWindowAttributes (disp, parent[n], &wattr); |
2604 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
|
|
2605 | |
2611 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2606 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2612 | { |
2607 | { |
2613 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2608 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2614 | break; |
2609 | break; |
2615 | } |
2610 | } |
2616 | } |
2611 | } |
2617 | } |
|
|
2618 | |
2612 | |
2619 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2613 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2620 | { |
2614 | { |
2621 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
2615 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
2622 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2616 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2623 | am_transparent = 0; |
2617 | am_transparent = 0; |
2624 | /* XXX: also turn off Opt_transparent? */ |
2618 | /* XXX: also turn off Opt_transparent? */ |
2625 | } |
2619 | } |
2626 | else |
2620 | else |
2627 | { |
2621 | { |
2628 | #if WAIT_FOR_WM |
|
|
2629 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2630 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2631 | sleep (1); |
|
|
2632 | #endif |
|
|
2633 | for (n = 0; n < (unsigned int)i; n++) |
2622 | for (n = 0; n < (unsigned int)i; n++) |
2634 | { |
2623 | { |
2635 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2624 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
2636 | XClearWindow (disp, parent[n]); |
2625 | XClearWindow (xdisp, parent[n]); |
2637 | } |
2626 | } |
2638 | |
2627 | |
2639 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2628 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2640 | am_transparent = 1; |
2629 | am_transparent = 1; |
2641 | } |
2630 | } |
2642 | |
2631 | |
2643 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2632 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2644 | parent[i] = None; |
2633 | parent[i] = None; |
2645 | } |
2634 | } |
2646 | |
2635 | |
2647 | if (scrollBar.win) |
2636 | if (scrollBar.win) |
2648 | { |
2637 | { |
2649 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2638 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
2650 | scrollBar.setIdle (); |
2639 | scrollBar.setIdle (); |
2651 | scrollbar_show (0); |
2640 | scrollbar_show (0); |
2652 | } |
2641 | } |
2653 | |
2642 | |
2654 | if (am_transparent) |
2643 | if (am_transparent) |
… | |
… | |
2666 | |
2655 | |
2667 | bool |
2656 | bool |
2668 | rxvt_term::cmd_parse () |
2657 | rxvt_term::cmd_parse () |
2669 | { |
2658 | { |
2670 | bool flag = false; |
2659 | bool flag = false; |
2671 | unicode_t ch = NOCHAR; |
2660 | wchar_t ch = NOCHAR; |
2672 | unsigned char *seq_begin; // remember start of esc-sequence here |
2661 | char *seq_begin; // remember start of esc-sequence here |
2673 | |
2662 | |
2674 | for (;;) |
2663 | for (;;) |
2675 | { |
2664 | { |
2676 | if (ch == NOCHAR) |
2665 | if (ch == NOCHAR) |
2677 | { |
2666 | { |
2678 | seq_begin = cmdbuf_ptr; |
2667 | seq_begin = cmdbuf_ptr; |
2679 | ch = next_char (); |
2668 | ch = next_char (); |
2680 | } |
|
|
2681 | |
2669 | |
2682 | if (ch == NOCHAR) // TODO: improve |
2670 | if (ch == NOCHAR) |
2683 | break; |
2671 | break; |
|
|
2672 | } |
2684 | |
2673 | |
2685 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2674 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2686 | { |
2675 | { |
2687 | if (!seen_input) |
2676 | if (!seen_input) |
2688 | { |
2677 | { |
… | |
… | |
2697 | if (seen_resize && cmd_pid) |
2686 | if (seen_resize && cmd_pid) |
2698 | kill (-cmd_pid, SIGWINCH); |
2687 | kill (-cmd_pid, SIGWINCH); |
2699 | } |
2688 | } |
2700 | |
2689 | |
2701 | /* Read a text string from the input buffer */ |
2690 | /* Read a text string from the input buffer */ |
2702 | unicode_t buf[UBUFSIZ]; |
2691 | wchar_t buf[UBUFSIZ]; |
2703 | bool refreshnow = false; |
2692 | bool refreshnow = false; |
2704 | int nlines = 0; |
2693 | int nlines = 0; |
2705 | unicode_t *str = buf; |
2694 | wchar_t *str = buf; |
2706 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2695 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2707 | |
2696 | |
2708 | for (;;) |
2697 | for (;;) |
2709 | { |
2698 | { |
2710 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2699 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2711 | break; |
2700 | break; |
… | |
… | |
2729 | } |
2718 | } |
2730 | |
2719 | |
2731 | // scr_add_lines only works for nlines <= nrow - 1. |
2720 | // scr_add_lines only works for nlines <= nrow - 1. |
2732 | if (nlines >= nrow - 1) |
2721 | if (nlines >= nrow - 1) |
2733 | { |
2722 | { |
|
|
2723 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2724 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2734 | scr_add_lines (buf, nlines, str - buf); |
2725 | scr_add_lines (buf, str - buf, nlines); |
|
|
2726 | |
2735 | nlines = 0; |
2727 | nlines = 0; |
2736 | str = buf; |
2728 | str = buf; |
2737 | eol = str + min (ncol, UBUFSIZ); |
2729 | eol = str + min (ncol, UBUFSIZ); |
2738 | } |
2730 | } |
2739 | |
2731 | |
… | |
… | |
2752 | |
2744 | |
2753 | seq_begin = cmdbuf_ptr; |
2745 | seq_begin = cmdbuf_ptr; |
2754 | ch = next_char (); |
2746 | ch = next_char (); |
2755 | } |
2747 | } |
2756 | |
2748 | |
|
|
2749 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2750 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2757 | scr_add_lines (buf, nlines, str - buf); |
2751 | scr_add_lines (buf, str - buf, nlines); |
2758 | |
2752 | |
2759 | /* |
2753 | /* |
2760 | * If there have been a lot of new lines, then update the screen |
2754 | * If there have been a lot of new lines, then update the screen |
2761 | * What the heck I'll cheat and only refresh less than every page-full. |
2755 | * What the heck I'll cheat and only refresh less than every page-full. |
2762 | * the number of pages between refreshes is refresh_limit, which |
2756 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2767 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2761 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2768 | refresh_limit++; |
2762 | refresh_limit++; |
2769 | else |
2763 | else |
2770 | { |
2764 | { |
2771 | flag = true; |
2765 | flag = true; |
2772 | scr_refresh (refresh_type); |
2766 | scr_refresh (); |
2773 | flush_ev.stop (); |
2767 | want_refresh = 1; |
2774 | } |
2768 | } |
2775 | } |
2769 | } |
2776 | |
2770 | |
2777 | } |
2771 | } |
2778 | else |
2772 | else |
… | |
… | |
2793 | } |
2787 | } |
2794 | |
2788 | |
2795 | return flag; |
2789 | return flag; |
2796 | } |
2790 | } |
2797 | |
2791 | |
2798 | // read the next octet |
|
|
2799 | unicode_t |
|
|
2800 | rxvt_term::next_octet () |
|
|
2801 | { |
|
|
2802 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2803 | ? *cmdbuf_ptr++ |
|
|
2804 | : NOCHAR; |
|
|
2805 | } |
|
|
2806 | |
|
|
2807 | // read the next character |
2792 | // read the next character |
2808 | unicode_t |
2793 | wchar_t |
2809 | rxvt_term::next_char () |
2794 | rxvt_term::next_char () NOTHROW |
2810 | { |
2795 | { |
2811 | while (cmdbuf_ptr < cmdbuf_endp) |
2796 | while (cmdbuf_ptr < cmdbuf_endp) |
2812 | { |
2797 | { |
2813 | // assume 7-bit to be ascii ALWAYS |
2798 | // assume 7-bit to be ascii ALWAYS |
2814 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2799 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2815 | return *cmdbuf_ptr++; |
2800 | return *cmdbuf_ptr++; |
2816 | |
2801 | |
2817 | wchar_t wc; |
2802 | wchar_t wc; |
2818 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2803 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2819 | |
2804 | |
2820 | if (len == (size_t)-2) |
2805 | if (len == (size_t)-2) |
2821 | { |
2806 | { |
2822 | // the mbstate stores incomplete sequences. didn't know this :/ |
2807 | // the mbstate stores incomplete sequences. didn't know this :/ |
2823 | cmdbuf_ptr = cmdbuf_endp; |
2808 | cmdbuf_ptr = cmdbuf_endp; |
2824 | break; |
2809 | break; |
2825 | } |
2810 | } |
2826 | |
2811 | |
2827 | if (len == (size_t)-1) |
2812 | if (len == (size_t)-1) |
2828 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2813 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2829 | |
2814 | |
2830 | // assume wchar == unicode |
2815 | // assume wchar == unicode |
2831 | cmdbuf_ptr += len; |
2816 | cmdbuf_ptr += len; |
2832 | return wc & UNICODE_MASK; |
2817 | return wc & UNICODE_MASK; |
2833 | } |
2818 | } |
2834 | |
2819 | |
2835 | return NOCHAR; |
2820 | return NOCHAR; |
2836 | } |
2821 | } |
|
|
2822 | |
|
|
2823 | // read the next octet |
|
|
2824 | uint32_t |
|
|
2825 | rxvt_term::next_octet () NOTHROW |
|
|
2826 | { |
|
|
2827 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2828 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2829 | : NOCHAR; |
|
|
2830 | } |
|
|
2831 | |
|
|
2832 | static class out_of_input out_of_input; |
2837 | |
2833 | |
2838 | /* rxvt_cmd_getc () - Return next input character */ |
2834 | /* rxvt_cmd_getc () - Return next input character */ |
2839 | /* |
2835 | /* |
2840 | * Return the next input character after first passing any keyboard input |
2836 | * Return the next input character after first passing any keyboard input |
2841 | * to the command. |
2837 | * to the command. |
2842 | */ |
2838 | */ |
2843 | unicode_t |
2839 | wchar_t |
2844 | rxvt_term::cmd_getc () |
2840 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2845 | { |
2841 | { |
2846 | unicode_t c = next_char (); |
2842 | wchar_t c = next_char (); |
2847 | |
2843 | |
2848 | if (c == NOCHAR) |
2844 | if (c == NOCHAR) |
2849 | throw out_of_input; |
2845 | throw out_of_input; |
2850 | |
2846 | |
2851 | return c; |
2847 | return c; |
2852 | } |
2848 | } |
2853 | |
2849 | |
2854 | unicode_t |
2850 | uint32_t |
2855 | rxvt_term::cmd_get8 () |
2851 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2856 | { |
2852 | { |
2857 | unicode_t c = next_octet (); |
2853 | uint32_t c = next_octet (); |
2858 | |
2854 | |
2859 | if (c == NOCHAR) |
2855 | if (c == NOCHAR) |
2860 | throw out_of_input; |
2856 | throw out_of_input; |
2861 | |
2857 | |
2862 | return c; |
2858 | return c; |
… | |
… | |
2962 | case C0_ESC: |
2958 | case C0_ESC: |
2963 | process_escape_seq (); |
2959 | process_escape_seq (); |
2964 | break; |
2960 | break; |
2965 | case C0_ENQ: /* terminal Status */ |
2961 | case C0_ENQ: /* terminal Status */ |
2966 | if (rs[Rs_answerbackstring]) |
2962 | if (rs[Rs_answerbackstring]) |
2967 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2963 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2968 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2969 | else |
2964 | else |
2970 | tt_write ((unsigned char *)VT100_ANS, |
2965 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2971 | (unsigned int)strlen (VT100_ANS)); |
|
|
2972 | break; |
2966 | break; |
2973 | case C0_BEL: /* bell */ |
2967 | case C0_BEL: /* bell */ |
2974 | scr_bell (); |
2968 | scr_bell (); |
2975 | break; |
2969 | break; |
2976 | case C0_BS: /* backspace */ |
2970 | case C0_BS: /* backspace */ |
… | |
… | |
3100 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3094 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3101 | break; |
3095 | break; |
3102 | case '+': |
3096 | case '+': |
3103 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3097 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3104 | break; |
3098 | break; |
3105 | #if ENABLE_FRILLS |
3099 | #if !ENABLE_MINIMAL |
3106 | case '6': |
3100 | case '6': |
3107 | scr_backindex (); |
3101 | scr_backindex (); |
3108 | break; |
3102 | break; |
3109 | #endif |
3103 | #endif |
3110 | case '7': |
3104 | case '7': |
3111 | scr_cursor (SAVE); |
3105 | scr_cursor (SAVE); |
3112 | break; |
3106 | break; |
3113 | case '8': |
3107 | case '8': |
3114 | scr_cursor (RESTORE); |
3108 | scr_cursor (RESTORE); |
3115 | break; |
3109 | break; |
3116 | #if ENABLE_FRILLS |
3110 | #if !ENABLE_MINIMAL |
3117 | case '9': |
3111 | case '9': |
3118 | scr_forwardindex (); |
3112 | scr_forwardindex (); |
3119 | break; |
3113 | break; |
3120 | #endif |
3114 | #endif |
3121 | case '=': |
3115 | case '=': |
… | |
… | |
3131 | break; |
3125 | break; |
3132 | |
3126 | |
3133 | /* 8.3.87: NEXT LINE */ |
3127 | /* 8.3.87: NEXT LINE */ |
3134 | case C1_NEL: /* ESC E */ |
3128 | case C1_NEL: /* ESC E */ |
3135 | { |
3129 | { |
3136 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3130 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3137 | scr_add_lines (nlcr, 1, 2); |
3131 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3138 | } |
3132 | } |
3139 | break; |
3133 | break; |
3140 | |
3134 | |
3141 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3135 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3142 | case C1_ESA: /* ESC G */ |
3136 | case C1_ESA: /* ESC G */ |
… | |
… | |
3164 | process_dcs_seq (); |
3158 | process_dcs_seq (); |
3165 | break; |
3159 | break; |
3166 | |
3160 | |
3167 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3161 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3168 | case C1_SCI: /* ESC Z */ |
3162 | case C1_SCI: /* ESC Z */ |
3169 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3163 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3170 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3171 | break; /* steal obsolete ESC [ c */ |
3164 | break; /* steal obsolete ESC [ c */ |
3172 | |
3165 | |
3173 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3166 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3174 | case C1_CSI: /* ESC [ */ |
3167 | case C1_CSI: /* ESC [ */ |
3175 | process_csi_seq (); |
3168 | process_csi_seq (); |
… | |
… | |
3284 | ndef = get_byte_array_bit (csi_defaults, i); |
3277 | ndef = get_byte_array_bit (csi_defaults, i); |
3285 | for (p = 0; p < nargs; p++) |
3278 | for (p = 0; p < nargs; p++) |
3286 | if (arg[p] == -1) |
3279 | if (arg[p] == -1) |
3287 | arg[p] = ndef; |
3280 | arg[p] = ndef; |
3288 | |
3281 | |
3289 | #ifdef DEBUG_CMD |
|
|
3290 | fprintf (stderr, "CSI "); |
|
|
3291 | for (p = 0; p < nargs; p++) |
|
|
3292 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3293 | fprintf (stderr, "%c\n", ch); |
|
|
3294 | #endif |
|
|
3295 | |
|
|
3296 | /* |
3282 | /* |
3297 | * private mode handling |
3283 | * private mode handling |
3298 | */ |
3284 | */ |
3299 | if (priv) |
3285 | if (priv) |
3300 | { |
3286 | { |
3301 | switch (priv) |
3287 | switch (priv) |
3302 | { |
3288 | { |
3303 | case '>': |
3289 | case '>': |
3304 | if (ch == CSI_DA) /* secondary device attributes */ |
3290 | if (ch == CSI_DA) /* secondary device attributes */ |
3305 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3291 | { |
|
|
3292 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3293 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
3294 | // |
|
|
3295 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3296 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3297 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3298 | // |
|
|
3299 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
3300 | } |
3306 | break; |
3301 | break; |
3307 | case '?': |
3302 | case '?': |
3308 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3303 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3309 | process_terminal_mode (ch, priv, nargs, arg); |
3304 | process_terminal_mode (ch, priv, nargs, arg); |
3310 | break; |
3305 | break; |
… | |
… | |
3419 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3414 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3420 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3415 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3421 | break; |
3416 | break; |
3422 | |
3417 | |
3423 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3418 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3424 | tt_write ((const unsigned char *)VT100_ANS, |
3419 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3425 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3426 | break; |
3420 | break; |
3427 | |
3421 | |
3428 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3422 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3429 | process_sgr_mode (nargs, arg); |
3423 | process_sgr_mode (nargs, arg); |
3430 | break; |
3424 | break; |
… | |
… | |
3514 | break; |
3508 | break; |
3515 | case CSI_75: |
3509 | case CSI_75: |
3516 | scr_cursor (RESTORE); |
3510 | scr_cursor (RESTORE); |
3517 | break; |
3511 | break; |
3518 | |
3512 | |
3519 | #if ENABLE_FRILLS |
3513 | #if !ENABLE_MINIMAL |
3520 | case CSI_74: |
3514 | case CSI_74: |
3521 | process_window_ops (arg, nargs); |
3515 | process_window_ops (arg, nargs); |
3522 | break; |
3516 | break; |
3523 | #endif |
3517 | #endif |
3524 | |
3518 | |
… | |
… | |
3531 | break; |
3525 | break; |
3532 | } |
3526 | } |
3533 | } |
3527 | } |
3534 | /*}}} */ |
3528 | /*}}} */ |
3535 | |
3529 | |
3536 | #if ENABLE_FRILLS |
3530 | #if !ENABLE_MINIMAL |
3537 | /* ARGSUSED */ |
3531 | /* ARGSUSED */ |
3538 | void |
3532 | void |
3539 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3533 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3540 | { |
3534 | { |
3541 | int x, y; |
3535 | int x, y; |
3542 | XWindowAttributes wattr; |
3536 | XWindowAttributes wattr; |
3543 | Window wdummy; |
3537 | Window wdummy; |
3544 | dDisp; |
3538 | |
|
|
3539 | dLocal (Display *, xdisp); |
3545 | |
3540 | |
3546 | if (nargs == 0) |
3541 | if (nargs == 0) |
3547 | return; |
3542 | return; |
3548 | |
3543 | |
3549 | switch (args[0]) |
3544 | switch (args[0]) |
3550 | { |
3545 | { |
3551 | /* |
3546 | /* |
3552 | * commands |
3547 | * commands |
3553 | */ |
3548 | */ |
3554 | case 1: /* deiconify window */ |
3549 | case 1: /* deiconify window */ |
3555 | XMapWindow (disp, parent[0]); |
3550 | XMapWindow (xdisp, parent[0]); |
3556 | break; |
3551 | break; |
3557 | case 2: /* iconify window */ |
3552 | case 2: /* iconify window */ |
3558 | XIconifyWindow (disp, parent[0], display->screen); |
3553 | XIconifyWindow (xdisp, parent[0], display->screen); |
3559 | break; |
3554 | break; |
3560 | case 3: /* set position (pixels) */ |
3555 | case 3: /* set position (pixels) */ |
3561 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3556 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3562 | break; |
3557 | break; |
3563 | case 4: /* set size (pixels) */ |
3558 | case 4: /* set size (pixels) */ |
3564 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3559 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3565 | break; |
3560 | break; |
3566 | case 5: /* raise window */ |
3561 | case 5: /* raise window */ |
3567 | XRaiseWindow (disp, parent[0]); |
3562 | XRaiseWindow (xdisp, parent[0]); |
3568 | break; |
3563 | break; |
3569 | case 6: /* lower window */ |
3564 | case 6: /* lower window */ |
3570 | XLowerWindow (disp, parent[0]); |
3565 | XLowerWindow (xdisp, parent[0]); |
3571 | break; |
3566 | break; |
3572 | case 7: /* refresh window */ |
3567 | case 7: /* refresh window */ |
3573 | scr_touch (true); |
3568 | scr_touch (true); |
3574 | break; |
3569 | break; |
3575 | case 8: /* set size (chars) */ |
3570 | case 8: /* set size (chars) */ |
… | |
… | |
3582 | if (args[0] >= 24) /* set height (chars) */ |
3577 | if (args[0] >= 24) /* set height (chars) */ |
3583 | set_widthheight ((unsigned int)width, |
3578 | set_widthheight ((unsigned int)width, |
3584 | (unsigned int) (args[1] * fheight)); |
3579 | (unsigned int) (args[1] * fheight)); |
3585 | break; |
3580 | break; |
3586 | |
3581 | |
3587 | |
|
|
3588 | /* |
3582 | /* |
3589 | * reports - some output format copied from XTerm |
3583 | * reports - some output format copied from XTerm |
3590 | */ |
3584 | */ |
3591 | case 11: /* report window state */ |
3585 | case 11: /* report window state */ |
3592 | XGetWindowAttributes (disp, parent[0], &wattr); |
3586 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3593 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3587 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3594 | break; |
3588 | break; |
3595 | case 13: /* report window position */ |
3589 | case 13: /* report window position */ |
3596 | XGetWindowAttributes (disp, parent[0], &wattr); |
3590 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3597 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3591 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3598 | -wattr.border_width, -wattr.border_width, |
3592 | -wattr.border_width, -wattr.border_width, |
3599 | &x, &y, &wdummy); |
3593 | &x, &y, &wdummy); |
3600 | tt_printf ("\033[3;%d;%dt", x, y); |
3594 | tt_printf ("\033[3;%d;%dt", x, y); |
3601 | break; |
3595 | break; |
3602 | case 14: /* report window size (pixels) */ |
3596 | case 14: /* report window size (pixels) */ |
3603 | XGetWindowAttributes (disp, parent[0], &wattr); |
3597 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3604 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3598 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3605 | break; |
3599 | break; |
3606 | case 18: /* report text area size (chars) */ |
3600 | case 18: /* report text area size (chars) */ |
3607 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3601 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3608 | break; |
3602 | break; |
… | |
… | |
3610 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3604 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3611 | break; |
3605 | break; |
3612 | case 20: /* report icon label */ |
3606 | case 20: /* report icon label */ |
3613 | { |
3607 | { |
3614 | char *s; |
3608 | char *s; |
3615 | XGetIconName (disp, parent[0], &s); |
3609 | XGetIconName (xdisp, parent[0], &s); |
3616 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3610 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3617 | XFree (s); |
3611 | XFree (s); |
3618 | } |
3612 | } |
3619 | break; |
3613 | break; |
3620 | case 21: /* report window title */ |
3614 | case 21: /* report window title */ |
3621 | { |
3615 | { |
3622 | char *s; |
3616 | char *s; |
3623 | XFetchName (disp, parent[0], &s); |
3617 | XFetchName (xdisp, parent[0], &s); |
3624 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3618 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3625 | XFree (s); |
3619 | XFree (s); |
3626 | } |
3620 | } |
3627 | break; |
3621 | break; |
3628 | } |
3622 | } |
… | |
… | |
3632 | /*----------------------------------------------------------------------*/ |
3626 | /*----------------------------------------------------------------------*/ |
3633 | /* |
3627 | /* |
3634 | * get input up until STRING TERMINATOR (or BEL) |
3628 | * get input up until STRING TERMINATOR (or BEL) |
3635 | * ends_how is terminator used. returned input must be free()'d |
3629 | * ends_how is terminator used. returned input must be free()'d |
3636 | */ |
3630 | */ |
3637 | unsigned char * |
3631 | char * |
3638 | rxvt_term::get_to_st (unicode_t &ends_how) |
3632 | rxvt_term::get_to_st (unicode_t &ends_how) |
3639 | { |
3633 | { |
3640 | unicode_t ch; |
3634 | unicode_t ch; |
3641 | bool seen_esc = false; |
3635 | bool seen_esc = false; |
3642 | unsigned int n = 0; |
3636 | unsigned int n = 0; |
… | |
… | |
3675 | |
3669 | |
3676 | string[n++] = '\0'; |
3670 | string[n++] = '\0'; |
3677 | |
3671 | |
3678 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3672 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3679 | |
3673 | |
3680 | return (unsigned char *)rxvt_wcstombs (string); |
3674 | return rxvt_wcstombs (string); |
3681 | } |
3675 | } |
3682 | |
3676 | |
3683 | /*----------------------------------------------------------------------*/ |
3677 | /*----------------------------------------------------------------------*/ |
3684 | /* |
3678 | /* |
3685 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3679 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3686 | */ |
3680 | */ |
3687 | void |
3681 | void |
3688 | rxvt_term::process_dcs_seq () |
3682 | rxvt_term::process_dcs_seq () |
3689 | { |
3683 | { |
3690 | unsigned char *s; |
3684 | char *s; |
3691 | unicode_t eh; |
3685 | unicode_t eh; |
3692 | |
3686 | |
3693 | /* |
3687 | /* |
3694 | * Not handled yet |
3688 | * Not handled yet |
3695 | */ |
3689 | */ |
… | |
… | |
3714 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3708 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3715 | arg = arg * 10 + (ch - '0'); |
3709 | arg = arg * 10 + (ch - '0'); |
3716 | |
3710 | |
3717 | if (ch == ';') |
3711 | if (ch == ';') |
3718 | { |
3712 | { |
3719 | unsigned char *s = get_to_st (eh); |
3713 | char *s = get_to_st (eh); |
3720 | |
3714 | |
3721 | if (s) |
3715 | if (s) |
3722 | { |
3716 | { |
3723 | process_xterm_seq (arg, (char *)s, eh); |
3717 | process_xterm_seq (arg, s, eh); |
3724 | free (s); |
3718 | free (s); |
3725 | } |
3719 | } |
3726 | } |
3720 | } |
3727 | } |
3721 | } |
3728 | |
3722 | |
3729 | void |
3723 | void |
3730 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3724 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3731 | { |
3725 | { |
3732 | if (str[0] == '?' && !str[1]) |
3726 | if (str[0] == '?' && !str[1]) |
3733 | { |
3727 | { |
3734 | unsigned short r, g, b; |
3728 | rgba c; |
3735 | pix_colors_focused[color].get (display, r, g, b); |
3729 | pix_colors_focused[color].get (c); |
|
|
3730 | |
|
|
3731 | #if XFT |
|
|
3732 | if (c.a != rgba::MAX_CC) |
|
|
3733 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3734 | else |
|
|
3735 | #endif |
3736 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3736 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3737 | } |
3737 | } |
3738 | else |
3738 | else |
3739 | set_window_color (color, str); |
3739 | set_window_color (color, str); |
3740 | } |
3740 | } |
3741 | |
3741 | |
3742 | /* |
3742 | /* |
3743 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3743 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3744 | */ |
3744 | */ |
3745 | void |
3745 | void |
3746 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3746 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3747 | { |
3747 | { |
3748 | int changed = 0; |
|
|
3749 | int color; |
3748 | int color; |
3750 | char *buf, *name; |
3749 | char *buf, *name; |
3751 | bool query = str[0] == '?' && !str[1]; |
3750 | bool query = str[0] == '?' && !str[1]; |
3752 | int saveop = op; |
3751 | int saveop = op; |
3753 | dDisp; |
3752 | |
|
|
3753 | dLocal (Display *, xdisp); |
3754 | |
3754 | |
3755 | assert (str != NULL); |
3755 | assert (str != NULL); |
3756 | switch (op) |
3756 | switch (op) |
3757 | { |
3757 | { |
3758 | case XTerm_name: |
3758 | case XTerm_name: |
… | |
… | |
3774 | unsigned long bytes_after; |
3774 | unsigned long bytes_after; |
3775 | unsigned char *value = 0; |
3775 | unsigned char *value = 0; |
3776 | const char *str = ""; |
3776 | const char *str = ""; |
3777 | |
3777 | |
3778 | if (prop |
3778 | if (prop |
3779 | && XGetWindowProperty (disp, parent[0], |
3779 | && XGetWindowProperty (xdisp, parent[0], |
3780 | prop, 0, 1<<16, 0, AnyPropertyType, |
3780 | prop, 0, 1<<16, 0, AnyPropertyType, |
3781 | &actual_type, &actual_format, |
3781 | &actual_type, &actual_format, |
3782 | &nitems, &bytes_after, &value) == Success |
3782 | &nitems, &bytes_after, &value) == Success |
3783 | && actual_type != None |
3783 | && actual_type != None |
3784 | && actual_format == 8) |
3784 | && actual_format == 8) |
3785 | str = (const char *)(value); |
3785 | str = (const char *)(value); |
3786 | |
3786 | |
3787 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3787 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3788 | |
3788 | |
3789 | XFree (value); |
3789 | XFree (value); |
3790 | } |
3790 | } |
3791 | else |
3791 | else |
3792 | { |
3792 | { |
… | |
… | |
3796 | { |
3796 | { |
3797 | *eq = 0; |
3797 | *eq = 0; |
3798 | set_utf8_property (display->atom (str), eq + 1); |
3798 | set_utf8_property (display->atom (str), eq + 1); |
3799 | } |
3799 | } |
3800 | else |
3800 | else |
3801 | XDeleteProperty (disp, parent[0], |
3801 | XDeleteProperty (xdisp, parent[0], |
3802 | display->atom (str)); |
3802 | display->atom (str)); |
3803 | } |
3803 | } |
3804 | break; |
3804 | break; |
3805 | |
3805 | |
3806 | case XTerm_Color: |
3806 | case XTerm_Color: |
… | |
… | |
3808 | { |
3808 | { |
3809 | if ((name = strchr (buf, ';')) == NULL) |
3809 | if ((name = strchr (buf, ';')) == NULL) |
3810 | break; |
3810 | break; |
3811 | |
3811 | |
3812 | *name++ = '\0'; |
3812 | *name++ = '\0'; |
3813 | color = atoi (buf); |
3813 | color = atoi (buf) + minCOLOR; |
3814 | |
3814 | |
3815 | if (color < 0 || color >= TOTAL_COLORS) |
3815 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3816 | break; |
3816 | break; |
3817 | |
3817 | |
3818 | if ((buf = strchr (name, ';')) != NULL) |
3818 | if ((buf = strchr (name, ';')) != NULL) |
3819 | *buf++ = '\0'; |
3819 | *buf++ = '\0'; |
3820 | |
3820 | |
3821 | if (name[0] == '?' && !name[1]) |
3821 | process_color_seq (op, color, name, resp); |
3822 | { |
|
|
3823 | unsigned short r, g, b; |
|
|
3824 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3825 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3826 | } |
|
|
3827 | else |
|
|
3828 | set_window_color (color + minCOLOR, name); |
|
|
3829 | } |
3822 | } |
3830 | break; |
3823 | break; |
3831 | case XTerm_Color00: |
3824 | case XTerm_Color00: |
3832 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3825 | process_color_seq (op, Color_fg, str, resp); |
3833 | break; |
3826 | break; |
3834 | case XTerm_Color01: |
3827 | case XTerm_Color01: |
3835 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3828 | process_color_seq (op, Color_bg, str, resp); |
3836 | break; |
3829 | break; |
3837 | #ifndef NO_CURSORCOLOR |
3830 | #ifndef NO_CURSORCOLOR |
3838 | case XTerm_Color_cursor: |
3831 | case XTerm_Color_cursor: |
3839 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3832 | process_color_seq (op, Color_cursor, str, resp); |
3840 | break; |
3833 | break; |
3841 | #endif |
3834 | #endif |
3842 | case XTerm_Color_pointer_fg: |
3835 | case XTerm_Color_pointer_fg: |
3843 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3836 | process_color_seq (op, Color_pointer_fg, str, resp); |
3844 | break; |
3837 | break; |
3845 | case XTerm_Color_pointer_bg: |
3838 | case XTerm_Color_pointer_bg: |
3846 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3839 | process_color_seq (op, Color_pointer_bg, str, resp); |
3847 | break; |
3840 | break; |
3848 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3841 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3849 | case XTerm_Color_BD: |
|
|
3850 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3851 | break; |
|
|
3852 | case XTerm_Color_UL: |
|
|
3853 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3854 | break; |
|
|
3855 | case XTerm_Color_RV: |
3842 | case XTerm_Color_RV: |
3856 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3843 | process_color_seq (op, Color_RV, str, resp); |
|
|
3844 | break; |
|
|
3845 | case Rxvt_Color_BD: |
|
|
3846 | case URxvt_Color_BD: |
|
|
3847 | process_color_seq (op, Color_BD, str, resp); |
|
|
3848 | break; |
|
|
3849 | case Rxvt_Color_UL: |
|
|
3850 | case URxvt_Color_UL: |
|
|
3851 | process_color_seq (op, Color_UL, str, resp); |
3857 | break; |
3852 | break; |
3858 | case URxvt_Color_IT: |
3853 | case URxvt_Color_IT: |
3859 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3854 | process_color_seq (op, Color_IT, str, resp); |
3860 | break; |
3855 | break; |
3861 | #endif |
3856 | #endif |
3862 | #if TRANSPARENT && TINTING |
3857 | #if TRANSPARENT && TINTING |
3863 | case URxvt_Color_tint: |
3858 | case URxvt_Color_tint: |
3864 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3859 | process_color_seq (op, Color_tint, str, resp); |
|
|
3860 | |
3865 | check_our_parents (); |
3861 | check_our_parents (); |
|
|
3862 | |
3866 | if (am_transparent) |
3863 | if (am_transparent) |
3867 | want_full_refresh = want_refresh = 1; |
3864 | want_full_refresh = want_refresh = 1; |
3868 | break; |
|
|
3869 | #endif |
|
|
3870 | |
3865 | |
|
|
3866 | break; |
|
|
3867 | #endif |
|
|
3868 | |
3871 | case XTerm_Pixmap: |
3869 | case Rxvt_Pixmap: |
|
|
3870 | { |
3872 | if (*str != ';') |
3871 | if (*str != ';') |
3873 | { |
3872 | { |
3874 | #if XPM_BACKGROUND |
3873 | #if XPM_BACKGROUND |
3875 | scale_pixmap (""); /* reset to default scaling */ |
3874 | scale_pixmap (""); /* reset to default scaling */ |
3876 | set_bgPixmap (str); /* change pixmap */ |
3875 | set_bgPixmap (str); /* change pixmap */ |
3877 | #endif |
|
|
3878 | scr_touch (true); |
3876 | scr_touch (true); |
|
|
3877 | #endif |
3879 | } |
3878 | } |
|
|
3879 | |
|
|
3880 | int changed = 0; |
|
|
3881 | |
3880 | while ((str = strchr (str, ';')) != NULL) |
3882 | while ((str = strchr (str, ';')) != NULL) |
3881 | { |
3883 | { |
3882 | str++; |
3884 | str++; |
3883 | #if XPM_BACKGROUND |
3885 | #if XPM_BACKGROUND |
3884 | changed += scale_pixmap (str); |
3886 | changed += scale_pixmap (str); |
3885 | #endif |
3887 | #endif |
3886 | } |
3888 | } |
3887 | |
3889 | |
3888 | if (changed) |
3890 | if (changed) |
3889 | { |
3891 | { |
3890 | #ifdef XPM_BACKGROUND |
3892 | #ifdef XPM_BACKGROUND |
3891 | resize_pixmap (); |
3893 | resize_pixmap (); |
3892 | #endif |
|
|
3893 | scr_touch (true); |
3894 | scr_touch (true); |
|
|
3895 | #endif |
3894 | } |
3896 | } |
|
|
3897 | } |
3895 | break; |
3898 | break; |
3896 | |
3899 | |
3897 | case XTerm_restoreFG: |
3900 | case Rxvt_restoreFG: |
3898 | set_window_color (Color_fg, str); |
3901 | set_window_color (Color_fg, str); |
3899 | break; |
3902 | break; |
3900 | case XTerm_restoreBG: |
3903 | case Rxvt_restoreBG: |
3901 | set_window_color (Color_bg, str); |
3904 | set_window_color (Color_bg, str); |
3902 | break; |
3905 | break; |
3903 | |
3906 | |
3904 | case XTerm_logfile: |
3907 | case XTerm_logfile: |
3905 | // TODO, when secure mode? |
3908 | // TODO, when secure mode? |
3906 | break; |
3909 | break; |
3907 | |
3910 | |
3908 | #ifdef MENUBAR |
|
|
3909 | case URxvt_Menu: |
|
|
3910 | if (OPTION (Opt_insecure)) |
|
|
3911 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3912 | break; |
|
|
3913 | #endif |
|
|
3914 | #if 0 |
3911 | #if 0 |
3915 | case XTerm_dumpscreen: /* no error notices */ |
3912 | case Rxvt_dumpscreen: /* no error notices */ |
3916 | { |
3913 | { |
3917 | int fd; |
3914 | int fd; |
3918 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3915 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3919 | { |
3916 | { |
3920 | scr_dump (fd); |
3917 | scr_dump (fd); |
… | |
… | |
3944 | allocated.push_back ((void *)res); |
3941 | allocated.push_back ((void *)res); |
3945 | set_fonts (); |
3942 | set_fonts (); |
3946 | } |
3943 | } |
3947 | break; |
3944 | break; |
3948 | |
3945 | |
3949 | #if ENABLE_FRILLS |
3946 | case URxvt_version: |
|
|
3947 | if (query) |
|
|
3948 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3949 | op, |
|
|
3950 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3951 | resp); |
|
|
3952 | break; |
|
|
3953 | |
|
|
3954 | #if !ENABLE_MINIMAL |
3950 | case URxvt_locale: |
3955 | case URxvt_locale: |
3951 | if (query) |
3956 | if (query) |
3952 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3957 | tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); |
3953 | else |
3958 | else |
3954 | { |
3959 | { |
3955 | set_locale (str); |
3960 | set_locale (str); |
3956 | pty.set_utf8_mode (enc_utf8); |
3961 | pty->set_utf8_mode (enc_utf8); |
3957 | init_xlocale (); |
3962 | init_xlocale (); |
3958 | } |
3963 | } |
3959 | break; |
3964 | break; |
3960 | |
3965 | |
3961 | case URxvt_view_up: |
3966 | case URxvt_view_up: |
3962 | case URxvt_view_down: |
3967 | case URxvt_view_down: |
|
|
3968 | { |
3963 | int lines = atoi (str); |
3969 | int lines = atoi (str); |
3964 | |
3970 | |
3965 | if (lines) |
3971 | if (lines) |
3966 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3972 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3967 | else |
3973 | else |
3968 | { |
|
|
3969 | scr_erase_savelines (); |
3974 | scr_erase_savelines (); |
3970 | } |
3975 | } |
3971 | |
3976 | |
|
|
3977 | break; |
|
|
3978 | #endif |
|
|
3979 | |
|
|
3980 | #if ENABLE_PERL |
|
|
3981 | case URxvt_perl: |
|
|
3982 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
3983 | ; // no responses yet |
3972 | break; |
3984 | break; |
3973 | #endif |
3985 | #endif |
3974 | } |
3986 | } |
3975 | } |
3987 | } |
3976 | /*----------------------------------------------------------------------*/ |
3988 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4007 | return state; |
4019 | return state; |
4008 | } |
4020 | } |
4009 | |
4021 | |
4010 | /* we're not using priv _yet_ */ |
4022 | /* we're not using priv _yet_ */ |
4011 | void |
4023 | void |
4012 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4024 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4013 | { |
4025 | { |
4014 | unsigned int i, j; |
4026 | unsigned int i, j; |
4015 | int state; |
4027 | int state; |
4016 | |
4028 | |
4017 | static const struct |
4029 | static const struct |
… | |
… | |
4028 | { 5, PrivMode_rVideo }, |
4040 | { 5, PrivMode_rVideo }, |
4029 | { 6, PrivMode_relOrigin }, |
4041 | { 6, PrivMode_relOrigin }, |
4030 | { 7, PrivMode_Autowrap }, |
4042 | { 7, PrivMode_Autowrap }, |
4031 | // 8, bi-directional support mode |
4043 | // 8, bi-directional support mode |
4032 | { 9, PrivMode_MouseX10 }, |
4044 | { 9, PrivMode_MouseX10 }, |
4033 | #ifdef menuBar_esc |
|
|
4034 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4035 | #endif |
|
|
4036 | // 18, 19 printing-related |
4045 | // 18, 19 printing-related |
4037 | { 25, PrivMode_VisibleCursor }, |
4046 | { 25, PrivMode_VisibleCursor }, |
4038 | #ifdef scrollBar_esc |
4047 | #ifdef scrollBar_esc |
4039 | { scrollBar_esc, PrivMode_scrollBar }, |
4048 | { scrollBar_esc, PrivMode_scrollBar }, |
4040 | #endif |
4049 | #endif |
… | |
… | |
4087 | /* extra handling for values with state unkept */ |
4096 | /* extra handling for values with state unkept */ |
4088 | switch (arg[i]) |
4097 | switch (arg[i]) |
4089 | { |
4098 | { |
4090 | #if ENABLE_STYLES |
4099 | #if ENABLE_STYLES |
4091 | case 1021: |
4100 | case 1021: |
4092 | if (mode) |
4101 | set_option (Opt_intensityStyles, mode); |
4093 | SET_OPTION (Opt_intensityStyles); |
|
|
4094 | else |
|
|
4095 | CLR_OPTION (Opt_intensityStyles); |
|
|
4096 | |
4102 | |
4097 | scr_touch (true); |
4103 | scr_touch (true); |
4098 | break; |
4104 | break; |
4099 | #endif |
4105 | #endif |
4100 | case 1048: /* alternative cursor save */ |
4106 | case 1048: /* alternative cursor save */ |
… | |
… | |
4122 | case 3: /* 80/132 */ |
4128 | case 3: /* 80/132 */ |
4123 | if (priv_modes & PrivMode_132OK) |
4129 | if (priv_modes & PrivMode_132OK) |
4124 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4130 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4125 | break; |
4131 | break; |
4126 | case 4: /* smooth scrolling */ |
4132 | case 4: /* smooth scrolling */ |
4127 | if (!state) |
4133 | set_option (Opt_jumpScroll, !state); |
4128 | SET_OPTION (Opt_jumpScroll); |
|
|
4129 | else |
|
|
4130 | CLR_OPTION (Opt_jumpScroll); |
|
|
4131 | break; |
4134 | break; |
4132 | case 5: /* reverse video */ |
4135 | case 5: /* reverse video */ |
4133 | scr_rvideo_mode (state); |
4136 | scr_rvideo_mode (state); |
4134 | break; |
4137 | break; |
4135 | case 6: /* relative/absolute origins */ |
4138 | case 6: /* relative/absolute origins */ |
… | |
… | |
4141 | /* case 8: - auto repeat, can't do on a per window basis */ |
4144 | /* case 8: - auto repeat, can't do on a per window basis */ |
4142 | case 9: /* X10 mouse reporting */ |
4145 | case 9: /* X10 mouse reporting */ |
4143 | if (state) /* orthogonal */ |
4146 | if (state) /* orthogonal */ |
4144 | priv_modes &= ~PrivMode_MouseX11; |
4147 | priv_modes &= ~PrivMode_MouseX11; |
4145 | break; |
4148 | break; |
4146 | #ifdef menuBar_esc |
|
|
4147 | case menuBar_esc: |
|
|
4148 | #ifdef MENUBAR |
|
|
4149 | map_menuBar (state); |
|
|
4150 | #endif |
|
|
4151 | break; |
|
|
4152 | #endif |
|
|
4153 | #ifdef scrollBar_esc |
4149 | #ifdef scrollBar_esc |
4154 | case scrollBar_esc: |
4150 | case scrollBar_esc: |
4155 | if (scrollbar_mapping (state)) |
4151 | if (scrollbar_mapping (state)) |
4156 | { |
4152 | { |
4157 | resize_all_windows (0, 0, 0); |
4153 | resize_all_windows (0, 0, 0); |
… | |
… | |
4176 | #if 0 |
4172 | #if 0 |
4177 | case 1001: |
4173 | case 1001: |
4178 | break; /* X11 mouse highlighting */ |
4174 | break; /* X11 mouse highlighting */ |
4179 | #endif |
4175 | #endif |
4180 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4176 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4181 | if (!state) |
4177 | set_option (Opt_scrollTtyOutput, !state); |
4182 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4183 | else |
|
|
4184 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4185 | break; |
4178 | break; |
4186 | case 1011: /* scroll to bottom on key press */ |
4179 | case 1011: /* scroll to bottom on key press */ |
4187 | if (state) |
4180 | set_option (Opt_scrollTtyKeypress, state); |
4188 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4189 | else |
|
|
4190 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4191 | break; |
4181 | break; |
4192 | case 1047: /* secondary screen w/ clearing last */ |
4182 | case 1047: /* secondary screen w/ clearing last */ |
4193 | if (OPTION (Opt_secondaryScreen)) |
4183 | if (OPTION (Opt_secondaryScreen)) |
4194 | if (current_screen != PRIMARY) |
4184 | if (current_screen != PRIMARY) |
4195 | scr_erase_screen (2); |
4185 | scr_erase_screen (2); |
… | |
… | |
4333 | scr_color (Color_bg, Color_bg); |
4323 | scr_color (Color_bg, Color_bg); |
4334 | break; |
4324 | break; |
4335 | |
4325 | |
4336 | //case 50: // not variable spacing |
4326 | //case 50: // not variable spacing |
4337 | |
4327 | |
4338 | #ifndef NO_BRIGHTCOLOR |
4328 | #if !ENABLE_MINIMAL |
4339 | case 90: |
4329 | case 90: |
4340 | case 91: /* set bright fg color */ |
4330 | case 91: /* set bright fg color */ |
4341 | case 92: |
4331 | case 92: |
4342 | case 93: |
4332 | case 93: |
4343 | case 94: |
4333 | case 94: |
… | |
… | |
4388 | */ |
4378 | */ |
4389 | void |
4379 | void |
4390 | rxvt_term::tt_printf (const char *fmt,...) |
4380 | rxvt_term::tt_printf (const char *fmt,...) |
4391 | { |
4381 | { |
4392 | va_list arg_ptr; |
4382 | va_list arg_ptr; |
4393 | unsigned char buf[256]; |
4383 | char buf[256]; |
4394 | |
4384 | |
4395 | va_start (arg_ptr, fmt); |
4385 | va_start (arg_ptr, fmt); |
4396 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4386 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4397 | va_end (arg_ptr); |
4387 | va_end (arg_ptr); |
4398 | tt_write (buf, strlen (buf)); |
4388 | tt_write (buf, strlen (buf)); |
… | |
… | |
4403 | * or generated by us in response to a query ESC sequence. |
4393 | * or generated by us in response to a query ESC sequence. |
4404 | */ |
4394 | */ |
4405 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4395 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4406 | |
4396 | |
4407 | void |
4397 | void |
4408 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4398 | rxvt_term::tt_write (const char *data, unsigned int len) |
4409 | { |
4399 | { |
|
|
4400 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4401 | return; |
|
|
4402 | |
|
|
4403 | if (pty->pty < 0) |
|
|
4404 | return; |
|
|
4405 | |
4410 | if (v_buflen == 0) |
4406 | if (v_buflen == 0) |
4411 | { |
4407 | { |
4412 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4408 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4413 | |
4409 | |
4414 | if ((unsigned int)written == len) |
4410 | if ((unsigned int)written == len) |
4415 | return; |
4411 | return; |
4416 | |
4412 | |
4417 | data += written; |
4413 | data += written; |
4418 | len -= written; |
4414 | len -= written; |
4419 | } |
4415 | } |
4420 | |
4416 | |
4421 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4417 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4422 | |
4418 | |
4423 | memcpy (v_buffer + v_buflen, data, len); |
4419 | memcpy (v_buffer + v_buflen, data, len); |
4424 | v_buflen += len; |
4420 | v_buflen += len; |
4425 | |
4421 | |
4426 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4422 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4427 | } |
4423 | } |
4428 | |
4424 | |
4429 | void rxvt_term::pty_write () |
4425 | void rxvt_term::pty_write () |
4430 | { |
4426 | { |
4431 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4427 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4432 | |
4428 | |
4433 | if (written > 0) |
4429 | if (written > 0) |
4434 | { |
4430 | { |
4435 | v_buflen -= written; |
4431 | v_buflen -= written; |
4436 | |
4432 | |