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) |
… | |
… | |
93 | XK_Shift_L, 0x21e7, |
95 | XK_Shift_L, 0x21e7, |
94 | XK_Shift_R, 0x21e7, |
96 | XK_Shift_R, 0x21e7, |
95 | |
97 | |
96 | XK_Shift_Lock, 0x21eb, |
98 | XK_Shift_Lock, 0x21eb, |
97 | XK_ISO_Lock, 0x21eb, |
99 | XK_ISO_Lock, 0x21eb, |
98 | XK_ISO_Lock, 0x21eb, |
|
|
99 | XK_Caps_Lock, 0x21ec, |
100 | XK_Caps_Lock, 0x21ec, |
100 | XK_Num_Lock, 0x21ed, |
101 | XK_Num_Lock, 0x21ed, |
101 | XK_ISO_Level3_Shift, 0x21ee, |
102 | XK_ISO_Level3_Shift, 0x21ee, |
102 | XK_ISO_Level3_Lock, 0x21ef, |
103 | XK_ISO_Level3_Lock, 0x21ef, |
103 | XK_ISO_Group_Lock, 0x21f0, |
104 | XK_ISO_Group_Lock, 0x21f0, |
… | |
… | |
141 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | return; |
143 | return; |
143 | |
144 | |
144 | for (;;) |
145 | for (;;) |
145 | { |
146 | { |
146 | const line_t &l = ROW(y - view_start); |
147 | const line_t &l = ROW(y + view_start); |
147 | |
148 | |
148 | text_t t = l.t[x]; |
149 | text_t t = l.t[x]; |
149 | |
150 | |
150 | if (t != NOCHAR || !x) |
151 | if (t != NOCHAR || !x) |
151 | { |
152 | { |
… | |
… | |
224 | # if !UNICODE3 |
225 | # if !UNICODE3 |
225 | if (ch >= 0x10000) |
226 | if (ch >= 0x10000) |
226 | ch = 0xfffd; |
227 | ch = 0xfffd; |
227 | # endif |
228 | # endif |
228 | scr_overlay_set (11, y, ch, r); |
229 | scr_overlay_set (11, y, ch, r); |
|
|
230 | |
|
|
231 | if (WCWIDTH (ch) >= 2) |
229 | scr_overlay_set (12, y, NOCHAR, r); |
232 | scr_overlay_set (12, y, NOCHAR, r); |
230 | } |
233 | } |
231 | |
234 | |
|
|
235 | // { |
|
|
236 | // char buf[4+4+3+1]; |
|
|
237 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
238 | // scr_overlay_set (0, 0, buf); |
|
|
239 | // } |
232 | scr_overlay_set (0, len , attr); |
240 | scr_overlay_set (0, len , attr); |
233 | scr_overlay_set (0, len + 1, fname); |
241 | scr_overlay_set (0, len + 1, fname); |
234 | |
242 | |
235 | free (fname); |
243 | free (fname); |
236 | |
244 | |
… | |
… | |
262 | mb[0] = ch[0]; |
270 | mb[0] = ch[0]; |
263 | len = 1; |
271 | len = 1; |
264 | } |
272 | } |
265 | |
273 | |
266 | if (len > 0) |
274 | if (len > 0) |
267 | tt_write ((unsigned char *)mb, len); |
275 | tt_write (mb, len); |
268 | else |
276 | else |
269 | scr_bell (); |
277 | scr_bell (); |
270 | } |
278 | } |
271 | |
279 | |
272 | iso14755buf = 0; |
280 | iso14755buf = 0; |
… | |
… | |
289 | |
297 | |
290 | return -1; |
298 | return -1; |
291 | } |
299 | } |
292 | #endif |
300 | #endif |
293 | |
301 | |
294 | /*{{{ Convert the keypress event into a string */ |
|
|
295 | void |
302 | void |
296 | rxvt_term::lookup_key (XKeyEvent &ev) |
303 | rxvt_term::key_press (XKeyEvent &ev) |
297 | { |
304 | { |
298 | int ctrl, meta, shft, len; |
305 | int ctrl, meta, shft, len; |
299 | unsigned int newlen; |
306 | unsigned int newlen; |
300 | KeySym keysym; |
307 | KeySym keysym; |
301 | #ifdef DEBUG_CMD |
|
|
302 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
303 | #endif |
|
|
304 | int valid_keysym; |
308 | int valid_keysym; |
305 | unsigned char kbuf[KBUFSZ]; |
309 | char kbuf[KBUFSZ]; |
|
|
310 | |
|
|
311 | #if ISO_14755 |
|
|
312 | if (iso14755buf & ISO_14755_52) |
|
|
313 | return; |
|
|
314 | #endif |
306 | |
315 | |
307 | /* |
316 | /* |
308 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
317 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
309 | * escape sequence to toggle the Keypad. |
318 | * escape sequence to toggle the Keypad. |
310 | * |
319 | * |
… | |
… | |
328 | Status status_return; |
337 | Status status_return; |
329 | |
338 | |
330 | #if 0 |
339 | #if 0 |
331 | #ifdef X_HAVE_UTF8_STRING |
340 | #ifdef X_HAVE_UTF8_STRING |
332 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
341 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
333 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
342 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
334 | KBUFSZ, &keysym, &status_return); |
343 | KBUFSZ, &keysym, &status_return); |
335 | else |
344 | else |
336 | #endif |
345 | #endif |
337 | #endif |
346 | #endif |
338 | { |
347 | { |
… | |
… | |
375 | || status_return == XLookupBoth; |
384 | || status_return == XLookupBoth; |
376 | } |
385 | } |
377 | else |
386 | else |
378 | #endif |
387 | #endif |
379 | { |
388 | { |
380 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
389 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
381 | valid_keysym = keysym != NoSymbol; |
390 | valid_keysym = keysym != NoSymbol; |
382 | } |
391 | } |
383 | |
392 | |
384 | if (valid_keysym) |
393 | if (valid_keysym) |
385 | { |
394 | { |
… | |
… | |
437 | scr_move_to (0, 1); |
446 | scr_move_to (0, 1); |
438 | return; |
447 | return; |
439 | } |
448 | } |
440 | else if (keysym == XK_End) |
449 | else if (keysym == XK_End) |
441 | { |
450 | { |
442 | scr_move_to (1, 0); |
451 | scr_move_to (1, 1); |
443 | return; |
452 | return; |
444 | } |
453 | } |
445 | } |
454 | } |
446 | #endif |
455 | #endif |
447 | } |
456 | } |
… | |
… | |
458 | { |
467 | { |
459 | switch (keysym) |
468 | switch (keysym) |
460 | { |
469 | { |
461 | /* normal XTerm key bindings */ |
470 | /* normal XTerm key bindings */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
471 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
463 | selection_request (ev.time, 0, 0); |
472 | selection_request (ev.time); |
464 | return; |
473 | return; |
465 | #if TODO |
474 | #if TODO |
466 | /* rxvt extras */ |
475 | /* rxvt extras */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
476 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
468 | change_font (FONT_UP); |
477 | change_font (FONT_UP); |
… | |
… | |
487 | { |
496 | { |
488 | commit_iso14755 (); |
497 | commit_iso14755 (); |
489 | iso14755buf = ISO_14755_51; |
498 | iso14755buf = ISO_14755_51; |
490 | # if ISO_14755 |
499 | # if ISO_14755 |
491 | iso14755_51 (0); |
500 | iso14755_51 (0); |
|
|
501 | # endif |
|
|
502 | return; |
|
|
503 | } |
|
|
504 | else if (keysym == XK_BackSpace) |
|
|
505 | { |
|
|
506 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
507 | # if ISO_14755 |
|
|
508 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
492 | # endif |
509 | # endif |
493 | return; |
510 | return; |
494 | } |
511 | } |
495 | else if ((hv = hex_keyval (ev)) >= 0) |
512 | else if ((hv = hex_keyval (ev)) >= 0) |
496 | { |
513 | { |
… | |
… | |
501 | # endif |
518 | # endif |
502 | return; |
519 | return; |
503 | } |
520 | } |
504 | else |
521 | else |
505 | { |
522 | { |
506 | # if ENABLE_OVERLAY |
523 | # if ISO_14755 |
507 | scr_overlay_off (); |
524 | scr_overlay_off (); |
508 | # endif |
525 | # endif |
509 | iso14755buf = 0; |
526 | iso14755buf = 0; |
510 | } |
527 | } |
511 | } |
528 | } |
512 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
529 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
513 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
530 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
514 | if (!(iso14755buf & ISO_14755_STARTED)) |
531 | if (!(iso14755buf & ISO_14755_STARTED)) |
515 | { |
532 | { |
516 | iso14755buf |= ISO_14755_STARTED; |
533 | iso14755buf |= ISO_14755_STARTED; |
517 | # if ENABLE_OVERLAY |
534 | # if ISO_14755 |
518 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
535 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
519 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
536 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
520 | # endif |
537 | # endif |
521 | } |
538 | } |
522 | #endif |
539 | #endif |
523 | |
540 | |
524 | #ifdef PRINTPIPE |
541 | #ifdef PRINTPIPE |
525 | if (keysym == XK_Print) |
542 | if (keysym == XK_Print) |
526 | { |
543 | { |
527 | scr_printscreen (ctrl | shft); |
544 | scr_printscreen (ctrl | shft); |
528 | return; |
545 | return; |
… | |
… | |
710 | |
727 | |
711 | case XK_Find: |
728 | case XK_Find: |
712 | strcpy (kbuf, "\033[1~"); |
729 | strcpy (kbuf, "\033[1~"); |
713 | break; |
730 | break; |
714 | |
731 | |
715 | #ifdef XK_KP_End |
732 | #ifdef XK_KP_Insert |
716 | case XK_KP_Insert: |
733 | case XK_KP_Insert: |
717 | /* allow shift to override */ |
734 | /* allow shift to override */ |
718 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
735 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
719 | { |
736 | { |
720 | strcpy (kbuf, "\033Op"); |
737 | strcpy (kbuf, "\033Op"); |
… | |
… | |
849 | { |
866 | { |
850 | #ifdef META8_OPTION |
867 | #ifdef META8_OPTION |
851 | /* set 8-bit on */ |
868 | /* set 8-bit on */ |
852 | if (meta && (meta_char == 0x80)) |
869 | if (meta && (meta_char == 0x80)) |
853 | { |
870 | { |
854 | unsigned char *ch; |
871 | char *ch; |
855 | |
872 | |
856 | for (ch = kbuf; ch < kbuf + len; ch++) |
873 | for (ch = kbuf; ch < kbuf + len; ch++) |
857 | *ch |= 0x80; |
874 | *ch |= 0x80; |
858 | |
875 | |
859 | meta = 0; |
876 | meta = 0; |
… | |
… | |
861 | #endif |
878 | #endif |
862 | /* nil */ ; |
879 | /* nil */ ; |
863 | } |
880 | } |
864 | } |
881 | } |
865 | |
882 | |
|
|
883 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
884 | return; |
|
|
885 | |
866 | if (len <= 0) |
886 | if (len <= 0) |
867 | return; /* not mapped */ |
887 | return; /* not mapped */ |
868 | |
888 | |
869 | if (OPTION (Opt_scrollTtyKeypress)) |
889 | if (option (Opt_scrollTtyKeypress)) |
870 | if (view_start) |
890 | if (view_start) |
871 | { |
891 | { |
872 | view_start = 0; |
892 | view_start = 0; |
873 | want_refresh = 1; |
893 | want_refresh = 1; |
874 | } |
894 | } |
… | |
… | |
892 | #ifdef META8_OPTION |
912 | #ifdef META8_OPTION |
893 | && meta_char == C0_ESC |
913 | && meta_char == C0_ESC |
894 | #endif |
914 | #endif |
895 | ) |
915 | ) |
896 | { |
916 | { |
897 | const unsigned char ch = C0_ESC; |
917 | const char ch = C0_ESC; |
898 | tt_write (&ch, 1); |
918 | tt_write (&ch, 1); |
899 | } |
919 | } |
900 | |
920 | |
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); |
921 | tt_write (kbuf, (unsigned int)len); |
912 | } |
922 | } |
913 | /*}}} */ |
|
|
914 | |
923 | |
|
|
924 | void |
|
|
925 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
926 | { |
|
|
927 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
928 | KeySym keysym; |
|
|
929 | |
|
|
930 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
931 | #endif |
|
|
932 | |
|
|
933 | #if ENABLE_FRILLS || ISO_14755 |
|
|
934 | // ISO 14755 support |
|
|
935 | if (iso14755buf) |
|
|
936 | if (iso14755buf & ISO_14755_52) |
|
|
937 | { |
|
|
938 | # if ISO_14755 |
|
|
939 | scr_overlay_off (); |
|
|
940 | # endif |
|
|
941 | # if ISO_14755 |
|
|
942 | // iso14755 part 5.2 handling: release time |
|
|
943 | // first: controls |
|
|
944 | if ((ev.state & ControlMask) |
|
|
945 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
946 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
947 | { |
|
|
948 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
949 | commit_iso14755 (); |
|
|
950 | |
|
|
951 | return; |
|
|
952 | } |
|
|
953 | |
|
|
954 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
955 | if (i[0] == keysym) |
|
|
956 | { |
|
|
957 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
958 | commit_iso14755 (); |
|
|
959 | |
|
|
960 | return; |
|
|
961 | } |
|
|
962 | |
|
|
963 | scr_bell (); |
|
|
964 | # endif |
|
|
965 | iso14755buf = 0; |
|
|
966 | |
|
|
967 | return; |
|
|
968 | } |
|
|
969 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
970 | { |
|
|
971 | # if ISO_14755 |
|
|
972 | scr_overlay_off (); |
|
|
973 | # endif |
|
|
974 | if (iso14755buf & ISO_14755_51) |
|
|
975 | commit_iso14755 (); |
|
|
976 | #if ISO_14755 |
|
|
977 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
978 | { |
|
|
979 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
980 | |
|
|
981 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
982 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
983 | } |
|
|
984 | # endif |
|
|
985 | else |
|
|
986 | iso14755buf = 0; |
|
|
987 | } |
|
|
988 | #endif |
|
|
989 | |
|
|
990 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
991 | return; |
|
|
992 | |
|
|
993 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
994 | if (!(ev.state & ControlMask)) |
|
|
995 | slip_wheel_ev.stop (); |
|
|
996 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
997 | mouse_slip_wheel_speed = 0; |
|
|
998 | #endif |
|
|
999 | } |
|
|
1000 | |
915 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
1001 | #if defined (KEYSYM_RESOURCE) |
916 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
917 | /* attempt to `write' count to the input buffer */ |
|
|
918 | unsigned int |
1002 | unsigned int |
919 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
1003 | rxvt_term::cmd_write (const char *str, unsigned int count) |
920 | { |
1004 | { |
921 | unsigned int n, s; |
1005 | unsigned int n, s; |
922 | |
1006 | |
923 | n = cmdbuf_ptr - cmdbuf_base; |
1007 | n = cmdbuf_ptr - cmdbuf_base; |
924 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
1008 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
950 | void |
1034 | void |
951 | rxvt_term::flush () |
1035 | rxvt_term::flush () |
952 | { |
1036 | { |
953 | flush_ev.stop (); |
1037 | flush_ev.stop (); |
954 | |
1038 | |
955 | #ifdef TRANSPARENT |
1039 | #ifdef ENABLE_TRANSPARENCY |
956 | if (want_full_refresh) |
1040 | if (want_full_refresh) |
957 | { |
1041 | { |
958 | want_full_refresh = 0; |
1042 | want_full_refresh = 0; |
959 | scr_clear (); |
1043 | scr_clear (); |
960 | scr_touch (false); |
1044 | scr_touch (false); |
961 | } |
1045 | } |
962 | #endif |
1046 | #endif |
963 | |
1047 | |
964 | if (want_refresh) |
1048 | if (want_refresh) |
965 | { |
1049 | { |
|
|
1050 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
1051 | { |
|
|
1052 | int row = view_start; |
|
|
1053 | int end_row = row + nrow; |
|
|
1054 | |
|
|
1055 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
1056 | --row; |
|
|
1057 | |
|
|
1058 | do |
|
|
1059 | { |
|
|
1060 | int start_row = row; |
|
|
1061 | line_t *l; |
|
|
1062 | |
|
|
1063 | do |
|
|
1064 | { |
|
|
1065 | l = &ROW (row++); |
|
|
1066 | |
|
|
1067 | if (!(l->f & LINE_FILTERED)) |
|
|
1068 | { |
|
|
1069 | // line not filtered, mark it as filtered |
|
|
1070 | l->f |= LINE_FILTERED; |
|
|
1071 | while (l->is_longer ()) |
|
|
1072 | { |
|
|
1073 | l = &ROW (row++); |
|
|
1074 | l->f |= LINE_FILTERED; |
|
|
1075 | } |
|
|
1076 | |
|
|
1077 | // and filter it |
|
|
1078 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1079 | |
|
|
1080 | break; |
|
|
1081 | } |
|
|
1082 | } |
|
|
1083 | while (l->is_longer () && row < end_row); |
|
|
1084 | } |
|
|
1085 | while (row < end_row); |
|
|
1086 | } |
|
|
1087 | |
966 | scr_refresh (refresh_type); |
1088 | scr_refresh (); |
967 | scrollbar_show (1); |
1089 | scrollbar_show (1); |
968 | #ifdef USE_XIM |
1090 | #ifdef USE_XIM |
969 | IMSendSpot (); |
1091 | IMSendSpot (); |
970 | #endif |
1092 | #endif |
971 | } |
1093 | } |
… | |
… | |
974 | } |
1096 | } |
975 | |
1097 | |
976 | void |
1098 | void |
977 | rxvt_term::check_cb (check_watcher &w) |
1099 | rxvt_term::check_cb (check_watcher &w) |
978 | { |
1100 | { |
979 | SET_R (this); |
1101 | make_current (); |
980 | SET_LOCALE (locale); |
|
|
981 | |
1102 | |
982 | display->flush (); |
1103 | display->flush (); |
983 | |
1104 | |
984 | if (want_refresh && !flush_ev.active) |
1105 | if (want_refresh && !flush_ev.active) |
985 | flush_ev.start (NOW + 0.01); |
1106 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
986 | } |
1107 | } |
987 | |
1108 | |
988 | void |
1109 | void |
989 | rxvt_term::flush_cb (time_watcher &w) |
1110 | rxvt_term::flush_cb (time_watcher &w) |
990 | { |
1111 | { |
991 | SET_R (this); |
1112 | make_current (); |
992 | SET_LOCALE (locale); |
|
|
993 | |
1113 | |
994 | refresh_limit = 1; |
|
|
995 | refresh_count = 0; |
1114 | refresh_count = 0; |
996 | flush (); |
1115 | flush (); |
997 | } |
1116 | } |
998 | |
1117 | |
999 | #ifdef CURSOR_BLINK |
1118 | #ifdef CURSOR_BLINK |
… | |
… | |
1001 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1120 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1002 | { |
1121 | { |
1003 | hidden_cursor = !hidden_cursor; |
1122 | hidden_cursor = !hidden_cursor; |
1004 | want_refresh = 1; |
1123 | want_refresh = 1; |
1005 | |
1124 | |
1006 | w.start (w.at + BLINK_INTERVAL); |
1125 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1007 | } |
1126 | } |
1008 | #endif |
1127 | #endif |
1009 | |
1128 | |
1010 | #ifdef TEXT_BLINK |
1129 | #ifdef TEXT_BLINK |
1011 | void |
1130 | void |
… | |
… | |
1025 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1144 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1026 | { |
1145 | { |
1027 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1146 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1028 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1147 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1029 | { |
1148 | { |
1030 | refresh_type |= SMOOTH_REFRESH; |
|
|
1031 | want_refresh = 1; |
1149 | want_refresh = 1; |
1032 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1150 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1033 | } |
1151 | } |
1034 | } |
1152 | } |
1035 | #endif |
1153 | #endif |
… | |
… | |
1039 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1157 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1040 | { |
1158 | { |
1041 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1159 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1042 | { |
1160 | { |
1043 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1161 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1044 | refresh_type |= SMOOTH_REFRESH; |
|
|
1045 | want_refresh = 1; |
1162 | want_refresh = 1; |
1046 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1163 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1047 | } |
1164 | } |
1048 | } |
1165 | } |
1049 | #endif |
1166 | #endif |
… | |
… | |
1054 | { |
1171 | { |
1055 | if (mouse_slip_wheel_speed == 0 |
1172 | if (mouse_slip_wheel_speed == 0 |
1056 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1173 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1057 | : scr_page (UP, mouse_slip_wheel_speed)) |
1174 | : scr_page (UP, mouse_slip_wheel_speed)) |
1058 | { |
1175 | { |
1059 | if (view_start == nsaved || |
1176 | if (view_start == top_row || view_start == 0) |
1060 | view_start == 0) |
|
|
1061 | mouse_slip_wheel_speed = 0; |
1177 | mouse_slip_wheel_speed = 0; |
1062 | |
1178 | |
1063 | refresh_type |= SMOOTH_REFRESH; |
|
|
1064 | want_refresh = 1; |
1179 | want_refresh = 1; |
1065 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1180 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1066 | } |
1181 | } |
1067 | } |
1182 | } |
1068 | #endif |
1183 | #endif |
1069 | |
1184 | |
|
|
1185 | #if LINUX_YIELD_HACK |
|
|
1186 | static struct event_handler |
|
|
1187 | { |
|
|
1188 | check_watcher yield_ev; |
|
|
1189 | |
|
|
1190 | void yield_cb (check_watcher &w) |
|
|
1191 | { |
|
|
1192 | // this should really be sched_yield(), but the linux guys thought |
|
|
1193 | // that giving a process calling sched_yield () less cpu time than |
|
|
1194 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1195 | // allowed by the sus... as is returning ENOSYS. |
|
|
1196 | |
|
|
1197 | struct timespec ts = { 0, 0 }; |
|
|
1198 | nanosleep (&ts, 0); |
|
|
1199 | |
|
|
1200 | w.stop (); |
|
|
1201 | } |
|
|
1202 | |
|
|
1203 | event_handler () |
|
|
1204 | : yield_ev (this, &event_handler::yield_cb) |
|
|
1205 | { |
|
|
1206 | } |
|
|
1207 | } event_handler; |
|
|
1208 | #endif |
|
|
1209 | |
1070 | bool |
1210 | bool |
1071 | rxvt_term::pty_fill () |
1211 | rxvt_term::pty_fill () |
1072 | { |
1212 | { |
1073 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1213 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1074 | |
1214 | |
1075 | if (CBUFSIZ == n) |
1215 | if (CBUFSIZ == n) |
1076 | { |
1216 | { |
1077 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1217 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1078 | n = 0; |
1218 | n = 0; |
1079 | } |
1219 | } |
1080 | |
1220 | |
1081 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1221 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1082 | cmdbuf_ptr = cmdbuf_base; |
1222 | cmdbuf_ptr = cmdbuf_base; |
1083 | cmdbuf_endp = cmdbuf_ptr + n; |
1223 | cmdbuf_endp = cmdbuf_ptr + n; |
1084 | |
1224 | |
1085 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1225 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1086 | |
1226 | |
1087 | if (n > 0) |
1227 | if (r > 0) |
1088 | { |
1228 | { |
1089 | cmdbuf_endp += n; |
1229 | cmdbuf_endp += r; |
1090 | return true; |
1230 | return true; |
1091 | } |
1231 | } |
1092 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1232 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1233 | { |
|
|
1234 | #if LINUX_YIELD_HACK |
|
|
1235 | if (display->is_local) |
|
|
1236 | event_handler.yield_ev.start (); |
|
|
1237 | #endif |
|
|
1238 | } |
|
|
1239 | else |
1093 | { |
1240 | { |
1094 | pty_ev.stop (); |
1241 | pty_ev.stop (); |
1095 | |
1242 | |
1096 | if (!OPTION (Opt_hold)) |
1243 | if (!option (Opt_hold)) |
1097 | destroy (); |
1244 | destroy (); |
1098 | } |
1245 | } |
1099 | |
1246 | |
1100 | return false; |
1247 | return false; |
1101 | } |
1248 | } |
1102 | |
1249 | |
1103 | void |
1250 | void |
1104 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1251 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1105 | { |
1252 | { |
1106 | SET_R (this); |
1253 | make_current (); |
1107 | SET_LOCALE (locale); |
|
|
1108 | |
1254 | |
1109 | if (revents & EVENT_READ) |
1255 | if (revents & EVENT_READ) |
1110 | // loop, but don't allow a single term to monopolize us |
1256 | // loop, but don't allow a single term to monopolize us |
1111 | while (pty_fill ()) |
1257 | while (pty_fill ()) |
1112 | if (cmd_parse ()) |
1258 | if (cmd_parse ()) |
… | |
… | |
1117 | } |
1263 | } |
1118 | |
1264 | |
1119 | void |
1265 | void |
1120 | rxvt_term::pointer_unblank () |
1266 | rxvt_term::pointer_unblank () |
1121 | { |
1267 | { |
1122 | XDefineCursor (display->display, vt, TermWin_cursor); |
1268 | XDefineCursor (dpy, vt, TermWin_cursor); |
1123 | recolour_cursor (); |
1269 | recolour_cursor (); |
1124 | |
1270 | |
1125 | #ifdef POINTER_BLANK |
1271 | #ifdef POINTER_BLANK |
1126 | hidden_pointer = 0; |
1272 | hidden_pointer = 0; |
1127 | |
1273 | |
1128 | if (OPTION (Opt_pointerBlank)) |
1274 | if (option (Opt_pointerBlank)) |
1129 | pointer_ev.start (NOW + pointerBlankDelay); |
1275 | pointer_ev.start (NOW + pointerBlankDelay); |
1130 | #endif |
1276 | #endif |
1131 | } |
1277 | } |
1132 | |
1278 | |
1133 | #ifdef POINTER_BLANK |
1279 | #ifdef POINTER_BLANK |
1134 | void |
1280 | void |
1135 | rxvt_term::pointer_blank () |
1281 | rxvt_term::pointer_blank () |
1136 | { |
1282 | { |
1137 | if (! OPTION (Opt_pointerBlank)) |
1283 | if (!option (Opt_pointerBlank)) |
1138 | return; |
1284 | return; |
1139 | |
1285 | |
1140 | XDefineCursor (display->display, vt, display->blank_cursor); |
1286 | XDefineCursor (dpy, vt, display->blank_cursor); |
1141 | XFlush (display->display); |
1287 | XFlush (dpy); |
1142 | |
1288 | |
1143 | hidden_pointer = 1; |
1289 | hidden_pointer = 1; |
1144 | } |
1290 | } |
1145 | |
1291 | |
1146 | void |
1292 | void |
1147 | rxvt_term::pointer_cb (time_watcher &w) |
1293 | rxvt_term::pointer_cb (time_watcher &w) |
1148 | { |
1294 | { |
1149 | SET_R (this); |
1295 | make_current (); |
1150 | SET_LOCALE (locale); |
|
|
1151 | |
1296 | |
1152 | pointer_blank (); |
1297 | pointer_blank (); |
1153 | } |
1298 | } |
1154 | #endif |
1299 | #endif |
1155 | |
1300 | |
… | |
… | |
1220 | (32 + button_number + key_state), |
1365 | (32 + button_number + key_state), |
1221 | (32 + x + 1), |
1366 | (32 + x + 1), |
1222 | (32 + y + 1)); |
1367 | (32 + y + 1)); |
1223 | } |
1368 | } |
1224 | |
1369 | |
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 */ |
1370 | /*{{{ process an X event */ |
1236 | void |
1371 | void |
1237 | rxvt_term::x_cb (XEvent &ev) |
1372 | rxvt_term::x_cb (XEvent &ev) |
1238 | { |
1373 | { |
1239 | dDisp; |
1374 | make_current (); |
1240 | |
1375 | |
1241 | SET_R (this); |
1376 | dLocal (Display *, dpy); |
1242 | SET_LOCALE (locale); |
|
|
1243 | |
1377 | |
1244 | #if defined(CURSOR_BLINK) |
1378 | if (ev.xany.window == vt |
1245 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1379 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1246 | { |
1380 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1247 | if (hidden_cursor) |
1381 | return; |
1248 | { |
|
|
1249 | hidden_cursor = 0; |
|
|
1250 | want_refresh = 1; |
|
|
1251 | } |
|
|
1252 | |
1382 | |
1253 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1383 | // 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; |
1384 | Window unused_root, unused_child; |
1272 | int unused_root_x, unused_root_y; |
1385 | int unused_root_x, unused_root_y; |
1273 | unsigned int unused_mask; |
1386 | unsigned int unused_mask; |
1274 | |
1387 | |
1275 | switch (ev.type) |
1388 | switch (ev.type) |
1276 | { |
1389 | { |
1277 | case KeyPress: |
1390 | case KeyPress: |
1278 | #if ISO_14755 |
1391 | key_press (ev.xkey); |
1279 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1280 | #endif |
|
|
1281 | lookup_key (ev.xkey); |
|
|
1282 | |
|
|
1283 | break; |
1392 | break; |
1284 | |
1393 | |
1285 | case KeyRelease: |
1394 | case KeyRelease: |
1286 | { |
1395 | 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; |
1396 | break; |
1354 | } |
|
|
1355 | |
1397 | |
1356 | case ButtonPress: |
1398 | case ButtonPress: |
1357 | button_press (ev.xbutton); |
1399 | button_press (ev.xbutton); |
1358 | break; |
1400 | break; |
1359 | |
1401 | |
… | |
… | |
1361 | button_release (ev.xbutton); |
1403 | button_release (ev.xbutton); |
1362 | break; |
1404 | break; |
1363 | |
1405 | |
1364 | case ClientMessage: |
1406 | case ClientMessage: |
1365 | if (ev.xclient.format == 32 |
1407 | if (ev.xclient.format == 32 |
1366 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1408 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1367 | { |
1409 | { |
|
|
1410 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1411 | { |
|
|
1412 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1413 | { |
1368 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1414 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1415 | { |
|
|
1416 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1369 | destroy (); |
1417 | destroy (); |
|
|
1418 | } |
1370 | #if ENABLE_EWMH |
1419 | #if ENABLE_EWMH |
1371 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1420 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1372 | XSendEvent (disp, ev.xclient.window = display->root, |
1421 | XSendEvent (dpy, ev.xclient.window = display->root, |
1373 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1422 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1374 | &ev); |
1423 | &ev); |
|
|
1424 | #endif |
|
|
1425 | } |
|
|
1426 | } |
|
|
1427 | #if ENABLE_XEMBED |
|
|
1428 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1429 | { |
|
|
1430 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1431 | focus_in (); |
|
|
1432 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1433 | focus_out (); |
|
|
1434 | } |
1375 | #endif |
1435 | #endif |
1376 | } |
1436 | } |
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; |
|
|
1413 | |
|
|
1414 | case MappingNotify: |
|
|
1415 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1416 | break; |
1437 | break; |
1417 | |
1438 | |
1418 | /* |
1439 | /* |
1419 | * XXX: this is not the _current_ arrangement |
1440 | * XXX: this is not the _current_ arrangement |
1420 | * Here's my conclusion: |
1441 | * Here's my conclusion: |
… | |
… | |
1439 | break; |
1460 | break; |
1440 | } |
1461 | } |
1441 | break; |
1462 | break; |
1442 | |
1463 | |
1443 | case FocusIn: |
1464 | case FocusIn: |
|
|
1465 | if (ev.xfocus.detail != NotifyInferior |
|
|
1466 | && ev.xfocus.detail != NotifyPointer |
|
|
1467 | && ev.xfocus.mode != NotifyGrab) |
1444 | focus_in (); |
1468 | focus_in (); |
1445 | break; |
1469 | break; |
1446 | |
1470 | |
1447 | case FocusOut: |
1471 | case FocusOut: |
|
|
1472 | if (ev.xfocus.detail != NotifyInferior |
|
|
1473 | && ev.xfocus.detail != NotifyPointer |
|
|
1474 | && ev.xfocus.mode != NotifyGrab) |
1448 | focus_out (); |
1475 | focus_out (); |
1449 | break; |
1476 | break; |
1450 | |
1477 | |
1451 | case ConfigureNotify: |
1478 | case ConfigureNotify: |
1452 | if (ev.xconfigure.window == parent[0]) |
1479 | if (ev.xconfigure.window == parent[0]) |
1453 | { |
1480 | { |
1454 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1481 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1455 | ; |
1482 | ; |
1456 | |
1483 | |
1457 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1484 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1458 | { |
1485 | { |
1459 | seen_resize = 1; |
1486 | seen_resize = 1; |
1460 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1487 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1461 | } |
1488 | } |
1462 | |
1489 | else |
1463 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1490 | { |
|
|
1491 | #ifdef ENABLE_TRANSPARENCY |
1464 | if (OPTION (Opt_transparent)) |
1492 | if (option (Opt_transparent)) |
1465 | check_our_parents (); |
1493 | if (bgPixmap.render ()) |
|
|
1494 | scr_touch (false); |
1466 | #endif |
1495 | #endif |
|
|
1496 | } |
|
|
1497 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1467 | } |
1498 | } |
1468 | break; |
1499 | break; |
1469 | |
1500 | |
1470 | case PropertyNotify: |
1501 | case PropertyNotify: |
|
|
1502 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1471 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1503 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1472 | && ev.xproperty.state == PropertyNewValue) |
1504 | && ev.xproperty.state == PropertyNewValue) |
1473 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1505 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1474 | |
1506 | |
1475 | break; |
1507 | break; |
1476 | |
1508 | |
1477 | case SelectionClear: |
1509 | case SelectionClear: |
1478 | selection_clear (); |
1510 | selection_clear (); |
… | |
… | |
1483 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1515 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1484 | break; |
1516 | break; |
1485 | |
1517 | |
1486 | case SelectionRequest: |
1518 | case SelectionRequest: |
1487 | selection_send (ev.xselectionrequest); |
1519 | selection_send (ev.xselectionrequest); |
|
|
1520 | break; |
|
|
1521 | |
|
|
1522 | case MapNotify: |
|
|
1523 | mapped = 1; |
|
|
1524 | #ifdef TEXT_BLINK |
|
|
1525 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1526 | #endif |
|
|
1527 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1488 | break; |
1528 | break; |
1489 | |
1529 | |
1490 | case UnmapNotify: |
1530 | case UnmapNotify: |
1491 | mapped = 0; |
1531 | mapped = 0; |
1492 | #ifdef TEXT_BLINK |
1532 | #ifdef TEXT_BLINK |
1493 | text_blink_ev.stop (); |
1533 | text_blink_ev.stop (); |
1494 | #endif |
1534 | #endif |
|
|
1535 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1495 | break; |
1536 | break; |
1496 | |
1537 | |
1497 | case MapNotify: |
|
|
1498 | mapped = 1; |
|
|
1499 | #ifdef TEXT_BLINK |
|
|
1500 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1501 | #endif |
|
|
1502 | break; |
|
|
1503 | |
|
|
1504 | #ifdef TRANSPARENT |
1538 | #ifdef ENABLE_TRANSPARENCY |
1505 | case ReparentNotify: |
1539 | case ReparentNotify: |
1506 | rootwin_cb (ev); |
1540 | rootwin_cb (ev); |
1507 | break; |
1541 | break; |
1508 | #endif /* TRANSPARENT */ |
1542 | #endif /* ENABLE_TRANSPARENCY */ |
1509 | |
1543 | |
1510 | case GraphicsExpose: |
1544 | case GraphicsExpose: |
1511 | case Expose: |
1545 | case Expose: |
1512 | if (ev.xany.window == vt) |
1546 | if (ev.xany.window == vt) |
1513 | { |
1547 | { |
1514 | do |
1548 | do |
1515 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1549 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1516 | ev.xexpose.width, ev.xexpose.height, False); |
1550 | ev.xexpose.width, ev.xexpose.height, False); |
1517 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1551 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1518 | |
1552 | |
1519 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1553 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1520 | |
1554 | |
1521 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1555 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1522 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1556 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1523 | ev.xexpose.width, ev.xexpose.height, False); |
1557 | ev.xexpose.width, ev.xexpose.height, False); |
1524 | |
1558 | |
1525 | scr_refresh (refresh_type); |
1559 | want_refresh = 1; |
1526 | } |
1560 | } |
1527 | else |
1561 | else |
1528 | { |
1562 | { |
1529 | XEvent unused_event; |
1563 | XEvent unused_event; |
1530 | |
1564 | |
1531 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1565 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1532 | ; |
1566 | ; |
1533 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1567 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1534 | ; |
1568 | ; |
1535 | |
1569 | |
1536 | if (isScrollbarWindow (ev.xany.window)) |
1570 | if (isScrollbarWindow (ev.xany.window)) |
1537 | { |
1571 | { |
1538 | scrollBar.setIdle (); |
1572 | scrollBar.setIdle (); |
1539 | scrollbar_show (0); |
1573 | scrollbar_show (0); |
1540 | } |
1574 | } |
1541 | #ifdef MENUBAR |
|
|
1542 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1543 | menubar_expose (); |
|
|
1544 | #endif |
|
|
1545 | |
|
|
1546 | #ifdef TRANSPARENT |
|
|
1547 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1548 | XClearWindow (disp, ev.xany.window); |
|
|
1549 | #endif |
|
|
1550 | } |
1575 | } |
1551 | break; |
1576 | break; |
1552 | |
1577 | |
1553 | case MotionNotify: |
1578 | case MotionNotify: |
1554 | #ifdef POINTER_BLANK |
1579 | #ifdef POINTER_BLANK |
1555 | if (hidden_pointer) |
1580 | if (hidden_pointer) |
1556 | pointer_unblank (); |
1581 | pointer_unblank (); |
1557 | #endif |
1582 | #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) |
1583 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1566 | break; |
1584 | break; |
1567 | |
1585 | |
1568 | if (ev.xany.window == vt) |
1586 | if (ev.xany.window == vt) |
1569 | { |
1587 | { |
|
|
1588 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1589 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1590 | ; // nop |
1570 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1591 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1571 | { |
1592 | { |
1572 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1593 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1573 | ; |
1594 | ; |
1574 | |
1595 | |
1575 | XQueryPointer (disp, vt, |
1596 | XQueryPointer (dpy, vt, |
1576 | &unused_root, &unused_child, |
1597 | &unused_root, &unused_child, |
1577 | &unused_root_x, &unused_root_y, |
1598 | &unused_root_x, &unused_root_y, |
1578 | &ev.xbutton.x, &ev.xbutton.y, |
1599 | &ev.xbutton.x, &ev.xbutton.y, |
1579 | &ev.xbutton.state); |
1600 | &ev.xbutton.state); |
1580 | #ifdef MOUSE_THRESHOLD |
1601 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1644 | #endif |
1665 | #endif |
1645 | } |
1666 | } |
1646 | } |
1667 | } |
1647 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1668 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1648 | { |
1669 | { |
1649 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1670 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1650 | MotionNotify, &ev)) |
1671 | MotionNotify, &ev)) |
1651 | ; |
1672 | ; |
1652 | |
1673 | |
1653 | XQueryPointer (disp, scrollBar.win, |
1674 | XQueryPointer (dpy, scrollBar.win, |
1654 | &unused_root, &unused_child, |
1675 | &unused_root, &unused_child, |
1655 | &unused_root_x, &unused_root_y, |
1676 | &unused_root_x, &unused_root_y, |
1656 | &ev.xbutton.x, &ev.xbutton.y, |
1677 | &ev.xbutton.x, &ev.xbutton.y, |
1657 | &unused_mask); |
1678 | &unused_mask); |
1658 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1679 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1659 | scrollbar_size ()); |
1680 | scrollbar_size ()); |
1660 | scr_refresh (refresh_type); |
|
|
1661 | refresh_limit = 0; |
1681 | want_refresh = 1; |
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; |
1690 | scr_recolour (); |
1740 | scr_recolour (); |
1691 | } |
1741 | } |
1692 | #endif |
1742 | #endif |
|
|
1743 | #if ENABLE_FRILLS |
|
|
1744 | if (option (Opt_urgentOnBell)) |
|
|
1745 | { |
|
|
1746 | XWMHints *h; |
|
|
1747 | |
|
|
1748 | h = XGetWMHints(dpy, parent[0]); |
|
|
1749 | if (h != NULL) |
|
|
1750 | { |
|
|
1751 | h->flags &= ~XUrgencyHint; |
|
|
1752 | XSetWMHints(dpy, parent[0], h); |
|
|
1753 | } |
|
|
1754 | } |
|
|
1755 | #endif |
1693 | } |
1756 | } |
1694 | } |
1757 | } |
1695 | |
1758 | |
1696 | void |
1759 | void |
1697 | rxvt_term::focus_out () |
1760 | rxvt_term::focus_out () |
… | |
… | |
1699 | if (focus) |
1762 | if (focus) |
1700 | { |
1763 | { |
1701 | focus = 0; |
1764 | focus = 0; |
1702 | want_refresh = 1; |
1765 | want_refresh = 1; |
1703 | |
1766 | |
|
|
1767 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1768 | |
1704 | #if ENABLE_FRILLS || ISO_14755 |
1769 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1770 | if (iso14755buf) |
|
|
1771 | { |
1705 | iso14755buf = 0; |
1772 | iso14755buf = 0; |
1706 | #endif |
1773 | # if ISO_14755 |
1707 | #if ENABLE_OVERLAY |
|
|
1708 | scr_overlay_off (); |
1774 | scr_overlay_off (); |
|
|
1775 | # endif |
|
|
1776 | } |
1709 | #endif |
1777 | #endif |
1710 | #if USE_XIM |
1778 | #if USE_XIM |
1711 | if (Input_Context != NULL) |
1779 | if (Input_Context != NULL) |
1712 | XUnsetICFocus (Input_Context); |
1780 | XUnsetICFocus (Input_Context); |
1713 | #endif |
1781 | #endif |
1714 | #if CURSOR_BLINK |
1782 | #if CURSOR_BLINK |
1715 | if (OPTION (Opt_cursorBlink)) |
1783 | if (option (Opt_cursorBlink)) |
1716 | cursor_blink_ev.stop (); |
1784 | cursor_blink_ev.stop (); |
1717 | hidden_cursor = 0; |
1785 | hidden_cursor = 0; |
1718 | #endif |
1786 | #endif |
1719 | #if OFF_FOCUS_FADING |
1787 | #if OFF_FOCUS_FADING |
1720 | if (rs[Rs_fade]) |
1788 | if (rs[Rs_fade]) |
… | |
… | |
1724 | } |
1792 | } |
1725 | #endif |
1793 | #endif |
1726 | } |
1794 | } |
1727 | } |
1795 | } |
1728 | |
1796 | |
1729 | #if TRANSPARENT |
1797 | void |
|
|
1798 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1799 | { |
|
|
1800 | #if OFF_FOCUS_FADING |
|
|
1801 | if (rs[Rs_fade]) |
|
|
1802 | { |
|
|
1803 | rgba c; |
|
|
1804 | pix_colors [Color_fade].get (c); |
|
|
1805 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1806 | } |
|
|
1807 | #endif |
|
|
1808 | } |
|
|
1809 | |
|
|
1810 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1730 | void |
1811 | void |
1731 | rxvt_term::rootwin_cb (XEvent &ev) |
1812 | rxvt_term::rootwin_cb (XEvent &ev) |
1732 | { |
1813 | { |
1733 | SET_R (this); |
1814 | make_current (); |
1734 | SET_LOCALE (locale); |
|
|
1735 | |
1815 | |
|
|
1816 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1817 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1818 | return; |
|
|
1819 | |
|
|
1820 | # if ENABLE_TRANSPARENCY |
1736 | switch (ev.type) |
1821 | switch (ev.type) |
1737 | { |
1822 | { |
1738 | case PropertyNotify: |
1823 | case PropertyNotify: |
1739 | /* |
1824 | /* |
1740 | * if user used some Esetroot compatible prog to set the root bg, |
1825 | * if user used some Esetroot compatible prog to set the root bg, |
1741 | * use the property to determine the pixmap. We use it later on. |
1826 | * use the property to determine the pixmap. We use it later on. |
1742 | */ |
1827 | */ |
1743 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1828 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1744 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1829 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1745 | return; |
1830 | { |
1746 | |
1831 | bgPixmap.set_root_pixmap (); |
1747 | /* FALLTHROUGH */ |
1832 | bgPixmap.render (); |
1748 | case ReparentNotify: |
1833 | } |
1749 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1750 | want_refresh = want_full_refresh = 1; |
|
|
1751 | break; |
1834 | break; |
1752 | } |
1835 | } |
|
|
1836 | # endif |
1753 | } |
1837 | } |
1754 | #endif |
1838 | #endif |
1755 | |
1839 | |
1756 | void |
1840 | void |
1757 | rxvt_term::button_press (XButtonEvent &ev) |
1841 | rxvt_term::button_press (XButtonEvent &ev) |
1758 | { |
1842 | { |
1759 | int reportmode = 0, clickintime; |
1843 | int reportmode = 0, clickintime; |
1760 | |
1844 | |
1761 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1845 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1846 | |
1762 | if (!bypass_keystate) |
1847 | if (!bypass_keystate) |
1763 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1848 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1764 | |
1849 | |
1765 | /* |
1850 | /* |
1766 | * VT window processing of button press |
1851 | * VT window processing of button press |
1767 | */ |
1852 | */ |
1768 | if (ev.window == vt) |
1853 | if (ev.window == vt) |
1769 | { |
1854 | { |
|
|
1855 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1856 | return; |
|
|
1857 | |
1770 | #if ISO_14755 |
1858 | #if ISO_14755 |
1771 | // 5.4 |
1859 | // 5.4 |
1772 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1860 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1773 | { |
1861 | { |
1774 | iso14755_54 (ev.x, ev.y); |
1862 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1786 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1874 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1787 | if (ev.button == MEvent.button && clickintime) |
1875 | if (ev.button == MEvent.button && clickintime) |
1788 | { |
1876 | { |
1789 | /* same button, within alloted time */ |
1877 | /* same button, within alloted time */ |
1790 | MEvent.clicks++; |
1878 | MEvent.clicks++; |
|
|
1879 | |
1791 | if (MEvent.clicks > 1) |
1880 | if (MEvent.clicks > 1) |
1792 | { |
1881 | { |
1793 | /* only report double clicks */ |
1882 | /* only report double clicks */ |
1794 | MEvent.clicks = 2; |
1883 | MEvent.clicks = 2; |
1795 | mouse_report (ev); |
1884 | mouse_report (ev); |
… | |
… | |
1827 | #else |
1916 | #else |
1828 | selection.rect = false; |
1917 | selection.rect = false; |
1829 | #endif |
1918 | #endif |
1830 | |
1919 | |
1831 | /* allow shift+left click to extend selection */ |
1920 | /* allow shift+left click to extend selection */ |
1832 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1921 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1833 | { |
1922 | { |
1834 | if (MEvent.button == Button1 && clickintime) |
1923 | if (MEvent.button == Button1 && clickintime) |
1835 | selection_rotate (ev.x, ev.y); |
1924 | selection_rotate (ev.x, ev.y); |
1836 | else |
1925 | else |
1837 | selection_extend (ev.x, ev.y, 1); |
1926 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2002 | } |
2091 | } |
2003 | |
2092 | |
2004 | break; |
2093 | break; |
2005 | } |
2094 | } |
2006 | } |
2095 | } |
|
|
2096 | |
2007 | return; |
2097 | return; |
2008 | } |
2098 | } |
2009 | #if MENUBAR |
|
|
2010 | /* |
|
|
2011 | * Menubar window processing of button press |
|
|
2012 | */ |
|
|
2013 | if (isMenuBarWindow (ev.window)) |
|
|
2014 | menubar_control (ev); |
|
|
2015 | #endif |
|
|
2016 | } |
2099 | } |
2017 | |
2100 | |
2018 | void |
2101 | void |
2019 | rxvt_term::button_release (XButtonEvent &ev) |
2102 | rxvt_term::button_release (XButtonEvent &ev) |
2020 | { |
2103 | { |
… | |
… | |
2026 | |
2109 | |
2027 | if (scrollbar_isUpDn ()) |
2110 | if (scrollbar_isUpDn ()) |
2028 | { |
2111 | { |
2029 | scrollBar.setIdle (); |
2112 | scrollBar.setIdle (); |
2030 | scrollbar_show (0); |
2113 | scrollbar_show (0); |
2031 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2032 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2033 | #endif |
|
|
2034 | } |
2114 | } |
2035 | |
2115 | |
2036 | #ifdef SELECTION_SCROLLING |
2116 | #ifdef SELECTION_SCROLLING |
2037 | if (sel_scroll_ev.active) |
2117 | if (sel_scroll_ev.active) |
2038 | sel_scroll_ev.stop(); |
2118 | sel_scroll_ev.stop(); |
2039 | #endif |
2119 | #endif |
2040 | |
2120 | |
2041 | if (ev.window == vt) |
2121 | if (ev.window == vt) |
2042 | { |
2122 | { |
|
|
2123 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2124 | return; |
|
|
2125 | |
2043 | #if ISO_14755 |
2126 | #if ISO_14755 |
2044 | // 5.4 |
2127 | // 5.4 |
2045 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2128 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2046 | return; |
2129 | return; |
2047 | #endif |
2130 | #endif |
|
|
2131 | |
2048 | if (reportmode) |
2132 | if (reportmode) |
2049 | { |
2133 | { |
2050 | /* mouse report from vt window */ |
2134 | /* mouse report from vt window */ |
2051 | /* don't report release of wheel "buttons" */ |
2135 | /* don't report release of wheel "buttons" */ |
2052 | if (ev.button >= 4) |
2136 | if (ev.button >= 4) |
… | |
… | |
2082 | { |
2166 | { |
2083 | case Button1: |
2167 | case Button1: |
2084 | case Button3: |
2168 | case Button3: |
2085 | selection_make (ev.time); |
2169 | selection_make (ev.time); |
2086 | break; |
2170 | break; |
|
|
2171 | |
2087 | case Button2: |
2172 | case Button2: |
2088 | selection_request (ev.time, ev.x, ev.y); |
2173 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2174 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2089 | break; |
2175 | break; |
|
|
2176 | |
2090 | #ifdef MOUSE_WHEEL |
2177 | #ifdef MOUSE_WHEEL |
2091 | case Button4: |
2178 | case Button4: |
2092 | case Button5: |
2179 | case Button5: |
2093 | { |
2180 | { |
2094 | int i; |
2181 | int i; |
… | |
… | |
2096 | |
2183 | |
2097 | v = ev.button == Button4 ? UP : DN; |
2184 | v = ev.button == Button4 ? UP : DN; |
2098 | |
2185 | |
2099 | if (ev.state & ShiftMask) |
2186 | if (ev.state & ShiftMask) |
2100 | i = 1; |
2187 | i = 1; |
2101 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2188 | else if (option (Opt_mouseWheelScrollPage)) |
2102 | i = nrow - 1; |
2189 | i = nrow - 1; |
2103 | else |
2190 | else |
2104 | i = 5; |
2191 | i = 5; |
2105 | |
2192 | |
2106 | # ifdef MOUSE_SLIP_WHEELING |
2193 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2116 | slip_wheel_ev.start (); |
2203 | slip_wheel_ev.start (); |
2117 | } |
2204 | } |
2118 | else |
2205 | else |
2119 | { |
2206 | { |
2120 | # endif |
2207 | # endif |
2121 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2122 | scr_page (v, i); |
2208 | scr_page (v, i); |
2123 | scr_refresh (SMOOTH_REFRESH); |
|
|
2124 | scrollbar_show (1); |
2209 | 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 |
2210 | # ifdef MOUSE_SLIP_WHEELING |
2134 | } |
2211 | } |
2135 | #endif |
2212 | # endif |
2136 | } |
2213 | } |
2137 | break; |
2214 | break; |
2138 | #endif |
2215 | #endif |
2139 | } |
2216 | } |
2140 | } |
2217 | } |
2141 | #ifdef MENUBAR |
|
|
2142 | else if (isMenuBarWindow (ev.window)) |
|
|
2143 | menubar_control (ev); |
|
|
2144 | #endif |
|
|
2145 | } |
2218 | } |
2146 | |
|
|
2147 | #ifdef TRANSPARENT |
|
|
2148 | #if TINTING |
|
|
2149 | /* taken from aterm-0.4.2 */ |
|
|
2150 | |
|
|
2151 | typedef uint32_t RUINT32T; |
|
|
2152 | |
|
|
2153 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2154 | { |
|
|
2155 | int sh_r, sh_g, sh_b; |
|
|
2156 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2157 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2158 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2159 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2160 | int i; |
|
|
2161 | |
|
|
2162 | Visual *visual = display->visual; |
|
|
2163 | |
|
|
2164 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2165 | |
|
|
2166 | /* for convenience */ |
|
|
2167 | mask_r = visual->red_mask; |
|
|
2168 | mask_g = visual->green_mask; |
|
|
2169 | mask_b = visual->blue_mask; |
|
|
2170 | |
|
|
2171 | /* boring lookup table pre-initialization */ |
|
|
2172 | switch (srcImage->bits_per_pixel) { |
|
|
2173 | case 15: |
|
|
2174 | if ((mask_r != 0x7c00) || |
|
|
2175 | (mask_g != 0x03e0) || |
|
|
2176 | (mask_b != 0x001f)) |
|
|
2177 | return; |
|
|
2178 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2179 | lookup_r = lookup; |
|
|
2180 | lookup_g = lookup+32; |
|
|
2181 | lookup_b = lookup+32+32; |
|
|
2182 | sh_r = 10; |
|
|
2183 | sh_g = 5; |
|
|
2184 | sh_b = 0; |
|
|
2185 | break; |
|
|
2186 | case 16: |
|
|
2187 | if ((mask_r != 0xf800) || |
|
|
2188 | (mask_g != 0x07e0) || |
|
|
2189 | (mask_b != 0x001f)) |
|
|
2190 | return; |
|
|
2191 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2192 | lookup_r = lookup; |
|
|
2193 | lookup_g = lookup+32; |
|
|
2194 | lookup_b = lookup+32+64; |
|
|
2195 | sh_r = 11; |
|
|
2196 | sh_g = 5; |
|
|
2197 | sh_b = 0; |
|
|
2198 | break; |
|
|
2199 | case 24: |
|
|
2200 | if ((mask_r != 0xff0000) || |
|
|
2201 | (mask_g != 0x00ff00) || |
|
|
2202 | (mask_b != 0x0000ff)) |
|
|
2203 | return; |
|
|
2204 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2205 | lookup_r = lookup; |
|
|
2206 | lookup_g = lookup+256; |
|
|
2207 | lookup_b = lookup+256+256; |
|
|
2208 | sh_r = 16; |
|
|
2209 | sh_g = 8; |
|
|
2210 | sh_b = 0; |
|
|
2211 | break; |
|
|
2212 | case 32: |
|
|
2213 | if ((mask_r != 0xff0000) || |
|
|
2214 | (mask_g != 0x00ff00) || |
|
|
2215 | (mask_b != 0x0000ff)) |
|
|
2216 | return; |
|
|
2217 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2218 | lookup_r = lookup; |
|
|
2219 | lookup_g = lookup+256; |
|
|
2220 | lookup_b = lookup+256+256; |
|
|
2221 | sh_r = 16; |
|
|
2222 | sh_g = 8; |
|
|
2223 | sh_b = 0; |
|
|
2224 | break; |
|
|
2225 | default: |
|
|
2226 | return; /* we do not support this color depth */ |
|
|
2227 | } |
|
|
2228 | |
|
|
2229 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2230 | if (shade < 0) { |
|
|
2231 | shade = -shade; |
|
|
2232 | if (shade < 0) shade = 0; |
|
|
2233 | if (shade > 100) shade = 100; |
|
|
2234 | |
|
|
2235 | lower_lim_r = 65535-rm; |
|
|
2236 | lower_lim_g = 65535-gm; |
|
|
2237 | lower_lim_b = 65535-bm; |
|
|
2238 | |
|
|
2239 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2240 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2241 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2242 | |
|
|
2243 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2244 | } else { |
|
|
2245 | if (shade < 0) shade = 0; |
|
|
2246 | if (shade > 100) shade = 100; |
|
|
2247 | |
|
|
2248 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2249 | |
|
|
2250 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2251 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2252 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2253 | } |
|
|
2254 | |
|
|
2255 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2256 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2257 | { |
|
|
2258 | unsigned int tmp; |
|
|
2259 | |
|
|
2260 | tmp = lower_lim_r; |
|
|
2261 | lower_lim_r = lower_lim_b; |
|
|
2262 | lower_lim_b = tmp; |
|
|
2263 | |
|
|
2264 | tmp = upper_lim_r; |
|
|
2265 | upper_lim_r = upper_lim_b; |
|
|
2266 | upper_lim_b = tmp; |
|
|
2267 | } |
|
|
2268 | |
|
|
2269 | /* fill our lookup tables */ |
|
|
2270 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2271 | { |
|
|
2272 | RUINT32T tmp; |
|
|
2273 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2274 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2275 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2276 | } |
|
|
2277 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2278 | { |
|
|
2279 | RUINT32T tmp; |
|
|
2280 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2281 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2282 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2283 | } |
|
|
2284 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2285 | { |
|
|
2286 | RUINT32T tmp; |
|
|
2287 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2288 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2289 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2290 | } |
|
|
2291 | |
|
|
2292 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2293 | switch (srcImage->bits_per_pixel) |
|
|
2294 | { |
|
|
2295 | case 15: |
|
|
2296 | { |
|
|
2297 | unsigned short *p1, *pf, *p, *pl; |
|
|
2298 | p1 = (unsigned short *) srcImage->data; |
|
|
2299 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2300 | while (p1 < pf) |
|
|
2301 | { |
|
|
2302 | p = p1; |
|
|
2303 | pl = p1 + srcImage->width; |
|
|
2304 | for (; p < pl; p++) |
|
|
2305 | { |
|
|
2306 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2307 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2308 | lookup_b[(*p & 0x001f)]; |
|
|
2309 | } |
|
|
2310 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2311 | } |
|
|
2312 | break; |
|
|
2313 | } |
|
|
2314 | case 16: |
|
|
2315 | { |
|
|
2316 | unsigned short *p1, *pf, *p, *pl; |
|
|
2317 | p1 = (unsigned short *) srcImage->data; |
|
|
2318 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2319 | while (p1 < pf) |
|
|
2320 | { |
|
|
2321 | p = p1; |
|
|
2322 | pl = p1 + srcImage->width; |
|
|
2323 | for (; p < pl; p++) |
|
|
2324 | { |
|
|
2325 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2326 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2327 | lookup_b[(*p & 0x001f)]; |
|
|
2328 | } |
|
|
2329 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2330 | } |
|
|
2331 | break; |
|
|
2332 | } |
|
|
2333 | case 24: |
|
|
2334 | { |
|
|
2335 | unsigned char *p1, *pf, *p, *pl; |
|
|
2336 | p1 = (unsigned char *) srcImage->data; |
|
|
2337 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2338 | while (p1 < pf) |
|
|
2339 | { |
|
|
2340 | p = p1; |
|
|
2341 | pl = p1 + srcImage->width * 3; |
|
|
2342 | for (; p < pl; p += 3) |
|
|
2343 | { |
|
|
2344 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2345 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2346 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2347 | } |
|
|
2348 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2349 | } |
|
|
2350 | break; |
|
|
2351 | } |
|
|
2352 | case 32: |
|
|
2353 | { |
|
|
2354 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2355 | p1 = (RUINT32T *) srcImage->data; |
|
|
2356 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2357 | |
|
|
2358 | while (p1 < pf) |
|
|
2359 | { |
|
|
2360 | p = p1; |
|
|
2361 | pl = p1 + srcImage->width; |
|
|
2362 | for (; p < pl; p++) |
|
|
2363 | { |
|
|
2364 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2365 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2366 | lookup_b[(*p & 0x0000ff)] | |
|
|
2367 | (*p & ~0xffffff); |
|
|
2368 | } |
|
|
2369 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2370 | } |
|
|
2371 | break; |
|
|
2372 | } |
|
|
2373 | } |
|
|
2374 | |
|
|
2375 | free (lookup); |
|
|
2376 | } |
|
|
2377 | #endif |
|
|
2378 | |
|
|
2379 | /* |
|
|
2380 | * Check our parents are still who we think they are. |
|
|
2381 | * Do transparency updates if required |
|
|
2382 | */ |
|
|
2383 | int |
|
|
2384 | rxvt_term::check_our_parents () |
|
|
2385 | { |
|
|
2386 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2387 | unsigned long nitems, bytes_after; |
|
|
2388 | Atom atype; |
|
|
2389 | unsigned char *prop = NULL; |
|
|
2390 | Window root, oldp, *list; |
|
|
2391 | Pixmap rootpixmap = None; |
|
|
2392 | XWindowAttributes wattr, wrootattr; |
|
|
2393 | dDisp; |
|
|
2394 | |
|
|
2395 | pchanged = 0; |
|
|
2396 | |
|
|
2397 | if (!OPTION (Opt_transparent)) |
|
|
2398 | return pchanged; /* Don't try any more */ |
|
|
2399 | |
|
|
2400 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2401 | rootdepth = wrootattr.depth; |
|
|
2402 | |
|
|
2403 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2404 | |
|
|
2405 | if (rootdepth != wattr.depth) |
|
|
2406 | { |
|
|
2407 | if (am_transparent) |
|
|
2408 | { |
|
|
2409 | pchanged = 1; |
|
|
2410 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2411 | am_transparent = am_pixmap_trans = 0; |
|
|
2412 | } |
|
|
2413 | |
|
|
2414 | return pchanged; /* Don't try any more */ |
|
|
2415 | } |
|
|
2416 | |
|
|
2417 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2418 | XSync (disp, False); |
|
|
2419 | |
|
|
2420 | /* |
|
|
2421 | * Make the frame window set by the window manager have |
|
|
2422 | * the root background. Some window managers put multiple nested frame |
|
|
2423 | * windows for each client, so we have to take care about that. |
|
|
2424 | */ |
|
|
2425 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2426 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2427 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2428 | &nitems, &bytes_after, &prop) == Success); |
|
|
2429 | |
|
|
2430 | if (!i || prop == NULL) |
|
|
2431 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2432 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2433 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2434 | &nitems, &bytes_after, &prop) == Success); |
|
|
2435 | |
|
|
2436 | if (!i || prop == NULL |
|
|
2437 | #if TINTING |
|
|
2438 | || !rs[Rs_color + Color_tint] |
|
|
2439 | #endif |
|
|
2440 | ) |
|
|
2441 | have_pixmap = 0; |
|
|
2442 | else |
|
|
2443 | { |
|
|
2444 | have_pixmap = 1; |
|
|
2445 | rootpixmap = *(Pixmap *)prop; |
|
|
2446 | XFree (prop); |
|
|
2447 | } |
|
|
2448 | |
|
|
2449 | if (have_pixmap) |
|
|
2450 | { |
|
|
2451 | /* |
|
|
2452 | * Copy display->root pixmap transparency |
|
|
2453 | */ |
|
|
2454 | int sx, sy, nx, ny; |
|
|
2455 | unsigned int nw, nh; |
|
|
2456 | Window cr; |
|
|
2457 | XImage *image; |
|
|
2458 | GC gc; |
|
|
2459 | XGCValues gcvalue; |
|
|
2460 | |
|
|
2461 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2462 | 0, 0, &sx, &sy, &cr); |
|
|
2463 | nw = (unsigned int)szHint.width; |
|
|
2464 | nh = (unsigned int)szHint.height; |
|
|
2465 | nx = ny = 0; |
|
|
2466 | |
|
|
2467 | if (sx < 0) |
|
|
2468 | { |
|
|
2469 | nw += sx; |
|
|
2470 | nx = -sx; |
|
|
2471 | sx = 0; |
|
|
2472 | } |
|
|
2473 | |
|
|
2474 | if (sy < 0) |
|
|
2475 | { |
|
|
2476 | nh += sy; |
|
|
2477 | ny = -sy; |
|
|
2478 | sy = 0; |
|
|
2479 | } |
|
|
2480 | |
|
|
2481 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2482 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2483 | |
|
|
2484 | XSync (disp, False); |
|
|
2485 | allowedxerror = -1; |
|
|
2486 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2487 | |
|
|
2488 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2489 | /* XXX: may need a delay here? */ |
|
|
2490 | allowedxerror = 0; |
|
|
2491 | |
|
|
2492 | if (image == NULL) |
|
|
2493 | { |
|
|
2494 | if (am_transparent && am_pixmap_trans) |
|
|
2495 | { |
|
|
2496 | pchanged = 1; |
|
|
2497 | if (pixmap != None) |
|
|
2498 | { |
|
|
2499 | XFreePixmap (disp, pixmap); |
|
|
2500 | pixmap = None; |
|
|
2501 | } |
|
|
2502 | } |
|
|
2503 | |
|
|
2504 | am_pixmap_trans = 0; |
|
|
2505 | } |
|
|
2506 | else |
|
|
2507 | { |
|
|
2508 | if (pixmap != None) |
|
|
2509 | XFreePixmap (disp, pixmap); |
|
|
2510 | |
|
|
2511 | #if TINTING |
|
|
2512 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2513 | { |
|
|
2514 | unsigned short rm, gm, bm; |
|
|
2515 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2516 | |
|
|
2517 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2518 | |
|
|
2519 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2520 | } |
|
|
2521 | #endif |
|
|
2522 | |
|
|
2523 | pixmap = XCreatePixmap (disp, vt, |
|
|
2524 | szHint.width, szHint.height, image->depth); |
|
|
2525 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2526 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2527 | nx, ny, image->width, image->height); |
|
|
2528 | XFreeGC (disp, gc); |
|
|
2529 | XDestroyImage (image); |
|
|
2530 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2531 | XClearWindow (disp, parent[0]); |
|
|
2532 | |
|
|
2533 | if (!am_transparent || !am_pixmap_trans) |
|
|
2534 | pchanged = 1; |
|
|
2535 | |
|
|
2536 | am_transparent = am_pixmap_trans = 1; |
|
|
2537 | } |
|
|
2538 | } |
|
|
2539 | |
|
|
2540 | if (am_pixmap_trans) |
|
|
2541 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2542 | else |
|
|
2543 | { |
|
|
2544 | unsigned int n; |
|
|
2545 | /* |
|
|
2546 | * InheritPixmap transparency |
|
|
2547 | */ |
|
|
2548 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2549 | { |
|
|
2550 | oldp = parent[i]; |
|
|
2551 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2552 | &parent[i], &list, &n); |
|
|
2553 | XFree (list); |
|
|
2554 | |
|
|
2555 | if (parent[i] == display->root) |
|
|
2556 | { |
|
|
2557 | if (oldp != None) |
|
|
2558 | pchanged = 1; |
|
|
2559 | |
|
|
2560 | break; |
|
|
2561 | } |
|
|
2562 | |
|
|
2563 | if (oldp != parent[i]) |
|
|
2564 | pchanged = 1; |
|
|
2565 | } |
|
|
2566 | |
|
|
2567 | n = 0; |
|
|
2568 | |
|
|
2569 | if (pchanged) |
|
|
2570 | { |
|
|
2571 | for (; n < (unsigned int)i; n++) |
|
|
2572 | { |
|
|
2573 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2574 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2575 | { |
|
|
2576 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2577 | break; |
|
|
2578 | } |
|
|
2579 | } |
|
|
2580 | } |
|
|
2581 | |
|
|
2582 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2583 | { |
|
|
2584 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2585 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2586 | am_transparent = 0; |
|
|
2587 | /* XXX: also turn off Opt_transparent? */ |
|
|
2588 | } |
|
|
2589 | else |
|
|
2590 | { |
|
|
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++) |
|
|
2597 | { |
|
|
2598 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2599 | XClearWindow (disp, parent[n]); |
|
|
2600 | } |
|
|
2601 | |
|
|
2602 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2603 | am_transparent = 1; |
|
|
2604 | } |
|
|
2605 | |
|
|
2606 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2607 | parent[i] = None; |
|
|
2608 | } |
|
|
2609 | |
|
|
2610 | if (scrollBar.win) |
|
|
2611 | { |
|
|
2612 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2613 | scrollBar.setIdle (); |
|
|
2614 | scrollbar_show (0); |
|
|
2615 | } |
|
|
2616 | |
|
|
2617 | if (am_transparent) |
|
|
2618 | { |
|
|
2619 | want_refresh = want_full_refresh = 1; |
|
|
2620 | if (am_pixmap_trans) |
|
|
2621 | flush (); |
|
|
2622 | } |
|
|
2623 | |
|
|
2624 | return pchanged; |
|
|
2625 | } |
|
|
2626 | #endif |
|
|
2627 | |
2219 | |
2628 | /*}}} */ |
2220 | /*}}} */ |
2629 | |
2221 | |
2630 | bool |
2222 | bool |
2631 | rxvt_term::cmd_parse () |
2223 | rxvt_term::cmd_parse () |
2632 | { |
2224 | { |
2633 | bool flag = false; |
2225 | bool flag = false; |
2634 | unicode_t ch = NOCHAR; |
2226 | wchar_t ch = NOCHAR; |
2635 | unsigned char *seq_begin; // remember start of esc-sequence here |
2227 | char *seq_begin; // remember start of esc-sequence here |
2636 | |
2228 | |
2637 | for (;;) |
2229 | for (;;) |
2638 | { |
2230 | { |
2639 | if (ch == NOCHAR) |
2231 | if (ch == NOCHAR) |
2640 | { |
2232 | { |
2641 | seq_begin = cmdbuf_ptr; |
2233 | seq_begin = cmdbuf_ptr; |
2642 | ch = next_char (); |
2234 | ch = next_char (); |
2643 | } |
|
|
2644 | |
2235 | |
2645 | if (ch == NOCHAR) // TODO: improve |
2236 | if (ch == NOCHAR) |
2646 | break; |
2237 | break; |
|
|
2238 | } |
2647 | |
2239 | |
2648 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2240 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2649 | { |
2241 | { |
2650 | if (!seen_input) |
2242 | if (!seen_input) |
2651 | { |
2243 | { |
… | |
… | |
2660 | if (seen_resize && cmd_pid) |
2252 | if (seen_resize && cmd_pid) |
2661 | kill (-cmd_pid, SIGWINCH); |
2253 | kill (-cmd_pid, SIGWINCH); |
2662 | } |
2254 | } |
2663 | |
2255 | |
2664 | /* Read a text string from the input buffer */ |
2256 | /* Read a text string from the input buffer */ |
2665 | unicode_t buf[UBUFSIZ]; |
2257 | wchar_t buf[UBUFSIZ]; |
2666 | bool refreshnow = false; |
2258 | bool refreshnow = false; |
2667 | int nlines = 0; |
2259 | int nlines = 0; |
2668 | unicode_t *str = buf; |
2260 | wchar_t *str = buf; |
2669 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2261 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2670 | |
2262 | |
2671 | for (;;) |
2263 | for (;;) |
2672 | { |
2264 | { |
2673 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2265 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2674 | break; |
2266 | break; |
… | |
… | |
2680 | if (ch == C0_LF) |
2272 | if (ch == C0_LF) |
2681 | nlines++; |
2273 | nlines++; |
2682 | |
2274 | |
2683 | refresh_count++; |
2275 | refresh_count++; |
2684 | |
2276 | |
2685 | if (!OPTION (Opt_jumpScroll) |
2277 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2686 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2687 | { |
2278 | { |
|
|
2279 | refresh_count = 0; |
|
|
2280 | |
|
|
2281 | if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.) |
|
|
2282 | { |
2688 | refreshnow = true; |
2283 | refreshnow = true; |
2689 | ch = NOCHAR; |
2284 | ch = NOCHAR; |
2690 | break; |
2285 | break; |
|
|
2286 | } |
2691 | } |
2287 | } |
2692 | |
2288 | |
2693 | // scr_add_lines only works for nlines <= nrow - 1. |
2289 | // scr_add_lines only works for nlines <= nrow - 1. |
2694 | if (nlines >= nrow - 1) |
2290 | if (nlines >= nrow - 1) |
2695 | { |
2291 | { |
|
|
2292 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2293 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2696 | scr_add_lines (buf, nlines, str - buf); |
2294 | scr_add_lines (buf, str - buf, nlines); |
|
|
2295 | |
2697 | nlines = 0; |
2296 | nlines = 0; |
2698 | str = buf; |
2297 | str = buf; |
2699 | eol = str + min (ncol, UBUFSIZ); |
2298 | eol = str + min (ncol, UBUFSIZ); |
2700 | } |
2299 | } |
2701 | |
2300 | |
… | |
… | |
2714 | |
2313 | |
2715 | seq_begin = cmdbuf_ptr; |
2314 | seq_begin = cmdbuf_ptr; |
2716 | ch = next_char (); |
2315 | ch = next_char (); |
2717 | } |
2316 | } |
2718 | |
2317 | |
|
|
2318 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2319 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2719 | scr_add_lines (buf, nlines, str - buf); |
2320 | scr_add_lines (buf, str - buf, nlines); |
2720 | |
2321 | |
2721 | /* |
2322 | /* |
2722 | * If there have been a lot of new lines, then update the screen |
2323 | * 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. |
2324 | * What the heck we'll cheat and only refresh less than every page-full. |
2724 | * the number of pages between refreshes is refresh_limit, which |
2325 | * if skipScroll is enabled. |
2725 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2726 | */ |
2326 | */ |
2727 | if (refreshnow) |
2327 | if (refreshnow) |
2728 | { |
2328 | { |
2729 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2730 | refresh_limit++; |
|
|
2731 | else |
|
|
2732 | { |
|
|
2733 | flag = true; |
2329 | flag = true; |
2734 | scr_refresh (refresh_type); |
2330 | scr_refresh (); |
2735 | } |
2331 | want_refresh = 1; |
2736 | } |
2332 | } |
2737 | |
2333 | |
2738 | } |
2334 | } |
2739 | else |
2335 | else |
2740 | { |
2336 | { |
… | |
… | |
2754 | } |
2350 | } |
2755 | |
2351 | |
2756 | return flag; |
2352 | return flag; |
2757 | } |
2353 | } |
2758 | |
2354 | |
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 |
2355 | // read the next character |
2769 | unicode_t |
2356 | wchar_t |
2770 | rxvt_term::next_char () |
2357 | rxvt_term::next_char () NOTHROW |
2771 | { |
2358 | { |
2772 | while (cmdbuf_ptr < cmdbuf_endp) |
2359 | while (cmdbuf_ptr < cmdbuf_endp) |
2773 | { |
2360 | { |
2774 | // assume 7-bit to be ascii ALWAYS |
2361 | // assume 7-bit to be ascii ALWAYS |
2775 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2362 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2776 | return *cmdbuf_ptr++; |
2363 | return *cmdbuf_ptr++; |
2777 | |
2364 | |
2778 | wchar_t wc; |
2365 | wchar_t wc; |
2779 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2366 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2780 | |
2367 | |
2781 | if (len == (size_t)-2) |
2368 | if (len == (size_t)-2) |
2782 | { |
2369 | { |
2783 | // the mbstate stores incomplete sequences. didn't know this :/ |
2370 | // the mbstate stores incomplete sequences. didn't know this :/ |
2784 | cmdbuf_ptr = cmdbuf_endp; |
2371 | cmdbuf_ptr = cmdbuf_endp; |
2785 | break; |
2372 | break; |
2786 | } |
2373 | } |
2787 | |
2374 | |
2788 | if (len == (size_t)-1) |
2375 | if (len == (size_t)-1) |
2789 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2376 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2790 | |
2377 | |
2791 | // assume wchar == unicode |
2378 | // assume wchar == unicode |
2792 | cmdbuf_ptr += len; |
2379 | cmdbuf_ptr += len; |
2793 | return wc & UNICODE_MASK; |
2380 | return wc & UNICODE_MASK; |
2794 | } |
2381 | } |
2795 | |
2382 | |
2796 | return NOCHAR; |
2383 | return NOCHAR; |
2797 | } |
2384 | } |
|
|
2385 | |
|
|
2386 | // read the next octet |
|
|
2387 | uint32_t |
|
|
2388 | rxvt_term::next_octet () NOTHROW |
|
|
2389 | { |
|
|
2390 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2391 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2392 | : NOCHAR; |
|
|
2393 | } |
|
|
2394 | |
|
|
2395 | static class out_of_input out_of_input; |
2798 | |
2396 | |
2799 | /* rxvt_cmd_getc () - Return next input character */ |
2397 | /* rxvt_cmd_getc () - Return next input character */ |
2800 | /* |
2398 | /* |
2801 | * Return the next input character after first passing any keyboard input |
2399 | * Return the next input character after first passing any keyboard input |
2802 | * to the command. |
2400 | * to the command. |
2803 | */ |
2401 | */ |
2804 | unicode_t |
2402 | wchar_t |
2805 | rxvt_term::cmd_getc () |
2403 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2806 | { |
2404 | { |
2807 | unicode_t c = next_char (); |
2405 | wchar_t c = next_char (); |
2808 | |
2406 | |
2809 | if (c == NOCHAR) |
2407 | if (c == NOCHAR) |
2810 | throw out_of_input; |
2408 | throw out_of_input; |
2811 | |
2409 | |
2812 | return c; |
2410 | return c; |
2813 | } |
2411 | } |
2814 | |
2412 | |
2815 | unicode_t |
2413 | uint32_t |
2816 | rxvt_term::cmd_get8 () |
2414 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2817 | { |
2415 | { |
2818 | unicode_t c = next_octet (); |
2416 | uint32_t c = next_octet (); |
2819 | |
2417 | |
2820 | if (c == NOCHAR) |
2418 | if (c == NOCHAR) |
2821 | throw out_of_input; |
2419 | throw out_of_input; |
2822 | |
2420 | |
2823 | return c; |
2421 | return c; |
… | |
… | |
2887 | { |
2485 | { |
2888 | if ((buf[len++] = cmd_getc ()) == 'i') |
2486 | if ((buf[len++] = cmd_getc ()) == 'i') |
2889 | break; /* done = 1 */ |
2487 | break; /* done = 1 */ |
2890 | } |
2488 | } |
2891 | } |
2489 | } |
2892 | |
2490 | |
2893 | for (i = 0; i < len; i++) |
2491 | for (i = 0; i < len; i++) |
2894 | if (putc (buf[i], fd) == EOF) |
2492 | if (putc (buf[i], fd) == EOF) |
2895 | { |
2493 | { |
2896 | done = 1; |
2494 | done = 1; |
2897 | break; |
2495 | break; |
… | |
… | |
2923 | case C0_ESC: |
2521 | case C0_ESC: |
2924 | process_escape_seq (); |
2522 | process_escape_seq (); |
2925 | break; |
2523 | break; |
2926 | case C0_ENQ: /* terminal Status */ |
2524 | case C0_ENQ: /* terminal Status */ |
2927 | if (rs[Rs_answerbackstring]) |
2525 | if (rs[Rs_answerbackstring]) |
2928 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2526 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2929 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2930 | else |
2527 | else |
2931 | tt_write ((unsigned char *)VT100_ANS, |
2528 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2932 | (unsigned int)strlen (VT100_ANS)); |
|
|
2933 | break; |
2529 | break; |
2934 | case C0_BEL: /* bell */ |
2530 | case C0_BEL: /* bell */ |
2935 | scr_bell (); |
2531 | scr_bell (); |
2936 | break; |
2532 | break; |
2937 | case C0_BS: /* backspace */ |
2533 | case C0_BS: /* backspace */ |
… | |
… | |
2961 | process_dcs_seq (); |
2557 | process_dcs_seq (); |
2962 | break; |
2558 | break; |
2963 | case 0x9b: /* CSI */ |
2559 | case 0x9b: /* CSI */ |
2964 | process_csi_seq (); |
2560 | process_csi_seq (); |
2965 | break; |
2561 | break; |
2966 | case 0x9d: /* CSI */ |
2562 | case 0x9d: /* OSC */ |
2967 | process_osc_seq (); |
2563 | process_osc_seq (); |
2968 | break; |
2564 | break; |
2969 | #endif |
2565 | #endif |
2970 | } |
2566 | } |
2971 | } |
2567 | } |
… | |
… | |
3061 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2657 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3062 | break; |
2658 | break; |
3063 | case '+': |
2659 | case '+': |
3064 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2660 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3065 | break; |
2661 | break; |
3066 | #if ENABLE_FRILLS |
2662 | #if !ENABLE_MINIMAL |
3067 | case '6': |
2663 | case '6': |
3068 | scr_backindex (); |
2664 | scr_backindex (); |
3069 | break; |
2665 | break; |
3070 | #endif |
2666 | #endif |
3071 | case '7': |
2667 | case '7': |
3072 | scr_cursor (SAVE); |
2668 | scr_cursor (SAVE); |
3073 | break; |
2669 | break; |
3074 | case '8': |
2670 | case '8': |
3075 | scr_cursor (RESTORE); |
2671 | scr_cursor (RESTORE); |
3076 | break; |
2672 | break; |
3077 | #if ENABLE_FRILLS |
2673 | #if !ENABLE_MINIMAL |
3078 | case '9': |
2674 | case '9': |
3079 | scr_forwardindex (); |
2675 | scr_forwardindex (); |
3080 | break; |
2676 | break; |
3081 | #endif |
2677 | #endif |
3082 | case '=': |
2678 | case '=': |
… | |
… | |
3092 | break; |
2688 | break; |
3093 | |
2689 | |
3094 | /* 8.3.87: NEXT LINE */ |
2690 | /* 8.3.87: NEXT LINE */ |
3095 | case C1_NEL: /* ESC E */ |
2691 | case C1_NEL: /* ESC E */ |
3096 | { |
2692 | { |
3097 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2693 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3098 | scr_add_lines (nlcr, 1, 2); |
2694 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3099 | } |
2695 | } |
3100 | break; |
2696 | break; |
3101 | |
2697 | |
3102 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2698 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3103 | case C1_ESA: /* ESC G */ |
2699 | case C1_ESA: /* ESC G */ |
… | |
… | |
3125 | process_dcs_seq (); |
2721 | process_dcs_seq (); |
3126 | break; |
2722 | break; |
3127 | |
2723 | |
3128 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2724 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3129 | case C1_SCI: /* ESC Z */ |
2725 | case C1_SCI: /* ESC Z */ |
3130 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
2726 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3131 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3132 | break; /* steal obsolete ESC [ c */ |
2727 | break; /* steal obsolete ESC [ c */ |
3133 | |
2728 | |
3134 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2729 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3135 | case C1_CSI: /* ESC [ */ |
2730 | case C1_CSI: /* ESC [ */ |
3136 | process_csi_seq (); |
2731 | process_csi_seq (); |
… | |
… | |
3200 | unicode_t ch, priv, i; |
2795 | unicode_t ch, priv, i; |
3201 | unsigned int nargs, p; |
2796 | unsigned int nargs, p; |
3202 | int n, ndef; |
2797 | int n, ndef; |
3203 | int arg[ESC_ARGS]; |
2798 | int arg[ESC_ARGS]; |
3204 | |
2799 | |
3205 | for (nargs = ESC_ARGS; nargs > 0;) |
2800 | memset (arg, 0, sizeof (arg)); |
3206 | arg[--nargs] = 0; |
2801 | nargs = 0; |
3207 | |
2802 | |
3208 | priv = 0; |
2803 | priv = 0; |
3209 | ch = cmd_getc (); |
2804 | ch = cmd_getc (); |
3210 | if (ch >= '<' && ch <= '?') |
2805 | if (ch >= '<' && ch <= '?') |
3211 | { /* '<' '=' '>' '?' */ |
2806 | { /* '<' '=' '>' '?' */ |
… | |
… | |
3245 | ndef = get_byte_array_bit (csi_defaults, i); |
2840 | ndef = get_byte_array_bit (csi_defaults, i); |
3246 | for (p = 0; p < nargs; p++) |
2841 | for (p = 0; p < nargs; p++) |
3247 | if (arg[p] == -1) |
2842 | if (arg[p] == -1) |
3248 | arg[p] = ndef; |
2843 | arg[p] = ndef; |
3249 | |
2844 | |
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 | /* |
2845 | /* |
3258 | * private mode handling |
2846 | * private mode handling |
3259 | */ |
2847 | */ |
3260 | if (priv) |
2848 | if (priv) |
3261 | { |
2849 | { |
3262 | switch (priv) |
2850 | switch (priv) |
3263 | { |
2851 | { |
3264 | case '>': |
2852 | case '>': |
3265 | if (ch == CSI_DA) /* secondary device attributes */ |
2853 | if (ch == CSI_DA) /* secondary device attributes */ |
3266 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2854 | { |
|
|
2855 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2856 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2857 | // |
|
|
2858 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2859 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
2860 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
2861 | // |
|
|
2862 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
2863 | } |
3267 | break; |
2864 | break; |
3268 | case '?': |
2865 | case '?': |
3269 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2866 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3270 | process_terminal_mode (ch, priv, nargs, arg); |
2867 | process_terminal_mode (ch, priv, nargs, arg); |
3271 | break; |
2868 | break; |
… | |
… | |
3380 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
2977 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3381 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
2978 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3382 | break; |
2979 | break; |
3383 | |
2980 | |
3384 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
2981 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3385 | tt_write ((const unsigned char *)VT100_ANS, |
2982 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3386 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3387 | break; |
2983 | break; |
3388 | |
2984 | |
3389 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
2985 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3390 | process_sgr_mode (nargs, arg); |
2986 | process_sgr_mode (nargs, arg); |
3391 | break; |
2987 | break; |
… | |
… | |
3398 | break; |
2994 | break; |
3399 | case 6: /* CPR requested */ |
2995 | case 6: /* CPR requested */ |
3400 | scr_report_position (); |
2996 | scr_report_position (); |
3401 | break; |
2997 | break; |
3402 | case 7: /* unofficial extension */ |
2998 | case 7: /* unofficial extension */ |
3403 | if (OPTION (Opt_insecure)) |
2999 | if (option (Opt_insecure)) |
3404 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3000 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3405 | break; |
3001 | break; |
3406 | case 8: /* unofficial extension */ |
3002 | case 8: /* unofficial extension */ |
3407 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3003 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3408 | break; |
3004 | break; |
… | |
… | |
3475 | break; |
3071 | break; |
3476 | case CSI_75: |
3072 | case CSI_75: |
3477 | scr_cursor (RESTORE); |
3073 | scr_cursor (RESTORE); |
3478 | break; |
3074 | break; |
3479 | |
3075 | |
3480 | #if ENABLE_FRILLS |
3076 | #if !ENABLE_MINIMAL |
3481 | case CSI_74: |
3077 | case CSI_74: |
3482 | process_window_ops (arg, nargs); |
3078 | process_window_ops (arg, nargs); |
3483 | break; |
3079 | break; |
3484 | #endif |
3080 | #endif |
3485 | |
3081 | |
… | |
… | |
3492 | break; |
3088 | break; |
3493 | } |
3089 | } |
3494 | } |
3090 | } |
3495 | /*}}} */ |
3091 | /*}}} */ |
3496 | |
3092 | |
3497 | #if ENABLE_FRILLS |
3093 | #if !ENABLE_MINIMAL |
3498 | /* ARGSUSED */ |
3094 | /* ARGSUSED */ |
3499 | void |
3095 | void |
3500 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3096 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3501 | { |
3097 | { |
3502 | int x, y; |
3098 | int x, y; |
3503 | XWindowAttributes wattr; |
3099 | XWindowAttributes wattr; |
3504 | Window wdummy; |
3100 | Window wdummy; |
3505 | dDisp; |
3101 | |
|
|
3102 | dLocal (Display *, dpy); |
3506 | |
3103 | |
3507 | if (nargs == 0) |
3104 | if (nargs == 0) |
3508 | return; |
3105 | return; |
3509 | |
3106 | |
3510 | switch (args[0]) |
3107 | switch (args[0]) |
3511 | { |
3108 | { |
3512 | /* |
3109 | /* |
3513 | * commands |
3110 | * commands |
3514 | */ |
3111 | */ |
3515 | case 1: /* deiconify window */ |
3112 | case 1: /* deiconify window */ |
3516 | XMapWindow (disp, parent[0]); |
3113 | XMapWindow (dpy, parent[0]); |
3517 | break; |
3114 | break; |
3518 | case 2: /* iconify window */ |
3115 | case 2: /* iconify window */ |
3519 | XIconifyWindow (disp, parent[0], display->screen); |
3116 | XIconifyWindow (dpy, parent[0], display->screen); |
3520 | break; |
3117 | break; |
3521 | case 3: /* set position (pixels) */ |
3118 | case 3: /* set position (pixels) */ |
3522 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3119 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3523 | break; |
3120 | break; |
3524 | case 4: /* set size (pixels) */ |
3121 | case 4: /* set size (pixels) */ |
3525 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3122 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3526 | break; |
3123 | break; |
3527 | case 5: /* raise window */ |
3124 | case 5: /* raise window */ |
3528 | XRaiseWindow (disp, parent[0]); |
3125 | XRaiseWindow (dpy, parent[0]); |
3529 | break; |
3126 | break; |
3530 | case 6: /* lower window */ |
3127 | case 6: /* lower window */ |
3531 | XLowerWindow (disp, parent[0]); |
3128 | XLowerWindow (dpy, parent[0]); |
3532 | break; |
3129 | break; |
3533 | case 7: /* refresh window */ |
3130 | case 7: /* refresh window */ |
3534 | scr_touch (true); |
3131 | scr_touch (true); |
3535 | break; |
3132 | break; |
3536 | case 8: /* set size (chars) */ |
3133 | case 8: /* set size (chars) */ |
… | |
… | |
3543 | if (args[0] >= 24) /* set height (chars) */ |
3140 | if (args[0] >= 24) /* set height (chars) */ |
3544 | set_widthheight ((unsigned int)width, |
3141 | set_widthheight ((unsigned int)width, |
3545 | (unsigned int) (args[1] * fheight)); |
3142 | (unsigned int) (args[1] * fheight)); |
3546 | break; |
3143 | break; |
3547 | |
3144 | |
3548 | |
|
|
3549 | /* |
3145 | /* |
3550 | * reports - some output format copied from XTerm |
3146 | * reports - some output format copied from XTerm |
3551 | */ |
3147 | */ |
3552 | case 11: /* report window state */ |
3148 | case 11: /* report window state */ |
3553 | XGetWindowAttributes (disp, parent[0], &wattr); |
3149 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3554 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3150 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3555 | break; |
3151 | break; |
3556 | case 13: /* report window position */ |
3152 | case 13: /* report window position */ |
3557 | XGetWindowAttributes (disp, parent[0], &wattr); |
3153 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3558 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3154 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3559 | -wattr.border_width, -wattr.border_width, |
3155 | -wattr.border_width, -wattr.border_width, |
3560 | &x, &y, &wdummy); |
3156 | &x, &y, &wdummy); |
3561 | tt_printf ("\033[3;%d;%dt", x, y); |
3157 | tt_printf ("\033[3;%d;%dt", x, y); |
3562 | break; |
3158 | break; |
3563 | case 14: /* report window size (pixels) */ |
3159 | case 14: /* report window size (pixels) */ |
3564 | XGetWindowAttributes (disp, parent[0], &wattr); |
3160 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3565 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3161 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3566 | break; |
3162 | break; |
3567 | case 18: /* report text area size (chars) */ |
3163 | case 18: /* report text area size (chars) */ |
3568 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3164 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3569 | break; |
3165 | break; |
… | |
… | |
3571 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3167 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3572 | break; |
3168 | break; |
3573 | case 20: /* report icon label */ |
3169 | case 20: /* report icon label */ |
3574 | { |
3170 | { |
3575 | char *s; |
3171 | char *s; |
3576 | XGetIconName (disp, parent[0], &s); |
3172 | XGetIconName (dpy, parent[0], &s); |
3577 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3173 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3578 | XFree (s); |
3174 | XFree (s); |
3579 | } |
3175 | } |
3580 | break; |
3176 | break; |
3581 | case 21: /* report window title */ |
3177 | case 21: /* report window title */ |
3582 | { |
3178 | { |
3583 | char *s; |
3179 | char *s; |
3584 | XFetchName (disp, parent[0], &s); |
3180 | XFetchName (dpy, parent[0], &s); |
3585 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3181 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3586 | XFree (s); |
3182 | XFree (s); |
3587 | } |
3183 | } |
3588 | break; |
3184 | break; |
3589 | } |
3185 | } |
3590 | } |
3186 | } |
… | |
… | |
3593 | /*----------------------------------------------------------------------*/ |
3189 | /*----------------------------------------------------------------------*/ |
3594 | /* |
3190 | /* |
3595 | * get input up until STRING TERMINATOR (or BEL) |
3191 | * get input up until STRING TERMINATOR (or BEL) |
3596 | * ends_how is terminator used. returned input must be free()'d |
3192 | * ends_how is terminator used. returned input must be free()'d |
3597 | */ |
3193 | */ |
3598 | unsigned char * |
3194 | char * |
3599 | rxvt_term::get_to_st (unicode_t &ends_how) |
3195 | rxvt_term::get_to_st (unicode_t &ends_how) |
3600 | { |
3196 | { |
3601 | unicode_t ch; |
3197 | unicode_t ch; |
3602 | bool seen_esc = false; |
3198 | bool seen_esc = false; |
3603 | unsigned int n = 0; |
3199 | unsigned int n = 0; |
… | |
… | |
3617 | seen_esc = true; |
3213 | seen_esc = true; |
3618 | continue; |
3214 | continue; |
3619 | } |
3215 | } |
3620 | else if (ch == C0_BEL || ch == CHAR_ST) |
3216 | else if (ch == C0_BEL || ch == CHAR_ST) |
3621 | break; |
3217 | break; |
|
|
3218 | else if (ch == C0_SYN) |
|
|
3219 | ch = cmd_get8 (); |
3622 | else if (ch < 0x20) |
3220 | else if (ch < 0x20) |
3623 | return NULL; /* other control character - exit */ |
3221 | return NULL; /* other control character - exit */ |
3624 | |
3222 | |
3625 | seen_esc = false; |
3223 | seen_esc = false; |
3626 | |
3224 | |
3627 | if (n >= STRING_MAX - 1) |
3225 | if (n >= STRING_MAX - 1) |
3628 | // stop at some sane length |
3226 | // stop at some sane length |
3629 | return NULL; |
3227 | return NULL; |
3630 | |
3228 | |
3631 | if (ch == C0_SYN) |
|
|
3632 | string[n++] = cmd_get8 (); |
|
|
3633 | else |
|
|
3634 | string[n++] = ch; |
3229 | string[n++] = ch; |
3635 | } |
3230 | } |
3636 | |
3231 | |
3637 | string[n++] = '\0'; |
3232 | string[n++] = '\0'; |
3638 | |
3233 | |
3639 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3234 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3640 | |
3235 | |
3641 | return (unsigned char *)rxvt_wcstombs (string); |
3236 | return rxvt_wcstombs (string); |
3642 | } |
3237 | } |
3643 | |
3238 | |
3644 | /*----------------------------------------------------------------------*/ |
3239 | /*----------------------------------------------------------------------*/ |
3645 | /* |
3240 | /* |
3646 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3241 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3647 | */ |
3242 | */ |
3648 | void |
3243 | void |
3649 | rxvt_term::process_dcs_seq () |
3244 | rxvt_term::process_dcs_seq () |
3650 | { |
3245 | { |
3651 | unsigned char *s; |
3246 | char *s; |
3652 | unicode_t eh; |
3247 | unicode_t eh; |
3653 | |
3248 | |
3654 | /* |
3249 | /* |
3655 | * Not handled yet |
3250 | * Not handled yet |
3656 | */ |
3251 | */ |
… | |
… | |
3675 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3270 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3676 | arg = arg * 10 + (ch - '0'); |
3271 | arg = arg * 10 + (ch - '0'); |
3677 | |
3272 | |
3678 | if (ch == ';') |
3273 | if (ch == ';') |
3679 | { |
3274 | { |
3680 | unsigned char *s = get_to_st (eh); |
3275 | char *s = get_to_st (eh); |
3681 | |
3276 | |
3682 | if (s) |
3277 | if (s) |
3683 | { |
3278 | { |
3684 | process_xterm_seq (arg, (char *)s, eh); |
3279 | process_xterm_seq (arg, s, eh); |
3685 | free (s); |
3280 | free (s); |
3686 | } |
3281 | } |
3687 | } |
3282 | } |
3688 | } |
3283 | } |
3689 | |
3284 | |
3690 | void |
3285 | void |
3691 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3286 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3692 | { |
3287 | { |
3693 | if (str[0] == '?' && !str[1]) |
3288 | if (str[0] == '?' && !str[1]) |
3694 | { |
3289 | { |
3695 | unsigned short r, g, b; |
3290 | rgba c; |
3696 | pix_colors_focused[color].get (display, r, g, b); |
3291 | pix_colors_focused[color].get (c); |
|
|
3292 | |
|
|
3293 | #if XFT |
|
|
3294 | if (c.a != rgba::MAX_CC) |
|
|
3295 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3296 | else |
|
|
3297 | #endif |
3697 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3298 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3698 | } |
3299 | } |
3699 | else |
3300 | else |
3700 | set_window_color (color, str); |
3301 | set_window_color (color, str); |
3701 | } |
3302 | } |
3702 | |
3303 | |
3703 | /* |
3304 | /* |
3704 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3305 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3705 | */ |
3306 | */ |
3706 | void |
3307 | void |
3707 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3308 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3708 | { |
3309 | { |
3709 | int changed = 0; |
|
|
3710 | int color; |
3310 | int color; |
3711 | char *buf, *name; |
3311 | char *buf, *name; |
3712 | bool query = str[0] == '?' && !str[1]; |
3312 | bool query = str[0] == '?' && !str[1]; |
3713 | int saveop = op; |
3313 | int saveop = op; |
3714 | dDisp; |
3314 | |
|
|
3315 | dLocal (Display *, dpy); |
3715 | |
3316 | |
3716 | assert (str != NULL); |
3317 | assert (str != NULL); |
|
|
3318 | |
|
|
3319 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3320 | return; |
|
|
3321 | |
3717 | switch (op) |
3322 | switch (op) |
3718 | { |
3323 | { |
3719 | case XTerm_name: |
3324 | case XTerm_name: |
3720 | set_title (str); |
3325 | set_title (str); |
3721 | /* FALLTHROUGH */ |
3326 | /* FALLTHROUGH */ |
… | |
… | |
3735 | unsigned long bytes_after; |
3340 | unsigned long bytes_after; |
3736 | unsigned char *value = 0; |
3341 | unsigned char *value = 0; |
3737 | const char *str = ""; |
3342 | const char *str = ""; |
3738 | |
3343 | |
3739 | if (prop |
3344 | if (prop |
3740 | && XGetWindowProperty (disp, parent[0], |
3345 | && XGetWindowProperty (dpy, parent[0], |
3741 | prop, 0, 1<<16, 0, AnyPropertyType, |
3346 | prop, 0, 1<<16, 0, AnyPropertyType, |
3742 | &actual_type, &actual_format, |
3347 | &actual_type, &actual_format, |
3743 | &nitems, &bytes_after, &value) == Success |
3348 | &nitems, &bytes_after, &value) == Success |
3744 | && actual_type != None |
3349 | && actual_type != None |
3745 | && actual_format == 8) |
3350 | && actual_format == 8) |
3746 | str = (const char *)(value); |
3351 | str = (const char *)(value); |
3747 | |
3352 | |
3748 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3353 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3749 | |
3354 | |
3750 | XFree (value); |
3355 | XFree (value); |
3751 | } |
3356 | } |
3752 | else |
3357 | else |
3753 | { |
3358 | { |
… | |
… | |
3757 | { |
3362 | { |
3758 | *eq = 0; |
3363 | *eq = 0; |
3759 | set_utf8_property (display->atom (str), eq + 1); |
3364 | set_utf8_property (display->atom (str), eq + 1); |
3760 | } |
3365 | } |
3761 | else |
3366 | else |
3762 | XDeleteProperty (disp, parent[0], |
3367 | XDeleteProperty (dpy, parent[0], |
3763 | display->atom (str)); |
3368 | display->atom (str)); |
3764 | } |
3369 | } |
3765 | break; |
3370 | break; |
3766 | |
3371 | |
3767 | case XTerm_Color: |
3372 | case XTerm_Color: |
… | |
… | |
3769 | { |
3374 | { |
3770 | if ((name = strchr (buf, ';')) == NULL) |
3375 | if ((name = strchr (buf, ';')) == NULL) |
3771 | break; |
3376 | break; |
3772 | |
3377 | |
3773 | *name++ = '\0'; |
3378 | *name++ = '\0'; |
3774 | color = atoi (buf); |
3379 | color = atoi (buf) + minCOLOR; |
3775 | |
3380 | |
3776 | if (color < 0 || color >= TOTAL_COLORS) |
3381 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3777 | break; |
3382 | break; |
3778 | |
3383 | |
3779 | if ((buf = strchr (name, ';')) != NULL) |
3384 | if ((buf = strchr (name, ';')) != NULL) |
3780 | *buf++ = '\0'; |
3385 | *buf++ = '\0'; |
3781 | |
3386 | |
3782 | if (name[0] == '?' && !name[1]) |
3387 | 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 | } |
3388 | } |
3791 | break; |
3389 | break; |
3792 | case XTerm_Color00: |
3390 | case XTerm_Color00: |
3793 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3391 | process_color_seq (op, Color_fg, str, resp); |
3794 | break; |
3392 | break; |
3795 | case XTerm_Color01: |
3393 | case XTerm_Color01: |
3796 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3394 | process_color_seq (op, Color_bg, str, resp); |
3797 | break; |
3395 | break; |
3798 | #ifndef NO_CURSORCOLOR |
3396 | #ifndef NO_CURSORCOLOR |
3799 | case XTerm_Color_cursor: |
3397 | case XTerm_Color_cursor: |
3800 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3398 | process_color_seq (op, Color_cursor, str, resp); |
3801 | break; |
3399 | break; |
3802 | #endif |
3400 | #endif |
3803 | case XTerm_Color_pointer_fg: |
3401 | case XTerm_Color_pointer_fg: |
3804 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3402 | process_color_seq (op, Color_pointer_fg, str, resp); |
3805 | break; |
3403 | break; |
3806 | case XTerm_Color_pointer_bg: |
3404 | case XTerm_Color_pointer_bg: |
3807 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3405 | process_color_seq (op, Color_pointer_bg, str, resp); |
3808 | break; |
3406 | break; |
3809 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3407 | #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: |
3408 | case XTerm_Color_RV: |
3817 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3409 | process_color_seq (op, Color_RV, str, resp); |
|
|
3410 | break; |
|
|
3411 | case Rxvt_Color_BD: |
|
|
3412 | case URxvt_Color_BD: |
|
|
3413 | process_color_seq (op, Color_BD, str, resp); |
|
|
3414 | break; |
|
|
3415 | case Rxvt_Color_UL: |
|
|
3416 | case URxvt_Color_UL: |
|
|
3417 | process_color_seq (op, Color_UL, str, resp); |
3818 | break; |
3418 | break; |
3819 | case URxvt_Color_IT: |
3419 | case URxvt_Color_IT: |
3820 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3420 | process_color_seq (op, Color_IT, str, resp); |
3821 | break; |
3421 | break; |
3822 | #endif |
3422 | #endif |
3823 | #if TRANSPARENT && TINTING |
3423 | #if ENABLE_TRANSPARENCY |
3824 | case URxvt_Color_tint: |
3424 | case URxvt_Color_tint: |
3825 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3425 | process_color_seq (op, Color_tint, str, resp); |
3826 | check_our_parents (); |
3426 | { |
3827 | if (am_transparent) |
3427 | bool changed = false; |
3828 | want_full_refresh = want_refresh = 1; |
3428 | if (ISSET_PIXCOLOR (Color_tint)) |
3829 | break; |
3429 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
3830 | #endif |
3430 | else |
|
|
3431 | changed = bgPixmap.unset_tint (); |
|
|
3432 | if (changed) |
|
|
3433 | bgPixmap.render (); |
|
|
3434 | } |
3831 | |
3435 | |
|
|
3436 | break; |
|
|
3437 | #endif |
|
|
3438 | |
|
|
3439 | #if XPM_BACKGROUND |
3832 | case XTerm_Pixmap: |
3440 | case Rxvt_Pixmap: |
3833 | if (*str != ';') |
3441 | if (!strcmp (str, "?")) |
3834 | { |
3442 | { |
3835 | #if XPM_BACKGROUND |
3443 | char str[256]; |
3836 | scale_pixmap (""); /* reset to default scaling */ |
3444 | |
3837 | set_bgPixmap (str); /* change pixmap */ |
3445 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3838 | #endif |
3446 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3839 | scr_touch (true); |
3447 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3448 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3840 | } |
3449 | } |
3841 | while ((str = strchr (str, ';')) != NULL) |
3450 | else |
3842 | { |
3451 | { |
|
|
3452 | int changed = 0; |
|
|
3453 | |
|
|
3454 | if (*str != ';') |
|
|
3455 | { |
|
|
3456 | /* reset to default scaling :*/ |
|
|
3457 | bgPixmap.unset_geometry (); |
|
|
3458 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3459 | changed++; |
|
|
3460 | str = strchr (str, ';'); |
|
|
3461 | if (str == NULL) |
|
|
3462 | bgPixmap.set_defaultGeometry (); |
|
|
3463 | } |
|
|
3464 | while (str) |
|
|
3465 | { |
3843 | str++; |
3466 | str++; |
3844 | #if XPM_BACKGROUND |
3467 | if (bgPixmap.set_geometry (str)) |
3845 | changed += scale_pixmap (str); |
3468 | changed++; |
3846 | #endif |
3469 | str = strchr (str, ';'); |
|
|
3470 | } |
|
|
3471 | if (changed) |
|
|
3472 | { |
|
|
3473 | bgPixmap.render (); |
|
|
3474 | scr_touch (true); |
|
|
3475 | } |
3847 | } |
3476 | } |
3848 | |
|
|
3849 | if (changed) |
|
|
3850 | { |
|
|
3851 | #ifdef XPM_BACKGROUND |
|
|
3852 | resize_pixmap (); |
|
|
3853 | #endif |
|
|
3854 | scr_touch (true); |
|
|
3855 | } |
|
|
3856 | break; |
3477 | break; |
|
|
3478 | #endif |
3857 | |
3479 | |
3858 | case XTerm_restoreFG: |
3480 | case Rxvt_restoreFG: |
3859 | set_window_color (Color_fg, str); |
3481 | set_window_color (Color_fg, str); |
3860 | break; |
3482 | break; |
3861 | case XTerm_restoreBG: |
3483 | case Rxvt_restoreBG: |
3862 | set_window_color (Color_bg, str); |
3484 | set_window_color (Color_bg, str); |
3863 | break; |
3485 | break; |
3864 | |
3486 | |
3865 | case XTerm_logfile: |
3487 | case XTerm_logfile: |
3866 | // TODO, when secure mode? |
3488 | // TODO, when secure mode? |
3867 | break; |
3489 | break; |
3868 | |
3490 | |
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 |
3491 | #if 0 |
3876 | case XTerm_dumpscreen: /* no error notices */ |
3492 | case Rxvt_dumpscreen: /* no error notices */ |
3877 | { |
3493 | { |
3878 | int fd; |
3494 | int fd; |
3879 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3495 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3880 | { |
3496 | { |
3881 | scr_dump (fd); |
3497 | scr_dump (fd); |
… | |
… | |
3892 | case URxvt_italicFont: |
3508 | case URxvt_italicFont: |
3893 | case URxvt_boldItalicFont: |
3509 | case URxvt_boldItalicFont: |
3894 | #endif |
3510 | #endif |
3895 | if (query) |
3511 | if (query) |
3896 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3512 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3897 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3513 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3898 | ? fontset[op - URxvt_font]->fontdesc : "", |
3514 | ? fontset[op - URxvt_font]->fontdesc : "", |
3899 | resp); |
3515 | resp); |
3900 | else |
3516 | else |
3901 | { |
3517 | { |
3902 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3518 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3905 | allocated.push_back ((void *)res); |
3521 | allocated.push_back ((void *)res); |
3906 | set_fonts (); |
3522 | set_fonts (); |
3907 | } |
3523 | } |
3908 | break; |
3524 | break; |
3909 | |
3525 | |
3910 | #if ENABLE_FRILLS |
3526 | case URxvt_version: |
|
|
3527 | if (query) |
|
|
3528 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3529 | op, |
|
|
3530 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3531 | resp); |
|
|
3532 | break; |
|
|
3533 | |
|
|
3534 | #if !ENABLE_MINIMAL |
3911 | case URxvt_locale: |
3535 | case URxvt_locale: |
3912 | if (query) |
3536 | if (query) |
3913 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3537 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
3914 | else |
3538 | else |
3915 | { |
3539 | { |
3916 | set_locale (str); |
3540 | set_locale (str); |
3917 | pty.set_utf8_mode (enc_utf8); |
3541 | pty->set_utf8_mode (enc_utf8); |
3918 | init_xlocale (); |
3542 | init_xlocale (); |
3919 | } |
3543 | } |
3920 | break; |
3544 | break; |
3921 | |
3545 | |
3922 | case URxvt_view_up: |
3546 | case URxvt_view_up: |
3923 | case URxvt_view_down: |
3547 | case URxvt_view_down: |
|
|
3548 | { |
3924 | int lines = atoi (str); |
3549 | int lines = atoi (str); |
3925 | |
3550 | |
3926 | if (lines) |
3551 | if (lines) |
3927 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3552 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3928 | else |
3553 | else |
3929 | { |
|
|
3930 | scr_erase_savelines (); |
3554 | scr_erase_savelines (); |
3931 | } |
3555 | } |
3932 | |
3556 | |
|
|
3557 | break; |
|
|
3558 | #endif |
|
|
3559 | |
|
|
3560 | #if ENABLE_PERL |
|
|
3561 | case URxvt_perl: |
|
|
3562 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
|
|
3563 | ; // no responses yet |
3933 | break; |
3564 | break; |
3934 | #endif |
3565 | #endif |
3935 | } |
3566 | } |
3936 | } |
3567 | } |
3937 | /*----------------------------------------------------------------------*/ |
3568 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3968 | return state; |
3599 | return state; |
3969 | } |
3600 | } |
3970 | |
3601 | |
3971 | /* we're not using priv _yet_ */ |
3602 | /* we're not using priv _yet_ */ |
3972 | void |
3603 | void |
3973 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3604 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3974 | { |
3605 | { |
3975 | unsigned int i, j; |
3606 | unsigned int i, j; |
3976 | int state; |
3607 | int state; |
3977 | |
3608 | |
3978 | static const struct |
3609 | static const struct |
3979 | { |
3610 | { |
3980 | const int argval; |
3611 | const int argval; |
3981 | const unsigned long bit; |
3612 | const unsigned long bit; |
3982 | } |
|
|
3983 | |
|
|
3984 | argtopriv[] = { |
3613 | } argtopriv[] = { |
3985 | { 1, PrivMode_aplCUR }, |
3614 | { 1, PrivMode_aplCUR }, |
3986 | { 2, PrivMode_vt52 }, |
3615 | { 2, PrivMode_vt52 }, |
3987 | { 3, PrivMode_132 }, |
3616 | { 3, PrivMode_132 }, |
3988 | { 4, PrivMode_smoothScroll }, |
3617 | { 4, PrivMode_smoothScroll }, |
3989 | { 5, PrivMode_rVideo }, |
3618 | { 5, PrivMode_rVideo }, |
3990 | { 6, PrivMode_relOrigin }, |
3619 | { 6, PrivMode_relOrigin }, |
3991 | { 7, PrivMode_Autowrap }, |
3620 | { 7, PrivMode_Autowrap }, |
3992 | // 8, bi-directional support mode |
3621 | // 8, bi-directional support mode |
3993 | { 9, PrivMode_MouseX10 }, |
3622 | { 9, PrivMode_MouseX10 }, |
3994 | #ifdef menuBar_esc |
|
|
3995 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3996 | #endif |
|
|
3997 | // 18, 19 printing-related |
3623 | // 18, 19 printing-related |
3998 | { 25, PrivMode_VisibleCursor }, |
3624 | { 25, PrivMode_VisibleCursor }, |
3999 | #ifdef scrollBar_esc |
3625 | #ifdef scrollBar_esc |
4000 | { scrollBar_esc, PrivMode_scrollBar }, |
3626 | { scrollBar_esc, PrivMode_scrollBar }, |
4001 | #endif |
3627 | #endif |
… | |
… | |
4048 | /* extra handling for values with state unkept */ |
3674 | /* extra handling for values with state unkept */ |
4049 | switch (arg[i]) |
3675 | switch (arg[i]) |
4050 | { |
3676 | { |
4051 | #if ENABLE_STYLES |
3677 | #if ENABLE_STYLES |
4052 | case 1021: |
3678 | case 1021: |
4053 | if (mode) |
3679 | set_option (Opt_intensityStyles, mode); |
4054 | SET_OPTION (Opt_intensityStyles); |
|
|
4055 | else |
|
|
4056 | CLR_OPTION (Opt_intensityStyles); |
|
|
4057 | |
3680 | |
4058 | want_refresh = 1; |
3681 | scr_touch (true); |
4059 | want_full_refresh = 1; |
|
|
4060 | break; |
3682 | break; |
4061 | #endif |
3683 | #endif |
4062 | case 1048: /* alternative cursor save */ |
3684 | case 1048: /* alternative cursor save */ |
4063 | case 1049: |
3685 | case 1049: |
4064 | if (OPTION (Opt_secondaryScreen)) |
3686 | if (option (Opt_secondaryScreen)) |
4065 | if (mode == 0) |
3687 | if (mode == 0) |
4066 | scr_cursor (RESTORE); |
3688 | scr_cursor (RESTORE); |
4067 | else if (mode == 1) |
3689 | else if (mode == 1) |
4068 | scr_cursor (SAVE); |
3690 | scr_cursor (SAVE); |
4069 | break; |
3691 | break; |
… | |
… | |
4084 | case 3: /* 80/132 */ |
3706 | case 3: /* 80/132 */ |
4085 | if (priv_modes & PrivMode_132OK) |
3707 | if (priv_modes & PrivMode_132OK) |
4086 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3708 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4087 | break; |
3709 | break; |
4088 | case 4: /* smooth scrolling */ |
3710 | case 4: /* smooth scrolling */ |
4089 | if (!state) |
3711 | set_option (Opt_jumpScroll, !state); |
4090 | SET_OPTION (Opt_jumpScroll); |
|
|
4091 | else |
|
|
4092 | CLR_OPTION (Opt_jumpScroll); |
|
|
4093 | break; |
3712 | break; |
4094 | case 5: /* reverse video */ |
3713 | case 5: /* reverse video */ |
4095 | scr_rvideo_mode (state); |
3714 | scr_rvideo_mode (state); |
4096 | break; |
3715 | break; |
4097 | case 6: /* relative/absolute origins */ |
3716 | case 6: /* relative/absolute origins */ |
… | |
… | |
4103 | /* case 8: - auto repeat, can't do on a per window basis */ |
3722 | /* case 8: - auto repeat, can't do on a per window basis */ |
4104 | case 9: /* X10 mouse reporting */ |
3723 | case 9: /* X10 mouse reporting */ |
4105 | if (state) /* orthogonal */ |
3724 | if (state) /* orthogonal */ |
4106 | priv_modes &= ~PrivMode_MouseX11; |
3725 | priv_modes &= ~PrivMode_MouseX11; |
4107 | break; |
3726 | break; |
4108 | #ifdef menuBar_esc |
|
|
4109 | case menuBar_esc: |
|
|
4110 | #ifdef MENUBAR |
|
|
4111 | map_menuBar (state); |
|
|
4112 | #endif |
|
|
4113 | break; |
|
|
4114 | #endif |
|
|
4115 | #ifdef scrollBar_esc |
3727 | #ifdef scrollBar_esc |
4116 | case scrollBar_esc: |
3728 | case scrollBar_esc: |
4117 | if (scrollbar_mapping (state)) |
3729 | if (scrollbar_mapping (state)) |
4118 | { |
3730 | { |
4119 | resize_all_windows (0, 0, 0); |
3731 | resize_all_windows (0, 0, 0); |
… | |
… | |
4138 | #if 0 |
3750 | #if 0 |
4139 | case 1001: |
3751 | case 1001: |
4140 | break; /* X11 mouse highlighting */ |
3752 | break; /* X11 mouse highlighting */ |
4141 | #endif |
3753 | #endif |
4142 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3754 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4143 | if (!state) |
3755 | set_option (Opt_scrollTtyOutput, !state); |
4144 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4145 | else |
|
|
4146 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4147 | break; |
3756 | break; |
4148 | case 1011: /* scroll to bottom on key press */ |
3757 | case 1011: /* scroll to bottom on key press */ |
4149 | if (state) |
3758 | set_option (Opt_scrollTtyKeypress, state); |
4150 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4151 | else |
|
|
4152 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4153 | break; |
3759 | break; |
4154 | case 1047: /* secondary screen w/ clearing last */ |
3760 | case 1047: /* secondary screen w/ clearing last */ |
4155 | if (OPTION (Opt_secondaryScreen)) |
3761 | if (option (Opt_secondaryScreen)) |
4156 | if (current_screen != PRIMARY) |
3762 | if (current_screen != PRIMARY) |
4157 | scr_erase_screen (2); |
3763 | scr_erase_screen (2); |
4158 | scr_change_screen (state); |
3764 | scr_change_screen (state); |
4159 | break; |
3765 | break; |
4160 | case 1049: /* secondary screen w/ clearing first */ |
3766 | case 1049: /* secondary screen w/ clearing first */ |
4161 | scr_change_screen (state); |
3767 | scr_change_screen (state); |
4162 | if (OPTION (Opt_secondaryScreen)) |
3768 | if (option (Opt_secondaryScreen)) |
4163 | if (current_screen != PRIMARY) |
3769 | if (current_screen != PRIMARY) |
4164 | scr_erase_screen (2); |
3770 | scr_erase_screen (2); |
4165 | break; |
3771 | break; |
4166 | default: |
3772 | default: |
4167 | break; |
3773 | break; |
… | |
… | |
4295 | scr_color (Color_bg, Color_bg); |
3901 | scr_color (Color_bg, Color_bg); |
4296 | break; |
3902 | break; |
4297 | |
3903 | |
4298 | //case 50: // not variable spacing |
3904 | //case 50: // not variable spacing |
4299 | |
3905 | |
4300 | #ifndef NO_BRIGHTCOLOR |
3906 | #if !ENABLE_MINIMAL |
4301 | case 90: |
3907 | case 90: |
4302 | case 91: /* set bright fg color */ |
3908 | case 91: /* set bright fg color */ |
4303 | case 92: |
3909 | case 92: |
4304 | case 93: |
3910 | case 93: |
4305 | case 94: |
3911 | case 94: |
… | |
… | |
4350 | */ |
3956 | */ |
4351 | void |
3957 | void |
4352 | rxvt_term::tt_printf (const char *fmt,...) |
3958 | rxvt_term::tt_printf (const char *fmt,...) |
4353 | { |
3959 | { |
4354 | va_list arg_ptr; |
3960 | va_list arg_ptr; |
4355 | unsigned char buf[256]; |
3961 | char buf[256]; |
4356 | |
3962 | |
4357 | va_start (arg_ptr, fmt); |
3963 | va_start (arg_ptr, fmt); |
4358 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
3964 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4359 | va_end (arg_ptr); |
3965 | va_end (arg_ptr); |
4360 | tt_write (buf, strlen (buf)); |
3966 | tt_write (buf, strlen (buf)); |
… | |
… | |
4365 | * or generated by us in response to a query ESC sequence. |
3971 | * or generated by us in response to a query ESC sequence. |
4366 | */ |
3972 | */ |
4367 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
3973 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4368 | |
3974 | |
4369 | void |
3975 | void |
4370 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
3976 | rxvt_term::tt_write (const char *data, unsigned int len) |
4371 | { |
3977 | { |
|
|
3978 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
3979 | return; |
|
|
3980 | |
|
|
3981 | if (pty->pty < 0) |
|
|
3982 | return; |
|
|
3983 | |
4372 | if (v_buflen == 0) |
3984 | if (v_buflen == 0) |
4373 | { |
3985 | { |
4374 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
3986 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4375 | |
3987 | |
4376 | if ((unsigned int)written == len) |
3988 | if ((unsigned int)written == len) |
4377 | return; |
3989 | return; |
4378 | |
3990 | |
4379 | data += written; |
3991 | data += written; |
4380 | len -= written; |
3992 | len -= written; |
4381 | } |
3993 | } |
4382 | |
3994 | |
4383 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
3995 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4384 | |
3996 | |
4385 | memcpy (v_buffer + v_buflen, data, len); |
3997 | memcpy (v_buffer + v_buflen, data, len); |
4386 | v_buflen += len; |
3998 | v_buflen += len; |
4387 | |
3999 | |
4388 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4000 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4389 | } |
4001 | } |
4390 | |
4002 | |
4391 | void rxvt_term::pty_write () |
4003 | void rxvt_term::pty_write () |
4392 | { |
4004 | { |
4393 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4005 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4394 | |
4006 | |
4395 | if (written > 0) |
4007 | if (written > 0) |
4396 | { |
4008 | { |
4397 | v_buflen -= written; |
4009 | v_buflen -= written; |
4398 | |
4010 | |