1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.C |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
… | |
… | |
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 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
60 | # include "keyboard.h" |
55 | # include "keyboard.h" |
61 | #endif |
56 | #endif |
62 | |
57 | |
63 | #include <csignal> |
58 | #include <csignal> |
64 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
65 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
66 | |
65 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
67 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
69 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
144 | return; |
149 | |
145 | |
150 | for (;;) |
146 | for (;;) |
151 | { |
147 | { |
152 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
153 | |
149 | |
154 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
155 | |
151 | |
156 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
157 | { |
153 | { |
… | |
… | |
230 | # if !UNICODE3 |
226 | # if !UNICODE3 |
231 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
232 | ch = 0xfffd; |
228 | ch = 0xfffd; |
233 | # endif |
229 | # endif |
234 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
235 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
236 | } |
234 | } |
237 | |
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 | // } |
238 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
239 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
240 | |
243 | |
241 | free (fname); |
244 | free (fname); |
242 | |
245 | |
… | |
… | |
268 | mb[0] = ch[0]; |
271 | mb[0] = ch[0]; |
269 | len = 1; |
272 | len = 1; |
270 | } |
273 | } |
271 | |
274 | |
272 | if (len > 0) |
275 | if (len > 0) |
273 | tt_write ((unsigned char *)mb, len); |
276 | tt_write (mb, len); |
274 | else |
277 | else |
275 | scr_bell (); |
278 | scr_bell (); |
276 | } |
279 | } |
277 | |
280 | |
278 | iso14755buf = 0; |
281 | iso14755buf = 0; |
… | |
… | |
295 | |
298 | |
296 | return -1; |
299 | return -1; |
297 | } |
300 | } |
298 | #endif |
301 | #endif |
299 | |
302 | |
300 | /*{{{ Convert the keypress event into a string */ |
|
|
301 | void |
303 | void |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
304 | rxvt_term::key_press (XKeyEvent &ev) |
303 | { |
305 | { |
304 | int ctrl, meta, shft, len; |
306 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
307 | unsigned int newlen; |
306 | KeySym keysym; |
308 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
309 | int valid_keysym; |
311 | unsigned char kbuf[KBUFSZ]; |
310 | char kbuf[KBUFSZ]; |
|
|
311 | |
|
|
312 | #if ISO_14755 |
|
|
313 | if (iso14755buf & ISO_14755_52) |
|
|
314 | return; |
|
|
315 | #endif |
312 | |
316 | |
313 | /* |
317 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
318 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
315 | * escape sequence to toggle the Keypad. |
319 | * escape sequence to toggle the Keypad. |
316 | * |
320 | * |
… | |
… | |
334 | Status status_return; |
338 | Status status_return; |
335 | |
339 | |
336 | #if 0 |
340 | #if 0 |
337 | #ifdef X_HAVE_UTF8_STRING |
341 | #ifdef X_HAVE_UTF8_STRING |
338 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
342 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
339 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
343 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
340 | KBUFSZ, &keysym, &status_return); |
344 | KBUFSZ, &keysym, &status_return); |
341 | else |
345 | else |
342 | #endif |
346 | #endif |
343 | #endif |
347 | #endif |
344 | { |
348 | { |
… | |
… | |
381 | || status_return == XLookupBoth; |
385 | || status_return == XLookupBoth; |
382 | } |
386 | } |
383 | else |
387 | else |
384 | #endif |
388 | #endif |
385 | { |
389 | { |
386 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
390 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
387 | valid_keysym = keysym != NoSymbol; |
391 | valid_keysym = keysym != NoSymbol; |
388 | } |
392 | } |
389 | |
393 | |
390 | if (valid_keysym) |
394 | if (valid_keysym) |
391 | { |
395 | { |
… | |
… | |
443 | scr_move_to (0, 1); |
447 | scr_move_to (0, 1); |
444 | return; |
448 | return; |
445 | } |
449 | } |
446 | else if (keysym == XK_End) |
450 | else if (keysym == XK_End) |
447 | { |
451 | { |
448 | scr_move_to (1, 0); |
452 | scr_move_to (1, 1); |
449 | return; |
453 | return; |
450 | } |
454 | } |
451 | } |
455 | } |
452 | #endif |
456 | #endif |
453 | } |
457 | } |
… | |
… | |
464 | { |
468 | { |
465 | switch (keysym) |
469 | switch (keysym) |
466 | { |
470 | { |
467 | /* normal XTerm key bindings */ |
471 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
472 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
473 | selection_request (ev.time); |
470 | return; |
474 | return; |
471 | #if TODO |
475 | #if TODO |
472 | /* rxvt extras */ |
476 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
477 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
478 | change_font (FONT_UP); |
… | |
… | |
855 | { |
859 | { |
856 | #ifdef META8_OPTION |
860 | #ifdef META8_OPTION |
857 | /* set 8-bit on */ |
861 | /* set 8-bit on */ |
858 | if (meta && (meta_char == 0x80)) |
862 | if (meta && (meta_char == 0x80)) |
859 | { |
863 | { |
860 | unsigned char *ch; |
864 | char *ch; |
861 | |
865 | |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
866 | for (ch = kbuf; ch < kbuf + len; ch++) |
863 | *ch |= 0x80; |
867 | *ch |= 0x80; |
864 | |
868 | |
865 | meta = 0; |
869 | meta = 0; |
866 | } |
870 | } |
867 | #endif |
871 | #endif |
868 | /* nil */ ; |
872 | /* nil */ ; |
869 | } |
873 | } |
870 | } |
874 | } |
|
|
875 | |
|
|
876 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
877 | return; |
871 | |
878 | |
872 | if (len <= 0) |
879 | if (len <= 0) |
873 | return; /* not mapped */ |
880 | return; /* not mapped */ |
874 | |
881 | |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
882 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
898 | #ifdef META8_OPTION |
905 | #ifdef META8_OPTION |
899 | && meta_char == C0_ESC |
906 | && meta_char == C0_ESC |
900 | #endif |
907 | #endif |
901 | ) |
908 | ) |
902 | { |
909 | { |
903 | const unsigned char ch = C0_ESC; |
910 | const char ch = C0_ESC; |
904 | tt_write (&ch, 1); |
911 | tt_write (&ch, 1); |
905 | } |
912 | } |
906 | |
913 | |
907 | #if defined(DEBUG_CMD) |
|
|
908 | /* Display keyboard buffer contents */ |
|
|
909 | unsigned char *p; |
|
|
910 | int i; |
|
|
911 | |
|
|
912 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
913 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
914 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
915 | fprintf (stderr, "'\n"); |
|
|
916 | #endif /* DEBUG_CMD */ |
|
|
917 | tt_write (kbuf, (unsigned int)len); |
914 | tt_write (kbuf, (unsigned int)len); |
918 | } |
915 | } |
919 | /*}}} */ |
|
|
920 | |
916 | |
|
|
917 | void |
|
|
918 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
919 | { |
|
|
920 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
921 | KeySym keysym; |
|
|
922 | |
|
|
923 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
924 | #endif |
|
|
925 | |
|
|
926 | #if ENABLE_FRILLS || ISO_14755 |
|
|
927 | // ISO 14755 support |
|
|
928 | if (iso14755buf) |
|
|
929 | if (iso14755buf & ISO_14755_52) |
|
|
930 | { |
|
|
931 | # if ENABLE_OVERLAY |
|
|
932 | scr_overlay_off (); |
|
|
933 | # endif |
|
|
934 | # if ISO_14755 |
|
|
935 | // iso14755 part 5.2 handling: release time |
|
|
936 | // first: controls |
|
|
937 | if ((ev.state & ControlMask) |
|
|
938 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
939 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
940 | { |
|
|
941 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
942 | commit_iso14755 (); |
|
|
943 | |
|
|
944 | return; |
|
|
945 | } |
|
|
946 | |
|
|
947 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
948 | if (i[0] == keysym) |
|
|
949 | { |
|
|
950 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
951 | commit_iso14755 (); |
|
|
952 | |
|
|
953 | return; |
|
|
954 | } |
|
|
955 | |
|
|
956 | scr_bell (); |
|
|
957 | # endif |
|
|
958 | iso14755buf = 0; |
|
|
959 | |
|
|
960 | return; |
|
|
961 | } |
|
|
962 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
963 | { |
|
|
964 | # if ENABLE_OVERLAY |
|
|
965 | scr_overlay_off (); |
|
|
966 | # endif |
|
|
967 | if (iso14755buf & ISO_14755_51) |
|
|
968 | commit_iso14755 (); |
|
|
969 | #if ISO_14755 |
|
|
970 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
971 | { |
|
|
972 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
973 | |
|
|
974 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
975 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
976 | } |
|
|
977 | # endif |
|
|
978 | else |
|
|
979 | iso14755buf = 0; |
|
|
980 | } |
|
|
981 | #endif |
|
|
982 | |
|
|
983 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
984 | return; |
|
|
985 | |
|
|
986 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
987 | if (!(ev.state & ControlMask)) |
|
|
988 | slip_wheel_ev.stop (); |
|
|
989 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
990 | mouse_slip_wheel_speed = 0; |
|
|
991 | #endif |
|
|
992 | } |
|
|
993 | |
921 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
994 | #if defined (KEYSYM_RESOURCE) |
922 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
923 | /* attempt to `write' count to the input buffer */ |
|
|
924 | unsigned int |
995 | unsigned int |
925 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
996 | rxvt_term::cmd_write (const char *str, unsigned int count) |
926 | { |
997 | { |
927 | unsigned int n, s; |
998 | unsigned int n, s; |
928 | |
999 | |
929 | n = cmdbuf_ptr - cmdbuf_base; |
1000 | n = cmdbuf_ptr - cmdbuf_base; |
930 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
1001 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
967 | } |
1038 | } |
968 | #endif |
1039 | #endif |
969 | |
1040 | |
970 | if (want_refresh) |
1041 | if (want_refresh) |
971 | { |
1042 | { |
|
|
1043 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
1044 | { |
|
|
1045 | int row = view_start; |
|
|
1046 | int end_row = row + nrow; |
|
|
1047 | |
|
|
1048 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
1049 | --row; |
|
|
1050 | |
|
|
1051 | do |
|
|
1052 | { |
|
|
1053 | int start_row = row; |
|
|
1054 | line_t *l; |
|
|
1055 | |
|
|
1056 | do |
|
|
1057 | { |
|
|
1058 | l = &ROW (row++); |
|
|
1059 | |
|
|
1060 | if (!(l->f & LINE_FILTERED)) |
|
|
1061 | { |
|
|
1062 | // line not filtered, mark it as filtered |
|
|
1063 | l->f |= LINE_FILTERED; |
|
|
1064 | while (l->is_longer ()) |
|
|
1065 | { |
|
|
1066 | l = &ROW (row++); |
|
|
1067 | l->f |= LINE_FILTERED; |
|
|
1068 | } |
|
|
1069 | |
|
|
1070 | // and filter it |
|
|
1071 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1072 | |
|
|
1073 | break; |
|
|
1074 | } |
|
|
1075 | } |
|
|
1076 | while (l->is_longer () && row < end_row); |
|
|
1077 | } |
|
|
1078 | while (row < end_row); |
|
|
1079 | } |
|
|
1080 | |
972 | scr_refresh (refresh_type); |
1081 | scr_refresh (); |
973 | scrollbar_show (1); |
1082 | scrollbar_show (1); |
974 | #ifdef USE_XIM |
1083 | #ifdef USE_XIM |
975 | IMSendSpot (); |
1084 | IMSendSpot (); |
976 | #endif |
1085 | #endif |
977 | } |
1086 | } |
… | |
… | |
980 | } |
1089 | } |
981 | |
1090 | |
982 | void |
1091 | void |
983 | rxvt_term::check_cb (check_watcher &w) |
1092 | rxvt_term::check_cb (check_watcher &w) |
984 | { |
1093 | { |
985 | SET_R (this); |
1094 | make_current (); |
986 | SET_LOCALE (locale); |
|
|
987 | |
1095 | |
988 | display->flush (); |
1096 | display->flush (); |
989 | |
1097 | |
990 | if (want_refresh && !flush_ev.active) |
1098 | if (want_refresh && !flush_ev.active) |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1099 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
992 | } |
1100 | } |
993 | |
1101 | |
994 | void |
1102 | void |
995 | rxvt_term::flush_cb (time_watcher &w) |
1103 | rxvt_term::flush_cb (time_watcher &w) |
996 | { |
1104 | { |
997 | SET_R (this); |
1105 | make_current (); |
998 | SET_LOCALE (locale); |
|
|
999 | |
1106 | |
1000 | refresh_limit = 1; |
1107 | refresh_limit = 1; |
1001 | refresh_count = 0; |
1108 | refresh_count = 0; |
1002 | flush (); |
1109 | flush (); |
1003 | } |
1110 | } |
… | |
… | |
1007 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1114 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1008 | { |
1115 | { |
1009 | hidden_cursor = !hidden_cursor; |
1116 | hidden_cursor = !hidden_cursor; |
1010 | want_refresh = 1; |
1117 | want_refresh = 1; |
1011 | |
1118 | |
1012 | w.start (w.at + BLINK_INTERVAL); |
1119 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1013 | } |
1120 | } |
1014 | #endif |
1121 | #endif |
1015 | |
1122 | |
1016 | #ifdef TEXT_BLINK |
1123 | #ifdef TEXT_BLINK |
1017 | void |
1124 | void |
… | |
… | |
1031 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1138 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1032 | { |
1139 | { |
1033 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1140 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1034 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1141 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1035 | { |
1142 | { |
1036 | refresh_type |= SMOOTH_REFRESH; |
|
|
1037 | want_refresh = 1; |
1143 | want_refresh = 1; |
1038 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1144 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1039 | } |
1145 | } |
1040 | } |
1146 | } |
1041 | #endif |
1147 | #endif |
… | |
… | |
1045 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1151 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1046 | { |
1152 | { |
1047 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1153 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1048 | { |
1154 | { |
1049 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1155 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1050 | refresh_type |= SMOOTH_REFRESH; |
|
|
1051 | want_refresh = 1; |
1156 | want_refresh = 1; |
1052 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1157 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1053 | } |
1158 | } |
1054 | } |
1159 | } |
1055 | #endif |
1160 | #endif |
… | |
… | |
1060 | { |
1165 | { |
1061 | if (mouse_slip_wheel_speed == 0 |
1166 | if (mouse_slip_wheel_speed == 0 |
1062 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1167 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1063 | : scr_page (UP, mouse_slip_wheel_speed)) |
1168 | : scr_page (UP, mouse_slip_wheel_speed)) |
1064 | { |
1169 | { |
1065 | if (view_start == nsaved || |
1170 | if (view_start == top_row || view_start == 0) |
1066 | view_start == 0) |
|
|
1067 | mouse_slip_wheel_speed = 0; |
1171 | mouse_slip_wheel_speed = 0; |
1068 | |
1172 | |
1069 | refresh_type |= SMOOTH_REFRESH; |
|
|
1070 | want_refresh = 1; |
1173 | want_refresh = 1; |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1174 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1072 | } |
1175 | } |
1073 | } |
1176 | } |
1074 | #endif |
1177 | #endif |
1075 | |
1178 | |
1076 | #if HAVE_SCHED_YIELD |
1179 | #if LINUX_YIELD_HACK |
1077 | static struct event_handler |
1180 | static struct event_handler |
1078 | { |
1181 | { |
1079 | check_watcher cw_yield; |
1182 | check_watcher yield_ev; |
1080 | |
1183 | |
1081 | void yield (check_watcher &w) |
1184 | void yield_cb (check_watcher &w) |
1082 | { |
1185 | { |
1083 | sched_yield (); |
1186 | // this should really be sched_yield(), but the linux guys thought |
|
|
1187 | // that giving a process calling sched_yield () less cpu time than |
|
|
1188 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1189 | // allowed by the sus... as is returning ENOSYS. |
|
|
1190 | |
|
|
1191 | struct timespec ts = { 0, 0 }; |
|
|
1192 | nanosleep (&ts, 0); |
|
|
1193 | |
1084 | w.stop (); |
1194 | w.stop (); |
1085 | } |
1195 | } |
1086 | |
1196 | |
1087 | event_handler () |
1197 | event_handler () |
1088 | : cw_yield (this, &event_handler::yield) |
1198 | : yield_ev (this, &event_handler::yield_cb) |
1089 | { |
1199 | { |
1090 | } |
1200 | } |
1091 | } event_handler; |
1201 | } event_handler; |
1092 | #endif |
1202 | #endif |
1093 | |
1203 | |
… | |
… | |
1104 | |
1214 | |
1105 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1215 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1106 | cmdbuf_ptr = cmdbuf_base; |
1216 | cmdbuf_ptr = cmdbuf_base; |
1107 | cmdbuf_endp = cmdbuf_ptr + n; |
1217 | cmdbuf_endp = cmdbuf_ptr + n; |
1108 | |
1218 | |
1109 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1219 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1110 | |
1220 | |
1111 | if (r > 0) |
1221 | if (r > 0) |
1112 | { |
1222 | { |
1113 | cmdbuf_endp += r; |
1223 | cmdbuf_endp += r; |
1114 | return true; |
1224 | return true; |
1115 | } |
1225 | } |
1116 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1226 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1117 | { |
1227 | { |
1118 | #if HAVE_SCHED_YIELD |
1228 | #if LINUX_YIELD_HACK |
1119 | if (display->is_local) |
1229 | if (display->is_local) |
1120 | event_handler.cw_yield.start (); |
1230 | event_handler.yield_ev.start (); |
1121 | #endif |
1231 | #endif |
1122 | } |
1232 | } |
1123 | else |
1233 | else |
1124 | { |
1234 | { |
1125 | pty_ev.stop (); |
1235 | pty_ev.stop (); |
… | |
… | |
1132 | } |
1242 | } |
1133 | |
1243 | |
1134 | void |
1244 | void |
1135 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1245 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1136 | { |
1246 | { |
1137 | SET_R (this); |
1247 | make_current (); |
1138 | SET_LOCALE (locale); |
|
|
1139 | |
1248 | |
1140 | if (revents & EVENT_READ) |
1249 | if (revents & EVENT_READ) |
1141 | // loop, but don't allow a single term to monopolize us |
1250 | // loop, but don't allow a single term to monopolize us |
1142 | while (pty_fill ()) |
1251 | while (pty_fill ()) |
1143 | if (cmd_parse ()) |
1252 | if (cmd_parse ()) |
… | |
… | |
1148 | } |
1257 | } |
1149 | |
1258 | |
1150 | void |
1259 | void |
1151 | rxvt_term::pointer_unblank () |
1260 | rxvt_term::pointer_unblank () |
1152 | { |
1261 | { |
1153 | XDefineCursor (display->display, vt, TermWin_cursor); |
1262 | XDefineCursor (dpy, vt, TermWin_cursor); |
1154 | recolour_cursor (); |
1263 | recolour_cursor (); |
1155 | |
1264 | |
1156 | #ifdef POINTER_BLANK |
1265 | #ifdef POINTER_BLANK |
1157 | hidden_pointer = 0; |
1266 | hidden_pointer = 0; |
1158 | |
1267 | |
… | |
… | |
1163 | |
1272 | |
1164 | #ifdef POINTER_BLANK |
1273 | #ifdef POINTER_BLANK |
1165 | void |
1274 | void |
1166 | rxvt_term::pointer_blank () |
1275 | rxvt_term::pointer_blank () |
1167 | { |
1276 | { |
1168 | if (! OPTION (Opt_pointerBlank)) |
1277 | if (!OPTION (Opt_pointerBlank)) |
1169 | return; |
1278 | return; |
1170 | |
1279 | |
1171 | XDefineCursor (display->display, vt, display->blank_cursor); |
1280 | XDefineCursor (dpy, vt, display->blank_cursor); |
1172 | XFlush (display->display); |
1281 | XFlush (dpy); |
1173 | |
1282 | |
1174 | hidden_pointer = 1; |
1283 | hidden_pointer = 1; |
1175 | } |
1284 | } |
1176 | |
1285 | |
1177 | void |
1286 | void |
1178 | rxvt_term::pointer_cb (time_watcher &w) |
1287 | rxvt_term::pointer_cb (time_watcher &w) |
1179 | { |
1288 | { |
1180 | SET_R (this); |
1289 | make_current (); |
1181 | SET_LOCALE (locale); |
|
|
1182 | |
1290 | |
1183 | pointer_blank (); |
1291 | pointer_blank (); |
1184 | } |
1292 | } |
1185 | #endif |
1293 | #endif |
1186 | |
1294 | |
… | |
… | |
1251 | (32 + button_number + key_state), |
1359 | (32 + button_number + key_state), |
1252 | (32 + x + 1), |
1360 | (32 + x + 1), |
1253 | (32 + y + 1)); |
1361 | (32 + y + 1)); |
1254 | } |
1362 | } |
1255 | |
1363 | |
1256 | #ifdef USING_W11LIB |
|
|
1257 | void |
|
|
1258 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1259 | { |
|
|
1260 | rxvt_t *r = rxvt_get_r (); |
|
|
1261 | |
|
|
1262 | x_cb (*ev); |
|
|
1263 | } |
|
|
1264 | #endif |
|
|
1265 | |
|
|
1266 | /*{{{ process an X event */ |
1364 | /*{{{ process an X event */ |
1267 | void |
1365 | void |
1268 | rxvt_term::x_cb (XEvent &ev) |
1366 | rxvt_term::x_cb (XEvent &ev) |
1269 | { |
1367 | { |
1270 | dDisp; |
1368 | make_current (); |
1271 | |
1369 | |
1272 | SET_R (this); |
1370 | dLocal (Display *, dpy); |
1273 | SET_LOCALE (locale); |
|
|
1274 | |
1371 | |
1275 | #if defined(CURSOR_BLINK) |
1372 | if (ev.xany.window == vt |
1276 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1373 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1277 | { |
1374 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1278 | if (hidden_cursor) |
1375 | return; |
1279 | { |
|
|
1280 | hidden_cursor = 0; |
|
|
1281 | want_refresh = 1; |
|
|
1282 | } |
|
|
1283 | |
1376 | |
1284 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1377 | // for XQueryPointer |
1285 | } |
|
|
1286 | #endif |
|
|
1287 | |
|
|
1288 | #if defined(POINTER_BLANK) |
|
|
1289 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1290 | { |
|
|
1291 | if (ev.type == MotionNotify |
|
|
1292 | || ev.type == ButtonPress |
|
|
1293 | || ev.type == ButtonRelease) |
|
|
1294 | if (hidden_pointer) |
|
|
1295 | pointer_unblank (); |
|
|
1296 | |
|
|
1297 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1298 | pointer_blank (); |
|
|
1299 | } |
|
|
1300 | #endif |
|
|
1301 | |
|
|
1302 | Window unused_root, unused_child; |
1378 | Window unused_root, unused_child; |
1303 | int unused_root_x, unused_root_y; |
1379 | int unused_root_x, unused_root_y; |
1304 | unsigned int unused_mask; |
1380 | unsigned int unused_mask; |
1305 | |
1381 | |
1306 | switch (ev.type) |
1382 | switch (ev.type) |
1307 | { |
1383 | { |
1308 | case KeyPress: |
1384 | case KeyPress: |
1309 | #if ISO_14755 |
1385 | key_press (ev.xkey); |
1310 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1311 | #endif |
|
|
1312 | lookup_key (ev.xkey); |
|
|
1313 | |
|
|
1314 | break; |
1386 | break; |
1315 | |
1387 | |
1316 | case KeyRelease: |
1388 | case KeyRelease: |
1317 | { |
1389 | key_release (ev.xkey); |
1318 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1319 | KeySym ks; |
|
|
1320 | |
|
|
1321 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1322 | #endif |
|
|
1323 | |
|
|
1324 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1325 | // ISO 14755 support |
|
|
1326 | if (iso14755buf) |
|
|
1327 | if (iso14755buf & ISO_14755_52) |
|
|
1328 | { |
|
|
1329 | # if ENABLE_OVERLAY |
|
|
1330 | scr_overlay_off (); |
|
|
1331 | # endif |
|
|
1332 | # if ISO_14755 |
|
|
1333 | // iso14755 part 5.2 handling: release time |
|
|
1334 | // first: controls |
|
|
1335 | if ((ev.xkey.state & ControlMask) |
|
|
1336 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1337 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1338 | { |
|
|
1339 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1340 | commit_iso14755 (); |
|
|
1341 | return; // case-break; |
|
|
1342 | } |
|
|
1343 | |
|
|
1344 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1345 | if (i[0] == ks) |
|
|
1346 | { |
|
|
1347 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1348 | commit_iso14755 (); |
|
|
1349 | return; // case-break; |
|
|
1350 | } |
|
|
1351 | |
|
|
1352 | scr_bell (); |
|
|
1353 | # endif |
|
|
1354 | iso14755buf = 0; |
|
|
1355 | break; |
|
|
1356 | } |
|
|
1357 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1358 | { |
|
|
1359 | # if ENABLE_OVERLAY |
|
|
1360 | scr_overlay_off (); |
|
|
1361 | # endif |
|
|
1362 | if (iso14755buf & ISO_14755_51) |
|
|
1363 | commit_iso14755 (); |
|
|
1364 | #if ISO_14755 |
|
|
1365 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1366 | { |
|
|
1367 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1368 | |
|
|
1369 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1370 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1371 | } |
|
|
1372 | # endif |
|
|
1373 | else |
|
|
1374 | iso14755buf = 0; |
|
|
1375 | } |
|
|
1376 | #endif |
|
|
1377 | |
|
|
1378 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1379 | if (!(ev.xkey.state & ControlMask)) |
|
|
1380 | slip_wheel_ev.stop (); |
|
|
1381 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1382 | mouse_slip_wheel_speed = 0; |
|
|
1383 | #endif |
|
|
1384 | break; |
1390 | break; |
1385 | } |
|
|
1386 | |
1391 | |
1387 | case ButtonPress: |
1392 | case ButtonPress: |
1388 | button_press (ev.xbutton); |
1393 | button_press (ev.xbutton); |
1389 | break; |
1394 | break; |
1390 | |
1395 | |
… | |
… | |
1392 | button_release (ev.xbutton); |
1397 | button_release (ev.xbutton); |
1393 | break; |
1398 | break; |
1394 | |
1399 | |
1395 | case ClientMessage: |
1400 | case ClientMessage: |
1396 | if (ev.xclient.format == 32 |
1401 | if (ev.xclient.format == 32 |
1397 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1402 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1398 | { |
1403 | { |
|
|
1404 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1405 | { |
|
|
1406 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1407 | { |
1399 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1408 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1409 | { |
|
|
1410 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1400 | destroy (); |
1411 | destroy (); |
|
|
1412 | } |
1401 | #if ENABLE_EWMH |
1413 | #if ENABLE_EWMH |
1402 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1414 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1403 | XSendEvent (disp, ev.xclient.window = display->root, |
1415 | XSendEvent (dpy, ev.xclient.window = display->root, |
1404 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1416 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1405 | &ev); |
1417 | &ev); |
|
|
1418 | #endif |
|
|
1419 | } |
|
|
1420 | } |
|
|
1421 | #if ENABLE_XEMBED |
|
|
1422 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1423 | { |
|
|
1424 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1425 | focus_in (); |
|
|
1426 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1427 | focus_out (); |
|
|
1428 | } |
1406 | #endif |
1429 | #endif |
1407 | } |
1430 | } |
1408 | #if ENABLE_XEMBED |
|
|
1409 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1410 | { |
|
|
1411 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1412 | focus_in (); |
|
|
1413 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1414 | focus_out (); |
|
|
1415 | } |
|
|
1416 | #endif |
|
|
1417 | #ifdef OFFIX_DND |
|
|
1418 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1419 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1420 | && (ev.xclient.data.l[0] == DndFile |
|
|
1421 | || ev.xclient.data.l[0] == DndDir |
|
|
1422 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1423 | { |
|
|
1424 | /* Get Dnd data */ |
|
|
1425 | Atom ActualType; |
|
|
1426 | int ActualFormat; |
|
|
1427 | unsigned char *data; |
|
|
1428 | unsigned long Size, RemainingBytes; |
|
|
1429 | |
|
|
1430 | XGetWindowProperty (disp, display->root, |
|
|
1431 | xa[XA_DNDSELECTION], |
|
|
1432 | 0L, 1000000L, |
|
|
1433 | False, AnyPropertyType, |
|
|
1434 | &ActualType, &ActualFormat, |
|
|
1435 | &Size, &RemainingBytes, |
|
|
1436 | &data); |
|
|
1437 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1438 | XFree (data); |
|
|
1439 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1440 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1441 | } |
|
|
1442 | #endif /* OFFIX_DND */ |
|
|
1443 | break; |
1431 | break; |
1444 | |
1432 | |
1445 | case MappingNotify: |
1433 | case MappingNotify: |
1446 | XRefreshKeyboardMapping (&ev.xmapping); |
1434 | XRefreshKeyboardMapping (&ev.xmapping); |
1447 | break; |
1435 | break; |
… | |
… | |
1480 | break; |
1468 | break; |
1481 | |
1469 | |
1482 | case ConfigureNotify: |
1470 | case ConfigureNotify: |
1483 | if (ev.xconfigure.window == parent[0]) |
1471 | if (ev.xconfigure.window == parent[0]) |
1484 | { |
1472 | { |
1485 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1473 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1486 | ; |
1474 | ; |
1487 | |
1475 | |
1488 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1476 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1489 | { |
1477 | { |
1490 | seen_resize = 1; |
1478 | seen_resize = 1; |
1491 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1479 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1492 | } |
1480 | } |
1493 | |
1481 | |
|
|
1482 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1483 | |
1494 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1484 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1495 | if (OPTION (Opt_transparent)) |
1485 | if (OPTION (Opt_transparent)) |
1496 | check_our_parents (); |
1486 | check_our_parents (); |
1497 | #endif |
1487 | #endif |
1498 | } |
1488 | } |
1499 | break; |
1489 | break; |
1500 | |
1490 | |
1501 | case PropertyNotify: |
1491 | case PropertyNotify: |
|
|
1492 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1502 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1493 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1503 | && ev.xproperty.state == PropertyNewValue) |
1494 | && ev.xproperty.state == PropertyNewValue) |
1504 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1495 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1505 | |
1496 | |
1506 | break; |
1497 | break; |
1507 | |
1498 | |
1508 | case SelectionClear: |
1499 | case SelectionClear: |
1509 | selection_clear (); |
1500 | selection_clear (); |
… | |
… | |
1514 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1505 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1515 | break; |
1506 | break; |
1516 | |
1507 | |
1517 | case SelectionRequest: |
1508 | case SelectionRequest: |
1518 | selection_send (ev.xselectionrequest); |
1509 | selection_send (ev.xselectionrequest); |
|
|
1510 | break; |
|
|
1511 | |
|
|
1512 | case MapNotify: |
|
|
1513 | mapped = 1; |
|
|
1514 | #ifdef TEXT_BLINK |
|
|
1515 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1516 | #endif |
|
|
1517 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1519 | break; |
1518 | break; |
1520 | |
1519 | |
1521 | case UnmapNotify: |
1520 | case UnmapNotify: |
1522 | mapped = 0; |
1521 | mapped = 0; |
1523 | #ifdef TEXT_BLINK |
1522 | #ifdef TEXT_BLINK |
1524 | text_blink_ev.stop (); |
1523 | text_blink_ev.stop (); |
1525 | #endif |
1524 | #endif |
1526 | break; |
1525 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1527 | |
|
|
1528 | case MapNotify: |
|
|
1529 | mapped = 1; |
|
|
1530 | #ifdef TEXT_BLINK |
|
|
1531 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1532 | #endif |
|
|
1533 | break; |
1526 | break; |
1534 | |
1527 | |
1535 | #ifdef TRANSPARENT |
1528 | #ifdef TRANSPARENT |
1536 | case ReparentNotify: |
1529 | case ReparentNotify: |
1537 | rootwin_cb (ev); |
1530 | rootwin_cb (ev); |
… | |
… | |
1543 | if (ev.xany.window == vt) |
1536 | if (ev.xany.window == vt) |
1544 | { |
1537 | { |
1545 | do |
1538 | do |
1546 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1539 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1547 | ev.xexpose.width, ev.xexpose.height, False); |
1540 | ev.xexpose.width, ev.xexpose.height, False); |
1548 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1541 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1549 | |
1542 | |
1550 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1543 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1551 | |
1544 | |
1552 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1545 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1553 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1546 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1554 | ev.xexpose.width, ev.xexpose.height, False); |
1547 | ev.xexpose.width, ev.xexpose.height, False); |
1555 | |
1548 | |
1556 | scr_refresh (refresh_type); |
1549 | want_refresh = 1; |
1557 | } |
1550 | } |
1558 | else |
1551 | else |
1559 | { |
1552 | { |
1560 | XEvent unused_event; |
1553 | XEvent unused_event; |
1561 | |
1554 | |
1562 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1555 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1563 | ; |
1556 | ; |
1564 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1557 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1565 | ; |
1558 | ; |
1566 | |
1559 | |
1567 | if (isScrollbarWindow (ev.xany.window)) |
1560 | if (isScrollbarWindow (ev.xany.window)) |
1568 | { |
1561 | { |
1569 | scrollBar.setIdle (); |
1562 | scrollBar.setIdle (); |
1570 | scrollbar_show (0); |
1563 | scrollbar_show (0); |
1571 | } |
1564 | } |
1572 | #ifdef MENUBAR |
|
|
1573 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1574 | menubar_expose (); |
|
|
1575 | #endif |
|
|
1576 | |
1565 | |
1577 | #ifdef TRANSPARENT |
1566 | #ifdef TRANSPARENT |
1578 | if (am_transparent && ev.xany.window == parent[0]) |
1567 | if (am_transparent && ev.xany.window == parent[0]) |
1579 | XClearWindow (disp, ev.xany.window); |
1568 | XClearWindow (dpy, ev.xany.window); |
1580 | #endif |
1569 | #endif |
1581 | } |
1570 | } |
1582 | break; |
1571 | break; |
1583 | |
1572 | |
1584 | case MotionNotify: |
1573 | case MotionNotify: |
1585 | #ifdef POINTER_BLANK |
1574 | #ifdef POINTER_BLANK |
1586 | if (hidden_pointer) |
1575 | if (hidden_pointer) |
1587 | pointer_unblank (); |
1576 | pointer_unblank (); |
1588 | #endif |
1577 | #endif |
1589 | #if MENUBAR |
|
|
1590 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1591 | { |
|
|
1592 | menubar_control (ev.xbutton); |
|
|
1593 | break; |
|
|
1594 | } |
|
|
1595 | #endif |
|
|
1596 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1578 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1597 | break; |
1579 | break; |
1598 | |
1580 | |
1599 | if (ev.xany.window == vt) |
1581 | if (ev.xany.window == vt) |
1600 | { |
1582 | { |
|
|
1583 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1584 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1585 | ; // nop |
1601 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1586 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1602 | { |
1587 | { |
1603 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1588 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1604 | ; |
1589 | ; |
1605 | |
1590 | |
1606 | XQueryPointer (disp, vt, |
1591 | XQueryPointer (dpy, vt, |
1607 | &unused_root, &unused_child, |
1592 | &unused_root, &unused_child, |
1608 | &unused_root_x, &unused_root_y, |
1593 | &unused_root_x, &unused_root_y, |
1609 | &ev.xbutton.x, &ev.xbutton.y, |
1594 | &ev.xbutton.x, &ev.xbutton.y, |
1610 | &ev.xbutton.state); |
1595 | &ev.xbutton.state); |
1611 | #ifdef MOUSE_THRESHOLD |
1596 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1675 | #endif |
1660 | #endif |
1676 | } |
1661 | } |
1677 | } |
1662 | } |
1678 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1663 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1679 | { |
1664 | { |
1680 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1665 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1681 | MotionNotify, &ev)) |
1666 | MotionNotify, &ev)) |
1682 | ; |
1667 | ; |
1683 | |
1668 | |
1684 | XQueryPointer (disp, scrollBar.win, |
1669 | XQueryPointer (dpy, scrollBar.win, |
1685 | &unused_root, &unused_child, |
1670 | &unused_root, &unused_child, |
1686 | &unused_root_x, &unused_root_y, |
1671 | &unused_root_x, &unused_root_y, |
1687 | &ev.xbutton.x, &ev.xbutton.y, |
1672 | &ev.xbutton.x, &ev.xbutton.y, |
1688 | &unused_mask); |
1673 | &unused_mask); |
1689 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1674 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1690 | scrollbar_size ()); |
1675 | scrollbar_size ()); |
1691 | scr_refresh (refresh_type); |
1676 | want_refresh = 1; |
1692 | refresh_limit = 0; |
1677 | refresh_limit = 0; |
1693 | scrollbar_show (1); |
1678 | scrollbar_show (1); |
1694 | } |
1679 | } |
1695 | break; |
1680 | break; |
1696 | } |
1681 | } |
|
|
1682 | |
|
|
1683 | #if defined(CURSOR_BLINK) |
|
|
1684 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1685 | { |
|
|
1686 | if (hidden_cursor) |
|
|
1687 | { |
|
|
1688 | hidden_cursor = 0; |
|
|
1689 | want_refresh = 1; |
|
|
1690 | } |
|
|
1691 | |
|
|
1692 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1693 | } |
|
|
1694 | #endif |
|
|
1695 | |
|
|
1696 | #if defined(POINTER_BLANK) |
|
|
1697 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1698 | { |
|
|
1699 | if (ev.type == MotionNotify |
|
|
1700 | || ev.type == ButtonPress |
|
|
1701 | || ev.type == ButtonRelease) |
|
|
1702 | if (hidden_pointer) |
|
|
1703 | pointer_unblank (); |
|
|
1704 | |
|
|
1705 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1706 | pointer_blank (); |
|
|
1707 | } |
|
|
1708 | #endif |
1697 | } |
1709 | } |
1698 | |
1710 | |
1699 | void |
1711 | void |
1700 | rxvt_term::focus_in () |
1712 | rxvt_term::focus_in () |
1701 | { |
1713 | { |
1702 | if (!focus) |
1714 | if (!focus) |
1703 | { |
1715 | { |
1704 | focus = 1; |
1716 | focus = 1; |
1705 | want_refresh = 1; |
1717 | want_refresh = 1; |
1706 | |
1718 | |
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1719 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1708 | |
1720 | |
1709 | #if USE_XIM |
1721 | #if USE_XIM |
1710 | if (Input_Context != NULL) |
1722 | if (Input_Context != NULL) |
1711 | { |
1723 | { |
1712 | IMSetStatusPosition (); |
1724 | IMSetPosition (); |
1713 | XSetICFocus (Input_Context); |
1725 | XSetICFocus (Input_Context); |
1714 | } |
1726 | } |
1715 | #endif |
1727 | #endif |
1716 | #if CURSOR_BLINK |
1728 | #if CURSOR_BLINK |
1717 | if (OPTION (Opt_cursorBlink)) |
1729 | if (OPTION (Opt_cursorBlink)) |
1718 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1730 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1719 | #endif |
1731 | #endif |
1720 | #if OFF_FOCUS_FADING |
1732 | #if OFF_FOCUS_FADING |
1721 | if (rs[Rs_fade]) |
1733 | if (rs[Rs_fade]) |
1722 | { |
1734 | { |
1723 | pix_colors = pix_colors_focused; |
1735 | pix_colors = pix_colors_focused; |
… | |
… | |
1733 | if (focus) |
1745 | if (focus) |
1734 | { |
1746 | { |
1735 | focus = 0; |
1747 | focus = 0; |
1736 | want_refresh = 1; |
1748 | want_refresh = 1; |
1737 | |
1749 | |
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1750 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1739 | |
1751 | |
1740 | #if ENABLE_FRILLS || ISO_14755 |
1752 | #if ENABLE_FRILLS || ISO_14755 |
1741 | if (iso14755buf) |
1753 | if (iso14755buf) |
1742 | { |
1754 | { |
1743 | iso14755buf = 0; |
1755 | iso14755buf = 0; |
… | |
… | |
1763 | } |
1775 | } |
1764 | #endif |
1776 | #endif |
1765 | } |
1777 | } |
1766 | } |
1778 | } |
1767 | |
1779 | |
1768 | #if TRANSPARENT |
1780 | void |
|
|
1781 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1782 | { |
|
|
1783 | #if OFF_FOCUS_FADING |
|
|
1784 | if (rs[Rs_fade]) |
|
|
1785 | { |
|
|
1786 | rgba c; |
|
|
1787 | pix_colors [Color_fade].get (c); |
|
|
1788 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1789 | } |
|
|
1790 | #endif |
|
|
1791 | } |
|
|
1792 | |
|
|
1793 | #if TRANSPARENT || ENABLE_PERL |
1769 | void |
1794 | void |
1770 | rxvt_term::rootwin_cb (XEvent &ev) |
1795 | rxvt_term::rootwin_cb (XEvent &ev) |
1771 | { |
1796 | { |
1772 | SET_R (this); |
1797 | make_current (); |
1773 | SET_LOCALE (locale); |
|
|
1774 | |
1798 | |
|
|
1799 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1800 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1801 | return; |
|
|
1802 | |
|
|
1803 | # if TRANSPARENT |
1775 | switch (ev.type) |
1804 | switch (ev.type) |
1776 | { |
1805 | { |
1777 | case PropertyNotify: |
1806 | case PropertyNotify: |
1778 | /* |
1807 | /* |
1779 | * if user used some Esetroot compatible prog to set the root bg, |
1808 | * if user used some Esetroot compatible prog to set the root bg, |
… | |
… | |
1787 | case ReparentNotify: |
1816 | case ReparentNotify: |
1788 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1817 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1789 | want_refresh = want_full_refresh = 1; |
1818 | want_refresh = want_full_refresh = 1; |
1790 | break; |
1819 | break; |
1791 | } |
1820 | } |
|
|
1821 | # endif |
1792 | } |
1822 | } |
1793 | #endif |
1823 | #endif |
1794 | |
1824 | |
1795 | void |
1825 | void |
1796 | rxvt_term::button_press (XButtonEvent &ev) |
1826 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1805 | /* |
1835 | /* |
1806 | * VT window processing of button press |
1836 | * VT window processing of button press |
1807 | */ |
1837 | */ |
1808 | if (ev.window == vt) |
1838 | if (ev.window == vt) |
1809 | { |
1839 | { |
|
|
1840 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1841 | return; |
|
|
1842 | |
1810 | #if ISO_14755 |
1843 | #if ISO_14755 |
1811 | // 5.4 |
1844 | // 5.4 |
1812 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1845 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1813 | { |
1846 | { |
1814 | iso14755_54 (ev.x, ev.y); |
1847 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1826 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1859 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1827 | if (ev.button == MEvent.button && clickintime) |
1860 | if (ev.button == MEvent.button && clickintime) |
1828 | { |
1861 | { |
1829 | /* same button, within alloted time */ |
1862 | /* same button, within alloted time */ |
1830 | MEvent.clicks++; |
1863 | MEvent.clicks++; |
|
|
1864 | |
1831 | if (MEvent.clicks > 1) |
1865 | if (MEvent.clicks > 1) |
1832 | { |
1866 | { |
1833 | /* only report double clicks */ |
1867 | /* only report double clicks */ |
1834 | MEvent.clicks = 2; |
1868 | MEvent.clicks = 2; |
1835 | mouse_report (ev); |
1869 | mouse_report (ev); |
… | |
… | |
1855 | else |
1889 | else |
1856 | { |
1890 | { |
1857 | if (ev.button != MEvent.button) |
1891 | if (ev.button != MEvent.button) |
1858 | MEvent.clicks = 0; |
1892 | MEvent.clicks = 0; |
1859 | |
1893 | |
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
|
|
1861 | switch (ev.button) |
1894 | switch (ev.button) |
1862 | { |
1895 | { |
1863 | case Button1: |
1896 | case Button1: |
1864 | /* allow meta + click to select rectangular areas */ |
1897 | /* allow meta + click to select rectangular areas */ |
1865 | /* should be done in screen.C */ |
1898 | /* should be done in screen.C */ |
1866 | #if ENABLE_FRILLS |
1899 | #if ENABLE_FRILLS |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1900 | selection.rect = !!(ev.state & ModMetaMask); |
1868 | #else |
1901 | #else |
1869 | selection.rect = false; |
1902 | selection.rect = false; |
1870 | #endif |
1903 | #endif |
1871 | |
1904 | |
1872 | /* allow shift+left click to extend selection */ |
1905 | /* allow shift+left click to extend selection */ |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1906 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1874 | { |
1907 | { |
1875 | if (MEvent.button == Button1 && clickintime) |
1908 | if (MEvent.button == Button1 && clickintime) |
1876 | selection_rotate (ev.x, ev.y); |
1909 | selection_rotate (ev.x, ev.y); |
1877 | else |
1910 | else |
1878 | selection_extend (ev.x, ev.y, 1); |
1911 | selection_extend (ev.x, ev.y, 1); |
1879 | } |
1912 | } |
1880 | else |
1913 | else |
1881 | { |
1914 | { |
1882 | if (MEvent.button == Button1 && clickintime) |
1915 | if (MEvent.button == Button1 && clickintime) |
1883 | MEvent.clicks++; |
1916 | MEvent.clicks++; |
1884 | else |
1917 | else |
1885 | MEvent.clicks = 1; |
1918 | MEvent.clicks = 1; |
1886 | |
1919 | |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1920 | selection_click (MEvent.clicks, ev.x, ev.y); |
1888 | } |
1921 | } |
1889 | |
1922 | |
1890 | MEvent.button = Button1; |
1923 | MEvent.button = Button1; |
1891 | break; |
1924 | break; |
1892 | |
1925 | |
1893 | case Button3: |
1926 | case Button3: |
1894 | if (MEvent.button == Button3 && clickintime) |
1927 | if (MEvent.button == Button3 && clickintime) |
1895 | selection_rotate (ev.x, ev.y); |
1928 | selection_rotate (ev.x, ev.y); |
1896 | else |
1929 | else |
1897 | selection_extend (ev.x, ev.y, 1); |
1930 | selection_extend (ev.x, ev.y, 1); |
1898 | |
1931 | |
1899 | MEvent.button = Button3; |
1932 | MEvent.button = Button3; |
1900 | break; |
1933 | break; |
1901 | } |
1934 | } |
1902 | } |
1935 | } |
1903 | |
1936 | |
1904 | MEvent.time = ev.time; |
1937 | MEvent.time = ev.time; |
1905 | return; |
1938 | return; |
1906 | } |
1939 | } |
1907 | |
1940 | |
… | |
… | |
2043 | } |
2076 | } |
2044 | |
2077 | |
2045 | break; |
2078 | break; |
2046 | } |
2079 | } |
2047 | } |
2080 | } |
|
|
2081 | |
2048 | return; |
2082 | return; |
2049 | } |
2083 | } |
2050 | #if MENUBAR |
|
|
2051 | /* |
|
|
2052 | * Menubar window processing of button press |
|
|
2053 | */ |
|
|
2054 | if (isMenuBarWindow (ev.window)) |
|
|
2055 | menubar_control (ev); |
|
|
2056 | #endif |
|
|
2057 | } |
2084 | } |
2058 | |
2085 | |
2059 | void |
2086 | void |
2060 | rxvt_term::button_release (XButtonEvent &ev) |
2087 | rxvt_term::button_release (XButtonEvent &ev) |
2061 | { |
2088 | { |
… | |
… | |
2067 | |
2094 | |
2068 | if (scrollbar_isUpDn ()) |
2095 | if (scrollbar_isUpDn ()) |
2069 | { |
2096 | { |
2070 | scrollBar.setIdle (); |
2097 | scrollBar.setIdle (); |
2071 | scrollbar_show (0); |
2098 | scrollbar_show (0); |
2072 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2073 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2074 | #endif |
|
|
2075 | } |
2099 | } |
2076 | |
2100 | |
2077 | #ifdef SELECTION_SCROLLING |
2101 | #ifdef SELECTION_SCROLLING |
2078 | if (sel_scroll_ev.active) |
2102 | if (sel_scroll_ev.active) |
2079 | sel_scroll_ev.stop(); |
2103 | sel_scroll_ev.stop(); |
2080 | #endif |
2104 | #endif |
2081 | |
2105 | |
2082 | if (ev.window == vt) |
2106 | if (ev.window == vt) |
2083 | { |
2107 | { |
|
|
2108 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2109 | return; |
|
|
2110 | |
2084 | #if ISO_14755 |
2111 | #if ISO_14755 |
2085 | // 5.4 |
2112 | // 5.4 |
2086 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2113 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2087 | return; |
2114 | return; |
2088 | #endif |
2115 | #endif |
|
|
2116 | |
2089 | if (reportmode) |
2117 | if (reportmode) |
2090 | { |
2118 | { |
2091 | /* mouse report from vt window */ |
2119 | /* mouse report from vt window */ |
2092 | /* don't report release of wheel "buttons" */ |
2120 | /* don't report release of wheel "buttons" */ |
2093 | if (ev.button >= 4) |
2121 | if (ev.button >= 4) |
… | |
… | |
2123 | { |
2151 | { |
2124 | case Button1: |
2152 | case Button1: |
2125 | case Button3: |
2153 | case Button3: |
2126 | selection_make (ev.time); |
2154 | selection_make (ev.time); |
2127 | break; |
2155 | break; |
|
|
2156 | |
2128 | case Button2: |
2157 | case Button2: |
2129 | selection_request (ev.time, ev.x, ev.y); |
2158 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2159 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2130 | break; |
2160 | break; |
|
|
2161 | |
2131 | #ifdef MOUSE_WHEEL |
2162 | #ifdef MOUSE_WHEEL |
2132 | case Button4: |
2163 | case Button4: |
2133 | case Button5: |
2164 | case Button5: |
2134 | { |
2165 | { |
2135 | int i; |
2166 | int i; |
… | |
… | |
2157 | slip_wheel_ev.start (); |
2188 | slip_wheel_ev.start (); |
2158 | } |
2189 | } |
2159 | else |
2190 | else |
2160 | { |
2191 | { |
2161 | # endif |
2192 | # endif |
2162 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2163 | scr_page (v, i); |
2193 | scr_page (v, i); |
2164 | scr_refresh (SMOOTH_REFRESH); |
|
|
2165 | scrollbar_show (1); |
2194 | scrollbar_show (1); |
2166 | # else |
|
|
2167 | while (i--) |
|
|
2168 | { |
|
|
2169 | scr_page (v, 1); |
|
|
2170 | scr_refresh (SMOOTH_REFRESH); |
|
|
2171 | scrollbar_show (1); |
|
|
2172 | } |
|
|
2173 | # endif |
|
|
2174 | # ifdef MOUSE_SLIP_WHEELING |
2195 | # ifdef MOUSE_SLIP_WHEELING |
2175 | } |
2196 | } |
2176 | #endif |
2197 | # endif |
2177 | } |
2198 | } |
2178 | break; |
2199 | break; |
2179 | #endif |
2200 | #endif |
2180 | } |
2201 | } |
2181 | } |
2202 | } |
2182 | #ifdef MENUBAR |
|
|
2183 | else if (isMenuBarWindow (ev.window)) |
|
|
2184 | menubar_control (ev); |
|
|
2185 | #endif |
|
|
2186 | } |
2203 | } |
2187 | |
2204 | |
2188 | #ifdef TRANSPARENT |
2205 | #ifdef TRANSPARENT |
2189 | #if TINTING |
2206 | #if TINTING |
2190 | /* taken from aterm-0.4.2 */ |
2207 | /* taken from aterm-0.4.2 */ |
2191 | |
2208 | |
2192 | typedef uint32_t RUINT32T; |
2209 | typedef uint32_t RUINT32T; |
2193 | |
2210 | |
2194 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
2211 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
2195 | { |
2212 | { |
2196 | int sh_r, sh_g, sh_b; |
2213 | int sh_r, sh_g, sh_b; |
2197 | RUINT32T mask_r, mask_g, mask_b; |
2214 | RUINT32T mask_r, mask_g, mask_b; |
2198 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2215 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2199 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2216 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2200 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2217 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2201 | int i; |
2218 | int i; |
2202 | |
2219 | |
2203 | Visual *visual = display->visual; |
2220 | Visual *visual = term->visual; |
2204 | |
2221 | |
2205 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2222 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2206 | |
2223 | |
2207 | /* for convenience */ |
2224 | /* for convenience */ |
2208 | mask_r = visual->red_mask; |
2225 | mask_r = visual->red_mask; |
… | |
… | |
2429 | Atom atype; |
2446 | Atom atype; |
2430 | unsigned char *prop = NULL; |
2447 | unsigned char *prop = NULL; |
2431 | Window root, oldp, *list; |
2448 | Window root, oldp, *list; |
2432 | Pixmap rootpixmap = None; |
2449 | Pixmap rootpixmap = None; |
2433 | XWindowAttributes wattr, wrootattr; |
2450 | XWindowAttributes wattr, wrootattr; |
2434 | dDisp; |
|
|
2435 | |
2451 | |
2436 | pchanged = 0; |
2452 | pchanged = 0; |
2437 | |
2453 | |
2438 | if (!OPTION (Opt_transparent)) |
2454 | if (!OPTION (Opt_transparent)) |
2439 | return pchanged; /* Don't try any more */ |
2455 | return pchanged; /* Don't try any more */ |
2440 | |
2456 | |
2441 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2457 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
2442 | rootdepth = wrootattr.depth; |
2458 | rootdepth = wrootattr.depth; |
2443 | |
2459 | |
2444 | XGetWindowAttributes (disp, parent[0], &wattr); |
2460 | XGetWindowAttributes (dpy, parent[0], &wattr); |
2445 | |
2461 | |
2446 | if (rootdepth != wattr.depth) |
2462 | if (rootdepth != wattr.depth) |
2447 | { |
2463 | { |
2448 | if (am_transparent) |
2464 | if (am_transparent) |
2449 | { |
2465 | { |
2450 | pchanged = 1; |
2466 | pchanged = 1; |
2451 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2467 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2452 | am_transparent = am_pixmap_trans = 0; |
2468 | am_transparent = am_pixmap_trans = 0; |
2453 | } |
2469 | } |
2454 | |
2470 | |
2455 | return pchanged; /* Don't try any more */ |
2471 | return pchanged; /* Don't try any more */ |
2456 | } |
2472 | } |
2457 | |
2473 | |
2458 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2474 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2459 | XSync (disp, False); |
2475 | XSync (dpy, False); |
2460 | |
2476 | |
2461 | /* |
2477 | /* |
2462 | * Make the frame window set by the window manager have |
2478 | * Make the frame window set by the window manager have |
2463 | * the root background. Some window managers put multiple nested frame |
2479 | * the root background. Some window managers put multiple nested frame |
2464 | * windows for each client, so we have to take care about that. |
2480 | * windows for each client, so we have to take care about that. |
2465 | */ |
2481 | */ |
2466 | i = (xa[XA_XROOTPMAP_ID] |
2482 | i = (xa[XA_XROOTPMAP_ID] |
2467 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2483 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
2468 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2484 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2469 | &nitems, &bytes_after, &prop) == Success); |
2485 | &nitems, &bytes_after, &prop) == Success); |
2470 | |
2486 | |
2471 | if (!i || prop == NULL) |
2487 | if (!i || prop == NULL) |
2472 | i = (xa[XA_ESETROOT_PMAP_ID] |
2488 | i = (xa[XA_ESETROOT_PMAP_ID] |
2473 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2489 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
2474 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2490 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2475 | &nitems, &bytes_after, &prop) == Success); |
2491 | &nitems, &bytes_after, &prop) == Success); |
2476 | |
2492 | |
2477 | if (!i || prop == NULL |
2493 | if (!i || prop == NULL |
2478 | #if TINTING |
2494 | #if TINTING |
2479 | || !rs[Rs_color + Color_tint] |
2495 | || !ISSET_PIXCOLOR (Color_tint) |
2480 | #endif |
2496 | #endif |
2481 | ) |
2497 | ) |
2482 | have_pixmap = 0; |
2498 | have_pixmap = 0; |
2483 | else |
2499 | else |
2484 | { |
2500 | { |
… | |
… | |
2497 | Window cr; |
2513 | Window cr; |
2498 | XImage *image; |
2514 | XImage *image; |
2499 | GC gc; |
2515 | GC gc; |
2500 | XGCValues gcvalue; |
2516 | XGCValues gcvalue; |
2501 | |
2517 | |
2502 | XTranslateCoordinates (disp, parent[0], display->root, |
2518 | XTranslateCoordinates (dpy, parent[0], display->root, |
2503 | 0, 0, &sx, &sy, &cr); |
2519 | 0, 0, &sx, &sy, &cr); |
2504 | nw = (unsigned int)szHint.width; |
2520 | nw = (unsigned int)szHint.width; |
2505 | nh = (unsigned int)szHint.height; |
2521 | nh = (unsigned int)szHint.height; |
2506 | nx = ny = 0; |
2522 | nx = ny = 0; |
2507 | |
2523 | |
… | |
… | |
2520 | } |
2536 | } |
2521 | |
2537 | |
2522 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2538 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2523 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2539 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2524 | |
2540 | |
2525 | XSync (disp, False); |
2541 | XSync (dpy, False); |
2526 | allowedxerror = -1; |
2542 | allowedxerror = -1; |
2527 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2543 | image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2528 | |
2544 | |
2529 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2545 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2530 | /* XXX: may need a delay here? */ |
2546 | /* XXX: may need a delay here? */ |
2531 | allowedxerror = 0; |
2547 | allowedxerror = 0; |
2532 | |
2548 | |
… | |
… | |
2535 | if (am_transparent && am_pixmap_trans) |
2551 | if (am_transparent && am_pixmap_trans) |
2536 | { |
2552 | { |
2537 | pchanged = 1; |
2553 | pchanged = 1; |
2538 | if (pixmap != None) |
2554 | if (pixmap != None) |
2539 | { |
2555 | { |
2540 | XFreePixmap (disp, pixmap); |
2556 | XFreePixmap (dpy, pixmap); |
2541 | pixmap = None; |
2557 | pixmap = None; |
2542 | } |
2558 | } |
2543 | } |
2559 | } |
2544 | |
2560 | |
2545 | am_pixmap_trans = 0; |
2561 | am_pixmap_trans = 0; |
2546 | } |
2562 | } |
2547 | else |
2563 | else |
2548 | { |
2564 | { |
2549 | if (pixmap != None) |
2565 | if (pixmap != None) |
2550 | XFreePixmap (disp, pixmap); |
2566 | XFreePixmap (dpy, pixmap); |
2551 | |
2567 | |
2552 | #if TINTING |
2568 | #if TINTING |
2553 | if (ISSET_PIXCOLOR (Color_tint)) |
2569 | if (ISSET_PIXCOLOR (Color_tint)) |
2554 | { |
2570 | { |
2555 | unsigned short rm, gm, bm; |
|
|
2556 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2571 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2557 | |
2572 | |
|
|
2573 | rgba c; |
2558 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
2574 | pix_colors_focused [Color_tint].get (c); |
2559 | |
2575 | |
2560 | ShadeXImage (display, image, shade, rm, gm, bm); |
2576 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2561 | } |
2577 | } |
2562 | #endif |
2578 | #endif |
2563 | |
2579 | |
2564 | pixmap = XCreatePixmap (disp, vt, |
2580 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); |
2565 | szHint.width, szHint.height, image->depth); |
|
|
2566 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
2581 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
2567 | XPutImage (disp, pixmap, gc, image, 0, 0, |
2582 | XPutImage (dpy, pixmap, gc, image, 0, 0, |
2568 | nx, ny, image->width, image->height); |
2583 | nx, ny, image->width, image->height); |
2569 | XFreeGC (disp, gc); |
2584 | XFreeGC (dpy, gc); |
2570 | XDestroyImage (image); |
2585 | XDestroyImage (image); |
2571 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
2586 | XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); |
2572 | XClearWindow (disp, parent[0]); |
2587 | XClearWindow (dpy, parent[0]); |
2573 | |
2588 | |
2574 | if (!am_transparent || !am_pixmap_trans) |
2589 | if (!am_transparent || !am_pixmap_trans) |
2575 | pchanged = 1; |
2590 | pchanged = 1; |
2576 | |
2591 | |
2577 | am_transparent = am_pixmap_trans = 1; |
2592 | am_transparent = am_pixmap_trans = 1; |
2578 | } |
2593 | } |
2579 | } |
2594 | } |
2580 | |
2595 | |
2581 | if (am_pixmap_trans) |
2596 | if (am_pixmap_trans) |
2582 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2597 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2583 | else |
2598 | else |
2584 | { |
2599 | { |
2585 | unsigned int n; |
2600 | unsigned int n; |
2586 | /* |
2601 | /* |
2587 | * InheritPixmap transparency |
2602 | * InheritPixmap transparency |
2588 | */ |
2603 | */ |
2589 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2604 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2590 | { |
2605 | { |
2591 | oldp = parent[i]; |
2606 | oldp = parent[i]; |
2592 | XQueryTree (disp, parent[i - 1], &root, |
2607 | XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n); |
2593 | &parent[i], &list, &n); |
|
|
2594 | XFree (list); |
2608 | XFree (list); |
2595 | |
2609 | |
2596 | if (parent[i] == display->root) |
2610 | if (parent[i] == display->root) |
2597 | { |
2611 | { |
2598 | if (oldp != None) |
2612 | if (oldp != None) |
… | |
… | |
2606 | } |
2620 | } |
2607 | |
2621 | |
2608 | n = 0; |
2622 | n = 0; |
2609 | |
2623 | |
2610 | if (pchanged) |
2624 | if (pchanged) |
2611 | { |
|
|
2612 | for (; n < (unsigned int)i; n++) |
2625 | for (; n < (unsigned int)i; n++) |
2613 | { |
2626 | { |
2614 | XGetWindowAttributes (disp, parent[n], &wattr); |
2627 | XGetWindowAttributes (dpy, parent[n], &wattr); |
|
|
2628 | |
2615 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2629 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2616 | { |
2630 | { |
2617 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2631 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2618 | break; |
2632 | break; |
2619 | } |
2633 | } |
2620 | } |
2634 | } |
2621 | } |
|
|
2622 | |
2635 | |
2623 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2636 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2624 | { |
2637 | { |
2625 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
2638 | XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]); |
2626 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2639 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2627 | am_transparent = 0; |
2640 | am_transparent = 0; |
2628 | /* XXX: also turn off Opt_transparent? */ |
2641 | /* XXX: also turn off Opt_transparent? */ |
2629 | } |
2642 | } |
2630 | else |
2643 | else |
2631 | { |
2644 | { |
2632 | #if WAIT_FOR_WM |
|
|
2633 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2634 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2635 | sleep (1); |
|
|
2636 | #endif |
|
|
2637 | for (n = 0; n < (unsigned int)i; n++) |
2645 | for (n = 0; n < (unsigned int)i; n++) |
2638 | { |
2646 | { |
2639 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2647 | XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative); |
2640 | XClearWindow (disp, parent[n]); |
2648 | XClearWindow (dpy, parent[n]); |
2641 | } |
2649 | } |
2642 | |
2650 | |
2643 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2651 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2644 | am_transparent = 1; |
2652 | am_transparent = 1; |
2645 | } |
2653 | } |
2646 | |
2654 | |
2647 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2655 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2648 | parent[i] = None; |
2656 | parent[i] = None; |
2649 | } |
2657 | } |
2650 | |
2658 | |
2651 | if (scrollBar.win) |
2659 | if (scrollBar.win) |
2652 | { |
2660 | { |
2653 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2661 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2654 | scrollBar.setIdle (); |
2662 | scrollBar.setIdle (); |
2655 | scrollbar_show (0); |
2663 | scrollbar_show (0); |
2656 | } |
2664 | } |
2657 | |
2665 | |
2658 | if (am_transparent) |
2666 | if (am_transparent) |
… | |
… | |
2670 | |
2678 | |
2671 | bool |
2679 | bool |
2672 | rxvt_term::cmd_parse () |
2680 | rxvt_term::cmd_parse () |
2673 | { |
2681 | { |
2674 | bool flag = false; |
2682 | bool flag = false; |
2675 | unicode_t ch = NOCHAR; |
2683 | wchar_t ch = NOCHAR; |
2676 | unsigned char *seq_begin; // remember start of esc-sequence here |
2684 | char *seq_begin; // remember start of esc-sequence here |
2677 | |
2685 | |
2678 | for (;;) |
2686 | for (;;) |
2679 | { |
2687 | { |
2680 | if (ch == NOCHAR) |
2688 | if (ch == NOCHAR) |
2681 | { |
2689 | { |
2682 | seq_begin = cmdbuf_ptr; |
2690 | seq_begin = cmdbuf_ptr; |
2683 | ch = next_char (); |
2691 | ch = next_char (); |
2684 | } |
|
|
2685 | |
2692 | |
2686 | if (ch == NOCHAR) // TODO: improve |
2693 | if (ch == NOCHAR) |
2687 | break; |
2694 | break; |
|
|
2695 | } |
2688 | |
2696 | |
2689 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2697 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2690 | { |
2698 | { |
2691 | if (!seen_input) |
2699 | if (!seen_input) |
2692 | { |
2700 | { |
… | |
… | |
2701 | if (seen_resize && cmd_pid) |
2709 | if (seen_resize && cmd_pid) |
2702 | kill (-cmd_pid, SIGWINCH); |
2710 | kill (-cmd_pid, SIGWINCH); |
2703 | } |
2711 | } |
2704 | |
2712 | |
2705 | /* Read a text string from the input buffer */ |
2713 | /* Read a text string from the input buffer */ |
2706 | unicode_t buf[UBUFSIZ]; |
2714 | wchar_t buf[UBUFSIZ]; |
2707 | bool refreshnow = false; |
2715 | bool refreshnow = false; |
2708 | int nlines = 0; |
2716 | int nlines = 0; |
2709 | unicode_t *str = buf; |
2717 | wchar_t *str = buf; |
2710 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2718 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2711 | |
2719 | |
2712 | for (;;) |
2720 | for (;;) |
2713 | { |
2721 | { |
2714 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2722 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2715 | break; |
2723 | break; |
… | |
… | |
2733 | } |
2741 | } |
2734 | |
2742 | |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
2743 | // scr_add_lines only works for nlines <= nrow - 1. |
2736 | if (nlines >= nrow - 1) |
2744 | if (nlines >= nrow - 1) |
2737 | { |
2745 | { |
|
|
2746 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2747 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2738 | scr_add_lines (buf, nlines, str - buf); |
2748 | scr_add_lines (buf, str - buf, nlines); |
|
|
2749 | |
2739 | nlines = 0; |
2750 | nlines = 0; |
2740 | str = buf; |
2751 | str = buf; |
2741 | eol = str + min (ncol, UBUFSIZ); |
2752 | eol = str + min (ncol, UBUFSIZ); |
2742 | } |
2753 | } |
2743 | |
2754 | |
… | |
… | |
2756 | |
2767 | |
2757 | seq_begin = cmdbuf_ptr; |
2768 | seq_begin = cmdbuf_ptr; |
2758 | ch = next_char (); |
2769 | ch = next_char (); |
2759 | } |
2770 | } |
2760 | |
2771 | |
|
|
2772 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2773 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2761 | scr_add_lines (buf, nlines, str - buf); |
2774 | scr_add_lines (buf, str - buf, nlines); |
2762 | |
2775 | |
2763 | /* |
2776 | /* |
2764 | * If there have been a lot of new lines, then update the screen |
2777 | * If there have been a lot of new lines, then update the screen |
2765 | * What the heck I'll cheat and only refresh less than every page-full. |
2778 | * What the heck I'll cheat and only refresh less than every page-full. |
2766 | * the number of pages between refreshes is refresh_limit, which |
2779 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2771 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2784 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2772 | refresh_limit++; |
2785 | refresh_limit++; |
2773 | else |
2786 | else |
2774 | { |
2787 | { |
2775 | flag = true; |
2788 | flag = true; |
|
|
2789 | //TODO: due to popular request, implement "skipscroll" option here |
2776 | scr_refresh (refresh_type); |
2790 | scr_refresh (); |
2777 | flush_ev.stop (); |
2791 | want_refresh = 1; |
2778 | } |
2792 | } |
2779 | } |
2793 | } |
2780 | |
2794 | |
2781 | } |
2795 | } |
2782 | else |
2796 | else |
… | |
… | |
2797 | } |
2811 | } |
2798 | |
2812 | |
2799 | return flag; |
2813 | return flag; |
2800 | } |
2814 | } |
2801 | |
2815 | |
2802 | // read the next octet |
|
|
2803 | unicode_t |
|
|
2804 | rxvt_term::next_octet () |
|
|
2805 | { |
|
|
2806 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2807 | ? *cmdbuf_ptr++ |
|
|
2808 | : NOCHAR; |
|
|
2809 | } |
|
|
2810 | |
|
|
2811 | // read the next character |
2816 | // read the next character |
2812 | unicode_t |
2817 | wchar_t |
2813 | rxvt_term::next_char () |
2818 | rxvt_term::next_char () NOTHROW |
2814 | { |
2819 | { |
2815 | while (cmdbuf_ptr < cmdbuf_endp) |
2820 | while (cmdbuf_ptr < cmdbuf_endp) |
2816 | { |
2821 | { |
2817 | // assume 7-bit to be ascii ALWAYS |
2822 | // assume 7-bit to be ascii ALWAYS |
2818 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2823 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2819 | return *cmdbuf_ptr++; |
2824 | return *cmdbuf_ptr++; |
2820 | |
2825 | |
2821 | wchar_t wc; |
2826 | wchar_t wc; |
2822 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2827 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2823 | |
2828 | |
2824 | if (len == (size_t)-2) |
2829 | if (len == (size_t)-2) |
2825 | { |
2830 | { |
2826 | // the mbstate stores incomplete sequences. didn't know this :/ |
2831 | // the mbstate stores incomplete sequences. didn't know this :/ |
2827 | cmdbuf_ptr = cmdbuf_endp; |
2832 | cmdbuf_ptr = cmdbuf_endp; |
2828 | break; |
2833 | break; |
2829 | } |
2834 | } |
2830 | |
2835 | |
2831 | if (len == (size_t)-1) |
2836 | if (len == (size_t)-1) |
2832 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2837 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2833 | |
2838 | |
2834 | // assume wchar == unicode |
2839 | // assume wchar == unicode |
2835 | cmdbuf_ptr += len; |
2840 | cmdbuf_ptr += len; |
2836 | return wc & UNICODE_MASK; |
2841 | return wc & UNICODE_MASK; |
2837 | } |
2842 | } |
2838 | |
2843 | |
2839 | return NOCHAR; |
2844 | return NOCHAR; |
2840 | } |
2845 | } |
|
|
2846 | |
|
|
2847 | // read the next octet |
|
|
2848 | uint32_t |
|
|
2849 | rxvt_term::next_octet () NOTHROW |
|
|
2850 | { |
|
|
2851 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2852 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2853 | : NOCHAR; |
|
|
2854 | } |
|
|
2855 | |
|
|
2856 | static class out_of_input out_of_input; |
2841 | |
2857 | |
2842 | /* rxvt_cmd_getc () - Return next input character */ |
2858 | /* rxvt_cmd_getc () - Return next input character */ |
2843 | /* |
2859 | /* |
2844 | * Return the next input character after first passing any keyboard input |
2860 | * Return the next input character after first passing any keyboard input |
2845 | * to the command. |
2861 | * to the command. |
2846 | */ |
2862 | */ |
2847 | unicode_t |
2863 | wchar_t |
2848 | rxvt_term::cmd_getc () |
2864 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2849 | { |
2865 | { |
2850 | unicode_t c = next_char (); |
2866 | wchar_t c = next_char (); |
2851 | |
2867 | |
2852 | if (c == NOCHAR) |
2868 | if (c == NOCHAR) |
2853 | throw out_of_input; |
2869 | throw out_of_input; |
2854 | |
2870 | |
2855 | return c; |
2871 | return c; |
2856 | } |
2872 | } |
2857 | |
2873 | |
2858 | unicode_t |
2874 | uint32_t |
2859 | rxvt_term::cmd_get8 () |
2875 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2860 | { |
2876 | { |
2861 | unicode_t c = next_octet (); |
2877 | uint32_t c = next_octet (); |
2862 | |
2878 | |
2863 | if (c == NOCHAR) |
2879 | if (c == NOCHAR) |
2864 | throw out_of_input; |
2880 | throw out_of_input; |
2865 | |
2881 | |
2866 | return c; |
2882 | return c; |
… | |
… | |
2966 | case C0_ESC: |
2982 | case C0_ESC: |
2967 | process_escape_seq (); |
2983 | process_escape_seq (); |
2968 | break; |
2984 | break; |
2969 | case C0_ENQ: /* terminal Status */ |
2985 | case C0_ENQ: /* terminal Status */ |
2970 | if (rs[Rs_answerbackstring]) |
2986 | if (rs[Rs_answerbackstring]) |
2971 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2987 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2972 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2973 | else |
2988 | else |
2974 | tt_write ((unsigned char *)VT100_ANS, |
2989 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2975 | (unsigned int)strlen (VT100_ANS)); |
|
|
2976 | break; |
2990 | break; |
2977 | case C0_BEL: /* bell */ |
2991 | case C0_BEL: /* bell */ |
2978 | scr_bell (); |
2992 | scr_bell (); |
2979 | break; |
2993 | break; |
2980 | case C0_BS: /* backspace */ |
2994 | case C0_BS: /* backspace */ |
… | |
… | |
3104 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3118 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3105 | break; |
3119 | break; |
3106 | case '+': |
3120 | case '+': |
3107 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3121 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3108 | break; |
3122 | break; |
3109 | #if ENABLE_FRILLS |
3123 | #if !ENABLE_MINIMAL |
3110 | case '6': |
3124 | case '6': |
3111 | scr_backindex (); |
3125 | scr_backindex (); |
3112 | break; |
3126 | break; |
3113 | #endif |
3127 | #endif |
3114 | case '7': |
3128 | case '7': |
3115 | scr_cursor (SAVE); |
3129 | scr_cursor (SAVE); |
3116 | break; |
3130 | break; |
3117 | case '8': |
3131 | case '8': |
3118 | scr_cursor (RESTORE); |
3132 | scr_cursor (RESTORE); |
3119 | break; |
3133 | break; |
3120 | #if ENABLE_FRILLS |
3134 | #if !ENABLE_MINIMAL |
3121 | case '9': |
3135 | case '9': |
3122 | scr_forwardindex (); |
3136 | scr_forwardindex (); |
3123 | break; |
3137 | break; |
3124 | #endif |
3138 | #endif |
3125 | case '=': |
3139 | case '=': |
… | |
… | |
3135 | break; |
3149 | break; |
3136 | |
3150 | |
3137 | /* 8.3.87: NEXT LINE */ |
3151 | /* 8.3.87: NEXT LINE */ |
3138 | case C1_NEL: /* ESC E */ |
3152 | case C1_NEL: /* ESC E */ |
3139 | { |
3153 | { |
3140 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3154 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3141 | scr_add_lines (nlcr, 1, 2); |
3155 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3142 | } |
3156 | } |
3143 | break; |
3157 | break; |
3144 | |
3158 | |
3145 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3159 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3146 | case C1_ESA: /* ESC G */ |
3160 | case C1_ESA: /* ESC G */ |
… | |
… | |
3168 | process_dcs_seq (); |
3182 | process_dcs_seq (); |
3169 | break; |
3183 | break; |
3170 | |
3184 | |
3171 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3185 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3172 | case C1_SCI: /* ESC Z */ |
3186 | case C1_SCI: /* ESC Z */ |
3173 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3187 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3174 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3175 | break; /* steal obsolete ESC [ c */ |
3188 | break; /* steal obsolete ESC [ c */ |
3176 | |
3189 | |
3177 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3190 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3178 | case C1_CSI: /* ESC [ */ |
3191 | case C1_CSI: /* ESC [ */ |
3179 | process_csi_seq (); |
3192 | process_csi_seq (); |
… | |
… | |
3288 | ndef = get_byte_array_bit (csi_defaults, i); |
3301 | ndef = get_byte_array_bit (csi_defaults, i); |
3289 | for (p = 0; p < nargs; p++) |
3302 | for (p = 0; p < nargs; p++) |
3290 | if (arg[p] == -1) |
3303 | if (arg[p] == -1) |
3291 | arg[p] = ndef; |
3304 | arg[p] = ndef; |
3292 | |
3305 | |
3293 | #ifdef DEBUG_CMD |
|
|
3294 | fprintf (stderr, "CSI "); |
|
|
3295 | for (p = 0; p < nargs; p++) |
|
|
3296 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3297 | fprintf (stderr, "%c\n", ch); |
|
|
3298 | #endif |
|
|
3299 | |
|
|
3300 | /* |
3306 | /* |
3301 | * private mode handling |
3307 | * private mode handling |
3302 | */ |
3308 | */ |
3303 | if (priv) |
3309 | if (priv) |
3304 | { |
3310 | { |
3305 | switch (priv) |
3311 | switch (priv) |
3306 | { |
3312 | { |
3307 | case '>': |
3313 | case '>': |
3308 | if (ch == CSI_DA) /* secondary device attributes */ |
3314 | if (ch == CSI_DA) /* secondary device attributes */ |
3309 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3315 | { |
|
|
3316 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3317 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
3318 | // |
|
|
3319 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3320 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3321 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3322 | // |
|
|
3323 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
3324 | } |
3310 | break; |
3325 | break; |
3311 | case '?': |
3326 | case '?': |
3312 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3327 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3313 | process_terminal_mode (ch, priv, nargs, arg); |
3328 | process_terminal_mode (ch, priv, nargs, arg); |
3314 | break; |
3329 | break; |
… | |
… | |
3423 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3438 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3424 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3439 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3425 | break; |
3440 | break; |
3426 | |
3441 | |
3427 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3442 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3428 | tt_write ((const unsigned char *)VT100_ANS, |
3443 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3429 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3430 | break; |
3444 | break; |
3431 | |
3445 | |
3432 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3446 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3433 | process_sgr_mode (nargs, arg); |
3447 | process_sgr_mode (nargs, arg); |
3434 | break; |
3448 | break; |
… | |
… | |
3518 | break; |
3532 | break; |
3519 | case CSI_75: |
3533 | case CSI_75: |
3520 | scr_cursor (RESTORE); |
3534 | scr_cursor (RESTORE); |
3521 | break; |
3535 | break; |
3522 | |
3536 | |
3523 | #if ENABLE_FRILLS |
3537 | #if !ENABLE_MINIMAL |
3524 | case CSI_74: |
3538 | case CSI_74: |
3525 | process_window_ops (arg, nargs); |
3539 | process_window_ops (arg, nargs); |
3526 | break; |
3540 | break; |
3527 | #endif |
3541 | #endif |
3528 | |
3542 | |
… | |
… | |
3535 | break; |
3549 | break; |
3536 | } |
3550 | } |
3537 | } |
3551 | } |
3538 | /*}}} */ |
3552 | /*}}} */ |
3539 | |
3553 | |
3540 | #if ENABLE_FRILLS |
3554 | #if !ENABLE_MINIMAL |
3541 | /* ARGSUSED */ |
3555 | /* ARGSUSED */ |
3542 | void |
3556 | void |
3543 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3557 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3544 | { |
3558 | { |
3545 | int x, y; |
3559 | int x, y; |
3546 | XWindowAttributes wattr; |
3560 | XWindowAttributes wattr; |
3547 | Window wdummy; |
3561 | Window wdummy; |
3548 | dDisp; |
3562 | |
|
|
3563 | dLocal (Display *, dpy); |
3549 | |
3564 | |
3550 | if (nargs == 0) |
3565 | if (nargs == 0) |
3551 | return; |
3566 | return; |
3552 | |
3567 | |
3553 | switch (args[0]) |
3568 | switch (args[0]) |
3554 | { |
3569 | { |
3555 | /* |
3570 | /* |
3556 | * commands |
3571 | * commands |
3557 | */ |
3572 | */ |
3558 | case 1: /* deiconify window */ |
3573 | case 1: /* deiconify window */ |
3559 | XMapWindow (disp, parent[0]); |
3574 | XMapWindow (dpy, parent[0]); |
3560 | break; |
3575 | break; |
3561 | case 2: /* iconify window */ |
3576 | case 2: /* iconify window */ |
3562 | XIconifyWindow (disp, parent[0], display->screen); |
3577 | XIconifyWindow (dpy, parent[0], display->screen); |
3563 | break; |
3578 | break; |
3564 | case 3: /* set position (pixels) */ |
3579 | case 3: /* set position (pixels) */ |
3565 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3580 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3566 | break; |
3581 | break; |
3567 | case 4: /* set size (pixels) */ |
3582 | case 4: /* set size (pixels) */ |
3568 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3583 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3569 | break; |
3584 | break; |
3570 | case 5: /* raise window */ |
3585 | case 5: /* raise window */ |
3571 | XRaiseWindow (disp, parent[0]); |
3586 | XRaiseWindow (dpy, parent[0]); |
3572 | break; |
3587 | break; |
3573 | case 6: /* lower window */ |
3588 | case 6: /* lower window */ |
3574 | XLowerWindow (disp, parent[0]); |
3589 | XLowerWindow (dpy, parent[0]); |
3575 | break; |
3590 | break; |
3576 | case 7: /* refresh window */ |
3591 | case 7: /* refresh window */ |
3577 | scr_touch (true); |
3592 | scr_touch (true); |
3578 | break; |
3593 | break; |
3579 | case 8: /* set size (chars) */ |
3594 | case 8: /* set size (chars) */ |
… | |
… | |
3586 | if (args[0] >= 24) /* set height (chars) */ |
3601 | if (args[0] >= 24) /* set height (chars) */ |
3587 | set_widthheight ((unsigned int)width, |
3602 | set_widthheight ((unsigned int)width, |
3588 | (unsigned int) (args[1] * fheight)); |
3603 | (unsigned int) (args[1] * fheight)); |
3589 | break; |
3604 | break; |
3590 | |
3605 | |
3591 | |
|
|
3592 | /* |
3606 | /* |
3593 | * reports - some output format copied from XTerm |
3607 | * reports - some output format copied from XTerm |
3594 | */ |
3608 | */ |
3595 | case 11: /* report window state */ |
3609 | case 11: /* report window state */ |
3596 | XGetWindowAttributes (disp, parent[0], &wattr); |
3610 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3597 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3611 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3598 | break; |
3612 | break; |
3599 | case 13: /* report window position */ |
3613 | case 13: /* report window position */ |
3600 | XGetWindowAttributes (disp, parent[0], &wattr); |
3614 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3601 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3615 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3602 | -wattr.border_width, -wattr.border_width, |
3616 | -wattr.border_width, -wattr.border_width, |
3603 | &x, &y, &wdummy); |
3617 | &x, &y, &wdummy); |
3604 | tt_printf ("\033[3;%d;%dt", x, y); |
3618 | tt_printf ("\033[3;%d;%dt", x, y); |
3605 | break; |
3619 | break; |
3606 | case 14: /* report window size (pixels) */ |
3620 | case 14: /* report window size (pixels) */ |
3607 | XGetWindowAttributes (disp, parent[0], &wattr); |
3621 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3608 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3622 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3609 | break; |
3623 | break; |
3610 | case 18: /* report text area size (chars) */ |
3624 | case 18: /* report text area size (chars) */ |
3611 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3625 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3612 | break; |
3626 | break; |
… | |
… | |
3614 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3628 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3615 | break; |
3629 | break; |
3616 | case 20: /* report icon label */ |
3630 | case 20: /* report icon label */ |
3617 | { |
3631 | { |
3618 | char *s; |
3632 | char *s; |
3619 | XGetIconName (disp, parent[0], &s); |
3633 | XGetIconName (dpy, parent[0], &s); |
3620 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3634 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3621 | XFree (s); |
3635 | XFree (s); |
3622 | } |
3636 | } |
3623 | break; |
3637 | break; |
3624 | case 21: /* report window title */ |
3638 | case 21: /* report window title */ |
3625 | { |
3639 | { |
3626 | char *s; |
3640 | char *s; |
3627 | XFetchName (disp, parent[0], &s); |
3641 | XFetchName (dpy, parent[0], &s); |
3628 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3642 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3629 | XFree (s); |
3643 | XFree (s); |
3630 | } |
3644 | } |
3631 | break; |
3645 | break; |
3632 | } |
3646 | } |
… | |
… | |
3636 | /*----------------------------------------------------------------------*/ |
3650 | /*----------------------------------------------------------------------*/ |
3637 | /* |
3651 | /* |
3638 | * get input up until STRING TERMINATOR (or BEL) |
3652 | * get input up until STRING TERMINATOR (or BEL) |
3639 | * ends_how is terminator used. returned input must be free()'d |
3653 | * ends_how is terminator used. returned input must be free()'d |
3640 | */ |
3654 | */ |
3641 | unsigned char * |
3655 | char * |
3642 | rxvt_term::get_to_st (unicode_t &ends_how) |
3656 | rxvt_term::get_to_st (unicode_t &ends_how) |
3643 | { |
3657 | { |
3644 | unicode_t ch; |
3658 | unicode_t ch; |
3645 | bool seen_esc = false; |
3659 | bool seen_esc = false; |
3646 | unsigned int n = 0; |
3660 | unsigned int n = 0; |
… | |
… | |
3660 | seen_esc = true; |
3674 | seen_esc = true; |
3661 | continue; |
3675 | continue; |
3662 | } |
3676 | } |
3663 | else if (ch == C0_BEL || ch == CHAR_ST) |
3677 | else if (ch == C0_BEL || ch == CHAR_ST) |
3664 | break; |
3678 | break; |
|
|
3679 | else if (ch == C0_SYN) |
|
|
3680 | ch = cmd_get8 (); |
3665 | else if (ch < 0x20) |
3681 | else if (ch < 0x20) |
3666 | return NULL; /* other control character - exit */ |
3682 | return NULL; /* other control character - exit */ |
3667 | |
3683 | |
3668 | seen_esc = false; |
3684 | seen_esc = false; |
3669 | |
3685 | |
3670 | if (n >= STRING_MAX - 1) |
3686 | if (n >= STRING_MAX - 1) |
3671 | // stop at some sane length |
3687 | // stop at some sane length |
3672 | return NULL; |
3688 | return NULL; |
3673 | |
3689 | |
3674 | if (ch == C0_SYN) |
|
|
3675 | string[n++] = cmd_get8 (); |
|
|
3676 | else |
|
|
3677 | string[n++] = ch; |
3690 | string[n++] = ch; |
3678 | } |
3691 | } |
3679 | |
3692 | |
3680 | string[n++] = '\0'; |
3693 | string[n++] = '\0'; |
3681 | |
3694 | |
3682 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3695 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3683 | |
3696 | |
3684 | return (unsigned char *)rxvt_wcstombs (string); |
3697 | return rxvt_wcstombs (string); |
3685 | } |
3698 | } |
3686 | |
3699 | |
3687 | /*----------------------------------------------------------------------*/ |
3700 | /*----------------------------------------------------------------------*/ |
3688 | /* |
3701 | /* |
3689 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3702 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3690 | */ |
3703 | */ |
3691 | void |
3704 | void |
3692 | rxvt_term::process_dcs_seq () |
3705 | rxvt_term::process_dcs_seq () |
3693 | { |
3706 | { |
3694 | unsigned char *s; |
3707 | char *s; |
3695 | unicode_t eh; |
3708 | unicode_t eh; |
3696 | |
3709 | |
3697 | /* |
3710 | /* |
3698 | * Not handled yet |
3711 | * Not handled yet |
3699 | */ |
3712 | */ |
… | |
… | |
3718 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3731 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3719 | arg = arg * 10 + (ch - '0'); |
3732 | arg = arg * 10 + (ch - '0'); |
3720 | |
3733 | |
3721 | if (ch == ';') |
3734 | if (ch == ';') |
3722 | { |
3735 | { |
3723 | unsigned char *s = get_to_st (eh); |
3736 | char *s = get_to_st (eh); |
3724 | |
3737 | |
3725 | if (s) |
3738 | if (s) |
3726 | { |
3739 | { |
3727 | process_xterm_seq (arg, (char *)s, eh); |
3740 | process_xterm_seq (arg, s, eh); |
3728 | free (s); |
3741 | free (s); |
3729 | } |
3742 | } |
3730 | } |
3743 | } |
3731 | } |
3744 | } |
3732 | |
3745 | |
3733 | void |
3746 | void |
3734 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3747 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3735 | { |
3748 | { |
3736 | if (str[0] == '?' && !str[1]) |
3749 | if (str[0] == '?' && !str[1]) |
3737 | { |
3750 | { |
3738 | unsigned short r, g, b; |
3751 | rgba c; |
3739 | pix_colors_focused[color].get (display, r, g, b); |
3752 | pix_colors_focused[color].get (c); |
|
|
3753 | |
|
|
3754 | #if XFT |
|
|
3755 | if (c.a != rgba::MAX_CC) |
|
|
3756 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3757 | else |
|
|
3758 | #endif |
3740 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3759 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3741 | } |
3760 | } |
3742 | else |
3761 | else |
3743 | set_window_color (color, str); |
3762 | set_window_color (color, str); |
3744 | } |
3763 | } |
3745 | |
3764 | |
3746 | /* |
3765 | /* |
3747 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3766 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3748 | */ |
3767 | */ |
3749 | void |
3768 | void |
3750 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3769 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3751 | { |
3770 | { |
3752 | int changed = 0; |
|
|
3753 | int color; |
3771 | int color; |
3754 | char *buf, *name; |
3772 | char *buf, *name; |
3755 | bool query = str[0] == '?' && !str[1]; |
3773 | bool query = str[0] == '?' && !str[1]; |
3756 | int saveop = op; |
3774 | int saveop = op; |
3757 | dDisp; |
3775 | |
|
|
3776 | dLocal (Display *, dpy); |
3758 | |
3777 | |
3759 | assert (str != NULL); |
3778 | assert (str != NULL); |
|
|
3779 | |
|
|
3780 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3781 | return; |
|
|
3782 | |
3760 | switch (op) |
3783 | switch (op) |
3761 | { |
3784 | { |
3762 | case XTerm_name: |
3785 | case XTerm_name: |
3763 | set_title (str); |
3786 | set_title (str); |
3764 | /* FALLTHROUGH */ |
3787 | /* FALLTHROUGH */ |
… | |
… | |
3778 | unsigned long bytes_after; |
3801 | unsigned long bytes_after; |
3779 | unsigned char *value = 0; |
3802 | unsigned char *value = 0; |
3780 | const char *str = ""; |
3803 | const char *str = ""; |
3781 | |
3804 | |
3782 | if (prop |
3805 | if (prop |
3783 | && XGetWindowProperty (disp, parent[0], |
3806 | && XGetWindowProperty (dpy, parent[0], |
3784 | prop, 0, 1<<16, 0, AnyPropertyType, |
3807 | prop, 0, 1<<16, 0, AnyPropertyType, |
3785 | &actual_type, &actual_format, |
3808 | &actual_type, &actual_format, |
3786 | &nitems, &bytes_after, &value) == Success |
3809 | &nitems, &bytes_after, &value) == Success |
3787 | && actual_type != None |
3810 | && actual_type != None |
3788 | && actual_format == 8) |
3811 | && actual_format == 8) |
3789 | str = (const char *)(value); |
3812 | str = (const char *)(value); |
3790 | |
3813 | |
3791 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3814 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3792 | |
3815 | |
3793 | XFree (value); |
3816 | XFree (value); |
3794 | } |
3817 | } |
3795 | else |
3818 | else |
3796 | { |
3819 | { |
… | |
… | |
3800 | { |
3823 | { |
3801 | *eq = 0; |
3824 | *eq = 0; |
3802 | set_utf8_property (display->atom (str), eq + 1); |
3825 | set_utf8_property (display->atom (str), eq + 1); |
3803 | } |
3826 | } |
3804 | else |
3827 | else |
3805 | XDeleteProperty (disp, parent[0], |
3828 | XDeleteProperty (dpy, parent[0], |
3806 | display->atom (str)); |
3829 | display->atom (str)); |
3807 | } |
3830 | } |
3808 | break; |
3831 | break; |
3809 | |
3832 | |
3810 | case XTerm_Color: |
3833 | case XTerm_Color: |
… | |
… | |
3812 | { |
3835 | { |
3813 | if ((name = strchr (buf, ';')) == NULL) |
3836 | if ((name = strchr (buf, ';')) == NULL) |
3814 | break; |
3837 | break; |
3815 | |
3838 | |
3816 | *name++ = '\0'; |
3839 | *name++ = '\0'; |
3817 | color = atoi (buf); |
3840 | color = atoi (buf) + minCOLOR; |
3818 | |
3841 | |
3819 | if (color < 0 || color >= TOTAL_COLORS) |
3842 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3820 | break; |
3843 | break; |
3821 | |
3844 | |
3822 | if ((buf = strchr (name, ';')) != NULL) |
3845 | if ((buf = strchr (name, ';')) != NULL) |
3823 | *buf++ = '\0'; |
3846 | *buf++ = '\0'; |
3824 | |
3847 | |
3825 | if (name[0] == '?' && !name[1]) |
3848 | process_color_seq (op, color, name, resp); |
3826 | { |
|
|
3827 | unsigned short r, g, b; |
|
|
3828 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3829 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3830 | } |
|
|
3831 | else |
|
|
3832 | set_window_color (color + minCOLOR, name); |
|
|
3833 | } |
3849 | } |
3834 | break; |
3850 | break; |
3835 | case XTerm_Color00: |
3851 | case XTerm_Color00: |
3836 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3852 | process_color_seq (op, Color_fg, str, resp); |
3837 | break; |
3853 | break; |
3838 | case XTerm_Color01: |
3854 | case XTerm_Color01: |
3839 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3855 | process_color_seq (op, Color_bg, str, resp); |
3840 | break; |
3856 | break; |
3841 | #ifndef NO_CURSORCOLOR |
3857 | #ifndef NO_CURSORCOLOR |
3842 | case XTerm_Color_cursor: |
3858 | case XTerm_Color_cursor: |
3843 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3859 | process_color_seq (op, Color_cursor, str, resp); |
3844 | break; |
3860 | break; |
3845 | #endif |
3861 | #endif |
3846 | case XTerm_Color_pointer_fg: |
3862 | case XTerm_Color_pointer_fg: |
3847 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3863 | process_color_seq (op, Color_pointer_fg, str, resp); |
3848 | break; |
3864 | break; |
3849 | case XTerm_Color_pointer_bg: |
3865 | case XTerm_Color_pointer_bg: |
3850 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3866 | process_color_seq (op, Color_pointer_bg, str, resp); |
3851 | break; |
3867 | break; |
3852 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3868 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3853 | case XTerm_Color_BD: |
|
|
3854 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3855 | break; |
|
|
3856 | case XTerm_Color_UL: |
|
|
3857 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3858 | break; |
|
|
3859 | case XTerm_Color_RV: |
3869 | case XTerm_Color_RV: |
3860 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3870 | process_color_seq (op, Color_RV, str, resp); |
|
|
3871 | break; |
|
|
3872 | case Rxvt_Color_BD: |
|
|
3873 | case URxvt_Color_BD: |
|
|
3874 | process_color_seq (op, Color_BD, str, resp); |
|
|
3875 | break; |
|
|
3876 | case Rxvt_Color_UL: |
|
|
3877 | case URxvt_Color_UL: |
|
|
3878 | process_color_seq (op, Color_UL, str, resp); |
3861 | break; |
3879 | break; |
3862 | case URxvt_Color_IT: |
3880 | case URxvt_Color_IT: |
3863 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3881 | process_color_seq (op, Color_IT, str, resp); |
3864 | break; |
3882 | break; |
3865 | #endif |
3883 | #endif |
3866 | #if TRANSPARENT && TINTING |
3884 | #if TRANSPARENT && TINTING |
3867 | case URxvt_Color_tint: |
3885 | case URxvt_Color_tint: |
3868 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3886 | process_color_seq (op, Color_tint, str, resp); |
|
|
3887 | |
3869 | check_our_parents (); |
3888 | check_our_parents (); |
|
|
3889 | |
3870 | if (am_transparent) |
3890 | if (am_transparent) |
3871 | want_full_refresh = want_refresh = 1; |
3891 | want_full_refresh = want_refresh = 1; |
3872 | break; |
|
|
3873 | #endif |
|
|
3874 | |
3892 | |
|
|
3893 | break; |
|
|
3894 | #endif |
|
|
3895 | |
3875 | case XTerm_Pixmap: |
3896 | case Rxvt_Pixmap: |
|
|
3897 | { |
3876 | if (*str != ';') |
3898 | if (*str != ';') |
3877 | { |
3899 | { |
3878 | #if XPM_BACKGROUND |
3900 | #if XPM_BACKGROUND |
3879 | scale_pixmap (""); /* reset to default scaling */ |
3901 | scale_pixmap (""); /* reset to default scaling */ |
3880 | set_bgPixmap (str); /* change pixmap */ |
3902 | set_bgPixmap (str); /* change pixmap */ |
3881 | #endif |
|
|
3882 | scr_touch (true); |
3903 | scr_touch (true); |
|
|
3904 | #endif |
3883 | } |
3905 | } |
|
|
3906 | |
|
|
3907 | int changed = 0; |
|
|
3908 | |
3884 | while ((str = strchr (str, ';')) != NULL) |
3909 | while ((str = strchr (str, ';')) != NULL) |
3885 | { |
3910 | { |
3886 | str++; |
3911 | str++; |
3887 | #if XPM_BACKGROUND |
3912 | #if XPM_BACKGROUND |
3888 | changed += scale_pixmap (str); |
3913 | changed += scale_pixmap (str); |
3889 | #endif |
3914 | #endif |
3890 | } |
3915 | } |
3891 | |
3916 | |
3892 | if (changed) |
3917 | if (changed) |
3893 | { |
3918 | { |
3894 | #ifdef XPM_BACKGROUND |
3919 | #ifdef XPM_BACKGROUND |
3895 | resize_pixmap (); |
3920 | resize_pixmap (); |
3896 | #endif |
|
|
3897 | scr_touch (true); |
3921 | scr_touch (true); |
|
|
3922 | #endif |
3898 | } |
3923 | } |
|
|
3924 | } |
3899 | break; |
3925 | break; |
3900 | |
3926 | |
3901 | case XTerm_restoreFG: |
3927 | case Rxvt_restoreFG: |
3902 | set_window_color (Color_fg, str); |
3928 | set_window_color (Color_fg, str); |
3903 | break; |
3929 | break; |
3904 | case XTerm_restoreBG: |
3930 | case Rxvt_restoreBG: |
3905 | set_window_color (Color_bg, str); |
3931 | set_window_color (Color_bg, str); |
3906 | break; |
3932 | break; |
3907 | |
3933 | |
3908 | case XTerm_logfile: |
3934 | case XTerm_logfile: |
3909 | // TODO, when secure mode? |
3935 | // TODO, when secure mode? |
3910 | break; |
3936 | break; |
3911 | |
3937 | |
3912 | #ifdef MENUBAR |
|
|
3913 | case URxvt_Menu: |
|
|
3914 | if (OPTION (Opt_insecure)) |
|
|
3915 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3916 | break; |
|
|
3917 | #endif |
|
|
3918 | #if 0 |
3938 | #if 0 |
3919 | case XTerm_dumpscreen: /* no error notices */ |
3939 | case Rxvt_dumpscreen: /* no error notices */ |
3920 | { |
3940 | { |
3921 | int fd; |
3941 | int fd; |
3922 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3942 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3923 | { |
3943 | { |
3924 | scr_dump (fd); |
3944 | scr_dump (fd); |
… | |
… | |
3948 | allocated.push_back ((void *)res); |
3968 | allocated.push_back ((void *)res); |
3949 | set_fonts (); |
3969 | set_fonts (); |
3950 | } |
3970 | } |
3951 | break; |
3971 | break; |
3952 | |
3972 | |
3953 | #if ENABLE_FRILLS |
3973 | case URxvt_version: |
|
|
3974 | if (query) |
|
|
3975 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3976 | op, |
|
|
3977 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3978 | resp); |
|
|
3979 | break; |
|
|
3980 | |
|
|
3981 | #if !ENABLE_MINIMAL |
3954 | case URxvt_locale: |
3982 | case URxvt_locale: |
3955 | if (query) |
3983 | if (query) |
3956 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3984 | tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); |
3957 | else |
3985 | else |
3958 | { |
3986 | { |
3959 | set_locale (str); |
3987 | set_locale (str); |
3960 | pty.set_utf8_mode (enc_utf8); |
3988 | pty->set_utf8_mode (enc_utf8); |
3961 | init_xlocale (); |
3989 | init_xlocale (); |
3962 | } |
3990 | } |
3963 | break; |
3991 | break; |
3964 | |
3992 | |
3965 | case URxvt_view_up: |
3993 | case URxvt_view_up: |
… | |
… | |
3976 | break; |
4004 | break; |
3977 | #endif |
4005 | #endif |
3978 | |
4006 | |
3979 | #if ENABLE_PERL |
4007 | #if ENABLE_PERL |
3980 | case URxvt_perl: |
4008 | case URxvt_perl: |
3981 | if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
4009 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
3982 | ; // no responses yet |
4010 | ; // no responses yet |
3983 | break; |
4011 | break; |
3984 | #endif |
4012 | #endif |
3985 | } |
4013 | } |
3986 | } |
4014 | } |
… | |
… | |
4018 | return state; |
4046 | return state; |
4019 | } |
4047 | } |
4020 | |
4048 | |
4021 | /* we're not using priv _yet_ */ |
4049 | /* we're not using priv _yet_ */ |
4022 | void |
4050 | void |
4023 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4051 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4024 | { |
4052 | { |
4025 | unsigned int i, j; |
4053 | unsigned int i, j; |
4026 | int state; |
4054 | int state; |
4027 | |
4055 | |
4028 | static const struct |
4056 | static const struct |
… | |
… | |
4039 | { 5, PrivMode_rVideo }, |
4067 | { 5, PrivMode_rVideo }, |
4040 | { 6, PrivMode_relOrigin }, |
4068 | { 6, PrivMode_relOrigin }, |
4041 | { 7, PrivMode_Autowrap }, |
4069 | { 7, PrivMode_Autowrap }, |
4042 | // 8, bi-directional support mode |
4070 | // 8, bi-directional support mode |
4043 | { 9, PrivMode_MouseX10 }, |
4071 | { 9, PrivMode_MouseX10 }, |
4044 | #ifdef menuBar_esc |
|
|
4045 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4046 | #endif |
|
|
4047 | // 18, 19 printing-related |
4072 | // 18, 19 printing-related |
4048 | { 25, PrivMode_VisibleCursor }, |
4073 | { 25, PrivMode_VisibleCursor }, |
4049 | #ifdef scrollBar_esc |
4074 | #ifdef scrollBar_esc |
4050 | { scrollBar_esc, PrivMode_scrollBar }, |
4075 | { scrollBar_esc, PrivMode_scrollBar }, |
4051 | #endif |
4076 | #endif |
… | |
… | |
4098 | /* extra handling for values with state unkept */ |
4123 | /* extra handling for values with state unkept */ |
4099 | switch (arg[i]) |
4124 | switch (arg[i]) |
4100 | { |
4125 | { |
4101 | #if ENABLE_STYLES |
4126 | #if ENABLE_STYLES |
4102 | case 1021: |
4127 | case 1021: |
4103 | if (mode) |
4128 | set_option (Opt_intensityStyles, mode); |
4104 | SET_OPTION (Opt_intensityStyles); |
|
|
4105 | else |
|
|
4106 | CLR_OPTION (Opt_intensityStyles); |
|
|
4107 | |
4129 | |
4108 | scr_touch (true); |
4130 | scr_touch (true); |
4109 | break; |
4131 | break; |
4110 | #endif |
4132 | #endif |
4111 | case 1048: /* alternative cursor save */ |
4133 | case 1048: /* alternative cursor save */ |
… | |
… | |
4133 | case 3: /* 80/132 */ |
4155 | case 3: /* 80/132 */ |
4134 | if (priv_modes & PrivMode_132OK) |
4156 | if (priv_modes & PrivMode_132OK) |
4135 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4157 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4136 | break; |
4158 | break; |
4137 | case 4: /* smooth scrolling */ |
4159 | case 4: /* smooth scrolling */ |
4138 | if (!state) |
4160 | set_option (Opt_jumpScroll, !state); |
4139 | SET_OPTION (Opt_jumpScroll); |
|
|
4140 | else |
|
|
4141 | CLR_OPTION (Opt_jumpScroll); |
|
|
4142 | break; |
4161 | break; |
4143 | case 5: /* reverse video */ |
4162 | case 5: /* reverse video */ |
4144 | scr_rvideo_mode (state); |
4163 | scr_rvideo_mode (state); |
4145 | break; |
4164 | break; |
4146 | case 6: /* relative/absolute origins */ |
4165 | case 6: /* relative/absolute origins */ |
… | |
… | |
4152 | /* case 8: - auto repeat, can't do on a per window basis */ |
4171 | /* case 8: - auto repeat, can't do on a per window basis */ |
4153 | case 9: /* X10 mouse reporting */ |
4172 | case 9: /* X10 mouse reporting */ |
4154 | if (state) /* orthogonal */ |
4173 | if (state) /* orthogonal */ |
4155 | priv_modes &= ~PrivMode_MouseX11; |
4174 | priv_modes &= ~PrivMode_MouseX11; |
4156 | break; |
4175 | break; |
4157 | #ifdef menuBar_esc |
|
|
4158 | case menuBar_esc: |
|
|
4159 | #ifdef MENUBAR |
|
|
4160 | map_menuBar (state); |
|
|
4161 | #endif |
|
|
4162 | break; |
|
|
4163 | #endif |
|
|
4164 | #ifdef scrollBar_esc |
4176 | #ifdef scrollBar_esc |
4165 | case scrollBar_esc: |
4177 | case scrollBar_esc: |
4166 | if (scrollbar_mapping (state)) |
4178 | if (scrollbar_mapping (state)) |
4167 | { |
4179 | { |
4168 | resize_all_windows (0, 0, 0); |
4180 | resize_all_windows (0, 0, 0); |
… | |
… | |
4187 | #if 0 |
4199 | #if 0 |
4188 | case 1001: |
4200 | case 1001: |
4189 | break; /* X11 mouse highlighting */ |
4201 | break; /* X11 mouse highlighting */ |
4190 | #endif |
4202 | #endif |
4191 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4203 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4192 | if (!state) |
4204 | set_option (Opt_scrollTtyOutput, !state); |
4193 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4194 | else |
|
|
4195 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4196 | break; |
4205 | break; |
4197 | case 1011: /* scroll to bottom on key press */ |
4206 | case 1011: /* scroll to bottom on key press */ |
4198 | if (state) |
4207 | set_option (Opt_scrollTtyKeypress, state); |
4199 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4200 | else |
|
|
4201 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4202 | break; |
4208 | break; |
4203 | case 1047: /* secondary screen w/ clearing last */ |
4209 | case 1047: /* secondary screen w/ clearing last */ |
4204 | if (OPTION (Opt_secondaryScreen)) |
4210 | if (OPTION (Opt_secondaryScreen)) |
4205 | if (current_screen != PRIMARY) |
4211 | if (current_screen != PRIMARY) |
4206 | scr_erase_screen (2); |
4212 | scr_erase_screen (2); |
… | |
… | |
4344 | scr_color (Color_bg, Color_bg); |
4350 | scr_color (Color_bg, Color_bg); |
4345 | break; |
4351 | break; |
4346 | |
4352 | |
4347 | //case 50: // not variable spacing |
4353 | //case 50: // not variable spacing |
4348 | |
4354 | |
4349 | #ifndef NO_BRIGHTCOLOR |
4355 | #if !ENABLE_MINIMAL |
4350 | case 90: |
4356 | case 90: |
4351 | case 91: /* set bright fg color */ |
4357 | case 91: /* set bright fg color */ |
4352 | case 92: |
4358 | case 92: |
4353 | case 93: |
4359 | case 93: |
4354 | case 94: |
4360 | case 94: |
… | |
… | |
4399 | */ |
4405 | */ |
4400 | void |
4406 | void |
4401 | rxvt_term::tt_printf (const char *fmt,...) |
4407 | rxvt_term::tt_printf (const char *fmt,...) |
4402 | { |
4408 | { |
4403 | va_list arg_ptr; |
4409 | va_list arg_ptr; |
4404 | unsigned char buf[256]; |
4410 | char buf[256]; |
4405 | |
4411 | |
4406 | va_start (arg_ptr, fmt); |
4412 | va_start (arg_ptr, fmt); |
4407 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4413 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4408 | va_end (arg_ptr); |
4414 | va_end (arg_ptr); |
4409 | tt_write (buf, strlen (buf)); |
4415 | tt_write (buf, strlen (buf)); |
… | |
… | |
4414 | * or generated by us in response to a query ESC sequence. |
4420 | * or generated by us in response to a query ESC sequence. |
4415 | */ |
4421 | */ |
4416 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4422 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4417 | |
4423 | |
4418 | void |
4424 | void |
4419 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4425 | rxvt_term::tt_write (const char *data, unsigned int len) |
4420 | { |
4426 | { |
|
|
4427 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4428 | return; |
|
|
4429 | |
|
|
4430 | if (pty->pty < 0) |
|
|
4431 | return; |
|
|
4432 | |
4421 | if (v_buflen == 0) |
4433 | if (v_buflen == 0) |
4422 | { |
4434 | { |
4423 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4435 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4424 | |
4436 | |
4425 | if ((unsigned int)written == len) |
4437 | if ((unsigned int)written == len) |
4426 | return; |
4438 | return; |
4427 | |
4439 | |
4428 | data += written; |
4440 | data += written; |
4429 | len -= written; |
4441 | len -= written; |
4430 | } |
4442 | } |
4431 | |
4443 | |
4432 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4444 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4433 | |
4445 | |
4434 | memcpy (v_buffer + v_buflen, data, len); |
4446 | memcpy (v_buffer + v_buflen, data, len); |
4435 | v_buflen += len; |
4447 | v_buflen += len; |
4436 | |
4448 | |
4437 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4449 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4438 | } |
4450 | } |
4439 | |
4451 | |
4440 | void rxvt_term::pty_write () |
4452 | void rxvt_term::pty_write () |
4441 | { |
4453 | { |
4442 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4454 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4443 | |
4455 | |
4444 | if (written > 0) |
4456 | if (written > 0) |
4445 | { |
4457 | { |
4446 | v_buflen -= written; |
4458 | v_buflen -= written; |
4447 | |
4459 | |