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