1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.C |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
43 | * along with this program; if not, write to the Free Software |
43 | * along with this program; if not, write to the Free Software |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
45 | *----------------------------------------------------------------------*/ |
45 | *----------------------------------------------------------------------*/ |
46 | |
46 | |
47 | /*{{{ includes: */ |
47 | /*{{{ includes: */ |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" |
|
|
50 | #include "rxvtperl.h" |
50 | #include "version.h" |
51 | #include "version.h" |
51 | #include "command.h" |
52 | #include "command.h" |
52 | |
53 | |
53 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
55 | # include "keyboard.h" |
55 | #endif |
56 | #endif |
56 | |
57 | |
57 | #include <csignal> |
58 | #include <csignal> |
58 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
59 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
60 | |
65 | |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | |
|
|
63 | // exception thrown when the command parser runs out of input data |
|
|
64 | class out_of_input { } out_of_input; |
|
|
65 | |
67 | |
66 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
67 | |
69 | |
68 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
69 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
141 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | return; |
144 | return; |
143 | |
145 | |
144 | for (;;) |
146 | for (;;) |
145 | { |
147 | { |
146 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
147 | |
149 | |
148 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
149 | |
151 | |
150 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
151 | { |
153 | { |
152 | iso14755_51 (l.t[x], l.r[x]); |
154 | iso14755_51 (l.t[x], l.r[x], x, y); |
153 | iso14755buf = ISO_14755_54; |
155 | iso14755buf = ISO_14755_54; |
154 | break; |
156 | break; |
155 | } |
157 | } |
156 | |
158 | |
157 | x--; |
159 | x--; |
158 | } |
160 | } |
159 | } |
161 | } |
160 | #endif |
|
|
161 | |
162 | |
162 | #if ENABLE_OVERLAY |
|
|
163 | void |
163 | void |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
165 | { |
165 | { |
166 | rxvt_fontset *fs = FONTSET (r); |
166 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
169 | int len; |
169 | int len; |
170 | |
170 | |
171 | fname = rxvt_utf8towcs (f->name); |
171 | fname = rxvt_utf8towcs (f->name); |
172 | |
172 | |
173 | #if ENABLE_COMBINING |
173 | # if ENABLE_COMBINING |
174 | if (IS_COMPOSE (ch)) |
174 | if (IS_COMPOSE (ch)) |
175 | { |
175 | { |
176 | len = rxvt_composite.expand (ch, 0); |
176 | len = rxvt_composite.expand (ch, 0); |
177 | alloc = chr = new wchar_t[len]; |
177 | alloc = chr = new wchar_t[len]; |
178 | rxvt_composite.expand (ch, chr); |
178 | rxvt_composite.expand (ch, chr); |
179 | } |
179 | } |
180 | else |
180 | else |
181 | #endif |
181 | # endif |
182 | { |
182 | { |
183 | ch2 = ch; |
183 | ch2 = ch; |
184 | |
184 | |
185 | alloc = 0; |
185 | alloc = 0; |
186 | chr = &ch2; |
186 | chr = &ch2; |
… | |
… | |
189 | |
189 | |
190 | char attr[80]; // plenty |
190 | char attr[80]; // plenty |
191 | |
191 | |
192 | sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s", |
192 | sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s", |
193 | (int)r, |
193 | (int)r, |
194 | GET_FGCOLOR (r), GET_BGCOLOR (r), |
194 | fgcolor_of (r), bgcolor_of (r), |
195 | r & RS_Bold ? " bold" : "", |
195 | r & RS_Bold ? " bold" : "", |
196 | r & RS_Italic ? " italic" : "", |
196 | r & RS_Italic ? " italic" : "", |
197 | r & RS_Blink ? " blink" : "", |
197 | r & RS_Blink ? " blink" : "", |
198 | r & RS_RVid ? " rvid" : "", |
198 | r & RS_RVid ? " rvid" : "", |
199 | r & RS_Uline ? " uline" : "", |
199 | r & RS_Uline ? " uline" : "", |
… | |
… | |
202 | int width = wcswidth (fname, wcslen (fname)); |
202 | int width = wcswidth (fname, wcslen (fname)); |
203 | |
203 | |
204 | max_it (width, 8+5); // for char + hey |
204 | max_it (width, 8+5); // for char + hey |
205 | max_it (width, strlen (attr)); |
205 | max_it (width, strlen (attr)); |
206 | |
206 | |
|
|
207 | if (y >= 0) |
|
|
208 | { |
|
|
209 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
|
|
210 | x = 0; |
|
|
211 | } |
|
|
212 | |
207 | scr_overlay_new (0, -1, width, len + 2); |
213 | scr_overlay_new (x, y, width, len + 2); |
208 | |
214 | |
209 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
215 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
210 | |
216 | |
211 | for (int y = 0; y < len; y++) |
217 | for (int y = 0; y < len; y++) |
212 | { |
218 | { |
… | |
… | |
215 | ch = *chr++; |
221 | ch = *chr++; |
216 | |
222 | |
217 | sprintf (buf, "%8x", ch); |
223 | sprintf (buf, "%8x", ch); |
218 | scr_overlay_set (0, y, buf); |
224 | scr_overlay_set (0, y, buf); |
219 | scr_overlay_set (9, y, '='); |
225 | scr_overlay_set (9, y, '='); |
220 | #if !UNICODE3 |
226 | # if !UNICODE3 |
221 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
222 | ch = 0xfffd; |
228 | ch = 0xfffd; |
223 | #endif |
229 | # endif |
224 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
225 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
226 | } |
234 | } |
227 | |
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 | // } |
228 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
229 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
230 | |
243 | |
231 | free (fname); |
244 | free (fname); |
232 | |
245 | |
233 | #if ENABLE_COMBINING |
246 | # if ENABLE_COMBINING |
234 | if (alloc) |
247 | if (alloc) |
235 | delete [] alloc; |
248 | delete [] alloc; |
236 | #endif |
249 | # endif |
237 | } |
250 | } |
238 | #endif |
251 | #endif |
239 | |
252 | |
240 | void |
253 | void |
241 | rxvt_term::commit_iso14755 () |
254 | rxvt_term::commit_iso14755 () |
… | |
… | |
258 | mb[0] = ch[0]; |
271 | mb[0] = ch[0]; |
259 | len = 1; |
272 | len = 1; |
260 | } |
273 | } |
261 | |
274 | |
262 | if (len > 0) |
275 | if (len > 0) |
263 | tt_write ((unsigned char *)mb, len); |
276 | tt_write (mb, len); |
264 | else |
277 | else |
265 | scr_bell (); |
278 | scr_bell (); |
266 | } |
279 | } |
267 | |
280 | |
268 | iso14755buf = 0; |
281 | iso14755buf = 0; |
… | |
… | |
285 | |
298 | |
286 | return -1; |
299 | return -1; |
287 | } |
300 | } |
288 | #endif |
301 | #endif |
289 | |
302 | |
290 | /*{{{ Convert the keypress event into a string */ |
|
|
291 | void |
303 | void |
292 | rxvt_term::lookup_key (XKeyEvent &ev) |
304 | rxvt_term::key_press (XKeyEvent &ev) |
293 | { |
305 | { |
294 | int ctrl, meta, shft, len; |
306 | int ctrl, meta, shft, len; |
295 | unsigned int newlen; |
307 | unsigned int newlen; |
296 | KeySym keysym; |
308 | KeySym keysym; |
297 | #ifdef DEBUG_CMD |
|
|
298 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
299 | #endif |
|
|
300 | int valid_keysym; |
309 | int valid_keysym; |
301 | unsigned char kbuf[KBUFSZ]; |
310 | char kbuf[KBUFSZ]; |
|
|
311 | |
|
|
312 | #if ISO_14755 |
|
|
313 | if (iso14755buf & ISO_14755_52) |
|
|
314 | return; |
|
|
315 | #endif |
302 | |
316 | |
303 | /* |
317 | /* |
304 | * 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 |
305 | * escape sequence to toggle the Keypad. |
319 | * escape sequence to toggle the Keypad. |
306 | * |
320 | * |
… | |
… | |
324 | Status status_return; |
338 | Status status_return; |
325 | |
339 | |
326 | #if 0 |
340 | #if 0 |
327 | #ifdef X_HAVE_UTF8_STRING |
341 | #ifdef X_HAVE_UTF8_STRING |
328 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
342 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
329 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
343 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
330 | KBUFSZ, &keysym, &status_return); |
344 | KBUFSZ, &keysym, &status_return); |
331 | else |
345 | else |
332 | #endif |
346 | #endif |
333 | #endif |
347 | #endif |
334 | { |
348 | { |
… | |
… | |
371 | || status_return == XLookupBoth; |
385 | || status_return == XLookupBoth; |
372 | } |
386 | } |
373 | else |
387 | else |
374 | #endif |
388 | #endif |
375 | { |
389 | { |
376 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
390 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
377 | valid_keysym = keysym != NoSymbol; |
391 | valid_keysym = keysym != NoSymbol; |
378 | } |
392 | } |
379 | |
393 | |
380 | if (valid_keysym) |
394 | if (valid_keysym) |
381 | { |
395 | { |
… | |
… | |
433 | scr_move_to (0, 1); |
447 | scr_move_to (0, 1); |
434 | return; |
448 | return; |
435 | } |
449 | } |
436 | else if (keysym == XK_End) |
450 | else if (keysym == XK_End) |
437 | { |
451 | { |
438 | scr_move_to (1, 0); |
452 | scr_move_to (1, 1); |
439 | return; |
453 | return; |
440 | } |
454 | } |
441 | } |
455 | } |
442 | #endif |
456 | #endif |
443 | } |
457 | } |
… | |
… | |
454 | { |
468 | { |
455 | switch (keysym) |
469 | switch (keysym) |
456 | { |
470 | { |
457 | /* normal XTerm key bindings */ |
471 | /* normal XTerm key bindings */ |
458 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
472 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
459 | selection_request (ev.time, 0, 0); |
473 | selection_request (ev.time); |
460 | return; |
474 | return; |
461 | #if TODO |
475 | #if TODO |
462 | /* rxvt extras */ |
476 | /* rxvt extras */ |
463 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
477 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
464 | change_font (FONT_UP); |
478 | change_font (FONT_UP); |
… | |
… | |
483 | { |
497 | { |
484 | commit_iso14755 (); |
498 | commit_iso14755 (); |
485 | iso14755buf = ISO_14755_51; |
499 | iso14755buf = ISO_14755_51; |
486 | # if ISO_14755 |
500 | # if ISO_14755 |
487 | 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); |
488 | # endif |
510 | # endif |
489 | return; |
511 | return; |
490 | } |
512 | } |
491 | else if ((hv = hex_keyval (ev)) >= 0) |
513 | else if ((hv = hex_keyval (ev)) >= 0) |
492 | { |
514 | { |
… | |
… | |
845 | { |
867 | { |
846 | #ifdef META8_OPTION |
868 | #ifdef META8_OPTION |
847 | /* set 8-bit on */ |
869 | /* set 8-bit on */ |
848 | if (meta && (meta_char == 0x80)) |
870 | if (meta && (meta_char == 0x80)) |
849 | { |
871 | { |
850 | unsigned char *ch; |
872 | char *ch; |
851 | |
873 | |
852 | for (ch = kbuf; ch < kbuf + len; ch++) |
874 | for (ch = kbuf; ch < kbuf + len; ch++) |
853 | *ch |= 0x80; |
875 | *ch |= 0x80; |
854 | |
876 | |
855 | meta = 0; |
877 | meta = 0; |
… | |
… | |
857 | #endif |
879 | #endif |
858 | /* nil */ ; |
880 | /* nil */ ; |
859 | } |
881 | } |
860 | } |
882 | } |
861 | |
883 | |
|
|
884 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
885 | return; |
|
|
886 | |
862 | if (len <= 0) |
887 | if (len <= 0) |
863 | return; /* not mapped */ |
888 | return; /* not mapped */ |
864 | |
889 | |
865 | if (options & Opt_scrollTtyKeypress) |
890 | if (option (Opt_scrollTtyKeypress)) |
866 | if (view_start) |
891 | if (view_start) |
867 | { |
892 | { |
868 | view_start = 0; |
893 | view_start = 0; |
869 | want_refresh = 1; |
894 | want_refresh = 1; |
870 | } |
895 | } |
… | |
… | |
888 | #ifdef META8_OPTION |
913 | #ifdef META8_OPTION |
889 | && meta_char == C0_ESC |
914 | && meta_char == C0_ESC |
890 | #endif |
915 | #endif |
891 | ) |
916 | ) |
892 | { |
917 | { |
893 | const unsigned char ch = C0_ESC; |
918 | const char ch = C0_ESC; |
894 | tt_write (&ch, 1); |
919 | tt_write (&ch, 1); |
895 | } |
920 | } |
896 | |
921 | |
897 | #if defined(DEBUG_CMD) |
|
|
898 | /* Display keyboard buffer contents */ |
|
|
899 | unsigned char *p; |
|
|
900 | int i; |
|
|
901 | |
|
|
902 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
903 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
904 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
905 | fprintf (stderr, "'\n"); |
|
|
906 | #endif /* DEBUG_CMD */ |
|
|
907 | tt_write (kbuf, (unsigned int)len); |
922 | tt_write (kbuf, (unsigned int)len); |
908 | } |
923 | } |
909 | /*}}} */ |
|
|
910 | |
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 (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 | |
911 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
1002 | #if defined (KEYSYM_RESOURCE) |
912 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
913 | /* attempt to `write' count to the input buffer */ |
|
|
914 | unsigned int |
1003 | unsigned int |
915 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
1004 | rxvt_term::cmd_write (const char *str, unsigned int count) |
916 | { |
1005 | { |
917 | unsigned int n, s; |
1006 | unsigned int n, s; |
918 | |
1007 | |
919 | n = cmdbuf_ptr - cmdbuf_base; |
1008 | n = cmdbuf_ptr - cmdbuf_base; |
920 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
1009 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
957 | } |
1046 | } |
958 | #endif |
1047 | #endif |
959 | |
1048 | |
960 | if (want_refresh) |
1049 | if (want_refresh) |
961 | { |
1050 | { |
|
|
1051 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
1052 | { |
|
|
1053 | int row = view_start; |
|
|
1054 | int end_row = row + nrow; |
|
|
1055 | |
|
|
1056 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
1057 | --row; |
|
|
1058 | |
|
|
1059 | do |
|
|
1060 | { |
|
|
1061 | int start_row = row; |
|
|
1062 | line_t *l; |
|
|
1063 | |
|
|
1064 | do |
|
|
1065 | { |
|
|
1066 | l = &ROW (row++); |
|
|
1067 | |
|
|
1068 | if (!(l->f & LINE_FILTERED)) |
|
|
1069 | { |
|
|
1070 | // line not filtered, mark it as filtered |
|
|
1071 | l->f |= LINE_FILTERED; |
|
|
1072 | while (l->is_longer ()) |
|
|
1073 | { |
|
|
1074 | l = &ROW (row++); |
|
|
1075 | l->f |= LINE_FILTERED; |
|
|
1076 | } |
|
|
1077 | |
|
|
1078 | // and filter it |
|
|
1079 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1080 | |
|
|
1081 | break; |
|
|
1082 | } |
|
|
1083 | } |
|
|
1084 | while (l->is_longer () && row < end_row); |
|
|
1085 | } |
|
|
1086 | while (row < end_row); |
|
|
1087 | } |
|
|
1088 | |
962 | scr_refresh (refresh_type); |
1089 | scr_refresh (); |
963 | scrollbar_show (1); |
1090 | scrollbar_show (1); |
964 | #ifdef USE_XIM |
1091 | #ifdef USE_XIM |
965 | IMSendSpot (); |
1092 | IMSendSpot (); |
966 | #endif |
1093 | #endif |
967 | } |
1094 | } |
… | |
… | |
970 | } |
1097 | } |
971 | |
1098 | |
972 | void |
1099 | void |
973 | rxvt_term::check_cb (check_watcher &w) |
1100 | rxvt_term::check_cb (check_watcher &w) |
974 | { |
1101 | { |
975 | SET_R (this); |
1102 | make_current (); |
976 | SET_LOCALE (locale); |
|
|
977 | |
1103 | |
978 | display->flush (); |
1104 | display->flush (); |
979 | |
1105 | |
980 | if (want_refresh && !flush_ev.active) |
1106 | if (want_refresh && !flush_ev.active) |
981 | flush_ev.start (NOW + 0.01); |
1107 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
982 | } |
1108 | } |
983 | |
1109 | |
984 | void |
1110 | void |
985 | rxvt_term::flush_cb (time_watcher &w) |
1111 | rxvt_term::flush_cb (time_watcher &w) |
986 | { |
1112 | { |
987 | SET_R (this); |
1113 | make_current (); |
988 | SET_LOCALE (locale); |
|
|
989 | |
1114 | |
990 | refresh_limit = 1; |
1115 | refresh_limit = 1; |
991 | refresh_count = 0; |
1116 | refresh_count = 0; |
992 | flush (); |
1117 | flush (); |
993 | } |
1118 | } |
… | |
… | |
997 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1122 | rxvt_term::cursor_blink_cb (time_watcher &w) |
998 | { |
1123 | { |
999 | hidden_cursor = !hidden_cursor; |
1124 | hidden_cursor = !hidden_cursor; |
1000 | want_refresh = 1; |
1125 | want_refresh = 1; |
1001 | |
1126 | |
1002 | w.start (w.at + BLINK_INTERVAL); |
1127 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1003 | } |
1128 | } |
1004 | #endif |
1129 | #endif |
1005 | |
1130 | |
1006 | #ifdef TEXT_BLINK |
1131 | #ifdef TEXT_BLINK |
1007 | void |
1132 | void |
… | |
… | |
1021 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1146 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1022 | { |
1147 | { |
1023 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1148 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1024 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1149 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1025 | { |
1150 | { |
1026 | refresh_type |= SMOOTH_REFRESH; |
|
|
1027 | want_refresh = 1; |
1151 | want_refresh = 1; |
1028 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1152 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1029 | } |
1153 | } |
1030 | } |
1154 | } |
1031 | #endif |
1155 | #endif |
… | |
… | |
1035 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1159 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1036 | { |
1160 | { |
1037 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1161 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1038 | { |
1162 | { |
1039 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1163 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1040 | refresh_type |= SMOOTH_REFRESH; |
|
|
1041 | want_refresh = 1; |
1164 | want_refresh = 1; |
1042 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1165 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1043 | } |
1166 | } |
1044 | } |
1167 | } |
1045 | #endif |
1168 | #endif |
… | |
… | |
1050 | { |
1173 | { |
1051 | if (mouse_slip_wheel_speed == 0 |
1174 | if (mouse_slip_wheel_speed == 0 |
1052 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1175 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1053 | : scr_page (UP, mouse_slip_wheel_speed)) |
1176 | : scr_page (UP, mouse_slip_wheel_speed)) |
1054 | { |
1177 | { |
1055 | if (view_start == nsaved || |
1178 | if (view_start == top_row || view_start == 0) |
1056 | view_start == 0) |
|
|
1057 | mouse_slip_wheel_speed = 0; |
1179 | mouse_slip_wheel_speed = 0; |
1058 | |
1180 | |
1059 | refresh_type |= SMOOTH_REFRESH; |
|
|
1060 | want_refresh = 1; |
1181 | want_refresh = 1; |
1061 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1182 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1062 | } |
1183 | } |
1063 | } |
1184 | } |
1064 | #endif |
1185 | #endif |
1065 | |
1186 | |
|
|
1187 | #if LINUX_YIELD_HACK |
|
|
1188 | static struct event_handler |
|
|
1189 | { |
|
|
1190 | check_watcher yield_ev; |
|
|
1191 | |
|
|
1192 | void yield_cb (check_watcher &w) |
|
|
1193 | { |
|
|
1194 | // this should really be sched_yield(), but the linux guys thought |
|
|
1195 | // that giving a process calling sched_yield () less cpu time than |
|
|
1196 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1197 | // allowed by the sus... as is returning ENOSYS. |
|
|
1198 | |
|
|
1199 | struct timespec ts = { 0, 0 }; |
|
|
1200 | nanosleep (&ts, 0); |
|
|
1201 | |
|
|
1202 | w.stop (); |
|
|
1203 | } |
|
|
1204 | |
|
|
1205 | event_handler () |
|
|
1206 | : yield_ev (this, &event_handler::yield_cb) |
|
|
1207 | { |
|
|
1208 | } |
|
|
1209 | } event_handler; |
|
|
1210 | #endif |
|
|
1211 | |
1066 | bool |
1212 | bool |
1067 | rxvt_term::pty_fill () |
1213 | rxvt_term::pty_fill () |
1068 | { |
1214 | { |
1069 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1215 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1070 | |
1216 | |
1071 | if (CBUFSIZ == n) |
1217 | if (CBUFSIZ == n) |
1072 | { |
1218 | { |
1073 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1219 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1074 | n = 0; |
1220 | n = 0; |
1075 | } |
1221 | } |
1076 | |
1222 | |
1077 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1223 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1078 | cmdbuf_ptr = cmdbuf_base; |
1224 | cmdbuf_ptr = cmdbuf_base; |
1079 | cmdbuf_endp = cmdbuf_ptr + n; |
1225 | cmdbuf_endp = cmdbuf_ptr + n; |
1080 | |
1226 | |
1081 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1227 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1082 | |
1228 | |
1083 | if (n > 0) |
1229 | if (r > 0) |
1084 | { |
1230 | { |
1085 | cmdbuf_endp += n; |
1231 | cmdbuf_endp += r; |
1086 | return true; |
1232 | return true; |
1087 | } |
1233 | } |
1088 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1234 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1235 | { |
|
|
1236 | #if LINUX_YIELD_HACK |
|
|
1237 | if (display->is_local) |
|
|
1238 | event_handler.yield_ev.start (); |
|
|
1239 | #endif |
|
|
1240 | } |
|
|
1241 | else |
1089 | { |
1242 | { |
1090 | pty_ev.stop (); |
1243 | pty_ev.stop (); |
1091 | |
1244 | |
1092 | if (!(options & Opt_hold)) |
1245 | if (!option (Opt_hold)) |
1093 | destroy (); |
1246 | destroy (); |
1094 | } |
1247 | } |
1095 | |
1248 | |
1096 | return false; |
1249 | return false; |
1097 | } |
1250 | } |
1098 | |
1251 | |
1099 | void |
1252 | void |
1100 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1253 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1101 | { |
1254 | { |
1102 | SET_R (this); |
1255 | make_current (); |
1103 | SET_LOCALE (locale); |
|
|
1104 | |
1256 | |
1105 | if (revents & EVENT_READ) |
1257 | if (revents & EVENT_READ) |
1106 | // loop, but don't allow a single term to monopolize us |
1258 | // loop, but don't allow a single term to monopolize us |
1107 | while (pty_fill ()) |
1259 | while (pty_fill ()) |
1108 | if (cmd_parse ()) |
1260 | if (cmd_parse ()) |
… | |
… | |
1113 | } |
1265 | } |
1114 | |
1266 | |
1115 | void |
1267 | void |
1116 | rxvt_term::pointer_unblank () |
1268 | rxvt_term::pointer_unblank () |
1117 | { |
1269 | { |
1118 | XDefineCursor (display->display, vt, TermWin_cursor); |
1270 | XDefineCursor (dpy, vt, TermWin_cursor); |
1119 | recolour_cursor (); |
1271 | recolour_cursor (); |
1120 | |
1272 | |
1121 | #ifdef POINTER_BLANK |
1273 | #ifdef POINTER_BLANK |
1122 | hidden_pointer = 0; |
1274 | hidden_pointer = 0; |
1123 | |
1275 | |
1124 | if (options & Opt_pointerBlank) |
1276 | if (option (Opt_pointerBlank)) |
1125 | pointer_ev.start (NOW + pointerBlankDelay); |
1277 | pointer_ev.start (NOW + pointerBlankDelay); |
1126 | #endif |
1278 | #endif |
1127 | } |
1279 | } |
1128 | |
1280 | |
1129 | #ifdef POINTER_BLANK |
1281 | #ifdef POINTER_BLANK |
1130 | void |
1282 | void |
1131 | rxvt_term::pointer_blank () |
1283 | rxvt_term::pointer_blank () |
1132 | { |
1284 | { |
1133 | if (! (options & Opt_pointerBlank)) |
1285 | if (!option (Opt_pointerBlank)) |
1134 | return; |
1286 | return; |
1135 | |
1287 | |
1136 | XDefineCursor (display->display, vt, display->blank_cursor); |
1288 | XDefineCursor (dpy, vt, display->blank_cursor); |
1137 | XFlush (display->display); |
1289 | XFlush (dpy); |
1138 | |
1290 | |
1139 | hidden_pointer = 1; |
1291 | hidden_pointer = 1; |
1140 | } |
1292 | } |
1141 | |
1293 | |
1142 | void |
1294 | void |
1143 | rxvt_term::pointer_cb (time_watcher &w) |
1295 | rxvt_term::pointer_cb (time_watcher &w) |
1144 | { |
1296 | { |
1145 | SET_R (this); |
1297 | make_current (); |
1146 | SET_LOCALE (locale); |
|
|
1147 | |
1298 | |
1148 | pointer_blank (); |
1299 | pointer_blank (); |
1149 | } |
1300 | } |
1150 | #endif |
1301 | #endif |
1151 | |
1302 | |
… | |
… | |
1216 | (32 + button_number + key_state), |
1367 | (32 + button_number + key_state), |
1217 | (32 + x + 1), |
1368 | (32 + x + 1), |
1218 | (32 + y + 1)); |
1369 | (32 + y + 1)); |
1219 | } |
1370 | } |
1220 | |
1371 | |
1221 | #ifdef USING_W11LIB |
|
|
1222 | void |
|
|
1223 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1224 | { |
|
|
1225 | rxvt_t *r = rxvt_get_r (); |
|
|
1226 | |
|
|
1227 | x_cb (*ev); |
|
|
1228 | } |
|
|
1229 | #endif |
|
|
1230 | |
|
|
1231 | /*{{{ process an X event */ |
1372 | /*{{{ process an X event */ |
1232 | void |
1373 | void |
1233 | rxvt_term::x_cb (XEvent &ev) |
1374 | rxvt_term::x_cb (XEvent &ev) |
1234 | { |
1375 | { |
1235 | dDisp; |
1376 | make_current (); |
1236 | |
1377 | |
1237 | SET_R (this); |
1378 | dLocal (Display *, dpy); |
1238 | SET_LOCALE (locale); |
|
|
1239 | |
1379 | |
1240 | #if defined(CURSOR_BLINK) |
1380 | if (ev.xany.window == vt |
1241 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1381 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1242 | { |
1382 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1243 | if (hidden_cursor) |
1383 | return; |
1244 | { |
|
|
1245 | hidden_cursor = 0; |
|
|
1246 | want_refresh = 1; |
|
|
1247 | } |
|
|
1248 | |
1384 | |
1249 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1385 | // 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; |
1386 | Window unused_root, unused_child; |
1268 | int unused_root_x, unused_root_y; |
1387 | int unused_root_x, unused_root_y; |
1269 | unsigned int unused_mask; |
1388 | unsigned int unused_mask; |
1270 | |
1389 | |
1271 | switch (ev.type) |
1390 | switch (ev.type) |
1272 | { |
1391 | { |
1273 | case KeyPress: |
1392 | case KeyPress: |
1274 | #if ISO_14755 |
1393 | key_press (ev.xkey); |
1275 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1276 | #endif |
|
|
1277 | lookup_key (ev.xkey); |
|
|
1278 | |
|
|
1279 | break; |
1394 | break; |
1280 | |
1395 | |
1281 | case KeyRelease: |
1396 | case KeyRelease: |
1282 | { |
1397 | key_release (ev.xkey); |
1283 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1284 | KeySym ks; |
|
|
1285 | |
|
|
1286 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1287 | #endif |
|
|
1288 | |
|
|
1289 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1290 | // ISO 14755 support |
|
|
1291 | if (iso14755buf) |
|
|
1292 | if (iso14755buf & ISO_14755_52) |
|
|
1293 | { |
|
|
1294 | # if ENABLE_OVERLAY |
|
|
1295 | scr_overlay_off (); |
|
|
1296 | # endif |
|
|
1297 | # if ISO_14755 |
|
|
1298 | // iso14755 part 5.2 handling: release time |
|
|
1299 | // first: controls |
|
|
1300 | if ((ev.xkey.state & ControlMask) |
|
|
1301 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1302 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1303 | { |
|
|
1304 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1305 | commit_iso14755 (); |
|
|
1306 | return; // case-break; |
|
|
1307 | } |
|
|
1308 | |
|
|
1309 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1310 | if (i[0] == ks) |
|
|
1311 | { |
|
|
1312 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1313 | commit_iso14755 (); |
|
|
1314 | return; // case-break; |
|
|
1315 | } |
|
|
1316 | |
|
|
1317 | scr_bell (); |
|
|
1318 | # endif |
|
|
1319 | iso14755buf = 0; |
|
|
1320 | break; |
|
|
1321 | } |
|
|
1322 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1323 | { |
|
|
1324 | # if ENABLE_OVERLAY |
|
|
1325 | scr_overlay_off (); |
|
|
1326 | # endif |
|
|
1327 | if (iso14755buf & ISO_14755_51) |
|
|
1328 | commit_iso14755 (); |
|
|
1329 | #if ISO_14755 |
|
|
1330 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1331 | { |
|
|
1332 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1333 | |
|
|
1334 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1335 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1336 | } |
|
|
1337 | # endif |
|
|
1338 | else |
|
|
1339 | iso14755buf = 0; |
|
|
1340 | } |
|
|
1341 | #endif |
|
|
1342 | |
|
|
1343 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1344 | if (!(ev.xkey.state & ControlMask)) |
|
|
1345 | slip_wheel_ev.stop (); |
|
|
1346 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1347 | mouse_slip_wheel_speed = 0; |
|
|
1348 | #endif |
|
|
1349 | break; |
1398 | break; |
1350 | } |
|
|
1351 | |
1399 | |
1352 | case ButtonPress: |
1400 | case ButtonPress: |
1353 | button_press (ev.xbutton); |
1401 | button_press (ev.xbutton); |
1354 | break; |
1402 | break; |
1355 | |
1403 | |
… | |
… | |
1357 | button_release (ev.xbutton); |
1405 | button_release (ev.xbutton); |
1358 | break; |
1406 | break; |
1359 | |
1407 | |
1360 | case ClientMessage: |
1408 | case ClientMessage: |
1361 | if (ev.xclient.format == 32 |
1409 | if (ev.xclient.format == 32 |
1362 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1410 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1363 | { |
1411 | { |
|
|
1412 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1413 | { |
|
|
1414 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1415 | { |
1364 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1416 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1417 | { |
|
|
1418 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1365 | destroy (); |
1419 | destroy (); |
|
|
1420 | } |
1366 | #if ENABLE_EWMH |
1421 | #if ENABLE_EWMH |
1367 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1422 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1368 | XSendEvent (disp, ev.xclient.window = display->root, |
1423 | XSendEvent (dpy, ev.xclient.window = display->root, |
1369 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1424 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1370 | &ev); |
1425 | &ev); |
|
|
1426 | #endif |
|
|
1427 | } |
|
|
1428 | } |
|
|
1429 | #if ENABLE_XEMBED |
|
|
1430 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1431 | { |
|
|
1432 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1433 | focus_in (); |
|
|
1434 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1435 | focus_out (); |
|
|
1436 | } |
1371 | #endif |
1437 | #endif |
1372 | } |
1438 | } |
1373 | #if ENABLE_XEMBED |
|
|
1374 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1375 | { |
|
|
1376 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1377 | focus_in (); |
|
|
1378 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1379 | focus_out (); |
|
|
1380 | } |
|
|
1381 | #endif |
|
|
1382 | #ifdef OFFIX_DND |
|
|
1383 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1384 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1385 | && (ev.xclient.data.l[0] == DndFile |
|
|
1386 | || ev.xclient.data.l[0] == DndDir |
|
|
1387 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1388 | { |
|
|
1389 | /* Get Dnd data */ |
|
|
1390 | Atom ActualType; |
|
|
1391 | int ActualFormat; |
|
|
1392 | unsigned char *data; |
|
|
1393 | unsigned long Size, RemainingBytes; |
|
|
1394 | |
|
|
1395 | XGetWindowProperty (disp, display->root, |
|
|
1396 | xa[XA_DNDSELECTION], |
|
|
1397 | 0L, 1000000L, |
|
|
1398 | False, AnyPropertyType, |
|
|
1399 | &ActualType, &ActualFormat, |
|
|
1400 | &Size, &RemainingBytes, |
|
|
1401 | &data); |
|
|
1402 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1403 | XFree (data); |
|
|
1404 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1405 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1406 | } |
|
|
1407 | #endif /* OFFIX_DND */ |
|
|
1408 | break; |
1439 | break; |
1409 | |
1440 | |
1410 | case MappingNotify: |
1441 | case MappingNotify: |
1411 | XRefreshKeyboardMapping (&ev.xmapping); |
1442 | XRefreshKeyboardMapping (&ev.xmapping); |
1412 | break; |
1443 | break; |
… | |
… | |
1435 | break; |
1466 | break; |
1436 | } |
1467 | } |
1437 | break; |
1468 | break; |
1438 | |
1469 | |
1439 | case FocusIn: |
1470 | case FocusIn: |
|
|
1471 | if (ev.xfocus.detail != NotifyInferior |
|
|
1472 | && ev.xfocus.detail != NotifyPointer |
|
|
1473 | && ev.xfocus.mode != NotifyGrab) |
1440 | focus_in (); |
1474 | focus_in (); |
1441 | break; |
1475 | break; |
1442 | |
1476 | |
1443 | case FocusOut: |
1477 | case FocusOut: |
|
|
1478 | if (ev.xfocus.detail != NotifyInferior |
|
|
1479 | && ev.xfocus.detail != NotifyPointer |
|
|
1480 | && ev.xfocus.mode != NotifyGrab) |
1444 | focus_out (); |
1481 | focus_out (); |
1445 | break; |
1482 | break; |
1446 | |
1483 | |
1447 | case ConfigureNotify: |
1484 | case ConfigureNotify: |
1448 | if (ev.xconfigure.window == parent[0]) |
1485 | if (ev.xconfigure.window == parent[0]) |
1449 | { |
1486 | { |
1450 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1487 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1451 | ; |
1488 | ; |
1452 | |
1489 | |
1453 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1490 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1454 | { |
1491 | { |
1455 | seen_resize = 1; |
1492 | seen_resize = 1; |
1456 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1493 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
|
|
1494 | #ifdef XPM_BACKGROUND |
|
|
1495 | if (!option(Opt_transparent) && bgPixmap.auto_resize) |
|
|
1496 | { |
|
|
1497 | resize_pixmap (); |
|
|
1498 | scr_touch (true); |
|
|
1499 | } |
|
|
1500 | #endif |
1457 | } |
1501 | } |
1458 | |
1502 | |
1459 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1503 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1504 | |
|
|
1505 | #ifdef TRANSPARENT |
1460 | if (options & Opt_transparent) |
1506 | if (option (Opt_transparent)) |
1461 | check_our_parents (); |
1507 | check_our_parents (); |
1462 | #endif |
1508 | #endif |
1463 | } |
1509 | } |
1464 | break; |
1510 | break; |
1465 | |
1511 | |
1466 | case PropertyNotify: |
1512 | case PropertyNotify: |
|
|
1513 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1467 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1514 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1468 | && ev.xproperty.state == PropertyNewValue) |
1515 | && ev.xproperty.state == PropertyNewValue) |
1469 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1516 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1470 | |
1517 | |
1471 | break; |
1518 | break; |
1472 | |
1519 | |
1473 | case SelectionClear: |
1520 | case SelectionClear: |
1474 | selection_clear (); |
1521 | selection_clear (); |
… | |
… | |
1479 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1526 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1480 | break; |
1527 | break; |
1481 | |
1528 | |
1482 | case SelectionRequest: |
1529 | case SelectionRequest: |
1483 | selection_send (ev.xselectionrequest); |
1530 | selection_send (ev.xselectionrequest); |
|
|
1531 | break; |
|
|
1532 | |
|
|
1533 | case MapNotify: |
|
|
1534 | mapped = 1; |
|
|
1535 | #ifdef TEXT_BLINK |
|
|
1536 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1537 | #endif |
|
|
1538 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1484 | break; |
1539 | break; |
1485 | |
1540 | |
1486 | case UnmapNotify: |
1541 | case UnmapNotify: |
1487 | mapped = 0; |
1542 | mapped = 0; |
1488 | #ifdef TEXT_BLINK |
1543 | #ifdef TEXT_BLINK |
1489 | text_blink_ev.stop (); |
1544 | text_blink_ev.stop (); |
1490 | #endif |
1545 | #endif |
1491 | break; |
1546 | 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; |
1547 | break; |
1499 | |
1548 | |
1500 | #ifdef TRANSPARENT |
1549 | #ifdef TRANSPARENT |
1501 | case ReparentNotify: |
1550 | case ReparentNotify: |
1502 | rootwin_cb (ev); |
1551 | rootwin_cb (ev); |
… | |
… | |
1508 | if (ev.xany.window == vt) |
1557 | if (ev.xany.window == vt) |
1509 | { |
1558 | { |
1510 | do |
1559 | do |
1511 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1560 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1512 | ev.xexpose.width, ev.xexpose.height, False); |
1561 | ev.xexpose.width, ev.xexpose.height, False); |
1513 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1562 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1514 | |
1563 | |
1515 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1564 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1516 | |
1565 | |
1517 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1566 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1518 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1567 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1519 | ev.xexpose.width, ev.xexpose.height, False); |
1568 | ev.xexpose.width, ev.xexpose.height, False); |
1520 | |
1569 | |
1521 | scr_refresh (refresh_type); |
1570 | want_refresh = 1; |
1522 | } |
1571 | } |
1523 | else |
1572 | else |
1524 | { |
1573 | { |
1525 | XEvent unused_event; |
1574 | XEvent unused_event; |
1526 | |
1575 | |
1527 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1576 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1528 | ; |
1577 | ; |
1529 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1578 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1530 | ; |
1579 | ; |
1531 | |
1580 | |
1532 | if (isScrollbarWindow (ev.xany.window)) |
1581 | if (isScrollbarWindow (ev.xany.window)) |
1533 | { |
1582 | { |
1534 | scrollBar.setIdle (); |
1583 | scrollBar.setIdle (); |
1535 | scrollbar_show (0); |
1584 | scrollbar_show (0); |
1536 | } |
1585 | } |
1537 | #ifdef MENUBAR |
|
|
1538 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1539 | menubar_expose (); |
|
|
1540 | #endif |
|
|
1541 | |
1586 | |
1542 | #ifdef TRANSPARENT |
1587 | #ifdef TRANSPARENT |
1543 | if (am_transparent && ev.xany.window == parent[0]) |
1588 | if (am_transparent && ev.xany.window == parent[0]) |
1544 | XClearWindow (disp, ev.xany.window); |
1589 | XClearWindow (dpy, ev.xany.window); |
1545 | #endif |
1590 | #endif |
1546 | } |
1591 | } |
1547 | break; |
1592 | break; |
1548 | |
1593 | |
1549 | case MotionNotify: |
1594 | case MotionNotify: |
1550 | #ifdef POINTER_BLANK |
1595 | #ifdef POINTER_BLANK |
1551 | if (hidden_pointer) |
1596 | if (hidden_pointer) |
1552 | pointer_unblank (); |
1597 | pointer_unblank (); |
1553 | #endif |
1598 | #endif |
1554 | #if MENUBAR |
|
|
1555 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1556 | { |
|
|
1557 | menubar_control (ev.xbutton); |
|
|
1558 | break; |
|
|
1559 | } |
|
|
1560 | #endif |
|
|
1561 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1599 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1562 | break; |
1600 | break; |
1563 | |
1601 | |
1564 | if (ev.xany.window == vt) |
1602 | if (ev.xany.window == vt) |
1565 | { |
1603 | { |
|
|
1604 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1605 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1606 | ; // nop |
1566 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1607 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1567 | { |
1608 | { |
1568 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1609 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1569 | ; |
1610 | ; |
1570 | |
1611 | |
1571 | XQueryPointer (disp, vt, |
1612 | XQueryPointer (dpy, vt, |
1572 | &unused_root, &unused_child, |
1613 | &unused_root, &unused_child, |
1573 | &unused_root_x, &unused_root_y, |
1614 | &unused_root_x, &unused_root_y, |
1574 | &ev.xbutton.x, &ev.xbutton.y, |
1615 | &ev.xbutton.x, &ev.xbutton.y, |
1575 | &ev.xbutton.state); |
1616 | &ev.xbutton.state); |
1576 | #ifdef MOUSE_THRESHOLD |
1617 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1640 | #endif |
1681 | #endif |
1641 | } |
1682 | } |
1642 | } |
1683 | } |
1643 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1684 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1644 | { |
1685 | { |
1645 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1686 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1646 | MotionNotify, &ev)) |
1687 | MotionNotify, &ev)) |
1647 | ; |
1688 | ; |
1648 | |
1689 | |
1649 | XQueryPointer (disp, scrollBar.win, |
1690 | XQueryPointer (dpy, scrollBar.win, |
1650 | &unused_root, &unused_child, |
1691 | &unused_root, &unused_child, |
1651 | &unused_root_x, &unused_root_y, |
1692 | &unused_root_x, &unused_root_y, |
1652 | &ev.xbutton.x, &ev.xbutton.y, |
1693 | &ev.xbutton.x, &ev.xbutton.y, |
1653 | &unused_mask); |
1694 | &unused_mask); |
1654 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1695 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1655 | scrollbar_size ()); |
1696 | scrollbar_size ()); |
1656 | scr_refresh (refresh_type); |
1697 | want_refresh = 1; |
1657 | refresh_limit = 0; |
1698 | refresh_limit = 0; |
1658 | scrollbar_show (1); |
1699 | scrollbar_show (1); |
1659 | } |
1700 | } |
1660 | break; |
1701 | break; |
1661 | } |
1702 | } |
|
|
1703 | |
|
|
1704 | #if defined(CURSOR_BLINK) |
|
|
1705 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1706 | { |
|
|
1707 | if (hidden_cursor) |
|
|
1708 | { |
|
|
1709 | hidden_cursor = 0; |
|
|
1710 | want_refresh = 1; |
|
|
1711 | } |
|
|
1712 | |
|
|
1713 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1714 | } |
|
|
1715 | #endif |
|
|
1716 | |
|
|
1717 | #if defined(POINTER_BLANK) |
|
|
1718 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1719 | { |
|
|
1720 | if (ev.type == MotionNotify |
|
|
1721 | || ev.type == ButtonPress |
|
|
1722 | || ev.type == ButtonRelease) |
|
|
1723 | if (hidden_pointer) |
|
|
1724 | pointer_unblank (); |
|
|
1725 | |
|
|
1726 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1727 | pointer_blank (); |
|
|
1728 | } |
|
|
1729 | #endif |
1662 | } |
1730 | } |
1663 | |
1731 | |
1664 | void |
1732 | void |
1665 | rxvt_term::focus_in () |
1733 | rxvt_term::focus_in () |
1666 | { |
1734 | { |
1667 | if (!focus) |
1735 | if (!focus) |
1668 | { |
1736 | { |
1669 | focus = 1; |
1737 | focus = 1; |
1670 | want_refresh = 1; |
1738 | want_refresh = 1; |
|
|
1739 | |
|
|
1740 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1741 | |
1671 | #if USE_XIM |
1742 | #if USE_XIM |
1672 | if (Input_Context != NULL) |
1743 | if (Input_Context != NULL) |
1673 | { |
1744 | { |
1674 | IMSetStatusPosition (); |
1745 | IMSetPosition (); |
1675 | XSetICFocus (Input_Context); |
1746 | XSetICFocus (Input_Context); |
1676 | } |
1747 | } |
1677 | #endif |
1748 | #endif |
1678 | #if CURSOR_BLINK |
1749 | #if CURSOR_BLINK |
1679 | if (options & Opt_cursorBlink) |
1750 | if (option (Opt_cursorBlink)) |
1680 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1751 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1681 | #endif |
1752 | #endif |
1682 | #if OFF_FOCUS_FADING |
1753 | #if OFF_FOCUS_FADING |
1683 | if (rs[Rs_fade]) |
1754 | if (rs[Rs_fade]) |
1684 | { |
1755 | { |
1685 | pix_colors = pix_colors_focused; |
1756 | pix_colors = pix_colors_focused; |
1686 | scr_recolour (); |
1757 | scr_recolour (); |
1687 | } |
1758 | } |
1688 | #endif |
1759 | #endif |
|
|
1760 | #if ENABLE_FRILLS |
|
|
1761 | if (option (Opt_urgentOnBell)) |
|
|
1762 | { |
|
|
1763 | XWMHints *h; |
|
|
1764 | |
|
|
1765 | h = XGetWMHints(dpy, parent[0]); |
|
|
1766 | if (h != NULL) |
|
|
1767 | { |
|
|
1768 | h->flags &= ~XUrgencyHint; |
|
|
1769 | XSetWMHints(dpy, parent[0], h); |
|
|
1770 | } |
|
|
1771 | } |
|
|
1772 | #endif |
1689 | } |
1773 | } |
1690 | } |
1774 | } |
1691 | |
1775 | |
1692 | void |
1776 | void |
1693 | rxvt_term::focus_out () |
1777 | rxvt_term::focus_out () |
… | |
… | |
1695 | if (focus) |
1779 | if (focus) |
1696 | { |
1780 | { |
1697 | focus = 0; |
1781 | focus = 0; |
1698 | want_refresh = 1; |
1782 | want_refresh = 1; |
1699 | |
1783 | |
|
|
1784 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1785 | |
1700 | #if ENABLE_FRILLS || ISO_14755 |
1786 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1787 | if (iso14755buf) |
|
|
1788 | { |
1701 | iso14755buf = 0; |
1789 | iso14755buf = 0; |
1702 | #endif |
|
|
1703 | #if ENABLE_OVERLAY |
1790 | # if ENABLE_OVERLAY |
1704 | scr_overlay_off (); |
1791 | scr_overlay_off (); |
|
|
1792 | # endif |
|
|
1793 | } |
1705 | #endif |
1794 | #endif |
1706 | #if USE_XIM |
1795 | #if USE_XIM |
1707 | if (Input_Context != NULL) |
1796 | if (Input_Context != NULL) |
1708 | XUnsetICFocus (Input_Context); |
1797 | XUnsetICFocus (Input_Context); |
1709 | #endif |
1798 | #endif |
1710 | #if CURSOR_BLINK |
1799 | #if CURSOR_BLINK |
1711 | if (options & Opt_cursorBlink) |
1800 | if (option (Opt_cursorBlink)) |
1712 | cursor_blink_ev.stop (); |
1801 | cursor_blink_ev.stop (); |
1713 | hidden_cursor = 0; |
1802 | hidden_cursor = 0; |
1714 | #endif |
1803 | #endif |
1715 | #if OFF_FOCUS_FADING |
1804 | #if OFF_FOCUS_FADING |
1716 | if (rs[Rs_fade]) |
1805 | if (rs[Rs_fade]) |
… | |
… | |
1720 | } |
1809 | } |
1721 | #endif |
1810 | #endif |
1722 | } |
1811 | } |
1723 | } |
1812 | } |
1724 | |
1813 | |
1725 | #if TRANSPARENT |
1814 | void |
|
|
1815 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1816 | { |
|
|
1817 | #if OFF_FOCUS_FADING |
|
|
1818 | if (rs[Rs_fade]) |
|
|
1819 | { |
|
|
1820 | rgba c; |
|
|
1821 | pix_colors [Color_fade].get (c); |
|
|
1822 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1823 | } |
|
|
1824 | #endif |
|
|
1825 | } |
|
|
1826 | |
|
|
1827 | #if TRANSPARENT || ENABLE_PERL |
1726 | void |
1828 | void |
1727 | rxvt_term::rootwin_cb (XEvent &ev) |
1829 | rxvt_term::rootwin_cb (XEvent &ev) |
1728 | { |
1830 | { |
1729 | SET_R (this); |
1831 | make_current (); |
1730 | SET_LOCALE (locale); |
|
|
1731 | |
1832 | |
|
|
1833 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1834 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1835 | return; |
|
|
1836 | |
|
|
1837 | # if TRANSPARENT |
1732 | switch (ev.type) |
1838 | switch (ev.type) |
1733 | { |
1839 | { |
1734 | case PropertyNotify: |
1840 | case PropertyNotify: |
1735 | /* |
1841 | /* |
1736 | * if user used some Esetroot compatible prog to set the root bg, |
1842 | * if user used some Esetroot compatible prog to set the root bg, |
… | |
… | |
1740 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1846 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1741 | return; |
1847 | return; |
1742 | |
1848 | |
1743 | /* FALLTHROUGH */ |
1849 | /* FALLTHROUGH */ |
1744 | case ReparentNotify: |
1850 | case ReparentNotify: |
1745 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1851 | if (option (Opt_transparent)) |
1746 | want_refresh = want_full_refresh = 1; |
1852 | check_our_parents (); |
1747 | break; |
1853 | break; |
1748 | } |
1854 | } |
|
|
1855 | # endif |
1749 | } |
1856 | } |
1750 | #endif |
1857 | #endif |
1751 | |
1858 | |
1752 | void |
1859 | void |
1753 | rxvt_term::button_press (XButtonEvent &ev) |
1860 | rxvt_term::button_press (XButtonEvent &ev) |
1754 | { |
1861 | { |
1755 | int reportmode = 0, clickintime; |
1862 | int reportmode = 0, clickintime; |
1756 | |
1863 | |
1757 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1864 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1865 | |
1758 | if (!bypass_keystate) |
1866 | if (!bypass_keystate) |
1759 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1867 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1760 | |
1868 | |
1761 | /* |
1869 | /* |
1762 | * VT window processing of button press |
1870 | * VT window processing of button press |
1763 | */ |
1871 | */ |
1764 | if (ev.window == vt) |
1872 | if (ev.window == vt) |
1765 | { |
1873 | { |
|
|
1874 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1875 | return; |
|
|
1876 | |
1766 | #if ISO_14755 |
1877 | #if ISO_14755 |
1767 | // 5.4 |
1878 | // 5.4 |
1768 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1879 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1769 | { |
1880 | { |
1770 | iso14755_54 (ev.x, ev.y); |
1881 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1782 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1893 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1783 | if (ev.button == MEvent.button && clickintime) |
1894 | if (ev.button == MEvent.button && clickintime) |
1784 | { |
1895 | { |
1785 | /* same button, within alloted time */ |
1896 | /* same button, within alloted time */ |
1786 | MEvent.clicks++; |
1897 | MEvent.clicks++; |
|
|
1898 | |
1787 | if (MEvent.clicks > 1) |
1899 | if (MEvent.clicks > 1) |
1788 | { |
1900 | { |
1789 | /* only report double clicks */ |
1901 | /* only report double clicks */ |
1790 | MEvent.clicks = 2; |
1902 | MEvent.clicks = 2; |
1791 | mouse_report (ev); |
1903 | mouse_report (ev); |
… | |
… | |
1823 | #else |
1935 | #else |
1824 | selection.rect = false; |
1936 | selection.rect = false; |
1825 | #endif |
1937 | #endif |
1826 | |
1938 | |
1827 | /* allow shift+left click to extend selection */ |
1939 | /* allow shift+left click to extend selection */ |
1828 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1940 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1829 | { |
1941 | { |
1830 | if (MEvent.button == Button1 && clickintime) |
1942 | if (MEvent.button == Button1 && clickintime) |
1831 | selection_rotate (ev.x, ev.y); |
1943 | selection_rotate (ev.x, ev.y); |
1832 | else |
1944 | else |
1833 | selection_extend (ev.x, ev.y, 1); |
1945 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
1998 | } |
2110 | } |
1999 | |
2111 | |
2000 | break; |
2112 | break; |
2001 | } |
2113 | } |
2002 | } |
2114 | } |
|
|
2115 | |
2003 | return; |
2116 | return; |
2004 | } |
2117 | } |
2005 | #if MENUBAR |
|
|
2006 | /* |
|
|
2007 | * Menubar window processing of button press |
|
|
2008 | */ |
|
|
2009 | if (isMenuBarWindow (ev.window)) |
|
|
2010 | menubar_control (ev); |
|
|
2011 | #endif |
|
|
2012 | } |
2118 | } |
2013 | |
2119 | |
2014 | void |
2120 | void |
2015 | rxvt_term::button_release (XButtonEvent &ev) |
2121 | rxvt_term::button_release (XButtonEvent &ev) |
2016 | { |
2122 | { |
… | |
… | |
2022 | |
2128 | |
2023 | if (scrollbar_isUpDn ()) |
2129 | if (scrollbar_isUpDn ()) |
2024 | { |
2130 | { |
2025 | scrollBar.setIdle (); |
2131 | scrollBar.setIdle (); |
2026 | scrollbar_show (0); |
2132 | scrollbar_show (0); |
2027 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2028 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2029 | #endif |
|
|
2030 | } |
2133 | } |
2031 | |
2134 | |
2032 | #ifdef SELECTION_SCROLLING |
2135 | #ifdef SELECTION_SCROLLING |
2033 | if (sel_scroll_ev.active) |
2136 | if (sel_scroll_ev.active) |
2034 | sel_scroll_ev.stop(); |
2137 | sel_scroll_ev.stop(); |
2035 | #endif |
2138 | #endif |
2036 | |
2139 | |
2037 | if (ev.window == vt) |
2140 | if (ev.window == vt) |
2038 | { |
2141 | { |
|
|
2142 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2143 | return; |
|
|
2144 | |
2039 | #if ISO_14755 |
2145 | #if ISO_14755 |
2040 | // 5.4 |
2146 | // 5.4 |
2041 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2147 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2042 | return; |
2148 | return; |
2043 | #endif |
2149 | #endif |
|
|
2150 | |
2044 | if (reportmode) |
2151 | if (reportmode) |
2045 | { |
2152 | { |
2046 | /* mouse report from vt window */ |
2153 | /* mouse report from vt window */ |
2047 | /* don't report release of wheel "buttons" */ |
2154 | /* don't report release of wheel "buttons" */ |
2048 | if (ev.button >= 4) |
2155 | if (ev.button >= 4) |
… | |
… | |
2078 | { |
2185 | { |
2079 | case Button1: |
2186 | case Button1: |
2080 | case Button3: |
2187 | case Button3: |
2081 | selection_make (ev.time); |
2188 | selection_make (ev.time); |
2082 | break; |
2189 | break; |
|
|
2190 | |
2083 | case Button2: |
2191 | case Button2: |
2084 | selection_request (ev.time, ev.x, ev.y); |
2192 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2193 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2085 | break; |
2194 | break; |
|
|
2195 | |
2086 | #ifdef MOUSE_WHEEL |
2196 | #ifdef MOUSE_WHEEL |
2087 | case Button4: |
2197 | case Button4: |
2088 | case Button5: |
2198 | case Button5: |
2089 | { |
2199 | { |
2090 | int i; |
2200 | int i; |
… | |
… | |
2092 | |
2202 | |
2093 | v = ev.button == Button4 ? UP : DN; |
2203 | v = ev.button == Button4 ? UP : DN; |
2094 | |
2204 | |
2095 | if (ev.state & ShiftMask) |
2205 | if (ev.state & ShiftMask) |
2096 | i = 1; |
2206 | i = 1; |
2097 | else if (options & Opt_mouseWheelScrollPage) |
2207 | else if (option (Opt_mouseWheelScrollPage)) |
2098 | i = nrow - 1; |
2208 | i = nrow - 1; |
2099 | else |
2209 | else |
2100 | i = 5; |
2210 | i = 5; |
2101 | |
2211 | |
2102 | # ifdef MOUSE_SLIP_WHEELING |
2212 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2112 | slip_wheel_ev.start (); |
2222 | slip_wheel_ev.start (); |
2113 | } |
2223 | } |
2114 | else |
2224 | else |
2115 | { |
2225 | { |
2116 | # endif |
2226 | # endif |
2117 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2118 | scr_page (v, i); |
2227 | scr_page (v, i); |
2119 | scr_refresh (SMOOTH_REFRESH); |
|
|
2120 | scrollbar_show (1); |
2228 | 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 |
2229 | # ifdef MOUSE_SLIP_WHEELING |
2130 | } |
2230 | } |
2131 | #endif |
2231 | # endif |
2132 | } |
2232 | } |
2133 | break; |
2233 | break; |
2134 | #endif |
2234 | #endif |
2135 | } |
2235 | } |
2136 | } |
2236 | } |
2137 | #ifdef MENUBAR |
|
|
2138 | else if (isMenuBarWindow (ev.window)) |
|
|
2139 | menubar_control (ev); |
|
|
2140 | #endif |
|
|
2141 | } |
2237 | } |
2142 | |
2238 | |
2143 | #ifdef TRANSPARENT |
2239 | #ifdef TRANSPARENT |
2144 | #if TINTING |
2240 | #if TINTING && !defined(HAVE_AFTERIMAGE) |
2145 | /* taken from aterm-0.4.2 */ |
2241 | /* taken from aterm-0.4.2 */ |
2146 | |
2242 | |
2147 | typedef uint32_t RUINT32T; |
2243 | typedef uint32_t RUINT32T; |
2148 | |
2244 | |
2149 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
2245 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
2150 | { |
2246 | { |
2151 | int sh_r, sh_g, sh_b; |
2247 | int sh_r, sh_g, sh_b; |
2152 | RUINT32T mask_r, mask_g, mask_b; |
2248 | RUINT32T mask_r, mask_g, mask_b; |
2153 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2249 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2154 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2250 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2155 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2251 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2156 | int i; |
2252 | int i; |
2157 | |
2253 | |
2158 | Visual *visual = display->visual; |
2254 | Visual *visual = term->visual; |
2159 | |
2255 | |
2160 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2256 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2161 | |
2257 | |
2162 | /* for convenience */ |
2258 | /* for convenience */ |
2163 | mask_r = visual->red_mask; |
2259 | mask_r = visual->red_mask; |
… | |
… | |
2377 | * Do transparency updates if required |
2473 | * Do transparency updates if required |
2378 | */ |
2474 | */ |
2379 | int |
2475 | int |
2380 | rxvt_term::check_our_parents () |
2476 | rxvt_term::check_our_parents () |
2381 | { |
2477 | { |
|
|
2478 | #if TRANSPARENT || ENABLE_PERL |
|
|
2479 | check_our_aprents_ev.stop(); |
|
|
2480 | check_our_aprents_ev.start(NOW + 1./3.); |
|
|
2481 | #endif |
|
|
2482 | return 0; |
|
|
2483 | } |
|
|
2484 | |
|
|
2485 | void |
|
|
2486 | rxvt_term::check_our_parents_cb (time_watcher &w) |
|
|
2487 | { |
2382 | int i, pchanged, aformat, have_pixmap, rootdepth; |
2488 | int i, pchanged, aformat, have_pixmap, rootdepth; |
2383 | unsigned long nitems, bytes_after; |
2489 | unsigned long nitems, bytes_after; |
2384 | Atom atype; |
2490 | Atom atype; |
2385 | unsigned char *prop = NULL; |
2491 | unsigned char *prop = NULL; |
2386 | Window root, oldp, *list; |
2492 | Window root, oldp, *list; |
2387 | Pixmap rootpixmap = None; |
2493 | Pixmap rootpixmap = None; |
2388 | XWindowAttributes wattr, wrootattr; |
2494 | XWindowAttributes wattr, wrootattr; |
2389 | dDisp; |
2495 | int sx, sy; |
|
|
2496 | Window cr; |
2390 | |
2497 | |
2391 | pchanged = 0; |
2498 | pchanged = 0; |
2392 | |
2499 | |
2393 | if (!(options & Opt_transparent)) |
2500 | if (!option (Opt_transparent)) |
2394 | return pchanged; /* Don't try any more */ |
2501 | return /*pchanged*/; /* Don't try any more */ |
2395 | |
2502 | |
2396 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2503 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
2397 | rootdepth = wrootattr.depth; |
2504 | rootdepth = wrootattr.depth; |
2398 | |
2505 | |
2399 | XGetWindowAttributes (disp, parent[0], &wattr); |
2506 | XGetWindowAttributes (dpy, parent[0], &wattr); |
2400 | |
2507 | |
2401 | if (rootdepth != wattr.depth) |
2508 | if (rootdepth != wattr.depth) |
2402 | { |
2509 | { |
2403 | if (am_transparent) |
2510 | if (am_transparent) |
2404 | { |
2511 | { |
2405 | pchanged = 1; |
2512 | pchanged = 1; |
2406 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2513 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2407 | am_transparent = am_pixmap_trans = 0; |
2514 | am_transparent = am_pixmap_trans = 0; |
2408 | } |
2515 | } |
2409 | |
2516 | |
2410 | return pchanged; /* Don't try any more */ |
2517 | return /*pchanged*/; /* Don't try any more */ |
2411 | } |
2518 | } |
2412 | |
2519 | |
2413 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2520 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2414 | XSync (disp, False); |
2521 | XSync (dpy, False); |
2415 | |
2522 | |
|
|
2523 | XTranslateCoordinates (dpy, parent[0], display->root, |
|
|
2524 | 0, 0, &sx, &sy, &cr); |
|
|
2525 | |
|
|
2526 | /* check if we are outside of the visible part of the virtual screen : */ |
|
|
2527 | if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 |
|
|
2528 | || sx >= wrootattr.width || sy >= wrootattr.height ) |
|
|
2529 | return /* 0 */ ; |
2416 | /* |
2530 | /* |
2417 | * Make the frame window set by the window manager have |
2531 | * Make the frame window set by the window manager have |
2418 | * the root background. Some window managers put multiple nested frame |
2532 | * the root background. Some window managers put multiple nested frame |
2419 | * windows for each client, so we have to take care about that. |
2533 | * windows for each client, so we have to take care about that. |
2420 | */ |
2534 | */ |
2421 | i = (xa[XA_XROOTPMAP_ID] |
2535 | i = (xa[XA_XROOTPMAP_ID] |
2422 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2536 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
2423 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2537 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2424 | &nitems, &bytes_after, &prop) == Success); |
2538 | &nitems, &bytes_after, &prop) == Success); |
2425 | |
2539 | |
2426 | if (!i || prop == NULL) |
2540 | if (!i || prop == NULL) |
2427 | i = (xa[XA_ESETROOT_PMAP_ID] |
2541 | i = (xa[XA_ESETROOT_PMAP_ID] |
2428 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2542 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
2429 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2543 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2430 | &nitems, &bytes_after, &prop) == Success); |
2544 | &nitems, &bytes_after, &prop) == Success); |
2431 | |
2545 | |
2432 | if (!i || prop == NULL |
2546 | if (!i || prop == NULL |
2433 | #if TINTING |
2547 | #if TINTING |
2434 | || !rs[Rs_color + Color_tint] |
2548 | || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL |
|
|
2549 | #ifdef HAVE_AFTERIMAGE |
|
|
2550 | && original_asim == NULL && rs[Rs_blurradius] == NULL |
|
|
2551 | #endif |
|
|
2552 | ) |
2435 | #endif |
2553 | #endif |
2436 | ) |
2554 | ) |
2437 | have_pixmap = 0; |
2555 | have_pixmap = 0; |
2438 | else |
2556 | else |
2439 | { |
2557 | { |
… | |
… | |
2442 | XFree (prop); |
2560 | XFree (prop); |
2443 | } |
2561 | } |
2444 | |
2562 | |
2445 | if (have_pixmap) |
2563 | if (have_pixmap) |
2446 | { |
2564 | { |
|
|
2565 | Bool success = False ; |
|
|
2566 | GC gc; |
|
|
2567 | XGCValues gcvalue; |
|
|
2568 | #ifdef HAVE_AFTERIMAGE |
|
|
2569 | { |
|
|
2570 | Pixmap tmp_pmap = None ; |
|
|
2571 | ShadingInfo shade; |
|
|
2572 | ARGB32 tint ; |
|
|
2573 | unsigned int pmap_w = 0, pmap_h = 0; |
|
|
2574 | |
|
|
2575 | if (get_drawable_size( rootpixmap, &pmap_w, &pmap_h )) |
|
|
2576 | { |
|
|
2577 | int root_x = 0, root_y = 0; |
|
|
2578 | |
|
|
2579 | shade.shading = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2580 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2581 | { |
|
|
2582 | rgba c; |
|
|
2583 | pix_colors_focused [Color_tint].get (c); |
|
|
2584 | shade.tintColor.red = c.r; |
|
|
2585 | shade.tintColor.green = c.g; |
|
|
2586 | shade.tintColor.blue = c.b; |
|
|
2587 | } |
|
|
2588 | else |
|
|
2589 | shade.tintColor.red = shade.tintColor.green = shade.tintColor.blue = 0xFFFF; |
|
|
2590 | tint = shading2tint32( &shade ); |
|
|
2591 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
|
|
2592 | if (GetWinPosition (parent[0], &root_x, &root_y) ) |
|
|
2593 | { |
|
|
2594 | ASImageLayer *layers = create_image_layers( 2 ); |
|
|
2595 | ASImage *merged_im = NULL; |
|
|
2596 | int back_x, back_y, back_w, back_h; |
|
|
2597 | /* merge_layers does good job at tiling background appropriately, |
|
|
2598 | so all we need is to cut out smallest possible piece : */ |
|
|
2599 | #define MAKE_ROOTPMAP_GEOM(xy,wh,widthheight) \ |
|
|
2600 | do{ while( root_##xy < 0 ) root_##xy += (int)wrootattr.widthheight; \ |
|
|
2601 | back_##xy = root_##xy % pmap_##wh; /* that gives us left side of the closest tile : */ \ |
|
|
2602 | if( pmap_##wh >= back_##xy + szHint.widthheight ) \ |
|
|
2603 | back_##wh = szHint.widthheight;/* background is large - limit it by our size */ \ |
|
|
2604 | else \ |
|
|
2605 | { /* small background - need the whole of it for successfull tiling :*/ \ |
|
|
2606 | back_##xy = 0; \ |
|
|
2607 | back_##wh = pmap_##wh; \ |
|
|
2608 | }}while(0) |
|
|
2609 | |
|
|
2610 | MAKE_ROOTPMAP_GEOM(x,w,width); |
|
|
2611 | MAKE_ROOTPMAP_GEOM(y,h,height); |
|
|
2612 | |
|
|
2613 | layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100); |
|
|
2614 | layers[0].clip_x = (back_w == pmap_w)?root_x:0; |
|
|
2615 | layers[0].clip_y = (back_h == pmap_h)?root_y:0; |
|
|
2616 | layers[0].clip_width = szHint.width; |
|
|
2617 | layers[0].clip_height = szHint.height; |
|
|
2618 | layers[0].tint = tint; |
|
|
2619 | if (rs[Rs_blurradius] && layers[0].im) |
|
|
2620 | { |
|
|
2621 | double r = atof(rs[Rs_blurradius]); |
|
|
2622 | ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT ); |
|
|
2623 | if( tmp ) |
|
|
2624 | { |
|
|
2625 | destroy_asimage( &layers[0].im ); |
|
|
2626 | layers[0].im = tmp; |
|
|
2627 | } |
|
|
2628 | } |
|
|
2629 | if (original_asim != NULL) |
|
|
2630 | { |
|
|
2631 | int fore_w, fore_h; |
|
|
2632 | layers[1].im = original_asim; |
|
|
2633 | if( bgPixmap.auto_resize ) |
|
|
2634 | { |
|
|
2635 | fore_w = szHint.width; |
|
|
2636 | fore_h = szHint.height; |
|
|
2637 | } |
|
|
2638 | else |
|
|
2639 | { |
|
|
2640 | fore_w = bgPixmap.w; |
|
|
2641 | fore_h = bgPixmap.h; |
|
|
2642 | } |
|
|
2643 | if (fore_w != original_asim->width |
|
|
2644 | || fore_h != original_asim->height) |
|
|
2645 | { |
|
|
2646 | layers[1].im = scale_asimage( display->asv, |
|
|
2647 | original_asim, |
|
|
2648 | fore_w, fore_h, |
|
|
2649 | ASA_ASImage, 100, |
|
|
2650 | ASIMAGE_QUALITY_DEFAULT ); |
|
|
2651 | } |
|
|
2652 | |
|
|
2653 | layers[1].clip_width = szHint.width; |
|
|
2654 | layers[1].clip_height = szHint.height; |
|
|
2655 | |
|
|
2656 | if (rs[Rs_blendtype]) |
|
|
2657 | { |
|
|
2658 | layers[1].merge_scanlines = blend_scanlines_name2func(rs[Rs_blendtype]); |
|
|
2659 | if( layers[1].merge_scanlines == NULL ) |
|
|
2660 | layers[1].merge_scanlines = alphablend_scanlines; |
|
|
2661 | } |
|
|
2662 | } |
|
|
2663 | merged_im = merge_layers( display->asv, layers, layers[1].im?2:1, |
|
|
2664 | szHint.width, szHint.height, |
|
|
2665 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); |
|
|
2666 | if (layers[1].im != original_asim) |
|
|
2667 | destroy_asimage( &(layers[1].im) ); |
|
|
2668 | destroy_asimage( &(layers[0].im) ); |
|
|
2669 | if (merged_im != NULL) |
|
|
2670 | { |
|
|
2671 | tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True ); |
|
|
2672 | destroy_asimage( &merged_im ); |
|
|
2673 | } |
|
|
2674 | free( layers ); |
|
|
2675 | } |
|
|
2676 | } |
|
|
2677 | if (tmp_pmap != None) |
|
|
2678 | { |
|
|
2679 | success = True; |
|
|
2680 | if (pixmap != None) |
|
|
2681 | XFreePixmap (dpy, pixmap); |
|
|
2682 | pixmap = tmp_pmap; |
|
|
2683 | } |
|
|
2684 | } |
|
|
2685 | #else /* HAVE_AFTERIMAGE */ |
|
|
2686 | { |
2447 | /* |
2687 | /* |
2448 | * Copy display->root pixmap transparency |
2688 | * Copy display->root pixmap transparency |
2449 | */ |
2689 | */ |
2450 | int sx, sy, nx, ny; |
2690 | int nx, ny; |
2451 | unsigned int nw, nh; |
2691 | unsigned int nw, nh; |
2452 | Window cr; |
|
|
2453 | XImage *image; |
2692 | XImage *image; |
2454 | GC gc; |
|
|
2455 | XGCValues gcvalue; |
|
|
2456 | |
2693 | |
2457 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2458 | 0, 0, &sx, &sy, &cr); |
|
|
2459 | nw = (unsigned int)szHint.width; |
2694 | nw = (unsigned int)szHint.width; |
2460 | nh = (unsigned int)szHint.height; |
2695 | nh = (unsigned int)szHint.height; |
2461 | nx = ny = 0; |
2696 | nx = ny = 0; |
2462 | |
2697 | |
2463 | if (sx < 0) |
2698 | if (sx < 0) |
2464 | { |
2699 | { |
2465 | nw += sx; |
2700 | nw += sx; |
2466 | nx = -sx; |
2701 | nx = -sx; |
2467 | sx = 0; |
2702 | sx = 0; |
2468 | } |
2703 | } |
2469 | |
2704 | |
2470 | if (sy < 0) |
2705 | if (sy < 0) |
2471 | { |
2706 | { |
2472 | nh += sy; |
2707 | nh += sy; |
2473 | ny = -sy; |
2708 | ny = -sy; |
2474 | sy = 0; |
2709 | sy = 0; |
2475 | } |
2710 | } |
2476 | |
2711 | |
2477 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2712 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2478 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2713 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2479 | |
2714 | |
2480 | XSync (disp, False); |
2715 | XSync (dpy, False); |
2481 | allowedxerror = -1; |
2716 | allowedxerror = -1; |
2482 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2717 | image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2483 | |
2718 | |
2484 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2719 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2485 | /* XXX: may need a delay here? */ |
2720 | /* XXX: may need a delay here? */ |
2486 | allowedxerror = 0; |
2721 | allowedxerror = 0; |
2487 | |
|
|
2488 | if (image == NULL) |
2722 | if (image != NULL) |
|
|
2723 | { |
|
|
2724 | if (pixmap != None) |
|
|
2725 | XFreePixmap (dpy, pixmap); |
|
|
2726 | |
|
|
2727 | #if TINTING |
|
|
2728 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2729 | { |
|
|
2730 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2731 | |
|
|
2732 | rgba c; |
|
|
2733 | pix_colors_focused [Color_tint].get (c); |
|
|
2734 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
|
|
2735 | } |
|
|
2736 | #endif |
|
|
2737 | |
|
|
2738 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); |
|
|
2739 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
|
|
2740 | XPutImage (dpy, pixmap, gc, image, 0, 0, |
|
|
2741 | nx, ny, image->width, image->height); |
|
|
2742 | XDestroyImage (image); |
|
|
2743 | success = True ; |
|
|
2744 | } |
|
|
2745 | } |
|
|
2746 | #endif /* HAVE_AFTERIMAGE */ |
|
|
2747 | if (gc != NULL) |
|
|
2748 | XFreeGC (dpy, gc); |
|
|
2749 | |
|
|
2750 | if (!success) |
2489 | { |
2751 | { |
2490 | if (am_transparent && am_pixmap_trans) |
2752 | if (am_transparent && am_pixmap_trans) |
2491 | { |
2753 | { |
2492 | pchanged = 1; |
2754 | pchanged = 1; |
2493 | if (pixmap != None) |
2755 | if (pixmap != None) |
2494 | { |
2756 | { |
2495 | XFreePixmap (disp, pixmap); |
2757 | XFreePixmap (dpy, pixmap); |
2496 | pixmap = None; |
2758 | pixmap = None; |
2497 | } |
2759 | } |
2498 | } |
2760 | } |
2499 | |
2761 | |
2500 | am_pixmap_trans = 0; |
2762 | am_pixmap_trans = 0; |
2501 | } |
2763 | } |
2502 | else |
2764 | else |
2503 | { |
2765 | { |
2504 | if (pixmap != None) |
|
|
2505 | XFreePixmap (disp, pixmap); |
|
|
2506 | |
|
|
2507 | #if TINTING |
|
|
2508 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2509 | { |
|
|
2510 | unsigned short rm, gm, bm; |
|
|
2511 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2512 | |
|
|
2513 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2514 | |
|
|
2515 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2516 | } |
|
|
2517 | #endif |
|
|
2518 | |
|
|
2519 | pixmap = XCreatePixmap (disp, vt, |
|
|
2520 | szHint.width, szHint.height, image->depth); |
|
|
2521 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2522 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2523 | nx, ny, image->width, image->height); |
|
|
2524 | XFreeGC (disp, gc); |
|
|
2525 | XDestroyImage (image); |
|
|
2526 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
2766 | XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); |
2527 | XClearWindow (disp, parent[0]); |
2767 | XClearWindow (dpy, parent[0]); |
2528 | |
2768 | |
2529 | if (!am_transparent || !am_pixmap_trans) |
2769 | if (!am_transparent || !am_pixmap_trans) |
2530 | pchanged = 1; |
2770 | pchanged = 1; |
2531 | |
2771 | |
2532 | am_transparent = am_pixmap_trans = 1; |
2772 | am_transparent = am_pixmap_trans = 1; |
2533 | } |
2773 | } |
2534 | } |
2774 | } |
2535 | |
2775 | |
2536 | if (am_pixmap_trans) |
2776 | if (am_pixmap_trans) |
2537 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2777 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2538 | else |
2778 | else |
2539 | { |
2779 | { |
2540 | unsigned int n; |
2780 | unsigned int n; |
2541 | /* |
2781 | /* |
2542 | * InheritPixmap transparency |
2782 | * InheritPixmap transparency |
2543 | */ |
2783 | */ |
2544 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2784 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2545 | { |
2785 | { |
2546 | oldp = parent[i]; |
2786 | oldp = parent[i]; |
2547 | XQueryTree (disp, parent[i - 1], &root, |
2787 | XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n); |
2548 | &parent[i], &list, &n); |
|
|
2549 | XFree (list); |
2788 | XFree (list); |
2550 | |
2789 | |
2551 | if (parent[i] == display->root) |
2790 | if (parent[i] == display->root) |
2552 | { |
2791 | { |
2553 | if (oldp != None) |
2792 | if (oldp != None) |
… | |
… | |
2561 | } |
2800 | } |
2562 | |
2801 | |
2563 | n = 0; |
2802 | n = 0; |
2564 | |
2803 | |
2565 | if (pchanged) |
2804 | if (pchanged) |
2566 | { |
|
|
2567 | for (; n < (unsigned int)i; n++) |
2805 | for (; n < (unsigned int)i; n++) |
2568 | { |
2806 | { |
2569 | XGetWindowAttributes (disp, parent[n], &wattr); |
2807 | XGetWindowAttributes (dpy, parent[n], &wattr); |
|
|
2808 | |
2570 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2809 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2571 | { |
2810 | { |
2572 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2811 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2573 | break; |
2812 | break; |
2574 | } |
2813 | } |
2575 | } |
2814 | } |
2576 | } |
|
|
2577 | |
2815 | |
2578 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2816 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2579 | { |
2817 | { |
2580 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
2818 | XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]); |
2581 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2819 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2582 | am_transparent = 0; |
2820 | am_transparent = 0; |
2583 | /* XXX: also turn off Opt_transparent? */ |
2821 | /* XXX: also turn off Opt_transparent? */ |
2584 | } |
2822 | } |
2585 | else |
2823 | else |
2586 | { |
2824 | { |
2587 | #if WAIT_FOR_WM |
|
|
2588 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2589 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2590 | sleep (1); |
|
|
2591 | #endif |
|
|
2592 | for (n = 0; n < (unsigned int)i; n++) |
2825 | for (n = 0; n < (unsigned int)i; n++) |
2593 | { |
2826 | { |
2594 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2827 | XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative); |
2595 | XClearWindow (disp, parent[n]); |
2828 | XClearWindow (dpy, parent[n]); |
2596 | } |
2829 | } |
2597 | |
2830 | |
2598 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2831 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2599 | am_transparent = 1; |
2832 | am_transparent = 1; |
2600 | } |
2833 | } |
2601 | |
2834 | |
2602 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2835 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2603 | parent[i] = None; |
2836 | parent[i] = None; |
2604 | } |
2837 | } |
2605 | |
2838 | |
2606 | if (scrollBar.win) |
2839 | if (scrollBar.win) |
2607 | { |
2840 | { |
2608 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2841 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2609 | scrollBar.setIdle (); |
2842 | scrollBar.setIdle (); |
2610 | scrollbar_show (0); |
2843 | scrollbar_show (0); |
2611 | } |
2844 | } |
2612 | |
2845 | |
2613 | if (am_transparent) |
2846 | if (am_transparent) |
… | |
… | |
2615 | want_refresh = want_full_refresh = 1; |
2848 | want_refresh = want_full_refresh = 1; |
2616 | if (am_pixmap_trans) |
2849 | if (am_pixmap_trans) |
2617 | flush (); |
2850 | flush (); |
2618 | } |
2851 | } |
2619 | |
2852 | |
2620 | return pchanged; |
2853 | // return pchanged; |
2621 | } |
2854 | } |
2622 | #endif |
2855 | #endif |
2623 | |
2856 | |
2624 | /*}}} */ |
2857 | /*}}} */ |
2625 | |
2858 | |
2626 | bool |
2859 | bool |
2627 | rxvt_term::cmd_parse () |
2860 | rxvt_term::cmd_parse () |
2628 | { |
2861 | { |
2629 | bool flag = false; |
2862 | bool flag = false; |
2630 | unicode_t ch = NOCHAR; |
2863 | wchar_t ch = NOCHAR; |
2631 | unsigned char *seq_begin; // remember start of esc-sequence here |
2864 | char *seq_begin; // remember start of esc-sequence here |
2632 | |
2865 | |
2633 | for (;;) |
2866 | for (;;) |
2634 | { |
2867 | { |
2635 | if (ch == NOCHAR) |
2868 | if (ch == NOCHAR) |
2636 | { |
2869 | { |
2637 | seq_begin = cmdbuf_ptr; |
2870 | seq_begin = cmdbuf_ptr; |
2638 | ch = next_char (); |
2871 | ch = next_char (); |
2639 | } |
|
|
2640 | |
2872 | |
2641 | if (ch == NOCHAR) // TODO: improve |
2873 | if (ch == NOCHAR) |
2642 | break; |
2874 | break; |
|
|
2875 | } |
2643 | |
2876 | |
2644 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2877 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2645 | { |
2878 | { |
2646 | if (!seen_input) |
2879 | if (!seen_input) |
2647 | { |
2880 | { |
… | |
… | |
2656 | if (seen_resize && cmd_pid) |
2889 | if (seen_resize && cmd_pid) |
2657 | kill (-cmd_pid, SIGWINCH); |
2890 | kill (-cmd_pid, SIGWINCH); |
2658 | } |
2891 | } |
2659 | |
2892 | |
2660 | /* Read a text string from the input buffer */ |
2893 | /* Read a text string from the input buffer */ |
2661 | unicode_t buf[UBUFSIZ]; |
2894 | wchar_t buf[UBUFSIZ]; |
2662 | bool refreshnow = false; |
2895 | bool refreshnow = false; |
2663 | int nlines = 0; |
2896 | int nlines = 0; |
2664 | unicode_t *str = buf; |
2897 | wchar_t *str = buf; |
2665 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2898 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2666 | |
2899 | |
2667 | for (;;) |
2900 | for (;;) |
2668 | { |
2901 | { |
2669 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2902 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2670 | break; |
2903 | break; |
… | |
… | |
2676 | if (ch == C0_LF) |
2909 | if (ch == C0_LF) |
2677 | nlines++; |
2910 | nlines++; |
2678 | |
2911 | |
2679 | refresh_count++; |
2912 | refresh_count++; |
2680 | |
2913 | |
2681 | if (!(options & Opt_jumpScroll) |
2914 | if (!option (Opt_jumpScroll) |
2682 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2915 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2683 | { |
2916 | { |
2684 | refreshnow = true; |
2917 | refreshnow = true; |
|
|
2918 | refresh_count = 0; |
2685 | ch = NOCHAR; |
2919 | ch = NOCHAR; |
2686 | break; |
2920 | break; |
2687 | } |
2921 | } |
2688 | |
2922 | |
2689 | // scr_add_lines only works for nlines <= nrow - 1. |
2923 | // scr_add_lines only works for nlines <= nrow - 1. |
2690 | if (nlines >= nrow - 1) |
2924 | if (nlines >= nrow - 1) |
2691 | { |
2925 | { |
|
|
2926 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2927 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2692 | scr_add_lines (buf, nlines, str - buf); |
2928 | scr_add_lines (buf, str - buf, nlines); |
|
|
2929 | |
2693 | nlines = 0; |
2930 | nlines = 0; |
2694 | str = buf; |
2931 | str = buf; |
2695 | eol = str + min (ncol, UBUFSIZ); |
2932 | eol = str + min (ncol, UBUFSIZ); |
2696 | } |
2933 | } |
2697 | |
2934 | |
… | |
… | |
2710 | |
2947 | |
2711 | seq_begin = cmdbuf_ptr; |
2948 | seq_begin = cmdbuf_ptr; |
2712 | ch = next_char (); |
2949 | ch = next_char (); |
2713 | } |
2950 | } |
2714 | |
2951 | |
|
|
2952 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2953 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2715 | scr_add_lines (buf, nlines, str - buf); |
2954 | scr_add_lines (buf, str - buf, nlines); |
2716 | |
2955 | |
2717 | /* |
2956 | /* |
2718 | * If there have been a lot of new lines, then update the screen |
2957 | * 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. |
2958 | * 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 |
2959 | * the number of pages between refreshes is refresh_limit, which |
2721 | * is incremented here because we must be doing flat-out scrolling. |
2960 | * is incremented here because we must be doing flat-out scrolling. |
2722 | */ |
2961 | */ |
2723 | if (refreshnow) |
2962 | if (refreshnow) |
2724 | { |
2963 | { |
2725 | if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2964 | if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2726 | refresh_limit++; |
2965 | refresh_limit++; |
2727 | else |
2966 | else |
2728 | { |
2967 | { |
2729 | flag = true; |
2968 | flag = true; |
|
|
2969 | //TODO: due to popular request, implement "skipscroll" option here |
2730 | scr_refresh (refresh_type); |
2970 | scr_refresh (); |
|
|
2971 | want_refresh = 1; |
2731 | } |
2972 | } |
2732 | } |
2973 | } |
2733 | |
2974 | |
2734 | } |
2975 | } |
2735 | else |
2976 | else |
… | |
… | |
2750 | } |
2991 | } |
2751 | |
2992 | |
2752 | return flag; |
2993 | return flag; |
2753 | } |
2994 | } |
2754 | |
2995 | |
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 |
2996 | // read the next character |
2765 | unicode_t |
2997 | wchar_t |
2766 | rxvt_term::next_char () |
2998 | rxvt_term::next_char () NOTHROW |
2767 | { |
2999 | { |
2768 | while (cmdbuf_ptr < cmdbuf_endp) |
3000 | while (cmdbuf_ptr < cmdbuf_endp) |
2769 | { |
3001 | { |
2770 | // assume 7-bit to be ascii ALWAYS |
3002 | // assume 7-bit to be ascii ALWAYS |
2771 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
3003 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2772 | return *cmdbuf_ptr++; |
3004 | return *cmdbuf_ptr++; |
2773 | |
3005 | |
2774 | wchar_t wc; |
3006 | wchar_t wc; |
2775 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
3007 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2776 | |
3008 | |
2777 | if (len == (size_t)-2) |
3009 | if (len == (size_t)-2) |
2778 | { |
3010 | { |
2779 | // the mbstate stores incomplete sequences. didn't know this :/ |
3011 | // the mbstate stores incomplete sequences. didn't know this :/ |
2780 | cmdbuf_ptr = cmdbuf_endp; |
3012 | cmdbuf_ptr = cmdbuf_endp; |
2781 | break; |
3013 | break; |
2782 | } |
3014 | } |
2783 | |
3015 | |
2784 | if (len == (size_t)-1) |
3016 | if (len == (size_t)-1) |
2785 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
3017 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2786 | |
3018 | |
2787 | // assume wchar == unicode |
3019 | // assume wchar == unicode |
2788 | cmdbuf_ptr += len; |
3020 | cmdbuf_ptr += len; |
2789 | return wc & UNICODE_MASK; |
3021 | return wc & UNICODE_MASK; |
2790 | } |
3022 | } |
2791 | |
3023 | |
2792 | return NOCHAR; |
3024 | return NOCHAR; |
2793 | } |
3025 | } |
|
|
3026 | |
|
|
3027 | // read the next octet |
|
|
3028 | uint32_t |
|
|
3029 | rxvt_term::next_octet () NOTHROW |
|
|
3030 | { |
|
|
3031 | return cmdbuf_ptr < cmdbuf_endp |
|
|
3032 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
3033 | : NOCHAR; |
|
|
3034 | } |
|
|
3035 | |
|
|
3036 | static class out_of_input out_of_input; |
2794 | |
3037 | |
2795 | /* rxvt_cmd_getc () - Return next input character */ |
3038 | /* rxvt_cmd_getc () - Return next input character */ |
2796 | /* |
3039 | /* |
2797 | * Return the next input character after first passing any keyboard input |
3040 | * Return the next input character after first passing any keyboard input |
2798 | * to the command. |
3041 | * to the command. |
2799 | */ |
3042 | */ |
2800 | unicode_t |
3043 | wchar_t |
2801 | rxvt_term::cmd_getc () |
3044 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2802 | { |
3045 | { |
2803 | unicode_t c = next_char (); |
3046 | wchar_t c = next_char (); |
2804 | |
3047 | |
2805 | if (c == NOCHAR) |
3048 | if (c == NOCHAR) |
2806 | throw out_of_input; |
3049 | throw out_of_input; |
2807 | |
3050 | |
2808 | return c; |
3051 | return c; |
2809 | } |
3052 | } |
2810 | |
3053 | |
2811 | unicode_t |
3054 | uint32_t |
2812 | rxvt_term::cmd_get8 () |
3055 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2813 | { |
3056 | { |
2814 | unicode_t c = next_octet (); |
3057 | uint32_t c = next_octet (); |
2815 | |
3058 | |
2816 | if (c == NOCHAR) |
3059 | if (c == NOCHAR) |
2817 | throw out_of_input; |
3060 | throw out_of_input; |
2818 | |
3061 | |
2819 | return c; |
3062 | return c; |
… | |
… | |
2919 | case C0_ESC: |
3162 | case C0_ESC: |
2920 | process_escape_seq (); |
3163 | process_escape_seq (); |
2921 | break; |
3164 | break; |
2922 | case C0_ENQ: /* terminal Status */ |
3165 | case C0_ENQ: /* terminal Status */ |
2923 | if (rs[Rs_answerbackstring]) |
3166 | if (rs[Rs_answerbackstring]) |
2924 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
3167 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2925 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2926 | else |
3168 | else |
2927 | tt_write ((unsigned char *)VT100_ANS, |
3169 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2928 | (unsigned int)strlen (VT100_ANS)); |
|
|
2929 | break; |
3170 | break; |
2930 | case C0_BEL: /* bell */ |
3171 | case C0_BEL: /* bell */ |
2931 | scr_bell (); |
3172 | scr_bell (); |
2932 | break; |
3173 | break; |
2933 | case C0_BS: /* backspace */ |
3174 | case C0_BS: /* backspace */ |
… | |
… | |
3057 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3298 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3058 | break; |
3299 | break; |
3059 | case '+': |
3300 | case '+': |
3060 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3301 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3061 | break; |
3302 | break; |
3062 | #if ENABLE_FRILLS |
3303 | #if !ENABLE_MINIMAL |
3063 | case '6': |
3304 | case '6': |
3064 | scr_backindex (); |
3305 | scr_backindex (); |
3065 | break; |
3306 | break; |
3066 | #endif |
3307 | #endif |
3067 | case '7': |
3308 | case '7': |
3068 | scr_cursor (SAVE); |
3309 | scr_cursor (SAVE); |
3069 | break; |
3310 | break; |
3070 | case '8': |
3311 | case '8': |
3071 | scr_cursor (RESTORE); |
3312 | scr_cursor (RESTORE); |
3072 | break; |
3313 | break; |
3073 | #if ENABLE_FRILLS |
3314 | #if !ENABLE_MINIMAL |
3074 | case '9': |
3315 | case '9': |
3075 | scr_forwardindex (); |
3316 | scr_forwardindex (); |
3076 | break; |
3317 | break; |
3077 | #endif |
3318 | #endif |
3078 | case '=': |
3319 | case '=': |
… | |
… | |
3088 | break; |
3329 | break; |
3089 | |
3330 | |
3090 | /* 8.3.87: NEXT LINE */ |
3331 | /* 8.3.87: NEXT LINE */ |
3091 | case C1_NEL: /* ESC E */ |
3332 | case C1_NEL: /* ESC E */ |
3092 | { |
3333 | { |
3093 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3334 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3094 | scr_add_lines (nlcr, 1, 2); |
3335 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3095 | } |
3336 | } |
3096 | break; |
3337 | break; |
3097 | |
3338 | |
3098 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3339 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3099 | case C1_ESA: /* ESC G */ |
3340 | case C1_ESA: /* ESC G */ |
… | |
… | |
3121 | process_dcs_seq (); |
3362 | process_dcs_seq (); |
3122 | break; |
3363 | break; |
3123 | |
3364 | |
3124 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3365 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3125 | case C1_SCI: /* ESC Z */ |
3366 | case C1_SCI: /* ESC Z */ |
3126 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
3367 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3127 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3128 | break; /* steal obsolete ESC [ c */ |
3368 | break; /* steal obsolete ESC [ c */ |
3129 | |
3369 | |
3130 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3370 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3131 | case C1_CSI: /* ESC [ */ |
3371 | case C1_CSI: /* ESC [ */ |
3132 | process_csi_seq (); |
3372 | process_csi_seq (); |
… | |
… | |
3241 | ndef = get_byte_array_bit (csi_defaults, i); |
3481 | ndef = get_byte_array_bit (csi_defaults, i); |
3242 | for (p = 0; p < nargs; p++) |
3482 | for (p = 0; p < nargs; p++) |
3243 | if (arg[p] == -1) |
3483 | if (arg[p] == -1) |
3244 | arg[p] = ndef; |
3484 | arg[p] = ndef; |
3245 | |
3485 | |
3246 | #ifdef DEBUG_CMD |
|
|
3247 | fprintf (stderr, "CSI "); |
|
|
3248 | for (p = 0; p < nargs; p++) |
|
|
3249 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3250 | fprintf (stderr, "%c\n", ch); |
|
|
3251 | #endif |
|
|
3252 | |
|
|
3253 | /* |
3486 | /* |
3254 | * private mode handling |
3487 | * private mode handling |
3255 | */ |
3488 | */ |
3256 | if (priv) |
3489 | if (priv) |
3257 | { |
3490 | { |
3258 | switch (priv) |
3491 | switch (priv) |
3259 | { |
3492 | { |
3260 | case '>': |
3493 | case '>': |
3261 | if (ch == CSI_DA) /* secondary device attributes */ |
3494 | if (ch == CSI_DA) /* secondary device attributes */ |
3262 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3495 | { |
|
|
3496 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3497 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
3498 | // |
|
|
3499 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3500 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3501 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3502 | // |
|
|
3503 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
3504 | } |
3263 | break; |
3505 | break; |
3264 | case '?': |
3506 | case '?': |
3265 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3507 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3266 | process_terminal_mode (ch, priv, nargs, arg); |
3508 | process_terminal_mode (ch, priv, nargs, arg); |
3267 | break; |
3509 | break; |
… | |
… | |
3376 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3618 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3377 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3619 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3378 | break; |
3620 | break; |
3379 | |
3621 | |
3380 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3622 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3381 | tt_write ((const unsigned char *)VT100_ANS, |
3623 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3382 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3383 | break; |
3624 | break; |
3384 | |
3625 | |
3385 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3626 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3386 | process_sgr_mode (nargs, arg); |
3627 | process_sgr_mode (nargs, arg); |
3387 | break; |
3628 | break; |
… | |
… | |
3394 | break; |
3635 | break; |
3395 | case 6: /* CPR requested */ |
3636 | case 6: /* CPR requested */ |
3396 | scr_report_position (); |
3637 | scr_report_position (); |
3397 | break; |
3638 | break; |
3398 | case 7: /* unofficial extension */ |
3639 | case 7: /* unofficial extension */ |
3399 | if (options & Opt_insecure) |
3640 | if (option (Opt_insecure)) |
3400 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3641 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3401 | break; |
3642 | break; |
3402 | case 8: /* unofficial extension */ |
3643 | case 8: /* unofficial extension */ |
3403 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3644 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3404 | break; |
3645 | break; |
… | |
… | |
3471 | break; |
3712 | break; |
3472 | case CSI_75: |
3713 | case CSI_75: |
3473 | scr_cursor (RESTORE); |
3714 | scr_cursor (RESTORE); |
3474 | break; |
3715 | break; |
3475 | |
3716 | |
3476 | #if ENABLE_FRILLS |
3717 | #if !ENABLE_MINIMAL |
3477 | case CSI_74: |
3718 | case CSI_74: |
3478 | process_window_ops (arg, nargs); |
3719 | process_window_ops (arg, nargs); |
3479 | break; |
3720 | break; |
3480 | #endif |
3721 | #endif |
3481 | |
3722 | |
… | |
… | |
3488 | break; |
3729 | break; |
3489 | } |
3730 | } |
3490 | } |
3731 | } |
3491 | /*}}} */ |
3732 | /*}}} */ |
3492 | |
3733 | |
3493 | #if ENABLE_FRILLS |
3734 | #if !ENABLE_MINIMAL |
3494 | /* ARGSUSED */ |
3735 | /* ARGSUSED */ |
3495 | void |
3736 | void |
3496 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3737 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3497 | { |
3738 | { |
3498 | int x, y; |
3739 | int x, y; |
3499 | XWindowAttributes wattr; |
3740 | XWindowAttributes wattr; |
3500 | Window wdummy; |
3741 | Window wdummy; |
3501 | dDisp; |
3742 | |
|
|
3743 | dLocal (Display *, dpy); |
3502 | |
3744 | |
3503 | if (nargs == 0) |
3745 | if (nargs == 0) |
3504 | return; |
3746 | return; |
3505 | |
3747 | |
3506 | switch (args[0]) |
3748 | switch (args[0]) |
3507 | { |
3749 | { |
3508 | /* |
3750 | /* |
3509 | * commands |
3751 | * commands |
3510 | */ |
3752 | */ |
3511 | case 1: /* deiconify window */ |
3753 | case 1: /* deiconify window */ |
3512 | XMapWindow (disp, parent[0]); |
3754 | XMapWindow (dpy, parent[0]); |
3513 | break; |
3755 | break; |
3514 | case 2: /* iconify window */ |
3756 | case 2: /* iconify window */ |
3515 | XIconifyWindow (disp, parent[0], display->screen); |
3757 | XIconifyWindow (dpy, parent[0], display->screen); |
3516 | break; |
3758 | break; |
3517 | case 3: /* set position (pixels) */ |
3759 | case 3: /* set position (pixels) */ |
3518 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3760 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3519 | break; |
3761 | break; |
3520 | case 4: /* set size (pixels) */ |
3762 | case 4: /* set size (pixels) */ |
3521 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3763 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3522 | break; |
3764 | break; |
3523 | case 5: /* raise window */ |
3765 | case 5: /* raise window */ |
3524 | XRaiseWindow (disp, parent[0]); |
3766 | XRaiseWindow (dpy, parent[0]); |
3525 | break; |
3767 | break; |
3526 | case 6: /* lower window */ |
3768 | case 6: /* lower window */ |
3527 | XLowerWindow (disp, parent[0]); |
3769 | XLowerWindow (dpy, parent[0]); |
3528 | break; |
3770 | break; |
3529 | case 7: /* refresh window */ |
3771 | case 7: /* refresh window */ |
3530 | scr_touch (true); |
3772 | scr_touch (true); |
3531 | break; |
3773 | break; |
3532 | case 8: /* set size (chars) */ |
3774 | case 8: /* set size (chars) */ |
… | |
… | |
3539 | if (args[0] >= 24) /* set height (chars) */ |
3781 | if (args[0] >= 24) /* set height (chars) */ |
3540 | set_widthheight ((unsigned int)width, |
3782 | set_widthheight ((unsigned int)width, |
3541 | (unsigned int) (args[1] * fheight)); |
3783 | (unsigned int) (args[1] * fheight)); |
3542 | break; |
3784 | break; |
3543 | |
3785 | |
3544 | |
|
|
3545 | /* |
3786 | /* |
3546 | * reports - some output format copied from XTerm |
3787 | * reports - some output format copied from XTerm |
3547 | */ |
3788 | */ |
3548 | case 11: /* report window state */ |
3789 | case 11: /* report window state */ |
3549 | XGetWindowAttributes (disp, parent[0], &wattr); |
3790 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3550 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3791 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3551 | break; |
3792 | break; |
3552 | case 13: /* report window position */ |
3793 | case 13: /* report window position */ |
3553 | XGetWindowAttributes (disp, parent[0], &wattr); |
3794 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3554 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3795 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3555 | -wattr.border_width, -wattr.border_width, |
3796 | -wattr.border_width, -wattr.border_width, |
3556 | &x, &y, &wdummy); |
3797 | &x, &y, &wdummy); |
3557 | tt_printf ("\033[3;%d;%dt", x, y); |
3798 | tt_printf ("\033[3;%d;%dt", x, y); |
3558 | break; |
3799 | break; |
3559 | case 14: /* report window size (pixels) */ |
3800 | case 14: /* report window size (pixels) */ |
3560 | XGetWindowAttributes (disp, parent[0], &wattr); |
3801 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3561 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3802 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3562 | break; |
3803 | break; |
3563 | case 18: /* report text area size (chars) */ |
3804 | case 18: /* report text area size (chars) */ |
3564 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3805 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3565 | break; |
3806 | break; |
… | |
… | |
3567 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3808 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3568 | break; |
3809 | break; |
3569 | case 20: /* report icon label */ |
3810 | case 20: /* report icon label */ |
3570 | { |
3811 | { |
3571 | char *s; |
3812 | char *s; |
3572 | XGetIconName (disp, parent[0], &s); |
3813 | XGetIconName (dpy, parent[0], &s); |
3573 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3814 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3574 | XFree (s); |
3815 | XFree (s); |
3575 | } |
3816 | } |
3576 | break; |
3817 | break; |
3577 | case 21: /* report window title */ |
3818 | case 21: /* report window title */ |
3578 | { |
3819 | { |
3579 | char *s; |
3820 | char *s; |
3580 | XFetchName (disp, parent[0], &s); |
3821 | XFetchName (dpy, parent[0], &s); |
3581 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3822 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3582 | XFree (s); |
3823 | XFree (s); |
3583 | } |
3824 | } |
3584 | break; |
3825 | break; |
3585 | } |
3826 | } |
3586 | } |
3827 | } |
… | |
… | |
3589 | /*----------------------------------------------------------------------*/ |
3830 | /*----------------------------------------------------------------------*/ |
3590 | /* |
3831 | /* |
3591 | * get input up until STRING TERMINATOR (or BEL) |
3832 | * get input up until STRING TERMINATOR (or BEL) |
3592 | * ends_how is terminator used. returned input must be free()'d |
3833 | * ends_how is terminator used. returned input must be free()'d |
3593 | */ |
3834 | */ |
3594 | unsigned char * |
3835 | char * |
3595 | rxvt_term::get_to_st (unicode_t &ends_how) |
3836 | rxvt_term::get_to_st (unicode_t &ends_how) |
3596 | { |
3837 | { |
3597 | unicode_t ch; |
3838 | unicode_t ch; |
3598 | bool seen_esc = false; |
3839 | bool seen_esc = false; |
3599 | unsigned int n = 0; |
3840 | unsigned int n = 0; |
… | |
… | |
3613 | seen_esc = true; |
3854 | seen_esc = true; |
3614 | continue; |
3855 | continue; |
3615 | } |
3856 | } |
3616 | else if (ch == C0_BEL || ch == CHAR_ST) |
3857 | else if (ch == C0_BEL || ch == CHAR_ST) |
3617 | break; |
3858 | break; |
|
|
3859 | else if (ch == C0_SYN) |
|
|
3860 | ch = cmd_get8 (); |
3618 | else if (ch < 0x20) |
3861 | else if (ch < 0x20) |
3619 | return NULL; /* other control character - exit */ |
3862 | return NULL; /* other control character - exit */ |
3620 | |
3863 | |
3621 | seen_esc = false; |
3864 | seen_esc = false; |
3622 | |
3865 | |
3623 | if (n >= STRING_MAX - 1) |
3866 | if (n >= STRING_MAX - 1) |
3624 | // stop at some sane length |
3867 | // stop at some sane length |
3625 | return NULL; |
3868 | return NULL; |
3626 | |
3869 | |
3627 | if (ch == C0_SYN) |
|
|
3628 | string[n++] = cmd_get8 (); |
|
|
3629 | else |
|
|
3630 | string[n++] = ch; |
3870 | string[n++] = ch; |
3631 | } |
3871 | } |
3632 | |
3872 | |
3633 | string[n++] = '\0'; |
3873 | string[n++] = '\0'; |
3634 | |
3874 | |
3635 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3875 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3636 | |
3876 | |
3637 | return (unsigned char *)rxvt_wcstombs (string); |
3877 | return rxvt_wcstombs (string); |
3638 | } |
3878 | } |
3639 | |
3879 | |
3640 | /*----------------------------------------------------------------------*/ |
3880 | /*----------------------------------------------------------------------*/ |
3641 | /* |
3881 | /* |
3642 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3882 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3643 | */ |
3883 | */ |
3644 | void |
3884 | void |
3645 | rxvt_term::process_dcs_seq () |
3885 | rxvt_term::process_dcs_seq () |
3646 | { |
3886 | { |
3647 | unsigned char *s; |
3887 | char *s; |
3648 | unicode_t eh; |
3888 | unicode_t eh; |
3649 | |
3889 | |
3650 | /* |
3890 | /* |
3651 | * Not handled yet |
3891 | * Not handled yet |
3652 | */ |
3892 | */ |
… | |
… | |
3671 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3911 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3672 | arg = arg * 10 + (ch - '0'); |
3912 | arg = arg * 10 + (ch - '0'); |
3673 | |
3913 | |
3674 | if (ch == ';') |
3914 | if (ch == ';') |
3675 | { |
3915 | { |
3676 | unsigned char *s = get_to_st (eh); |
3916 | char *s = get_to_st (eh); |
3677 | |
3917 | |
3678 | if (s) |
3918 | if (s) |
3679 | { |
3919 | { |
3680 | process_xterm_seq (arg, (char *)s, eh); |
3920 | process_xterm_seq (arg, s, eh); |
3681 | free (s); |
3921 | free (s); |
3682 | } |
3922 | } |
3683 | } |
3923 | } |
3684 | } |
3924 | } |
3685 | |
3925 | |
3686 | void |
3926 | void |
3687 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3927 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3688 | { |
3928 | { |
3689 | if (str[0] == '?' && !str[1]) |
3929 | if (str[0] == '?' && !str[1]) |
3690 | { |
3930 | { |
3691 | unsigned short r, g, b; |
3931 | rgba c; |
3692 | pix_colors_focused[color].get (display, r, g, b); |
3932 | pix_colors_focused[color].get (c); |
|
|
3933 | |
|
|
3934 | #if XFT |
|
|
3935 | if (c.a != rgba::MAX_CC) |
|
|
3936 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3937 | else |
|
|
3938 | #endif |
3693 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3939 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3694 | } |
3940 | } |
3695 | else |
3941 | else |
3696 | set_window_color (color, str); |
3942 | set_window_color (color, str); |
3697 | } |
3943 | } |
3698 | |
3944 | |
3699 | /* |
3945 | /* |
3700 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3946 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3701 | */ |
3947 | */ |
3702 | void |
3948 | void |
3703 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3949 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3704 | { |
3950 | { |
3705 | int changed = 0; |
|
|
3706 | int color; |
3951 | int color; |
3707 | char *buf, *name; |
3952 | char *buf, *name; |
3708 | bool query = str[0] == '?' && !str[1]; |
3953 | bool query = str[0] == '?' && !str[1]; |
3709 | int saveop = op; |
3954 | int saveop = op; |
3710 | dDisp; |
3955 | |
|
|
3956 | dLocal (Display *, dpy); |
3711 | |
3957 | |
3712 | assert (str != NULL); |
3958 | assert (str != NULL); |
|
|
3959 | |
|
|
3960 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3961 | return; |
|
|
3962 | |
3713 | switch (op) |
3963 | switch (op) |
3714 | { |
3964 | { |
3715 | case XTerm_name: |
3965 | case XTerm_name: |
3716 | set_title (str); |
3966 | set_title (str); |
3717 | /* FALLTHROUGH */ |
3967 | /* FALLTHROUGH */ |
… | |
… | |
3731 | unsigned long bytes_after; |
3981 | unsigned long bytes_after; |
3732 | unsigned char *value = 0; |
3982 | unsigned char *value = 0; |
3733 | const char *str = ""; |
3983 | const char *str = ""; |
3734 | |
3984 | |
3735 | if (prop |
3985 | if (prop |
3736 | && XGetWindowProperty (disp, parent[0], |
3986 | && XGetWindowProperty (dpy, parent[0], |
3737 | prop, 0, 1<<16, 0, AnyPropertyType, |
3987 | prop, 0, 1<<16, 0, AnyPropertyType, |
3738 | &actual_type, &actual_format, |
3988 | &actual_type, &actual_format, |
3739 | &nitems, &bytes_after, &value) == Success |
3989 | &nitems, &bytes_after, &value) == Success |
3740 | && actual_type != None |
3990 | && actual_type != None |
3741 | && actual_format == 8) |
3991 | && actual_format == 8) |
3742 | str = (const char *)(value); |
3992 | str = (const char *)(value); |
3743 | |
3993 | |
3744 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3994 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3745 | |
3995 | |
3746 | XFree (value); |
3996 | XFree (value); |
3747 | } |
3997 | } |
3748 | else |
3998 | else |
3749 | { |
3999 | { |
… | |
… | |
3753 | { |
4003 | { |
3754 | *eq = 0; |
4004 | *eq = 0; |
3755 | set_utf8_property (display->atom (str), eq + 1); |
4005 | set_utf8_property (display->atom (str), eq + 1); |
3756 | } |
4006 | } |
3757 | else |
4007 | else |
3758 | XDeleteProperty (disp, parent[0], |
4008 | XDeleteProperty (dpy, parent[0], |
3759 | display->atom (str)); |
4009 | display->atom (str)); |
3760 | } |
4010 | } |
3761 | break; |
4011 | break; |
3762 | |
4012 | |
3763 | case XTerm_Color: |
4013 | case XTerm_Color: |
… | |
… | |
3765 | { |
4015 | { |
3766 | if ((name = strchr (buf, ';')) == NULL) |
4016 | if ((name = strchr (buf, ';')) == NULL) |
3767 | break; |
4017 | break; |
3768 | |
4018 | |
3769 | *name++ = '\0'; |
4019 | *name++ = '\0'; |
3770 | color = atoi (buf); |
4020 | color = atoi (buf) + minCOLOR; |
3771 | |
4021 | |
3772 | if (color < 0 || color >= TOTAL_COLORS) |
4022 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3773 | break; |
4023 | break; |
3774 | |
4024 | |
3775 | if ((buf = strchr (name, ';')) != NULL) |
4025 | if ((buf = strchr (name, ';')) != NULL) |
3776 | *buf++ = '\0'; |
4026 | *buf++ = '\0'; |
3777 | |
4027 | |
3778 | if (name[0] == '?' && !name[1]) |
4028 | process_color_seq (op, color, name, resp); |
3779 | { |
|
|
3780 | unsigned short r, g, b; |
|
|
3781 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3782 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3783 | } |
|
|
3784 | else |
|
|
3785 | set_window_color (color + minCOLOR, name); |
|
|
3786 | } |
4029 | } |
3787 | break; |
4030 | break; |
3788 | case XTerm_Color00: |
4031 | case XTerm_Color00: |
3789 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
4032 | process_color_seq (op, Color_fg, str, resp); |
3790 | break; |
4033 | break; |
3791 | case XTerm_Color01: |
4034 | case XTerm_Color01: |
3792 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
4035 | process_color_seq (op, Color_bg, str, resp); |
3793 | break; |
4036 | break; |
3794 | #ifndef NO_CURSORCOLOR |
4037 | #ifndef NO_CURSORCOLOR |
3795 | case XTerm_Color_cursor: |
4038 | case XTerm_Color_cursor: |
3796 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
4039 | process_color_seq (op, Color_cursor, str, resp); |
3797 | break; |
4040 | break; |
3798 | #endif |
4041 | #endif |
3799 | case XTerm_Color_pointer_fg: |
4042 | case XTerm_Color_pointer_fg: |
3800 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
4043 | process_color_seq (op, Color_pointer_fg, str, resp); |
3801 | break; |
4044 | break; |
3802 | case XTerm_Color_pointer_bg: |
4045 | case XTerm_Color_pointer_bg: |
3803 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
4046 | process_color_seq (op, Color_pointer_bg, str, resp); |
3804 | break; |
4047 | break; |
3805 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
4048 | #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: |
4049 | case XTerm_Color_RV: |
3813 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
4050 | process_color_seq (op, Color_RV, str, resp); |
|
|
4051 | break; |
|
|
4052 | case Rxvt_Color_BD: |
|
|
4053 | case URxvt_Color_BD: |
|
|
4054 | process_color_seq (op, Color_BD, str, resp); |
|
|
4055 | break; |
|
|
4056 | case Rxvt_Color_UL: |
|
|
4057 | case URxvt_Color_UL: |
|
|
4058 | process_color_seq (op, Color_UL, str, resp); |
3814 | break; |
4059 | break; |
3815 | case URxvt_Color_IT: |
4060 | case URxvt_Color_IT: |
3816 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
4061 | process_color_seq (op, Color_IT, str, resp); |
3817 | break; |
4062 | break; |
3818 | #endif |
4063 | #endif |
3819 | #if TRANSPARENT && TINTING |
4064 | #if TRANSPARENT && TINTING |
3820 | case URxvt_Color_tint: |
4065 | case URxvt_Color_tint: |
3821 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
4066 | process_color_seq (op, Color_tint, str, resp); |
|
|
4067 | |
3822 | check_our_parents (); |
4068 | check_our_parents (); |
|
|
4069 | |
3823 | if (am_transparent) |
4070 | if (am_transparent) |
3824 | want_full_refresh = want_refresh = 1; |
4071 | want_full_refresh = want_refresh = 1; |
3825 | break; |
|
|
3826 | #endif |
|
|
3827 | |
4072 | |
|
|
4073 | break; |
|
|
4074 | #endif |
|
|
4075 | |
3828 | case XTerm_Pixmap: |
4076 | case Rxvt_Pixmap: |
|
|
4077 | { |
3829 | if (*str != ';') |
4078 | if (*str != ';') |
3830 | { |
4079 | { |
3831 | #if XPM_BACKGROUND |
4080 | #if XPM_BACKGROUND |
3832 | scale_pixmap (""); /* reset to default scaling */ |
4081 | scale_pixmap (""); /* reset to default scaling */ |
3833 | set_bgPixmap (str); /* change pixmap */ |
4082 | set_bgPixmap (str); /* change pixmap */ |
3834 | #endif |
|
|
3835 | scr_touch (true); |
4083 | scr_touch (true); |
|
|
4084 | #endif |
3836 | } |
4085 | } |
|
|
4086 | |
|
|
4087 | int changed = 0; |
|
|
4088 | |
3837 | while ((str = strchr (str, ';')) != NULL) |
4089 | while ((str = strchr (str, ';')) != NULL) |
3838 | { |
4090 | { |
3839 | str++; |
4091 | str++; |
3840 | #if XPM_BACKGROUND |
4092 | #if XPM_BACKGROUND |
3841 | changed += scale_pixmap (str); |
4093 | changed += scale_pixmap (str); |
3842 | #endif |
4094 | #endif |
3843 | } |
4095 | } |
3844 | |
4096 | |
3845 | if (changed) |
4097 | if (changed) |
3846 | { |
4098 | { |
3847 | #ifdef XPM_BACKGROUND |
4099 | #ifdef XPM_BACKGROUND |
3848 | resize_pixmap (); |
4100 | resize_pixmap (); |
3849 | #endif |
|
|
3850 | scr_touch (true); |
4101 | scr_touch (true); |
|
|
4102 | #endif |
3851 | } |
4103 | } |
|
|
4104 | #if TRANSPARENT && defined(HAVE_AFTERIMAGE) |
|
|
4105 | if (option(Opt_transparent)) |
|
|
4106 | check_our_parents (); |
|
|
4107 | #endif |
|
|
4108 | |
|
|
4109 | } |
3852 | break; |
4110 | break; |
3853 | |
4111 | |
3854 | case XTerm_restoreFG: |
4112 | case Rxvt_restoreFG: |
3855 | set_window_color (Color_fg, str); |
4113 | set_window_color (Color_fg, str); |
3856 | break; |
4114 | break; |
3857 | case XTerm_restoreBG: |
4115 | case Rxvt_restoreBG: |
3858 | set_window_color (Color_bg, str); |
4116 | set_window_color (Color_bg, str); |
3859 | break; |
4117 | break; |
3860 | |
4118 | |
3861 | case XTerm_logfile: |
4119 | case XTerm_logfile: |
3862 | // TODO, when secure mode? |
4120 | // TODO, when secure mode? |
3863 | break; |
4121 | break; |
3864 | |
4122 | |
3865 | #ifdef MENUBAR |
|
|
3866 | case URxvt_Menu: |
|
|
3867 | if (options & Opt_insecure) |
|
|
3868 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3869 | break; |
|
|
3870 | #endif |
|
|
3871 | #if 0 |
4123 | #if 0 |
3872 | case XTerm_dumpscreen: /* no error notices */ |
4124 | case Rxvt_dumpscreen: /* no error notices */ |
3873 | { |
4125 | { |
3874 | int fd; |
4126 | int fd; |
3875 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
4127 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3876 | { |
4128 | { |
3877 | scr_dump (fd); |
4129 | scr_dump (fd); |
… | |
… | |
3888 | case URxvt_italicFont: |
4140 | case URxvt_italicFont: |
3889 | case URxvt_boldItalicFont: |
4141 | case URxvt_boldItalicFont: |
3890 | #endif |
4142 | #endif |
3891 | if (query) |
4143 | if (query) |
3892 | tt_printf ("\33]%d;%-.250s%c", saveop, |
4144 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3893 | (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
4145 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3894 | ? fontset[op - URxvt_font]->fontdesc : "", |
4146 | ? fontset[op - URxvt_font]->fontdesc : "", |
3895 | resp); |
4147 | resp); |
3896 | else |
4148 | else |
3897 | { |
4149 | { |
3898 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
4150 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3901 | allocated.push_back ((void *)res); |
4153 | allocated.push_back ((void *)res); |
3902 | set_fonts (); |
4154 | set_fonts (); |
3903 | } |
4155 | } |
3904 | break; |
4156 | break; |
3905 | |
4157 | |
3906 | #if ENABLE_FRILLS |
4158 | case URxvt_version: |
|
|
4159 | if (query) |
|
|
4160 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
4161 | op, |
|
|
4162 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
4163 | resp); |
|
|
4164 | break; |
|
|
4165 | |
|
|
4166 | #if !ENABLE_MINIMAL |
3907 | case URxvt_locale: |
4167 | case URxvt_locale: |
3908 | if (query) |
4168 | if (query) |
3909 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
4169 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
3910 | else |
4170 | else |
3911 | { |
4171 | { |
3912 | set_locale (str); |
4172 | set_locale (str); |
3913 | pty.set_utf8_mode (enc_utf8); |
4173 | pty->set_utf8_mode (enc_utf8); |
3914 | init_xlocale (); |
4174 | init_xlocale (); |
3915 | } |
4175 | } |
3916 | break; |
4176 | break; |
3917 | |
4177 | |
3918 | case URxvt_view_up: |
4178 | case URxvt_view_up: |
3919 | case URxvt_view_down: |
4179 | case URxvt_view_down: |
|
|
4180 | { |
3920 | int lines = atoi (str); |
4181 | int lines = atoi (str); |
3921 | |
4182 | |
3922 | if (lines) |
4183 | if (lines) |
3923 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
4184 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3924 | else |
4185 | else |
3925 | { |
|
|
3926 | scr_erase_savelines (); |
4186 | scr_erase_savelines (); |
3927 | } |
4187 | } |
3928 | |
4188 | |
|
|
4189 | break; |
|
|
4190 | #endif |
|
|
4191 | |
|
|
4192 | #if ENABLE_PERL |
|
|
4193 | case URxvt_perl: |
|
|
4194 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
|
|
4195 | ; // no responses yet |
3929 | break; |
4196 | break; |
3930 | #endif |
4197 | #endif |
3931 | } |
4198 | } |
3932 | } |
4199 | } |
3933 | /*----------------------------------------------------------------------*/ |
4200 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3964 | return state; |
4231 | return state; |
3965 | } |
4232 | } |
3966 | |
4233 | |
3967 | /* we're not using priv _yet_ */ |
4234 | /* we're not using priv _yet_ */ |
3968 | void |
4235 | void |
3969 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4236 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3970 | { |
4237 | { |
3971 | unsigned int i, j; |
4238 | unsigned int i, j; |
3972 | int state; |
4239 | int state; |
3973 | |
4240 | |
3974 | static const struct |
4241 | static const struct |
… | |
… | |
3985 | { 5, PrivMode_rVideo }, |
4252 | { 5, PrivMode_rVideo }, |
3986 | { 6, PrivMode_relOrigin }, |
4253 | { 6, PrivMode_relOrigin }, |
3987 | { 7, PrivMode_Autowrap }, |
4254 | { 7, PrivMode_Autowrap }, |
3988 | // 8, bi-directional support mode |
4255 | // 8, bi-directional support mode |
3989 | { 9, PrivMode_MouseX10 }, |
4256 | { 9, PrivMode_MouseX10 }, |
3990 | #ifdef menuBar_esc |
|
|
3991 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3992 | #endif |
|
|
3993 | // 18, 19 printing-related |
4257 | // 18, 19 printing-related |
3994 | { 25, PrivMode_VisibleCursor }, |
4258 | { 25, PrivMode_VisibleCursor }, |
3995 | #ifdef scrollBar_esc |
4259 | #ifdef scrollBar_esc |
3996 | { scrollBar_esc, PrivMode_scrollBar }, |
4260 | { scrollBar_esc, PrivMode_scrollBar }, |
3997 | #endif |
4261 | #endif |
… | |
… | |
4042 | } |
4306 | } |
4043 | |
4307 | |
4044 | /* extra handling for values with state unkept */ |
4308 | /* extra handling for values with state unkept */ |
4045 | switch (arg[i]) |
4309 | switch (arg[i]) |
4046 | { |
4310 | { |
|
|
4311 | #if ENABLE_STYLES |
|
|
4312 | case 1021: |
|
|
4313 | set_option (Opt_intensityStyles, mode); |
|
|
4314 | |
|
|
4315 | scr_touch (true); |
|
|
4316 | break; |
|
|
4317 | #endif |
4047 | case 1048: /* alternative cursor save */ |
4318 | case 1048: /* alternative cursor save */ |
4048 | case 1049: |
4319 | case 1049: |
4049 | if (options & Opt_secondaryScreen) |
4320 | if (option (Opt_secondaryScreen)) |
4050 | if (mode == 0) |
4321 | if (mode == 0) |
4051 | scr_cursor (RESTORE); |
4322 | scr_cursor (RESTORE); |
4052 | else if (mode == 1) |
4323 | else if (mode == 1) |
4053 | scr_cursor (SAVE); |
4324 | scr_cursor (SAVE); |
4054 | break; |
4325 | break; |
… | |
… | |
4069 | case 3: /* 80/132 */ |
4340 | case 3: /* 80/132 */ |
4070 | if (priv_modes & PrivMode_132OK) |
4341 | if (priv_modes & PrivMode_132OK) |
4071 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4342 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4072 | break; |
4343 | break; |
4073 | case 4: /* smooth scrolling */ |
4344 | case 4: /* smooth scrolling */ |
4074 | if (state) |
|
|
4075 | options &= ~Opt_jumpScroll; |
|
|
4076 | else |
|
|
4077 | options |= Opt_jumpScroll; |
4345 | set_option (Opt_jumpScroll, !state); |
4078 | break; |
4346 | break; |
4079 | case 5: /* reverse video */ |
4347 | case 5: /* reverse video */ |
4080 | scr_rvideo_mode (state); |
4348 | scr_rvideo_mode (state); |
4081 | break; |
4349 | break; |
4082 | case 6: /* relative/absolute origins */ |
4350 | case 6: /* relative/absolute origins */ |
… | |
… | |
4088 | /* case 8: - auto repeat, can't do on a per window basis */ |
4356 | /* case 8: - auto repeat, can't do on a per window basis */ |
4089 | case 9: /* X10 mouse reporting */ |
4357 | case 9: /* X10 mouse reporting */ |
4090 | if (state) /* orthogonal */ |
4358 | if (state) /* orthogonal */ |
4091 | priv_modes &= ~PrivMode_MouseX11; |
4359 | priv_modes &= ~PrivMode_MouseX11; |
4092 | break; |
4360 | break; |
4093 | #ifdef menuBar_esc |
|
|
4094 | case menuBar_esc: |
|
|
4095 | #ifdef MENUBAR |
|
|
4096 | map_menuBar (state); |
|
|
4097 | #endif |
|
|
4098 | break; |
|
|
4099 | #endif |
|
|
4100 | #ifdef scrollBar_esc |
4361 | #ifdef scrollBar_esc |
4101 | case scrollBar_esc: |
4362 | case scrollBar_esc: |
4102 | if (scrollbar_mapping (state)) |
4363 | if (scrollbar_mapping (state)) |
4103 | { |
4364 | { |
4104 | resize_all_windows (0, 0, 0); |
4365 | resize_all_windows (0, 0, 0); |
… | |
… | |
4123 | #if 0 |
4384 | #if 0 |
4124 | case 1001: |
4385 | case 1001: |
4125 | break; /* X11 mouse highlighting */ |
4386 | break; /* X11 mouse highlighting */ |
4126 | #endif |
4387 | #endif |
4127 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4388 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4128 | if (state) |
|
|
4129 | options &= ~Opt_scrollTtyOutput; |
|
|
4130 | else |
|
|
4131 | options |= Opt_scrollTtyOutput; |
4389 | set_option (Opt_scrollTtyOutput, !state); |
4132 | break; |
4390 | break; |
4133 | case 1011: /* scroll to bottom on key press */ |
4391 | case 1011: /* scroll to bottom on key press */ |
4134 | if (state) |
|
|
4135 | options |= Opt_scrollTtyKeypress; |
4392 | set_option (Opt_scrollTtyKeypress, state); |
4136 | else |
|
|
4137 | options &= ~Opt_scrollTtyKeypress; |
|
|
4138 | break; |
4393 | break; |
4139 | case 1047: /* secondary screen w/ clearing last */ |
4394 | case 1047: /* secondary screen w/ clearing last */ |
4140 | if (options & Opt_secondaryScreen) |
4395 | if (option (Opt_secondaryScreen)) |
4141 | if (current_screen != PRIMARY) |
4396 | if (current_screen != PRIMARY) |
4142 | scr_erase_screen (2); |
4397 | scr_erase_screen (2); |
4143 | scr_change_screen (state); |
4398 | scr_change_screen (state); |
4144 | break; |
4399 | break; |
4145 | case 1049: /* secondary screen w/ clearing first */ |
4400 | case 1049: /* secondary screen w/ clearing first */ |
4146 | scr_change_screen (state); |
4401 | scr_change_screen (state); |
4147 | if (options & Opt_secondaryScreen) |
4402 | if (option (Opt_secondaryScreen)) |
4148 | if (current_screen != PRIMARY) |
4403 | if (current_screen != PRIMARY) |
4149 | scr_erase_screen (2); |
4404 | scr_erase_screen (2); |
4150 | break; |
4405 | break; |
4151 | default: |
4406 | default: |
4152 | break; |
4407 | break; |
… | |
… | |
4280 | scr_color (Color_bg, Color_bg); |
4535 | scr_color (Color_bg, Color_bg); |
4281 | break; |
4536 | break; |
4282 | |
4537 | |
4283 | //case 50: // not variable spacing |
4538 | //case 50: // not variable spacing |
4284 | |
4539 | |
4285 | #ifndef NO_BRIGHTCOLOR |
4540 | #if !ENABLE_MINIMAL |
4286 | case 90: |
4541 | case 90: |
4287 | case 91: /* set bright fg color */ |
4542 | case 91: /* set bright fg color */ |
4288 | case 92: |
4543 | case 92: |
4289 | case 93: |
4544 | case 93: |
4290 | case 94: |
4545 | case 94: |
… | |
… | |
4302 | case 106: |
4557 | case 106: |
4303 | case 107: |
4558 | case 107: |
4304 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4559 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4305 | break; |
4560 | break; |
4306 | #endif |
4561 | #endif |
4307 | |
|
|
4308 | } |
4562 | } |
4309 | } |
4563 | } |
4310 | } |
4564 | } |
4311 | /*}}} */ |
4565 | /*}}} */ |
4312 | |
4566 | |
… | |
… | |
4336 | */ |
4590 | */ |
4337 | void |
4591 | void |
4338 | rxvt_term::tt_printf (const char *fmt,...) |
4592 | rxvt_term::tt_printf (const char *fmt,...) |
4339 | { |
4593 | { |
4340 | va_list arg_ptr; |
4594 | va_list arg_ptr; |
4341 | unsigned char buf[256]; |
4595 | char buf[256]; |
4342 | |
4596 | |
4343 | va_start (arg_ptr, fmt); |
4597 | va_start (arg_ptr, fmt); |
4344 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4598 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4345 | va_end (arg_ptr); |
4599 | va_end (arg_ptr); |
4346 | tt_write (buf, strlen (buf)); |
4600 | tt_write (buf, strlen (buf)); |
… | |
… | |
4351 | * or generated by us in response to a query ESC sequence. |
4605 | * or generated by us in response to a query ESC sequence. |
4352 | */ |
4606 | */ |
4353 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4607 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4354 | |
4608 | |
4355 | void |
4609 | void |
4356 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4610 | rxvt_term::tt_write (const char *data, unsigned int len) |
4357 | { |
4611 | { |
|
|
4612 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4613 | return; |
|
|
4614 | |
|
|
4615 | if (pty->pty < 0) |
|
|
4616 | return; |
|
|
4617 | |
4358 | if (v_buflen == 0) |
4618 | if (v_buflen == 0) |
4359 | { |
4619 | { |
4360 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4620 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4361 | |
4621 | |
4362 | if ((unsigned int)written == len) |
4622 | if ((unsigned int)written == len) |
4363 | return; |
4623 | return; |
4364 | |
4624 | |
4365 | data += written; |
4625 | data += written; |
4366 | len -= written; |
4626 | len -= written; |
4367 | } |
4627 | } |
4368 | |
4628 | |
4369 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4629 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4370 | |
4630 | |
4371 | memcpy (v_buffer + v_buflen, data, len); |
4631 | memcpy (v_buffer + v_buflen, data, len); |
4372 | v_buflen += len; |
4632 | v_buflen += len; |
4373 | |
4633 | |
4374 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4634 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4375 | } |
4635 | } |
4376 | |
4636 | |
4377 | void rxvt_term::pty_write () |
4637 | void rxvt_term::pty_write () |
4378 | { |
4638 | { |
4379 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4639 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4380 | |
4640 | |
4381 | if (written > 0) |
4641 | if (written > 0) |
4382 | { |
4642 | { |
4383 | v_buflen -= written; |
4643 | v_buflen -= written; |
4384 | |
4644 | |