… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
|
|
53 | |
|
|
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
52 | |
58 | |
53 | #ifdef KEYSYM_RESOURCE |
59 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
60 | # include "keyboard.h" |
55 | #endif |
61 | #endif |
56 | |
62 | |
… | |
… | |
147 | |
153 | |
148 | text_t t = l.t[x]; |
154 | text_t t = l.t[x]; |
149 | |
155 | |
150 | if (t != NOCHAR || !x) |
156 | if (t != NOCHAR || !x) |
151 | { |
157 | { |
152 | iso14755_51 (l.t[x], l.r[x]); |
158 | iso14755_51 (l.t[x], l.r[x], x, y); |
153 | iso14755buf = ISO_14755_54; |
159 | iso14755buf = ISO_14755_54; |
154 | break; |
160 | break; |
155 | } |
161 | } |
156 | |
162 | |
157 | x--; |
163 | x--; |
158 | } |
164 | } |
159 | } |
165 | } |
160 | #endif |
|
|
161 | |
166 | |
162 | #if ENABLE_OVERLAY |
|
|
163 | void |
167 | void |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
168 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
165 | { |
169 | { |
166 | rxvt_fontset *fs = FONTSET (r); |
170 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
171 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
172 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
173 | int len; |
170 | |
174 | |
171 | fname = rxvt_utf8towcs (f->name); |
175 | fname = rxvt_utf8towcs (f->name); |
172 | |
176 | |
173 | #if ENABLE_COMBINING |
177 | # if ENABLE_COMBINING |
174 | if (IS_COMPOSE (ch)) |
178 | if (IS_COMPOSE (ch)) |
175 | { |
179 | { |
176 | len = rxvt_composite.expand (ch, 0); |
180 | len = rxvt_composite.expand (ch, 0); |
177 | alloc = chr = new wchar_t[len]; |
181 | alloc = chr = new wchar_t[len]; |
178 | rxvt_composite.expand (ch, chr); |
182 | rxvt_composite.expand (ch, chr); |
179 | } |
183 | } |
180 | else |
184 | else |
181 | #endif |
185 | # endif |
182 | { |
186 | { |
183 | ch2 = ch; |
187 | ch2 = ch; |
184 | |
188 | |
185 | alloc = 0; |
189 | alloc = 0; |
186 | chr = &ch2; |
190 | chr = &ch2; |
… | |
… | |
189 | |
193 | |
190 | char attr[80]; // plenty |
194 | char attr[80]; // plenty |
191 | |
195 | |
192 | sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s", |
196 | sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s", |
193 | (int)r, |
197 | (int)r, |
194 | GET_FGCOLOR (r), GET_BGCOLOR (r), |
198 | fgcolor_of (r), bgcolor_of (r), |
195 | r & RS_Bold ? " bold" : "", |
199 | r & RS_Bold ? " bold" : "", |
196 | r & RS_Italic ? " italic" : "", |
200 | r & RS_Italic ? " italic" : "", |
197 | r & RS_Blink ? " blink" : "", |
201 | r & RS_Blink ? " blink" : "", |
198 | r & RS_RVid ? " rvid" : "", |
202 | r & RS_RVid ? " rvid" : "", |
199 | r & RS_Uline ? " uline" : "", |
203 | r & RS_Uline ? " uline" : "", |
… | |
… | |
202 | int width = wcswidth (fname, wcslen (fname)); |
206 | int width = wcswidth (fname, wcslen (fname)); |
203 | |
207 | |
204 | max_it (width, 8+5); // for char + hey |
208 | max_it (width, 8+5); // for char + hey |
205 | max_it (width, strlen (attr)); |
209 | max_it (width, strlen (attr)); |
206 | |
210 | |
|
|
211 | if (y >= 0) |
|
|
212 | { |
|
|
213 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
|
|
214 | x = 0; |
|
|
215 | } |
|
|
216 | |
207 | scr_overlay_new (0, -1, width, len + 2); |
217 | scr_overlay_new (x, y, width, len + 2); |
208 | |
218 | |
209 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
219 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
210 | |
220 | |
211 | for (int y = 0; y < len; y++) |
221 | for (int y = 0; y < len; y++) |
212 | { |
222 | { |
… | |
… | |
215 | ch = *chr++; |
225 | ch = *chr++; |
216 | |
226 | |
217 | sprintf (buf, "%8x", ch); |
227 | sprintf (buf, "%8x", ch); |
218 | scr_overlay_set (0, y, buf); |
228 | scr_overlay_set (0, y, buf); |
219 | scr_overlay_set (9, y, '='); |
229 | scr_overlay_set (9, y, '='); |
220 | #if !UNICODE3 |
230 | # if !UNICODE3 |
221 | if (ch >= 0x10000) |
231 | if (ch >= 0x10000) |
222 | ch = 0xfffd; |
232 | ch = 0xfffd; |
223 | #endif |
233 | # endif |
224 | scr_overlay_set (11, y, ch, r); |
234 | scr_overlay_set (11, y, ch, r); |
225 | scr_overlay_set (12, y, NOCHAR, r); |
235 | scr_overlay_set (12, y, NOCHAR, r); |
226 | } |
236 | } |
227 | |
237 | |
228 | scr_overlay_set (0, len , attr); |
238 | scr_overlay_set (0, len , attr); |
229 | scr_overlay_set (0, len + 1, fname); |
239 | scr_overlay_set (0, len + 1, fname); |
230 | |
240 | |
231 | free (fname); |
241 | free (fname); |
232 | |
242 | |
233 | #if ENABLE_COMBINING |
243 | # if ENABLE_COMBINING |
234 | if (alloc) |
244 | if (alloc) |
235 | delete [] alloc; |
245 | delete [] alloc; |
236 | #endif |
246 | # endif |
237 | } |
247 | } |
238 | #endif |
248 | #endif |
239 | |
249 | |
240 | void |
250 | void |
241 | rxvt_term::commit_iso14755 () |
251 | rxvt_term::commit_iso14755 () |
… | |
… | |
258 | mb[0] = ch[0]; |
268 | mb[0] = ch[0]; |
259 | len = 1; |
269 | len = 1; |
260 | } |
270 | } |
261 | |
271 | |
262 | if (len > 0) |
272 | if (len > 0) |
263 | tt_write ((unsigned char *)mb, len); |
273 | tt_write (mb, len); |
264 | else |
274 | else |
265 | scr_bell (); |
275 | scr_bell (); |
266 | } |
276 | } |
267 | |
277 | |
268 | iso14755buf = 0; |
278 | iso14755buf = 0; |
… | |
… | |
296 | KeySym keysym; |
306 | KeySym keysym; |
297 | #ifdef DEBUG_CMD |
307 | #ifdef DEBUG_CMD |
298 | static int debug_key = 1; /* accessible by a debugger only */ |
308 | static int debug_key = 1; /* accessible by a debugger only */ |
299 | #endif |
309 | #endif |
300 | int valid_keysym; |
310 | int valid_keysym; |
301 | unsigned char kbuf[KBUFSZ]; |
311 | char kbuf[KBUFSZ]; |
302 | |
312 | |
303 | /* |
313 | /* |
304 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
305 | * escape sequence to toggle the Keypad. |
315 | * escape sequence to toggle the Keypad. |
306 | * |
316 | * |
… | |
… | |
324 | Status status_return; |
334 | Status status_return; |
325 | |
335 | |
326 | #if 0 |
336 | #if 0 |
327 | #ifdef X_HAVE_UTF8_STRING |
337 | #ifdef X_HAVE_UTF8_STRING |
328 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
329 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
339 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
330 | KBUFSZ, &keysym, &status_return); |
340 | KBUFSZ, &keysym, &status_return); |
331 | else |
341 | else |
332 | #endif |
342 | #endif |
333 | #endif |
343 | #endif |
334 | { |
344 | { |
… | |
… | |
371 | || status_return == XLookupBoth; |
381 | || status_return == XLookupBoth; |
372 | } |
382 | } |
373 | else |
383 | else |
374 | #endif |
384 | #endif |
375 | { |
385 | { |
376 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
386 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
377 | valid_keysym = keysym != NoSymbol; |
387 | valid_keysym = keysym != NoSymbol; |
378 | } |
388 | } |
379 | |
389 | |
380 | if (valid_keysym) |
390 | if (valid_keysym) |
381 | { |
391 | { |
… | |
… | |
845 | { |
855 | { |
846 | #ifdef META8_OPTION |
856 | #ifdef META8_OPTION |
847 | /* set 8-bit on */ |
857 | /* set 8-bit on */ |
848 | if (meta && (meta_char == 0x80)) |
858 | if (meta && (meta_char == 0x80)) |
849 | { |
859 | { |
850 | unsigned char *ch; |
860 | char *ch; |
851 | |
861 | |
852 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | for (ch = kbuf; ch < kbuf + len; ch++) |
853 | *ch |= 0x80; |
863 | *ch |= 0x80; |
854 | |
864 | |
855 | meta = 0; |
865 | meta = 0; |
… | |
… | |
857 | #endif |
867 | #endif |
858 | /* nil */ ; |
868 | /* nil */ ; |
859 | } |
869 | } |
860 | } |
870 | } |
861 | |
871 | |
|
|
872 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
873 | return; |
|
|
874 | |
862 | if (len <= 0) |
875 | if (len <= 0) |
863 | return; /* not mapped */ |
876 | return; /* not mapped */ |
864 | |
877 | |
865 | if (options & Opt_scrollTtyKeypress) |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
866 | if (view_start) |
879 | if (view_start) |
867 | { |
880 | { |
868 | view_start = 0; |
881 | view_start = 0; |
869 | want_refresh = 1; |
882 | want_refresh = 1; |
870 | } |
883 | } |
… | |
… | |
888 | #ifdef META8_OPTION |
901 | #ifdef META8_OPTION |
889 | && meta_char == C0_ESC |
902 | && meta_char == C0_ESC |
890 | #endif |
903 | #endif |
891 | ) |
904 | ) |
892 | { |
905 | { |
893 | const unsigned char ch = C0_ESC; |
906 | const char ch = C0_ESC; |
894 | tt_write (&ch, 1); |
907 | tt_write (&ch, 1); |
895 | } |
908 | } |
896 | |
909 | |
897 | #if defined(DEBUG_CMD) |
910 | #if defined(DEBUG_CMD) |
898 | /* Display keyboard buffer contents */ |
911 | /* Display keyboard buffer contents */ |
… | |
… | |
910 | |
923 | |
911 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
924 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
912 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
925 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
913 | /* attempt to `write' count to the input buffer */ |
926 | /* attempt to `write' count to the input buffer */ |
914 | unsigned int |
927 | unsigned int |
915 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
928 | rxvt_term::cmd_write (const char *str, unsigned int count) |
916 | { |
929 | { |
917 | unsigned int n, s; |
930 | unsigned int n, s; |
918 | |
931 | |
919 | n = cmdbuf_ptr - cmdbuf_base; |
932 | n = cmdbuf_ptr - cmdbuf_base; |
920 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
933 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
957 | } |
970 | } |
958 | #endif |
971 | #endif |
959 | |
972 | |
960 | if (want_refresh) |
973 | if (want_refresh) |
961 | { |
974 | { |
|
|
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
976 | { |
|
|
977 | int row = -view_start; |
|
|
978 | int end_row = row + nrow; |
|
|
979 | |
|
|
980 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
|
|
981 | --row; |
|
|
982 | |
|
|
983 | do |
|
|
984 | { |
|
|
985 | int start_row = row; |
|
|
986 | line_t *l; |
|
|
987 | |
|
|
988 | do |
|
|
989 | { |
|
|
990 | l = &ROW (row++); |
|
|
991 | |
|
|
992 | if (!(l->f & LINE_FILTERED)) |
|
|
993 | { |
|
|
994 | // line not filtered, mark it as filtered |
|
|
995 | l->f |= LINE_FILTERED; |
|
|
996 | while (l->is_longer ()) |
|
|
997 | { |
|
|
998 | l = &ROW (row++); |
|
|
999 | l->f |= LINE_FILTERED; |
|
|
1000 | } |
|
|
1001 | |
|
|
1002 | // and filter it |
|
|
1003 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1004 | |
|
|
1005 | break; |
|
|
1006 | } |
|
|
1007 | } |
|
|
1008 | while (l->is_longer () && row < end_row); |
|
|
1009 | } |
|
|
1010 | while (row < end_row); |
|
|
1011 | } |
|
|
1012 | |
962 | scr_refresh (refresh_type); |
1013 | scr_refresh (refresh_type); |
963 | scrollbar_show (1); |
1014 | scrollbar_show (1); |
964 | #ifdef USE_XIM |
1015 | #ifdef USE_XIM |
965 | IMSendSpot (); |
1016 | IMSendSpot (); |
966 | #endif |
1017 | #endif |
… | |
… | |
976 | SET_LOCALE (locale); |
1027 | SET_LOCALE (locale); |
977 | |
1028 | |
978 | display->flush (); |
1029 | display->flush (); |
979 | |
1030 | |
980 | if (want_refresh && !flush_ev.active) |
1031 | if (want_refresh && !flush_ev.active) |
981 | flush_ev.start (NOW + 0.01); |
1032 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
982 | } |
1033 | } |
983 | |
1034 | |
984 | void |
1035 | void |
985 | rxvt_term::flush_cb (time_watcher &w) |
1036 | rxvt_term::flush_cb (time_watcher &w) |
986 | { |
1037 | { |
… | |
… | |
1061 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1112 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1062 | } |
1113 | } |
1063 | } |
1114 | } |
1064 | #endif |
1115 | #endif |
1065 | |
1116 | |
|
|
1117 | #if HAVE_SCHED_YIELD |
|
|
1118 | static struct event_handler |
|
|
1119 | { |
|
|
1120 | check_watcher cw_yield; |
|
|
1121 | |
|
|
1122 | void yield (check_watcher &w) |
|
|
1123 | { |
|
|
1124 | sched_yield (); |
|
|
1125 | w.stop (); |
|
|
1126 | } |
|
|
1127 | |
|
|
1128 | event_handler () |
|
|
1129 | : cw_yield (this, &event_handler::yield) |
|
|
1130 | { |
|
|
1131 | } |
|
|
1132 | } event_handler; |
|
|
1133 | #endif |
|
|
1134 | |
1066 | bool |
1135 | bool |
1067 | rxvt_term::pty_fill () |
1136 | rxvt_term::pty_fill () |
1068 | { |
1137 | { |
1069 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1138 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1070 | |
1139 | |
1071 | if (CBUFSIZ == n) |
1140 | if (CBUFSIZ == n) |
1072 | { |
1141 | { |
1073 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1142 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1074 | n = 0; |
1143 | n = 0; |
1075 | } |
1144 | } |
1076 | |
1145 | |
1077 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1146 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1078 | cmdbuf_ptr = cmdbuf_base; |
1147 | cmdbuf_ptr = cmdbuf_base; |
1079 | cmdbuf_endp = cmdbuf_ptr + n; |
1148 | cmdbuf_endp = cmdbuf_ptr + n; |
1080 | |
1149 | |
1081 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1150 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1082 | |
1151 | |
1083 | if (n > 0) |
1152 | if (r > 0) |
1084 | { |
1153 | { |
1085 | cmdbuf_endp += n; |
1154 | cmdbuf_endp += r; |
1086 | return true; |
1155 | return true; |
1087 | } |
1156 | } |
1088 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1157 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1158 | { |
|
|
1159 | #if HAVE_SCHED_YIELD |
|
|
1160 | if (display->is_local) |
|
|
1161 | event_handler.cw_yield.start (); |
|
|
1162 | #endif |
|
|
1163 | } |
|
|
1164 | else |
1089 | { |
1165 | { |
1090 | pty_ev.stop (); |
1166 | pty_ev.stop (); |
1091 | |
1167 | |
1092 | if (!(options & Opt_hold)) |
1168 | if (!OPTION (Opt_hold)) |
1093 | destroy (); |
1169 | destroy (); |
1094 | } |
1170 | } |
1095 | |
1171 | |
1096 | return false; |
1172 | return false; |
1097 | } |
1173 | } |
… | |
… | |
1119 | recolour_cursor (); |
1195 | recolour_cursor (); |
1120 | |
1196 | |
1121 | #ifdef POINTER_BLANK |
1197 | #ifdef POINTER_BLANK |
1122 | hidden_pointer = 0; |
1198 | hidden_pointer = 0; |
1123 | |
1199 | |
1124 | if (options & Opt_pointerBlank) |
1200 | if (OPTION (Opt_pointerBlank)) |
1125 | pointer_ev.start (NOW + pointerBlankDelay); |
1201 | pointer_ev.start (NOW + pointerBlankDelay); |
1126 | #endif |
1202 | #endif |
1127 | } |
1203 | } |
1128 | |
1204 | |
1129 | #ifdef POINTER_BLANK |
1205 | #ifdef POINTER_BLANK |
1130 | void |
1206 | void |
1131 | rxvt_term::pointer_blank () |
1207 | rxvt_term::pointer_blank () |
1132 | { |
1208 | { |
1133 | if (! (options & Opt_pointerBlank)) |
1209 | if (!OPTION (Opt_pointerBlank)) |
1134 | return; |
1210 | return; |
1135 | |
1211 | |
1136 | XDefineCursor (display->display, vt, display->blank_cursor); |
1212 | XDefineCursor (display->display, vt, display->blank_cursor); |
1137 | XFlush (display->display); |
1213 | XFlush (display->display); |
1138 | |
1214 | |
… | |
… | |
1235 | dDisp; |
1311 | dDisp; |
1236 | |
1312 | |
1237 | SET_R (this); |
1313 | SET_R (this); |
1238 | SET_LOCALE (locale); |
1314 | SET_LOCALE (locale); |
1239 | |
1315 | |
1240 | #if defined(CURSOR_BLINK) |
1316 | if (ev.xany.window == vt |
1241 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1317 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1242 | { |
1318 | return; |
1243 | if (hidden_cursor) |
|
|
1244 | { |
|
|
1245 | hidden_cursor = 0; |
|
|
1246 | want_refresh = 1; |
|
|
1247 | } |
|
|
1248 | |
1319 | |
1249 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1320 | // for XQueryPointer |
1250 | } |
|
|
1251 | #endif |
|
|
1252 | |
|
|
1253 | #if defined(POINTER_BLANK) |
|
|
1254 | if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1255 | { |
|
|
1256 | if (ev.type == MotionNotify |
|
|
1257 | || ev.type == ButtonPress |
|
|
1258 | || ev.type == ButtonRelease) |
|
|
1259 | if (hidden_pointer) |
|
|
1260 | pointer_unblank (); |
|
|
1261 | |
|
|
1262 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1263 | pointer_blank (); |
|
|
1264 | } |
|
|
1265 | #endif |
|
|
1266 | |
|
|
1267 | Window unused_root, unused_child; |
1321 | Window unused_root, unused_child; |
1268 | int unused_root_x, unused_root_y; |
1322 | int unused_root_x, unused_root_y; |
1269 | unsigned int unused_mask; |
1323 | unsigned int unused_mask; |
1270 | |
1324 | |
1271 | switch (ev.type) |
1325 | switch (ev.type) |
… | |
… | |
1278 | |
1332 | |
1279 | break; |
1333 | break; |
1280 | |
1334 | |
1281 | case KeyRelease: |
1335 | case KeyRelease: |
1282 | { |
1336 | { |
1283 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1337 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1284 | KeySym ks; |
1338 | KeySym keysym; |
1285 | |
1339 | |
1286 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1340 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1287 | #endif |
1341 | #endif |
1288 | |
1342 | |
1289 | #if ENABLE_FRILLS || ISO_14755 |
1343 | #if ENABLE_FRILLS || ISO_14755 |
1290 | // ISO 14755 support |
1344 | // ISO 14755 support |
1291 | if (iso14755buf) |
1345 | if (iso14755buf) |
… | |
… | |
1296 | # endif |
1350 | # endif |
1297 | # if ISO_14755 |
1351 | # if ISO_14755 |
1298 | // iso14755 part 5.2 handling: release time |
1352 | // iso14755 part 5.2 handling: release time |
1299 | // first: controls |
1353 | // first: controls |
1300 | if ((ev.xkey.state & ControlMask) |
1354 | if ((ev.xkey.state & ControlMask) |
1301 | && ((ks >= 0x40 && ks <= 0x5f) |
1355 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1302 | || (ks >= 0x61 && ks <= 0x7f))) |
1356 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1303 | { |
1357 | { |
1304 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1358 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1305 | commit_iso14755 (); |
1359 | commit_iso14755 (); |
1306 | return; // case-break; |
1360 | goto skip_switch; |
1307 | } |
1361 | } |
1308 | |
1362 | |
1309 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1363 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1310 | if (i[0] == ks) |
1364 | if (i[0] == keysym) |
1311 | { |
1365 | { |
1312 | iso14755buf = ISO_14755_51 | i[1]; |
1366 | iso14755buf = ISO_14755_51 | i[1]; |
1313 | commit_iso14755 (); |
1367 | commit_iso14755 (); |
1314 | return; // case-break; |
1368 | goto skip_switch; |
1315 | } |
1369 | } |
1316 | |
1370 | |
1317 | scr_bell (); |
1371 | scr_bell (); |
1318 | # endif |
1372 | # endif |
1319 | iso14755buf = 0; |
1373 | iso14755buf = 0; |
… | |
… | |
1338 | else |
1392 | else |
1339 | iso14755buf = 0; |
1393 | iso14755buf = 0; |
1340 | } |
1394 | } |
1341 | #endif |
1395 | #endif |
1342 | |
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 | |
1343 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1401 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1344 | if (!(ev.xkey.state & ControlMask)) |
1402 | if (!(ev.xkey.state & ControlMask)) |
1345 | slip_wheel_ev.stop (); |
1403 | slip_wheel_ev.stop (); |
1346 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1404 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1347 | mouse_slip_wheel_speed = 0; |
1405 | mouse_slip_wheel_speed = 0; |
1348 | #endif |
1406 | #endif |
1349 | break; |
1407 | break; |
1350 | } |
1408 | } |
1351 | |
1409 | |
… | |
… | |
1455 | seen_resize = 1; |
1513 | seen_resize = 1; |
1456 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1514 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1457 | } |
1515 | } |
1458 | |
1516 | |
1459 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1517 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1460 | if (options & Opt_transparent) |
1518 | if (OPTION (Opt_transparent)) |
1461 | check_our_parents (); |
1519 | check_our_parents (); |
1462 | #endif |
1520 | #endif |
1463 | } |
1521 | } |
1464 | break; |
1522 | break; |
1465 | |
1523 | |
… | |
… | |
1481 | |
1539 | |
1482 | case SelectionRequest: |
1540 | case SelectionRequest: |
1483 | selection_send (ev.xselectionrequest); |
1541 | selection_send (ev.xselectionrequest); |
1484 | break; |
1542 | break; |
1485 | |
1543 | |
|
|
1544 | case MapNotify: |
|
|
1545 | mapped = 1; |
|
|
1546 | #ifdef TEXT_BLINK |
|
|
1547 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1548 | #endif |
|
|
1549 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1550 | break; |
|
|
1551 | |
1486 | case UnmapNotify: |
1552 | case UnmapNotify: |
1487 | mapped = 0; |
1553 | mapped = 0; |
1488 | #ifdef TEXT_BLINK |
1554 | #ifdef TEXT_BLINK |
1489 | text_blink_ev.stop (); |
1555 | text_blink_ev.stop (); |
1490 | #endif |
1556 | #endif |
1491 | break; |
1557 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1492 | |
|
|
1493 | case MapNotify: |
|
|
1494 | mapped = 1; |
|
|
1495 | #ifdef TEXT_BLINK |
|
|
1496 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1497 | #endif |
|
|
1498 | break; |
1558 | break; |
1499 | |
1559 | |
1500 | #ifdef TRANSPARENT |
1560 | #ifdef TRANSPARENT |
1501 | case ReparentNotify: |
1561 | case ReparentNotify: |
1502 | rootwin_cb (ev); |
1562 | rootwin_cb (ev); |
… | |
… | |
1516 | |
1576 | |
1517 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1577 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1518 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1578 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1519 | ev.xexpose.width, ev.xexpose.height, False); |
1579 | ev.xexpose.width, ev.xexpose.height, False); |
1520 | |
1580 | |
1521 | scr_refresh (refresh_type); |
1581 | want_refresh = 1; |
1522 | } |
1582 | } |
1523 | else |
1583 | else |
1524 | { |
1584 | { |
1525 | XEvent unused_event; |
1585 | XEvent unused_event; |
1526 | |
1586 | |
… | |
… | |
1545 | #endif |
1605 | #endif |
1546 | } |
1606 | } |
1547 | break; |
1607 | break; |
1548 | |
1608 | |
1549 | case MotionNotify: |
1609 | case MotionNotify: |
|
|
1610 | printf ("motion notify\n");//D |
1550 | #ifdef POINTER_BLANK |
1611 | #ifdef POINTER_BLANK |
1551 | if (hidden_pointer) |
1612 | if (hidden_pointer) |
1552 | pointer_unblank (); |
1613 | pointer_unblank (); |
1553 | #endif |
1614 | #endif |
1554 | #if MENUBAR |
1615 | #if MENUBAR |
… | |
… | |
1561 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1622 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1562 | break; |
1623 | break; |
1563 | |
1624 | |
1564 | if (ev.xany.window == vt) |
1625 | if (ev.xany.window == vt) |
1565 | { |
1626 | { |
|
|
1627 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1628 | ; // nop |
1566 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1629 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1567 | { |
1630 | { |
1568 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1631 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1569 | ; |
1632 | ; |
1570 | |
1633 | |
1571 | XQueryPointer (disp, vt, |
1634 | XQueryPointer (disp, vt, |
… | |
… | |
1651 | &unused_root_x, &unused_root_y, |
1714 | &unused_root_x, &unused_root_y, |
1652 | &ev.xbutton.x, &ev.xbutton.y, |
1715 | &ev.xbutton.x, &ev.xbutton.y, |
1653 | &unused_mask); |
1716 | &unused_mask); |
1654 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1717 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1655 | scrollbar_size ()); |
1718 | scrollbar_size ()); |
1656 | scr_refresh (refresh_type); |
1719 | want_refresh = 1; |
1657 | refresh_limit = 0; |
1720 | refresh_limit = 0; |
1658 | scrollbar_show (1); |
1721 | scrollbar_show (1); |
1659 | } |
1722 | } |
1660 | break; |
1723 | break; |
1661 | } |
1724 | } |
|
|
1725 | |
|
|
1726 | skip_switch: ; |
|
|
1727 | |
|
|
1728 | #if defined(CURSOR_BLINK) |
|
|
1729 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1730 | { |
|
|
1731 | if (hidden_cursor) |
|
|
1732 | { |
|
|
1733 | hidden_cursor = 0; |
|
|
1734 | want_refresh = 1; |
|
|
1735 | } |
|
|
1736 | |
|
|
1737 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1738 | } |
|
|
1739 | #endif |
|
|
1740 | |
|
|
1741 | #if defined(POINTER_BLANK) |
|
|
1742 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1743 | { |
|
|
1744 | if (ev.type == MotionNotify |
|
|
1745 | || ev.type == ButtonPress |
|
|
1746 | || ev.type == ButtonRelease) |
|
|
1747 | if (hidden_pointer) |
|
|
1748 | pointer_unblank (); |
|
|
1749 | |
|
|
1750 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1751 | pointer_blank (); |
|
|
1752 | } |
|
|
1753 | #endif |
1662 | } |
1754 | } |
1663 | |
1755 | |
1664 | void |
1756 | void |
1665 | rxvt_term::focus_in () |
1757 | rxvt_term::focus_in () |
1666 | { |
1758 | { |
1667 | if (!focus) |
1759 | if (!focus) |
1668 | { |
1760 | { |
1669 | focus = 1; |
1761 | focus = 1; |
1670 | want_refresh = 1; |
1762 | want_refresh = 1; |
|
|
1763 | |
|
|
1764 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1765 | |
1671 | #if USE_XIM |
1766 | #if USE_XIM |
1672 | if (Input_Context != NULL) |
1767 | if (Input_Context != NULL) |
1673 | { |
1768 | { |
1674 | IMSetStatusPosition (); |
1769 | IMSetStatusPosition (); |
1675 | XSetICFocus (Input_Context); |
1770 | XSetICFocus (Input_Context); |
1676 | } |
1771 | } |
1677 | #endif |
1772 | #endif |
1678 | #if CURSOR_BLINK |
1773 | #if CURSOR_BLINK |
1679 | if (options & Opt_cursorBlink) |
1774 | if (OPTION (Opt_cursorBlink)) |
1680 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1775 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1681 | #endif |
1776 | #endif |
1682 | #if OFF_FOCUS_FADING |
1777 | #if OFF_FOCUS_FADING |
1683 | if (rs[Rs_fade]) |
1778 | if (rs[Rs_fade]) |
1684 | { |
1779 | { |
… | |
… | |
1695 | if (focus) |
1790 | if (focus) |
1696 | { |
1791 | { |
1697 | focus = 0; |
1792 | focus = 0; |
1698 | want_refresh = 1; |
1793 | want_refresh = 1; |
1699 | |
1794 | |
|
|
1795 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1796 | |
1700 | #if ENABLE_FRILLS || ISO_14755 |
1797 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1798 | if (iso14755buf) |
|
|
1799 | { |
1701 | iso14755buf = 0; |
1800 | iso14755buf = 0; |
1702 | #endif |
|
|
1703 | #if ENABLE_OVERLAY |
1801 | # if ENABLE_OVERLAY |
1704 | scr_overlay_off (); |
1802 | scr_overlay_off (); |
|
|
1803 | # endif |
|
|
1804 | } |
1705 | #endif |
1805 | #endif |
1706 | #if USE_XIM |
1806 | #if USE_XIM |
1707 | if (Input_Context != NULL) |
1807 | if (Input_Context != NULL) |
1708 | XUnsetICFocus (Input_Context); |
1808 | XUnsetICFocus (Input_Context); |
1709 | #endif |
1809 | #endif |
1710 | #if CURSOR_BLINK |
1810 | #if CURSOR_BLINK |
1711 | if (options & Opt_cursorBlink) |
1811 | if (OPTION (Opt_cursorBlink)) |
1712 | cursor_blink_ev.stop (); |
1812 | cursor_blink_ev.stop (); |
1713 | hidden_cursor = 0; |
1813 | hidden_cursor = 0; |
1714 | #endif |
1814 | #endif |
1715 | #if OFF_FOCUS_FADING |
1815 | #if OFF_FOCUS_FADING |
1716 | if (rs[Rs_fade]) |
1816 | if (rs[Rs_fade]) |
… | |
… | |
1740 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1840 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1741 | return; |
1841 | return; |
1742 | |
1842 | |
1743 | /* FALLTHROUGH */ |
1843 | /* FALLTHROUGH */ |
1744 | case ReparentNotify: |
1844 | case ReparentNotify: |
1745 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1845 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1746 | want_refresh = want_full_refresh = 1; |
1846 | want_refresh = want_full_refresh = 1; |
1747 | break; |
1847 | break; |
1748 | } |
1848 | } |
1749 | } |
1849 | } |
1750 | #endif |
1850 | #endif |
… | |
… | |
1753 | rxvt_term::button_press (XButtonEvent &ev) |
1853 | rxvt_term::button_press (XButtonEvent &ev) |
1754 | { |
1854 | { |
1755 | int reportmode = 0, clickintime; |
1855 | int reportmode = 0, clickintime; |
1756 | |
1856 | |
1757 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1857 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1858 | |
1758 | if (!bypass_keystate) |
1859 | if (!bypass_keystate) |
1759 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1860 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1760 | |
1861 | |
1761 | /* |
1862 | /* |
1762 | * VT window processing of button press |
1863 | * VT window processing of button press |
… | |
… | |
1782 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1883 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1783 | if (ev.button == MEvent.button && clickintime) |
1884 | if (ev.button == MEvent.button && clickintime) |
1784 | { |
1885 | { |
1785 | /* same button, within alloted time */ |
1886 | /* same button, within alloted time */ |
1786 | MEvent.clicks++; |
1887 | MEvent.clicks++; |
|
|
1888 | |
1787 | if (MEvent.clicks > 1) |
1889 | if (MEvent.clicks > 1) |
1788 | { |
1890 | { |
1789 | /* only report double clicks */ |
1891 | /* only report double clicks */ |
1790 | MEvent.clicks = 2; |
1892 | MEvent.clicks = 2; |
1791 | mouse_report (ev); |
1893 | mouse_report (ev); |
… | |
… | |
1811 | else |
1913 | else |
1812 | { |
1914 | { |
1813 | if (ev.button != MEvent.button) |
1915 | if (ev.button != MEvent.button) |
1814 | MEvent.clicks = 0; |
1916 | MEvent.clicks = 0; |
1815 | |
1917 | |
|
|
1918 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
1816 | switch (ev.button) |
1919 | switch (ev.button) |
1817 | { |
1920 | { |
1818 | case Button1: |
1921 | case Button1: |
1819 | /* allow meta + click to select rectangular areas */ |
1922 | /* allow meta + click to select rectangular areas */ |
1820 | /* should be done in screen.C */ |
1923 | /* should be done in screen.C */ |
1821 | #if ENABLE_FRILLS |
1924 | #if ENABLE_FRILLS |
1822 | selection.rect = !!(ev.state & ModMetaMask); |
1925 | selection.rect = !!(ev.state & ModMetaMask); |
1823 | #else |
1926 | #else |
1824 | selection.rect = false; |
1927 | selection.rect = false; |
1825 | #endif |
1928 | #endif |
1826 | |
1929 | |
1827 | /* allow shift+left click to extend selection */ |
1930 | /* allow shift+left click to extend selection */ |
1828 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1931 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1829 | { |
1932 | { |
1830 | if (MEvent.button == Button1 && clickintime) |
1933 | if (MEvent.button == Button1 && clickintime) |
1831 | selection_rotate (ev.x, ev.y); |
1934 | selection_rotate (ev.x, ev.y); |
1832 | else |
1935 | else |
1833 | selection_extend (ev.x, ev.y, 1); |
1936 | selection_extend (ev.x, ev.y, 1); |
1834 | } |
1937 | } |
1835 | else |
1938 | else |
1836 | { |
1939 | { |
1837 | if (MEvent.button == Button1 && clickintime) |
1940 | if (MEvent.button == Button1 && clickintime) |
1838 | MEvent.clicks++; |
1941 | MEvent.clicks++; |
1839 | else |
1942 | else |
1840 | MEvent.clicks = 1; |
1943 | MEvent.clicks = 1; |
1841 | |
1944 | |
1842 | selection_click (MEvent.clicks, ev.x, ev.y); |
1945 | selection_click (MEvent.clicks, ev.x, ev.y); |
1843 | } |
1946 | } |
1844 | |
1947 | |
1845 | MEvent.button = Button1; |
1948 | MEvent.button = Button1; |
1846 | break; |
1949 | break; |
1847 | |
1950 | |
1848 | case Button3: |
1951 | case Button3: |
1849 | if (MEvent.button == Button3 && clickintime) |
1952 | if (MEvent.button == Button3 && clickintime) |
1850 | selection_rotate (ev.x, ev.y); |
1953 | selection_rotate (ev.x, ev.y); |
1851 | else |
1954 | else |
1852 | selection_extend (ev.x, ev.y, 1); |
1955 | selection_extend (ev.x, ev.y, 1); |
1853 | |
1956 | |
1854 | MEvent.button = Button3; |
1957 | MEvent.button = Button3; |
1855 | break; |
1958 | break; |
1856 | } |
1959 | } |
1857 | } |
1960 | } |
1858 | |
1961 | |
1859 | MEvent.time = ev.time; |
1962 | MEvent.time = ev.time; |
1860 | return; |
1963 | return; |
1861 | } |
1964 | } |
1862 | |
1965 | |
… | |
… | |
1998 | } |
2101 | } |
1999 | |
2102 | |
2000 | break; |
2103 | break; |
2001 | } |
2104 | } |
2002 | } |
2105 | } |
|
|
2106 | |
2003 | return; |
2107 | return; |
2004 | } |
2108 | } |
|
|
2109 | |
2005 | #if MENUBAR |
2110 | #if MENUBAR |
2006 | /* |
2111 | /* |
2007 | * Menubar window processing of button press |
2112 | * Menubar window processing of button press |
2008 | */ |
2113 | */ |
2009 | if (isMenuBarWindow (ev.window)) |
2114 | if (isMenuBarWindow (ev.window)) |
… | |
… | |
2072 | if (priv_modes & PrivMode_mouse_report |
2177 | if (priv_modes & PrivMode_mouse_report |
2073 | && bypass_keystate |
2178 | && bypass_keystate |
2074 | && ev.button == Button1 && MEvent.clicks <= 1) |
2179 | && ev.button == Button1 && MEvent.clicks <= 1) |
2075 | selection_extend (ev.x, ev.y, 0); |
2180 | selection_extend (ev.x, ev.y, 0); |
2076 | |
2181 | |
|
|
2182 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2183 | return; |
|
|
2184 | |
2077 | switch (ev.button) |
2185 | switch (ev.button) |
2078 | { |
2186 | { |
2079 | case Button1: |
2187 | case Button1: |
2080 | case Button3: |
2188 | case Button3: |
2081 | selection_make (ev.time); |
2189 | selection_make (ev.time); |
… | |
… | |
2092 | |
2200 | |
2093 | v = ev.button == Button4 ? UP : DN; |
2201 | v = ev.button == Button4 ? UP : DN; |
2094 | |
2202 | |
2095 | if (ev.state & ShiftMask) |
2203 | if (ev.state & ShiftMask) |
2096 | i = 1; |
2204 | i = 1; |
2097 | else if (options & Opt_mouseWheelScrollPage) |
2205 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2098 | i = nrow - 1; |
2206 | i = nrow - 1; |
2099 | else |
2207 | else |
2100 | i = 5; |
2208 | i = 5; |
2101 | |
2209 | |
2102 | # ifdef MOUSE_SLIP_WHEELING |
2210 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2112 | slip_wheel_ev.start (); |
2220 | slip_wheel_ev.start (); |
2113 | } |
2221 | } |
2114 | else |
2222 | else |
2115 | { |
2223 | { |
2116 | # endif |
2224 | # endif |
2117 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2118 | scr_page (v, i); |
2225 | scr_page (v, i); |
2119 | scr_refresh (SMOOTH_REFRESH); |
|
|
2120 | scrollbar_show (1); |
2226 | scrollbar_show (1); |
2121 | # else |
|
|
2122 | while (i--) |
|
|
2123 | { |
|
|
2124 | scr_page (v, 1); |
|
|
2125 | scr_refresh (SMOOTH_REFRESH); |
|
|
2126 | scrollbar_show (1); |
|
|
2127 | } |
|
|
2128 | # endif |
|
|
2129 | # ifdef MOUSE_SLIP_WHEELING |
2227 | # ifdef MOUSE_SLIP_WHEELING |
2130 | } |
2228 | } |
2131 | #endif |
2229 | # endif |
2132 | } |
2230 | } |
2133 | break; |
2231 | break; |
2134 | #endif |
2232 | #endif |
2135 | } |
2233 | } |
2136 | } |
2234 | } |
… | |
… | |
2388 | XWindowAttributes wattr, wrootattr; |
2486 | XWindowAttributes wattr, wrootattr; |
2389 | dDisp; |
2487 | dDisp; |
2390 | |
2488 | |
2391 | pchanged = 0; |
2489 | pchanged = 0; |
2392 | |
2490 | |
2393 | if (!(options & Opt_transparent)) |
2491 | if (!OPTION (Opt_transparent)) |
2394 | return pchanged; /* Don't try any more */ |
2492 | return pchanged; /* Don't try any more */ |
2395 | |
2493 | |
2396 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2494 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2397 | rootdepth = wrootattr.depth; |
2495 | rootdepth = wrootattr.depth; |
2398 | |
2496 | |
… | |
… | |
2625 | |
2723 | |
2626 | bool |
2724 | bool |
2627 | rxvt_term::cmd_parse () |
2725 | rxvt_term::cmd_parse () |
2628 | { |
2726 | { |
2629 | bool flag = false; |
2727 | bool flag = false; |
2630 | unicode_t ch = NOCHAR; |
2728 | wchar_t ch = NOCHAR; |
2631 | unsigned char *seq_begin; // remember start of esc-sequence here |
2729 | char *seq_begin; // remember start of esc-sequence here |
2632 | |
2730 | |
2633 | for (;;) |
2731 | for (;;) |
2634 | { |
2732 | { |
2635 | if (ch == NOCHAR) |
2733 | if (ch == NOCHAR) |
2636 | { |
2734 | { |
2637 | seq_begin = cmdbuf_ptr; |
2735 | seq_begin = cmdbuf_ptr; |
2638 | ch = next_char (); |
2736 | ch = next_char (); |
2639 | } |
|
|
2640 | |
2737 | |
2641 | if (ch == NOCHAR) // TODO: improve |
2738 | if (ch == NOCHAR) |
2642 | break; |
2739 | break; |
|
|
2740 | } |
2643 | |
2741 | |
2644 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2742 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2645 | { |
2743 | { |
2646 | if (!seen_input) |
2744 | if (!seen_input) |
2647 | { |
2745 | { |
… | |
… | |
2656 | if (seen_resize && cmd_pid) |
2754 | if (seen_resize && cmd_pid) |
2657 | kill (-cmd_pid, SIGWINCH); |
2755 | kill (-cmd_pid, SIGWINCH); |
2658 | } |
2756 | } |
2659 | |
2757 | |
2660 | /* Read a text string from the input buffer */ |
2758 | /* Read a text string from the input buffer */ |
2661 | unicode_t buf[UBUFSIZ]; |
2759 | wchar_t buf[UBUFSIZ]; |
2662 | bool refreshnow = false; |
2760 | bool refreshnow = false; |
2663 | int nlines = 0; |
2761 | int nlines = 0; |
2664 | unicode_t *str = buf; |
2762 | wchar_t *str = buf; |
2665 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2763 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2666 | |
2764 | |
2667 | for (;;) |
2765 | for (;;) |
2668 | { |
2766 | { |
2669 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2767 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2670 | break; |
2768 | break; |
… | |
… | |
2676 | if (ch == C0_LF) |
2774 | if (ch == C0_LF) |
2677 | nlines++; |
2775 | nlines++; |
2678 | |
2776 | |
2679 | refresh_count++; |
2777 | refresh_count++; |
2680 | |
2778 | |
2681 | if (!(options & Opt_jumpScroll) |
2779 | if (!OPTION (Opt_jumpScroll) |
2682 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2780 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2683 | { |
2781 | { |
2684 | refreshnow = true; |
2782 | refreshnow = true; |
|
|
2783 | refresh_count = 0; |
2685 | ch = NOCHAR; |
2784 | ch = NOCHAR; |
2686 | break; |
2785 | break; |
2687 | } |
2786 | } |
2688 | |
2787 | |
2689 | // scr_add_lines only works for nlines <= nrow - 1. |
2788 | // scr_add_lines only works for nlines <= nrow - 1. |
2690 | if (nlines >= nrow - 1) |
2789 | if (nlines >= nrow - 1) |
2691 | { |
2790 | { |
|
|
2791 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2692 | scr_add_lines (buf, nlines, str - buf); |
2792 | scr_add_lines (buf, str - buf, nlines); |
|
|
2793 | |
2693 | nlines = 0; |
2794 | nlines = 0; |
2694 | str = buf; |
2795 | str = buf; |
2695 | eol = str + min (ncol, UBUFSIZ); |
2796 | eol = str + min (ncol, UBUFSIZ); |
2696 | } |
2797 | } |
2697 | |
2798 | |
… | |
… | |
2710 | |
2811 | |
2711 | seq_begin = cmdbuf_ptr; |
2812 | seq_begin = cmdbuf_ptr; |
2712 | ch = next_char (); |
2813 | ch = next_char (); |
2713 | } |
2814 | } |
2714 | |
2815 | |
|
|
2816 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2715 | scr_add_lines (buf, nlines, str - buf); |
2817 | scr_add_lines (buf, str - buf, nlines); |
2716 | |
2818 | |
2717 | /* |
2819 | /* |
2718 | * If there have been a lot of new lines, then update the screen |
2820 | * If there have been a lot of new lines, then update the screen |
2719 | * What the heck I'll cheat and only refresh less than every page-full. |
2821 | * What the heck I'll cheat and only refresh less than every page-full. |
2720 | * the number of pages between refreshes is refresh_limit, which |
2822 | * the number of pages between refreshes is refresh_limit, which |
2721 | * is incremented here because we must be doing flat-out scrolling. |
2823 | * is incremented here because we must be doing flat-out scrolling. |
2722 | */ |
2824 | */ |
2723 | if (refreshnow) |
2825 | if (refreshnow) |
2724 | { |
2826 | { |
2725 | if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2827 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2726 | refresh_limit++; |
2828 | refresh_limit++; |
2727 | else |
2829 | else |
2728 | { |
2830 | { |
2729 | flag = true; |
2831 | flag = true; |
2730 | scr_refresh (refresh_type); |
2832 | scr_refresh (refresh_type); |
|
|
2833 | want_refresh = 1; |
2731 | } |
2834 | } |
2732 | } |
2835 | } |
2733 | |
2836 | |
2734 | } |
2837 | } |
2735 | else |
2838 | else |
… | |
… | |
2750 | } |
2853 | } |
2751 | |
2854 | |
2752 | return flag; |
2855 | return flag; |
2753 | } |
2856 | } |
2754 | |
2857 | |
2755 | // read the next octet |
|
|
2756 | unicode_t |
|
|
2757 | rxvt_term::next_octet () |
|
|
2758 | { |
|
|
2759 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2760 | ? *cmdbuf_ptr++ |
|
|
2761 | : NOCHAR; |
|
|
2762 | } |
|
|
2763 | |
|
|
2764 | // read the next character |
2858 | // read the next character |
2765 | unicode_t |
2859 | wchar_t |
2766 | rxvt_term::next_char () |
2860 | rxvt_term::next_char () |
2767 | { |
2861 | { |
2768 | while (cmdbuf_ptr < cmdbuf_endp) |
2862 | while (cmdbuf_ptr < cmdbuf_endp) |
2769 | { |
2863 | { |
2770 | // assume 7-bit to be ascii ALWAYS |
2864 | // assume 7-bit to be ascii ALWAYS |
2771 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2865 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2772 | return *cmdbuf_ptr++; |
2866 | return *cmdbuf_ptr++; |
2773 | |
2867 | |
2774 | wchar_t wc; |
2868 | wchar_t wc; |
2775 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2869 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2776 | |
2870 | |
2777 | if (len == (size_t)-2) |
2871 | if (len == (size_t)-2) |
2778 | { |
2872 | { |
2779 | // the mbstate stores incomplete sequences. didn't know this :/ |
2873 | // the mbstate stores incomplete sequences. didn't know this :/ |
2780 | cmdbuf_ptr = cmdbuf_endp; |
2874 | cmdbuf_ptr = cmdbuf_endp; |
2781 | break; |
2875 | break; |
2782 | } |
2876 | } |
2783 | |
2877 | |
2784 | if (len == (size_t)-1) |
2878 | if (len == (size_t)-1) |
2785 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2879 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2786 | |
2880 | |
2787 | // assume wchar == unicode |
2881 | // assume wchar == unicode |
2788 | cmdbuf_ptr += len; |
2882 | cmdbuf_ptr += len; |
2789 | return wc & UNICODE_MASK; |
2883 | return wc & UNICODE_MASK; |
2790 | } |
2884 | } |
2791 | |
2885 | |
2792 | return NOCHAR; |
2886 | return NOCHAR; |
|
|
2887 | } |
|
|
2888 | |
|
|
2889 | // read the next octet |
|
|
2890 | uint32_t |
|
|
2891 | rxvt_term::next_octet () |
|
|
2892 | { |
|
|
2893 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2894 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2895 | : NOCHAR; |
2793 | } |
2896 | } |
2794 | |
2897 | |
2795 | /* rxvt_cmd_getc () - Return next input character */ |
2898 | /* rxvt_cmd_getc () - Return next input character */ |
2796 | /* |
2899 | /* |
2797 | * Return the next input character after first passing any keyboard input |
2900 | * Return the next input character after first passing any keyboard input |
2798 | * to the command. |
2901 | * to the command. |
2799 | */ |
2902 | */ |
2800 | unicode_t |
2903 | wchar_t |
2801 | rxvt_term::cmd_getc () |
2904 | rxvt_term::cmd_getc () |
2802 | { |
2905 | { |
2803 | unicode_t c = next_char (); |
2906 | wchar_t c = next_char (); |
2804 | |
2907 | |
2805 | if (c == NOCHAR) |
2908 | if (c == NOCHAR) |
2806 | throw out_of_input; |
2909 | throw out_of_input; |
2807 | |
2910 | |
2808 | return c; |
2911 | return c; |
2809 | } |
2912 | } |
2810 | |
2913 | |
2811 | unicode_t |
2914 | uint32_t |
2812 | rxvt_term::cmd_get8 () |
2915 | rxvt_term::cmd_get8 () |
2813 | { |
2916 | { |
2814 | unicode_t c = next_octet (); |
2917 | uint32_t c = next_octet (); |
2815 | |
2918 | |
2816 | if (c == NOCHAR) |
2919 | if (c == NOCHAR) |
2817 | throw out_of_input; |
2920 | throw out_of_input; |
2818 | |
2921 | |
2819 | return c; |
2922 | return c; |
… | |
… | |
2919 | case C0_ESC: |
3022 | case C0_ESC: |
2920 | process_escape_seq (); |
3023 | process_escape_seq (); |
2921 | break; |
3024 | break; |
2922 | case C0_ENQ: /* terminal Status */ |
3025 | case C0_ENQ: /* terminal Status */ |
2923 | if (rs[Rs_answerbackstring]) |
3026 | if (rs[Rs_answerbackstring]) |
2924 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
3027 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2925 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2926 | else |
3028 | else |
2927 | tt_write ((unsigned char *)VT100_ANS, |
3029 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2928 | (unsigned int)strlen (VT100_ANS)); |
|
|
2929 | break; |
3030 | break; |
2930 | case C0_BEL: /* bell */ |
3031 | case C0_BEL: /* bell */ |
2931 | scr_bell (); |
3032 | scr_bell (); |
2932 | break; |
3033 | break; |
2933 | case C0_BS: /* backspace */ |
3034 | case C0_BS: /* backspace */ |
… | |
… | |
3088 | break; |
3189 | break; |
3089 | |
3190 | |
3090 | /* 8.3.87: NEXT LINE */ |
3191 | /* 8.3.87: NEXT LINE */ |
3091 | case C1_NEL: /* ESC E */ |
3192 | case C1_NEL: /* ESC E */ |
3092 | { |
3193 | { |
3093 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3194 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3094 | scr_add_lines (nlcr, 1, 2); |
3195 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3095 | } |
3196 | } |
3096 | break; |
3197 | break; |
3097 | |
3198 | |
3098 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3199 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3099 | case C1_ESA: /* ESC G */ |
3200 | case C1_ESA: /* ESC G */ |
… | |
… | |
3121 | process_dcs_seq (); |
3222 | process_dcs_seq (); |
3122 | break; |
3223 | break; |
3123 | |
3224 | |
3124 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3225 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3125 | case C1_SCI: /* ESC Z */ |
3226 | case C1_SCI: /* ESC Z */ |
3126 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3227 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3127 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3128 | break; /* steal obsolete ESC [ c */ |
3228 | break; /* steal obsolete ESC [ c */ |
3129 | |
3229 | |
3130 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3230 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3131 | case C1_CSI: /* ESC [ */ |
3231 | case C1_CSI: /* ESC [ */ |
3132 | process_csi_seq (); |
3232 | process_csi_seq (); |
… | |
… | |
3376 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3476 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3377 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3477 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3378 | break; |
3478 | break; |
3379 | |
3479 | |
3380 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3480 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3381 | tt_write ((const unsigned char *)VT100_ANS, |
3481 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3382 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3383 | break; |
3482 | break; |
3384 | |
3483 | |
3385 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3484 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3386 | process_sgr_mode (nargs, arg); |
3485 | process_sgr_mode (nargs, arg); |
3387 | break; |
3486 | break; |
… | |
… | |
3394 | break; |
3493 | break; |
3395 | case 6: /* CPR requested */ |
3494 | case 6: /* CPR requested */ |
3396 | scr_report_position (); |
3495 | scr_report_position (); |
3397 | break; |
3496 | break; |
3398 | case 7: /* unofficial extension */ |
3497 | case 7: /* unofficial extension */ |
3399 | if (options & Opt_insecure) |
3498 | if (OPTION (Opt_insecure)) |
3400 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3499 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3401 | break; |
3500 | break; |
3402 | case 8: /* unofficial extension */ |
3501 | case 8: /* unofficial extension */ |
3403 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3502 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3404 | break; |
3503 | break; |
… | |
… | |
3568 | break; |
3667 | break; |
3569 | case 20: /* report icon label */ |
3668 | case 20: /* report icon label */ |
3570 | { |
3669 | { |
3571 | char *s; |
3670 | char *s; |
3572 | XGetIconName (disp, parent[0], &s); |
3671 | XGetIconName (disp, parent[0], &s); |
3573 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3672 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3574 | XFree (s); |
3673 | XFree (s); |
3575 | } |
3674 | } |
3576 | break; |
3675 | break; |
3577 | case 21: /* report window title */ |
3676 | case 21: /* report window title */ |
3578 | { |
3677 | { |
3579 | char *s; |
3678 | char *s; |
3580 | XFetchName (disp, parent[0], &s); |
3679 | XFetchName (disp, parent[0], &s); |
3581 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3680 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3582 | XFree (s); |
3681 | XFree (s); |
3583 | } |
3682 | } |
3584 | break; |
3683 | break; |
3585 | } |
3684 | } |
3586 | } |
3685 | } |
… | |
… | |
3589 | /*----------------------------------------------------------------------*/ |
3688 | /*----------------------------------------------------------------------*/ |
3590 | /* |
3689 | /* |
3591 | * get input up until STRING TERMINATOR (or BEL) |
3690 | * get input up until STRING TERMINATOR (or BEL) |
3592 | * ends_how is terminator used. returned input must be free()'d |
3691 | * ends_how is terminator used. returned input must be free()'d |
3593 | */ |
3692 | */ |
3594 | unsigned char * |
3693 | char * |
3595 | rxvt_term::get_to_st (unicode_t &ends_how) |
3694 | rxvt_term::get_to_st (unicode_t &ends_how) |
3596 | { |
3695 | { |
3597 | unicode_t ch; |
3696 | unicode_t ch; |
3598 | bool seen_esc = false; |
3697 | bool seen_esc = false; |
3599 | unsigned int n = 0; |
3698 | unsigned int n = 0; |
… | |
… | |
3632 | |
3731 | |
3633 | string[n++] = '\0'; |
3732 | string[n++] = '\0'; |
3634 | |
3733 | |
3635 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3734 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3636 | |
3735 | |
3637 | return (unsigned char *)rxvt_wcstombs (string); |
3736 | return rxvt_wcstombs (string); |
3638 | } |
3737 | } |
3639 | |
3738 | |
3640 | /*----------------------------------------------------------------------*/ |
3739 | /*----------------------------------------------------------------------*/ |
3641 | /* |
3740 | /* |
3642 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3741 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3643 | */ |
3742 | */ |
3644 | void |
3743 | void |
3645 | rxvt_term::process_dcs_seq () |
3744 | rxvt_term::process_dcs_seq () |
3646 | { |
3745 | { |
3647 | unsigned char *s; |
3746 | char *s; |
3648 | unicode_t eh; |
3747 | unicode_t eh; |
3649 | |
3748 | |
3650 | /* |
3749 | /* |
3651 | * Not handled yet |
3750 | * Not handled yet |
3652 | */ |
3751 | */ |
… | |
… | |
3671 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3770 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3672 | arg = arg * 10 + (ch - '0'); |
3771 | arg = arg * 10 + (ch - '0'); |
3673 | |
3772 | |
3674 | if (ch == ';') |
3773 | if (ch == ';') |
3675 | { |
3774 | { |
3676 | unsigned char *s = get_to_st (eh); |
3775 | char *s = get_to_st (eh); |
3677 | |
3776 | |
3678 | if (s) |
3777 | if (s) |
3679 | { |
3778 | { |
3680 | process_xterm_seq (arg, (char *)s, eh); |
3779 | process_xterm_seq (arg, s, eh); |
3681 | free (s); |
3780 | free (s); |
3682 | } |
3781 | } |
3683 | } |
3782 | } |
3684 | } |
3783 | } |
3685 | |
3784 | |
3686 | void |
3785 | void |
3687 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3786 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3688 | { |
3787 | { |
3689 | if (str[0] == '?' && !str[1]) |
3788 | if (str[0] == '?' && !str[1]) |
3690 | { |
3789 | { |
3691 | unsigned short r, g, b; |
3790 | unsigned short r, g, b; |
3692 | pix_colors_focused[color].get (display, r, g, b); |
3791 | pix_colors_focused[color].get (display, r, g, b); |
… | |
… | |
3698 | |
3797 | |
3699 | /* |
3798 | /* |
3700 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3799 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3701 | */ |
3800 | */ |
3702 | void |
3801 | void |
3703 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3802 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3704 | { |
3803 | { |
3705 | int changed = 0; |
3804 | int changed = 0; |
3706 | int color; |
3805 | int color; |
3707 | char *buf, *name; |
3806 | char *buf, *name; |
3708 | bool query = str[0] == '?' && !str[1]; |
3807 | bool query = str[0] == '?' && !str[1]; |
… | |
… | |
3765 | { |
3864 | { |
3766 | if ((name = strchr (buf, ';')) == NULL) |
3865 | if ((name = strchr (buf, ';')) == NULL) |
3767 | break; |
3866 | break; |
3768 | |
3867 | |
3769 | *name++ = '\0'; |
3868 | *name++ = '\0'; |
3770 | color = atoi (buf); |
3869 | color = atoi (buf) + minCOLOR; |
3771 | |
3870 | |
3772 | if (color < 0 || color >= TOTAL_COLORS) |
3871 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3773 | break; |
3872 | break; |
3774 | |
3873 | |
3775 | if ((buf = strchr (name, ';')) != NULL) |
3874 | if ((buf = strchr (name, ';')) != NULL) |
3776 | *buf++ = '\0'; |
3875 | *buf++ = '\0'; |
3777 | |
3876 | |
3778 | if (name[0] == '?' && !name[1]) |
3877 | if (name[0] == '?' && !name[1]) |
3779 | { |
3878 | { |
3780 | unsigned short r, g, b; |
3879 | unsigned short r, g, b; |
3781 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3880 | pix_colors_focused[color].get (display, r, g, b); |
3782 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3881 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3783 | } |
3882 | } |
3784 | else |
3883 | else |
3785 | set_window_color (color + minCOLOR, name); |
3884 | set_window_color (color, name); |
3786 | } |
3885 | } |
3787 | break; |
3886 | break; |
3788 | case XTerm_Color00: |
3887 | case XTerm_Color00: |
3789 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3888 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3790 | break; |
3889 | break; |
3791 | case XTerm_Color01: |
3890 | case XTerm_Color01: |
3792 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3891 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3793 | break; |
3892 | break; |
3794 | #ifndef NO_CURSORCOLOR |
3893 | #ifndef NO_CURSORCOLOR |
3795 | case XTerm_Color_cursor: |
3894 | case XTerm_Color_cursor: |
3796 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3895 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3797 | break; |
3896 | break; |
… | |
… | |
3801 | break; |
3900 | break; |
3802 | case XTerm_Color_pointer_bg: |
3901 | case XTerm_Color_pointer_bg: |
3803 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3902 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3804 | break; |
3903 | break; |
3805 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3904 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3806 | case XTerm_Color_BD: |
|
|
3807 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3808 | break; |
|
|
3809 | case XTerm_Color_UL: |
|
|
3810 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3811 | break; |
|
|
3812 | case XTerm_Color_RV: |
3905 | case XTerm_Color_RV: |
3813 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3906 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3907 | break; |
|
|
3908 | case Rxvt_Color_BD: |
|
|
3909 | case URxvt_Color_BD: |
|
|
3910 | process_color_seq (op, Color_BD, str, resp); |
|
|
3911 | break; |
|
|
3912 | case Rxvt_Color_UL: |
|
|
3913 | case URxvt_Color_UL: |
|
|
3914 | process_color_seq (op, Color_UL, str, resp); |
3814 | break; |
3915 | break; |
3815 | case URxvt_Color_IT: |
3916 | case URxvt_Color_IT: |
3816 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3917 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3817 | break; |
3918 | break; |
3818 | #endif |
3919 | #endif |
… | |
… | |
3823 | if (am_transparent) |
3924 | if (am_transparent) |
3824 | want_full_refresh = want_refresh = 1; |
3925 | want_full_refresh = want_refresh = 1; |
3825 | break; |
3926 | break; |
3826 | #endif |
3927 | #endif |
3827 | |
3928 | |
3828 | case XTerm_Pixmap: |
3929 | case Rxvt_Pixmap: |
3829 | if (*str != ';') |
3930 | if (*str != ';') |
3830 | { |
3931 | { |
3831 | #if XPM_BACKGROUND |
3932 | #if XPM_BACKGROUND |
3832 | scale_pixmap (""); /* reset to default scaling */ |
3933 | scale_pixmap (""); /* reset to default scaling */ |
3833 | set_bgPixmap (str); /* change pixmap */ |
3934 | set_bgPixmap (str); /* change pixmap */ |
3834 | #endif |
|
|
3835 | scr_touch (true); |
3935 | scr_touch (true); |
|
|
3936 | #endif |
3836 | } |
3937 | } |
|
|
3938 | |
3837 | while ((str = strchr (str, ';')) != NULL) |
3939 | while ((str = strchr (str, ';')) != NULL) |
3838 | { |
3940 | { |
3839 | str++; |
3941 | str++; |
3840 | #if XPM_BACKGROUND |
3942 | #if XPM_BACKGROUND |
3841 | changed += scale_pixmap (str); |
3943 | changed += scale_pixmap (str); |
… | |
… | |
3844 | |
3946 | |
3845 | if (changed) |
3947 | if (changed) |
3846 | { |
3948 | { |
3847 | #ifdef XPM_BACKGROUND |
3949 | #ifdef XPM_BACKGROUND |
3848 | resize_pixmap (); |
3950 | resize_pixmap (); |
3849 | #endif |
|
|
3850 | scr_touch (true); |
3951 | scr_touch (true); |
|
|
3952 | #endif |
3851 | } |
3953 | } |
3852 | break; |
3954 | break; |
3853 | |
3955 | |
3854 | case XTerm_restoreFG: |
3956 | case Rxvt_restoreFG: |
3855 | set_window_color (Color_fg, str); |
3957 | set_window_color (Color_fg, str); |
3856 | break; |
3958 | break; |
3857 | case XTerm_restoreBG: |
3959 | case Rxvt_restoreBG: |
3858 | set_window_color (Color_bg, str); |
3960 | set_window_color (Color_bg, str); |
3859 | break; |
3961 | break; |
3860 | |
3962 | |
3861 | case XTerm_logfile: |
3963 | case XTerm_logfile: |
3862 | // TODO, when secure mode? |
3964 | // TODO, when secure mode? |
3863 | break; |
3965 | break; |
3864 | |
3966 | |
3865 | #ifdef MENUBAR |
3967 | #ifdef MENUBAR |
3866 | case URxvt_Menu: |
3968 | case URxvt_Menu: |
3867 | if (options & Opt_insecure) |
3969 | if (OPTION (Opt_insecure)) |
3868 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3970 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3869 | break; |
3971 | break; |
3870 | #endif |
3972 | #endif |
3871 | #if 0 |
3973 | #if 0 |
3872 | case XTerm_dumpscreen: /* no error notices */ |
3974 | case Rxvt_dumpscreen: /* no error notices */ |
3873 | { |
3975 | { |
3874 | int fd; |
3976 | int fd; |
3875 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3977 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3876 | { |
3978 | { |
3877 | scr_dump (fd); |
3979 | scr_dump (fd); |
… | |
… | |
3888 | case URxvt_italicFont: |
3990 | case URxvt_italicFont: |
3889 | case URxvt_boldItalicFont: |
3991 | case URxvt_boldItalicFont: |
3890 | #endif |
3992 | #endif |
3891 | if (query) |
3993 | if (query) |
3892 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3994 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3893 | (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3995 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3894 | ? fontset[op - URxvt_font]->fontdesc : "", |
3996 | ? fontset[op - URxvt_font]->fontdesc : "", |
3895 | resp); |
3997 | resp); |
3896 | else |
3998 | else |
3897 | { |
3999 | { |
3898 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
4000 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3904 | break; |
4006 | break; |
3905 | |
4007 | |
3906 | #if ENABLE_FRILLS |
4008 | #if ENABLE_FRILLS |
3907 | case URxvt_locale: |
4009 | case URxvt_locale: |
3908 | if (query) |
4010 | if (query) |
3909 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
4011 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3910 | else |
4012 | else |
3911 | { |
4013 | { |
3912 | set_locale (str); |
4014 | set_locale (str); |
3913 | pty.set_utf8_mode (enc_utf8); |
4015 | pty.set_utf8_mode (enc_utf8); |
3914 | init_xlocale (); |
4016 | init_xlocale (); |
3915 | } |
4017 | } |
3916 | break; |
4018 | break; |
3917 | |
4019 | |
3918 | case URxvt_view_up: |
4020 | case URxvt_view_up: |
3919 | case URxvt_view_down: |
4021 | case URxvt_view_down: |
|
|
4022 | { |
3920 | int lines = atoi (str); |
4023 | int lines = atoi (str); |
3921 | |
4024 | |
3922 | if (lines) |
4025 | if (lines) |
3923 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
4026 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3924 | else |
4027 | else |
3925 | { |
|
|
3926 | scr_erase_savelines (); |
4028 | scr_erase_savelines (); |
3927 | } |
4029 | } |
3928 | |
4030 | |
|
|
4031 | break; |
|
|
4032 | #endif |
|
|
4033 | |
|
|
4034 | #if ENABLE_PERL |
|
|
4035 | case URxvt_perl: |
|
|
4036 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
|
|
4037 | ; // no responses yet |
3929 | break; |
4038 | break; |
3930 | #endif |
4039 | #endif |
3931 | } |
4040 | } |
3932 | } |
4041 | } |
3933 | /*----------------------------------------------------------------------*/ |
4042 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4042 | } |
4151 | } |
4043 | |
4152 | |
4044 | /* extra handling for values with state unkept */ |
4153 | /* extra handling for values with state unkept */ |
4045 | switch (arg[i]) |
4154 | switch (arg[i]) |
4046 | { |
4155 | { |
|
|
4156 | #if ENABLE_STYLES |
|
|
4157 | case 1021: |
|
|
4158 | set_option (Opt_intensityStyles, mode); |
|
|
4159 | |
|
|
4160 | scr_touch (true); |
|
|
4161 | break; |
|
|
4162 | #endif |
4047 | case 1048: /* alternative cursor save */ |
4163 | case 1048: /* alternative cursor save */ |
4048 | case 1049: |
4164 | case 1049: |
4049 | if (options & Opt_secondaryScreen) |
4165 | if (OPTION (Opt_secondaryScreen)) |
4050 | if (mode == 0) |
4166 | if (mode == 0) |
4051 | scr_cursor (RESTORE); |
4167 | scr_cursor (RESTORE); |
4052 | else if (mode == 1) |
4168 | else if (mode == 1) |
4053 | scr_cursor (SAVE); |
4169 | scr_cursor (SAVE); |
4054 | break; |
4170 | break; |
… | |
… | |
4069 | case 3: /* 80/132 */ |
4185 | case 3: /* 80/132 */ |
4070 | if (priv_modes & PrivMode_132OK) |
4186 | if (priv_modes & PrivMode_132OK) |
4071 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4187 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4072 | break; |
4188 | break; |
4073 | case 4: /* smooth scrolling */ |
4189 | case 4: /* smooth scrolling */ |
4074 | if (state) |
|
|
4075 | options &= ~Opt_jumpScroll; |
|
|
4076 | else |
|
|
4077 | options |= Opt_jumpScroll; |
4190 | set_option (Opt_jumpScroll, !state); |
4078 | break; |
4191 | break; |
4079 | case 5: /* reverse video */ |
4192 | case 5: /* reverse video */ |
4080 | scr_rvideo_mode (state); |
4193 | scr_rvideo_mode (state); |
4081 | break; |
4194 | break; |
4082 | case 6: /* relative/absolute origins */ |
4195 | case 6: /* relative/absolute origins */ |
… | |
… | |
4123 | #if 0 |
4236 | #if 0 |
4124 | case 1001: |
4237 | case 1001: |
4125 | break; /* X11 mouse highlighting */ |
4238 | break; /* X11 mouse highlighting */ |
4126 | #endif |
4239 | #endif |
4127 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4240 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4128 | if (state) |
|
|
4129 | options &= ~Opt_scrollTtyOutput; |
|
|
4130 | else |
|
|
4131 | options |= Opt_scrollTtyOutput; |
4241 | set_option (Opt_scrollTtyOutput, !state); |
4132 | break; |
4242 | break; |
4133 | case 1011: /* scroll to bottom on key press */ |
4243 | case 1011: /* scroll to bottom on key press */ |
4134 | if (state) |
|
|
4135 | options |= Opt_scrollTtyKeypress; |
4244 | set_option (Opt_scrollTtyKeypress, state); |
4136 | else |
|
|
4137 | options &= ~Opt_scrollTtyKeypress; |
|
|
4138 | break; |
4245 | break; |
4139 | case 1047: /* secondary screen w/ clearing last */ |
4246 | case 1047: /* secondary screen w/ clearing last */ |
4140 | if (options & Opt_secondaryScreen) |
4247 | if (OPTION (Opt_secondaryScreen)) |
4141 | if (current_screen != PRIMARY) |
4248 | if (current_screen != PRIMARY) |
4142 | scr_erase_screen (2); |
4249 | scr_erase_screen (2); |
4143 | scr_change_screen (state); |
4250 | scr_change_screen (state); |
4144 | break; |
4251 | break; |
4145 | case 1049: /* secondary screen w/ clearing first */ |
4252 | case 1049: /* secondary screen w/ clearing first */ |
4146 | scr_change_screen (state); |
4253 | scr_change_screen (state); |
4147 | if (options & Opt_secondaryScreen) |
4254 | if (OPTION (Opt_secondaryScreen)) |
4148 | if (current_screen != PRIMARY) |
4255 | if (current_screen != PRIMARY) |
4149 | scr_erase_screen (2); |
4256 | scr_erase_screen (2); |
4150 | break; |
4257 | break; |
4151 | default: |
4258 | default: |
4152 | break; |
4259 | break; |
… | |
… | |
4280 | scr_color (Color_bg, Color_bg); |
4387 | scr_color (Color_bg, Color_bg); |
4281 | break; |
4388 | break; |
4282 | |
4389 | |
4283 | //case 50: // not variable spacing |
4390 | //case 50: // not variable spacing |
4284 | |
4391 | |
4285 | #ifndef NO_BRIGHTCOLOR |
4392 | #if ENABLE_FRILLS |
4286 | case 90: |
4393 | case 90: |
4287 | case 91: /* set bright fg color */ |
4394 | case 91: /* set bright fg color */ |
4288 | case 92: |
4395 | case 92: |
4289 | case 93: |
4396 | case 93: |
4290 | case 94: |
4397 | case 94: |
… | |
… | |
4302 | case 106: |
4409 | case 106: |
4303 | case 107: |
4410 | case 107: |
4304 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4411 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4305 | break; |
4412 | break; |
4306 | #endif |
4413 | #endif |
4307 | |
|
|
4308 | } |
4414 | } |
4309 | } |
4415 | } |
4310 | } |
4416 | } |
4311 | /*}}} */ |
4417 | /*}}} */ |
4312 | |
4418 | |
… | |
… | |
4336 | */ |
4442 | */ |
4337 | void |
4443 | void |
4338 | rxvt_term::tt_printf (const char *fmt,...) |
4444 | rxvt_term::tt_printf (const char *fmt,...) |
4339 | { |
4445 | { |
4340 | va_list arg_ptr; |
4446 | va_list arg_ptr; |
4341 | unsigned char buf[256]; |
4447 | char buf[256]; |
4342 | |
4448 | |
4343 | va_start (arg_ptr, fmt); |
4449 | va_start (arg_ptr, fmt); |
4344 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4450 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4345 | va_end (arg_ptr); |
4451 | va_end (arg_ptr); |
4346 | tt_write (buf, strlen (buf)); |
4452 | tt_write (buf, strlen (buf)); |
… | |
… | |
4351 | * or generated by us in response to a query ESC sequence. |
4457 | * or generated by us in response to a query ESC sequence. |
4352 | */ |
4458 | */ |
4353 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4459 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4354 | |
4460 | |
4355 | void |
4461 | void |
4356 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4462 | rxvt_term::tt_write (const char *data, unsigned int len) |
4357 | { |
4463 | { |
|
|
4464 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4465 | return; |
|
|
4466 | |
|
|
4467 | if (pty.pty < 0) |
|
|
4468 | return; |
|
|
4469 | |
4358 | if (v_buflen == 0) |
4470 | if (v_buflen == 0) |
4359 | { |
4471 | { |
4360 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4472 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4361 | |
4473 | |
4362 | if ((unsigned int)written == len) |
4474 | if ((unsigned int)written == len) |
… | |
… | |
4364 | |
4476 | |
4365 | data += written; |
4477 | data += written; |
4366 | len -= written; |
4478 | len -= written; |
4367 | } |
4479 | } |
4368 | |
4480 | |
4369 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4481 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4370 | |
4482 | |
4371 | memcpy (v_buffer + v_buflen, data, len); |
4483 | memcpy (v_buffer + v_buflen, data, len); |
4372 | v_buflen += len; |
4484 | v_buflen += len; |
4373 | |
4485 | |
4374 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4486 | pty_ev.set (EVENT_READ | EVENT_WRITE); |