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