… | |
… | |
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-2004 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2005 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. |
… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #ifdef KEYSYM_RESOURCE |
|
|
54 | # include "keyboard.h" |
|
|
55 | #endif |
|
|
56 | |
|
|
57 | #include <csignal> |
54 | |
58 | |
55 | /*----------------------------------------------------------------------*/ |
59 | /*----------------------------------------------------------------------*/ |
56 | |
60 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
62 | |
… | |
… | |
113 | XK_Escape, 0x238b, |
117 | XK_Escape, 0x238b, |
114 | XK_Undo, 0x238c, |
118 | XK_Undo, 0x238c, |
115 | XK_Print, 0x2399, |
119 | XK_Print, 0x2399, |
116 | |
120 | |
117 | XK_space, 0x2423, |
121 | XK_space, 0x2423, |
|
|
122 | |
|
|
123 | #ifdef XK_KP_Begin |
|
|
124 | XK_KP_Prior, 0x21de, |
|
|
125 | XK_KP_Next, 0x21df, |
|
|
126 | XK_KP_Begin, 0x2320, |
|
|
127 | XK_KP_Insert, 0x2380, |
|
|
128 | XK_KP_Delete, 0x2326, |
118 | XK_KP_Space, 0x2422, |
129 | XK_KP_Space, 0x2422, |
|
|
130 | #endif |
119 | 0, |
131 | 0, |
120 | }; |
132 | }; |
121 | |
133 | |
122 | void |
134 | void |
123 | rxvt_term::iso14755_54 (int x, int y) |
135 | rxvt_term::iso14755_54 (int x, int y) |
… | |
… | |
133 | { |
145 | { |
134 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
146 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
135 | |
147 | |
136 | if (t != NOCHAR || !x) |
148 | if (t != NOCHAR || !x) |
137 | { |
149 | { |
138 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]); |
150 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x], |
|
|
151 | screen.rend[y + TermWin.saveLines - TermWin.view_start][x]); |
139 | iso14755buf = ISO_14755_54; |
152 | iso14755buf = ISO_14755_54; |
140 | break; |
153 | break; |
141 | } |
154 | } |
142 | |
155 | |
143 | x--; |
156 | x--; |
… | |
… | |
146 | } |
159 | } |
147 | #endif |
160 | #endif |
148 | |
161 | |
149 | #if ENABLE_OVERLAY |
162 | #if ENABLE_OVERLAY |
150 | void |
163 | void |
151 | rxvt_term::iso14755_51 (wchar_t ch) |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
152 | { |
165 | { |
|
|
166 | rxvt_fontset *fs = FONTSET (r); |
|
|
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
153 | wchar_t *chr, *alloc; |
168 | wchar_t *chr, *alloc, ch2; |
154 | int len; |
169 | int len; |
155 | |
170 | |
156 | #if ENABLE_COMBINING |
171 | #if ENABLE_COMBINING |
157 | if (IS_COMPOSE (ch)) |
172 | if (IS_COMPOSE (ch)) |
158 | { |
173 | { |
… | |
… | |
161 | rxvt_composite.expand (ch, chr); |
176 | rxvt_composite.expand (ch, chr); |
162 | } |
177 | } |
163 | else |
178 | else |
164 | #endif |
179 | #endif |
165 | { |
180 | { |
|
|
181 | ch2 = ch; |
|
|
182 | |
166 | alloc = 0; |
183 | alloc = 0; |
167 | chr = &ch; |
184 | chr = &ch2; |
168 | len = 1; |
185 | len = 1; |
169 | } |
186 | } |
170 | |
187 | |
171 | scr_overlay_new (0, -1, 8 + 5, len); |
188 | int width = strlen (f->name); |
|
|
189 | |
|
|
190 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
|
|
191 | |
|
|
192 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
172 | |
193 | |
173 | for (int y = 0; y < len; y++) |
194 | for (int y = 0; y < len; y++) |
174 | { |
195 | { |
175 | char buf[9]; |
196 | char buf[9]; |
176 | |
197 | |
… | |
… | |
181 | scr_overlay_set (9, y, '='); |
202 | scr_overlay_set (9, y, '='); |
182 | #if !UNICODE3 |
203 | #if !UNICODE3 |
183 | if (ch >= 0x10000) |
204 | if (ch >= 0x10000) |
184 | ch = 0xfffd; |
205 | ch = 0xfffd; |
185 | #endif |
206 | #endif |
186 | scr_overlay_set (11, y, ch); |
207 | scr_overlay_set (11, y, ch, r); |
187 | scr_overlay_set (12, y, NOCHAR); |
208 | scr_overlay_set (12, y, NOCHAR, r); |
188 | } |
209 | } |
|
|
210 | |
|
|
211 | scr_overlay_set (0, len, f->name); |
189 | |
212 | |
190 | #if ENABLE_COMBINING |
213 | #if ENABLE_COMBINING |
191 | if (alloc) |
214 | if (alloc) |
192 | delete [] alloc; |
215 | delete [] alloc; |
193 | #endif |
216 | #endif |
… | |
… | |
261 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
284 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
262 | * escape sequence to toggle the Keypad. |
285 | * escape sequence to toggle the Keypad. |
263 | * |
286 | * |
264 | * Always permit `shift' to override the current setting |
287 | * Always permit `shift' to override the current setting |
265 | */ |
288 | */ |
266 | shft = (ev.state & ShiftMask); |
289 | shft = ev.state & ShiftMask; |
267 | ctrl = (ev.state & ControlMask); |
290 | ctrl = ev.state & ControlMask; |
268 | meta = (ev.state & ModMetaMask); |
291 | meta = ev.state & ModMetaMask; |
269 | |
292 | |
270 | if (numlock_state || (ev.state & ModNumLockMask)) |
293 | if (numlock_state || (ev.state & ModNumLockMask)) |
271 | { |
294 | { |
272 | numlock_state = (ev.state & ModNumLockMask); |
295 | numlock_state = (ev.state & ModNumLockMask); |
273 | PrivMode ((!numlock_state), PrivMode_aplKP); |
296 | PrivMode ((!numlock_state), PrivMode_aplKP); |
… | |
… | |
332 | valid_keysym = keysym != NoSymbol; |
355 | valid_keysym = keysym != NoSymbol; |
333 | } |
356 | } |
334 | |
357 | |
335 | if (valid_keysym) |
358 | if (valid_keysym) |
336 | { |
359 | { |
|
|
360 | #ifdef KEYSYM_RESOURCE |
|
|
361 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
362 | return; |
|
|
363 | #endif |
|
|
364 | |
337 | if (TermWin.saveLines) |
365 | if (TermWin.saveLines) |
338 | { |
366 | { |
339 | #ifdef UNSHIFTED_SCROLLKEYS |
367 | #ifdef UNSHIFTED_SCROLLKEYS |
340 | if (!ctrl && !meta) |
368 | if (!ctrl && !meta) |
341 | #else |
369 | #else |
… | |
… | |
406 | { |
434 | { |
407 | /* normal XTerm key bindings */ |
435 | /* normal XTerm key bindings */ |
408 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
436 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
409 | selection_request (ev.time, 0, 0); |
437 | selection_request (ev.time, 0, 0); |
410 | return; |
438 | return; |
411 | #if TODO // TODO |
439 | #if TODO |
412 | /* rxvt extras */ |
440 | /* rxvt extras */ |
413 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
441 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
414 | change_font (FONT_UP); |
442 | change_font (FONT_UP); |
415 | return; |
443 | return; |
416 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
444 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
475 | } |
503 | } |
476 | #endif |
504 | #endif |
477 | |
505 | |
478 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
506 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
479 | { |
507 | { |
480 | #ifdef KEYSYM_RESOURCE |
|
|
481 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
482 | { |
|
|
483 | unsigned int l; |
|
|
484 | const unsigned char *kbuf0; |
|
|
485 | |
|
|
486 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
487 | l = (unsigned int)*kbuf0++; |
|
|
488 | |
|
|
489 | /* escape prefix */ |
|
|
490 | if (meta |
|
|
491 | # ifdef META8_OPTION |
|
|
492 | && meta_char == C0_ESC |
|
|
493 | # endif |
|
|
494 | ) |
|
|
495 | { |
|
|
496 | const unsigned char ch = C0_ESC; |
|
|
497 | tt_write (&ch, 1); |
|
|
498 | } |
|
|
499 | |
|
|
500 | tt_write (kbuf0, l); |
|
|
501 | return; |
|
|
502 | } |
|
|
503 | else |
|
|
504 | #endif |
|
|
505 | { |
508 | { |
506 | newlen = 1; |
509 | newlen = 1; |
507 | switch (keysym) |
510 | switch (keysym) |
508 | { |
511 | { |
509 | #ifndef NO_BACKSPACE_KEY |
512 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
517 | else |
520 | else |
518 | strcpy (kbuf, key_backspace); |
521 | strcpy (kbuf, key_backspace); |
519 | break; |
522 | break; |
520 | #endif |
523 | #endif |
521 | #ifndef NO_DELETE_KEY |
524 | #ifndef NO_DELETE_KEY |
|
|
525 | # ifdef XK_KP_Prior |
|
|
526 | case XK_KP_Delete: |
|
|
527 | /* allow shift to override */ |
|
|
528 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
529 | { |
|
|
530 | strcpy (kbuf, "\033On"); |
|
|
531 | break; |
|
|
532 | } |
|
|
533 | /* FALLTHROUGH */ |
|
|
534 | # endif |
522 | case XK_Delete: |
535 | case XK_Delete: |
523 | strcpy (kbuf, key_delete); |
536 | strcpy (kbuf, key_delete); |
524 | break; |
537 | break; |
525 | #endif |
538 | #endif |
526 | case XK_Tab: |
539 | case XK_Tab: |
… | |
… | |
629 | #ifdef XK_KP_Begin |
642 | #ifdef XK_KP_Begin |
630 | case XK_KP_Begin: |
643 | case XK_KP_Begin: |
631 | strcpy (kbuf, "\033Ou"); |
644 | strcpy (kbuf, "\033Ou"); |
632 | break; |
645 | break; |
633 | |
646 | |
634 | case XK_KP_Insert: |
|
|
635 | strcpy (kbuf, "\033Op"); |
|
|
636 | break; |
|
|
637 | |
|
|
638 | case XK_KP_Delete: |
|
|
639 | strcpy (kbuf, "\033On"); |
|
|
640 | break; |
|
|
641 | #endif |
647 | #endif |
642 | case XK_KP_F1: /* "\033OP" */ |
648 | case XK_KP_F1: /* "\033OP" */ |
643 | case XK_KP_F2: /* "\033OQ" */ |
649 | case XK_KP_F2: /* "\033OQ" */ |
644 | case XK_KP_F3: /* "\033OR" */ |
650 | case XK_KP_F3: /* "\033OR" */ |
645 | case XK_KP_F4: /* "\033OS" */ |
651 | case XK_KP_F4: /* "\033OS" */ |
… | |
… | |
677 | break; |
683 | break; |
678 | |
684 | |
679 | case XK_Find: |
685 | case XK_Find: |
680 | strcpy (kbuf, "\033[1~"); |
686 | strcpy (kbuf, "\033[1~"); |
681 | break; |
687 | break; |
|
|
688 | |
|
|
689 | #ifdef XK_KP_End |
|
|
690 | case XK_KP_Insert: |
|
|
691 | /* allow shift to override */ |
|
|
692 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
693 | { |
|
|
694 | strcpy (kbuf, "\033Op"); |
|
|
695 | break; |
|
|
696 | } |
|
|
697 | /* FALLTHROUGH */ |
|
|
698 | #endif |
682 | case XK_Insert: |
699 | case XK_Insert: |
683 | strcpy (kbuf, "\033[2~"); |
700 | strcpy (kbuf, "\033[2~"); |
684 | break; |
701 | break; |
685 | #ifdef DXK_Remove /* support for DEC remove like key */ |
702 | #ifdef DXK_Remove /* support for DEC remove like key */ |
686 | case DXK_Remove: |
703 | case DXK_Remove: |
… | |
… | |
776 | #undef FKEY |
793 | #undef FKEY |
777 | default: |
794 | default: |
778 | newlen = 0; |
795 | newlen = 0; |
779 | break; |
796 | break; |
780 | } |
797 | } |
|
|
798 | |
781 | if (newlen) |
799 | if (newlen) |
782 | len = strlen (kbuf); |
800 | len = strlen (kbuf); |
783 | } |
801 | } |
784 | |
802 | |
785 | /* |
803 | /* |
… | |
… | |
793 | } |
811 | } |
794 | else if (ctrl && keysym == XK_minus) |
812 | else if (ctrl && keysym == XK_minus) |
795 | { |
813 | { |
796 | len = 1; |
814 | len = 1; |
797 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
815 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
816 | } |
|
|
817 | else if (keysym == XK_ISO_Left_Tab) |
|
|
818 | { |
|
|
819 | strcpy (kbuf, "\033[Z"); |
|
|
820 | len = 3; |
798 | } |
821 | } |
799 | else |
822 | else |
800 | { |
823 | { |
801 | #ifdef META8_OPTION |
824 | #ifdef META8_OPTION |
802 | /* set 8-bit on */ |
825 | /* set 8-bit on */ |
… | |
… | |
861 | #endif /* DEBUG_CMD */ |
884 | #endif /* DEBUG_CMD */ |
862 | tt_write (kbuf, (unsigned int)len); |
885 | tt_write (kbuf, (unsigned int)len); |
863 | } |
886 | } |
864 | /*}}} */ |
887 | /*}}} */ |
865 | |
888 | |
866 | #if (MENUBAR_MAX) |
889 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
867 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
890 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
868 | /* attempt to `write' count to the input buffer */ |
891 | /* attempt to `write' count to the input buffer */ |
869 | unsigned int |
892 | unsigned int |
870 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
893 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
871 | { |
894 | { |
… | |
… | |
894 | |
917 | |
895 | cmd_parse (); |
918 | cmd_parse (); |
896 | |
919 | |
897 | return 0; |
920 | return 0; |
898 | } |
921 | } |
899 | #endif /* MENUBAR_MAX */ |
922 | #endif |
900 | |
923 | |
901 | void |
924 | void |
902 | rxvt_term::flush () |
925 | rxvt_term::flush () |
903 | { |
926 | { |
|
|
927 | flush_ev.stop (); |
|
|
928 | |
904 | #ifdef TRANSPARENT |
929 | #ifdef TRANSPARENT |
905 | if (want_full_refresh) |
930 | if (want_full_refresh) |
906 | { |
931 | { |
907 | want_full_refresh = 0; |
932 | want_full_refresh = 0; |
908 | scr_clear (); |
933 | scr_clear (); |
… | |
… | |
918 | IMSendSpot (); |
943 | IMSendSpot (); |
919 | #endif |
944 | #endif |
920 | } |
945 | } |
921 | |
946 | |
922 | display->flush (); |
947 | display->flush (); |
923 | |
|
|
924 | flush_ev.stop (); |
|
|
925 | } |
948 | } |
926 | |
949 | |
927 | void |
950 | void |
928 | rxvt_term::check_cb (check_watcher &w) |
951 | rxvt_term::check_cb (check_watcher &w) |
929 | { |
952 | { |
… | |
… | |
1005 | { |
1028 | { |
1006 | if (mouse_slip_wheel_speed == 0 |
1029 | if (mouse_slip_wheel_speed == 0 |
1007 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1030 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1008 | : scr_page (UP, mouse_slip_wheel_speed)) |
1031 | : scr_page (UP, mouse_slip_wheel_speed)) |
1009 | { |
1032 | { |
|
|
1033 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1034 | TermWin.view_start == 0) |
|
|
1035 | mouse_slip_wheel_speed = 0; |
|
|
1036 | |
1010 | refresh_type |= SMOOTH_REFRESH; |
1037 | refresh_type |= SMOOTH_REFRESH; |
1011 | want_refresh = 1; |
1038 | want_refresh = 1; |
1012 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1039 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1013 | } |
1040 | } |
1014 | } |
1041 | } |
… | |
… | |
1046 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1073 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1047 | { |
1074 | { |
1048 | SET_R (this); |
1075 | SET_R (this); |
1049 | SET_LOCALE (locale); |
1076 | SET_LOCALE (locale); |
1050 | |
1077 | |
1051 | if (revents & EVENT_WRITE) |
|
|
1052 | tt_write (0, 0); |
|
|
1053 | else if (revents & EVENT_READ) |
1078 | if (revents & EVENT_READ) |
1054 | // loop, but don't allow a single term to monopolize us |
1079 | // loop, but don't allow a single term to monopolize us |
1055 | while (pty_fill ()) |
1080 | while (pty_fill ()) |
1056 | if (cmd_parse ()) |
1081 | if (cmd_parse ()) |
1057 | break; |
1082 | break; |
|
|
1083 | |
|
|
1084 | if (revents & EVENT_WRITE) |
|
|
1085 | pty_write (); |
1058 | } |
1086 | } |
1059 | |
1087 | |
1060 | void |
1088 | void |
1061 | rxvt_term::pointer_unblank () |
1089 | rxvt_term::pointer_unblank () |
1062 | { |
1090 | { |
… | |
… | |
1076 | rxvt_term::pointer_blank () |
1104 | rxvt_term::pointer_blank () |
1077 | { |
1105 | { |
1078 | if (! (options & Opt_pointerBlank)) |
1106 | if (! (options & Opt_pointerBlank)) |
1079 | return; |
1107 | return; |
1080 | |
1108 | |
1081 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1109 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1082 | XFlush (display->display); |
1110 | XFlush (display->display); |
1083 | |
1111 | |
1084 | hidden_pointer = 1; |
1112 | hidden_pointer = 1; |
1085 | } |
1113 | } |
1086 | |
1114 | |
… | |
… | |
1137 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1165 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1138 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1166 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1139 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1167 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1140 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1168 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1141 | #endif |
1169 | #endif |
1142 | |
|
|
1143 | } |
1170 | } |
1144 | |
1171 | |
1145 | #ifdef DEBUG_MOUSEREPORT |
1172 | #if DEBUG_MOUSEREPORT |
1146 | fprintf (stderr, "Mouse ["); |
1173 | fprintf (stderr, "Mouse ["); |
1147 | if (key_state & 16) |
1174 | if (key_state & 16) |
1148 | fputc ('C', stderr); |
1175 | fputc ('C', stderr); |
1149 | if (key_state & 4) |
1176 | if (key_state & 4) |
1150 | fputc ('S', stderr); |
1177 | fputc ('S', stderr); |
… | |
… | |
1154 | fputc ('2', stderr); |
1181 | fputc ('2', stderr); |
1155 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1182 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1156 | button_number, |
1183 | button_number, |
1157 | x + 1, |
1184 | x + 1, |
1158 | y + 1); |
1185 | y + 1); |
1159 | #else |
1186 | #endif |
|
|
1187 | |
1160 | tt_printf ("\033[M%c%c%c", |
1188 | tt_printf ("\033[M%c%c%c", |
1161 | (32 + button_number + key_state), |
1189 | (32 + button_number + key_state), |
1162 | (32 + x + 1), |
1190 | (32 + x + 1), |
1163 | (32 + y + 1)); |
1191 | (32 + y + 1)); |
1164 | #endif |
|
|
1165 | } |
1192 | } |
1166 | |
1193 | |
1167 | #ifdef USING_W11LIB |
1194 | #ifdef USING_W11LIB |
1168 | void |
1195 | void |
1169 | rxvt_W11_process_x_event (XEvent *ev) |
1196 | rxvt_W11_process_x_event (XEvent *ev) |
… | |
… | |
1176 | |
1203 | |
1177 | /*{{{ process an X event */ |
1204 | /*{{{ process an X event */ |
1178 | void |
1205 | void |
1179 | rxvt_term::x_cb (XEvent &ev) |
1206 | rxvt_term::x_cb (XEvent &ev) |
1180 | { |
1207 | { |
|
|
1208 | dDisp; |
|
|
1209 | |
1181 | SET_R (this); |
1210 | SET_R (this); |
1182 | SET_LOCALE (locale); |
1211 | SET_LOCALE (locale); |
1183 | |
1212 | |
1184 | #if defined(CURSOR_BLINK) |
1213 | #if defined(CURSOR_BLINK) |
1185 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1214 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
… | |
… | |
1206 | if (ev.type == KeyPress && hidden_pointer == 0) |
1235 | if (ev.type == KeyPress && hidden_pointer == 0) |
1207 | pointer_blank (); |
1236 | pointer_blank (); |
1208 | } |
1237 | } |
1209 | #endif |
1238 | #endif |
1210 | |
1239 | |
1211 | #ifdef USE_XIM |
|
|
1212 | if (XFilterEvent (&ev, None)) |
|
|
1213 | return; |
|
|
1214 | #endif |
|
|
1215 | |
|
|
1216 | Window unused_root, unused_child; |
1240 | Window unused_root, unused_child; |
1217 | int unused_root_x, unused_root_y; |
1241 | int unused_root_x, unused_root_y; |
1218 | unsigned int unused_mask; |
1242 | unsigned int unused_mask; |
1219 | |
1243 | |
1220 | switch (ev.type) |
1244 | switch (ev.type) |
1221 | { |
1245 | { |
1222 | case KeyPress: |
1246 | case KeyPress: |
1223 | #if ISO_14755 |
1247 | #if ISO_14755 |
… | |
… | |
1227 | |
1251 | |
1228 | break; |
1252 | break; |
1229 | |
1253 | |
1230 | case KeyRelease: |
1254 | case KeyRelease: |
1231 | { |
1255 | { |
1232 | #if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS) |
1256 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1233 | KeySym ks; |
1257 | KeySym ks; |
1234 | |
1258 | |
1235 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1259 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1236 | #endif |
1260 | #endif |
1237 | |
1261 | |
… | |
… | |
1306 | button_release (ev.xbutton); |
1330 | button_release (ev.xbutton); |
1307 | break; |
1331 | break; |
1308 | |
1332 | |
1309 | case ClientMessage: |
1333 | case ClientMessage: |
1310 | if (ev.xclient.format == 32 |
1334 | if (ev.xclient.format == 32 |
|
|
1335 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS] |
1311 | && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) |
1336 | && ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1312 | destroy (); |
1337 | destroy (); |
|
|
1338 | #if ENABLE_XEMBED |
|
|
1339 | else if (ev.xclient.format == 32 |
|
|
1340 | && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1341 | { |
|
|
1342 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1343 | focus_in (); |
|
|
1344 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1345 | focus_out (); |
|
|
1346 | } |
|
|
1347 | #endif |
1313 | #ifdef OFFIX_DND |
1348 | #ifdef OFFIX_DND |
1314 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1349 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1315 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1350 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1316 | && (ev.xclient.data.l[0] == DndFile |
1351 | && (ev.xclient.data.l[0] == DndFile |
1317 | || ev.xclient.data.l[0] == DndDir |
1352 | || ev.xclient.data.l[0] == DndDir |
1318 | || ev.xclient.data.l[0] == DndLink)) |
1353 | || ev.xclient.data.l[0] == DndLink)) |
1319 | { |
1354 | { |
1320 | /* Get Dnd data */ |
1355 | /* Get Dnd data */ |
1321 | Atom ActualType; |
1356 | Atom ActualType; |
1322 | int ActualFormat; |
1357 | int ActualFormat; |
1323 | unsigned char *data; |
1358 | unsigned char *data; |
1324 | unsigned long Size, RemainingBytes; |
1359 | unsigned long Size, RemainingBytes; |
1325 | |
1360 | |
1326 | XGetWindowProperty (display->display, display->root, |
1361 | XGetWindowProperty (disp, display->root, |
1327 | xa[XA_DNDSELECTION], |
1362 | xa[XA_DNDSELECTION], |
1328 | 0L, 1000000L, |
1363 | 0L, 1000000L, |
1329 | False, AnyPropertyType, |
1364 | False, AnyPropertyType, |
1330 | &ActualType, &ActualFormat, |
1365 | &ActualType, &ActualFormat, |
1331 | &Size, &RemainingBytes, |
1366 | &Size, &RemainingBytes, |
1332 | &data); |
1367 | &data); |
1333 | XChangeProperty (display->display, display->root, |
1368 | set_string_property (XA_CUT_BUFFER0, data); |
1334 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1335 | 8, PropModeReplace, |
|
|
1336 | data, strlen (data)); |
|
|
1337 | XFree (data); |
1369 | XFree (data); |
1338 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1370 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1339 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1371 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
1340 | } |
1372 | } |
1341 | #endif /* OFFIX_DND */ |
1373 | #endif /* OFFIX_DND */ |
1342 | break; |
1374 | break; |
1343 | |
1375 | |
1344 | case MappingNotify: |
1376 | case MappingNotify: |
… | |
… | |
1369 | break; |
1401 | break; |
1370 | } |
1402 | } |
1371 | break; |
1403 | break; |
1372 | |
1404 | |
1373 | case FocusIn: |
1405 | case FocusIn: |
1374 | if (!TermWin.focus) |
1406 | focus_in (); |
1375 | { |
|
|
1376 | TermWin.focus = 1; |
|
|
1377 | want_refresh = 1; |
|
|
1378 | #ifdef USE_XIM |
|
|
1379 | if (Input_Context != NULL) |
|
|
1380 | { |
|
|
1381 | IMSetStatusPosition (); |
|
|
1382 | XSetICFocus (Input_Context); |
|
|
1383 | } |
|
|
1384 | #endif |
|
|
1385 | #ifdef CURSOR_BLINK |
|
|
1386 | if (options & Opt_cursorBlink) |
|
|
1387 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1388 | #endif |
|
|
1389 | #ifdef OFF_FOCUS_FADING |
|
|
1390 | if (rs[Rs_fade]) |
|
|
1391 | { |
|
|
1392 | pix_colors = pix_colors_focused; |
|
|
1393 | set_colorfgbg (); |
|
|
1394 | scr_clear (); |
|
|
1395 | scr_touch (true); |
|
|
1396 | } |
|
|
1397 | #endif |
|
|
1398 | |
|
|
1399 | } |
|
|
1400 | break; |
1407 | break; |
1401 | |
1408 | |
1402 | case FocusOut: |
1409 | case FocusOut: |
1403 | if (TermWin.focus) |
1410 | focus_out (); |
1404 | { |
|
|
1405 | TermWin.focus = 0; |
|
|
1406 | want_refresh = 1; |
|
|
1407 | #ifdef USE_XIM |
|
|
1408 | if (Input_Context != NULL) |
|
|
1409 | XUnsetICFocus (Input_Context); |
|
|
1410 | #endif |
|
|
1411 | #ifdef CURSOR_BLINK |
|
|
1412 | if (options & Opt_cursorBlink) |
|
|
1413 | cursor_blink_ev.stop (); |
|
|
1414 | hidden_cursor = 0; |
|
|
1415 | #endif |
|
|
1416 | #ifdef OFF_FOCUS_FADING |
|
|
1417 | if (rs[Rs_fade]) |
|
|
1418 | { |
|
|
1419 | pix_colors = pix_colors_unfocused; |
|
|
1420 | set_colorfgbg (); |
|
|
1421 | scr_clear (); |
|
|
1422 | scr_touch (true); |
|
|
1423 | } |
|
|
1424 | #endif |
|
|
1425 | |
|
|
1426 | } |
|
|
1427 | break; |
1411 | break; |
1428 | |
1412 | |
1429 | case ConfigureNotify: |
1413 | case ConfigureNotify: |
1430 | if (ev.xconfigure.window == TermWin.parent[0]) |
1414 | if (ev.xconfigure.window == TermWin.parent[0]) |
1431 | { |
1415 | { |
… | |
… | |
1435 | { /* Wrap lots of configures into one */ |
1419 | { /* Wrap lots of configures into one */ |
1436 | width = ev.xconfigure.width; |
1420 | width = ev.xconfigure.width; |
1437 | height = ev.xconfigure.height; |
1421 | height = ev.xconfigure.height; |
1438 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1422 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | } |
1423 | } |
1440 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1424 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | |
1425 | |
1442 | if (szHint.width != width || szHint.height != height) |
1426 | if (szHint.width != width || szHint.height != height) |
|
|
1427 | { |
|
|
1428 | seen_resize = 1; |
1443 | resize_all_windows (width, height, 1); |
1429 | resize_all_windows (width, height, 1); |
|
|
1430 | } |
1444 | |
1431 | |
1445 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1432 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1446 | if (options & Opt_transparent) |
1433 | if (options & Opt_transparent) |
1447 | { |
|
|
1448 | check_our_parents (); |
1434 | check_our_parents (); |
1449 | if (am_transparent) |
|
|
1450 | want_refresh = want_full_refresh = 1; |
|
|
1451 | } |
|
|
1452 | #endif |
1435 | #endif |
1453 | } |
1436 | } |
1454 | break; |
1437 | break; |
1455 | |
1438 | |
1456 | case PropertyNotify: |
1439 | case PropertyNotify: |
… | |
… | |
1464 | selection_clear (); |
1447 | selection_clear (); |
1465 | break; |
1448 | break; |
1466 | |
1449 | |
1467 | case SelectionNotify: |
1450 | case SelectionNotify: |
1468 | if (selection_wait == Sel_normal) |
1451 | if (selection_wait == Sel_normal) |
1469 | selection_paste (ev.xselection.requestor, |
1452 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1470 | ev.xselection.property, True); |
|
|
1471 | break; |
1453 | break; |
1472 | |
1454 | |
1473 | case SelectionRequest: |
1455 | case SelectionRequest: |
1474 | selection_send (ev.xselectionrequest); |
1456 | selection_send (ev.xselectionrequest); |
1475 | break; |
1457 | break; |
… | |
… | |
1499 | if (ev.xany.window == TermWin.vt) |
1481 | if (ev.xany.window == TermWin.vt) |
1500 | { |
1482 | { |
1501 | do |
1483 | do |
1502 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1484 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1503 | ev.xexpose.width, ev.xexpose.height, False); |
1485 | ev.xexpose.width, ev.xexpose.height, False); |
1504 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); |
1486 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)); |
1505 | |
1487 | |
1506 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1488 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1507 | |
1489 | |
1508 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) |
1490 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)) |
1509 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1491 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1510 | ev.xexpose.width, ev.xexpose.height, False); |
1492 | ev.xexpose.width, ev.xexpose.height, False); |
1511 | |
1493 | |
1512 | scr_refresh (refresh_type); |
1494 | scr_refresh (refresh_type); |
1513 | } |
1495 | } |
1514 | else |
1496 | else |
1515 | { |
1497 | { |
1516 | XEvent unused_event; |
1498 | XEvent unused_event; |
1517 | |
1499 | |
1518 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1500 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1519 | ; |
1501 | ; |
1520 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1502 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1521 | ; |
1503 | ; |
1522 | |
1504 | |
1523 | if (isScrollbarWindow (ev.xany.window)) |
1505 | if (isScrollbarWindow (ev.xany.window)) |
1524 | { |
1506 | { |
1525 | scrollBar.setIdle (); |
1507 | scrollBar.setIdle (); |
… | |
… | |
1530 | menubar_expose (); |
1512 | menubar_expose (); |
1531 | #endif |
1513 | #endif |
1532 | |
1514 | |
1533 | #ifdef TRANSPARENT |
1515 | #ifdef TRANSPARENT |
1534 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1516 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1535 | XClearWindow (display->display, ev.xany.window); |
1517 | XClearWindow (disp, ev.xany.window); |
1536 | #endif |
1518 | #endif |
1537 | } |
1519 | } |
1538 | break; |
1520 | break; |
1539 | |
1521 | |
1540 | case MotionNotify: |
1522 | case MotionNotify: |
… | |
… | |
1547 | { |
1529 | { |
1548 | menubar_control (ev.xbutton); |
1530 | menubar_control (ev.xbutton); |
1549 | break; |
1531 | break; |
1550 | } |
1532 | } |
1551 | #endif |
1533 | #endif |
1552 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1534 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1553 | break; |
1535 | break; |
1554 | |
1536 | |
1555 | if (ev.xany.window == TermWin.vt) |
1537 | if (ev.xany.window == TermWin.vt) |
1556 | { |
1538 | { |
1557 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1539 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1558 | { |
1540 | { |
1559 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) |
1541 | while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev)) |
1560 | ; |
1542 | ; |
1561 | |
1543 | |
1562 | XQueryPointer (display->display, TermWin.vt, |
1544 | XQueryPointer (disp, TermWin.vt, |
1563 | &unused_root, &unused_child, |
1545 | &unused_root, &unused_child, |
1564 | &unused_root_x, &unused_root_y, |
1546 | &unused_root_x, &unused_root_y, |
1565 | & (ev.xbutton.x), & (ev.xbutton.y), |
1547 | &ev.xbutton.x, &ev.xbutton.y, |
1566 | &unused_mask); |
1548 | &ev.xbutton.state); |
1567 | #ifdef MOUSE_THRESHOLD |
1549 | #ifdef MOUSE_THRESHOLD |
1568 | /* deal with a `jumpy' mouse */ |
1550 | /* deal with a `jumpy' mouse */ |
1569 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1551 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1570 | { |
1552 | { |
1571 | #endif |
1553 | #endif |
… | |
… | |
1576 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1558 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1577 | break; |
1559 | break; |
1578 | } |
1560 | } |
1579 | #endif |
1561 | #endif |
1580 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1562 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1581 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1563 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1564 | |
1582 | #ifdef SELECTION_SCROLLING |
1565 | #ifdef SELECTION_SCROLLING |
1583 | if (ev.xbutton.y < TermWin.int_bwidth |
1566 | if (ev.xbutton.y < TermWin.int_bwidth |
1584 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1567 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1585 | { |
1568 | { |
1586 | int dist; |
1569 | int dist; |
… | |
… | |
1597 | selection_save_x = ev.xbutton.x; |
1580 | selection_save_x = ev.xbutton.x; |
1598 | selection_save_y = ev.xbutton.y; |
1581 | selection_save_y = ev.xbutton.y; |
1599 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1582 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1600 | |
1583 | |
1601 | /* calc number of lines to scroll */ |
1584 | /* calc number of lines to scroll */ |
1602 | if (ev.xbutton.y<TermWin.int_bwidth) |
1585 | if (ev.xbutton.y < TermWin.int_bwidth) |
1603 | { |
1586 | { |
1604 | scroll_selection_dir = UP; |
1587 | scroll_selection_dir = UP; |
1605 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1588 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1606 | } |
1589 | } |
1607 | else |
1590 | else |
… | |
… | |
1630 | #endif |
1613 | #endif |
1631 | } |
1614 | } |
1632 | } |
1615 | } |
1633 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1616 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1634 | { |
1617 | { |
1635 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1618 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1636 | MotionNotify, &ev)) ; |
1619 | MotionNotify, &ev)) |
|
|
1620 | ; |
|
|
1621 | |
1637 | XQueryPointer (display->display, scrollBar.win, |
1622 | XQueryPointer (disp, scrollBar.win, |
1638 | &unused_root, &unused_child, |
1623 | &unused_root, &unused_child, |
1639 | &unused_root_x, &unused_root_y, |
1624 | &unused_root_x, &unused_root_y, |
1640 | & (ev.xbutton.x), & (ev.xbutton.y), |
1625 | &ev.xbutton.x, &ev.xbutton.y, |
1641 | &unused_mask); |
1626 | &unused_mask); |
1642 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1627 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1643 | scrollbar_size ()); |
1628 | scrollbar_size ()); |
1644 | scr_refresh (refresh_type); |
1629 | scr_refresh (refresh_type); |
1645 | refresh_limit = 0; |
1630 | refresh_limit = 0; |
… | |
… | |
1647 | } |
1632 | } |
1648 | break; |
1633 | break; |
1649 | } |
1634 | } |
1650 | } |
1635 | } |
1651 | |
1636 | |
|
|
1637 | void |
|
|
1638 | rxvt_term::focus_in () |
|
|
1639 | { |
|
|
1640 | if (!TermWin.focus) |
|
|
1641 | { |
|
|
1642 | TermWin.focus = 1; |
|
|
1643 | want_refresh = 1; |
|
|
1644 | #ifdef USE_XIM |
|
|
1645 | if (Input_Context != NULL) |
|
|
1646 | { |
|
|
1647 | IMSetStatusPosition (); |
|
|
1648 | XSetICFocus (Input_Context); |
|
|
1649 | } |
|
|
1650 | #endif |
|
|
1651 | #ifdef CURSOR_BLINK |
|
|
1652 | if (options & Opt_cursorBlink) |
|
|
1653 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1654 | #endif |
|
|
1655 | #ifdef OFF_FOCUS_FADING |
|
|
1656 | if (rs[Rs_fade]) |
|
|
1657 | { |
|
|
1658 | pix_colors = pix_colors_focused; |
|
|
1659 | scr_recolour (); |
|
|
1660 | } |
|
|
1661 | #endif |
|
|
1662 | } |
|
|
1663 | } |
|
|
1664 | |
|
|
1665 | void |
|
|
1666 | rxvt_term::focus_out () |
|
|
1667 | { |
|
|
1668 | if (TermWin.focus) |
|
|
1669 | { |
|
|
1670 | TermWin.focus = 0; |
|
|
1671 | want_refresh = 1; |
|
|
1672 | |
|
|
1673 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1674 | iso14755buf = 0; |
|
|
1675 | #endif |
|
|
1676 | #if ENABLE_OVERLAY |
|
|
1677 | scr_overlay_off (); |
|
|
1678 | #endif |
|
|
1679 | #ifdef USE_XIM |
|
|
1680 | if (Input_Context != NULL) |
|
|
1681 | XUnsetICFocus (Input_Context); |
|
|
1682 | #endif |
|
|
1683 | #ifdef CURSOR_BLINK |
|
|
1684 | if (options & Opt_cursorBlink) |
|
|
1685 | cursor_blink_ev.stop (); |
|
|
1686 | hidden_cursor = 0; |
|
|
1687 | #endif |
|
|
1688 | #ifdef OFF_FOCUS_FADING |
|
|
1689 | if (rs[Rs_fade]) |
|
|
1690 | { |
|
|
1691 | pix_colors = pix_colors_unfocused; |
|
|
1692 | scr_recolour (); |
|
|
1693 | } |
|
|
1694 | #endif |
|
|
1695 | } |
|
|
1696 | } |
|
|
1697 | |
1652 | #if TRANSPARENT |
1698 | #if TRANSPARENT |
1653 | void |
1699 | void |
1654 | rxvt_term::rootwin_cb (XEvent &ev) |
1700 | rxvt_term::rootwin_cb (XEvent &ev) |
1655 | { |
1701 | { |
1656 | SET_R (this); |
1702 | SET_R (this); |
… | |
… | |
1661 | case PropertyNotify: |
1707 | case PropertyNotify: |
1662 | /* |
1708 | /* |
1663 | * if user used some Esetroot compatible prog to set the root bg, |
1709 | * if user used some Esetroot compatible prog to set the root bg, |
1664 | * use the property to determine the pixmap. We use it later on. |
1710 | * use the property to determine the pixmap. We use it later on. |
1665 | */ |
1711 | */ |
1666 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1667 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1668 | |
|
|
1669 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1712 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1713 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1670 | return; |
1714 | return; |
1671 | |
1715 | |
1672 | /* FALLTHROUGH */ |
1716 | /* FALLTHROUGH */ |
1673 | case ReparentNotify: |
1717 | case ReparentNotify: |
1674 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1718 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1700 | return; |
1744 | return; |
1701 | } |
1745 | } |
1702 | #endif |
1746 | #endif |
1703 | |
1747 | |
1704 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1748 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1749 | |
1705 | if (reportmode) |
1750 | if (reportmode) |
1706 | { |
1751 | { |
1707 | /* mouse report from vt window */ |
1752 | /* mouse report from vt window */ |
1708 | /* save the xbutton state (for ButtonRelease) */ |
1753 | /* save the xbutton state (for ButtonRelease) */ |
1709 | MEvent.state = ev.state; |
1754 | MEvent.state = ev.state; |
… | |
… | |
1738 | } |
1783 | } |
1739 | else |
1784 | else |
1740 | { |
1785 | { |
1741 | if (ev.button != MEvent.button) |
1786 | if (ev.button != MEvent.button) |
1742 | MEvent.clicks = 0; |
1787 | MEvent.clicks = 0; |
|
|
1788 | |
1743 | switch (ev.button) |
1789 | switch (ev.button) |
1744 | { |
1790 | { |
1745 | case Button1: |
1791 | case Button1: |
|
|
1792 | /* allow meta + click to select rectangular areas */ |
|
|
1793 | /* should be done in screen.C */ |
|
|
1794 | #if ENABLE_FRILLS |
|
|
1795 | selection.rect = !!(ev.state & ModMetaMask); |
|
|
1796 | #else |
|
|
1797 | selection.rect = false; |
|
|
1798 | #endif |
|
|
1799 | |
1746 | /* allow shift+left click to extend selection */ |
1800 | /* allow shift+left click to extend selection */ |
1747 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1801 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1748 | { |
1802 | { |
1749 | if (MEvent.button == Button1 && clickintime) |
1803 | if (MEvent.button == Button1 && clickintime) |
1750 | selection_rotate (ev.x, ev.y); |
1804 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2072 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2126 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2073 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2127 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2074 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2128 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2075 | int i; |
2129 | int i; |
2076 | |
2130 | |
2077 | Visual* visual = display->visual; |
2131 | Visual *visual = display->visual; |
2078 | |
2132 | |
2079 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2133 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2080 | |
2134 | |
2081 | /* for convenience */ |
2135 | /* for convenience */ |
2082 | mask_r = visual->red_mask; |
2136 | mask_r = visual->red_mask; |
… | |
… | |
2303 | Atom atype; |
2357 | Atom atype; |
2304 | unsigned char *prop = NULL; |
2358 | unsigned char *prop = NULL; |
2305 | Window root, oldp, *list; |
2359 | Window root, oldp, *list; |
2306 | Pixmap rootpixmap = None; |
2360 | Pixmap rootpixmap = None; |
2307 | XWindowAttributes wattr, wrootattr; |
2361 | XWindowAttributes wattr, wrootattr; |
|
|
2362 | dDisp; |
2308 | |
2363 | |
2309 | pchanged = 0; |
2364 | pchanged = 0; |
2310 | |
2365 | |
2311 | if (!(options & Opt_transparent)) |
2366 | if (!(options & Opt_transparent)) |
2312 | return pchanged; /* Don't try any more */ |
2367 | return pchanged; /* Don't try any more */ |
2313 | |
2368 | |
2314 | XGetWindowAttributes (display->display, display->root, &wrootattr); |
2369 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2315 | rootdepth = wrootattr.depth; |
2370 | rootdepth = wrootattr.depth; |
2316 | |
2371 | |
2317 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2372 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
2318 | |
2373 | |
2319 | if (rootdepth != wattr.depth) |
2374 | if (rootdepth != wattr.depth) |
2320 | { |
2375 | { |
2321 | if (am_transparent) |
2376 | if (am_transparent) |
2322 | { |
2377 | { |
2323 | pchanged = 1; |
2378 | pchanged = 1; |
2324 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2379 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2325 | am_transparent = am_pixmap_trans = 0; |
2380 | am_transparent = am_pixmap_trans = 0; |
2326 | } |
2381 | } |
2327 | |
2382 | |
2328 | return pchanged; /* Don't try any more */ |
2383 | return pchanged; /* Don't try any more */ |
2329 | } |
2384 | } |
2330 | |
2385 | |
2331 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2386 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2332 | XSync (display->display, False); |
2387 | XSync (disp, False); |
2333 | |
2388 | |
2334 | /* |
2389 | /* |
2335 | * Make the frame window set by the window manager have |
2390 | * Make the frame window set by the window manager have |
2336 | * the root background. Some window managers put multiple nested frame |
2391 | * the root background. Some window managers put multiple nested frame |
2337 | * windows for each client, so we have to take care about that. |
2392 | * windows for each client, so we have to take care about that. |
2338 | */ |
2393 | */ |
2339 | i = (xa[XA_XROOTPMAPID] |
2394 | i = (xa[XA_XROOTPMAP_ID] |
2340 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2395 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2341 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2396 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2342 | &nitems, &bytes_after, &prop) == Success); |
2397 | &nitems, &bytes_after, &prop) == Success); |
2343 | |
2398 | |
2344 | if (!i || prop == NULL) |
2399 | if (!i || prop == NULL) |
2345 | i = (xa[XA_XSETROOTID] |
2400 | i = (xa[XA_ESETROOT_PMAP_ID] |
2346 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2401 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2347 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2402 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2348 | &nitems, &bytes_after, &prop) == Success); |
2403 | &nitems, &bytes_after, &prop) == Success); |
2349 | |
2404 | |
2350 | if (!i || prop == NULL |
2405 | if (!i || prop == NULL |
2351 | #if TINTING |
2406 | #if TINTING |
… | |
… | |
2370 | Window cr; |
2425 | Window cr; |
2371 | XImage *image; |
2426 | XImage *image; |
2372 | GC gc; |
2427 | GC gc; |
2373 | XGCValues gcvalue; |
2428 | XGCValues gcvalue; |
2374 | |
2429 | |
2375 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2430 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
2376 | 0, 0, &sx, &sy, &cr); |
2431 | 0, 0, &sx, &sy, &cr); |
2377 | nw = (unsigned int)szHint.width; |
2432 | nw = (unsigned int)szHint.width; |
2378 | nh = (unsigned int)szHint.height; |
2433 | nh = (unsigned int)szHint.height; |
2379 | nx = ny = 0; |
2434 | nx = ny = 0; |
2380 | |
2435 | |
… | |
… | |
2392 | sy = 0; |
2447 | sy = 0; |
2393 | } |
2448 | } |
2394 | |
2449 | |
2395 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2450 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2396 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2451 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2452 | |
|
|
2453 | XSync (disp, False); |
2397 | allowedxerror = -1; |
2454 | allowedxerror = -1; |
2398 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2455 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2399 | |
2456 | |
2400 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2457 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2401 | /* XXX: may need a delay here? */ |
2458 | /* XXX: may need a delay here? */ |
2402 | allowedxerror = 0; |
2459 | allowedxerror = 0; |
2403 | |
2460 | |
… | |
… | |
2406 | if (am_transparent && am_pixmap_trans) |
2463 | if (am_transparent && am_pixmap_trans) |
2407 | { |
2464 | { |
2408 | pchanged = 1; |
2465 | pchanged = 1; |
2409 | if (TermWin.pixmap != None) |
2466 | if (TermWin.pixmap != None) |
2410 | { |
2467 | { |
2411 | XFreePixmap (display->display, TermWin.pixmap); |
2468 | XFreePixmap (disp, TermWin.pixmap); |
2412 | TermWin.pixmap = None; |
2469 | TermWin.pixmap = None; |
2413 | } |
2470 | } |
2414 | } |
2471 | } |
2415 | |
2472 | |
2416 | am_pixmap_trans = 0; |
2473 | am_pixmap_trans = 0; |
2417 | } |
2474 | } |
2418 | else |
2475 | else |
2419 | { |
2476 | { |
2420 | if (TermWin.pixmap != None) |
2477 | if (TermWin.pixmap != None) |
2421 | XFreePixmap (display->display, TermWin.pixmap); |
2478 | XFreePixmap (disp, TermWin.pixmap); |
2422 | |
2479 | |
2423 | #if TINTING |
2480 | #if TINTING |
2424 | if (ISSET_PIXCOLOR (Color_tint)) |
2481 | if (ISSET_PIXCOLOR (Color_tint)) |
2425 | { |
2482 | { |
2426 | unsigned short rm, gm, bm; |
2483 | unsigned short rm, gm, bm; |
… | |
… | |
2430 | |
2487 | |
2431 | ShadeXImage (display, image, shade, rm, gm, bm); |
2488 | ShadeXImage (display, image, shade, rm, gm, bm); |
2432 | } |
2489 | } |
2433 | #endif |
2490 | #endif |
2434 | |
2491 | |
2435 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2492 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
2436 | szHint.width, szHint.height, image->depth); |
2493 | szHint.width, szHint.height, image->depth); |
2437 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2494 | gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue); |
2438 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2495 | XPutImage (disp, TermWin.pixmap, gc, image, 0, 0, |
2439 | nx, ny, image->width, image->height); |
2496 | nx, ny, image->width, image->height); |
2440 | XFreeGC (display->display, gc); |
2497 | XFreeGC (disp, gc); |
2441 | XDestroyImage (image); |
2498 | XDestroyImage (image); |
2442 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); |
2499 | XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap); |
2443 | XClearWindow (display->display, TermWin.parent[0]); |
2500 | XClearWindow (disp, TermWin.parent[0]); |
2444 | |
2501 | |
2445 | if (!am_transparent || !am_pixmap_trans) |
2502 | if (!am_transparent || !am_pixmap_trans) |
2446 | pchanged = 1; |
2503 | pchanged = 1; |
2447 | |
2504 | |
2448 | am_transparent = am_pixmap_trans = 1; |
2505 | am_transparent = am_pixmap_trans = 1; |
2449 | } |
2506 | } |
2450 | } |
2507 | } |
2451 | |
2508 | |
2452 | if (!am_pixmap_trans) |
2509 | if (am_pixmap_trans) |
|
|
2510 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
|
|
2511 | else |
2453 | { |
2512 | { |
2454 | unsigned int n; |
2513 | unsigned int n; |
2455 | /* |
2514 | /* |
2456 | * InheritPixmap transparency |
2515 | * InheritPixmap transparency |
2457 | */ |
2516 | */ |
2458 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2517 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2459 | { |
2518 | { |
2460 | oldp = TermWin.parent[i]; |
2519 | oldp = TermWin.parent[i]; |
2461 | XQueryTree (display->display, TermWin.parent[i - 1], &root, |
2520 | XQueryTree (disp, TermWin.parent[i - 1], &root, |
2462 | &TermWin.parent[i], &list, &n); |
2521 | &TermWin.parent[i], &list, &n); |
2463 | XFree (list); |
2522 | XFree (list); |
2464 | |
2523 | |
2465 | if (TermWin.parent[i] == display->root) |
2524 | if (TermWin.parent[i] == display->root) |
2466 | { |
2525 | { |
… | |
… | |
2478 | |
2537 | |
2479 | if (pchanged) |
2538 | if (pchanged) |
2480 | { |
2539 | { |
2481 | for (; n < (unsigned int)i; n++) |
2540 | for (; n < (unsigned int)i; n++) |
2482 | { |
2541 | { |
2483 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2542 | XGetWindowAttributes (disp, TermWin.parent[n], &wattr); |
2484 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2543 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2485 | { |
2544 | { |
2486 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2545 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2487 | break; |
2546 | break; |
2488 | } |
2547 | } |
2489 | } |
2548 | } |
2490 | } |
2549 | } |
2491 | |
2550 | |
2492 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2551 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2493 | { |
2552 | { |
2494 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2553 | XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2495 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2554 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2496 | am_transparent = 0; |
2555 | am_transparent = 0; |
2497 | /* XXX: also turn off Opt_transparent? */ |
2556 | /* XXX: also turn off Opt_transparent? */ |
2498 | } |
2557 | } |
2499 | else |
2558 | else |
2500 | { |
2559 | { |
… | |
… | |
2503 | * needed for fvwm2.2.2 (and before?) */ |
2562 | * needed for fvwm2.2.2 (and before?) */ |
2504 | sleep (1); |
2563 | sleep (1); |
2505 | #endif |
2564 | #endif |
2506 | for (n = 0; n < (unsigned int)i; n++) |
2565 | for (n = 0; n < (unsigned int)i; n++) |
2507 | { |
2566 | { |
2508 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
2567 | XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative); |
2509 | XClearWindow (display->display, TermWin.parent[n]); |
2568 | XClearWindow (disp, TermWin.parent[n]); |
2510 | } |
2569 | } |
2511 | |
2570 | |
2512 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2571 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2513 | am_transparent = 1; |
2572 | am_transparent = 1; |
2514 | } |
2573 | } |
2515 | |
2574 | |
2516 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2575 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2517 | TermWin.parent[i] = None; |
2576 | TermWin.parent[i] = None; |
2518 | } |
2577 | } |
2519 | |
2578 | |
2520 | // this is experimental |
|
|
2521 | if (scrollBar.win) |
2579 | if (scrollBar.win) |
2522 | { |
2580 | { |
2523 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2581 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2524 | XClearWindow (display->display, scrollBar.win); |
|
|
2525 | scrollBar.setIdle (); |
2582 | scrollBar.setIdle (); |
2526 | scrollbar_show (0); |
2583 | scrollbar_show (0); |
|
|
2584 | } |
|
|
2585 | |
|
|
2586 | if (am_transparent) |
|
|
2587 | { |
|
|
2588 | want_refresh = want_full_refresh = 1; |
|
|
2589 | if (am_pixmap_trans) |
|
|
2590 | flush (); |
2527 | } |
2591 | } |
2528 | |
2592 | |
2529 | return pchanged; |
2593 | return pchanged; |
2530 | } |
2594 | } |
2531 | #endif |
2595 | #endif |
… | |
… | |
2557 | seen_input = 1; |
2621 | seen_input = 1; |
2558 | // many badly-written programs (e.g. jed) contain a race condition: |
2622 | // many badly-written programs (e.g. jed) contain a race condition: |
2559 | // they first read the screensize and then install a SIGWINCH handler. |
2623 | // they first read the screensize and then install a SIGWINCH handler. |
2560 | // some window managers resize the window early, and these programs |
2624 | // some window managers resize the window early, and these programs |
2561 | // then sometimes get the size wrong. |
2625 | // then sometimes get the size wrong. |
|
|
2626 | // unfortunately other programs are even more buggy and dislike |
|
|
2627 | // being sent SIGWINCH, so only do it when we were in fact being |
|
|
2628 | // resized. |
|
|
2629 | if (seen_resize && cmd_pid) |
2562 | kill (-cmd_pid, SIGWINCH); |
2630 | kill (-cmd_pid, SIGWINCH); |
2563 | } |
2631 | } |
2564 | |
2632 | |
2565 | /* Read a text string from the input buffer */ |
2633 | /* Read a text string from the input buffer */ |
2566 | unicode_t buf[UBUFSIZ]; |
2634 | unicode_t buf[UBUFSIZ]; |
2567 | bool refreshnow = false; |
2635 | bool refreshnow = false; |
… | |
… | |
2679 | if (len == (size_t)-1) |
2747 | if (len == (size_t)-1) |
2680 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2748 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2681 | |
2749 | |
2682 | // assume wchar == unicode |
2750 | // assume wchar == unicode |
2683 | cmdbuf_ptr += len; |
2751 | cmdbuf_ptr += len; |
2684 | return wc; |
2752 | return wc & UNICODE_MASK; |
2685 | } |
2753 | } |
2686 | |
2754 | |
2687 | return NOCHAR; |
2755 | return NOCHAR; |
2688 | } |
2756 | } |
2689 | |
2757 | |
… | |
… | |
3152 | { |
3220 | { |
3153 | switch (priv) |
3221 | switch (priv) |
3154 | { |
3222 | { |
3155 | case '>': |
3223 | case '>': |
3156 | if (ch == CSI_DA) /* secondary device attributes */ |
3224 | if (ch == CSI_DA) /* secondary device attributes */ |
3157 | tt_printf ("\033[>%d;%-.8s;0c", 'R', VSTRING); |
3225 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3158 | break; |
3226 | break; |
3159 | case '?': |
3227 | case '?': |
3160 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3228 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3161 | process_terminal_mode (ch, priv, nargs, arg); |
3229 | process_terminal_mode (ch, priv, nargs, arg); |
3162 | break; |
3230 | break; |
… | |
… | |
3391 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3459 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3392 | { |
3460 | { |
3393 | int x, y; |
3461 | int x, y; |
3394 | XWindowAttributes wattr; |
3462 | XWindowAttributes wattr; |
3395 | Window wdummy; |
3463 | Window wdummy; |
|
|
3464 | dDisp; |
3396 | |
3465 | |
3397 | if (nargs == 0) |
3466 | if (nargs == 0) |
3398 | return; |
3467 | return; |
3399 | |
3468 | |
3400 | switch (args[0]) |
3469 | switch (args[0]) |
3401 | { |
3470 | { |
3402 | /* |
3471 | /* |
3403 | * commands |
3472 | * commands |
3404 | */ |
3473 | */ |
3405 | case 1: /* deiconify window */ |
3474 | case 1: /* deiconify window */ |
3406 | XMapWindow (display->display, TermWin.parent[0]); |
3475 | XMapWindow (disp, TermWin.parent[0]); |
3407 | break; |
3476 | break; |
3408 | case 2: /* iconify window */ |
3477 | case 2: /* iconify window */ |
3409 | XIconifyWindow (display->display, TermWin.parent[0], |
3478 | XIconifyWindow (disp, TermWin.parent[0], display->screen); |
3410 | DefaultScreen (display->display)); |
|
|
3411 | break; |
3479 | break; |
3412 | case 3: /* set position (pixels) */ |
3480 | case 3: /* set position (pixels) */ |
3413 | XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); |
3481 | XMoveWindow (disp, TermWin.parent[0], args[1], args[2]); |
3414 | break; |
3482 | break; |
3415 | case 4: /* set size (pixels) */ |
3483 | case 4: /* set size (pixels) */ |
3416 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3484 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3417 | break; |
3485 | break; |
3418 | case 5: /* raise window */ |
3486 | case 5: /* raise window */ |
3419 | XRaiseWindow (display->display, TermWin.parent[0]); |
3487 | XRaiseWindow (disp, TermWin.parent[0]); |
3420 | break; |
3488 | break; |
3421 | case 6: /* lower window */ |
3489 | case 6: /* lower window */ |
3422 | XLowerWindow (display->display, TermWin.parent[0]); |
3490 | XLowerWindow (disp, TermWin.parent[0]); |
3423 | break; |
3491 | break; |
3424 | case 7: /* refresh window */ |
3492 | case 7: /* refresh window */ |
3425 | scr_touch (true); |
3493 | scr_touch (true); |
3426 | break; |
3494 | break; |
3427 | case 8: /* set size (chars) */ |
3495 | case 8: /* set size (chars) */ |
… | |
… | |
3439 | |
3507 | |
3440 | /* |
3508 | /* |
3441 | * reports - some output format copied from XTerm |
3509 | * reports - some output format copied from XTerm |
3442 | */ |
3510 | */ |
3443 | case 11: /* report window state */ |
3511 | case 11: /* report window state */ |
3444 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3512 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3445 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3513 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3446 | break; |
3514 | break; |
3447 | case 13: /* report window position */ |
3515 | case 13: /* report window position */ |
3448 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3516 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3449 | XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, |
3517 | XTranslateCoordinates (disp, TermWin.parent[0], wattr.root, |
3450 | -wattr.border_width, -wattr.border_width, |
3518 | -wattr.border_width, -wattr.border_width, |
3451 | &x, &y, &wdummy); |
3519 | &x, &y, &wdummy); |
3452 | tt_printf ("\033[3;%d;%dt", x, y); |
3520 | tt_printf ("\033[3;%d;%dt", x, y); |
3453 | break; |
3521 | break; |
3454 | case 14: /* report window size (pixels) */ |
3522 | case 14: /* report window size (pixels) */ |
3455 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3523 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3456 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3524 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3457 | break; |
3525 | break; |
3458 | case 18: /* report text area size (chars) */ |
3526 | case 18: /* report text area size (chars) */ |
3459 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3527 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3460 | break; |
3528 | break; |
… | |
… | |
3462 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3530 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3463 | break; |
3531 | break; |
3464 | case 20: /* report icon label */ |
3532 | case 20: /* report icon label */ |
3465 | { |
3533 | { |
3466 | char *s; |
3534 | char *s; |
3467 | XGetIconName (display->display, TermWin.parent[0], &s); |
3535 | XGetIconName (disp, TermWin.parent[0], &s); |
3468 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3536 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3469 | XFree (s); |
3537 | XFree (s); |
3470 | } |
3538 | } |
3471 | break; |
3539 | break; |
3472 | case 21: /* report window title */ |
3540 | case 21: /* report window title */ |
3473 | { |
3541 | { |
3474 | char *s; |
3542 | char *s; |
3475 | XFetchName (display->display, TermWin.parent[0], &s); |
3543 | XFetchName (disp, TermWin.parent[0], &s); |
3476 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3544 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3477 | XFree (s); |
3545 | XFree (s); |
3478 | } |
3546 | } |
3479 | break; |
3547 | break; |
3480 | } |
3548 | } |
… | |
… | |
3487 | * ends_how is terminator used. returned input must be free()'d |
3555 | * ends_how is terminator used. returned input must be free()'d |
3488 | */ |
3556 | */ |
3489 | unsigned char * |
3557 | unsigned char * |
3490 | rxvt_term::get_to_st (unicode_t &ends_how) |
3558 | rxvt_term::get_to_st (unicode_t &ends_how) |
3491 | { |
3559 | { |
3492 | unicode_t prev = 0, ch; |
3560 | unicode_t ch; |
|
|
3561 | bool seen_esc = false; |
3493 | unsigned int n = 0; |
3562 | unsigned int n = 0; |
3494 | unsigned char *s; |
|
|
3495 | unsigned char string[STRING_MAX]; |
3563 | wchar_t string[STRING_MAX]; |
3496 | |
3564 | |
3497 | while ((ch = cmd_getc ()) != NOCHAR) |
3565 | while ((ch = cmd_getc ()) != NOCHAR) |
3498 | { |
3566 | { |
3499 | if (prev == C0_ESC) |
3567 | if (seen_esc) |
3500 | { |
3568 | { |
3501 | if (ch == 0x5c) /* 7bit ST */ |
3569 | if (ch == 0x5c) /* 7bit ST */ |
3502 | break; |
3570 | break; |
3503 | else |
3571 | else |
3504 | return NULL; |
3572 | return NULL; |
3505 | } |
3573 | } |
|
|
3574 | else if (ch == C0_ESC) |
|
|
3575 | { |
|
|
3576 | seen_esc = true; |
|
|
3577 | continue; |
|
|
3578 | } |
3506 | else if (ch == C0_BEL || ch == CHAR_ST) |
3579 | else if (ch == C0_BEL || ch == CHAR_ST) |
3507 | break; |
3580 | break; |
3508 | else if (ch < 0x20) |
3581 | else if (ch < 0x20) |
3509 | return NULL; /* other control character - exit */ |
3582 | return NULL; /* other control character - exit */ |
|
|
3583 | |
|
|
3584 | seen_esc = false; |
3510 | |
3585 | |
3511 | if (n >= sizeof (string) - 1) |
3586 | if (n >= sizeof (string) - 1) |
3512 | // stop at some sane length |
3587 | // stop at some sane length |
3513 | return NULL; |
3588 | return NULL; |
3514 | |
3589 | |
3515 | if (ch == C0_SYN) |
3590 | if (ch == C0_SYN) |
3516 | { |
|
|
3517 | string[n++] = cmd_get8 (); |
3591 | string[n++] = cmd_get8 (); |
3518 | prev = 0; |
|
|
3519 | } |
|
|
3520 | else |
3592 | else |
3521 | string[n++] = prev = ch; |
3593 | string[n++] = ch; |
3522 | } |
3594 | } |
3523 | |
3595 | |
3524 | string[n++] = '\0'; |
3596 | string[n++] = '\0'; |
3525 | |
3597 | |
3526 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3527 | return NULL; |
|
|
3528 | |
|
|
3529 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3598 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3530 | strncpy (s, string, n); |
3599 | |
3531 | return s; |
3600 | return (unsigned char *)rxvt_wcstombs (string); |
3532 | } |
3601 | } |
3533 | |
3602 | |
3534 | /*----------------------------------------------------------------------*/ |
3603 | /*----------------------------------------------------------------------*/ |
3535 | /* |
3604 | /* |
3536 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3605 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3620 | { |
3689 | { |
3621 | int changed = 0; |
3690 | int changed = 0; |
3622 | int color; |
3691 | int color; |
3623 | char *buf, *name; |
3692 | char *buf, *name; |
3624 | bool query = str[0] == '?' && !str[1]; |
3693 | bool query = str[0] == '?' && !str[1]; |
|
|
3694 | int saveop = op; |
|
|
3695 | dDisp; |
3625 | |
3696 | |
3626 | assert (str != NULL); |
3697 | assert (str != NULL); |
3627 | switch (op) |
3698 | switch (op) |
3628 | { |
3699 | { |
3629 | case XTerm_name: |
3700 | case XTerm_name: |
… | |
… | |
3636 | set_title (str); |
3707 | set_title (str); |
3637 | break; |
3708 | break; |
3638 | case XTerm_property: |
3709 | case XTerm_property: |
3639 | if (str[0] == '?') |
3710 | if (str[0] == '?') |
3640 | { |
3711 | { |
3641 | Atom prop = XInternAtom (display->display, str + 1, True); |
3712 | Atom prop = display->atom (str + 1); |
3642 | Atom actual_type; |
3713 | Atom actual_type; |
3643 | int actual_format; |
3714 | int actual_format; |
3644 | unsigned long nitems; |
3715 | unsigned long nitems; |
3645 | unsigned long bytes_after; |
3716 | unsigned long bytes_after; |
3646 | unsigned char *value = 0; |
3717 | unsigned char *value = 0; |
3647 | const char *str = ""; |
3718 | const char *str = ""; |
3648 | |
3719 | |
3649 | if (prop |
3720 | if (prop |
3650 | && XGetWindowProperty (display->display, TermWin.parent[0], |
3721 | && XGetWindowProperty (disp, TermWin.parent[0], |
3651 | prop, 0, 1<<16, 0, AnyPropertyType, |
3722 | prop, 0, 1<<16, 0, AnyPropertyType, |
3652 | &actual_type, &actual_format, |
3723 | &actual_type, &actual_format, |
3653 | &nitems, &bytes_after, &value) == Success |
3724 | &nitems, &bytes_after, &value) == Success |
3654 | && actual_type != None |
3725 | && actual_type != None |
3655 | && actual_format == 8) |
3726 | && actual_format == 8) |
… | |
… | |
3664 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3735 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3665 | |
3736 | |
3666 | if (eq) |
3737 | if (eq) |
3667 | { |
3738 | { |
3668 | *eq = 0; |
3739 | *eq = 0; |
3669 | XChangeProperty (display->display, TermWin.parent[0], |
3740 | set_utf8_property (display->atom (str), eq + 1); |
3670 | display->atom (str), XA_STRING, 8, |
|
|
3671 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3672 | strlen (eq + 1)); |
|
|
3673 | } |
3741 | } |
3674 | else |
3742 | else |
3675 | XDeleteProperty (display->display, TermWin.parent[0], |
3743 | XDeleteProperty (disp, TermWin.parent[0], |
3676 | display->atom (str)); |
3744 | display->atom (str)); |
3677 | } |
3745 | } |
3678 | break; |
3746 | break; |
3679 | |
3747 | |
3680 | case XTerm_Color: |
3748 | case XTerm_Color: |
… | |
… | |
3721 | break; |
3789 | break; |
3722 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3790 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3723 | case XTerm_Color_BD: |
3791 | case XTerm_Color_BD: |
3724 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3792 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3725 | break; |
3793 | break; |
|
|
3794 | case XTerm_Color_IT: |
|
|
3795 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3796 | break; |
3726 | case XTerm_Color_UL: |
3797 | case XTerm_Color_UL: |
3727 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3798 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3728 | break; |
3799 | break; |
3729 | case XTerm_Color_RV: |
3800 | case XTerm_Color_RV: |
3730 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3801 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3802 | break; |
|
|
3803 | #endif |
|
|
3804 | #if TRANSPARENT && TINTING |
|
|
3805 | case XTerm_Color_tint: |
|
|
3806 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
|
|
3807 | check_our_parents (); |
|
|
3808 | if (am_transparent) |
|
|
3809 | want_full_refresh = want_refresh = 1; |
3731 | break; |
3810 | break; |
3732 | #endif |
3811 | #endif |
3733 | |
3812 | |
3734 | case XTerm_Pixmap: |
3813 | case XTerm_Pixmap: |
3735 | if (*str != ';') |
3814 | if (*str != ';') |
… | |
… | |
3744 | { |
3823 | { |
3745 | str++; |
3824 | str++; |
3746 | #if XPM_BACKGROUND |
3825 | #if XPM_BACKGROUND |
3747 | changed += scale_pixmap (str); |
3826 | changed += scale_pixmap (str); |
3748 | #endif |
3827 | #endif |
3749 | |
|
|
3750 | } |
3828 | } |
|
|
3829 | |
3751 | if (changed) |
3830 | if (changed) |
3752 | { |
3831 | { |
3753 | #ifdef XPM_BACKGROUND |
3832 | #ifdef XPM_BACKGROUND |
3754 | resize_pixmap (); |
3833 | resize_pixmap (); |
3755 | #endif |
3834 | #endif |
… | |
… | |
3767 | case XTerm_logfile: |
3846 | case XTerm_logfile: |
3768 | // TODO, when secure mode? |
3847 | // TODO, when secure mode? |
3769 | break; |
3848 | break; |
3770 | |
3849 | |
3771 | case XTerm_font: |
3850 | case XTerm_font: |
|
|
3851 | op = URxvt_font; |
|
|
3852 | case URxvt_font: |
|
|
3853 | #if ENABLE_STYLES |
|
|
3854 | case URxvt_boldFont: |
|
|
3855 | case URxvt_italicFont: |
|
|
3856 | case URxvt_boldItalicFont: |
|
|
3857 | #endif |
3772 | if (query) |
3858 | if (query) |
3773 | tt_printf ("\33]%d;%-.250s%c", XTerm_font, |
3859 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3774 | (options & Opt_insecure) && TermWin.fontset->fontdesc |
3860 | (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc |
3775 | ? TermWin.fontset->fontdesc : "", |
3861 | ? TermWin.fontset[op - URxvt_font]->fontdesc : "", |
3776 | resp); |
3862 | resp); |
3777 | else |
3863 | else |
|
|
3864 | { |
|
|
3865 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
|
|
3866 | |
|
|
3867 | res = strdup (str); |
|
|
3868 | allocated.push_back ((void *)res); |
3778 | change_font (str); |
3869 | set_fonts (); |
|
|
3870 | } |
3779 | break; |
3871 | break; |
3780 | |
3872 | |
3781 | #if ENABLE_FRILLS |
3873 | #if ENABLE_FRILLS |
3782 | case XTerm_locale: |
3874 | case XTerm_locale: |
3783 | if (query) |
3875 | if (query) |
3784 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3876 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3785 | else |
3877 | else |
3786 | { |
3878 | { |
3787 | set_locale (str); |
3879 | set_locale (str); |
|
|
3880 | pty.set_utf8_mode (enc_utf8); |
3788 | # ifdef USE_XIM |
3881 | # ifdef USE_XIM |
3789 | im_cb (); |
3882 | im_cb (); |
3790 | # endif |
3883 | # endif |
3791 | } |
3884 | } |
3792 | break; |
|
|
3793 | |
|
|
3794 | case XTerm_findfont: |
|
|
3795 | { |
|
|
3796 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3797 | tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont, |
|
|
3798 | fid, |
|
|
3799 | (options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "", |
|
|
3800 | resp); |
|
|
3801 | } |
|
|
3802 | break; |
3885 | break; |
3803 | #endif |
3886 | #endif |
3804 | |
3887 | |
3805 | #ifdef MENUBAR |
3888 | #ifdef MENUBAR |
3806 | case XTerm_Menu: |
3889 | case XTerm_Menu: |
… | |
… | |
3935 | |
4018 | |
3936 | /* extra handling for values with state unkept */ |
4019 | /* extra handling for values with state unkept */ |
3937 | switch (arg[i]) |
4020 | switch (arg[i]) |
3938 | { |
4021 | { |
3939 | case 1048: /* alternative cursor save */ |
4022 | case 1048: /* alternative cursor save */ |
|
|
4023 | case 1049: |
3940 | if (options & Opt_secondaryScreen) |
4024 | if (options & Opt_secondaryScreen) |
3941 | if (mode == 0) |
4025 | if (mode == 0) |
3942 | scr_cursor (RESTORE); |
4026 | scr_cursor (RESTORE); |
3943 | else if (mode == 1) |
4027 | else if (mode == 1) |
3944 | scr_cursor (SAVE); |
4028 | scr_cursor (SAVE); |
… | |
… | |
4069 | rendset = 0, rendstyle = ~RS_None; |
4153 | rendset = 0, rendstyle = ~RS_None; |
4070 | break; |
4154 | break; |
4071 | case 1: |
4155 | case 1: |
4072 | rendset = 1, rendstyle = RS_Bold; |
4156 | rendset = 1, rendstyle = RS_Bold; |
4073 | break; |
4157 | break; |
4074 | //case 2: // faint or second colour |
4158 | //case 2: // low intensity |
4075 | //case 3: // italic |
4159 | case 3: |
|
|
4160 | rendset = 1, rendstyle = RS_Italic; |
|
|
4161 | break; |
4076 | case 4: |
4162 | case 4: |
4077 | rendset = 1, rendstyle = RS_Uline; |
4163 | rendset = 1, rendstyle = RS_Uline; |
4078 | break; |
4164 | break; |
4079 | case 5: // slowly blinking |
4165 | case 5: // slowly blinking |
4080 | case 6: // rapidly blinking |
4166 | case 6: // rapidly blinking |
… | |
… | |
4092 | //case 11: // scoansi acs on, first alt font |
4178 | //case 11: // scoansi acs on, first alt font |
4093 | //case 12: // scoansi acs on, |0x80, second alt font |
4179 | //case 12: // scoansi acs on, |0x80, second alt font |
4094 | //... |
4180 | //... |
4095 | //case 19: // ninth alt font |
4181 | //case 19: // ninth alt font |
4096 | //case 20: // gothic |
4182 | //case 20: // gothic |
4097 | case 21: // disable bold, faint |
4183 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
4098 | rendset = 0, rendstyle = RS_Bold; |
4184 | rendset = 0, rendstyle = RS_Bold; |
4099 | break; |
4185 | break; |
4100 | case 22: |
4186 | case 22: // normal intensity |
4101 | rendset = 0, rendstyle = RS_Bold; |
4187 | rendset = 0, rendstyle = RS_Bold; |
4102 | break; |
4188 | break; |
4103 | //case 23: disable italic |
4189 | case 23: // disable italic |
|
|
4190 | rendset = 0, rendstyle = RS_Italic; |
|
|
4191 | break; |
4104 | case 24: |
4192 | case 24: |
4105 | rendset = 0, rendstyle = RS_Uline; |
4193 | rendset = 0, rendstyle = RS_Uline; |
4106 | break; |
4194 | break; |
4107 | case 25: |
4195 | case 25: |
4108 | rendset = 0, rendstyle = RS_Blink; |
4196 | rendset = 0, rendstyle = RS_Blink; |
4109 | break; |
4197 | break; |
4110 | case 26: |
4198 | case 26: // variable spacing (iso 8613) |
4111 | rendset = 0, rendstyle = RS_Blink; |
4199 | rendset = 0, rendstyle = RS_Blink; |
4112 | break; |
4200 | break; |
4113 | case 27: |
4201 | case 27: |
4114 | rendset = 0, rendstyle = RS_RVid; |
4202 | rendset = 0, rendstyle = RS_RVid; |
4115 | break; |
4203 | break; |
… | |
… | |
4133 | case 35: |
4221 | case 35: |
4134 | case 36: |
4222 | case 36: |
4135 | case 37: |
4223 | case 37: |
4136 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4224 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4137 | break; |
4225 | break; |
4138 | #ifdef TTY_256COLOR |
4226 | case 38: // set fg color, ISO 8613-6 |
4139 | case 38: |
|
|
4140 | if (nargs > i + 2 && arg[i + 1] == 5) |
4227 | if (nargs > i + 2 && arg[i + 1] == 5) |
4141 | { |
4228 | { |
4142 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4229 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4143 | i += 2; |
4230 | i += 2; |
4144 | } |
4231 | } |
4145 | break; |
4232 | break; |
4146 | #endif |
|
|
4147 | case 39: /* default fg */ |
4233 | case 39: /* default fg */ |
4148 | scr_color (Color_fg, Color_fg); |
4234 | scr_color (Color_fg, Color_fg); |
4149 | break; |
4235 | break; |
4150 | |
4236 | |
4151 | case 40: |
4237 | case 40: |
… | |
… | |
4156 | case 45: |
4242 | case 45: |
4157 | case 46: |
4243 | case 46: |
4158 | case 47: |
4244 | case 47: |
4159 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4245 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4160 | break; |
4246 | break; |
4161 | #ifdef TTY_256COLOR |
4247 | case 48: // set bg color, ISO 8613-6 |
4162 | case 48: |
|
|
4163 | if (nargs > i + 2 && arg[i + 1] == 5) |
4248 | if (nargs > i + 2 && arg[i + 1] == 5) |
4164 | { |
4249 | { |
4165 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4250 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4166 | i += 2; |
4251 | i += 2; |
4167 | } |
4252 | } |
4168 | break; |
4253 | break; |
4169 | #endif |
|
|
4170 | case 49: /* default bg */ |
4254 | case 49: /* default bg */ |
4171 | scr_color (Color_bg, Color_bg); |
4255 | scr_color (Color_bg, Color_bg); |
4172 | break; |
4256 | break; |
|
|
4257 | |
|
|
4258 | //case 50: // not variable spacing |
4173 | |
4259 | |
4174 | #ifndef NO_BRIGHTCOLOR |
4260 | #ifndef NO_BRIGHTCOLOR |
4175 | case 90: |
4261 | case 90: |
4176 | case 91: /* set bright fg color */ |
4262 | case 91: /* set bright fg color */ |
4177 | case 92: |
4263 | case 92: |
4178 | case 93: |
4264 | case 93: |
4179 | case 94: |
4265 | case 94: |
4180 | case 95: |
4266 | case 95: |
4181 | case 96: |
4267 | case 96: |
4182 | case 97: |
4268 | case 97: |
4183 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), |
4269 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); |
4184 | Color_fg); |
|
|
4185 | break; |
4270 | break; |
4186 | case 100: |
4271 | case 100: |
4187 | case 101: /* set bright bg color */ |
4272 | case 101: /* set bright bg color */ |
4188 | case 102: |
4273 | case 102: |
4189 | case 103: |
4274 | case 103: |
4190 | case 104: |
4275 | case 104: |
4191 | case 105: |
4276 | case 105: |
4192 | case 106: |
4277 | case 106: |
4193 | case 107: |
4278 | case 107: |
4194 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), |
4279 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4195 | Color_bg); |
|
|
4196 | break; |
4280 | break; |
4197 | #endif |
4281 | #endif |
4198 | |
4282 | |
4199 | } |
4283 | } |
4200 | } |
4284 | } |
… | |
… | |
4239 | |
4323 | |
4240 | /* ---------------------------------------------------------------------- */ |
4324 | /* ---------------------------------------------------------------------- */ |
4241 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4325 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4242 | * or generated by us in response to a query ESC sequence. |
4326 | * or generated by us in response to a query ESC sequence. |
4243 | */ |
4327 | */ |
|
|
4328 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4329 | |
4244 | void |
4330 | void |
4245 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4331 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4246 | { |
4332 | { |
4247 | enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT |
4333 | if (v_buflen == 0) |
|
|
4334 | { |
|
|
4335 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4248 | |
4336 | |
4249 | if (len) |
4337 | if ((unsigned int)written == len) |
|
|
4338 | return; |
|
|
4339 | |
|
|
4340 | data += written; |
|
|
4341 | len -= written; |
4250 | { |
4342 | } |
|
|
4343 | |
|
|
4344 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4345 | |
|
|
4346 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4347 | v_buflen += len; |
|
|
4348 | |
|
|
4349 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4350 | } |
|
|
4351 | |
|
|
4352 | void rxvt_term::pty_write () |
|
|
4353 | { |
|
|
4354 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4355 | |
|
|
4356 | if (written > 0) |
|
|
4357 | { |
|
|
4358 | v_buflen -= written; |
|
|
4359 | |
4251 | if (v_buflen == 0) |
4360 | if (v_buflen == 0) |
4252 | { |
4361 | { |
4253 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4254 | |
|
|
4255 | if ((unsigned int)written == len) |
|
|
4256 | return; |
|
|
4257 | |
|
|
4258 | data += written; |
|
|
4259 | len -= written; |
|
|
4260 | } |
|
|
4261 | |
|
|
4262 | |
|
|
4263 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4264 | |
|
|
4265 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4266 | v_buflen += len; |
|
|
4267 | } |
|
|
4268 | |
|
|
4269 | for (;;) |
|
|
4270 | { |
|
|
4271 | int written = write (pty.pty, v_buffer, min (MAX_PTY_WRITE, v_buflen)); |
|
|
4272 | |
|
|
4273 | if (written > 0) |
|
|
4274 | { |
|
|
4275 | v_buflen -= written; |
|
|
4276 | |
|
|
4277 | if (v_buflen == 0) |
|
|
4278 | { |
|
|
4279 | free (v_buffer); |
4362 | free (v_buffer); |
4280 | v_buffer = 0; |
4363 | v_buffer = 0; |
4281 | v_buflen = 0; |
4364 | v_buflen = 0; |
4282 | |
4365 | |
4283 | pty_ev.set (EVENT_READ); |
4366 | pty_ev.set (EVENT_READ); |
4284 | return; |
|
|
4285 | } |
|
|
4286 | |
|
|
4287 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4288 | } |
|
|
4289 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4290 | // original code just ignores this... |
|
|
4291 | destroy (); |
|
|
4292 | else |
|
|
4293 | { |
|
|
4294 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4295 | return; |
4367 | return; |
4296 | } |
4368 | } |
|
|
4369 | |
|
|
4370 | memmove (v_buffer, v_buffer + written, v_buflen); |
4297 | } |
4371 | } |
|
|
4372 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4373 | // original code just ignores this... |
|
|
4374 | destroy (); |
4298 | } |
4375 | } |
4299 | |
4376 | |
4300 | /*----------------------- end-of-file (C source) -----------------------*/ |
4377 | /*----------------------- end-of-file (C source) -----------------------*/ |
4301 | |
4378 | |