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. |
… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
52 | |
53 | |
53 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
55 | # include "keyboard.h" |
55 | #endif |
56 | #endif |
56 | |
57 | |
57 | #include <csignal> |
58 | #include <csignal> |
58 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
59 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
60 | |
65 | |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | |
|
|
63 | // exception thrown when the command parser runs out of input data |
|
|
64 | class out_of_input { } out_of_input; |
|
|
65 | |
67 | |
66 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
67 | |
69 | |
68 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
69 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
141 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | return; |
144 | return; |
143 | |
145 | |
144 | for (;;) |
146 | for (;;) |
145 | { |
147 | { |
146 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
147 | |
149 | |
148 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
149 | |
151 | |
150 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
151 | { |
153 | { |
… | |
… | |
224 | # if !UNICODE3 |
226 | # if !UNICODE3 |
225 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
226 | ch = 0xfffd; |
228 | ch = 0xfffd; |
227 | # endif |
229 | # endif |
228 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
229 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
230 | } |
234 | } |
231 | |
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 | // } |
232 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
233 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
234 | |
243 | |
235 | free (fname); |
244 | free (fname); |
236 | |
245 | |
… | |
… | |
262 | mb[0] = ch[0]; |
271 | mb[0] = ch[0]; |
263 | len = 1; |
272 | len = 1; |
264 | } |
273 | } |
265 | |
274 | |
266 | if (len > 0) |
275 | if (len > 0) |
267 | tt_write ((unsigned char *)mb, len); |
276 | tt_write (mb, len); |
268 | else |
277 | else |
269 | scr_bell (); |
278 | scr_bell (); |
270 | } |
279 | } |
271 | |
280 | |
272 | iso14755buf = 0; |
281 | iso14755buf = 0; |
… | |
… | |
289 | |
298 | |
290 | return -1; |
299 | return -1; |
291 | } |
300 | } |
292 | #endif |
301 | #endif |
293 | |
302 | |
294 | /*{{{ Convert the keypress event into a string */ |
|
|
295 | void |
303 | void |
296 | rxvt_term::lookup_key (XKeyEvent &ev) |
304 | rxvt_term::key_press (XKeyEvent &ev) |
297 | { |
305 | { |
298 | int ctrl, meta, shft, len; |
306 | int ctrl, meta, shft, len; |
299 | unsigned int newlen; |
307 | unsigned int newlen; |
300 | KeySym keysym; |
308 | KeySym keysym; |
301 | #ifdef DEBUG_CMD |
|
|
302 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
303 | #endif |
|
|
304 | int valid_keysym; |
309 | int valid_keysym; |
305 | unsigned char kbuf[KBUFSZ]; |
310 | char kbuf[KBUFSZ]; |
|
|
311 | |
|
|
312 | #if ISO_14755 |
|
|
313 | if (iso14755buf & ISO_14755_52) |
|
|
314 | return; |
|
|
315 | #endif |
306 | |
316 | |
307 | /* |
317 | /* |
308 | * 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 |
309 | * escape sequence to toggle the Keypad. |
319 | * escape sequence to toggle the Keypad. |
310 | * |
320 | * |
… | |
… | |
328 | Status status_return; |
338 | Status status_return; |
329 | |
339 | |
330 | #if 0 |
340 | #if 0 |
331 | #ifdef X_HAVE_UTF8_STRING |
341 | #ifdef X_HAVE_UTF8_STRING |
332 | 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 |
333 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
343 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
334 | KBUFSZ, &keysym, &status_return); |
344 | KBUFSZ, &keysym, &status_return); |
335 | else |
345 | else |
336 | #endif |
346 | #endif |
337 | #endif |
347 | #endif |
338 | { |
348 | { |
… | |
… | |
375 | || status_return == XLookupBoth; |
385 | || status_return == XLookupBoth; |
376 | } |
386 | } |
377 | else |
387 | else |
378 | #endif |
388 | #endif |
379 | { |
389 | { |
380 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
390 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
381 | valid_keysym = keysym != NoSymbol; |
391 | valid_keysym = keysym != NoSymbol; |
382 | } |
392 | } |
383 | |
393 | |
384 | if (valid_keysym) |
394 | if (valid_keysym) |
385 | { |
395 | { |
… | |
… | |
437 | scr_move_to (0, 1); |
447 | scr_move_to (0, 1); |
438 | return; |
448 | return; |
439 | } |
449 | } |
440 | else if (keysym == XK_End) |
450 | else if (keysym == XK_End) |
441 | { |
451 | { |
442 | scr_move_to (1, 0); |
452 | scr_move_to (1, 1); |
443 | return; |
453 | return; |
444 | } |
454 | } |
445 | } |
455 | } |
446 | #endif |
456 | #endif |
447 | } |
457 | } |
… | |
… | |
458 | { |
468 | { |
459 | switch (keysym) |
469 | switch (keysym) |
460 | { |
470 | { |
461 | /* normal XTerm key bindings */ |
471 | /* normal XTerm key bindings */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
472 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
463 | selection_request (ev.time, 0, 0); |
473 | selection_request (ev.time); |
464 | return; |
474 | return; |
465 | #if TODO |
475 | #if TODO |
466 | /* rxvt extras */ |
476 | /* rxvt extras */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
477 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
468 | change_font (FONT_UP); |
478 | change_font (FONT_UP); |
… | |
… | |
849 | { |
859 | { |
850 | #ifdef META8_OPTION |
860 | #ifdef META8_OPTION |
851 | /* set 8-bit on */ |
861 | /* set 8-bit on */ |
852 | if (meta && (meta_char == 0x80)) |
862 | if (meta && (meta_char == 0x80)) |
853 | { |
863 | { |
854 | unsigned char *ch; |
864 | char *ch; |
855 | |
865 | |
856 | for (ch = kbuf; ch < kbuf + len; ch++) |
866 | for (ch = kbuf; ch < kbuf + len; ch++) |
857 | *ch |= 0x80; |
867 | *ch |= 0x80; |
858 | |
868 | |
859 | meta = 0; |
869 | meta = 0; |
860 | } |
870 | } |
861 | #endif |
871 | #endif |
862 | /* nil */ ; |
872 | /* nil */ ; |
863 | } |
873 | } |
864 | } |
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; |
865 | |
878 | |
866 | if (len <= 0) |
879 | if (len <= 0) |
867 | return; /* not mapped */ |
880 | return; /* not mapped */ |
868 | |
881 | |
869 | if (OPTION (Opt_scrollTtyKeypress)) |
882 | if (OPTION (Opt_scrollTtyKeypress)) |
… | |
… | |
892 | #ifdef META8_OPTION |
905 | #ifdef META8_OPTION |
893 | && meta_char == C0_ESC |
906 | && meta_char == C0_ESC |
894 | #endif |
907 | #endif |
895 | ) |
908 | ) |
896 | { |
909 | { |
897 | const unsigned char ch = C0_ESC; |
910 | const char ch = C0_ESC; |
898 | tt_write (&ch, 1); |
911 | tt_write (&ch, 1); |
899 | } |
912 | } |
900 | |
913 | |
901 | #if defined(DEBUG_CMD) |
|
|
902 | /* Display keyboard buffer contents */ |
|
|
903 | unsigned char *p; |
|
|
904 | int i; |
|
|
905 | |
|
|
906 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
907 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
908 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
909 | fprintf (stderr, "'\n"); |
|
|
910 | #endif /* DEBUG_CMD */ |
|
|
911 | tt_write (kbuf, (unsigned int)len); |
914 | tt_write (kbuf, (unsigned int)len); |
912 | } |
915 | } |
913 | /*}}} */ |
|
|
914 | |
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 | |
915 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
994 | #if defined (KEYSYM_RESOURCE) |
916 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
917 | /* attempt to `write' count to the input buffer */ |
|
|
918 | unsigned int |
995 | unsigned int |
919 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
996 | rxvt_term::cmd_write (const char *str, unsigned int count) |
920 | { |
997 | { |
921 | unsigned int n, s; |
998 | unsigned int n, s; |
922 | |
999 | |
923 | n = cmdbuf_ptr - cmdbuf_base; |
1000 | n = cmdbuf_ptr - cmdbuf_base; |
924 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
1001 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
961 | } |
1038 | } |
962 | #endif |
1039 | #endif |
963 | |
1040 | |
964 | if (want_refresh) |
1041 | if (want_refresh) |
965 | { |
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 | |
966 | scr_refresh (refresh_type); |
1081 | scr_refresh (); |
967 | scrollbar_show (1); |
1082 | scrollbar_show (1); |
968 | #ifdef USE_XIM |
1083 | #ifdef USE_XIM |
969 | IMSendSpot (); |
1084 | IMSendSpot (); |
970 | #endif |
1085 | #endif |
971 | } |
1086 | } |
… | |
… | |
974 | } |
1089 | } |
975 | |
1090 | |
976 | void |
1091 | void |
977 | rxvt_term::check_cb (check_watcher &w) |
1092 | rxvt_term::check_cb (check_watcher &w) |
978 | { |
1093 | { |
979 | SET_R (this); |
1094 | make_current (); |
980 | SET_LOCALE (locale); |
|
|
981 | |
1095 | |
982 | display->flush (); |
1096 | display->flush (); |
983 | |
1097 | |
984 | if (want_refresh && !flush_ev.active) |
1098 | if (want_refresh && !flush_ev.active) |
985 | flush_ev.start (NOW + 0.01); |
1099 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
986 | } |
1100 | } |
987 | |
1101 | |
988 | void |
1102 | void |
989 | rxvt_term::flush_cb (time_watcher &w) |
1103 | rxvt_term::flush_cb (time_watcher &w) |
990 | { |
1104 | { |
991 | SET_R (this); |
1105 | make_current (); |
992 | SET_LOCALE (locale); |
|
|
993 | |
1106 | |
994 | refresh_limit = 1; |
1107 | refresh_limit = 1; |
995 | refresh_count = 0; |
1108 | refresh_count = 0; |
996 | flush (); |
1109 | flush (); |
997 | } |
1110 | } |
… | |
… | |
1001 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1114 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1002 | { |
1115 | { |
1003 | hidden_cursor = !hidden_cursor; |
1116 | hidden_cursor = !hidden_cursor; |
1004 | want_refresh = 1; |
1117 | want_refresh = 1; |
1005 | |
1118 | |
1006 | w.start (w.at + BLINK_INTERVAL); |
1119 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1007 | } |
1120 | } |
1008 | #endif |
1121 | #endif |
1009 | |
1122 | |
1010 | #ifdef TEXT_BLINK |
1123 | #ifdef TEXT_BLINK |
1011 | void |
1124 | void |
… | |
… | |
1025 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1138 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1026 | { |
1139 | { |
1027 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1140 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1028 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1141 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1029 | { |
1142 | { |
1030 | refresh_type |= SMOOTH_REFRESH; |
|
|
1031 | want_refresh = 1; |
1143 | want_refresh = 1; |
1032 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1144 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1033 | } |
1145 | } |
1034 | } |
1146 | } |
1035 | #endif |
1147 | #endif |
… | |
… | |
1039 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1151 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1040 | { |
1152 | { |
1041 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1153 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1042 | { |
1154 | { |
1043 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1155 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1044 | refresh_type |= SMOOTH_REFRESH; |
|
|
1045 | want_refresh = 1; |
1156 | want_refresh = 1; |
1046 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1157 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1047 | } |
1158 | } |
1048 | } |
1159 | } |
1049 | #endif |
1160 | #endif |
… | |
… | |
1054 | { |
1165 | { |
1055 | if (mouse_slip_wheel_speed == 0 |
1166 | if (mouse_slip_wheel_speed == 0 |
1056 | || 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) |
1057 | : scr_page (UP, mouse_slip_wheel_speed)) |
1168 | : scr_page (UP, mouse_slip_wheel_speed)) |
1058 | { |
1169 | { |
1059 | if (view_start == nsaved || |
1170 | if (view_start == top_row || view_start == 0) |
1060 | view_start == 0) |
|
|
1061 | mouse_slip_wheel_speed = 0; |
1171 | mouse_slip_wheel_speed = 0; |
1062 | |
1172 | |
1063 | refresh_type |= SMOOTH_REFRESH; |
|
|
1064 | want_refresh = 1; |
1173 | want_refresh = 1; |
1065 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1174 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1066 | } |
1175 | } |
1067 | } |
1176 | } |
1068 | #endif |
1177 | #endif |
1069 | |
1178 | |
|
|
1179 | #if LINUX_YIELD_HACK |
|
|
1180 | static struct event_handler |
|
|
1181 | { |
|
|
1182 | check_watcher yield_ev; |
|
|
1183 | |
|
|
1184 | void yield_cb (check_watcher &w) |
|
|
1185 | { |
|
|
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 | |
|
|
1194 | w.stop (); |
|
|
1195 | } |
|
|
1196 | |
|
|
1197 | event_handler () |
|
|
1198 | : yield_ev (this, &event_handler::yield_cb) |
|
|
1199 | { |
|
|
1200 | } |
|
|
1201 | } event_handler; |
|
|
1202 | #endif |
|
|
1203 | |
1070 | bool |
1204 | bool |
1071 | rxvt_term::pty_fill () |
1205 | rxvt_term::pty_fill () |
1072 | { |
1206 | { |
1073 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1207 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1074 | |
1208 | |
1075 | if (CBUFSIZ == n) |
1209 | if (CBUFSIZ == n) |
1076 | { |
1210 | { |
1077 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1211 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1078 | n = 0; |
1212 | n = 0; |
1079 | } |
1213 | } |
1080 | |
1214 | |
1081 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1215 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1082 | cmdbuf_ptr = cmdbuf_base; |
1216 | cmdbuf_ptr = cmdbuf_base; |
1083 | cmdbuf_endp = cmdbuf_ptr + n; |
1217 | cmdbuf_endp = cmdbuf_ptr + n; |
1084 | |
1218 | |
1085 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1219 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1086 | |
1220 | |
1087 | if (n > 0) |
1221 | if (r > 0) |
1088 | { |
1222 | { |
1089 | cmdbuf_endp += n; |
1223 | cmdbuf_endp += r; |
1090 | return true; |
1224 | return true; |
1091 | } |
1225 | } |
1092 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1226 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1227 | { |
|
|
1228 | #if LINUX_YIELD_HACK |
|
|
1229 | if (display->is_local) |
|
|
1230 | event_handler.yield_ev.start (); |
|
|
1231 | #endif |
|
|
1232 | } |
|
|
1233 | else |
1093 | { |
1234 | { |
1094 | pty_ev.stop (); |
1235 | pty_ev.stop (); |
1095 | |
1236 | |
1096 | if (!OPTION (Opt_hold)) |
1237 | if (!OPTION (Opt_hold)) |
1097 | destroy (); |
1238 | destroy (); |
… | |
… | |
1101 | } |
1242 | } |
1102 | |
1243 | |
1103 | void |
1244 | void |
1104 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1245 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1105 | { |
1246 | { |
1106 | SET_R (this); |
1247 | make_current (); |
1107 | SET_LOCALE (locale); |
|
|
1108 | |
1248 | |
1109 | if (revents & EVENT_READ) |
1249 | if (revents & EVENT_READ) |
1110 | // loop, but don't allow a single term to monopolize us |
1250 | // loop, but don't allow a single term to monopolize us |
1111 | while (pty_fill ()) |
1251 | while (pty_fill ()) |
1112 | if (cmd_parse ()) |
1252 | if (cmd_parse ()) |
… | |
… | |
1117 | } |
1257 | } |
1118 | |
1258 | |
1119 | void |
1259 | void |
1120 | rxvt_term::pointer_unblank () |
1260 | rxvt_term::pointer_unblank () |
1121 | { |
1261 | { |
1122 | XDefineCursor (display->display, vt, TermWin_cursor); |
1262 | XDefineCursor (dpy, vt, TermWin_cursor); |
1123 | recolour_cursor (); |
1263 | recolour_cursor (); |
1124 | |
1264 | |
1125 | #ifdef POINTER_BLANK |
1265 | #ifdef POINTER_BLANK |
1126 | hidden_pointer = 0; |
1266 | hidden_pointer = 0; |
1127 | |
1267 | |
… | |
… | |
1132 | |
1272 | |
1133 | #ifdef POINTER_BLANK |
1273 | #ifdef POINTER_BLANK |
1134 | void |
1274 | void |
1135 | rxvt_term::pointer_blank () |
1275 | rxvt_term::pointer_blank () |
1136 | { |
1276 | { |
1137 | if (! OPTION (Opt_pointerBlank)) |
1277 | if (!OPTION (Opt_pointerBlank)) |
1138 | return; |
1278 | return; |
1139 | |
1279 | |
1140 | XDefineCursor (display->display, vt, display->blank_cursor); |
1280 | XDefineCursor (dpy, vt, display->blank_cursor); |
1141 | XFlush (display->display); |
1281 | XFlush (dpy); |
1142 | |
1282 | |
1143 | hidden_pointer = 1; |
1283 | hidden_pointer = 1; |
1144 | } |
1284 | } |
1145 | |
1285 | |
1146 | void |
1286 | void |
1147 | rxvt_term::pointer_cb (time_watcher &w) |
1287 | rxvt_term::pointer_cb (time_watcher &w) |
1148 | { |
1288 | { |
1149 | SET_R (this); |
1289 | make_current (); |
1150 | SET_LOCALE (locale); |
|
|
1151 | |
1290 | |
1152 | pointer_blank (); |
1291 | pointer_blank (); |
1153 | } |
1292 | } |
1154 | #endif |
1293 | #endif |
1155 | |
1294 | |
… | |
… | |
1220 | (32 + button_number + key_state), |
1359 | (32 + button_number + key_state), |
1221 | (32 + x + 1), |
1360 | (32 + x + 1), |
1222 | (32 + y + 1)); |
1361 | (32 + y + 1)); |
1223 | } |
1362 | } |
1224 | |
1363 | |
1225 | #ifdef USING_W11LIB |
|
|
1226 | void |
|
|
1227 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1228 | { |
|
|
1229 | rxvt_t *r = rxvt_get_r (); |
|
|
1230 | |
|
|
1231 | x_cb (*ev); |
|
|
1232 | } |
|
|
1233 | #endif |
|
|
1234 | |
|
|
1235 | /*{{{ process an X event */ |
1364 | /*{{{ process an X event */ |
1236 | void |
1365 | void |
1237 | rxvt_term::x_cb (XEvent &ev) |
1366 | rxvt_term::x_cb (XEvent &ev) |
1238 | { |
1367 | { |
1239 | dDisp; |
1368 | make_current (); |
1240 | |
1369 | |
1241 | SET_R (this); |
1370 | dLocal (Display *, dpy); |
1242 | SET_LOCALE (locale); |
|
|
1243 | |
1371 | |
1244 | #if defined(CURSOR_BLINK) |
1372 | if (ev.xany.window == vt |
1245 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1373 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1246 | { |
1374 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1247 | if (hidden_cursor) |
1375 | return; |
1248 | { |
|
|
1249 | hidden_cursor = 0; |
|
|
1250 | want_refresh = 1; |
|
|
1251 | } |
|
|
1252 | |
1376 | |
1253 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1377 | // for XQueryPointer |
1254 | } |
|
|
1255 | #endif |
|
|
1256 | |
|
|
1257 | #if defined(POINTER_BLANK) |
|
|
1258 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1259 | { |
|
|
1260 | if (ev.type == MotionNotify |
|
|
1261 | || ev.type == ButtonPress |
|
|
1262 | || ev.type == ButtonRelease) |
|
|
1263 | if (hidden_pointer) |
|
|
1264 | pointer_unblank (); |
|
|
1265 | |
|
|
1266 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1267 | pointer_blank (); |
|
|
1268 | } |
|
|
1269 | #endif |
|
|
1270 | |
|
|
1271 | Window unused_root, unused_child; |
1378 | Window unused_root, unused_child; |
1272 | int unused_root_x, unused_root_y; |
1379 | int unused_root_x, unused_root_y; |
1273 | unsigned int unused_mask; |
1380 | unsigned int unused_mask; |
1274 | |
1381 | |
1275 | switch (ev.type) |
1382 | switch (ev.type) |
1276 | { |
1383 | { |
1277 | case KeyPress: |
1384 | case KeyPress: |
1278 | #if ISO_14755 |
1385 | key_press (ev.xkey); |
1279 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1280 | #endif |
|
|
1281 | lookup_key (ev.xkey); |
|
|
1282 | |
|
|
1283 | break; |
1386 | break; |
1284 | |
1387 | |
1285 | case KeyRelease: |
1388 | case KeyRelease: |
1286 | { |
1389 | key_release (ev.xkey); |
1287 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1288 | KeySym ks; |
|
|
1289 | |
|
|
1290 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1291 | #endif |
|
|
1292 | |
|
|
1293 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1294 | // ISO 14755 support |
|
|
1295 | if (iso14755buf) |
|
|
1296 | if (iso14755buf & ISO_14755_52) |
|
|
1297 | { |
|
|
1298 | # if ENABLE_OVERLAY |
|
|
1299 | scr_overlay_off (); |
|
|
1300 | # endif |
|
|
1301 | # if ISO_14755 |
|
|
1302 | // iso14755 part 5.2 handling: release time |
|
|
1303 | // first: controls |
|
|
1304 | if ((ev.xkey.state & ControlMask) |
|
|
1305 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1306 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1307 | { |
|
|
1308 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1309 | commit_iso14755 (); |
|
|
1310 | return; // case-break; |
|
|
1311 | } |
|
|
1312 | |
|
|
1313 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1314 | if (i[0] == ks) |
|
|
1315 | { |
|
|
1316 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1317 | commit_iso14755 (); |
|
|
1318 | return; // case-break; |
|
|
1319 | } |
|
|
1320 | |
|
|
1321 | scr_bell (); |
|
|
1322 | # endif |
|
|
1323 | iso14755buf = 0; |
|
|
1324 | break; |
|
|
1325 | } |
|
|
1326 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1327 | { |
|
|
1328 | # if ENABLE_OVERLAY |
|
|
1329 | scr_overlay_off (); |
|
|
1330 | # endif |
|
|
1331 | if (iso14755buf & ISO_14755_51) |
|
|
1332 | commit_iso14755 (); |
|
|
1333 | #if ISO_14755 |
|
|
1334 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1335 | { |
|
|
1336 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1337 | |
|
|
1338 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1339 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1340 | } |
|
|
1341 | # endif |
|
|
1342 | else |
|
|
1343 | iso14755buf = 0; |
|
|
1344 | } |
|
|
1345 | #endif |
|
|
1346 | |
|
|
1347 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1348 | if (!(ev.xkey.state & ControlMask)) |
|
|
1349 | slip_wheel_ev.stop (); |
|
|
1350 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1351 | mouse_slip_wheel_speed = 0; |
|
|
1352 | #endif |
|
|
1353 | break; |
1390 | break; |
1354 | } |
|
|
1355 | |
1391 | |
1356 | case ButtonPress: |
1392 | case ButtonPress: |
1357 | button_press (ev.xbutton); |
1393 | button_press (ev.xbutton); |
1358 | break; |
1394 | break; |
1359 | |
1395 | |
… | |
… | |
1361 | button_release (ev.xbutton); |
1397 | button_release (ev.xbutton); |
1362 | break; |
1398 | break; |
1363 | |
1399 | |
1364 | case ClientMessage: |
1400 | case ClientMessage: |
1365 | if (ev.xclient.format == 32 |
1401 | if (ev.xclient.format == 32 |
1366 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1402 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1367 | { |
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 | { |
1368 | 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))) |
1369 | destroy (); |
1411 | destroy (); |
|
|
1412 | } |
1370 | #if ENABLE_EWMH |
1413 | #if ENABLE_EWMH |
1371 | 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]) |
1372 | XSendEvent (disp, ev.xclient.window = display->root, |
1415 | XSendEvent (dpy, ev.xclient.window = display->root, |
1373 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1416 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1374 | &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 | } |
1375 | #endif |
1429 | #endif |
1376 | } |
1430 | } |
1377 | #if ENABLE_XEMBED |
|
|
1378 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1379 | { |
|
|
1380 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1381 | focus_in (); |
|
|
1382 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1383 | focus_out (); |
|
|
1384 | } |
|
|
1385 | #endif |
|
|
1386 | #ifdef OFFIX_DND |
|
|
1387 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1388 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1389 | && (ev.xclient.data.l[0] == DndFile |
|
|
1390 | || ev.xclient.data.l[0] == DndDir |
|
|
1391 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1392 | { |
|
|
1393 | /* Get Dnd data */ |
|
|
1394 | Atom ActualType; |
|
|
1395 | int ActualFormat; |
|
|
1396 | unsigned char *data; |
|
|
1397 | unsigned long Size, RemainingBytes; |
|
|
1398 | |
|
|
1399 | XGetWindowProperty (disp, display->root, |
|
|
1400 | xa[XA_DNDSELECTION], |
|
|
1401 | 0L, 1000000L, |
|
|
1402 | False, AnyPropertyType, |
|
|
1403 | &ActualType, &ActualFormat, |
|
|
1404 | &Size, &RemainingBytes, |
|
|
1405 | &data); |
|
|
1406 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1407 | XFree (data); |
|
|
1408 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1409 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1410 | } |
|
|
1411 | #endif /* OFFIX_DND */ |
|
|
1412 | break; |
1431 | break; |
1413 | |
1432 | |
1414 | case MappingNotify: |
1433 | case MappingNotify: |
1415 | XRefreshKeyboardMapping (&ev.xmapping); |
1434 | XRefreshKeyboardMapping (&ev.xmapping); |
1416 | break; |
1435 | break; |
… | |
… | |
1439 | break; |
1458 | break; |
1440 | } |
1459 | } |
1441 | break; |
1460 | break; |
1442 | |
1461 | |
1443 | case FocusIn: |
1462 | case FocusIn: |
|
|
1463 | if (ev.xfocus.detail != NotifyInferior && ev.xfocus.detail != NotifyPointer) |
1444 | focus_in (); |
1464 | focus_in (); |
1445 | break; |
1465 | break; |
1446 | |
1466 | |
1447 | case FocusOut: |
1467 | case FocusOut: |
|
|
1468 | if (ev.xfocus.detail != NotifyInferior && ev.xfocus.detail != NotifyPointer) |
1448 | focus_out (); |
1469 | focus_out (); |
1449 | break; |
1470 | break; |
1450 | |
1471 | |
1451 | case ConfigureNotify: |
1472 | case ConfigureNotify: |
1452 | if (ev.xconfigure.window == parent[0]) |
1473 | if (ev.xconfigure.window == parent[0]) |
1453 | { |
1474 | { |
1454 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1475 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1455 | ; |
1476 | ; |
1456 | |
1477 | |
1457 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1478 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1458 | { |
1479 | { |
1459 | seen_resize = 1; |
1480 | seen_resize = 1; |
1460 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1481 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1461 | } |
1482 | } |
1462 | |
1483 | |
|
|
1484 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1485 | |
1463 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1486 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
|
|
1487 | #if 0 |
1464 | if (OPTION (Opt_transparent)) |
1488 | if (OPTION (Opt_transparent)) |
1465 | check_our_parents (); |
1489 | check_our_parents (); |
1466 | #endif |
1490 | #endif |
|
|
1491 | #endif |
1467 | } |
1492 | } |
1468 | break; |
1493 | break; |
1469 | |
1494 | |
1470 | case PropertyNotify: |
1495 | case PropertyNotify: |
|
|
1496 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1471 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1497 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1472 | && ev.xproperty.state == PropertyNewValue) |
1498 | && ev.xproperty.state == PropertyNewValue) |
1473 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1499 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1474 | |
1500 | |
1475 | break; |
1501 | break; |
1476 | |
1502 | |
1477 | case SelectionClear: |
1503 | case SelectionClear: |
1478 | selection_clear (); |
1504 | selection_clear (); |
… | |
… | |
1483 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1509 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1484 | break; |
1510 | break; |
1485 | |
1511 | |
1486 | case SelectionRequest: |
1512 | case SelectionRequest: |
1487 | selection_send (ev.xselectionrequest); |
1513 | selection_send (ev.xselectionrequest); |
|
|
1514 | break; |
|
|
1515 | |
|
|
1516 | case MapNotify: |
|
|
1517 | mapped = 1; |
|
|
1518 | #ifdef TEXT_BLINK |
|
|
1519 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1520 | #endif |
|
|
1521 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1488 | break; |
1522 | break; |
1489 | |
1523 | |
1490 | case UnmapNotify: |
1524 | case UnmapNotify: |
1491 | mapped = 0; |
1525 | mapped = 0; |
1492 | #ifdef TEXT_BLINK |
1526 | #ifdef TEXT_BLINK |
1493 | text_blink_ev.stop (); |
1527 | text_blink_ev.stop (); |
1494 | #endif |
1528 | #endif |
1495 | break; |
1529 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1496 | |
|
|
1497 | case MapNotify: |
|
|
1498 | mapped = 1; |
|
|
1499 | #ifdef TEXT_BLINK |
|
|
1500 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1501 | #endif |
|
|
1502 | break; |
1530 | break; |
1503 | |
1531 | |
1504 | #ifdef TRANSPARENT |
1532 | #ifdef TRANSPARENT |
1505 | case ReparentNotify: |
1533 | case ReparentNotify: |
1506 | rootwin_cb (ev); |
1534 | rootwin_cb (ev); |
… | |
… | |
1512 | if (ev.xany.window == vt) |
1540 | if (ev.xany.window == vt) |
1513 | { |
1541 | { |
1514 | do |
1542 | do |
1515 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1543 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1516 | ev.xexpose.width, ev.xexpose.height, False); |
1544 | ev.xexpose.width, ev.xexpose.height, False); |
1517 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1545 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1518 | |
1546 | |
1519 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1547 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1520 | |
1548 | |
1521 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1549 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1522 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1550 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1523 | ev.xexpose.width, ev.xexpose.height, False); |
1551 | ev.xexpose.width, ev.xexpose.height, False); |
1524 | |
1552 | |
1525 | scr_refresh (refresh_type); |
1553 | want_refresh = 1; |
1526 | } |
1554 | } |
1527 | else |
1555 | else |
1528 | { |
1556 | { |
1529 | XEvent unused_event; |
1557 | XEvent unused_event; |
1530 | |
1558 | |
1531 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1559 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1532 | ; |
1560 | ; |
1533 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1561 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1534 | ; |
1562 | ; |
1535 | |
1563 | |
1536 | if (isScrollbarWindow (ev.xany.window)) |
1564 | if (isScrollbarWindow (ev.xany.window)) |
1537 | { |
1565 | { |
1538 | scrollBar.setIdle (); |
1566 | scrollBar.setIdle (); |
1539 | scrollbar_show (0); |
1567 | scrollbar_show (0); |
1540 | } |
1568 | } |
1541 | #ifdef MENUBAR |
|
|
1542 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1543 | menubar_expose (); |
|
|
1544 | #endif |
|
|
1545 | |
1569 | |
1546 | #ifdef TRANSPARENT |
1570 | #ifdef TRANSPARENT |
1547 | if (am_transparent && ev.xany.window == parent[0]) |
1571 | if (am_transparent && ev.xany.window == parent[0]) |
1548 | XClearWindow (disp, ev.xany.window); |
1572 | XClearWindow (dpy, ev.xany.window); |
1549 | #endif |
1573 | #endif |
1550 | } |
1574 | } |
1551 | break; |
1575 | break; |
1552 | |
1576 | |
1553 | case MotionNotify: |
1577 | case MotionNotify: |
1554 | #ifdef POINTER_BLANK |
1578 | #ifdef POINTER_BLANK |
1555 | if (hidden_pointer) |
1579 | if (hidden_pointer) |
1556 | pointer_unblank (); |
1580 | pointer_unblank (); |
1557 | #endif |
1581 | #endif |
1558 | #if MENUBAR |
|
|
1559 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1560 | { |
|
|
1561 | menubar_control (ev.xbutton); |
|
|
1562 | break; |
|
|
1563 | } |
|
|
1564 | #endif |
|
|
1565 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1582 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1566 | break; |
1583 | break; |
1567 | |
1584 | |
1568 | if (ev.xany.window == vt) |
1585 | if (ev.xany.window == vt) |
1569 | { |
1586 | { |
|
|
1587 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1588 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1589 | ; // nop |
1570 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1590 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1571 | { |
1591 | { |
1572 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1592 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1573 | ; |
1593 | ; |
1574 | |
1594 | |
1575 | XQueryPointer (disp, vt, |
1595 | XQueryPointer (dpy, vt, |
1576 | &unused_root, &unused_child, |
1596 | &unused_root, &unused_child, |
1577 | &unused_root_x, &unused_root_y, |
1597 | &unused_root_x, &unused_root_y, |
1578 | &ev.xbutton.x, &ev.xbutton.y, |
1598 | &ev.xbutton.x, &ev.xbutton.y, |
1579 | &ev.xbutton.state); |
1599 | &ev.xbutton.state); |
1580 | #ifdef MOUSE_THRESHOLD |
1600 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1644 | #endif |
1664 | #endif |
1645 | } |
1665 | } |
1646 | } |
1666 | } |
1647 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1667 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1648 | { |
1668 | { |
1649 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1669 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1650 | MotionNotify, &ev)) |
1670 | MotionNotify, &ev)) |
1651 | ; |
1671 | ; |
1652 | |
1672 | |
1653 | XQueryPointer (disp, scrollBar.win, |
1673 | XQueryPointer (dpy, scrollBar.win, |
1654 | &unused_root, &unused_child, |
1674 | &unused_root, &unused_child, |
1655 | &unused_root_x, &unused_root_y, |
1675 | &unused_root_x, &unused_root_y, |
1656 | &ev.xbutton.x, &ev.xbutton.y, |
1676 | &ev.xbutton.x, &ev.xbutton.y, |
1657 | &unused_mask); |
1677 | &unused_mask); |
1658 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1678 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1659 | scrollbar_size ()); |
1679 | scrollbar_size ()); |
1660 | scr_refresh (refresh_type); |
1680 | want_refresh = 1; |
1661 | refresh_limit = 0; |
1681 | refresh_limit = 0; |
1662 | scrollbar_show (1); |
1682 | scrollbar_show (1); |
1663 | } |
1683 | } |
1664 | break; |
1684 | break; |
1665 | } |
1685 | } |
|
|
1686 | |
|
|
1687 | #if defined(CURSOR_BLINK) |
|
|
1688 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1689 | { |
|
|
1690 | if (hidden_cursor) |
|
|
1691 | { |
|
|
1692 | hidden_cursor = 0; |
|
|
1693 | want_refresh = 1; |
|
|
1694 | } |
|
|
1695 | |
|
|
1696 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1697 | } |
|
|
1698 | #endif |
|
|
1699 | |
|
|
1700 | #if defined(POINTER_BLANK) |
|
|
1701 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1702 | { |
|
|
1703 | if (ev.type == MotionNotify |
|
|
1704 | || ev.type == ButtonPress |
|
|
1705 | || ev.type == ButtonRelease) |
|
|
1706 | if (hidden_pointer) |
|
|
1707 | pointer_unblank (); |
|
|
1708 | |
|
|
1709 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1710 | pointer_blank (); |
|
|
1711 | } |
|
|
1712 | #endif |
1666 | } |
1713 | } |
1667 | |
1714 | |
1668 | void |
1715 | void |
1669 | rxvt_term::focus_in () |
1716 | rxvt_term::focus_in () |
1670 | { |
1717 | { |
1671 | if (!focus) |
1718 | if (!focus) |
1672 | { |
1719 | { |
1673 | focus = 1; |
1720 | focus = 1; |
1674 | want_refresh = 1; |
1721 | want_refresh = 1; |
|
|
1722 | |
|
|
1723 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1724 | |
1675 | #if USE_XIM |
1725 | #if USE_XIM |
1676 | if (Input_Context != NULL) |
1726 | if (Input_Context != NULL) |
1677 | { |
1727 | { |
1678 | IMSetStatusPosition (); |
1728 | IMSetPosition (); |
1679 | XSetICFocus (Input_Context); |
1729 | XSetICFocus (Input_Context); |
1680 | } |
1730 | } |
1681 | #endif |
1731 | #endif |
1682 | #if CURSOR_BLINK |
1732 | #if CURSOR_BLINK |
1683 | if (OPTION (Opt_cursorBlink)) |
1733 | if (OPTION (Opt_cursorBlink)) |
1684 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1734 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1685 | #endif |
1735 | #endif |
1686 | #if OFF_FOCUS_FADING |
1736 | #if OFF_FOCUS_FADING |
1687 | if (rs[Rs_fade]) |
1737 | if (rs[Rs_fade]) |
1688 | { |
1738 | { |
1689 | pix_colors = pix_colors_focused; |
1739 | pix_colors = pix_colors_focused; |
… | |
… | |
1699 | if (focus) |
1749 | if (focus) |
1700 | { |
1750 | { |
1701 | focus = 0; |
1751 | focus = 0; |
1702 | want_refresh = 1; |
1752 | want_refresh = 1; |
1703 | |
1753 | |
|
|
1754 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1755 | |
1704 | #if ENABLE_FRILLS || ISO_14755 |
1756 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1757 | if (iso14755buf) |
|
|
1758 | { |
1705 | iso14755buf = 0; |
1759 | iso14755buf = 0; |
1706 | #endif |
|
|
1707 | #if ENABLE_OVERLAY |
1760 | # if ENABLE_OVERLAY |
1708 | scr_overlay_off (); |
1761 | scr_overlay_off (); |
|
|
1762 | # endif |
|
|
1763 | } |
1709 | #endif |
1764 | #endif |
1710 | #if USE_XIM |
1765 | #if USE_XIM |
1711 | if (Input_Context != NULL) |
1766 | if (Input_Context != NULL) |
1712 | XUnsetICFocus (Input_Context); |
1767 | XUnsetICFocus (Input_Context); |
1713 | #endif |
1768 | #endif |
… | |
… | |
1724 | } |
1779 | } |
1725 | #endif |
1780 | #endif |
1726 | } |
1781 | } |
1727 | } |
1782 | } |
1728 | |
1783 | |
1729 | #if TRANSPARENT |
1784 | void |
|
|
1785 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1786 | { |
|
|
1787 | #if OFF_FOCUS_FADING |
|
|
1788 | if (rs[Rs_fade]) |
|
|
1789 | { |
|
|
1790 | rgba c; |
|
|
1791 | pix_colors [Color_fade].get (c); |
|
|
1792 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1793 | } |
|
|
1794 | #endif |
|
|
1795 | } |
|
|
1796 | |
|
|
1797 | #if TRANSPARENT || ENABLE_PERL |
1730 | void |
1798 | void |
1731 | rxvt_term::rootwin_cb (XEvent &ev) |
1799 | rxvt_term::rootwin_cb (XEvent &ev) |
1732 | { |
1800 | { |
1733 | SET_R (this); |
1801 | make_current (); |
1734 | SET_LOCALE (locale); |
|
|
1735 | |
1802 | |
|
|
1803 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1804 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1805 | return; |
|
|
1806 | |
|
|
1807 | # if TRANSPARENT |
1736 | switch (ev.type) |
1808 | switch (ev.type) |
1737 | { |
1809 | { |
1738 | case PropertyNotify: |
1810 | case PropertyNotify: |
1739 | /* |
1811 | /* |
1740 | * if user used some Esetroot compatible prog to set the root bg, |
1812 | * if user used some Esetroot compatible prog to set the root bg, |
… | |
… | |
1748 | case ReparentNotify: |
1820 | case ReparentNotify: |
1749 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1821 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1750 | want_refresh = want_full_refresh = 1; |
1822 | want_refresh = want_full_refresh = 1; |
1751 | break; |
1823 | break; |
1752 | } |
1824 | } |
|
|
1825 | # endif |
1753 | } |
1826 | } |
1754 | #endif |
1827 | #endif |
1755 | |
1828 | |
1756 | void |
1829 | void |
1757 | rxvt_term::button_press (XButtonEvent &ev) |
1830 | rxvt_term::button_press (XButtonEvent &ev) |
1758 | { |
1831 | { |
1759 | int reportmode = 0, clickintime; |
1832 | int reportmode = 0, clickintime; |
1760 | |
1833 | |
1761 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1834 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1835 | |
1762 | if (!bypass_keystate) |
1836 | if (!bypass_keystate) |
1763 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1837 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1764 | |
1838 | |
1765 | /* |
1839 | /* |
1766 | * VT window processing of button press |
1840 | * VT window processing of button press |
1767 | */ |
1841 | */ |
1768 | if (ev.window == vt) |
1842 | if (ev.window == vt) |
1769 | { |
1843 | { |
|
|
1844 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1845 | return; |
|
|
1846 | |
1770 | #if ISO_14755 |
1847 | #if ISO_14755 |
1771 | // 5.4 |
1848 | // 5.4 |
1772 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1849 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1773 | { |
1850 | { |
1774 | iso14755_54 (ev.x, ev.y); |
1851 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1786 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1863 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1787 | if (ev.button == MEvent.button && clickintime) |
1864 | if (ev.button == MEvent.button && clickintime) |
1788 | { |
1865 | { |
1789 | /* same button, within alloted time */ |
1866 | /* same button, within alloted time */ |
1790 | MEvent.clicks++; |
1867 | MEvent.clicks++; |
|
|
1868 | |
1791 | if (MEvent.clicks > 1) |
1869 | if (MEvent.clicks > 1) |
1792 | { |
1870 | { |
1793 | /* only report double clicks */ |
1871 | /* only report double clicks */ |
1794 | MEvent.clicks = 2; |
1872 | MEvent.clicks = 2; |
1795 | mouse_report (ev); |
1873 | mouse_report (ev); |
… | |
… | |
1827 | #else |
1905 | #else |
1828 | selection.rect = false; |
1906 | selection.rect = false; |
1829 | #endif |
1907 | #endif |
1830 | |
1908 | |
1831 | /* allow shift+left click to extend selection */ |
1909 | /* allow shift+left click to extend selection */ |
1832 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1910 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1833 | { |
1911 | { |
1834 | if (MEvent.button == Button1 && clickintime) |
1912 | if (MEvent.button == Button1 && clickintime) |
1835 | selection_rotate (ev.x, ev.y); |
1913 | selection_rotate (ev.x, ev.y); |
1836 | else |
1914 | else |
1837 | selection_extend (ev.x, ev.y, 1); |
1915 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2002 | } |
2080 | } |
2003 | |
2081 | |
2004 | break; |
2082 | break; |
2005 | } |
2083 | } |
2006 | } |
2084 | } |
|
|
2085 | |
2007 | return; |
2086 | return; |
2008 | } |
2087 | } |
2009 | #if MENUBAR |
|
|
2010 | /* |
|
|
2011 | * Menubar window processing of button press |
|
|
2012 | */ |
|
|
2013 | if (isMenuBarWindow (ev.window)) |
|
|
2014 | menubar_control (ev); |
|
|
2015 | #endif |
|
|
2016 | } |
2088 | } |
2017 | |
2089 | |
2018 | void |
2090 | void |
2019 | rxvt_term::button_release (XButtonEvent &ev) |
2091 | rxvt_term::button_release (XButtonEvent &ev) |
2020 | { |
2092 | { |
… | |
… | |
2026 | |
2098 | |
2027 | if (scrollbar_isUpDn ()) |
2099 | if (scrollbar_isUpDn ()) |
2028 | { |
2100 | { |
2029 | scrollBar.setIdle (); |
2101 | scrollBar.setIdle (); |
2030 | scrollbar_show (0); |
2102 | scrollbar_show (0); |
2031 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2032 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2033 | #endif |
|
|
2034 | } |
2103 | } |
2035 | |
2104 | |
2036 | #ifdef SELECTION_SCROLLING |
2105 | #ifdef SELECTION_SCROLLING |
2037 | if (sel_scroll_ev.active) |
2106 | if (sel_scroll_ev.active) |
2038 | sel_scroll_ev.stop(); |
2107 | sel_scroll_ev.stop(); |
2039 | #endif |
2108 | #endif |
2040 | |
2109 | |
2041 | if (ev.window == vt) |
2110 | if (ev.window == vt) |
2042 | { |
2111 | { |
|
|
2112 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2113 | return; |
|
|
2114 | |
2043 | #if ISO_14755 |
2115 | #if ISO_14755 |
2044 | // 5.4 |
2116 | // 5.4 |
2045 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2117 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2046 | return; |
2118 | return; |
2047 | #endif |
2119 | #endif |
|
|
2120 | |
2048 | if (reportmode) |
2121 | if (reportmode) |
2049 | { |
2122 | { |
2050 | /* mouse report from vt window */ |
2123 | /* mouse report from vt window */ |
2051 | /* don't report release of wheel "buttons" */ |
2124 | /* don't report release of wheel "buttons" */ |
2052 | if (ev.button >= 4) |
2125 | if (ev.button >= 4) |
… | |
… | |
2082 | { |
2155 | { |
2083 | case Button1: |
2156 | case Button1: |
2084 | case Button3: |
2157 | case Button3: |
2085 | selection_make (ev.time); |
2158 | selection_make (ev.time); |
2086 | break; |
2159 | break; |
|
|
2160 | |
2087 | case Button2: |
2161 | case Button2: |
2088 | selection_request (ev.time, ev.x, ev.y); |
2162 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2163 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2089 | break; |
2164 | break; |
|
|
2165 | |
2090 | #ifdef MOUSE_WHEEL |
2166 | #ifdef MOUSE_WHEEL |
2091 | case Button4: |
2167 | case Button4: |
2092 | case Button5: |
2168 | case Button5: |
2093 | { |
2169 | { |
2094 | int i; |
2170 | int i; |
… | |
… | |
2116 | slip_wheel_ev.start (); |
2192 | slip_wheel_ev.start (); |
2117 | } |
2193 | } |
2118 | else |
2194 | else |
2119 | { |
2195 | { |
2120 | # endif |
2196 | # endif |
2121 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2122 | scr_page (v, i); |
2197 | scr_page (v, i); |
2123 | scr_refresh (SMOOTH_REFRESH); |
|
|
2124 | scrollbar_show (1); |
2198 | scrollbar_show (1); |
2125 | # else |
|
|
2126 | while (i--) |
|
|
2127 | { |
|
|
2128 | scr_page (v, 1); |
|
|
2129 | scr_refresh (SMOOTH_REFRESH); |
|
|
2130 | scrollbar_show (1); |
|
|
2131 | } |
|
|
2132 | # endif |
|
|
2133 | # ifdef MOUSE_SLIP_WHEELING |
2199 | # ifdef MOUSE_SLIP_WHEELING |
2134 | } |
2200 | } |
2135 | #endif |
2201 | # endif |
2136 | } |
2202 | } |
2137 | break; |
2203 | break; |
2138 | #endif |
2204 | #endif |
2139 | } |
2205 | } |
2140 | } |
2206 | } |
2141 | #ifdef MENUBAR |
|
|
2142 | else if (isMenuBarWindow (ev.window)) |
|
|
2143 | menubar_control (ev); |
|
|
2144 | #endif |
|
|
2145 | } |
2207 | } |
2146 | |
2208 | |
2147 | #ifdef TRANSPARENT |
2209 | #ifdef TRANSPARENT |
2148 | #if TINTING |
2210 | #if TINTING |
2149 | /* taken from aterm-0.4.2 */ |
2211 | /* taken from aterm-0.4.2 */ |
2150 | |
2212 | |
2151 | typedef uint32_t RUINT32T; |
2213 | typedef uint32_t RUINT32T; |
2152 | |
2214 | |
2153 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
2215 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
2154 | { |
2216 | { |
2155 | int sh_r, sh_g, sh_b; |
2217 | int sh_r, sh_g, sh_b; |
2156 | RUINT32T mask_r, mask_g, mask_b; |
2218 | RUINT32T mask_r, mask_g, mask_b; |
2157 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2219 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2158 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2220 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2159 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2221 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2160 | int i; |
2222 | int i; |
2161 | |
2223 | |
2162 | Visual *visual = display->visual; |
2224 | Visual *visual = term->visual; |
2163 | |
2225 | |
2164 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2226 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2165 | |
2227 | |
2166 | /* for convenience */ |
2228 | /* for convenience */ |
2167 | mask_r = visual->red_mask; |
2229 | mask_r = visual->red_mask; |
… | |
… | |
2388 | Atom atype; |
2450 | Atom atype; |
2389 | unsigned char *prop = NULL; |
2451 | unsigned char *prop = NULL; |
2390 | Window root, oldp, *list; |
2452 | Window root, oldp, *list; |
2391 | Pixmap rootpixmap = None; |
2453 | Pixmap rootpixmap = None; |
2392 | XWindowAttributes wattr, wrootattr; |
2454 | XWindowAttributes wattr, wrootattr; |
2393 | dDisp; |
|
|
2394 | |
2455 | |
2395 | pchanged = 0; |
2456 | pchanged = 0; |
2396 | |
2457 | |
2397 | if (!OPTION (Opt_transparent)) |
2458 | if (!OPTION (Opt_transparent)) |
2398 | return pchanged; /* Don't try any more */ |
2459 | return pchanged; /* Don't try any more */ |
2399 | |
2460 | |
2400 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2461 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
2401 | rootdepth = wrootattr.depth; |
2462 | rootdepth = wrootattr.depth; |
2402 | |
2463 | |
2403 | XGetWindowAttributes (disp, parent[0], &wattr); |
2464 | XGetWindowAttributes (dpy, parent[0], &wattr); |
2404 | |
2465 | |
2405 | if (rootdepth != wattr.depth) |
2466 | if (rootdepth != wattr.depth) |
2406 | { |
2467 | { |
2407 | if (am_transparent) |
2468 | if (am_transparent) |
2408 | { |
2469 | { |
2409 | pchanged = 1; |
2470 | pchanged = 1; |
2410 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2471 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2411 | am_transparent = am_pixmap_trans = 0; |
2472 | am_transparent = am_pixmap_trans = 0; |
2412 | } |
2473 | } |
2413 | |
2474 | |
2414 | return pchanged; /* Don't try any more */ |
2475 | return pchanged; /* Don't try any more */ |
2415 | } |
2476 | } |
2416 | |
2477 | |
2417 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2478 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2418 | XSync (disp, False); |
2479 | XSync (dpy, False); |
2419 | |
2480 | |
2420 | /* |
2481 | /* |
2421 | * Make the frame window set by the window manager have |
2482 | * Make the frame window set by the window manager have |
2422 | * the root background. Some window managers put multiple nested frame |
2483 | * the root background. Some window managers put multiple nested frame |
2423 | * windows for each client, so we have to take care about that. |
2484 | * windows for each client, so we have to take care about that. |
2424 | */ |
2485 | */ |
2425 | i = (xa[XA_XROOTPMAP_ID] |
2486 | i = (xa[XA_XROOTPMAP_ID] |
2426 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2487 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
2427 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2488 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2428 | &nitems, &bytes_after, &prop) == Success); |
2489 | &nitems, &bytes_after, &prop) == Success); |
2429 | |
2490 | |
2430 | if (!i || prop == NULL) |
2491 | if (!i || prop == NULL) |
2431 | i = (xa[XA_ESETROOT_PMAP_ID] |
2492 | i = (xa[XA_ESETROOT_PMAP_ID] |
2432 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2493 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
2433 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2494 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2434 | &nitems, &bytes_after, &prop) == Success); |
2495 | &nitems, &bytes_after, &prop) == Success); |
2435 | |
2496 | |
2436 | if (!i || prop == NULL |
2497 | if (!i || prop == NULL |
2437 | #if TINTING |
2498 | #if TINTING |
2438 | || !rs[Rs_color + Color_tint] |
2499 | || !ISSET_PIXCOLOR (Color_tint) |
2439 | #endif |
2500 | #endif |
2440 | ) |
2501 | ) |
2441 | have_pixmap = 0; |
2502 | have_pixmap = 0; |
2442 | else |
2503 | else |
2443 | { |
2504 | { |
… | |
… | |
2456 | Window cr; |
2517 | Window cr; |
2457 | XImage *image; |
2518 | XImage *image; |
2458 | GC gc; |
2519 | GC gc; |
2459 | XGCValues gcvalue; |
2520 | XGCValues gcvalue; |
2460 | |
2521 | |
2461 | XTranslateCoordinates (disp, parent[0], display->root, |
2522 | XTranslateCoordinates (dpy, parent[0], display->root, |
2462 | 0, 0, &sx, &sy, &cr); |
2523 | 0, 0, &sx, &sy, &cr); |
2463 | nw = (unsigned int)szHint.width; |
2524 | nw = (unsigned int)szHint.width; |
2464 | nh = (unsigned int)szHint.height; |
2525 | nh = (unsigned int)szHint.height; |
2465 | nx = ny = 0; |
2526 | nx = ny = 0; |
2466 | |
2527 | |
… | |
… | |
2479 | } |
2540 | } |
2480 | |
2541 | |
2481 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2542 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2482 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2543 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2483 | |
2544 | |
2484 | XSync (disp, False); |
2545 | XSync (dpy, False); |
2485 | allowedxerror = -1; |
2546 | allowedxerror = -1; |
2486 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2547 | image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2487 | |
2548 | |
2488 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2549 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2489 | /* XXX: may need a delay here? */ |
2550 | /* XXX: may need a delay here? */ |
2490 | allowedxerror = 0; |
2551 | allowedxerror = 0; |
2491 | |
2552 | |
… | |
… | |
2494 | if (am_transparent && am_pixmap_trans) |
2555 | if (am_transparent && am_pixmap_trans) |
2495 | { |
2556 | { |
2496 | pchanged = 1; |
2557 | pchanged = 1; |
2497 | if (pixmap != None) |
2558 | if (pixmap != None) |
2498 | { |
2559 | { |
2499 | XFreePixmap (disp, pixmap); |
2560 | XFreePixmap (dpy, pixmap); |
2500 | pixmap = None; |
2561 | pixmap = None; |
2501 | } |
2562 | } |
2502 | } |
2563 | } |
2503 | |
2564 | |
2504 | am_pixmap_trans = 0; |
2565 | am_pixmap_trans = 0; |
2505 | } |
2566 | } |
2506 | else |
2567 | else |
2507 | { |
2568 | { |
2508 | if (pixmap != None) |
2569 | if (pixmap != None) |
2509 | XFreePixmap (disp, pixmap); |
2570 | XFreePixmap (dpy, pixmap); |
2510 | |
2571 | |
2511 | #if TINTING |
2572 | #if TINTING |
2512 | if (ISSET_PIXCOLOR (Color_tint)) |
2573 | if (ISSET_PIXCOLOR (Color_tint)) |
2513 | { |
2574 | { |
2514 | unsigned short rm, gm, bm; |
|
|
2515 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2575 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2516 | |
2576 | |
|
|
2577 | rgba c; |
2517 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
2578 | pix_colors_focused [Color_tint].get (c); |
2518 | |
2579 | |
2519 | ShadeXImage (display, image, shade, rm, gm, bm); |
2580 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2520 | } |
2581 | } |
2521 | #endif |
2582 | #endif |
2522 | |
2583 | |
2523 | pixmap = XCreatePixmap (disp, vt, |
2584 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); |
2524 | szHint.width, szHint.height, image->depth); |
|
|
2525 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
2585 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
2526 | XPutImage (disp, pixmap, gc, image, 0, 0, |
2586 | XPutImage (dpy, pixmap, gc, image, 0, 0, |
2527 | nx, ny, image->width, image->height); |
2587 | nx, ny, image->width, image->height); |
2528 | XFreeGC (disp, gc); |
2588 | XFreeGC (dpy, gc); |
2529 | XDestroyImage (image); |
2589 | XDestroyImage (image); |
2530 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
2590 | XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); |
2531 | XClearWindow (disp, parent[0]); |
2591 | XClearWindow (dpy, parent[0]); |
2532 | |
2592 | |
2533 | if (!am_transparent || !am_pixmap_trans) |
2593 | if (!am_transparent || !am_pixmap_trans) |
2534 | pchanged = 1; |
2594 | pchanged = 1; |
2535 | |
2595 | |
2536 | am_transparent = am_pixmap_trans = 1; |
2596 | am_transparent = am_pixmap_trans = 1; |
2537 | } |
2597 | } |
2538 | } |
2598 | } |
2539 | |
2599 | |
2540 | if (am_pixmap_trans) |
2600 | if (am_pixmap_trans) |
2541 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2601 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2542 | else |
2602 | else |
2543 | { |
2603 | { |
2544 | unsigned int n; |
2604 | unsigned int n; |
2545 | /* |
2605 | /* |
2546 | * InheritPixmap transparency |
2606 | * InheritPixmap transparency |
2547 | */ |
2607 | */ |
2548 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2608 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2549 | { |
2609 | { |
2550 | oldp = parent[i]; |
2610 | oldp = parent[i]; |
2551 | XQueryTree (disp, parent[i - 1], &root, |
2611 | XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n); |
2552 | &parent[i], &list, &n); |
|
|
2553 | XFree (list); |
2612 | XFree (list); |
2554 | |
2613 | |
2555 | if (parent[i] == display->root) |
2614 | if (parent[i] == display->root) |
2556 | { |
2615 | { |
2557 | if (oldp != None) |
2616 | if (oldp != None) |
… | |
… | |
2565 | } |
2624 | } |
2566 | |
2625 | |
2567 | n = 0; |
2626 | n = 0; |
2568 | |
2627 | |
2569 | if (pchanged) |
2628 | if (pchanged) |
2570 | { |
|
|
2571 | for (; n < (unsigned int)i; n++) |
2629 | for (; n < (unsigned int)i; n++) |
2572 | { |
2630 | { |
2573 | XGetWindowAttributes (disp, parent[n], &wattr); |
2631 | XGetWindowAttributes (dpy, parent[n], &wattr); |
|
|
2632 | |
2574 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2633 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2575 | { |
2634 | { |
2576 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2635 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2577 | break; |
2636 | break; |
2578 | } |
2637 | } |
2579 | } |
2638 | } |
2580 | } |
|
|
2581 | |
2639 | |
2582 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2640 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2583 | { |
2641 | { |
2584 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
2642 | XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]); |
2585 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2643 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2586 | am_transparent = 0; |
2644 | am_transparent = 0; |
2587 | /* XXX: also turn off Opt_transparent? */ |
2645 | /* XXX: also turn off Opt_transparent? */ |
2588 | } |
2646 | } |
2589 | else |
2647 | else |
2590 | { |
2648 | { |
2591 | #if WAIT_FOR_WM |
|
|
2592 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2593 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2594 | sleep (1); |
|
|
2595 | #endif |
|
|
2596 | for (n = 0; n < (unsigned int)i; n++) |
2649 | for (n = 0; n < (unsigned int)i; n++) |
2597 | { |
2650 | { |
2598 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2651 | XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative); |
2599 | XClearWindow (disp, parent[n]); |
2652 | XClearWindow (dpy, parent[n]); |
2600 | } |
2653 | } |
2601 | |
2654 | |
2602 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2655 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2603 | am_transparent = 1; |
2656 | am_transparent = 1; |
2604 | } |
2657 | } |
2605 | |
2658 | |
2606 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2659 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2607 | parent[i] = None; |
2660 | parent[i] = None; |
2608 | } |
2661 | } |
2609 | |
2662 | |
2610 | if (scrollBar.win) |
2663 | if (scrollBar.win) |
2611 | { |
2664 | { |
2612 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2665 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2613 | scrollBar.setIdle (); |
2666 | scrollBar.setIdle (); |
2614 | scrollbar_show (0); |
2667 | scrollbar_show (0); |
2615 | } |
2668 | } |
2616 | |
2669 | |
2617 | if (am_transparent) |
2670 | if (am_transparent) |
… | |
… | |
2629 | |
2682 | |
2630 | bool |
2683 | bool |
2631 | rxvt_term::cmd_parse () |
2684 | rxvt_term::cmd_parse () |
2632 | { |
2685 | { |
2633 | bool flag = false; |
2686 | bool flag = false; |
2634 | unicode_t ch = NOCHAR; |
2687 | wchar_t ch = NOCHAR; |
2635 | unsigned char *seq_begin; // remember start of esc-sequence here |
2688 | char *seq_begin; // remember start of esc-sequence here |
2636 | |
2689 | |
2637 | for (;;) |
2690 | for (;;) |
2638 | { |
2691 | { |
2639 | if (ch == NOCHAR) |
2692 | if (ch == NOCHAR) |
2640 | { |
2693 | { |
2641 | seq_begin = cmdbuf_ptr; |
2694 | seq_begin = cmdbuf_ptr; |
2642 | ch = next_char (); |
2695 | ch = next_char (); |
2643 | } |
|
|
2644 | |
2696 | |
2645 | if (ch == NOCHAR) // TODO: improve |
2697 | if (ch == NOCHAR) |
2646 | break; |
2698 | break; |
|
|
2699 | } |
2647 | |
2700 | |
2648 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2701 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2649 | { |
2702 | { |
2650 | if (!seen_input) |
2703 | if (!seen_input) |
2651 | { |
2704 | { |
… | |
… | |
2660 | if (seen_resize && cmd_pid) |
2713 | if (seen_resize && cmd_pid) |
2661 | kill (-cmd_pid, SIGWINCH); |
2714 | kill (-cmd_pid, SIGWINCH); |
2662 | } |
2715 | } |
2663 | |
2716 | |
2664 | /* Read a text string from the input buffer */ |
2717 | /* Read a text string from the input buffer */ |
2665 | unicode_t buf[UBUFSIZ]; |
2718 | wchar_t buf[UBUFSIZ]; |
2666 | bool refreshnow = false; |
2719 | bool refreshnow = false; |
2667 | int nlines = 0; |
2720 | int nlines = 0; |
2668 | unicode_t *str = buf; |
2721 | wchar_t *str = buf; |
2669 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2722 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2670 | |
2723 | |
2671 | for (;;) |
2724 | for (;;) |
2672 | { |
2725 | { |
2673 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2726 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2674 | break; |
2727 | break; |
… | |
… | |
2684 | |
2737 | |
2685 | if (!OPTION (Opt_jumpScroll) |
2738 | if (!OPTION (Opt_jumpScroll) |
2686 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2739 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2687 | { |
2740 | { |
2688 | refreshnow = true; |
2741 | refreshnow = true; |
|
|
2742 | refresh_count = 0; |
2689 | ch = NOCHAR; |
2743 | ch = NOCHAR; |
2690 | break; |
2744 | break; |
2691 | } |
2745 | } |
2692 | |
2746 | |
2693 | // scr_add_lines only works for nlines <= nrow - 1. |
2747 | // scr_add_lines only works for nlines <= nrow - 1. |
2694 | if (nlines >= nrow - 1) |
2748 | if (nlines >= nrow - 1) |
2695 | { |
2749 | { |
|
|
2750 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2751 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2696 | scr_add_lines (buf, nlines, str - buf); |
2752 | scr_add_lines (buf, str - buf, nlines); |
|
|
2753 | |
2697 | nlines = 0; |
2754 | nlines = 0; |
2698 | str = buf; |
2755 | str = buf; |
2699 | eol = str + min (ncol, UBUFSIZ); |
2756 | eol = str + min (ncol, UBUFSIZ); |
2700 | } |
2757 | } |
2701 | |
2758 | |
… | |
… | |
2714 | |
2771 | |
2715 | seq_begin = cmdbuf_ptr; |
2772 | seq_begin = cmdbuf_ptr; |
2716 | ch = next_char (); |
2773 | ch = next_char (); |
2717 | } |
2774 | } |
2718 | |
2775 | |
|
|
2776 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2777 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2719 | scr_add_lines (buf, nlines, str - buf); |
2778 | scr_add_lines (buf, str - buf, nlines); |
2720 | |
2779 | |
2721 | /* |
2780 | /* |
2722 | * If there have been a lot of new lines, then update the screen |
2781 | * If there have been a lot of new lines, then update the screen |
2723 | * What the heck I'll cheat and only refresh less than every page-full. |
2782 | * What the heck I'll cheat and only refresh less than every page-full. |
2724 | * the number of pages between refreshes is refresh_limit, which |
2783 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2729 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2788 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2730 | refresh_limit++; |
2789 | refresh_limit++; |
2731 | else |
2790 | else |
2732 | { |
2791 | { |
2733 | flag = true; |
2792 | flag = true; |
|
|
2793 | //TODO: due to popular request, implement "skipscroll" option here |
2734 | scr_refresh (refresh_type); |
2794 | scr_refresh (); |
|
|
2795 | want_refresh = 1; |
2735 | } |
2796 | } |
2736 | } |
2797 | } |
2737 | |
2798 | |
2738 | } |
2799 | } |
2739 | else |
2800 | else |
… | |
… | |
2754 | } |
2815 | } |
2755 | |
2816 | |
2756 | return flag; |
2817 | return flag; |
2757 | } |
2818 | } |
2758 | |
2819 | |
2759 | // read the next octet |
|
|
2760 | unicode_t |
|
|
2761 | rxvt_term::next_octet () |
|
|
2762 | { |
|
|
2763 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2764 | ? *cmdbuf_ptr++ |
|
|
2765 | : NOCHAR; |
|
|
2766 | } |
|
|
2767 | |
|
|
2768 | // read the next character |
2820 | // read the next character |
2769 | unicode_t |
2821 | wchar_t |
2770 | rxvt_term::next_char () |
2822 | rxvt_term::next_char () NOTHROW |
2771 | { |
2823 | { |
2772 | while (cmdbuf_ptr < cmdbuf_endp) |
2824 | while (cmdbuf_ptr < cmdbuf_endp) |
2773 | { |
2825 | { |
2774 | // assume 7-bit to be ascii ALWAYS |
2826 | // assume 7-bit to be ascii ALWAYS |
2775 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2827 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2776 | return *cmdbuf_ptr++; |
2828 | return *cmdbuf_ptr++; |
2777 | |
2829 | |
2778 | wchar_t wc; |
2830 | wchar_t wc; |
2779 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2831 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2780 | |
2832 | |
2781 | if (len == (size_t)-2) |
2833 | if (len == (size_t)-2) |
2782 | { |
2834 | { |
2783 | // the mbstate stores incomplete sequences. didn't know this :/ |
2835 | // the mbstate stores incomplete sequences. didn't know this :/ |
2784 | cmdbuf_ptr = cmdbuf_endp; |
2836 | cmdbuf_ptr = cmdbuf_endp; |
2785 | break; |
2837 | break; |
2786 | } |
2838 | } |
2787 | |
2839 | |
2788 | if (len == (size_t)-1) |
2840 | if (len == (size_t)-1) |
2789 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2841 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2790 | |
2842 | |
2791 | // assume wchar == unicode |
2843 | // assume wchar == unicode |
2792 | cmdbuf_ptr += len; |
2844 | cmdbuf_ptr += len; |
2793 | return wc & UNICODE_MASK; |
2845 | return wc & UNICODE_MASK; |
2794 | } |
2846 | } |
2795 | |
2847 | |
2796 | return NOCHAR; |
2848 | return NOCHAR; |
2797 | } |
2849 | } |
|
|
2850 | |
|
|
2851 | // read the next octet |
|
|
2852 | uint32_t |
|
|
2853 | rxvt_term::next_octet () NOTHROW |
|
|
2854 | { |
|
|
2855 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2856 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2857 | : NOCHAR; |
|
|
2858 | } |
|
|
2859 | |
|
|
2860 | static class out_of_input out_of_input; |
2798 | |
2861 | |
2799 | /* rxvt_cmd_getc () - Return next input character */ |
2862 | /* rxvt_cmd_getc () - Return next input character */ |
2800 | /* |
2863 | /* |
2801 | * Return the next input character after first passing any keyboard input |
2864 | * Return the next input character after first passing any keyboard input |
2802 | * to the command. |
2865 | * to the command. |
2803 | */ |
2866 | */ |
2804 | unicode_t |
2867 | wchar_t |
2805 | rxvt_term::cmd_getc () |
2868 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2806 | { |
2869 | { |
2807 | unicode_t c = next_char (); |
2870 | wchar_t c = next_char (); |
2808 | |
2871 | |
2809 | if (c == NOCHAR) |
2872 | if (c == NOCHAR) |
2810 | throw out_of_input; |
2873 | throw out_of_input; |
2811 | |
2874 | |
2812 | return c; |
2875 | return c; |
2813 | } |
2876 | } |
2814 | |
2877 | |
2815 | unicode_t |
2878 | uint32_t |
2816 | rxvt_term::cmd_get8 () |
2879 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2817 | { |
2880 | { |
2818 | unicode_t c = next_octet (); |
2881 | uint32_t c = next_octet (); |
2819 | |
2882 | |
2820 | if (c == NOCHAR) |
2883 | if (c == NOCHAR) |
2821 | throw out_of_input; |
2884 | throw out_of_input; |
2822 | |
2885 | |
2823 | return c; |
2886 | return c; |
… | |
… | |
2923 | case C0_ESC: |
2986 | case C0_ESC: |
2924 | process_escape_seq (); |
2987 | process_escape_seq (); |
2925 | break; |
2988 | break; |
2926 | case C0_ENQ: /* terminal Status */ |
2989 | case C0_ENQ: /* terminal Status */ |
2927 | if (rs[Rs_answerbackstring]) |
2990 | if (rs[Rs_answerbackstring]) |
2928 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2991 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2929 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2930 | else |
2992 | else |
2931 | tt_write ((unsigned char *)VT100_ANS, |
2993 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2932 | (unsigned int)strlen (VT100_ANS)); |
|
|
2933 | break; |
2994 | break; |
2934 | case C0_BEL: /* bell */ |
2995 | case C0_BEL: /* bell */ |
2935 | scr_bell (); |
2996 | scr_bell (); |
2936 | break; |
2997 | break; |
2937 | case C0_BS: /* backspace */ |
2998 | case C0_BS: /* backspace */ |
… | |
… | |
3061 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3122 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3062 | break; |
3123 | break; |
3063 | case '+': |
3124 | case '+': |
3064 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3125 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3065 | break; |
3126 | break; |
3066 | #if ENABLE_FRILLS |
3127 | #if !ENABLE_MINIMAL |
3067 | case '6': |
3128 | case '6': |
3068 | scr_backindex (); |
3129 | scr_backindex (); |
3069 | break; |
3130 | break; |
3070 | #endif |
3131 | #endif |
3071 | case '7': |
3132 | case '7': |
3072 | scr_cursor (SAVE); |
3133 | scr_cursor (SAVE); |
3073 | break; |
3134 | break; |
3074 | case '8': |
3135 | case '8': |
3075 | scr_cursor (RESTORE); |
3136 | scr_cursor (RESTORE); |
3076 | break; |
3137 | break; |
3077 | #if ENABLE_FRILLS |
3138 | #if !ENABLE_MINIMAL |
3078 | case '9': |
3139 | case '9': |
3079 | scr_forwardindex (); |
3140 | scr_forwardindex (); |
3080 | break; |
3141 | break; |
3081 | #endif |
3142 | #endif |
3082 | case '=': |
3143 | case '=': |
… | |
… | |
3092 | break; |
3153 | break; |
3093 | |
3154 | |
3094 | /* 8.3.87: NEXT LINE */ |
3155 | /* 8.3.87: NEXT LINE */ |
3095 | case C1_NEL: /* ESC E */ |
3156 | case C1_NEL: /* ESC E */ |
3096 | { |
3157 | { |
3097 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3158 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3098 | scr_add_lines (nlcr, 1, 2); |
3159 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3099 | } |
3160 | } |
3100 | break; |
3161 | break; |
3101 | |
3162 | |
3102 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3163 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3103 | case C1_ESA: /* ESC G */ |
3164 | case C1_ESA: /* ESC G */ |
… | |
… | |
3125 | process_dcs_seq (); |
3186 | process_dcs_seq (); |
3126 | break; |
3187 | break; |
3127 | |
3188 | |
3128 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3189 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3129 | case C1_SCI: /* ESC Z */ |
3190 | case C1_SCI: /* ESC Z */ |
3130 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3191 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3131 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3132 | break; /* steal obsolete ESC [ c */ |
3192 | break; /* steal obsolete ESC [ c */ |
3133 | |
3193 | |
3134 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3194 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3135 | case C1_CSI: /* ESC [ */ |
3195 | case C1_CSI: /* ESC [ */ |
3136 | process_csi_seq (); |
3196 | process_csi_seq (); |
… | |
… | |
3245 | ndef = get_byte_array_bit (csi_defaults, i); |
3305 | ndef = get_byte_array_bit (csi_defaults, i); |
3246 | for (p = 0; p < nargs; p++) |
3306 | for (p = 0; p < nargs; p++) |
3247 | if (arg[p] == -1) |
3307 | if (arg[p] == -1) |
3248 | arg[p] = ndef; |
3308 | arg[p] = ndef; |
3249 | |
3309 | |
3250 | #ifdef DEBUG_CMD |
|
|
3251 | fprintf (stderr, "CSI "); |
|
|
3252 | for (p = 0; p < nargs; p++) |
|
|
3253 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3254 | fprintf (stderr, "%c\n", ch); |
|
|
3255 | #endif |
|
|
3256 | |
|
|
3257 | /* |
3310 | /* |
3258 | * private mode handling |
3311 | * private mode handling |
3259 | */ |
3312 | */ |
3260 | if (priv) |
3313 | if (priv) |
3261 | { |
3314 | { |
3262 | switch (priv) |
3315 | switch (priv) |
3263 | { |
3316 | { |
3264 | case '>': |
3317 | case '>': |
3265 | if (ch == CSI_DA) /* secondary device attributes */ |
3318 | if (ch == CSI_DA) /* secondary device attributes */ |
3266 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3319 | { |
|
|
3320 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3321 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
3322 | // |
|
|
3323 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3324 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3325 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3326 | // |
|
|
3327 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
3328 | } |
3267 | break; |
3329 | break; |
3268 | case '?': |
3330 | case '?': |
3269 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3331 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3270 | process_terminal_mode (ch, priv, nargs, arg); |
3332 | process_terminal_mode (ch, priv, nargs, arg); |
3271 | break; |
3333 | break; |
… | |
… | |
3380 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3442 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3381 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3443 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3382 | break; |
3444 | break; |
3383 | |
3445 | |
3384 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3446 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3385 | tt_write ((const unsigned char *)VT100_ANS, |
3447 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3386 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3387 | break; |
3448 | break; |
3388 | |
3449 | |
3389 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3450 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3390 | process_sgr_mode (nargs, arg); |
3451 | process_sgr_mode (nargs, arg); |
3391 | break; |
3452 | break; |
… | |
… | |
3475 | break; |
3536 | break; |
3476 | case CSI_75: |
3537 | case CSI_75: |
3477 | scr_cursor (RESTORE); |
3538 | scr_cursor (RESTORE); |
3478 | break; |
3539 | break; |
3479 | |
3540 | |
3480 | #if ENABLE_FRILLS |
3541 | #if !ENABLE_MINIMAL |
3481 | case CSI_74: |
3542 | case CSI_74: |
3482 | process_window_ops (arg, nargs); |
3543 | process_window_ops (arg, nargs); |
3483 | break; |
3544 | break; |
3484 | #endif |
3545 | #endif |
3485 | |
3546 | |
… | |
… | |
3492 | break; |
3553 | break; |
3493 | } |
3554 | } |
3494 | } |
3555 | } |
3495 | /*}}} */ |
3556 | /*}}} */ |
3496 | |
3557 | |
3497 | #if ENABLE_FRILLS |
3558 | #if !ENABLE_MINIMAL |
3498 | /* ARGSUSED */ |
3559 | /* ARGSUSED */ |
3499 | void |
3560 | void |
3500 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3561 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3501 | { |
3562 | { |
3502 | int x, y; |
3563 | int x, y; |
3503 | XWindowAttributes wattr; |
3564 | XWindowAttributes wattr; |
3504 | Window wdummy; |
3565 | Window wdummy; |
3505 | dDisp; |
3566 | |
|
|
3567 | dLocal (Display *, dpy); |
3506 | |
3568 | |
3507 | if (nargs == 0) |
3569 | if (nargs == 0) |
3508 | return; |
3570 | return; |
3509 | |
3571 | |
3510 | switch (args[0]) |
3572 | switch (args[0]) |
3511 | { |
3573 | { |
3512 | /* |
3574 | /* |
3513 | * commands |
3575 | * commands |
3514 | */ |
3576 | */ |
3515 | case 1: /* deiconify window */ |
3577 | case 1: /* deiconify window */ |
3516 | XMapWindow (disp, parent[0]); |
3578 | XMapWindow (dpy, parent[0]); |
3517 | break; |
3579 | break; |
3518 | case 2: /* iconify window */ |
3580 | case 2: /* iconify window */ |
3519 | XIconifyWindow (disp, parent[0], display->screen); |
3581 | XIconifyWindow (dpy, parent[0], display->screen); |
3520 | break; |
3582 | break; |
3521 | case 3: /* set position (pixels) */ |
3583 | case 3: /* set position (pixels) */ |
3522 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3584 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3523 | break; |
3585 | break; |
3524 | case 4: /* set size (pixels) */ |
3586 | case 4: /* set size (pixels) */ |
3525 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3587 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3526 | break; |
3588 | break; |
3527 | case 5: /* raise window */ |
3589 | case 5: /* raise window */ |
3528 | XRaiseWindow (disp, parent[0]); |
3590 | XRaiseWindow (dpy, parent[0]); |
3529 | break; |
3591 | break; |
3530 | case 6: /* lower window */ |
3592 | case 6: /* lower window */ |
3531 | XLowerWindow (disp, parent[0]); |
3593 | XLowerWindow (dpy, parent[0]); |
3532 | break; |
3594 | break; |
3533 | case 7: /* refresh window */ |
3595 | case 7: /* refresh window */ |
3534 | scr_touch (true); |
3596 | scr_touch (true); |
3535 | break; |
3597 | break; |
3536 | case 8: /* set size (chars) */ |
3598 | case 8: /* set size (chars) */ |
… | |
… | |
3543 | if (args[0] >= 24) /* set height (chars) */ |
3605 | if (args[0] >= 24) /* set height (chars) */ |
3544 | set_widthheight ((unsigned int)width, |
3606 | set_widthheight ((unsigned int)width, |
3545 | (unsigned int) (args[1] * fheight)); |
3607 | (unsigned int) (args[1] * fheight)); |
3546 | break; |
3608 | break; |
3547 | |
3609 | |
3548 | |
|
|
3549 | /* |
3610 | /* |
3550 | * reports - some output format copied from XTerm |
3611 | * reports - some output format copied from XTerm |
3551 | */ |
3612 | */ |
3552 | case 11: /* report window state */ |
3613 | case 11: /* report window state */ |
3553 | XGetWindowAttributes (disp, parent[0], &wattr); |
3614 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3554 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3615 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3555 | break; |
3616 | break; |
3556 | case 13: /* report window position */ |
3617 | case 13: /* report window position */ |
3557 | XGetWindowAttributes (disp, parent[0], &wattr); |
3618 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3558 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3619 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3559 | -wattr.border_width, -wattr.border_width, |
3620 | -wattr.border_width, -wattr.border_width, |
3560 | &x, &y, &wdummy); |
3621 | &x, &y, &wdummy); |
3561 | tt_printf ("\033[3;%d;%dt", x, y); |
3622 | tt_printf ("\033[3;%d;%dt", x, y); |
3562 | break; |
3623 | break; |
3563 | case 14: /* report window size (pixels) */ |
3624 | case 14: /* report window size (pixels) */ |
3564 | XGetWindowAttributes (disp, parent[0], &wattr); |
3625 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3565 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3626 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3566 | break; |
3627 | break; |
3567 | case 18: /* report text area size (chars) */ |
3628 | case 18: /* report text area size (chars) */ |
3568 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3629 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3569 | break; |
3630 | break; |
… | |
… | |
3571 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3632 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3572 | break; |
3633 | break; |
3573 | case 20: /* report icon label */ |
3634 | case 20: /* report icon label */ |
3574 | { |
3635 | { |
3575 | char *s; |
3636 | char *s; |
3576 | XGetIconName (disp, parent[0], &s); |
3637 | XGetIconName (dpy, parent[0], &s); |
3577 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3638 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3578 | XFree (s); |
3639 | XFree (s); |
3579 | } |
3640 | } |
3580 | break; |
3641 | break; |
3581 | case 21: /* report window title */ |
3642 | case 21: /* report window title */ |
3582 | { |
3643 | { |
3583 | char *s; |
3644 | char *s; |
3584 | XFetchName (disp, parent[0], &s); |
3645 | XFetchName (dpy, parent[0], &s); |
3585 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3646 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3586 | XFree (s); |
3647 | XFree (s); |
3587 | } |
3648 | } |
3588 | break; |
3649 | break; |
3589 | } |
3650 | } |
… | |
… | |
3593 | /*----------------------------------------------------------------------*/ |
3654 | /*----------------------------------------------------------------------*/ |
3594 | /* |
3655 | /* |
3595 | * get input up until STRING TERMINATOR (or BEL) |
3656 | * get input up until STRING TERMINATOR (or BEL) |
3596 | * ends_how is terminator used. returned input must be free()'d |
3657 | * ends_how is terminator used. returned input must be free()'d |
3597 | */ |
3658 | */ |
3598 | unsigned char * |
3659 | char * |
3599 | rxvt_term::get_to_st (unicode_t &ends_how) |
3660 | rxvt_term::get_to_st (unicode_t &ends_how) |
3600 | { |
3661 | { |
3601 | unicode_t ch; |
3662 | unicode_t ch; |
3602 | bool seen_esc = false; |
3663 | bool seen_esc = false; |
3603 | unsigned int n = 0; |
3664 | unsigned int n = 0; |
… | |
… | |
3617 | seen_esc = true; |
3678 | seen_esc = true; |
3618 | continue; |
3679 | continue; |
3619 | } |
3680 | } |
3620 | else if (ch == C0_BEL || ch == CHAR_ST) |
3681 | else if (ch == C0_BEL || ch == CHAR_ST) |
3621 | break; |
3682 | break; |
|
|
3683 | else if (ch == C0_SYN) |
|
|
3684 | ch = cmd_get8 (); |
3622 | else if (ch < 0x20) |
3685 | else if (ch < 0x20) |
3623 | return NULL; /* other control character - exit */ |
3686 | return NULL; /* other control character - exit */ |
3624 | |
3687 | |
3625 | seen_esc = false; |
3688 | seen_esc = false; |
3626 | |
3689 | |
3627 | if (n >= STRING_MAX - 1) |
3690 | if (n >= STRING_MAX - 1) |
3628 | // stop at some sane length |
3691 | // stop at some sane length |
3629 | return NULL; |
3692 | return NULL; |
3630 | |
3693 | |
3631 | if (ch == C0_SYN) |
|
|
3632 | string[n++] = cmd_get8 (); |
|
|
3633 | else |
|
|
3634 | string[n++] = ch; |
3694 | string[n++] = ch; |
3635 | } |
3695 | } |
3636 | |
3696 | |
3637 | string[n++] = '\0'; |
3697 | string[n++] = '\0'; |
3638 | |
3698 | |
3639 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3699 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3640 | |
3700 | |
3641 | return (unsigned char *)rxvt_wcstombs (string); |
3701 | return rxvt_wcstombs (string); |
3642 | } |
3702 | } |
3643 | |
3703 | |
3644 | /*----------------------------------------------------------------------*/ |
3704 | /*----------------------------------------------------------------------*/ |
3645 | /* |
3705 | /* |
3646 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3706 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3647 | */ |
3707 | */ |
3648 | void |
3708 | void |
3649 | rxvt_term::process_dcs_seq () |
3709 | rxvt_term::process_dcs_seq () |
3650 | { |
3710 | { |
3651 | unsigned char *s; |
3711 | char *s; |
3652 | unicode_t eh; |
3712 | unicode_t eh; |
3653 | |
3713 | |
3654 | /* |
3714 | /* |
3655 | * Not handled yet |
3715 | * Not handled yet |
3656 | */ |
3716 | */ |
… | |
… | |
3675 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3735 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3676 | arg = arg * 10 + (ch - '0'); |
3736 | arg = arg * 10 + (ch - '0'); |
3677 | |
3737 | |
3678 | if (ch == ';') |
3738 | if (ch == ';') |
3679 | { |
3739 | { |
3680 | unsigned char *s = get_to_st (eh); |
3740 | char *s = get_to_st (eh); |
3681 | |
3741 | |
3682 | if (s) |
3742 | if (s) |
3683 | { |
3743 | { |
3684 | process_xterm_seq (arg, (char *)s, eh); |
3744 | process_xterm_seq (arg, s, eh); |
3685 | free (s); |
3745 | free (s); |
3686 | } |
3746 | } |
3687 | } |
3747 | } |
3688 | } |
3748 | } |
3689 | |
3749 | |
3690 | void |
3750 | void |
3691 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3751 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3692 | { |
3752 | { |
3693 | if (str[0] == '?' && !str[1]) |
3753 | if (str[0] == '?' && !str[1]) |
3694 | { |
3754 | { |
3695 | unsigned short r, g, b; |
3755 | rgba c; |
3696 | pix_colors_focused[color].get (display, r, g, b); |
3756 | pix_colors_focused[color].get (c); |
|
|
3757 | |
|
|
3758 | #if XFT |
|
|
3759 | if (c.a != rgba::MAX_CC) |
|
|
3760 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3761 | else |
|
|
3762 | #endif |
3697 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3763 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3698 | } |
3764 | } |
3699 | else |
3765 | else |
3700 | set_window_color (color, str); |
3766 | set_window_color (color, str); |
3701 | } |
3767 | } |
3702 | |
3768 | |
3703 | /* |
3769 | /* |
3704 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3770 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3705 | */ |
3771 | */ |
3706 | void |
3772 | void |
3707 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3773 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3708 | { |
3774 | { |
3709 | int changed = 0; |
|
|
3710 | int color; |
3775 | int color; |
3711 | char *buf, *name; |
3776 | char *buf, *name; |
3712 | bool query = str[0] == '?' && !str[1]; |
3777 | bool query = str[0] == '?' && !str[1]; |
3713 | int saveop = op; |
3778 | int saveop = op; |
3714 | dDisp; |
3779 | |
|
|
3780 | dLocal (Display *, dpy); |
3715 | |
3781 | |
3716 | assert (str != NULL); |
3782 | assert (str != NULL); |
|
|
3783 | |
|
|
3784 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3785 | return; |
|
|
3786 | |
3717 | switch (op) |
3787 | switch (op) |
3718 | { |
3788 | { |
3719 | case XTerm_name: |
3789 | case XTerm_name: |
3720 | set_title (str); |
3790 | set_title (str); |
3721 | /* FALLTHROUGH */ |
3791 | /* FALLTHROUGH */ |
… | |
… | |
3735 | unsigned long bytes_after; |
3805 | unsigned long bytes_after; |
3736 | unsigned char *value = 0; |
3806 | unsigned char *value = 0; |
3737 | const char *str = ""; |
3807 | const char *str = ""; |
3738 | |
3808 | |
3739 | if (prop |
3809 | if (prop |
3740 | && XGetWindowProperty (disp, parent[0], |
3810 | && XGetWindowProperty (dpy, parent[0], |
3741 | prop, 0, 1<<16, 0, AnyPropertyType, |
3811 | prop, 0, 1<<16, 0, AnyPropertyType, |
3742 | &actual_type, &actual_format, |
3812 | &actual_type, &actual_format, |
3743 | &nitems, &bytes_after, &value) == Success |
3813 | &nitems, &bytes_after, &value) == Success |
3744 | && actual_type != None |
3814 | && actual_type != None |
3745 | && actual_format == 8) |
3815 | && actual_format == 8) |
3746 | str = (const char *)(value); |
3816 | str = (const char *)(value); |
3747 | |
3817 | |
3748 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3818 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3749 | |
3819 | |
3750 | XFree (value); |
3820 | XFree (value); |
3751 | } |
3821 | } |
3752 | else |
3822 | else |
3753 | { |
3823 | { |
… | |
… | |
3757 | { |
3827 | { |
3758 | *eq = 0; |
3828 | *eq = 0; |
3759 | set_utf8_property (display->atom (str), eq + 1); |
3829 | set_utf8_property (display->atom (str), eq + 1); |
3760 | } |
3830 | } |
3761 | else |
3831 | else |
3762 | XDeleteProperty (disp, parent[0], |
3832 | XDeleteProperty (dpy, parent[0], |
3763 | display->atom (str)); |
3833 | display->atom (str)); |
3764 | } |
3834 | } |
3765 | break; |
3835 | break; |
3766 | |
3836 | |
3767 | case XTerm_Color: |
3837 | case XTerm_Color: |
… | |
… | |
3769 | { |
3839 | { |
3770 | if ((name = strchr (buf, ';')) == NULL) |
3840 | if ((name = strchr (buf, ';')) == NULL) |
3771 | break; |
3841 | break; |
3772 | |
3842 | |
3773 | *name++ = '\0'; |
3843 | *name++ = '\0'; |
3774 | color = atoi (buf); |
3844 | color = atoi (buf) + minCOLOR; |
3775 | |
3845 | |
3776 | if (color < 0 || color >= TOTAL_COLORS) |
3846 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3777 | break; |
3847 | break; |
3778 | |
3848 | |
3779 | if ((buf = strchr (name, ';')) != NULL) |
3849 | if ((buf = strchr (name, ';')) != NULL) |
3780 | *buf++ = '\0'; |
3850 | *buf++ = '\0'; |
3781 | |
3851 | |
3782 | if (name[0] == '?' && !name[1]) |
3852 | process_color_seq (op, color, name, resp); |
3783 | { |
|
|
3784 | unsigned short r, g, b; |
|
|
3785 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3786 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3787 | } |
|
|
3788 | else |
|
|
3789 | set_window_color (color + minCOLOR, name); |
|
|
3790 | } |
3853 | } |
3791 | break; |
3854 | break; |
3792 | case XTerm_Color00: |
3855 | case XTerm_Color00: |
3793 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3856 | process_color_seq (op, Color_fg, str, resp); |
3794 | break; |
3857 | break; |
3795 | case XTerm_Color01: |
3858 | case XTerm_Color01: |
3796 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3859 | process_color_seq (op, Color_bg, str, resp); |
3797 | break; |
3860 | break; |
3798 | #ifndef NO_CURSORCOLOR |
3861 | #ifndef NO_CURSORCOLOR |
3799 | case XTerm_Color_cursor: |
3862 | case XTerm_Color_cursor: |
3800 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3863 | process_color_seq (op, Color_cursor, str, resp); |
3801 | break; |
3864 | break; |
3802 | #endif |
3865 | #endif |
3803 | case XTerm_Color_pointer_fg: |
3866 | case XTerm_Color_pointer_fg: |
3804 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3867 | process_color_seq (op, Color_pointer_fg, str, resp); |
3805 | break; |
3868 | break; |
3806 | case XTerm_Color_pointer_bg: |
3869 | case XTerm_Color_pointer_bg: |
3807 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3870 | process_color_seq (op, Color_pointer_bg, str, resp); |
3808 | break; |
3871 | break; |
3809 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3872 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3810 | case XTerm_Color_BD: |
|
|
3811 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3812 | break; |
|
|
3813 | case XTerm_Color_UL: |
|
|
3814 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3815 | break; |
|
|
3816 | case XTerm_Color_RV: |
3873 | case XTerm_Color_RV: |
3817 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3874 | process_color_seq (op, Color_RV, str, resp); |
|
|
3875 | break; |
|
|
3876 | case Rxvt_Color_BD: |
|
|
3877 | case URxvt_Color_BD: |
|
|
3878 | process_color_seq (op, Color_BD, str, resp); |
|
|
3879 | break; |
|
|
3880 | case Rxvt_Color_UL: |
|
|
3881 | case URxvt_Color_UL: |
|
|
3882 | process_color_seq (op, Color_UL, str, resp); |
3818 | break; |
3883 | break; |
3819 | case URxvt_Color_IT: |
3884 | case URxvt_Color_IT: |
3820 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3885 | process_color_seq (op, Color_IT, str, resp); |
3821 | break; |
3886 | break; |
3822 | #endif |
3887 | #endif |
3823 | #if TRANSPARENT && TINTING |
3888 | #if TRANSPARENT && TINTING |
3824 | case URxvt_Color_tint: |
3889 | case URxvt_Color_tint: |
3825 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3890 | process_color_seq (op, Color_tint, str, resp); |
|
|
3891 | |
3826 | check_our_parents (); |
3892 | check_our_parents (); |
|
|
3893 | |
3827 | if (am_transparent) |
3894 | if (am_transparent) |
3828 | want_full_refresh = want_refresh = 1; |
3895 | want_full_refresh = want_refresh = 1; |
3829 | break; |
|
|
3830 | #endif |
|
|
3831 | |
3896 | |
|
|
3897 | break; |
|
|
3898 | #endif |
|
|
3899 | |
3832 | case XTerm_Pixmap: |
3900 | case Rxvt_Pixmap: |
|
|
3901 | { |
3833 | if (*str != ';') |
3902 | if (*str != ';') |
3834 | { |
3903 | { |
3835 | #if XPM_BACKGROUND |
3904 | #if XPM_BACKGROUND |
3836 | scale_pixmap (""); /* reset to default scaling */ |
3905 | scale_pixmap (""); /* reset to default scaling */ |
3837 | set_bgPixmap (str); /* change pixmap */ |
3906 | set_bgPixmap (str); /* change pixmap */ |
3838 | #endif |
|
|
3839 | scr_touch (true); |
3907 | scr_touch (true); |
|
|
3908 | #endif |
3840 | } |
3909 | } |
|
|
3910 | |
|
|
3911 | int changed = 0; |
|
|
3912 | |
3841 | while ((str = strchr (str, ';')) != NULL) |
3913 | while ((str = strchr (str, ';')) != NULL) |
3842 | { |
3914 | { |
3843 | str++; |
3915 | str++; |
3844 | #if XPM_BACKGROUND |
3916 | #if XPM_BACKGROUND |
3845 | changed += scale_pixmap (str); |
3917 | changed += scale_pixmap (str); |
3846 | #endif |
3918 | #endif |
3847 | } |
3919 | } |
3848 | |
3920 | |
3849 | if (changed) |
3921 | if (changed) |
3850 | { |
3922 | { |
3851 | #ifdef XPM_BACKGROUND |
3923 | #ifdef XPM_BACKGROUND |
3852 | resize_pixmap (); |
3924 | resize_pixmap (); |
3853 | #endif |
|
|
3854 | scr_touch (true); |
3925 | scr_touch (true); |
|
|
3926 | #endif |
3855 | } |
3927 | } |
|
|
3928 | } |
3856 | break; |
3929 | break; |
3857 | |
3930 | |
3858 | case XTerm_restoreFG: |
3931 | case Rxvt_restoreFG: |
3859 | set_window_color (Color_fg, str); |
3932 | set_window_color (Color_fg, str); |
3860 | break; |
3933 | break; |
3861 | case XTerm_restoreBG: |
3934 | case Rxvt_restoreBG: |
3862 | set_window_color (Color_bg, str); |
3935 | set_window_color (Color_bg, str); |
3863 | break; |
3936 | break; |
3864 | |
3937 | |
3865 | case XTerm_logfile: |
3938 | case XTerm_logfile: |
3866 | // TODO, when secure mode? |
3939 | // TODO, when secure mode? |
3867 | break; |
3940 | break; |
3868 | |
3941 | |
3869 | #ifdef MENUBAR |
|
|
3870 | case URxvt_Menu: |
|
|
3871 | if (OPTION (Opt_insecure)) |
|
|
3872 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3873 | break; |
|
|
3874 | #endif |
|
|
3875 | #if 0 |
3942 | #if 0 |
3876 | case XTerm_dumpscreen: /* no error notices */ |
3943 | case Rxvt_dumpscreen: /* no error notices */ |
3877 | { |
3944 | { |
3878 | int fd; |
3945 | int fd; |
3879 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3946 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3880 | { |
3947 | { |
3881 | scr_dump (fd); |
3948 | scr_dump (fd); |
… | |
… | |
3905 | allocated.push_back ((void *)res); |
3972 | allocated.push_back ((void *)res); |
3906 | set_fonts (); |
3973 | set_fonts (); |
3907 | } |
3974 | } |
3908 | break; |
3975 | break; |
3909 | |
3976 | |
3910 | #if ENABLE_FRILLS |
3977 | case URxvt_version: |
|
|
3978 | if (query) |
|
|
3979 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3980 | op, |
|
|
3981 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3982 | resp); |
|
|
3983 | break; |
|
|
3984 | |
|
|
3985 | #if !ENABLE_MINIMAL |
3911 | case URxvt_locale: |
3986 | case URxvt_locale: |
3912 | if (query) |
3987 | if (query) |
3913 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3988 | tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); |
3914 | else |
3989 | else |
3915 | { |
3990 | { |
3916 | set_locale (str); |
3991 | set_locale (str); |
3917 | pty.set_utf8_mode (enc_utf8); |
3992 | pty->set_utf8_mode (enc_utf8); |
3918 | init_xlocale (); |
3993 | init_xlocale (); |
3919 | } |
3994 | } |
3920 | break; |
3995 | break; |
3921 | |
3996 | |
3922 | case URxvt_view_up: |
3997 | case URxvt_view_up: |
3923 | case URxvt_view_down: |
3998 | case URxvt_view_down: |
|
|
3999 | { |
3924 | int lines = atoi (str); |
4000 | int lines = atoi (str); |
3925 | |
4001 | |
3926 | if (lines) |
4002 | if (lines) |
3927 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
4003 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3928 | else |
4004 | else |
3929 | { |
|
|
3930 | scr_erase_savelines (); |
4005 | scr_erase_savelines (); |
3931 | } |
4006 | } |
3932 | |
4007 | |
|
|
4008 | break; |
|
|
4009 | #endif |
|
|
4010 | |
|
|
4011 | #if ENABLE_PERL |
|
|
4012 | case URxvt_perl: |
|
|
4013 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
|
|
4014 | ; // no responses yet |
3933 | break; |
4015 | break; |
3934 | #endif |
4016 | #endif |
3935 | } |
4017 | } |
3936 | } |
4018 | } |
3937 | /*----------------------------------------------------------------------*/ |
4019 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3968 | return state; |
4050 | return state; |
3969 | } |
4051 | } |
3970 | |
4052 | |
3971 | /* we're not using priv _yet_ */ |
4053 | /* we're not using priv _yet_ */ |
3972 | void |
4054 | void |
3973 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4055 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3974 | { |
4056 | { |
3975 | unsigned int i, j; |
4057 | unsigned int i, j; |
3976 | int state; |
4058 | int state; |
3977 | |
4059 | |
3978 | static const struct |
4060 | static const struct |
… | |
… | |
3989 | { 5, PrivMode_rVideo }, |
4071 | { 5, PrivMode_rVideo }, |
3990 | { 6, PrivMode_relOrigin }, |
4072 | { 6, PrivMode_relOrigin }, |
3991 | { 7, PrivMode_Autowrap }, |
4073 | { 7, PrivMode_Autowrap }, |
3992 | // 8, bi-directional support mode |
4074 | // 8, bi-directional support mode |
3993 | { 9, PrivMode_MouseX10 }, |
4075 | { 9, PrivMode_MouseX10 }, |
3994 | #ifdef menuBar_esc |
|
|
3995 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3996 | #endif |
|
|
3997 | // 18, 19 printing-related |
4076 | // 18, 19 printing-related |
3998 | { 25, PrivMode_VisibleCursor }, |
4077 | { 25, PrivMode_VisibleCursor }, |
3999 | #ifdef scrollBar_esc |
4078 | #ifdef scrollBar_esc |
4000 | { scrollBar_esc, PrivMode_scrollBar }, |
4079 | { scrollBar_esc, PrivMode_scrollBar }, |
4001 | #endif |
4080 | #endif |
… | |
… | |
4048 | /* extra handling for values with state unkept */ |
4127 | /* extra handling for values with state unkept */ |
4049 | switch (arg[i]) |
4128 | switch (arg[i]) |
4050 | { |
4129 | { |
4051 | #if ENABLE_STYLES |
4130 | #if ENABLE_STYLES |
4052 | case 1021: |
4131 | case 1021: |
4053 | if (mode) |
4132 | set_option (Opt_intensityStyles, mode); |
4054 | SET_OPTION (Opt_intensityStyles); |
4133 | |
|
|
4134 | scr_touch (true); |
4055 | else |
4135 | break; |
4056 | CLR_OPTION (Opt_intensityStyles); |
|
|
4057 | #endif |
4136 | #endif |
4058 | case 1048: /* alternative cursor save */ |
4137 | case 1048: /* alternative cursor save */ |
4059 | case 1049: |
4138 | case 1049: |
4060 | if (OPTION (Opt_secondaryScreen)) |
4139 | if (OPTION (Opt_secondaryScreen)) |
4061 | if (mode == 0) |
4140 | if (mode == 0) |
… | |
… | |
4080 | case 3: /* 80/132 */ |
4159 | case 3: /* 80/132 */ |
4081 | if (priv_modes & PrivMode_132OK) |
4160 | if (priv_modes & PrivMode_132OK) |
4082 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4161 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4083 | break; |
4162 | break; |
4084 | case 4: /* smooth scrolling */ |
4163 | case 4: /* smooth scrolling */ |
4085 | if (!state) |
4164 | set_option (Opt_jumpScroll, !state); |
4086 | SET_OPTION (Opt_jumpScroll); |
|
|
4087 | else |
|
|
4088 | CLR_OPTION (Opt_jumpScroll); |
|
|
4089 | break; |
4165 | break; |
4090 | case 5: /* reverse video */ |
4166 | case 5: /* reverse video */ |
4091 | scr_rvideo_mode (state); |
4167 | scr_rvideo_mode (state); |
4092 | break; |
4168 | break; |
4093 | case 6: /* relative/absolute origins */ |
4169 | case 6: /* relative/absolute origins */ |
… | |
… | |
4099 | /* case 8: - auto repeat, can't do on a per window basis */ |
4175 | /* case 8: - auto repeat, can't do on a per window basis */ |
4100 | case 9: /* X10 mouse reporting */ |
4176 | case 9: /* X10 mouse reporting */ |
4101 | if (state) /* orthogonal */ |
4177 | if (state) /* orthogonal */ |
4102 | priv_modes &= ~PrivMode_MouseX11; |
4178 | priv_modes &= ~PrivMode_MouseX11; |
4103 | break; |
4179 | break; |
4104 | #ifdef menuBar_esc |
|
|
4105 | case menuBar_esc: |
|
|
4106 | #ifdef MENUBAR |
|
|
4107 | map_menuBar (state); |
|
|
4108 | #endif |
|
|
4109 | break; |
|
|
4110 | #endif |
|
|
4111 | #ifdef scrollBar_esc |
4180 | #ifdef scrollBar_esc |
4112 | case scrollBar_esc: |
4181 | case scrollBar_esc: |
4113 | if (scrollbar_mapping (state)) |
4182 | if (scrollbar_mapping (state)) |
4114 | { |
4183 | { |
4115 | resize_all_windows (0, 0, 0); |
4184 | resize_all_windows (0, 0, 0); |
… | |
… | |
4134 | #if 0 |
4203 | #if 0 |
4135 | case 1001: |
4204 | case 1001: |
4136 | break; /* X11 mouse highlighting */ |
4205 | break; /* X11 mouse highlighting */ |
4137 | #endif |
4206 | #endif |
4138 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4207 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4139 | if (!state) |
4208 | set_option (Opt_scrollTtyOutput, !state); |
4140 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4141 | else |
|
|
4142 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4143 | break; |
4209 | break; |
4144 | case 1011: /* scroll to bottom on key press */ |
4210 | case 1011: /* scroll to bottom on key press */ |
4145 | if (state) |
4211 | set_option (Opt_scrollTtyKeypress, state); |
4146 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4147 | else |
|
|
4148 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4149 | break; |
4212 | break; |
4150 | case 1047: /* secondary screen w/ clearing last */ |
4213 | case 1047: /* secondary screen w/ clearing last */ |
4151 | if (OPTION (Opt_secondaryScreen)) |
4214 | if (OPTION (Opt_secondaryScreen)) |
4152 | if (current_screen != PRIMARY) |
4215 | if (current_screen != PRIMARY) |
4153 | scr_erase_screen (2); |
4216 | scr_erase_screen (2); |
… | |
… | |
4291 | scr_color (Color_bg, Color_bg); |
4354 | scr_color (Color_bg, Color_bg); |
4292 | break; |
4355 | break; |
4293 | |
4356 | |
4294 | //case 50: // not variable spacing |
4357 | //case 50: // not variable spacing |
4295 | |
4358 | |
4296 | #ifndef NO_BRIGHTCOLOR |
4359 | #if !ENABLE_MINIMAL |
4297 | case 90: |
4360 | case 90: |
4298 | case 91: /* set bright fg color */ |
4361 | case 91: /* set bright fg color */ |
4299 | case 92: |
4362 | case 92: |
4300 | case 93: |
4363 | case 93: |
4301 | case 94: |
4364 | case 94: |
… | |
… | |
4346 | */ |
4409 | */ |
4347 | void |
4410 | void |
4348 | rxvt_term::tt_printf (const char *fmt,...) |
4411 | rxvt_term::tt_printf (const char *fmt,...) |
4349 | { |
4412 | { |
4350 | va_list arg_ptr; |
4413 | va_list arg_ptr; |
4351 | unsigned char buf[256]; |
4414 | char buf[256]; |
4352 | |
4415 | |
4353 | va_start (arg_ptr, fmt); |
4416 | va_start (arg_ptr, fmt); |
4354 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4417 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4355 | va_end (arg_ptr); |
4418 | va_end (arg_ptr); |
4356 | tt_write (buf, strlen (buf)); |
4419 | tt_write (buf, strlen (buf)); |
… | |
… | |
4361 | * or generated by us in response to a query ESC sequence. |
4424 | * or generated by us in response to a query ESC sequence. |
4362 | */ |
4425 | */ |
4363 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4426 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4364 | |
4427 | |
4365 | void |
4428 | void |
4366 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4429 | rxvt_term::tt_write (const char *data, unsigned int len) |
4367 | { |
4430 | { |
|
|
4431 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4432 | return; |
|
|
4433 | |
|
|
4434 | if (pty->pty < 0) |
|
|
4435 | return; |
|
|
4436 | |
4368 | if (v_buflen == 0) |
4437 | if (v_buflen == 0) |
4369 | { |
4438 | { |
4370 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4439 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4371 | |
4440 | |
4372 | if ((unsigned int)written == len) |
4441 | if ((unsigned int)written == len) |
4373 | return; |
4442 | return; |
4374 | |
4443 | |
4375 | data += written; |
4444 | data += written; |
4376 | len -= written; |
4445 | len -= written; |
4377 | } |
4446 | } |
4378 | |
4447 | |
4379 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4448 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4380 | |
4449 | |
4381 | memcpy (v_buffer + v_buflen, data, len); |
4450 | memcpy (v_buffer + v_buflen, data, len); |
4382 | v_buflen += len; |
4451 | v_buflen += len; |
4383 | |
4452 | |
4384 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4453 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4385 | } |
4454 | } |
4386 | |
4455 | |
4387 | void rxvt_term::pty_write () |
4456 | void rxvt_term::pty_write () |
4388 | { |
4457 | { |
4389 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4458 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4390 | |
4459 | |
4391 | if (written > 0) |
4460 | if (written > 0) |
4392 | { |
4461 | { |
4393 | v_buflen -= written; |
4462 | v_buflen -= written; |
4394 | |
4463 | |