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