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> |
… | |
… | |
49 | #include "rxvt.h" |
49 | #include "rxvt.h" |
50 | #include "rxvtperl.h" |
50 | #include "rxvtperl.h" |
51 | #include "version.h" |
51 | #include "version.h" |
52 | #include "command.h" |
52 | #include "command.h" |
53 | |
53 | |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
60 | # include "keyboard.h" |
55 | # include "keyboard.h" |
61 | #endif |
56 | #endif |
62 | |
57 | |
63 | #include <csignal> |
58 | #include <csignal> |
64 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
65 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
66 | |
65 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
67 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
69 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
144 | return; |
149 | |
145 | |
150 | for (;;) |
146 | for (;;) |
151 | { |
147 | { |
152 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
153 | |
149 | |
154 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
155 | |
151 | |
156 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
157 | { |
153 | { |
… | |
… | |
230 | # if !UNICODE3 |
226 | # if !UNICODE3 |
231 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
232 | ch = 0xfffd; |
228 | ch = 0xfffd; |
233 | # endif |
229 | # endif |
234 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
235 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
236 | } |
234 | } |
237 | |
235 | |
|
|
236 | // { |
|
|
237 | // char buf[4+4+3+1]; |
|
|
238 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
239 | // scr_overlay_set (0, 0, buf); |
|
|
240 | // } |
238 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
239 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
240 | |
243 | |
241 | free (fname); |
244 | free (fname); |
242 | |
245 | |
… | |
… | |
295 | |
298 | |
296 | return -1; |
299 | return -1; |
297 | } |
300 | } |
298 | #endif |
301 | #endif |
299 | |
302 | |
300 | /*{{{ Convert the keypress event into a string */ |
|
|
301 | void |
303 | void |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
304 | rxvt_term::key_press (XKeyEvent &ev) |
303 | { |
305 | { |
304 | int ctrl, meta, shft, len; |
306 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
307 | unsigned int newlen; |
306 | KeySym keysym; |
308 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
309 | int valid_keysym; |
311 | char kbuf[KBUFSZ]; |
310 | char kbuf[KBUFSZ]; |
|
|
311 | |
|
|
312 | #if ISO_14755 |
|
|
313 | if (iso14755buf & ISO_14755_52) |
|
|
314 | return; |
|
|
315 | #endif |
312 | |
316 | |
313 | /* |
317 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
318 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
315 | * escape sequence to toggle the Keypad. |
319 | * escape sequence to toggle the Keypad. |
316 | * |
320 | * |
… | |
… | |
443 | scr_move_to (0, 1); |
447 | scr_move_to (0, 1); |
444 | return; |
448 | return; |
445 | } |
449 | } |
446 | else if (keysym == XK_End) |
450 | else if (keysym == XK_End) |
447 | { |
451 | { |
448 | scr_move_to (1, 0); |
452 | scr_move_to (1, 1); |
449 | return; |
453 | return; |
450 | } |
454 | } |
451 | } |
455 | } |
452 | #endif |
456 | #endif |
453 | } |
457 | } |
… | |
… | |
464 | { |
468 | { |
465 | switch (keysym) |
469 | switch (keysym) |
466 | { |
470 | { |
467 | /* normal XTerm key bindings */ |
471 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
472 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
473 | selection_request (ev.time); |
470 | return; |
474 | return; |
471 | #if TODO |
475 | #if TODO |
472 | /* rxvt extras */ |
476 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
477 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
478 | change_font (FONT_UP); |
… | |
… | |
493 | { |
497 | { |
494 | commit_iso14755 (); |
498 | commit_iso14755 (); |
495 | iso14755buf = ISO_14755_51; |
499 | iso14755buf = ISO_14755_51; |
496 | # if ISO_14755 |
500 | # if ISO_14755 |
497 | iso14755_51 (0); |
501 | iso14755_51 (0); |
|
|
502 | # endif |
|
|
503 | return; |
|
|
504 | } |
|
|
505 | else if (keysym == XK_BackSpace) |
|
|
506 | { |
|
|
507 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
508 | # if ISO_14755 |
|
|
509 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
498 | # endif |
510 | # endif |
499 | return; |
511 | return; |
500 | } |
512 | } |
501 | else if ((hv = hex_keyval (ev)) >= 0) |
513 | else if ((hv = hex_keyval (ev)) >= 0) |
502 | { |
514 | { |
… | |
… | |
524 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
536 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
525 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
537 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
526 | # endif |
538 | # endif |
527 | } |
539 | } |
528 | #endif |
540 | #endif |
529 | |
541 | |
530 | #ifdef PRINTPIPE |
542 | #ifdef PRINTPIPE |
531 | if (keysym == XK_Print) |
543 | if (keysym == XK_Print) |
532 | { |
544 | { |
533 | scr_printscreen (ctrl | shft); |
545 | scr_printscreen (ctrl | shft); |
534 | return; |
546 | return; |
… | |
… | |
873 | return; |
885 | return; |
874 | |
886 | |
875 | if (len <= 0) |
887 | if (len <= 0) |
876 | return; /* not mapped */ |
888 | return; /* not mapped */ |
877 | |
889 | |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
890 | if (option (Opt_scrollTtyKeypress)) |
879 | if (view_start) |
891 | if (view_start) |
880 | { |
892 | { |
881 | view_start = 0; |
893 | view_start = 0; |
882 | want_refresh = 1; |
894 | want_refresh = 1; |
883 | } |
895 | } |
… | |
… | |
905 | { |
917 | { |
906 | const char ch = C0_ESC; |
918 | const char ch = C0_ESC; |
907 | tt_write (&ch, 1); |
919 | tt_write (&ch, 1); |
908 | } |
920 | } |
909 | |
921 | |
910 | #if defined(DEBUG_CMD) |
|
|
911 | /* Display keyboard buffer contents */ |
|
|
912 | unsigned char *p; |
|
|
913 | int i; |
|
|
914 | |
|
|
915 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
916 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
917 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
918 | fprintf (stderr, "'\n"); |
|
|
919 | #endif /* DEBUG_CMD */ |
|
|
920 | tt_write (kbuf, (unsigned int)len); |
922 | tt_write (kbuf, (unsigned int)len); |
921 | } |
923 | } |
922 | /*}}} */ |
|
|
923 | |
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 ENABLE_OVERLAY |
|
|
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 ENABLE_OVERLAY |
|
|
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 | |
924 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
1002 | #if defined (KEYSYM_RESOURCE) |
925 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
926 | /* attempt to `write' count to the input buffer */ |
|
|
927 | unsigned int |
1003 | unsigned int |
928 | rxvt_term::cmd_write (const char *str, unsigned int count) |
1004 | rxvt_term::cmd_write (const char *str, unsigned int count) |
929 | { |
1005 | { |
930 | unsigned int n, s; |
1006 | unsigned int n, s; |
931 | |
1007 | |
… | |
… | |
972 | |
1048 | |
973 | if (want_refresh) |
1049 | if (want_refresh) |
974 | { |
1050 | { |
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
1051 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
976 | { |
1052 | { |
977 | int row = -view_start; |
1053 | int row = view_start; |
978 | int end_row = row + nrow; |
1054 | int end_row = row + nrow; |
979 | |
1055 | |
980 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
1056 | while (row > top_row && ROW (row - 1).is_longer ()) |
981 | --row; |
1057 | --row; |
982 | |
1058 | |
983 | do |
1059 | do |
984 | { |
1060 | { |
985 | int start_row = row; |
1061 | int start_row = row; |
… | |
… | |
1008 | while (l->is_longer () && row < end_row); |
1084 | while (l->is_longer () && row < end_row); |
1009 | } |
1085 | } |
1010 | while (row < end_row); |
1086 | while (row < end_row); |
1011 | } |
1087 | } |
1012 | |
1088 | |
1013 | scr_refresh (refresh_type); |
1089 | scr_refresh (); |
1014 | scrollbar_show (1); |
1090 | scrollbar_show (1); |
1015 | #ifdef USE_XIM |
1091 | #ifdef USE_XIM |
1016 | IMSendSpot (); |
1092 | IMSendSpot (); |
1017 | #endif |
1093 | #endif |
1018 | } |
1094 | } |
… | |
… | |
1021 | } |
1097 | } |
1022 | |
1098 | |
1023 | void |
1099 | void |
1024 | rxvt_term::check_cb (check_watcher &w) |
1100 | rxvt_term::check_cb (check_watcher &w) |
1025 | { |
1101 | { |
1026 | SET_R (this); |
1102 | make_current (); |
1027 | SET_LOCALE (locale); |
|
|
1028 | |
1103 | |
1029 | display->flush (); |
1104 | display->flush (); |
1030 | |
1105 | |
1031 | if (want_refresh && !flush_ev.active) |
1106 | if (want_refresh && !flush_ev.active) |
1032 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1107 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1033 | } |
1108 | } |
1034 | |
1109 | |
1035 | void |
1110 | void |
1036 | rxvt_term::flush_cb (time_watcher &w) |
1111 | rxvt_term::flush_cb (time_watcher &w) |
1037 | { |
1112 | { |
1038 | SET_R (this); |
1113 | make_current (); |
1039 | SET_LOCALE (locale); |
|
|
1040 | |
1114 | |
1041 | refresh_limit = 1; |
|
|
1042 | refresh_count = 0; |
1115 | refresh_count = 0; |
1043 | flush (); |
1116 | flush (); |
1044 | } |
1117 | } |
1045 | |
1118 | |
1046 | #ifdef CURSOR_BLINK |
1119 | #ifdef CURSOR_BLINK |
… | |
… | |
1048 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1121 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1049 | { |
1122 | { |
1050 | hidden_cursor = !hidden_cursor; |
1123 | hidden_cursor = !hidden_cursor; |
1051 | want_refresh = 1; |
1124 | want_refresh = 1; |
1052 | |
1125 | |
1053 | w.start (w.at + BLINK_INTERVAL); |
1126 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1054 | } |
1127 | } |
1055 | #endif |
1128 | #endif |
1056 | |
1129 | |
1057 | #ifdef TEXT_BLINK |
1130 | #ifdef TEXT_BLINK |
1058 | void |
1131 | void |
… | |
… | |
1072 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1145 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1073 | { |
1146 | { |
1074 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1147 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1075 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1148 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1076 | { |
1149 | { |
1077 | refresh_type |= SMOOTH_REFRESH; |
|
|
1078 | want_refresh = 1; |
1150 | want_refresh = 1; |
1079 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1151 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1080 | } |
1152 | } |
1081 | } |
1153 | } |
1082 | #endif |
1154 | #endif |
… | |
… | |
1086 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1158 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1087 | { |
1159 | { |
1088 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1160 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1089 | { |
1161 | { |
1090 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1162 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1091 | refresh_type |= SMOOTH_REFRESH; |
|
|
1092 | want_refresh = 1; |
1163 | want_refresh = 1; |
1093 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1164 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1094 | } |
1165 | } |
1095 | } |
1166 | } |
1096 | #endif |
1167 | #endif |
… | |
… | |
1101 | { |
1172 | { |
1102 | if (mouse_slip_wheel_speed == 0 |
1173 | if (mouse_slip_wheel_speed == 0 |
1103 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1174 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1104 | : scr_page (UP, mouse_slip_wheel_speed)) |
1175 | : scr_page (UP, mouse_slip_wheel_speed)) |
1105 | { |
1176 | { |
1106 | if (view_start == nsaved || |
1177 | if (view_start == top_row || view_start == 0) |
1107 | view_start == 0) |
|
|
1108 | mouse_slip_wheel_speed = 0; |
1178 | mouse_slip_wheel_speed = 0; |
1109 | |
1179 | |
1110 | refresh_type |= SMOOTH_REFRESH; |
|
|
1111 | want_refresh = 1; |
1180 | want_refresh = 1; |
1112 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1181 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1113 | } |
1182 | } |
1114 | } |
1183 | } |
1115 | #endif |
1184 | #endif |
1116 | |
1185 | |
1117 | #if HAVE_SCHED_YIELD |
1186 | #if LINUX_YIELD_HACK |
1118 | static struct event_handler |
1187 | static struct event_handler |
1119 | { |
1188 | { |
1120 | check_watcher cw_yield; |
1189 | check_watcher yield_ev; |
1121 | |
1190 | |
1122 | void yield (check_watcher &w) |
1191 | void yield_cb (check_watcher &w) |
1123 | { |
1192 | { |
1124 | sched_yield (); |
1193 | // this should really be sched_yield(), but the linux guys thought |
|
|
1194 | // that giving a process calling sched_yield () less cpu time than |
|
|
1195 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1196 | // allowed by the sus... as is returning ENOSYS. |
|
|
1197 | |
|
|
1198 | struct timespec ts = { 0, 0 }; |
|
|
1199 | nanosleep (&ts, 0); |
|
|
1200 | |
1125 | w.stop (); |
1201 | w.stop (); |
1126 | } |
1202 | } |
1127 | |
1203 | |
1128 | event_handler () |
1204 | event_handler () |
1129 | : cw_yield (this, &event_handler::yield) |
1205 | : yield_ev (this, &event_handler::yield_cb) |
1130 | { |
1206 | { |
1131 | } |
1207 | } |
1132 | } event_handler; |
1208 | } event_handler; |
1133 | #endif |
1209 | #endif |
1134 | |
1210 | |
… | |
… | |
1145 | |
1221 | |
1146 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1222 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1147 | cmdbuf_ptr = cmdbuf_base; |
1223 | cmdbuf_ptr = cmdbuf_base; |
1148 | cmdbuf_endp = cmdbuf_ptr + n; |
1224 | cmdbuf_endp = cmdbuf_ptr + n; |
1149 | |
1225 | |
1150 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1226 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1151 | |
1227 | |
1152 | if (r > 0) |
1228 | if (r > 0) |
1153 | { |
1229 | { |
1154 | cmdbuf_endp += r; |
1230 | cmdbuf_endp += r; |
1155 | return true; |
1231 | return true; |
1156 | } |
1232 | } |
1157 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1233 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1158 | { |
1234 | { |
1159 | #if HAVE_SCHED_YIELD |
1235 | #if LINUX_YIELD_HACK |
1160 | if (display->is_local) |
1236 | if (display->is_local) |
1161 | event_handler.cw_yield.start (); |
1237 | event_handler.yield_ev.start (); |
1162 | #endif |
1238 | #endif |
1163 | } |
1239 | } |
1164 | else |
1240 | else |
1165 | { |
1241 | { |
1166 | pty_ev.stop (); |
1242 | pty_ev.stop (); |
1167 | |
1243 | |
1168 | if (!OPTION (Opt_hold)) |
1244 | if (!option (Opt_hold)) |
1169 | destroy (); |
1245 | destroy (); |
1170 | } |
1246 | } |
1171 | |
1247 | |
1172 | return false; |
1248 | return false; |
1173 | } |
1249 | } |
1174 | |
1250 | |
1175 | void |
1251 | void |
1176 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1252 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1177 | { |
1253 | { |
1178 | SET_R (this); |
1254 | make_current (); |
1179 | SET_LOCALE (locale); |
|
|
1180 | |
1255 | |
1181 | if (revents & EVENT_READ) |
1256 | if (revents & EVENT_READ) |
1182 | // loop, but don't allow a single term to monopolize us |
1257 | // loop, but don't allow a single term to monopolize us |
1183 | while (pty_fill ()) |
1258 | while (pty_fill ()) |
1184 | if (cmd_parse ()) |
1259 | if (cmd_parse ()) |
… | |
… | |
1189 | } |
1264 | } |
1190 | |
1265 | |
1191 | void |
1266 | void |
1192 | rxvt_term::pointer_unblank () |
1267 | rxvt_term::pointer_unblank () |
1193 | { |
1268 | { |
1194 | XDefineCursor (display->display, vt, TermWin_cursor); |
1269 | XDefineCursor (dpy, vt, TermWin_cursor); |
1195 | recolour_cursor (); |
1270 | recolour_cursor (); |
1196 | |
1271 | |
1197 | #ifdef POINTER_BLANK |
1272 | #ifdef POINTER_BLANK |
1198 | hidden_pointer = 0; |
1273 | hidden_pointer = 0; |
1199 | |
1274 | |
1200 | if (OPTION (Opt_pointerBlank)) |
1275 | if (option (Opt_pointerBlank)) |
1201 | pointer_ev.start (NOW + pointerBlankDelay); |
1276 | pointer_ev.start (NOW + pointerBlankDelay); |
1202 | #endif |
1277 | #endif |
1203 | } |
1278 | } |
1204 | |
1279 | |
1205 | #ifdef POINTER_BLANK |
1280 | #ifdef POINTER_BLANK |
1206 | void |
1281 | void |
1207 | rxvt_term::pointer_blank () |
1282 | rxvt_term::pointer_blank () |
1208 | { |
1283 | { |
1209 | if (!OPTION (Opt_pointerBlank)) |
1284 | if (!option (Opt_pointerBlank)) |
1210 | return; |
1285 | return; |
1211 | |
1286 | |
1212 | XDefineCursor (display->display, vt, display->blank_cursor); |
1287 | XDefineCursor (dpy, vt, display->blank_cursor); |
1213 | XFlush (display->display); |
1288 | XFlush (dpy); |
1214 | |
1289 | |
1215 | hidden_pointer = 1; |
1290 | hidden_pointer = 1; |
1216 | } |
1291 | } |
1217 | |
1292 | |
1218 | void |
1293 | void |
1219 | rxvt_term::pointer_cb (time_watcher &w) |
1294 | rxvt_term::pointer_cb (time_watcher &w) |
1220 | { |
1295 | { |
1221 | SET_R (this); |
1296 | make_current (); |
1222 | SET_LOCALE (locale); |
|
|
1223 | |
1297 | |
1224 | pointer_blank (); |
1298 | pointer_blank (); |
1225 | } |
1299 | } |
1226 | #endif |
1300 | #endif |
1227 | |
1301 | |
… | |
… | |
1292 | (32 + button_number + key_state), |
1366 | (32 + button_number + key_state), |
1293 | (32 + x + 1), |
1367 | (32 + x + 1), |
1294 | (32 + y + 1)); |
1368 | (32 + y + 1)); |
1295 | } |
1369 | } |
1296 | |
1370 | |
1297 | #ifdef USING_W11LIB |
|
|
1298 | void |
|
|
1299 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1300 | { |
|
|
1301 | rxvt_t *r = rxvt_get_r (); |
|
|
1302 | |
|
|
1303 | x_cb (*ev); |
|
|
1304 | } |
|
|
1305 | #endif |
|
|
1306 | |
|
|
1307 | /*{{{ process an X event */ |
1371 | /*{{{ process an X event */ |
1308 | void |
1372 | void |
1309 | rxvt_term::x_cb (XEvent &ev) |
1373 | rxvt_term::x_cb (XEvent &ev) |
1310 | { |
1374 | { |
1311 | dDisp; |
1375 | make_current (); |
1312 | |
1376 | |
1313 | SET_R (this); |
1377 | dLocal (Display *, dpy); |
1314 | SET_LOCALE (locale); |
|
|
1315 | |
1378 | |
1316 | if (ev.xany.window == vt |
1379 | if (ev.xany.window == vt |
|
|
1380 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1317 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1381 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1318 | return; |
1382 | return; |
1319 | |
1383 | |
1320 | // for XQueryPointer |
1384 | // for XQueryPointer |
1321 | Window unused_root, unused_child; |
1385 | Window unused_root, unused_child; |
… | |
… | |
1323 | unsigned int unused_mask; |
1387 | unsigned int unused_mask; |
1324 | |
1388 | |
1325 | switch (ev.type) |
1389 | switch (ev.type) |
1326 | { |
1390 | { |
1327 | case KeyPress: |
1391 | case KeyPress: |
1328 | #if ISO_14755 |
1392 | key_press (ev.xkey); |
1329 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1330 | #endif |
|
|
1331 | lookup_key (ev.xkey); |
|
|
1332 | |
|
|
1333 | break; |
1393 | break; |
1334 | |
1394 | |
1335 | case KeyRelease: |
1395 | case KeyRelease: |
1336 | { |
1396 | key_release (ev.xkey); |
1337 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
1338 | KeySym keysym; |
|
|
1339 | |
|
|
1340 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1341 | #endif |
|
|
1342 | |
|
|
1343 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1344 | // ISO 14755 support |
|
|
1345 | if (iso14755buf) |
|
|
1346 | if (iso14755buf & ISO_14755_52) |
|
|
1347 | { |
|
|
1348 | # if ENABLE_OVERLAY |
|
|
1349 | scr_overlay_off (); |
|
|
1350 | # endif |
|
|
1351 | # if ISO_14755 |
|
|
1352 | // iso14755 part 5.2 handling: release time |
|
|
1353 | // first: controls |
|
|
1354 | if ((ev.xkey.state & ControlMask) |
|
|
1355 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
1356 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
1357 | { |
|
|
1358 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
1359 | commit_iso14755 (); |
|
|
1360 | goto skip_switch; |
|
|
1361 | } |
|
|
1362 | |
|
|
1363 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1364 | if (i[0] == keysym) |
|
|
1365 | { |
|
|
1366 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1367 | commit_iso14755 (); |
|
|
1368 | goto skip_switch; |
|
|
1369 | } |
|
|
1370 | |
|
|
1371 | scr_bell (); |
|
|
1372 | # endif |
|
|
1373 | iso14755buf = 0; |
|
|
1374 | break; |
|
|
1375 | } |
|
|
1376 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1377 | { |
|
|
1378 | # if ENABLE_OVERLAY |
|
|
1379 | scr_overlay_off (); |
|
|
1380 | # endif |
|
|
1381 | if (iso14755buf & ISO_14755_51) |
|
|
1382 | commit_iso14755 (); |
|
|
1383 | #if ISO_14755 |
|
|
1384 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1385 | { |
|
|
1386 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1387 | |
|
|
1388 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1389 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1390 | } |
|
|
1391 | # endif |
|
|
1392 | else |
|
|
1393 | iso14755buf = 0; |
|
|
1394 | } |
|
|
1395 | #endif |
|
|
1396 | |
|
|
1397 | if (ev.xany.window == vt |
|
|
1398 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1399 | break; |
|
|
1400 | |
|
|
1401 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1402 | if (!(ev.xkey.state & ControlMask)) |
|
|
1403 | slip_wheel_ev.stop (); |
|
|
1404 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
1405 | mouse_slip_wheel_speed = 0; |
|
|
1406 | #endif |
|
|
1407 | break; |
1397 | break; |
1408 | } |
|
|
1409 | |
1398 | |
1410 | case ButtonPress: |
1399 | case ButtonPress: |
1411 | button_press (ev.xbutton); |
1400 | button_press (ev.xbutton); |
1412 | break; |
1401 | break; |
1413 | |
1402 | |
… | |
… | |
1415 | button_release (ev.xbutton); |
1404 | button_release (ev.xbutton); |
1416 | break; |
1405 | break; |
1417 | |
1406 | |
1418 | case ClientMessage: |
1407 | case ClientMessage: |
1419 | if (ev.xclient.format == 32 |
1408 | if (ev.xclient.format == 32 |
1420 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1409 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1421 | { |
1410 | { |
|
|
1411 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1412 | { |
|
|
1413 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1414 | { |
1422 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1415 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1416 | { |
|
|
1417 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1423 | destroy (); |
1418 | destroy (); |
|
|
1419 | } |
1424 | #if ENABLE_EWMH |
1420 | #if ENABLE_EWMH |
1425 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1421 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1426 | XSendEvent (disp, ev.xclient.window = display->root, |
1422 | XSendEvent (dpy, ev.xclient.window = display->root, |
1427 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1423 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1428 | &ev); |
1424 | &ev); |
|
|
1425 | #endif |
|
|
1426 | } |
|
|
1427 | } |
|
|
1428 | #if ENABLE_XEMBED |
|
|
1429 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1430 | { |
|
|
1431 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1432 | focus_in (); |
|
|
1433 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1434 | focus_out (); |
|
|
1435 | } |
1429 | #endif |
1436 | #endif |
1430 | } |
1437 | } |
1431 | #if ENABLE_XEMBED |
|
|
1432 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1433 | { |
|
|
1434 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1435 | focus_in (); |
|
|
1436 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1437 | focus_out (); |
|
|
1438 | } |
|
|
1439 | #endif |
|
|
1440 | #ifdef OFFIX_DND |
|
|
1441 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1442 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1443 | && (ev.xclient.data.l[0] == DndFile |
|
|
1444 | || ev.xclient.data.l[0] == DndDir |
|
|
1445 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1446 | { |
|
|
1447 | /* Get Dnd data */ |
|
|
1448 | Atom ActualType; |
|
|
1449 | int ActualFormat; |
|
|
1450 | unsigned char *data; |
|
|
1451 | unsigned long Size, RemainingBytes; |
|
|
1452 | |
|
|
1453 | XGetWindowProperty (disp, display->root, |
|
|
1454 | xa[XA_DNDSELECTION], |
|
|
1455 | 0L, 1000000L, |
|
|
1456 | False, AnyPropertyType, |
|
|
1457 | &ActualType, &ActualFormat, |
|
|
1458 | &Size, &RemainingBytes, |
|
|
1459 | &data); |
|
|
1460 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1461 | XFree (data); |
|
|
1462 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1463 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1464 | } |
|
|
1465 | #endif /* OFFIX_DND */ |
|
|
1466 | break; |
1438 | break; |
1467 | |
1439 | |
1468 | case MappingNotify: |
1440 | case MappingNotify: |
1469 | XRefreshKeyboardMapping (&ev.xmapping); |
1441 | XRefreshKeyboardMapping (&ev.xmapping); |
1470 | break; |
1442 | break; |
… | |
… | |
1493 | break; |
1465 | break; |
1494 | } |
1466 | } |
1495 | break; |
1467 | break; |
1496 | |
1468 | |
1497 | case FocusIn: |
1469 | case FocusIn: |
|
|
1470 | if (ev.xfocus.detail != NotifyInferior |
|
|
1471 | && ev.xfocus.detail != NotifyPointer |
|
|
1472 | && ev.xfocus.mode != NotifyGrab) |
1498 | focus_in (); |
1473 | focus_in (); |
1499 | break; |
1474 | break; |
1500 | |
1475 | |
1501 | case FocusOut: |
1476 | case FocusOut: |
|
|
1477 | if (ev.xfocus.detail != NotifyInferior |
|
|
1478 | && ev.xfocus.detail != NotifyPointer |
|
|
1479 | && ev.xfocus.mode != NotifyGrab) |
1502 | focus_out (); |
1480 | focus_out (); |
1503 | break; |
1481 | break; |
1504 | |
1482 | |
1505 | case ConfigureNotify: |
1483 | case ConfigureNotify: |
1506 | if (ev.xconfigure.window == parent[0]) |
1484 | if (ev.xconfigure.window == parent[0]) |
1507 | { |
1485 | { |
1508 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1486 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1509 | ; |
1487 | ; |
1510 | |
1488 | |
1511 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1489 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1512 | { |
1490 | { |
1513 | seen_resize = 1; |
1491 | seen_resize = 1; |
1514 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1492 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
|
|
1493 | #ifdef XPM_BACKGROUND |
|
|
1494 | if (!option (Opt_transparent) && bgPixmap.auto_resize) |
|
|
1495 | { |
|
|
1496 | resize_pixmap (); |
|
|
1497 | scr_touch (true); |
|
|
1498 | } |
|
|
1499 | #endif |
1515 | } |
1500 | } |
1516 | |
1501 | |
1517 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1502 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1503 | |
|
|
1504 | #ifdef TRANSPARENT |
1518 | if (OPTION (Opt_transparent)) |
1505 | if (option (Opt_transparent)) |
1519 | check_our_parents (); |
1506 | check_our_parents (); |
1520 | #endif |
1507 | #endif |
1521 | } |
1508 | } |
1522 | break; |
1509 | break; |
1523 | |
1510 | |
1524 | case PropertyNotify: |
1511 | case PropertyNotify: |
|
|
1512 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1525 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1513 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1526 | && ev.xproperty.state == PropertyNewValue) |
1514 | && ev.xproperty.state == PropertyNewValue) |
1527 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1515 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1528 | |
1516 | |
1529 | break; |
1517 | break; |
1530 | |
1518 | |
1531 | case SelectionClear: |
1519 | case SelectionClear: |
1532 | selection_clear (); |
1520 | selection_clear (); |
… | |
… | |
1568 | if (ev.xany.window == vt) |
1556 | if (ev.xany.window == vt) |
1569 | { |
1557 | { |
1570 | do |
1558 | do |
1571 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1559 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1572 | ev.xexpose.width, ev.xexpose.height, False); |
1560 | ev.xexpose.width, ev.xexpose.height, False); |
1573 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1561 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1574 | |
1562 | |
1575 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1563 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1576 | |
1564 | |
1577 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1565 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1578 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1566 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1579 | ev.xexpose.width, ev.xexpose.height, False); |
1567 | ev.xexpose.width, ev.xexpose.height, False); |
1580 | |
1568 | |
1581 | want_refresh = 1; |
1569 | want_refresh = 1; |
1582 | } |
1570 | } |
1583 | else |
1571 | else |
1584 | { |
1572 | { |
1585 | XEvent unused_event; |
1573 | XEvent unused_event; |
1586 | |
1574 | |
1587 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1575 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1588 | ; |
1576 | ; |
1589 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1577 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1590 | ; |
1578 | ; |
1591 | |
1579 | |
1592 | if (isScrollbarWindow (ev.xany.window)) |
1580 | if (isScrollbarWindow (ev.xany.window)) |
1593 | { |
1581 | { |
1594 | scrollBar.setIdle (); |
1582 | scrollBar.setIdle (); |
1595 | scrollbar_show (0); |
1583 | scrollbar_show (0); |
1596 | } |
1584 | } |
1597 | #ifdef MENUBAR |
|
|
1598 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1599 | menubar_expose (); |
|
|
1600 | #endif |
|
|
1601 | |
1585 | |
1602 | #ifdef TRANSPARENT |
1586 | #ifdef TRANSPARENT |
1603 | if (am_transparent && ev.xany.window == parent[0]) |
1587 | if (am_transparent && ev.xany.window == parent[0]) |
1604 | XClearWindow (disp, ev.xany.window); |
1588 | XClearWindow (dpy, ev.xany.window); |
1605 | #endif |
1589 | #endif |
1606 | } |
1590 | } |
1607 | break; |
1591 | break; |
1608 | |
1592 | |
1609 | case MotionNotify: |
1593 | case MotionNotify: |
1610 | #ifdef POINTER_BLANK |
1594 | #ifdef POINTER_BLANK |
1611 | if (hidden_pointer) |
1595 | if (hidden_pointer) |
1612 | pointer_unblank (); |
1596 | pointer_unblank (); |
1613 | #endif |
1597 | #endif |
1614 | #if MENUBAR |
|
|
1615 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1616 | { |
|
|
1617 | menubar_control (ev.xbutton); |
|
|
1618 | break; |
|
|
1619 | } |
|
|
1620 | #endif |
|
|
1621 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1598 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1622 | break; |
1599 | break; |
1623 | |
1600 | |
1624 | if (ev.xany.window == vt) |
1601 | if (ev.xany.window == vt) |
1625 | { |
1602 | { |
|
|
1603 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1626 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1604 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1627 | ; // nop |
1605 | ; // nop |
1628 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1606 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1629 | { |
1607 | { |
1630 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1608 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1631 | ; |
1609 | ; |
1632 | |
1610 | |
1633 | XQueryPointer (disp, vt, |
1611 | XQueryPointer (dpy, vt, |
1634 | &unused_root, &unused_child, |
1612 | &unused_root, &unused_child, |
1635 | &unused_root_x, &unused_root_y, |
1613 | &unused_root_x, &unused_root_y, |
1636 | &ev.xbutton.x, &ev.xbutton.y, |
1614 | &ev.xbutton.x, &ev.xbutton.y, |
1637 | &ev.xbutton.state); |
1615 | &ev.xbutton.state); |
1638 | #ifdef MOUSE_THRESHOLD |
1616 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1702 | #endif |
1680 | #endif |
1703 | } |
1681 | } |
1704 | } |
1682 | } |
1705 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1683 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1706 | { |
1684 | { |
1707 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1685 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1708 | MotionNotify, &ev)) |
1686 | MotionNotify, &ev)) |
1709 | ; |
1687 | ; |
1710 | |
1688 | |
1711 | XQueryPointer (disp, scrollBar.win, |
1689 | XQueryPointer (dpy, scrollBar.win, |
1712 | &unused_root, &unused_child, |
1690 | &unused_root, &unused_child, |
1713 | &unused_root_x, &unused_root_y, |
1691 | &unused_root_x, &unused_root_y, |
1714 | &ev.xbutton.x, &ev.xbutton.y, |
1692 | &ev.xbutton.x, &ev.xbutton.y, |
1715 | &unused_mask); |
1693 | &unused_mask); |
1716 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1694 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1717 | scrollbar_size ()); |
1695 | scrollbar_size ()); |
1718 | want_refresh = 1; |
1696 | want_refresh = 1; |
1719 | refresh_limit = 0; |
|
|
1720 | scrollbar_show (1); |
1697 | scrollbar_show (1); |
1721 | } |
1698 | } |
1722 | break; |
1699 | break; |
1723 | } |
1700 | } |
1724 | |
1701 | |
1725 | skip_switch: ; |
|
|
1726 | |
|
|
1727 | #if defined(CURSOR_BLINK) |
1702 | #if defined(CURSOR_BLINK) |
1728 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1703 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
1729 | { |
1704 | { |
1730 | if (hidden_cursor) |
1705 | if (hidden_cursor) |
1731 | { |
1706 | { |
1732 | hidden_cursor = 0; |
1707 | hidden_cursor = 0; |
1733 | want_refresh = 1; |
1708 | want_refresh = 1; |
1734 | } |
1709 | } |
1735 | |
1710 | |
1736 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1711 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1737 | } |
1712 | } |
1738 | #endif |
1713 | #endif |
1739 | |
1714 | |
1740 | #if defined(POINTER_BLANK) |
1715 | #if defined(POINTER_BLANK) |
1741 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1716 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1742 | { |
1717 | { |
1743 | if (ev.type == MotionNotify |
1718 | if (ev.type == MotionNotify |
1744 | || ev.type == ButtonPress |
1719 | || ev.type == ButtonPress |
1745 | || ev.type == ButtonRelease) |
1720 | || ev.type == ButtonRelease) |
1746 | if (hidden_pointer) |
1721 | if (hidden_pointer) |
… | |
… | |
1758 | if (!focus) |
1733 | if (!focus) |
1759 | { |
1734 | { |
1760 | focus = 1; |
1735 | focus = 1; |
1761 | want_refresh = 1; |
1736 | want_refresh = 1; |
1762 | |
1737 | |
1763 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1738 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1764 | |
1739 | |
1765 | #if USE_XIM |
1740 | #if USE_XIM |
1766 | if (Input_Context != NULL) |
1741 | if (Input_Context != NULL) |
1767 | { |
1742 | { |
1768 | IMSetStatusPosition (); |
1743 | IMSetPosition (); |
1769 | XSetICFocus (Input_Context); |
1744 | XSetICFocus (Input_Context); |
1770 | } |
1745 | } |
1771 | #endif |
1746 | #endif |
1772 | #if CURSOR_BLINK |
1747 | #if CURSOR_BLINK |
1773 | if (OPTION (Opt_cursorBlink)) |
1748 | if (option (Opt_cursorBlink)) |
1774 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1749 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1775 | #endif |
1750 | #endif |
1776 | #if OFF_FOCUS_FADING |
1751 | #if OFF_FOCUS_FADING |
1777 | if (rs[Rs_fade]) |
1752 | if (rs[Rs_fade]) |
1778 | { |
1753 | { |
1779 | pix_colors = pix_colors_focused; |
1754 | pix_colors = pix_colors_focused; |
1780 | scr_recolour (); |
1755 | scr_recolour (); |
|
|
1756 | } |
|
|
1757 | #endif |
|
|
1758 | #if ENABLE_FRILLS |
|
|
1759 | if (option (Opt_urgentOnBell)) |
|
|
1760 | { |
|
|
1761 | XWMHints *h; |
|
|
1762 | |
|
|
1763 | h = XGetWMHints(dpy, parent[0]); |
|
|
1764 | if (h != NULL) |
|
|
1765 | { |
|
|
1766 | h->flags &= ~XUrgencyHint; |
|
|
1767 | XSetWMHints(dpy, parent[0], h); |
|
|
1768 | } |
1781 | } |
1769 | } |
1782 | #endif |
1770 | #endif |
1783 | } |
1771 | } |
1784 | } |
1772 | } |
1785 | |
1773 | |
… | |
… | |
1805 | #if USE_XIM |
1793 | #if USE_XIM |
1806 | if (Input_Context != NULL) |
1794 | if (Input_Context != NULL) |
1807 | XUnsetICFocus (Input_Context); |
1795 | XUnsetICFocus (Input_Context); |
1808 | #endif |
1796 | #endif |
1809 | #if CURSOR_BLINK |
1797 | #if CURSOR_BLINK |
1810 | if (OPTION (Opt_cursorBlink)) |
1798 | if (option (Opt_cursorBlink)) |
1811 | cursor_blink_ev.stop (); |
1799 | cursor_blink_ev.stop (); |
1812 | hidden_cursor = 0; |
1800 | hidden_cursor = 0; |
1813 | #endif |
1801 | #endif |
1814 | #if OFF_FOCUS_FADING |
1802 | #if OFF_FOCUS_FADING |
1815 | if (rs[Rs_fade]) |
1803 | if (rs[Rs_fade]) |
… | |
… | |
1819 | } |
1807 | } |
1820 | #endif |
1808 | #endif |
1821 | } |
1809 | } |
1822 | } |
1810 | } |
1823 | |
1811 | |
1824 | #if TRANSPARENT |
1812 | void |
|
|
1813 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1814 | { |
|
|
1815 | #if OFF_FOCUS_FADING |
|
|
1816 | if (rs[Rs_fade]) |
|
|
1817 | { |
|
|
1818 | rgba c; |
|
|
1819 | pix_colors [Color_fade].get (c); |
|
|
1820 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1821 | } |
|
|
1822 | #endif |
|
|
1823 | } |
|
|
1824 | |
|
|
1825 | #if TRANSPARENT || ENABLE_PERL |
1825 | void |
1826 | void |
1826 | rxvt_term::rootwin_cb (XEvent &ev) |
1827 | rxvt_term::rootwin_cb (XEvent &ev) |
1827 | { |
1828 | { |
1828 | SET_R (this); |
1829 | make_current (); |
1829 | SET_LOCALE (locale); |
|
|
1830 | |
1830 | |
|
|
1831 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1832 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1833 | return; |
|
|
1834 | |
|
|
1835 | # if TRANSPARENT |
1831 | switch (ev.type) |
1836 | switch (ev.type) |
1832 | { |
1837 | { |
1833 | case PropertyNotify: |
1838 | case PropertyNotify: |
1834 | /* |
1839 | /* |
1835 | * if user used some Esetroot compatible prog to set the root bg, |
1840 | * if user used some Esetroot compatible prog to set the root bg, |
… | |
… | |
1839 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1844 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1840 | return; |
1845 | return; |
1841 | |
1846 | |
1842 | /* FALLTHROUGH */ |
1847 | /* FALLTHROUGH */ |
1843 | case ReparentNotify: |
1848 | case ReparentNotify: |
1844 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1849 | if (option (Opt_transparent)) |
1845 | want_refresh = want_full_refresh = 1; |
1850 | check_our_parents (); |
1846 | break; |
1851 | break; |
1847 | } |
1852 | } |
|
|
1853 | # endif |
1848 | } |
1854 | } |
1849 | #endif |
1855 | #endif |
1850 | |
1856 | |
1851 | void |
1857 | void |
1852 | rxvt_term::button_press (XButtonEvent &ev) |
1858 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1861 | /* |
1867 | /* |
1862 | * VT window processing of button press |
1868 | * VT window processing of button press |
1863 | */ |
1869 | */ |
1864 | if (ev.window == vt) |
1870 | if (ev.window == vt) |
1865 | { |
1871 | { |
|
|
1872 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1873 | return; |
|
|
1874 | |
1866 | #if ISO_14755 |
1875 | #if ISO_14755 |
1867 | // 5.4 |
1876 | // 5.4 |
1868 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1877 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1869 | { |
1878 | { |
1870 | iso14755_54 (ev.x, ev.y); |
1879 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1912 | else |
1921 | else |
1913 | { |
1922 | { |
1914 | if (ev.button != MEvent.button) |
1923 | if (ev.button != MEvent.button) |
1915 | MEvent.clicks = 0; |
1924 | MEvent.clicks = 0; |
1916 | |
1925 | |
1917 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1918 | switch (ev.button) |
1926 | switch (ev.button) |
1919 | { |
1927 | { |
1920 | case Button1: |
1928 | case Button1: |
1921 | /* allow meta + click to select rectangular areas */ |
1929 | /* allow meta + click to select rectangular areas */ |
1922 | /* should be done in screen.C */ |
1930 | /* should be done in screen.C */ |
1923 | #if ENABLE_FRILLS |
1931 | #if ENABLE_FRILLS |
1924 | selection.rect = !!(ev.state & ModMetaMask); |
1932 | selection.rect = !!(ev.state & ModMetaMask); |
1925 | #else |
1933 | #else |
1926 | selection.rect = false; |
1934 | selection.rect = false; |
1927 | #endif |
1935 | #endif |
1928 | |
1936 | |
1929 | /* allow shift+left click to extend selection */ |
1937 | /* allow shift+left click to extend selection */ |
1930 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1938 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1931 | { |
1939 | { |
1932 | if (MEvent.button == Button1 && clickintime) |
1940 | if (MEvent.button == Button1 && clickintime) |
1933 | selection_rotate (ev.x, ev.y); |
1941 | selection_rotate (ev.x, ev.y); |
1934 | else |
1942 | else |
1935 | selection_extend (ev.x, ev.y, 1); |
1943 | selection_extend (ev.x, ev.y, 1); |
1936 | } |
1944 | } |
1937 | else |
1945 | else |
1938 | { |
1946 | { |
1939 | if (MEvent.button == Button1 && clickintime) |
1947 | if (MEvent.button == Button1 && clickintime) |
1940 | MEvent.clicks++; |
1948 | MEvent.clicks++; |
1941 | else |
1949 | else |
1942 | MEvent.clicks = 1; |
1950 | MEvent.clicks = 1; |
1943 | |
1951 | |
1944 | selection_click (MEvent.clicks, ev.x, ev.y); |
1952 | selection_click (MEvent.clicks, ev.x, ev.y); |
1945 | } |
1953 | } |
1946 | |
1954 | |
1947 | MEvent.button = Button1; |
1955 | MEvent.button = Button1; |
1948 | break; |
1956 | break; |
1949 | |
1957 | |
1950 | case Button3: |
1958 | case Button3: |
1951 | if (MEvent.button == Button3 && clickintime) |
1959 | if (MEvent.button == Button3 && clickintime) |
1952 | selection_rotate (ev.x, ev.y); |
1960 | selection_rotate (ev.x, ev.y); |
1953 | else |
1961 | else |
1954 | selection_extend (ev.x, ev.y, 1); |
1962 | selection_extend (ev.x, ev.y, 1); |
1955 | |
1963 | |
1956 | MEvent.button = Button3; |
1964 | MEvent.button = Button3; |
1957 | break; |
1965 | break; |
1958 | } |
1966 | } |
1959 | } |
1967 | } |
1960 | |
1968 | |
1961 | MEvent.time = ev.time; |
1969 | MEvent.time = ev.time; |
1962 | return; |
1970 | return; |
1963 | } |
1971 | } |
1964 | |
1972 | |
… | |
… | |
2103 | } |
2111 | } |
2104 | } |
2112 | } |
2105 | |
2113 | |
2106 | return; |
2114 | return; |
2107 | } |
2115 | } |
2108 | |
|
|
2109 | #if MENUBAR |
|
|
2110 | /* |
|
|
2111 | * Menubar window processing of button press |
|
|
2112 | */ |
|
|
2113 | if (isMenuBarWindow (ev.window)) |
|
|
2114 | menubar_control (ev); |
|
|
2115 | #endif |
|
|
2116 | } |
2116 | } |
2117 | |
2117 | |
2118 | void |
2118 | void |
2119 | rxvt_term::button_release (XButtonEvent &ev) |
2119 | rxvt_term::button_release (XButtonEvent &ev) |
2120 | { |
2120 | { |
… | |
… | |
2126 | |
2126 | |
2127 | if (scrollbar_isUpDn ()) |
2127 | if (scrollbar_isUpDn ()) |
2128 | { |
2128 | { |
2129 | scrollBar.setIdle (); |
2129 | scrollBar.setIdle (); |
2130 | scrollbar_show (0); |
2130 | scrollbar_show (0); |
2131 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2132 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2133 | #endif |
|
|
2134 | } |
2131 | } |
2135 | |
2132 | |
2136 | #ifdef SELECTION_SCROLLING |
2133 | #ifdef SELECTION_SCROLLING |
2137 | if (sel_scroll_ev.active) |
2134 | if (sel_scroll_ev.active) |
2138 | sel_scroll_ev.stop(); |
2135 | sel_scroll_ev.stop(); |
2139 | #endif |
2136 | #endif |
2140 | |
2137 | |
2141 | if (ev.window == vt) |
2138 | if (ev.window == vt) |
2142 | { |
2139 | { |
|
|
2140 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2141 | return; |
|
|
2142 | |
2143 | #if ISO_14755 |
2143 | #if ISO_14755 |
2144 | // 5.4 |
2144 | // 5.4 |
2145 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2145 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2146 | return; |
2146 | return; |
2147 | #endif |
2147 | #endif |
|
|
2148 | |
2148 | if (reportmode) |
2149 | if (reportmode) |
2149 | { |
2150 | { |
2150 | /* mouse report from vt window */ |
2151 | /* mouse report from vt window */ |
2151 | /* don't report release of wheel "buttons" */ |
2152 | /* don't report release of wheel "buttons" */ |
2152 | if (ev.button >= 4) |
2153 | if (ev.button >= 4) |
… | |
… | |
2176 | if (priv_modes & PrivMode_mouse_report |
2177 | if (priv_modes & PrivMode_mouse_report |
2177 | && bypass_keystate |
2178 | && bypass_keystate |
2178 | && ev.button == Button1 && MEvent.clicks <= 1) |
2179 | && ev.button == Button1 && MEvent.clicks <= 1) |
2179 | selection_extend (ev.x, ev.y, 0); |
2180 | selection_extend (ev.x, ev.y, 0); |
2180 | |
2181 | |
2181 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2182 | return; |
|
|
2183 | |
|
|
2184 | switch (ev.button) |
2182 | switch (ev.button) |
2185 | { |
2183 | { |
2186 | case Button1: |
2184 | case Button1: |
2187 | case Button3: |
2185 | case Button3: |
2188 | selection_make (ev.time); |
2186 | selection_make (ev.time); |
2189 | break; |
2187 | break; |
|
|
2188 | |
2190 | case Button2: |
2189 | case Button2: |
2191 | selection_request (ev.time, ev.x, ev.y); |
2190 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2191 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2192 | break; |
2192 | break; |
|
|
2193 | |
2193 | #ifdef MOUSE_WHEEL |
2194 | #ifdef MOUSE_WHEEL |
2194 | case Button4: |
2195 | case Button4: |
2195 | case Button5: |
2196 | case Button5: |
2196 | { |
2197 | { |
2197 | int i; |
2198 | int i; |
… | |
… | |
2199 | |
2200 | |
2200 | v = ev.button == Button4 ? UP : DN; |
2201 | v = ev.button == Button4 ? UP : DN; |
2201 | |
2202 | |
2202 | if (ev.state & ShiftMask) |
2203 | if (ev.state & ShiftMask) |
2203 | i = 1; |
2204 | i = 1; |
2204 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2205 | else if (option (Opt_mouseWheelScrollPage)) |
2205 | i = nrow - 1; |
2206 | i = nrow - 1; |
2206 | else |
2207 | else |
2207 | i = 5; |
2208 | i = 5; |
2208 | |
2209 | |
2209 | # ifdef MOUSE_SLIP_WHEELING |
2210 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2229 | } |
2230 | } |
2230 | break; |
2231 | break; |
2231 | #endif |
2232 | #endif |
2232 | } |
2233 | } |
2233 | } |
2234 | } |
2234 | #ifdef MENUBAR |
|
|
2235 | else if (isMenuBarWindow (ev.window)) |
|
|
2236 | menubar_control (ev); |
|
|
2237 | #endif |
|
|
2238 | } |
2235 | } |
2239 | |
|
|
2240 | #ifdef TRANSPARENT |
|
|
2241 | #if TINTING |
|
|
2242 | /* taken from aterm-0.4.2 */ |
|
|
2243 | |
|
|
2244 | typedef uint32_t RUINT32T; |
|
|
2245 | |
|
|
2246 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2247 | { |
|
|
2248 | int sh_r, sh_g, sh_b; |
|
|
2249 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2250 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2251 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2252 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2253 | int i; |
|
|
2254 | |
|
|
2255 | Visual *visual = display->visual; |
|
|
2256 | |
|
|
2257 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2258 | |
|
|
2259 | /* for convenience */ |
|
|
2260 | mask_r = visual->red_mask; |
|
|
2261 | mask_g = visual->green_mask; |
|
|
2262 | mask_b = visual->blue_mask; |
|
|
2263 | |
|
|
2264 | /* boring lookup table pre-initialization */ |
|
|
2265 | switch (srcImage->bits_per_pixel) { |
|
|
2266 | case 15: |
|
|
2267 | if ((mask_r != 0x7c00) || |
|
|
2268 | (mask_g != 0x03e0) || |
|
|
2269 | (mask_b != 0x001f)) |
|
|
2270 | return; |
|
|
2271 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2272 | lookup_r = lookup; |
|
|
2273 | lookup_g = lookup+32; |
|
|
2274 | lookup_b = lookup+32+32; |
|
|
2275 | sh_r = 10; |
|
|
2276 | sh_g = 5; |
|
|
2277 | sh_b = 0; |
|
|
2278 | break; |
|
|
2279 | case 16: |
|
|
2280 | if ((mask_r != 0xf800) || |
|
|
2281 | (mask_g != 0x07e0) || |
|
|
2282 | (mask_b != 0x001f)) |
|
|
2283 | return; |
|
|
2284 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2285 | lookup_r = lookup; |
|
|
2286 | lookup_g = lookup+32; |
|
|
2287 | lookup_b = lookup+32+64; |
|
|
2288 | sh_r = 11; |
|
|
2289 | sh_g = 5; |
|
|
2290 | sh_b = 0; |
|
|
2291 | break; |
|
|
2292 | case 24: |
|
|
2293 | if ((mask_r != 0xff0000) || |
|
|
2294 | (mask_g != 0x00ff00) || |
|
|
2295 | (mask_b != 0x0000ff)) |
|
|
2296 | return; |
|
|
2297 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2298 | lookup_r = lookup; |
|
|
2299 | lookup_g = lookup+256; |
|
|
2300 | lookup_b = lookup+256+256; |
|
|
2301 | sh_r = 16; |
|
|
2302 | sh_g = 8; |
|
|
2303 | sh_b = 0; |
|
|
2304 | break; |
|
|
2305 | case 32: |
|
|
2306 | if ((mask_r != 0xff0000) || |
|
|
2307 | (mask_g != 0x00ff00) || |
|
|
2308 | (mask_b != 0x0000ff)) |
|
|
2309 | return; |
|
|
2310 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2311 | lookup_r = lookup; |
|
|
2312 | lookup_g = lookup+256; |
|
|
2313 | lookup_b = lookup+256+256; |
|
|
2314 | sh_r = 16; |
|
|
2315 | sh_g = 8; |
|
|
2316 | sh_b = 0; |
|
|
2317 | break; |
|
|
2318 | default: |
|
|
2319 | return; /* we do not support this color depth */ |
|
|
2320 | } |
|
|
2321 | |
|
|
2322 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2323 | if (shade < 0) { |
|
|
2324 | shade = -shade; |
|
|
2325 | if (shade < 0) shade = 0; |
|
|
2326 | if (shade > 100) shade = 100; |
|
|
2327 | |
|
|
2328 | lower_lim_r = 65535-rm; |
|
|
2329 | lower_lim_g = 65535-gm; |
|
|
2330 | lower_lim_b = 65535-bm; |
|
|
2331 | |
|
|
2332 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2333 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2334 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2335 | |
|
|
2336 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2337 | } else { |
|
|
2338 | if (shade < 0) shade = 0; |
|
|
2339 | if (shade > 100) shade = 100; |
|
|
2340 | |
|
|
2341 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2342 | |
|
|
2343 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2344 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2345 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2346 | } |
|
|
2347 | |
|
|
2348 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2349 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2350 | { |
|
|
2351 | unsigned int tmp; |
|
|
2352 | |
|
|
2353 | tmp = lower_lim_r; |
|
|
2354 | lower_lim_r = lower_lim_b; |
|
|
2355 | lower_lim_b = tmp; |
|
|
2356 | |
|
|
2357 | tmp = upper_lim_r; |
|
|
2358 | upper_lim_r = upper_lim_b; |
|
|
2359 | upper_lim_b = tmp; |
|
|
2360 | } |
|
|
2361 | |
|
|
2362 | /* fill our lookup tables */ |
|
|
2363 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2364 | { |
|
|
2365 | RUINT32T tmp; |
|
|
2366 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2367 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2368 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2369 | } |
|
|
2370 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2371 | { |
|
|
2372 | RUINT32T tmp; |
|
|
2373 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2374 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2375 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2376 | } |
|
|
2377 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2378 | { |
|
|
2379 | RUINT32T tmp; |
|
|
2380 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2381 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2382 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2383 | } |
|
|
2384 | |
|
|
2385 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2386 | switch (srcImage->bits_per_pixel) |
|
|
2387 | { |
|
|
2388 | case 15: |
|
|
2389 | { |
|
|
2390 | unsigned short *p1, *pf, *p, *pl; |
|
|
2391 | p1 = (unsigned short *) srcImage->data; |
|
|
2392 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2393 | while (p1 < pf) |
|
|
2394 | { |
|
|
2395 | p = p1; |
|
|
2396 | pl = p1 + srcImage->width; |
|
|
2397 | for (; p < pl; p++) |
|
|
2398 | { |
|
|
2399 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2400 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2401 | lookup_b[(*p & 0x001f)]; |
|
|
2402 | } |
|
|
2403 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2404 | } |
|
|
2405 | break; |
|
|
2406 | } |
|
|
2407 | case 16: |
|
|
2408 | { |
|
|
2409 | unsigned short *p1, *pf, *p, *pl; |
|
|
2410 | p1 = (unsigned short *) srcImage->data; |
|
|
2411 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2412 | while (p1 < pf) |
|
|
2413 | { |
|
|
2414 | p = p1; |
|
|
2415 | pl = p1 + srcImage->width; |
|
|
2416 | for (; p < pl; p++) |
|
|
2417 | { |
|
|
2418 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2419 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2420 | lookup_b[(*p & 0x001f)]; |
|
|
2421 | } |
|
|
2422 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2423 | } |
|
|
2424 | break; |
|
|
2425 | } |
|
|
2426 | case 24: |
|
|
2427 | { |
|
|
2428 | unsigned char *p1, *pf, *p, *pl; |
|
|
2429 | p1 = (unsigned char *) srcImage->data; |
|
|
2430 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2431 | while (p1 < pf) |
|
|
2432 | { |
|
|
2433 | p = p1; |
|
|
2434 | pl = p1 + srcImage->width * 3; |
|
|
2435 | for (; p < pl; p += 3) |
|
|
2436 | { |
|
|
2437 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2438 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2439 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2440 | } |
|
|
2441 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2442 | } |
|
|
2443 | break; |
|
|
2444 | } |
|
|
2445 | case 32: |
|
|
2446 | { |
|
|
2447 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2448 | p1 = (RUINT32T *) srcImage->data; |
|
|
2449 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2450 | |
|
|
2451 | while (p1 < pf) |
|
|
2452 | { |
|
|
2453 | p = p1; |
|
|
2454 | pl = p1 + srcImage->width; |
|
|
2455 | for (; p < pl; p++) |
|
|
2456 | { |
|
|
2457 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2458 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2459 | lookup_b[(*p & 0x0000ff)] | |
|
|
2460 | (*p & ~0xffffff); |
|
|
2461 | } |
|
|
2462 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2463 | } |
|
|
2464 | break; |
|
|
2465 | } |
|
|
2466 | } |
|
|
2467 | |
|
|
2468 | free (lookup); |
|
|
2469 | } |
|
|
2470 | #endif |
|
|
2471 | |
|
|
2472 | /* |
|
|
2473 | * Check our parents are still who we think they are. |
|
|
2474 | * Do transparency updates if required |
|
|
2475 | */ |
|
|
2476 | int |
|
|
2477 | rxvt_term::check_our_parents () |
|
|
2478 | { |
|
|
2479 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2480 | unsigned long nitems, bytes_after; |
|
|
2481 | Atom atype; |
|
|
2482 | unsigned char *prop = NULL; |
|
|
2483 | Window root, oldp, *list; |
|
|
2484 | Pixmap rootpixmap = None; |
|
|
2485 | XWindowAttributes wattr, wrootattr; |
|
|
2486 | dDisp; |
|
|
2487 | |
|
|
2488 | pchanged = 0; |
|
|
2489 | |
|
|
2490 | if (!OPTION (Opt_transparent)) |
|
|
2491 | return pchanged; /* Don't try any more */ |
|
|
2492 | |
|
|
2493 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2494 | rootdepth = wrootattr.depth; |
|
|
2495 | |
|
|
2496 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2497 | |
|
|
2498 | if (rootdepth != wattr.depth) |
|
|
2499 | { |
|
|
2500 | if (am_transparent) |
|
|
2501 | { |
|
|
2502 | pchanged = 1; |
|
|
2503 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2504 | am_transparent = am_pixmap_trans = 0; |
|
|
2505 | } |
|
|
2506 | |
|
|
2507 | return pchanged; /* Don't try any more */ |
|
|
2508 | } |
|
|
2509 | |
|
|
2510 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2511 | XSync (disp, False); |
|
|
2512 | |
|
|
2513 | /* |
|
|
2514 | * Make the frame window set by the window manager have |
|
|
2515 | * the root background. Some window managers put multiple nested frame |
|
|
2516 | * windows for each client, so we have to take care about that. |
|
|
2517 | */ |
|
|
2518 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2519 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2520 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2521 | &nitems, &bytes_after, &prop) == Success); |
|
|
2522 | |
|
|
2523 | if (!i || prop == NULL) |
|
|
2524 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2525 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2526 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2527 | &nitems, &bytes_after, &prop) == Success); |
|
|
2528 | |
|
|
2529 | if (!i || prop == NULL |
|
|
2530 | #if TINTING |
|
|
2531 | || !rs[Rs_color + Color_tint] |
|
|
2532 | #endif |
|
|
2533 | ) |
|
|
2534 | have_pixmap = 0; |
|
|
2535 | else |
|
|
2536 | { |
|
|
2537 | have_pixmap = 1; |
|
|
2538 | rootpixmap = *(Pixmap *)prop; |
|
|
2539 | XFree (prop); |
|
|
2540 | } |
|
|
2541 | |
|
|
2542 | if (have_pixmap) |
|
|
2543 | { |
|
|
2544 | /* |
|
|
2545 | * Copy display->root pixmap transparency |
|
|
2546 | */ |
|
|
2547 | int sx, sy, nx, ny; |
|
|
2548 | unsigned int nw, nh; |
|
|
2549 | Window cr; |
|
|
2550 | XImage *image; |
|
|
2551 | GC gc; |
|
|
2552 | XGCValues gcvalue; |
|
|
2553 | |
|
|
2554 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2555 | 0, 0, &sx, &sy, &cr); |
|
|
2556 | nw = (unsigned int)szHint.width; |
|
|
2557 | nh = (unsigned int)szHint.height; |
|
|
2558 | nx = ny = 0; |
|
|
2559 | |
|
|
2560 | if (sx < 0) |
|
|
2561 | { |
|
|
2562 | nw += sx; |
|
|
2563 | nx = -sx; |
|
|
2564 | sx = 0; |
|
|
2565 | } |
|
|
2566 | |
|
|
2567 | if (sy < 0) |
|
|
2568 | { |
|
|
2569 | nh += sy; |
|
|
2570 | ny = -sy; |
|
|
2571 | sy = 0; |
|
|
2572 | } |
|
|
2573 | |
|
|
2574 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2575 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2576 | |
|
|
2577 | XSync (disp, False); |
|
|
2578 | allowedxerror = -1; |
|
|
2579 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2580 | |
|
|
2581 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2582 | /* XXX: may need a delay here? */ |
|
|
2583 | allowedxerror = 0; |
|
|
2584 | |
|
|
2585 | if (image == NULL) |
|
|
2586 | { |
|
|
2587 | if (am_transparent && am_pixmap_trans) |
|
|
2588 | { |
|
|
2589 | pchanged = 1; |
|
|
2590 | if (pixmap != None) |
|
|
2591 | { |
|
|
2592 | XFreePixmap (disp, pixmap); |
|
|
2593 | pixmap = None; |
|
|
2594 | } |
|
|
2595 | } |
|
|
2596 | |
|
|
2597 | am_pixmap_trans = 0; |
|
|
2598 | } |
|
|
2599 | else |
|
|
2600 | { |
|
|
2601 | if (pixmap != None) |
|
|
2602 | XFreePixmap (disp, pixmap); |
|
|
2603 | |
|
|
2604 | #if TINTING |
|
|
2605 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2606 | { |
|
|
2607 | unsigned short rm, gm, bm; |
|
|
2608 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2609 | |
|
|
2610 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2611 | |
|
|
2612 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2613 | } |
|
|
2614 | #endif |
|
|
2615 | |
|
|
2616 | pixmap = XCreatePixmap (disp, vt, |
|
|
2617 | szHint.width, szHint.height, image->depth); |
|
|
2618 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2619 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2620 | nx, ny, image->width, image->height); |
|
|
2621 | XFreeGC (disp, gc); |
|
|
2622 | XDestroyImage (image); |
|
|
2623 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2624 | XClearWindow (disp, parent[0]); |
|
|
2625 | |
|
|
2626 | if (!am_transparent || !am_pixmap_trans) |
|
|
2627 | pchanged = 1; |
|
|
2628 | |
|
|
2629 | am_transparent = am_pixmap_trans = 1; |
|
|
2630 | } |
|
|
2631 | } |
|
|
2632 | |
|
|
2633 | if (am_pixmap_trans) |
|
|
2634 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2635 | else |
|
|
2636 | { |
|
|
2637 | unsigned int n; |
|
|
2638 | /* |
|
|
2639 | * InheritPixmap transparency |
|
|
2640 | */ |
|
|
2641 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2642 | { |
|
|
2643 | oldp = parent[i]; |
|
|
2644 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2645 | &parent[i], &list, &n); |
|
|
2646 | XFree (list); |
|
|
2647 | |
|
|
2648 | if (parent[i] == display->root) |
|
|
2649 | { |
|
|
2650 | if (oldp != None) |
|
|
2651 | pchanged = 1; |
|
|
2652 | |
|
|
2653 | break; |
|
|
2654 | } |
|
|
2655 | |
|
|
2656 | if (oldp != parent[i]) |
|
|
2657 | pchanged = 1; |
|
|
2658 | } |
|
|
2659 | |
|
|
2660 | n = 0; |
|
|
2661 | |
|
|
2662 | if (pchanged) |
|
|
2663 | { |
|
|
2664 | for (; n < (unsigned int)i; n++) |
|
|
2665 | { |
|
|
2666 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2667 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2668 | { |
|
|
2669 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2670 | break; |
|
|
2671 | } |
|
|
2672 | } |
|
|
2673 | } |
|
|
2674 | |
|
|
2675 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2676 | { |
|
|
2677 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2678 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2679 | am_transparent = 0; |
|
|
2680 | /* XXX: also turn off Opt_transparent? */ |
|
|
2681 | } |
|
|
2682 | else |
|
|
2683 | { |
|
|
2684 | #if WAIT_FOR_WM |
|
|
2685 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2686 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2687 | sleep (1); |
|
|
2688 | #endif |
|
|
2689 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2690 | { |
|
|
2691 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2692 | XClearWindow (disp, parent[n]); |
|
|
2693 | } |
|
|
2694 | |
|
|
2695 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2696 | am_transparent = 1; |
|
|
2697 | } |
|
|
2698 | |
|
|
2699 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2700 | parent[i] = None; |
|
|
2701 | } |
|
|
2702 | |
|
|
2703 | if (scrollBar.win) |
|
|
2704 | { |
|
|
2705 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2706 | scrollBar.setIdle (); |
|
|
2707 | scrollbar_show (0); |
|
|
2708 | } |
|
|
2709 | |
|
|
2710 | if (am_transparent) |
|
|
2711 | { |
|
|
2712 | want_refresh = want_full_refresh = 1; |
|
|
2713 | if (am_pixmap_trans) |
|
|
2714 | flush (); |
|
|
2715 | } |
|
|
2716 | |
|
|
2717 | return pchanged; |
|
|
2718 | } |
|
|
2719 | #endif |
|
|
2720 | |
2236 | |
2721 | /*}}} */ |
2237 | /*}}} */ |
2722 | |
2238 | |
2723 | bool |
2239 | bool |
2724 | rxvt_term::cmd_parse () |
2240 | rxvt_term::cmd_parse () |
… | |
… | |
2773 | if (ch == C0_LF) |
2289 | if (ch == C0_LF) |
2774 | nlines++; |
2290 | nlines++; |
2775 | |
2291 | |
2776 | refresh_count++; |
2292 | refresh_count++; |
2777 | |
2293 | |
2778 | if (!OPTION (Opt_jumpScroll) |
2294 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2779 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2780 | { |
2295 | { |
2781 | refreshnow = true; |
|
|
2782 | refresh_count = 0; |
2296 | refresh_count = 0; |
|
|
2297 | |
|
|
2298 | if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.) |
|
|
2299 | { |
|
|
2300 | refreshnow = true; |
2783 | ch = NOCHAR; |
2301 | ch = NOCHAR; |
2784 | break; |
2302 | break; |
|
|
2303 | } |
2785 | } |
2304 | } |
2786 | |
2305 | |
2787 | // scr_add_lines only works for nlines <= nrow - 1. |
2306 | // scr_add_lines only works for nlines <= nrow - 1. |
2788 | if (nlines >= nrow - 1) |
2307 | if (nlines >= nrow - 1) |
2789 | { |
2308 | { |
|
|
2309 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2790 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2310 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2791 | scr_add_lines (buf, str - buf, nlines); |
2311 | scr_add_lines (buf, str - buf, nlines); |
2792 | |
2312 | |
2793 | nlines = 0; |
2313 | nlines = 0; |
2794 | str = buf; |
2314 | str = buf; |
2795 | eol = str + min (ncol, UBUFSIZ); |
2315 | eol = str + min (ncol, UBUFSIZ); |
… | |
… | |
2810 | |
2330 | |
2811 | seq_begin = cmdbuf_ptr; |
2331 | seq_begin = cmdbuf_ptr; |
2812 | ch = next_char (); |
2332 | ch = next_char (); |
2813 | } |
2333 | } |
2814 | |
2334 | |
|
|
2335 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2815 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2336 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2816 | scr_add_lines (buf, str - buf, nlines); |
2337 | scr_add_lines (buf, str - buf, nlines); |
2817 | |
2338 | |
2818 | /* |
2339 | /* |
2819 | * If there have been a lot of new lines, then update the screen |
2340 | * If there have been a lot of new lines, then update the screen |
2820 | * What the heck I'll cheat and only refresh less than every page-full. |
2341 | * What the heck we'll cheat and only refresh less than every page-full. |
2821 | * the number of pages between refreshes is refresh_limit, which |
2342 | * if skipScroll is enabled. |
2822 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2823 | */ |
2343 | */ |
2824 | if (refreshnow) |
2344 | if (refreshnow) |
2825 | { |
2345 | { |
2826 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2827 | refresh_limit++; |
|
|
2828 | else |
|
|
2829 | { |
|
|
2830 | flag = true; |
2346 | flag = true; |
2831 | scr_refresh (refresh_type); |
2347 | scr_refresh (); |
2832 | want_refresh = 1; |
2348 | want_refresh = 1; |
2833 | } |
|
|
2834 | } |
2349 | } |
2835 | |
2350 | |
2836 | } |
2351 | } |
2837 | else |
2352 | else |
2838 | { |
2353 | { |
… | |
… | |
2854 | return flag; |
2369 | return flag; |
2855 | } |
2370 | } |
2856 | |
2371 | |
2857 | // read the next character |
2372 | // read the next character |
2858 | wchar_t |
2373 | wchar_t |
2859 | rxvt_term::next_char () |
2374 | rxvt_term::next_char () NOTHROW |
2860 | { |
2375 | { |
2861 | while (cmdbuf_ptr < cmdbuf_endp) |
2376 | while (cmdbuf_ptr < cmdbuf_endp) |
2862 | { |
2377 | { |
2863 | // assume 7-bit to be ascii ALWAYS |
2378 | // assume 7-bit to be ascii ALWAYS |
2864 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2379 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2885 | return NOCHAR; |
2400 | return NOCHAR; |
2886 | } |
2401 | } |
2887 | |
2402 | |
2888 | // read the next octet |
2403 | // read the next octet |
2889 | uint32_t |
2404 | uint32_t |
2890 | rxvt_term::next_octet () |
2405 | rxvt_term::next_octet () NOTHROW |
2891 | { |
2406 | { |
2892 | return cmdbuf_ptr < cmdbuf_endp |
2407 | return cmdbuf_ptr < cmdbuf_endp |
2893 | ? (unsigned char)*cmdbuf_ptr++ |
2408 | ? (unsigned char)*cmdbuf_ptr++ |
2894 | : NOCHAR; |
2409 | : NOCHAR; |
2895 | } |
2410 | } |
|
|
2411 | |
|
|
2412 | static class out_of_input out_of_input; |
2896 | |
2413 | |
2897 | /* rxvt_cmd_getc () - Return next input character */ |
2414 | /* rxvt_cmd_getc () - Return next input character */ |
2898 | /* |
2415 | /* |
2899 | * Return the next input character after first passing any keyboard input |
2416 | * Return the next input character after first passing any keyboard input |
2900 | * to the command. |
2417 | * to the command. |
2901 | */ |
2418 | */ |
2902 | wchar_t |
2419 | wchar_t |
2903 | rxvt_term::cmd_getc () |
2420 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2904 | { |
2421 | { |
2905 | wchar_t c = next_char (); |
2422 | wchar_t c = next_char (); |
2906 | |
2423 | |
2907 | if (c == NOCHAR) |
2424 | if (c == NOCHAR) |
2908 | throw out_of_input; |
2425 | throw out_of_input; |
2909 | |
2426 | |
2910 | return c; |
2427 | return c; |
2911 | } |
2428 | } |
2912 | |
2429 | |
2913 | uint32_t |
2430 | uint32_t |
2914 | rxvt_term::cmd_get8 () |
2431 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2915 | { |
2432 | { |
2916 | uint32_t c = next_octet (); |
2433 | uint32_t c = next_octet (); |
2917 | |
2434 | |
2918 | if (c == NOCHAR) |
2435 | if (c == NOCHAR) |
2919 | throw out_of_input; |
2436 | throw out_of_input; |
… | |
… | |
2985 | { |
2502 | { |
2986 | if ((buf[len++] = cmd_getc ()) == 'i') |
2503 | if ((buf[len++] = cmd_getc ()) == 'i') |
2987 | break; /* done = 1 */ |
2504 | break; /* done = 1 */ |
2988 | } |
2505 | } |
2989 | } |
2506 | } |
2990 | |
2507 | |
2991 | for (i = 0; i < len; i++) |
2508 | for (i = 0; i < len; i++) |
2992 | if (putc (buf[i], fd) == EOF) |
2509 | if (putc (buf[i], fd) == EOF) |
2993 | { |
2510 | { |
2994 | done = 1; |
2511 | done = 1; |
2995 | break; |
2512 | break; |
… | |
… | |
3157 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2674 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3158 | break; |
2675 | break; |
3159 | case '+': |
2676 | case '+': |
3160 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2677 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3161 | break; |
2678 | break; |
3162 | #if ENABLE_FRILLS |
2679 | #if !ENABLE_MINIMAL |
3163 | case '6': |
2680 | case '6': |
3164 | scr_backindex (); |
2681 | scr_backindex (); |
3165 | break; |
2682 | break; |
3166 | #endif |
2683 | #endif |
3167 | case '7': |
2684 | case '7': |
3168 | scr_cursor (SAVE); |
2685 | scr_cursor (SAVE); |
3169 | break; |
2686 | break; |
3170 | case '8': |
2687 | case '8': |
3171 | scr_cursor (RESTORE); |
2688 | scr_cursor (RESTORE); |
3172 | break; |
2689 | break; |
3173 | #if ENABLE_FRILLS |
2690 | #if !ENABLE_MINIMAL |
3174 | case '9': |
2691 | case '9': |
3175 | scr_forwardindex (); |
2692 | scr_forwardindex (); |
3176 | break; |
2693 | break; |
3177 | #endif |
2694 | #endif |
3178 | case '=': |
2695 | case '=': |
… | |
… | |
3340 | ndef = get_byte_array_bit (csi_defaults, i); |
2857 | ndef = get_byte_array_bit (csi_defaults, i); |
3341 | for (p = 0; p < nargs; p++) |
2858 | for (p = 0; p < nargs; p++) |
3342 | if (arg[p] == -1) |
2859 | if (arg[p] == -1) |
3343 | arg[p] = ndef; |
2860 | arg[p] = ndef; |
3344 | |
2861 | |
3345 | #ifdef DEBUG_CMD |
|
|
3346 | fprintf (stderr, "CSI "); |
|
|
3347 | for (p = 0; p < nargs; p++) |
|
|
3348 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3349 | fprintf (stderr, "%c\n", ch); |
|
|
3350 | #endif |
|
|
3351 | |
|
|
3352 | /* |
2862 | /* |
3353 | * private mode handling |
2863 | * private mode handling |
3354 | */ |
2864 | */ |
3355 | if (priv) |
2865 | if (priv) |
3356 | { |
2866 | { |
3357 | switch (priv) |
2867 | switch (priv) |
3358 | { |
2868 | { |
3359 | case '>': |
2869 | case '>': |
3360 | if (ch == CSI_DA) /* secondary device attributes */ |
2870 | if (ch == CSI_DA) /* secondary device attributes */ |
3361 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2871 | { |
|
|
2872 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
2873 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2874 | // |
|
|
2875 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2876 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
2877 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
2878 | // |
|
|
2879 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
2880 | } |
3362 | break; |
2881 | break; |
3363 | case '?': |
2882 | case '?': |
3364 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2883 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3365 | process_terminal_mode (ch, priv, nargs, arg); |
2884 | process_terminal_mode (ch, priv, nargs, arg); |
3366 | break; |
2885 | break; |
… | |
… | |
3492 | break; |
3011 | break; |
3493 | case 6: /* CPR requested */ |
3012 | case 6: /* CPR requested */ |
3494 | scr_report_position (); |
3013 | scr_report_position (); |
3495 | break; |
3014 | break; |
3496 | case 7: /* unofficial extension */ |
3015 | case 7: /* unofficial extension */ |
3497 | if (OPTION (Opt_insecure)) |
3016 | if (option (Opt_insecure)) |
3498 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3017 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3499 | break; |
3018 | break; |
3500 | case 8: /* unofficial extension */ |
3019 | case 8: /* unofficial extension */ |
3501 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3020 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3502 | break; |
3021 | break; |
… | |
… | |
3569 | break; |
3088 | break; |
3570 | case CSI_75: |
3089 | case CSI_75: |
3571 | scr_cursor (RESTORE); |
3090 | scr_cursor (RESTORE); |
3572 | break; |
3091 | break; |
3573 | |
3092 | |
3574 | #if ENABLE_FRILLS |
3093 | #if !ENABLE_MINIMAL |
3575 | case CSI_74: |
3094 | case CSI_74: |
3576 | process_window_ops (arg, nargs); |
3095 | process_window_ops (arg, nargs); |
3577 | break; |
3096 | break; |
3578 | #endif |
3097 | #endif |
3579 | |
3098 | |
… | |
… | |
3586 | break; |
3105 | break; |
3587 | } |
3106 | } |
3588 | } |
3107 | } |
3589 | /*}}} */ |
3108 | /*}}} */ |
3590 | |
3109 | |
3591 | #if ENABLE_FRILLS |
3110 | #if !ENABLE_MINIMAL |
3592 | /* ARGSUSED */ |
3111 | /* ARGSUSED */ |
3593 | void |
3112 | void |
3594 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3113 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3595 | { |
3114 | { |
3596 | int x, y; |
3115 | int x, y; |
3597 | XWindowAttributes wattr; |
3116 | XWindowAttributes wattr; |
3598 | Window wdummy; |
3117 | Window wdummy; |
3599 | dDisp; |
3118 | |
|
|
3119 | dLocal (Display *, dpy); |
3600 | |
3120 | |
3601 | if (nargs == 0) |
3121 | if (nargs == 0) |
3602 | return; |
3122 | return; |
3603 | |
3123 | |
3604 | switch (args[0]) |
3124 | switch (args[0]) |
3605 | { |
3125 | { |
3606 | /* |
3126 | /* |
3607 | * commands |
3127 | * commands |
3608 | */ |
3128 | */ |
3609 | case 1: /* deiconify window */ |
3129 | case 1: /* deiconify window */ |
3610 | XMapWindow (disp, parent[0]); |
3130 | XMapWindow (dpy, parent[0]); |
3611 | break; |
3131 | break; |
3612 | case 2: /* iconify window */ |
3132 | case 2: /* iconify window */ |
3613 | XIconifyWindow (disp, parent[0], display->screen); |
3133 | XIconifyWindow (dpy, parent[0], display->screen); |
3614 | break; |
3134 | break; |
3615 | case 3: /* set position (pixels) */ |
3135 | case 3: /* set position (pixels) */ |
3616 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3136 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3617 | break; |
3137 | break; |
3618 | case 4: /* set size (pixels) */ |
3138 | case 4: /* set size (pixels) */ |
3619 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3139 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3620 | break; |
3140 | break; |
3621 | case 5: /* raise window */ |
3141 | case 5: /* raise window */ |
3622 | XRaiseWindow (disp, parent[0]); |
3142 | XRaiseWindow (dpy, parent[0]); |
3623 | break; |
3143 | break; |
3624 | case 6: /* lower window */ |
3144 | case 6: /* lower window */ |
3625 | XLowerWindow (disp, parent[0]); |
3145 | XLowerWindow (dpy, parent[0]); |
3626 | break; |
3146 | break; |
3627 | case 7: /* refresh window */ |
3147 | case 7: /* refresh window */ |
3628 | scr_touch (true); |
3148 | scr_touch (true); |
3629 | break; |
3149 | break; |
3630 | case 8: /* set size (chars) */ |
3150 | case 8: /* set size (chars) */ |
… | |
… | |
3637 | if (args[0] >= 24) /* set height (chars) */ |
3157 | if (args[0] >= 24) /* set height (chars) */ |
3638 | set_widthheight ((unsigned int)width, |
3158 | set_widthheight ((unsigned int)width, |
3639 | (unsigned int) (args[1] * fheight)); |
3159 | (unsigned int) (args[1] * fheight)); |
3640 | break; |
3160 | break; |
3641 | |
3161 | |
3642 | |
|
|
3643 | /* |
3162 | /* |
3644 | * reports - some output format copied from XTerm |
3163 | * reports - some output format copied from XTerm |
3645 | */ |
3164 | */ |
3646 | case 11: /* report window state */ |
3165 | case 11: /* report window state */ |
3647 | XGetWindowAttributes (disp, parent[0], &wattr); |
3166 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3648 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3167 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3649 | break; |
3168 | break; |
3650 | case 13: /* report window position */ |
3169 | case 13: /* report window position */ |
3651 | XGetWindowAttributes (disp, parent[0], &wattr); |
3170 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3652 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3171 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3653 | -wattr.border_width, -wattr.border_width, |
3172 | -wattr.border_width, -wattr.border_width, |
3654 | &x, &y, &wdummy); |
3173 | &x, &y, &wdummy); |
3655 | tt_printf ("\033[3;%d;%dt", x, y); |
3174 | tt_printf ("\033[3;%d;%dt", x, y); |
3656 | break; |
3175 | break; |
3657 | case 14: /* report window size (pixels) */ |
3176 | case 14: /* report window size (pixels) */ |
3658 | XGetWindowAttributes (disp, parent[0], &wattr); |
3177 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3659 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3178 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3660 | break; |
3179 | break; |
3661 | case 18: /* report text area size (chars) */ |
3180 | case 18: /* report text area size (chars) */ |
3662 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3181 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3663 | break; |
3182 | break; |
… | |
… | |
3665 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3184 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3666 | break; |
3185 | break; |
3667 | case 20: /* report icon label */ |
3186 | case 20: /* report icon label */ |
3668 | { |
3187 | { |
3669 | char *s; |
3188 | char *s; |
3670 | XGetIconName (disp, parent[0], &s); |
3189 | XGetIconName (dpy, parent[0], &s); |
3671 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3190 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3672 | XFree (s); |
3191 | XFree (s); |
3673 | } |
3192 | } |
3674 | break; |
3193 | break; |
3675 | case 21: /* report window title */ |
3194 | case 21: /* report window title */ |
3676 | { |
3195 | { |
3677 | char *s; |
3196 | char *s; |
3678 | XFetchName (disp, parent[0], &s); |
3197 | XFetchName (dpy, parent[0], &s); |
3679 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3198 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3680 | XFree (s); |
3199 | XFree (s); |
3681 | } |
3200 | } |
3682 | break; |
3201 | break; |
3683 | } |
3202 | } |
3684 | } |
3203 | } |
… | |
… | |
3711 | seen_esc = true; |
3230 | seen_esc = true; |
3712 | continue; |
3231 | continue; |
3713 | } |
3232 | } |
3714 | else if (ch == C0_BEL || ch == CHAR_ST) |
3233 | else if (ch == C0_BEL || ch == CHAR_ST) |
3715 | break; |
3234 | break; |
|
|
3235 | else if (ch == C0_SYN) |
|
|
3236 | ch = cmd_get8 (); |
3716 | else if (ch < 0x20) |
3237 | else if (ch < 0x20) |
3717 | return NULL; /* other control character - exit */ |
3238 | return NULL; /* other control character - exit */ |
3718 | |
3239 | |
3719 | seen_esc = false; |
3240 | seen_esc = false; |
3720 | |
3241 | |
3721 | if (n >= STRING_MAX - 1) |
3242 | if (n >= STRING_MAX - 1) |
3722 | // stop at some sane length |
3243 | // stop at some sane length |
3723 | return NULL; |
3244 | return NULL; |
3724 | |
3245 | |
3725 | if (ch == C0_SYN) |
|
|
3726 | string[n++] = cmd_get8 (); |
|
|
3727 | else |
|
|
3728 | string[n++] = ch; |
3246 | string[n++] = ch; |
3729 | } |
3247 | } |
3730 | |
3248 | |
3731 | string[n++] = '\0'; |
3249 | string[n++] = '\0'; |
3732 | |
3250 | |
3733 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3251 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3784 | void |
3302 | void |
3785 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3303 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3786 | { |
3304 | { |
3787 | if (str[0] == '?' && !str[1]) |
3305 | if (str[0] == '?' && !str[1]) |
3788 | { |
3306 | { |
3789 | unsigned short r, g, b; |
3307 | rgba c; |
3790 | pix_colors_focused[color].get (display, r, g, b); |
3308 | pix_colors_focused[color].get (c); |
|
|
3309 | |
|
|
3310 | #if XFT |
|
|
3311 | if (c.a != rgba::MAX_CC) |
|
|
3312 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3313 | else |
|
|
3314 | #endif |
3791 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3315 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3792 | } |
3316 | } |
3793 | else |
3317 | else |
3794 | set_window_color (color, str); |
3318 | set_window_color (color, str); |
3795 | } |
3319 | } |
3796 | |
3320 | |
… | |
… | |
3798 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3322 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3799 | */ |
3323 | */ |
3800 | void |
3324 | void |
3801 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3325 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3802 | { |
3326 | { |
3803 | int changed = 0; |
|
|
3804 | int color; |
3327 | int color; |
3805 | char *buf, *name; |
3328 | char *buf, *name; |
3806 | bool query = str[0] == '?' && !str[1]; |
3329 | bool query = str[0] == '?' && !str[1]; |
3807 | int saveop = op; |
3330 | int saveop = op; |
3808 | dDisp; |
3331 | |
|
|
3332 | dLocal (Display *, dpy); |
3809 | |
3333 | |
3810 | assert (str != NULL); |
3334 | assert (str != NULL); |
|
|
3335 | |
|
|
3336 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3337 | return; |
|
|
3338 | |
3811 | switch (op) |
3339 | switch (op) |
3812 | { |
3340 | { |
3813 | case XTerm_name: |
3341 | case XTerm_name: |
3814 | set_title (str); |
3342 | set_title (str); |
3815 | /* FALLTHROUGH */ |
3343 | /* FALLTHROUGH */ |
… | |
… | |
3829 | unsigned long bytes_after; |
3357 | unsigned long bytes_after; |
3830 | unsigned char *value = 0; |
3358 | unsigned char *value = 0; |
3831 | const char *str = ""; |
3359 | const char *str = ""; |
3832 | |
3360 | |
3833 | if (prop |
3361 | if (prop |
3834 | && XGetWindowProperty (disp, parent[0], |
3362 | && XGetWindowProperty (dpy, parent[0], |
3835 | prop, 0, 1<<16, 0, AnyPropertyType, |
3363 | prop, 0, 1<<16, 0, AnyPropertyType, |
3836 | &actual_type, &actual_format, |
3364 | &actual_type, &actual_format, |
3837 | &nitems, &bytes_after, &value) == Success |
3365 | &nitems, &bytes_after, &value) == Success |
3838 | && actual_type != None |
3366 | && actual_type != None |
3839 | && actual_format == 8) |
3367 | && actual_format == 8) |
3840 | str = (const char *)(value); |
3368 | str = (const char *)(value); |
3841 | |
3369 | |
3842 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3370 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3843 | |
3371 | |
3844 | XFree (value); |
3372 | XFree (value); |
3845 | } |
3373 | } |
3846 | else |
3374 | else |
3847 | { |
3375 | { |
… | |
… | |
3851 | { |
3379 | { |
3852 | *eq = 0; |
3380 | *eq = 0; |
3853 | set_utf8_property (display->atom (str), eq + 1); |
3381 | set_utf8_property (display->atom (str), eq + 1); |
3854 | } |
3382 | } |
3855 | else |
3383 | else |
3856 | XDeleteProperty (disp, parent[0], |
3384 | XDeleteProperty (dpy, parent[0], |
3857 | display->atom (str)); |
3385 | display->atom (str)); |
3858 | } |
3386 | } |
3859 | break; |
3387 | break; |
3860 | |
3388 | |
3861 | case XTerm_Color: |
3389 | case XTerm_Color: |
… | |
… | |
3871 | break; |
3399 | break; |
3872 | |
3400 | |
3873 | if ((buf = strchr (name, ';')) != NULL) |
3401 | if ((buf = strchr (name, ';')) != NULL) |
3874 | *buf++ = '\0'; |
3402 | *buf++ = '\0'; |
3875 | |
3403 | |
3876 | if (name[0] == '?' && !name[1]) |
3404 | process_color_seq (op, color, name, resp); |
3877 | { |
|
|
3878 | unsigned short r, g, b; |
|
|
3879 | pix_colors_focused[color].get (display, r, g, b); |
|
|
3880 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3881 | } |
|
|
3882 | else |
|
|
3883 | set_window_color (color, name); |
|
|
3884 | } |
3405 | } |
3885 | break; |
3406 | break; |
3886 | case XTerm_Color00: |
3407 | case XTerm_Color00: |
3887 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3408 | process_color_seq (op, Color_fg, str, resp); |
3888 | break; |
3409 | break; |
3889 | case XTerm_Color01: |
3410 | case XTerm_Color01: |
3890 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3411 | process_color_seq (op, Color_bg, str, resp); |
3891 | break; |
3412 | break; |
3892 | #ifndef NO_CURSORCOLOR |
3413 | #ifndef NO_CURSORCOLOR |
3893 | case XTerm_Color_cursor: |
3414 | case XTerm_Color_cursor: |
3894 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3415 | process_color_seq (op, Color_cursor, str, resp); |
3895 | break; |
3416 | break; |
3896 | #endif |
3417 | #endif |
3897 | case XTerm_Color_pointer_fg: |
3418 | case XTerm_Color_pointer_fg: |
3898 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3419 | process_color_seq (op, Color_pointer_fg, str, resp); |
3899 | break; |
3420 | break; |
3900 | case XTerm_Color_pointer_bg: |
3421 | case XTerm_Color_pointer_bg: |
3901 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3422 | process_color_seq (op, Color_pointer_bg, str, resp); |
3902 | break; |
3423 | break; |
3903 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3424 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3904 | case XTerm_Color_RV: |
3425 | case XTerm_Color_RV: |
3905 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3426 | process_color_seq (op, Color_RV, str, resp); |
3906 | break; |
3427 | break; |
3907 | case Rxvt_Color_BD: |
3428 | case Rxvt_Color_BD: |
3908 | case URxvt_Color_BD: |
3429 | case URxvt_Color_BD: |
3909 | process_color_seq (op, Color_BD, str, resp); |
3430 | process_color_seq (op, Color_BD, str, resp); |
3910 | break; |
3431 | break; |
3911 | case Rxvt_Color_UL: |
3432 | case Rxvt_Color_UL: |
3912 | case URxvt_Color_UL: |
3433 | case URxvt_Color_UL: |
3913 | process_color_seq (op, Color_UL, str, resp); |
3434 | process_color_seq (op, Color_UL, str, resp); |
3914 | break; |
3435 | break; |
3915 | case URxvt_Color_IT: |
3436 | case URxvt_Color_IT: |
3916 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3437 | process_color_seq (op, Color_IT, str, resp); |
3917 | break; |
3438 | break; |
3918 | #endif |
3439 | #endif |
3919 | #if TRANSPARENT && TINTING |
3440 | #if TRANSPARENT && TINTING |
3920 | case URxvt_Color_tint: |
3441 | case URxvt_Color_tint: |
3921 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3442 | process_color_seq (op, Color_tint, str, resp); |
|
|
3443 | |
3922 | check_our_parents (); |
3444 | check_our_parents (); |
|
|
3445 | |
3923 | if (am_transparent) |
3446 | if (am_transparent) |
3924 | want_full_refresh = want_refresh = 1; |
3447 | want_full_refresh = want_refresh = 1; |
|
|
3448 | |
3925 | break; |
3449 | break; |
3926 | #endif |
3450 | #endif |
3927 | |
3451 | |
3928 | case Rxvt_Pixmap: |
3452 | case Rxvt_Pixmap: |
|
|
3453 | { |
3929 | if (*str != ';') |
3454 | if (*str != ';') |
3930 | { |
3455 | { |
3931 | #if XPM_BACKGROUND |
3456 | #if XPM_BACKGROUND |
3932 | scale_pixmap (""); /* reset to default scaling */ |
3457 | scale_pixmap (""); /* reset to default scaling */ |
3933 | set_bgPixmap (str); /* change pixmap */ |
3458 | set_bgPixmap (str); /* change pixmap */ |
3934 | scr_touch (true); |
3459 | scr_touch (true); |
3935 | #endif |
3460 | #endif |
3936 | } |
3461 | } |
3937 | |
3462 | |
|
|
3463 | int changed = 0; |
|
|
3464 | |
3938 | while ((str = strchr (str, ';')) != NULL) |
3465 | while ((str = strchr (str, ';')) != NULL) |
3939 | { |
3466 | { |
3940 | str++; |
3467 | str++; |
3941 | #if XPM_BACKGROUND |
3468 | #if XPM_BACKGROUND |
3942 | changed += scale_pixmap (str); |
3469 | changed += scale_pixmap (str); |
3943 | #endif |
3470 | #endif |
3944 | } |
3471 | } |
3945 | |
3472 | |
3946 | if (changed) |
3473 | if (changed) |
3947 | { |
3474 | { |
3948 | #ifdef XPM_BACKGROUND |
3475 | #ifdef XPM_BACKGROUND |
3949 | resize_pixmap (); |
3476 | resize_pixmap (); |
3950 | scr_touch (true); |
3477 | scr_touch (true); |
3951 | #endif |
3478 | #endif |
3952 | } |
3479 | } |
|
|
3480 | #if TRANSPARENT && defined(HAVE_AFTERIMAGE) |
|
|
3481 | if (option (Opt_transparent)) |
|
|
3482 | check_our_parents (); |
|
|
3483 | #endif |
|
|
3484 | } |
3953 | break; |
3485 | break; |
3954 | |
3486 | |
3955 | case Rxvt_restoreFG: |
3487 | case Rxvt_restoreFG: |
3956 | set_window_color (Color_fg, str); |
3488 | set_window_color (Color_fg, str); |
3957 | break; |
3489 | break; |
… | |
… | |
3961 | |
3493 | |
3962 | case XTerm_logfile: |
3494 | case XTerm_logfile: |
3963 | // TODO, when secure mode? |
3495 | // TODO, when secure mode? |
3964 | break; |
3496 | break; |
3965 | |
3497 | |
3966 | #ifdef MENUBAR |
|
|
3967 | case URxvt_Menu: |
|
|
3968 | if (OPTION (Opt_insecure)) |
|
|
3969 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3970 | break; |
|
|
3971 | #endif |
|
|
3972 | #if 0 |
3498 | #if 0 |
3973 | case Rxvt_dumpscreen: /* no error notices */ |
3499 | case Rxvt_dumpscreen: /* no error notices */ |
3974 | { |
3500 | { |
3975 | int fd; |
3501 | int fd; |
3976 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3502 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3989 | case URxvt_italicFont: |
3515 | case URxvt_italicFont: |
3990 | case URxvt_boldItalicFont: |
3516 | case URxvt_boldItalicFont: |
3991 | #endif |
3517 | #endif |
3992 | if (query) |
3518 | if (query) |
3993 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3519 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3994 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3520 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3995 | ? fontset[op - URxvt_font]->fontdesc : "", |
3521 | ? fontset[op - URxvt_font]->fontdesc : "", |
3996 | resp); |
3522 | resp); |
3997 | else |
3523 | else |
3998 | { |
3524 | { |
3999 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3525 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
4002 | allocated.push_back ((void *)res); |
3528 | allocated.push_back ((void *)res); |
4003 | set_fonts (); |
3529 | set_fonts (); |
4004 | } |
3530 | } |
4005 | break; |
3531 | break; |
4006 | |
3532 | |
4007 | #if ENABLE_FRILLS |
3533 | case URxvt_version: |
|
|
3534 | if (query) |
|
|
3535 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3536 | op, |
|
|
3537 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3538 | resp); |
|
|
3539 | break; |
|
|
3540 | |
|
|
3541 | #if !ENABLE_MINIMAL |
4008 | case URxvt_locale: |
3542 | case URxvt_locale: |
4009 | if (query) |
3543 | if (query) |
4010 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3544 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
4011 | else |
3545 | else |
4012 | { |
3546 | { |
4013 | set_locale (str); |
3547 | set_locale (str); |
4014 | pty.set_utf8_mode (enc_utf8); |
3548 | pty->set_utf8_mode (enc_utf8); |
4015 | init_xlocale (); |
3549 | init_xlocale (); |
4016 | } |
3550 | } |
4017 | break; |
3551 | break; |
4018 | |
3552 | |
4019 | case URxvt_view_up: |
3553 | case URxvt_view_up: |
… | |
… | |
4030 | break; |
3564 | break; |
4031 | #endif |
3565 | #endif |
4032 | |
3566 | |
4033 | #if ENABLE_PERL |
3567 | #if ENABLE_PERL |
4034 | case URxvt_perl: |
3568 | case URxvt_perl: |
4035 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3569 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
4036 | ; // no responses yet |
3570 | ; // no responses yet |
4037 | break; |
3571 | break; |
4038 | #endif |
3572 | #endif |
4039 | } |
3573 | } |
4040 | } |
3574 | } |
… | |
… | |
4072 | return state; |
3606 | return state; |
4073 | } |
3607 | } |
4074 | |
3608 | |
4075 | /* we're not using priv _yet_ */ |
3609 | /* we're not using priv _yet_ */ |
4076 | void |
3610 | void |
4077 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3611 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4078 | { |
3612 | { |
4079 | unsigned int i, j; |
3613 | unsigned int i, j; |
4080 | int state; |
3614 | int state; |
4081 | |
3615 | |
4082 | static const struct |
3616 | static const struct |
… | |
… | |
4093 | { 5, PrivMode_rVideo }, |
3627 | { 5, PrivMode_rVideo }, |
4094 | { 6, PrivMode_relOrigin }, |
3628 | { 6, PrivMode_relOrigin }, |
4095 | { 7, PrivMode_Autowrap }, |
3629 | { 7, PrivMode_Autowrap }, |
4096 | // 8, bi-directional support mode |
3630 | // 8, bi-directional support mode |
4097 | { 9, PrivMode_MouseX10 }, |
3631 | { 9, PrivMode_MouseX10 }, |
4098 | #ifdef menuBar_esc |
|
|
4099 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4100 | #endif |
|
|
4101 | // 18, 19 printing-related |
3632 | // 18, 19 printing-related |
4102 | { 25, PrivMode_VisibleCursor }, |
3633 | { 25, PrivMode_VisibleCursor }, |
4103 | #ifdef scrollBar_esc |
3634 | #ifdef scrollBar_esc |
4104 | { scrollBar_esc, PrivMode_scrollBar }, |
3635 | { scrollBar_esc, PrivMode_scrollBar }, |
4105 | #endif |
3636 | #endif |
… | |
… | |
4159 | scr_touch (true); |
3690 | scr_touch (true); |
4160 | break; |
3691 | break; |
4161 | #endif |
3692 | #endif |
4162 | case 1048: /* alternative cursor save */ |
3693 | case 1048: /* alternative cursor save */ |
4163 | case 1049: |
3694 | case 1049: |
4164 | if (OPTION (Opt_secondaryScreen)) |
3695 | if (option (Opt_secondaryScreen)) |
4165 | if (mode == 0) |
3696 | if (mode == 0) |
4166 | scr_cursor (RESTORE); |
3697 | scr_cursor (RESTORE); |
4167 | else if (mode == 1) |
3698 | else if (mode == 1) |
4168 | scr_cursor (SAVE); |
3699 | scr_cursor (SAVE); |
4169 | break; |
3700 | break; |
… | |
… | |
4200 | /* case 8: - auto repeat, can't do on a per window basis */ |
3731 | /* case 8: - auto repeat, can't do on a per window basis */ |
4201 | case 9: /* X10 mouse reporting */ |
3732 | case 9: /* X10 mouse reporting */ |
4202 | if (state) /* orthogonal */ |
3733 | if (state) /* orthogonal */ |
4203 | priv_modes &= ~PrivMode_MouseX11; |
3734 | priv_modes &= ~PrivMode_MouseX11; |
4204 | break; |
3735 | break; |
4205 | #ifdef menuBar_esc |
|
|
4206 | case menuBar_esc: |
|
|
4207 | #ifdef MENUBAR |
|
|
4208 | map_menuBar (state); |
|
|
4209 | #endif |
|
|
4210 | break; |
|
|
4211 | #endif |
|
|
4212 | #ifdef scrollBar_esc |
3736 | #ifdef scrollBar_esc |
4213 | case scrollBar_esc: |
3737 | case scrollBar_esc: |
4214 | if (scrollbar_mapping (state)) |
3738 | if (scrollbar_mapping (state)) |
4215 | { |
3739 | { |
4216 | resize_all_windows (0, 0, 0); |
3740 | resize_all_windows (0, 0, 0); |
… | |
… | |
4241 | break; |
3765 | break; |
4242 | case 1011: /* scroll to bottom on key press */ |
3766 | case 1011: /* scroll to bottom on key press */ |
4243 | set_option (Opt_scrollTtyKeypress, state); |
3767 | set_option (Opt_scrollTtyKeypress, state); |
4244 | break; |
3768 | break; |
4245 | case 1047: /* secondary screen w/ clearing last */ |
3769 | case 1047: /* secondary screen w/ clearing last */ |
4246 | if (OPTION (Opt_secondaryScreen)) |
3770 | if (option (Opt_secondaryScreen)) |
4247 | if (current_screen != PRIMARY) |
3771 | if (current_screen != PRIMARY) |
4248 | scr_erase_screen (2); |
3772 | scr_erase_screen (2); |
4249 | scr_change_screen (state); |
3773 | scr_change_screen (state); |
4250 | break; |
3774 | break; |
4251 | case 1049: /* secondary screen w/ clearing first */ |
3775 | case 1049: /* secondary screen w/ clearing first */ |
4252 | scr_change_screen (state); |
3776 | scr_change_screen (state); |
4253 | if (OPTION (Opt_secondaryScreen)) |
3777 | if (option (Opt_secondaryScreen)) |
4254 | if (current_screen != PRIMARY) |
3778 | if (current_screen != PRIMARY) |
4255 | scr_erase_screen (2); |
3779 | scr_erase_screen (2); |
4256 | break; |
3780 | break; |
4257 | default: |
3781 | default: |
4258 | break; |
3782 | break; |
… | |
… | |
4386 | scr_color (Color_bg, Color_bg); |
3910 | scr_color (Color_bg, Color_bg); |
4387 | break; |
3911 | break; |
4388 | |
3912 | |
4389 | //case 50: // not variable spacing |
3913 | //case 50: // not variable spacing |
4390 | |
3914 | |
4391 | #if ENABLE_FRILLS |
3915 | #if !ENABLE_MINIMAL |
4392 | case 90: |
3916 | case 90: |
4393 | case 91: /* set bright fg color */ |
3917 | case 91: /* set bright fg color */ |
4394 | case 92: |
3918 | case 92: |
4395 | case 93: |
3919 | case 93: |
4396 | case 94: |
3920 | case 94: |
… | |
… | |
4461 | rxvt_term::tt_write (const char *data, unsigned int len) |
3985 | rxvt_term::tt_write (const char *data, unsigned int len) |
4462 | { |
3986 | { |
4463 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
3987 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4464 | return; |
3988 | return; |
4465 | |
3989 | |
4466 | if (pty.pty < 0) |
3990 | if (pty->pty < 0) |
4467 | return; |
3991 | return; |
4468 | |
3992 | |
4469 | if (v_buflen == 0) |
3993 | if (v_buflen == 0) |
4470 | { |
3994 | { |
4471 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
3995 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4472 | |
3996 | |
4473 | if ((unsigned int)written == len) |
3997 | if ((unsigned int)written == len) |
4474 | return; |
3998 | return; |
4475 | |
3999 | |
4476 | data += written; |
4000 | data += written; |
… | |
… | |
4485 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4009 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4486 | } |
4010 | } |
4487 | |
4011 | |
4488 | void rxvt_term::pty_write () |
4012 | void rxvt_term::pty_write () |
4489 | { |
4013 | { |
4490 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4014 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4491 | |
4015 | |
4492 | if (written > 0) |
4016 | if (written > 0) |
4493 | { |
4017 | { |
4494 | v_buflen -= written; |
4018 | v_buflen -= written; |
4495 | |
4019 | |