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 | { |
… | |
… | |
497 | # endif |
519 | # endif |
498 | return; |
520 | return; |
499 | } |
521 | } |
500 | else |
522 | else |
501 | { |
523 | { |
502 | # if ENABLE_OVERLAY |
524 | # if ISO_14755 |
503 | scr_overlay_off (); |
525 | scr_overlay_off (); |
504 | # endif |
526 | # endif |
505 | iso14755buf = 0; |
527 | iso14755buf = 0; |
506 | } |
528 | } |
507 | } |
529 | } |
508 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
530 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
509 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
531 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
510 | if (!(iso14755buf & ISO_14755_STARTED)) |
532 | if (!(iso14755buf & ISO_14755_STARTED)) |
511 | { |
533 | { |
512 | iso14755buf |= ISO_14755_STARTED; |
534 | iso14755buf |= ISO_14755_STARTED; |
513 | # if ENABLE_OVERLAY |
535 | # if ISO_14755 |
514 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
536 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
515 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
537 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
516 | # endif |
538 | # endif |
517 | } |
539 | } |
518 | #endif |
540 | #endif |
519 | |
541 | |
520 | #ifdef PRINTPIPE |
542 | #ifdef PRINTPIPE |
521 | if (keysym == XK_Print) |
543 | if (keysym == XK_Print) |
522 | { |
544 | { |
523 | scr_printscreen (ctrl | shft); |
545 | scr_printscreen (ctrl | shft); |
524 | return; |
546 | return; |
… | |
… | |
706 | |
728 | |
707 | case XK_Find: |
729 | case XK_Find: |
708 | strcpy (kbuf, "\033[1~"); |
730 | strcpy (kbuf, "\033[1~"); |
709 | break; |
731 | break; |
710 | |
732 | |
711 | #ifdef XK_KP_End |
733 | #ifdef XK_KP_Insert |
712 | case XK_KP_Insert: |
734 | case XK_KP_Insert: |
713 | /* allow shift to override */ |
735 | /* allow shift to override */ |
714 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
736 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
715 | { |
737 | { |
716 | strcpy (kbuf, "\033Op"); |
738 | strcpy (kbuf, "\033Op"); |
… | |
… | |
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 ISO_14755 |
|
|
940 | scr_overlay_off (); |
|
|
941 | # endif |
|
|
942 | # if ISO_14755 |
|
|
943 | // iso14755 part 5.2 handling: release time |
|
|
944 | // first: controls |
|
|
945 | if ((ev.state & ControlMask) |
|
|
946 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
947 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
948 | { |
|
|
949 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
950 | commit_iso14755 (); |
|
|
951 | |
|
|
952 | return; |
|
|
953 | } |
|
|
954 | |
|
|
955 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
956 | if (i[0] == keysym) |
|
|
957 | { |
|
|
958 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
959 | commit_iso14755 (); |
|
|
960 | |
|
|
961 | return; |
|
|
962 | } |
|
|
963 | |
|
|
964 | scr_bell (); |
|
|
965 | # endif |
|
|
966 | iso14755buf = 0; |
|
|
967 | |
|
|
968 | return; |
|
|
969 | } |
|
|
970 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
971 | { |
|
|
972 | # if ISO_14755 |
|
|
973 | scr_overlay_off (); |
|
|
974 | # endif |
|
|
975 | if (iso14755buf & ISO_14755_51) |
|
|
976 | commit_iso14755 (); |
|
|
977 | #if ISO_14755 |
|
|
978 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
979 | { |
|
|
980 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
981 | |
|
|
982 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
983 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
984 | } |
|
|
985 | # endif |
|
|
986 | else |
|
|
987 | iso14755buf = 0; |
|
|
988 | } |
|
|
989 | #endif |
|
|
990 | |
|
|
991 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
992 | return; |
|
|
993 | |
|
|
994 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
995 | if (!(ev.state & ControlMask)) |
|
|
996 | slip_wheel_ev.stop (); |
|
|
997 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
998 | mouse_slip_wheel_speed = 0; |
|
|
999 | #endif |
|
|
1000 | } |
|
|
1001 | |
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; |
… | |
… | |
946 | void |
1035 | void |
947 | rxvt_term::flush () |
1036 | rxvt_term::flush () |
948 | { |
1037 | { |
949 | flush_ev.stop (); |
1038 | flush_ev.stop (); |
950 | |
1039 | |
951 | #ifdef TRANSPARENT |
1040 | #ifdef ENABLE_TRANSPARENCY |
952 | if (want_full_refresh) |
1041 | if (want_full_refresh) |
953 | { |
1042 | { |
954 | want_full_refresh = 0; |
1043 | want_full_refresh = 0; |
955 | scr_clear (); |
1044 | scr_clear (); |
956 | scr_touch (false); |
1045 | scr_touch (false); |
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; |
|
|
991 | refresh_count = 0; |
1115 | refresh_count = 0; |
992 | flush (); |
1116 | flush (); |
993 | } |
1117 | } |
994 | |
1118 | |
995 | #ifdef CURSOR_BLINK |
1119 | #ifdef CURSOR_BLINK |
… | |
… | |
997 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1121 | rxvt_term::cursor_blink_cb (time_watcher &w) |
998 | { |
1122 | { |
999 | hidden_cursor = !hidden_cursor; |
1123 | hidden_cursor = !hidden_cursor; |
1000 | want_refresh = 1; |
1124 | want_refresh = 1; |
1001 | |
1125 | |
1002 | w.start (w.at + BLINK_INTERVAL); |
1126 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1003 | } |
1127 | } |
1004 | #endif |
1128 | #endif |
1005 | |
1129 | |
1006 | #ifdef TEXT_BLINK |
1130 | #ifdef TEXT_BLINK |
1007 | void |
1131 | void |
… | |
… | |
1021 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1145 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1022 | { |
1146 | { |
1023 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1147 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1024 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1148 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1025 | { |
1149 | { |
1026 | refresh_type |= SMOOTH_REFRESH; |
|
|
1027 | want_refresh = 1; |
1150 | want_refresh = 1; |
1028 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1151 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1029 | } |
1152 | } |
1030 | } |
1153 | } |
1031 | #endif |
1154 | #endif |
… | |
… | |
1035 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1158 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1036 | { |
1159 | { |
1037 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1160 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1038 | { |
1161 | { |
1039 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1162 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1040 | refresh_type |= SMOOTH_REFRESH; |
|
|
1041 | want_refresh = 1; |
1163 | want_refresh = 1; |
1042 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1164 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1043 | } |
1165 | } |
1044 | } |
1166 | } |
1045 | #endif |
1167 | #endif |
… | |
… | |
1050 | { |
1172 | { |
1051 | if (mouse_slip_wheel_speed == 0 |
1173 | if (mouse_slip_wheel_speed == 0 |
1052 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1174 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1053 | : scr_page (UP, mouse_slip_wheel_speed)) |
1175 | : scr_page (UP, mouse_slip_wheel_speed)) |
1054 | { |
1176 | { |
1055 | if (view_start == nsaved || |
1177 | if (view_start == top_row || view_start == 0) |
1056 | view_start == 0) |
|
|
1057 | mouse_slip_wheel_speed = 0; |
1178 | mouse_slip_wheel_speed = 0; |
1058 | |
1179 | |
1059 | refresh_type |= SMOOTH_REFRESH; |
|
|
1060 | want_refresh = 1; |
1180 | want_refresh = 1; |
1061 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1181 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1062 | } |
1182 | } |
1063 | } |
1183 | } |
1064 | #endif |
1184 | #endif |
1065 | |
1185 | |
|
|
1186 | #if LINUX_YIELD_HACK |
|
|
1187 | static struct event_handler |
|
|
1188 | { |
|
|
1189 | check_watcher yield_ev; |
|
|
1190 | |
|
|
1191 | void yield_cb (check_watcher &w) |
|
|
1192 | { |
|
|
1193 | // this should really be sched_yield(), but the linux guys thought |
|
|
1194 | // that giving a process calling sched_yield () less cpu time than |
|
|
1195 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1196 | // allowed by the sus... as is returning ENOSYS. |
|
|
1197 | |
|
|
1198 | struct timespec ts = { 0, 0 }; |
|
|
1199 | nanosleep (&ts, 0); |
|
|
1200 | |
|
|
1201 | w.stop (); |
|
|
1202 | } |
|
|
1203 | |
|
|
1204 | event_handler () |
|
|
1205 | : yield_ev (this, &event_handler::yield_cb) |
|
|
1206 | { |
|
|
1207 | } |
|
|
1208 | } event_handler; |
|
|
1209 | #endif |
|
|
1210 | |
1066 | bool |
1211 | bool |
1067 | rxvt_term::pty_fill () |
1212 | rxvt_term::pty_fill () |
1068 | { |
1213 | { |
1069 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1214 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1070 | |
1215 | |
1071 | if (CBUFSIZ == n) |
1216 | if (CBUFSIZ == n) |
1072 | { |
1217 | { |
1073 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1218 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1074 | n = 0; |
1219 | n = 0; |
1075 | } |
1220 | } |
1076 | |
1221 | |
1077 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1222 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1078 | cmdbuf_ptr = cmdbuf_base; |
1223 | cmdbuf_ptr = cmdbuf_base; |
1079 | cmdbuf_endp = cmdbuf_ptr + n; |
1224 | cmdbuf_endp = cmdbuf_ptr + n; |
1080 | |
1225 | |
1081 | n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1226 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1082 | |
1227 | |
1083 | if (n > 0) |
1228 | if (r > 0) |
1084 | { |
1229 | { |
1085 | cmdbuf_endp += n; |
1230 | cmdbuf_endp += r; |
1086 | return true; |
1231 | return true; |
1087 | } |
1232 | } |
1088 | else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) |
1233 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
|
|
1234 | { |
|
|
1235 | #if LINUX_YIELD_HACK |
|
|
1236 | if (display->is_local) |
|
|
1237 | event_handler.yield_ev.start (); |
|
|
1238 | #endif |
|
|
1239 | } |
|
|
1240 | else |
1089 | { |
1241 | { |
1090 | pty_ev.stop (); |
1242 | pty_ev.stop (); |
1091 | |
1243 | |
1092 | if (!(options & Opt_hold)) |
1244 | if (!option (Opt_hold)) |
1093 | destroy (); |
1245 | destroy (); |
1094 | } |
1246 | } |
1095 | |
1247 | |
1096 | return false; |
1248 | return false; |
1097 | } |
1249 | } |
1098 | |
1250 | |
1099 | void |
1251 | void |
1100 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1252 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1101 | { |
1253 | { |
1102 | SET_R (this); |
1254 | make_current (); |
1103 | SET_LOCALE (locale); |
|
|
1104 | |
1255 | |
1105 | if (revents & EVENT_READ) |
1256 | if (revents & EVENT_READ) |
1106 | // loop, but don't allow a single term to monopolize us |
1257 | // loop, but don't allow a single term to monopolize us |
1107 | while (pty_fill ()) |
1258 | while (pty_fill ()) |
1108 | if (cmd_parse ()) |
1259 | if (cmd_parse ()) |
… | |
… | |
1113 | } |
1264 | } |
1114 | |
1265 | |
1115 | void |
1266 | void |
1116 | rxvt_term::pointer_unblank () |
1267 | rxvt_term::pointer_unblank () |
1117 | { |
1268 | { |
1118 | XDefineCursor (display->display, vt, TermWin_cursor); |
1269 | XDefineCursor (dpy, vt, TermWin_cursor); |
1119 | recolour_cursor (); |
1270 | recolour_cursor (); |
1120 | |
1271 | |
1121 | #ifdef POINTER_BLANK |
1272 | #ifdef POINTER_BLANK |
1122 | hidden_pointer = 0; |
1273 | hidden_pointer = 0; |
1123 | |
1274 | |
1124 | if (options & Opt_pointerBlank) |
1275 | if (option (Opt_pointerBlank)) |
1125 | pointer_ev.start (NOW + pointerBlankDelay); |
1276 | pointer_ev.start (NOW + pointerBlankDelay); |
1126 | #endif |
1277 | #endif |
1127 | } |
1278 | } |
1128 | |
1279 | |
1129 | #ifdef POINTER_BLANK |
1280 | #ifdef POINTER_BLANK |
1130 | void |
1281 | void |
1131 | rxvt_term::pointer_blank () |
1282 | rxvt_term::pointer_blank () |
1132 | { |
1283 | { |
1133 | if (! (options & Opt_pointerBlank)) |
1284 | if (!option (Opt_pointerBlank)) |
1134 | return; |
1285 | return; |
1135 | |
1286 | |
1136 | XDefineCursor (display->display, vt, display->blank_cursor); |
1287 | XDefineCursor (dpy, vt, display->blank_cursor); |
1137 | XFlush (display->display); |
1288 | XFlush (dpy); |
1138 | |
1289 | |
1139 | hidden_pointer = 1; |
1290 | hidden_pointer = 1; |
1140 | } |
1291 | } |
1141 | |
1292 | |
1142 | void |
1293 | void |
1143 | rxvt_term::pointer_cb (time_watcher &w) |
1294 | rxvt_term::pointer_cb (time_watcher &w) |
1144 | { |
1295 | { |
1145 | SET_R (this); |
1296 | make_current (); |
1146 | SET_LOCALE (locale); |
|
|
1147 | |
1297 | |
1148 | pointer_blank (); |
1298 | pointer_blank (); |
1149 | } |
1299 | } |
1150 | #endif |
1300 | #endif |
1151 | |
1301 | |
… | |
… | |
1216 | (32 + button_number + key_state), |
1366 | (32 + button_number + key_state), |
1217 | (32 + x + 1), |
1367 | (32 + x + 1), |
1218 | (32 + y + 1)); |
1368 | (32 + y + 1)); |
1219 | } |
1369 | } |
1220 | |
1370 | |
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 */ |
1371 | /*{{{ process an X event */ |
1232 | void |
1372 | void |
1233 | rxvt_term::x_cb (XEvent &ev) |
1373 | rxvt_term::x_cb (XEvent &ev) |
1234 | { |
1374 | { |
1235 | dDisp; |
1375 | make_current (); |
1236 | |
1376 | |
1237 | SET_R (this); |
1377 | dLocal (Display *, dpy); |
1238 | SET_LOCALE (locale); |
|
|
1239 | |
1378 | |
1240 | #if defined(CURSOR_BLINK) |
1379 | if (ev.xany.window == vt |
1241 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1380 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1242 | { |
1381 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1243 | if (hidden_cursor) |
1382 | return; |
1244 | { |
|
|
1245 | hidden_cursor = 0; |
|
|
1246 | want_refresh = 1; |
|
|
1247 | } |
|
|
1248 | |
1383 | |
1249 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1384 | // 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; |
1385 | Window unused_root, unused_child; |
1268 | int unused_root_x, unused_root_y; |
1386 | int unused_root_x, unused_root_y; |
1269 | unsigned int unused_mask; |
1387 | unsigned int unused_mask; |
1270 | |
1388 | |
1271 | switch (ev.type) |
1389 | switch (ev.type) |
1272 | { |
1390 | { |
1273 | case KeyPress: |
1391 | case KeyPress: |
1274 | #if ISO_14755 |
1392 | key_press (ev.xkey); |
1275 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1276 | #endif |
|
|
1277 | lookup_key (ev.xkey); |
|
|
1278 | |
|
|
1279 | break; |
1393 | break; |
1280 | |
1394 | |
1281 | case KeyRelease: |
1395 | case KeyRelease: |
1282 | { |
1396 | 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; |
1397 | break; |
1350 | } |
|
|
1351 | |
1398 | |
1352 | case ButtonPress: |
1399 | case ButtonPress: |
1353 | button_press (ev.xbutton); |
1400 | button_press (ev.xbutton); |
1354 | break; |
1401 | break; |
1355 | |
1402 | |
… | |
… | |
1357 | button_release (ev.xbutton); |
1404 | button_release (ev.xbutton); |
1358 | break; |
1405 | break; |
1359 | |
1406 | |
1360 | case ClientMessage: |
1407 | case ClientMessage: |
1361 | if (ev.xclient.format == 32 |
1408 | if (ev.xclient.format == 32 |
1362 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1409 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1363 | { |
1410 | { |
|
|
1411 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1412 | { |
|
|
1413 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1414 | { |
1364 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1415 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1416 | { |
|
|
1417 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1365 | destroy (); |
1418 | destroy (); |
|
|
1419 | } |
1366 | #if ENABLE_EWMH |
1420 | #if ENABLE_EWMH |
1367 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1421 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1368 | XSendEvent (disp, ev.xclient.window = display->root, |
1422 | XSendEvent (dpy, ev.xclient.window = display->root, |
1369 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1423 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1370 | &ev); |
1424 | &ev); |
|
|
1425 | #endif |
|
|
1426 | } |
|
|
1427 | } |
|
|
1428 | #if ENABLE_XEMBED |
|
|
1429 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1430 | { |
|
|
1431 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1432 | focus_in (); |
|
|
1433 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1434 | focus_out (); |
|
|
1435 | } |
1371 | #endif |
1436 | #endif |
1372 | } |
1437 | } |
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; |
|
|
1409 | |
|
|
1410 | case MappingNotify: |
|
|
1411 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1412 | break; |
1438 | break; |
1413 | |
1439 | |
1414 | /* |
1440 | /* |
1415 | * XXX: this is not the _current_ arrangement |
1441 | * XXX: this is not the _current_ arrangement |
1416 | * Here's my conclusion: |
1442 | * Here's my conclusion: |
… | |
… | |
1435 | break; |
1461 | break; |
1436 | } |
1462 | } |
1437 | break; |
1463 | break; |
1438 | |
1464 | |
1439 | case FocusIn: |
1465 | case FocusIn: |
|
|
1466 | if (ev.xfocus.detail != NotifyInferior |
|
|
1467 | && ev.xfocus.detail != NotifyPointer |
|
|
1468 | && ev.xfocus.mode != NotifyGrab) |
1440 | focus_in (); |
1469 | focus_in (); |
1441 | break; |
1470 | break; |
1442 | |
1471 | |
1443 | case FocusOut: |
1472 | case FocusOut: |
|
|
1473 | if (ev.xfocus.detail != NotifyInferior |
|
|
1474 | && ev.xfocus.detail != NotifyPointer |
|
|
1475 | && ev.xfocus.mode != NotifyGrab) |
1444 | focus_out (); |
1476 | focus_out (); |
1445 | break; |
1477 | break; |
1446 | |
1478 | |
1447 | case ConfigureNotify: |
1479 | case ConfigureNotify: |
1448 | if (ev.xconfigure.window == parent[0]) |
1480 | if (ev.xconfigure.window == parent[0]) |
1449 | { |
1481 | { |
1450 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1482 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1451 | ; |
1483 | ; |
1452 | |
1484 | |
1453 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1485 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1454 | { |
1486 | { |
1455 | seen_resize = 1; |
1487 | seen_resize = 1; |
1456 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1488 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
|
|
1489 | #ifdef XPM_BACKGROUND |
|
|
1490 | /* TODO: replace with update_pixmap() that should unify transparency and bg image handling ! */ |
|
|
1491 | if (!option (Opt_transparent) && bgPixmap.window_size_sensitive ()) |
|
|
1492 | { |
|
|
1493 | bgPixmap.render (); |
|
|
1494 | scr_touch (true); |
|
|
1495 | } |
|
|
1496 | #endif |
1457 | } |
1497 | } |
1458 | |
1498 | |
1459 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1499 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1500 | |
|
|
1501 | #ifdef ENABLE_TRANSPARENCY |
1460 | if (options & Opt_transparent) |
1502 | if (option (Opt_transparent)) |
1461 | check_our_parents (); |
1503 | bgPixmap.render (); |
1462 | #endif |
1504 | #endif |
1463 | } |
1505 | } |
1464 | break; |
1506 | break; |
1465 | |
1507 | |
1466 | case PropertyNotify: |
1508 | case PropertyNotify: |
|
|
1509 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1467 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1510 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1468 | && ev.xproperty.state == PropertyNewValue) |
1511 | && ev.xproperty.state == PropertyNewValue) |
1469 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1512 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1470 | |
1513 | |
1471 | break; |
1514 | break; |
1472 | |
1515 | |
1473 | case SelectionClear: |
1516 | case SelectionClear: |
1474 | selection_clear (); |
1517 | selection_clear (); |
… | |
… | |
1479 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1522 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1480 | break; |
1523 | break; |
1481 | |
1524 | |
1482 | case SelectionRequest: |
1525 | case SelectionRequest: |
1483 | selection_send (ev.xselectionrequest); |
1526 | selection_send (ev.xselectionrequest); |
|
|
1527 | break; |
|
|
1528 | |
|
|
1529 | case MapNotify: |
|
|
1530 | mapped = 1; |
|
|
1531 | #ifdef TEXT_BLINK |
|
|
1532 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1533 | #endif |
|
|
1534 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1484 | break; |
1535 | break; |
1485 | |
1536 | |
1486 | case UnmapNotify: |
1537 | case UnmapNotify: |
1487 | mapped = 0; |
1538 | mapped = 0; |
1488 | #ifdef TEXT_BLINK |
1539 | #ifdef TEXT_BLINK |
1489 | text_blink_ev.stop (); |
1540 | text_blink_ev.stop (); |
1490 | #endif |
1541 | #endif |
|
|
1542 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1491 | break; |
1543 | break; |
1492 | |
1544 | |
1493 | case MapNotify: |
|
|
1494 | mapped = 1; |
|
|
1495 | #ifdef TEXT_BLINK |
|
|
1496 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1497 | #endif |
|
|
1498 | break; |
|
|
1499 | |
|
|
1500 | #ifdef TRANSPARENT |
1545 | #ifdef ENABLE_TRANSPARENCY |
1501 | case ReparentNotify: |
1546 | case ReparentNotify: |
1502 | rootwin_cb (ev); |
1547 | rootwin_cb (ev); |
1503 | break; |
1548 | break; |
1504 | #endif /* TRANSPARENT */ |
1549 | #endif /* ENABLE_TRANSPARENCY */ |
1505 | |
1550 | |
1506 | case GraphicsExpose: |
1551 | case GraphicsExpose: |
1507 | case Expose: |
1552 | case Expose: |
1508 | if (ev.xany.window == vt) |
1553 | if (ev.xany.window == vt) |
1509 | { |
1554 | { |
1510 | do |
1555 | do |
1511 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1556 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1512 | ev.xexpose.width, ev.xexpose.height, False); |
1557 | ev.xexpose.width, ev.xexpose.height, False); |
1513 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1558 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1514 | |
1559 | |
1515 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1560 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1516 | |
1561 | |
1517 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1562 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1518 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1563 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1519 | ev.xexpose.width, ev.xexpose.height, False); |
1564 | ev.xexpose.width, ev.xexpose.height, False); |
1520 | |
1565 | |
1521 | scr_refresh (refresh_type); |
1566 | want_refresh = 1; |
1522 | } |
1567 | } |
1523 | else |
1568 | else |
1524 | { |
1569 | { |
1525 | XEvent unused_event; |
1570 | XEvent unused_event; |
1526 | |
1571 | |
1527 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1572 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1528 | ; |
1573 | ; |
1529 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1574 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1530 | ; |
1575 | ; |
1531 | |
1576 | |
1532 | if (isScrollbarWindow (ev.xany.window)) |
1577 | if (isScrollbarWindow (ev.xany.window)) |
1533 | { |
1578 | { |
1534 | scrollBar.setIdle (); |
1579 | scrollBar.setIdle (); |
1535 | scrollbar_show (0); |
1580 | scrollbar_show (0); |
1536 | } |
1581 | } |
1537 | #ifdef MENUBAR |
|
|
1538 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1539 | menubar_expose (); |
|
|
1540 | #endif |
|
|
1541 | |
|
|
1542 | #ifdef TRANSPARENT |
|
|
1543 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1544 | XClearWindow (disp, ev.xany.window); |
|
|
1545 | #endif |
|
|
1546 | } |
1582 | } |
1547 | break; |
1583 | break; |
1548 | |
1584 | |
1549 | case MotionNotify: |
1585 | case MotionNotify: |
1550 | #ifdef POINTER_BLANK |
1586 | #ifdef POINTER_BLANK |
1551 | if (hidden_pointer) |
1587 | if (hidden_pointer) |
1552 | pointer_unblank (); |
1588 | pointer_unblank (); |
1553 | #endif |
1589 | #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) |
1590 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1562 | break; |
1591 | break; |
1563 | |
1592 | |
1564 | if (ev.xany.window == vt) |
1593 | if (ev.xany.window == vt) |
1565 | { |
1594 | { |
|
|
1595 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1596 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1597 | ; // nop |
1566 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1598 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1567 | { |
1599 | { |
1568 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1600 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1569 | ; |
1601 | ; |
1570 | |
1602 | |
1571 | XQueryPointer (disp, vt, |
1603 | XQueryPointer (dpy, vt, |
1572 | &unused_root, &unused_child, |
1604 | &unused_root, &unused_child, |
1573 | &unused_root_x, &unused_root_y, |
1605 | &unused_root_x, &unused_root_y, |
1574 | &ev.xbutton.x, &ev.xbutton.y, |
1606 | &ev.xbutton.x, &ev.xbutton.y, |
1575 | &ev.xbutton.state); |
1607 | &ev.xbutton.state); |
1576 | #ifdef MOUSE_THRESHOLD |
1608 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1640 | #endif |
1672 | #endif |
1641 | } |
1673 | } |
1642 | } |
1674 | } |
1643 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1675 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1644 | { |
1676 | { |
1645 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1677 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1646 | MotionNotify, &ev)) |
1678 | MotionNotify, &ev)) |
1647 | ; |
1679 | ; |
1648 | |
1680 | |
1649 | XQueryPointer (disp, scrollBar.win, |
1681 | XQueryPointer (dpy, scrollBar.win, |
1650 | &unused_root, &unused_child, |
1682 | &unused_root, &unused_child, |
1651 | &unused_root_x, &unused_root_y, |
1683 | &unused_root_x, &unused_root_y, |
1652 | &ev.xbutton.x, &ev.xbutton.y, |
1684 | &ev.xbutton.x, &ev.xbutton.y, |
1653 | &unused_mask); |
1685 | &unused_mask); |
1654 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1686 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1655 | scrollbar_size ()); |
1687 | scrollbar_size ()); |
1656 | scr_refresh (refresh_type); |
|
|
1657 | refresh_limit = 0; |
1688 | want_refresh = 1; |
1658 | scrollbar_show (1); |
1689 | scrollbar_show (1); |
1659 | } |
1690 | } |
1660 | break; |
1691 | break; |
1661 | } |
1692 | } |
|
|
1693 | |
|
|
1694 | #if defined(CURSOR_BLINK) |
|
|
1695 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1696 | { |
|
|
1697 | if (hidden_cursor) |
|
|
1698 | { |
|
|
1699 | hidden_cursor = 0; |
|
|
1700 | want_refresh = 1; |
|
|
1701 | } |
|
|
1702 | |
|
|
1703 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1704 | } |
|
|
1705 | #endif |
|
|
1706 | |
|
|
1707 | #if defined(POINTER_BLANK) |
|
|
1708 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1709 | { |
|
|
1710 | if (ev.type == MotionNotify |
|
|
1711 | || ev.type == ButtonPress |
|
|
1712 | || ev.type == ButtonRelease) |
|
|
1713 | if (hidden_pointer) |
|
|
1714 | pointer_unblank (); |
|
|
1715 | |
|
|
1716 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1717 | pointer_blank (); |
|
|
1718 | } |
|
|
1719 | #endif |
1662 | } |
1720 | } |
1663 | |
1721 | |
1664 | void |
1722 | void |
1665 | rxvt_term::focus_in () |
1723 | rxvt_term::focus_in () |
1666 | { |
1724 | { |
1667 | if (!focus) |
1725 | if (!focus) |
1668 | { |
1726 | { |
1669 | focus = 1; |
1727 | focus = 1; |
1670 | want_refresh = 1; |
1728 | want_refresh = 1; |
|
|
1729 | |
|
|
1730 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1731 | |
1671 | #if USE_XIM |
1732 | #if USE_XIM |
1672 | if (Input_Context != NULL) |
1733 | if (Input_Context != NULL) |
1673 | { |
1734 | { |
1674 | IMSetStatusPosition (); |
1735 | IMSetPosition (); |
1675 | XSetICFocus (Input_Context); |
1736 | XSetICFocus (Input_Context); |
1676 | } |
1737 | } |
1677 | #endif |
1738 | #endif |
1678 | #if CURSOR_BLINK |
1739 | #if CURSOR_BLINK |
1679 | if (options & Opt_cursorBlink) |
1740 | if (option (Opt_cursorBlink)) |
1680 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1741 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1681 | #endif |
1742 | #endif |
1682 | #if OFF_FOCUS_FADING |
1743 | #if OFF_FOCUS_FADING |
1683 | if (rs[Rs_fade]) |
1744 | if (rs[Rs_fade]) |
1684 | { |
1745 | { |
1685 | pix_colors = pix_colors_focused; |
1746 | pix_colors = pix_colors_focused; |
1686 | scr_recolour (); |
1747 | scr_recolour (); |
1687 | } |
1748 | } |
1688 | #endif |
1749 | #endif |
|
|
1750 | #if ENABLE_FRILLS |
|
|
1751 | if (option (Opt_urgentOnBell)) |
|
|
1752 | { |
|
|
1753 | XWMHints *h; |
|
|
1754 | |
|
|
1755 | h = XGetWMHints(dpy, parent[0]); |
|
|
1756 | if (h != NULL) |
|
|
1757 | { |
|
|
1758 | h->flags &= ~XUrgencyHint; |
|
|
1759 | XSetWMHints(dpy, parent[0], h); |
|
|
1760 | } |
|
|
1761 | } |
|
|
1762 | #endif |
1689 | } |
1763 | } |
1690 | } |
1764 | } |
1691 | |
1765 | |
1692 | void |
1766 | void |
1693 | rxvt_term::focus_out () |
1767 | rxvt_term::focus_out () |
… | |
… | |
1695 | if (focus) |
1769 | if (focus) |
1696 | { |
1770 | { |
1697 | focus = 0; |
1771 | focus = 0; |
1698 | want_refresh = 1; |
1772 | want_refresh = 1; |
1699 | |
1773 | |
|
|
1774 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1775 | |
1700 | #if ENABLE_FRILLS || ISO_14755 |
1776 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1777 | if (iso14755buf) |
|
|
1778 | { |
1701 | iso14755buf = 0; |
1779 | iso14755buf = 0; |
1702 | #endif |
1780 | # if ISO_14755 |
1703 | #if ENABLE_OVERLAY |
|
|
1704 | scr_overlay_off (); |
1781 | scr_overlay_off (); |
|
|
1782 | # endif |
|
|
1783 | } |
1705 | #endif |
1784 | #endif |
1706 | #if USE_XIM |
1785 | #if USE_XIM |
1707 | if (Input_Context != NULL) |
1786 | if (Input_Context != NULL) |
1708 | XUnsetICFocus (Input_Context); |
1787 | XUnsetICFocus (Input_Context); |
1709 | #endif |
1788 | #endif |
1710 | #if CURSOR_BLINK |
1789 | #if CURSOR_BLINK |
1711 | if (options & Opt_cursorBlink) |
1790 | if (option (Opt_cursorBlink)) |
1712 | cursor_blink_ev.stop (); |
1791 | cursor_blink_ev.stop (); |
1713 | hidden_cursor = 0; |
1792 | hidden_cursor = 0; |
1714 | #endif |
1793 | #endif |
1715 | #if OFF_FOCUS_FADING |
1794 | #if OFF_FOCUS_FADING |
1716 | if (rs[Rs_fade]) |
1795 | if (rs[Rs_fade]) |
… | |
… | |
1720 | } |
1799 | } |
1721 | #endif |
1800 | #endif |
1722 | } |
1801 | } |
1723 | } |
1802 | } |
1724 | |
1803 | |
1725 | #if TRANSPARENT |
1804 | void |
|
|
1805 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1806 | { |
|
|
1807 | #if OFF_FOCUS_FADING |
|
|
1808 | if (rs[Rs_fade]) |
|
|
1809 | { |
|
|
1810 | rgba c; |
|
|
1811 | pix_colors [Color_fade].get (c); |
|
|
1812 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1813 | } |
|
|
1814 | #endif |
|
|
1815 | } |
|
|
1816 | |
|
|
1817 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1726 | void |
1818 | void |
1727 | rxvt_term::rootwin_cb (XEvent &ev) |
1819 | rxvt_term::rootwin_cb (XEvent &ev) |
1728 | { |
1820 | { |
1729 | SET_R (this); |
1821 | make_current (); |
1730 | SET_LOCALE (locale); |
|
|
1731 | |
1822 | |
|
|
1823 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1824 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1825 | return; |
|
|
1826 | |
|
|
1827 | # if ENABLE_TRANSPARENCY |
1732 | switch (ev.type) |
1828 | switch (ev.type) |
1733 | { |
1829 | { |
1734 | case PropertyNotify: |
1830 | case PropertyNotify: |
1735 | /* |
1831 | /* |
1736 | * if user used some Esetroot compatible prog to set the root bg, |
1832 | * if user used some Esetroot compatible prog to set the root bg, |
1737 | * use the property to determine the pixmap. We use it later on. |
1833 | * use the property to determine the pixmap. We use it later on. |
1738 | */ |
1834 | */ |
1739 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1835 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1740 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1836 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1741 | return; |
1837 | { |
1742 | |
1838 | bgPixmap.set_root_pixmap (); |
1743 | /* FALLTHROUGH */ |
1839 | bgPixmap.render (); |
1744 | case ReparentNotify: |
1840 | } |
1745 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1746 | want_refresh = want_full_refresh = 1; |
|
|
1747 | break; |
1841 | break; |
1748 | } |
1842 | } |
|
|
1843 | # endif |
1749 | } |
1844 | } |
1750 | #endif |
1845 | #endif |
1751 | |
1846 | |
1752 | void |
1847 | void |
1753 | rxvt_term::button_press (XButtonEvent &ev) |
1848 | rxvt_term::button_press (XButtonEvent &ev) |
1754 | { |
1849 | { |
1755 | int reportmode = 0, clickintime; |
1850 | int reportmode = 0, clickintime; |
1756 | |
1851 | |
1757 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1852 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1853 | |
1758 | if (!bypass_keystate) |
1854 | if (!bypass_keystate) |
1759 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1855 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1760 | |
1856 | |
1761 | /* |
1857 | /* |
1762 | * VT window processing of button press |
1858 | * VT window processing of button press |
1763 | */ |
1859 | */ |
1764 | if (ev.window == vt) |
1860 | if (ev.window == vt) |
1765 | { |
1861 | { |
|
|
1862 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1863 | return; |
|
|
1864 | |
1766 | #if ISO_14755 |
1865 | #if ISO_14755 |
1767 | // 5.4 |
1866 | // 5.4 |
1768 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1867 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1769 | { |
1868 | { |
1770 | iso14755_54 (ev.x, ev.y); |
1869 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1782 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1881 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1783 | if (ev.button == MEvent.button && clickintime) |
1882 | if (ev.button == MEvent.button && clickintime) |
1784 | { |
1883 | { |
1785 | /* same button, within alloted time */ |
1884 | /* same button, within alloted time */ |
1786 | MEvent.clicks++; |
1885 | MEvent.clicks++; |
|
|
1886 | |
1787 | if (MEvent.clicks > 1) |
1887 | if (MEvent.clicks > 1) |
1788 | { |
1888 | { |
1789 | /* only report double clicks */ |
1889 | /* only report double clicks */ |
1790 | MEvent.clicks = 2; |
1890 | MEvent.clicks = 2; |
1791 | mouse_report (ev); |
1891 | mouse_report (ev); |
… | |
… | |
1823 | #else |
1923 | #else |
1824 | selection.rect = false; |
1924 | selection.rect = false; |
1825 | #endif |
1925 | #endif |
1826 | |
1926 | |
1827 | /* allow shift+left click to extend selection */ |
1927 | /* allow shift+left click to extend selection */ |
1828 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1928 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1829 | { |
1929 | { |
1830 | if (MEvent.button == Button1 && clickintime) |
1930 | if (MEvent.button == Button1 && clickintime) |
1831 | selection_rotate (ev.x, ev.y); |
1931 | selection_rotate (ev.x, ev.y); |
1832 | else |
1932 | else |
1833 | selection_extend (ev.x, ev.y, 1); |
1933 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
1998 | } |
2098 | } |
1999 | |
2099 | |
2000 | break; |
2100 | break; |
2001 | } |
2101 | } |
2002 | } |
2102 | } |
|
|
2103 | |
2003 | return; |
2104 | return; |
2004 | } |
2105 | } |
2005 | #if MENUBAR |
|
|
2006 | /* |
|
|
2007 | * Menubar window processing of button press |
|
|
2008 | */ |
|
|
2009 | if (isMenuBarWindow (ev.window)) |
|
|
2010 | menubar_control (ev); |
|
|
2011 | #endif |
|
|
2012 | } |
2106 | } |
2013 | |
2107 | |
2014 | void |
2108 | void |
2015 | rxvt_term::button_release (XButtonEvent &ev) |
2109 | rxvt_term::button_release (XButtonEvent &ev) |
2016 | { |
2110 | { |
… | |
… | |
2022 | |
2116 | |
2023 | if (scrollbar_isUpDn ()) |
2117 | if (scrollbar_isUpDn ()) |
2024 | { |
2118 | { |
2025 | scrollBar.setIdle (); |
2119 | scrollBar.setIdle (); |
2026 | scrollbar_show (0); |
2120 | scrollbar_show (0); |
2027 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2028 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2029 | #endif |
|
|
2030 | } |
2121 | } |
2031 | |
2122 | |
2032 | #ifdef SELECTION_SCROLLING |
2123 | #ifdef SELECTION_SCROLLING |
2033 | if (sel_scroll_ev.active) |
2124 | if (sel_scroll_ev.active) |
2034 | sel_scroll_ev.stop(); |
2125 | sel_scroll_ev.stop(); |
2035 | #endif |
2126 | #endif |
2036 | |
2127 | |
2037 | if (ev.window == vt) |
2128 | if (ev.window == vt) |
2038 | { |
2129 | { |
|
|
2130 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2131 | return; |
|
|
2132 | |
2039 | #if ISO_14755 |
2133 | #if ISO_14755 |
2040 | // 5.4 |
2134 | // 5.4 |
2041 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2135 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2042 | return; |
2136 | return; |
2043 | #endif |
2137 | #endif |
|
|
2138 | |
2044 | if (reportmode) |
2139 | if (reportmode) |
2045 | { |
2140 | { |
2046 | /* mouse report from vt window */ |
2141 | /* mouse report from vt window */ |
2047 | /* don't report release of wheel "buttons" */ |
2142 | /* don't report release of wheel "buttons" */ |
2048 | if (ev.button >= 4) |
2143 | if (ev.button >= 4) |
… | |
… | |
2078 | { |
2173 | { |
2079 | case Button1: |
2174 | case Button1: |
2080 | case Button3: |
2175 | case Button3: |
2081 | selection_make (ev.time); |
2176 | selection_make (ev.time); |
2082 | break; |
2177 | break; |
|
|
2178 | |
2083 | case Button2: |
2179 | case Button2: |
2084 | selection_request (ev.time, ev.x, ev.y); |
2180 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2181 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2085 | break; |
2182 | break; |
|
|
2183 | |
2086 | #ifdef MOUSE_WHEEL |
2184 | #ifdef MOUSE_WHEEL |
2087 | case Button4: |
2185 | case Button4: |
2088 | case Button5: |
2186 | case Button5: |
2089 | { |
2187 | { |
2090 | int i; |
2188 | int i; |
… | |
… | |
2092 | |
2190 | |
2093 | v = ev.button == Button4 ? UP : DN; |
2191 | v = ev.button == Button4 ? UP : DN; |
2094 | |
2192 | |
2095 | if (ev.state & ShiftMask) |
2193 | if (ev.state & ShiftMask) |
2096 | i = 1; |
2194 | i = 1; |
2097 | else if (options & Opt_mouseWheelScrollPage) |
2195 | else if (option (Opt_mouseWheelScrollPage)) |
2098 | i = nrow - 1; |
2196 | i = nrow - 1; |
2099 | else |
2197 | else |
2100 | i = 5; |
2198 | i = 5; |
2101 | |
2199 | |
2102 | # ifdef MOUSE_SLIP_WHEELING |
2200 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2112 | slip_wheel_ev.start (); |
2210 | slip_wheel_ev.start (); |
2113 | } |
2211 | } |
2114 | else |
2212 | else |
2115 | { |
2213 | { |
2116 | # endif |
2214 | # endif |
2117 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2118 | scr_page (v, i); |
2215 | scr_page (v, i); |
2119 | scr_refresh (SMOOTH_REFRESH); |
|
|
2120 | scrollbar_show (1); |
2216 | 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 |
2217 | # ifdef MOUSE_SLIP_WHEELING |
2130 | } |
2218 | } |
2131 | #endif |
2219 | # endif |
2132 | } |
2220 | } |
2133 | break; |
2221 | break; |
2134 | #endif |
2222 | #endif |
2135 | } |
2223 | } |
2136 | } |
2224 | } |
2137 | #ifdef MENUBAR |
|
|
2138 | else if (isMenuBarWindow (ev.window)) |
|
|
2139 | menubar_control (ev); |
|
|
2140 | #endif |
|
|
2141 | } |
2225 | } |
2142 | |
|
|
2143 | #ifdef TRANSPARENT |
|
|
2144 | #if TINTING |
|
|
2145 | /* taken from aterm-0.4.2 */ |
|
|
2146 | |
|
|
2147 | typedef uint32_t RUINT32T; |
|
|
2148 | |
|
|
2149 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2150 | { |
|
|
2151 | int sh_r, sh_g, sh_b; |
|
|
2152 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2153 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2154 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2155 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2156 | int i; |
|
|
2157 | |
|
|
2158 | Visual *visual = display->visual; |
|
|
2159 | |
|
|
2160 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2161 | |
|
|
2162 | /* for convenience */ |
|
|
2163 | mask_r = visual->red_mask; |
|
|
2164 | mask_g = visual->green_mask; |
|
|
2165 | mask_b = visual->blue_mask; |
|
|
2166 | |
|
|
2167 | /* boring lookup table pre-initialization */ |
|
|
2168 | switch (srcImage->bits_per_pixel) { |
|
|
2169 | case 15: |
|
|
2170 | if ((mask_r != 0x7c00) || |
|
|
2171 | (mask_g != 0x03e0) || |
|
|
2172 | (mask_b != 0x001f)) |
|
|
2173 | return; |
|
|
2174 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2175 | lookup_r = lookup; |
|
|
2176 | lookup_g = lookup+32; |
|
|
2177 | lookup_b = lookup+32+32; |
|
|
2178 | sh_r = 10; |
|
|
2179 | sh_g = 5; |
|
|
2180 | sh_b = 0; |
|
|
2181 | break; |
|
|
2182 | case 16: |
|
|
2183 | if ((mask_r != 0xf800) || |
|
|
2184 | (mask_g != 0x07e0) || |
|
|
2185 | (mask_b != 0x001f)) |
|
|
2186 | return; |
|
|
2187 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2188 | lookup_r = lookup; |
|
|
2189 | lookup_g = lookup+32; |
|
|
2190 | lookup_b = lookup+32+64; |
|
|
2191 | sh_r = 11; |
|
|
2192 | sh_g = 5; |
|
|
2193 | sh_b = 0; |
|
|
2194 | break; |
|
|
2195 | case 24: |
|
|
2196 | if ((mask_r != 0xff0000) || |
|
|
2197 | (mask_g != 0x00ff00) || |
|
|
2198 | (mask_b != 0x0000ff)) |
|
|
2199 | return; |
|
|
2200 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2201 | lookup_r = lookup; |
|
|
2202 | lookup_g = lookup+256; |
|
|
2203 | lookup_b = lookup+256+256; |
|
|
2204 | sh_r = 16; |
|
|
2205 | sh_g = 8; |
|
|
2206 | sh_b = 0; |
|
|
2207 | break; |
|
|
2208 | case 32: |
|
|
2209 | if ((mask_r != 0xff0000) || |
|
|
2210 | (mask_g != 0x00ff00) || |
|
|
2211 | (mask_b != 0x0000ff)) |
|
|
2212 | return; |
|
|
2213 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2214 | lookup_r = lookup; |
|
|
2215 | lookup_g = lookup+256; |
|
|
2216 | lookup_b = lookup+256+256; |
|
|
2217 | sh_r = 16; |
|
|
2218 | sh_g = 8; |
|
|
2219 | sh_b = 0; |
|
|
2220 | break; |
|
|
2221 | default: |
|
|
2222 | return; /* we do not support this color depth */ |
|
|
2223 | } |
|
|
2224 | |
|
|
2225 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2226 | if (shade < 0) { |
|
|
2227 | shade = -shade; |
|
|
2228 | if (shade < 0) shade = 0; |
|
|
2229 | if (shade > 100) shade = 100; |
|
|
2230 | |
|
|
2231 | lower_lim_r = 65535-rm; |
|
|
2232 | lower_lim_g = 65535-gm; |
|
|
2233 | lower_lim_b = 65535-bm; |
|
|
2234 | |
|
|
2235 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2236 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2237 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2238 | |
|
|
2239 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2240 | } else { |
|
|
2241 | if (shade < 0) shade = 0; |
|
|
2242 | if (shade > 100) shade = 100; |
|
|
2243 | |
|
|
2244 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2245 | |
|
|
2246 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2247 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2248 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2249 | } |
|
|
2250 | |
|
|
2251 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2252 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2253 | { |
|
|
2254 | unsigned int tmp; |
|
|
2255 | |
|
|
2256 | tmp = lower_lim_r; |
|
|
2257 | lower_lim_r = lower_lim_b; |
|
|
2258 | lower_lim_b = tmp; |
|
|
2259 | |
|
|
2260 | tmp = upper_lim_r; |
|
|
2261 | upper_lim_r = upper_lim_b; |
|
|
2262 | upper_lim_b = tmp; |
|
|
2263 | } |
|
|
2264 | |
|
|
2265 | /* fill our lookup tables */ |
|
|
2266 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2267 | { |
|
|
2268 | RUINT32T tmp; |
|
|
2269 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2270 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2271 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2272 | } |
|
|
2273 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2274 | { |
|
|
2275 | RUINT32T tmp; |
|
|
2276 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2277 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2278 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2279 | } |
|
|
2280 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2281 | { |
|
|
2282 | RUINT32T tmp; |
|
|
2283 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2284 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2285 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2286 | } |
|
|
2287 | |
|
|
2288 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2289 | switch (srcImage->bits_per_pixel) |
|
|
2290 | { |
|
|
2291 | case 15: |
|
|
2292 | { |
|
|
2293 | unsigned short *p1, *pf, *p, *pl; |
|
|
2294 | p1 = (unsigned short *) srcImage->data; |
|
|
2295 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2296 | while (p1 < pf) |
|
|
2297 | { |
|
|
2298 | p = p1; |
|
|
2299 | pl = p1 + srcImage->width; |
|
|
2300 | for (; p < pl; p++) |
|
|
2301 | { |
|
|
2302 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2303 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2304 | lookup_b[(*p & 0x001f)]; |
|
|
2305 | } |
|
|
2306 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2307 | } |
|
|
2308 | break; |
|
|
2309 | } |
|
|
2310 | case 16: |
|
|
2311 | { |
|
|
2312 | unsigned short *p1, *pf, *p, *pl; |
|
|
2313 | p1 = (unsigned short *) srcImage->data; |
|
|
2314 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2315 | while (p1 < pf) |
|
|
2316 | { |
|
|
2317 | p = p1; |
|
|
2318 | pl = p1 + srcImage->width; |
|
|
2319 | for (; p < pl; p++) |
|
|
2320 | { |
|
|
2321 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2322 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2323 | lookup_b[(*p & 0x001f)]; |
|
|
2324 | } |
|
|
2325 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2326 | } |
|
|
2327 | break; |
|
|
2328 | } |
|
|
2329 | case 24: |
|
|
2330 | { |
|
|
2331 | unsigned char *p1, *pf, *p, *pl; |
|
|
2332 | p1 = (unsigned char *) srcImage->data; |
|
|
2333 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2334 | while (p1 < pf) |
|
|
2335 | { |
|
|
2336 | p = p1; |
|
|
2337 | pl = p1 + srcImage->width * 3; |
|
|
2338 | for (; p < pl; p += 3) |
|
|
2339 | { |
|
|
2340 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2341 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2342 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2343 | } |
|
|
2344 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2345 | } |
|
|
2346 | break; |
|
|
2347 | } |
|
|
2348 | case 32: |
|
|
2349 | { |
|
|
2350 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2351 | p1 = (RUINT32T *) srcImage->data; |
|
|
2352 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2353 | |
|
|
2354 | while (p1 < pf) |
|
|
2355 | { |
|
|
2356 | p = p1; |
|
|
2357 | pl = p1 + srcImage->width; |
|
|
2358 | for (; p < pl; p++) |
|
|
2359 | { |
|
|
2360 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2361 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2362 | lookup_b[(*p & 0x0000ff)] | |
|
|
2363 | (*p & ~0xffffff); |
|
|
2364 | } |
|
|
2365 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2366 | } |
|
|
2367 | break; |
|
|
2368 | } |
|
|
2369 | } |
|
|
2370 | |
|
|
2371 | free (lookup); |
|
|
2372 | } |
|
|
2373 | #endif |
|
|
2374 | |
|
|
2375 | /* |
|
|
2376 | * Check our parents are still who we think they are. |
|
|
2377 | * Do transparency updates if required |
|
|
2378 | */ |
|
|
2379 | int |
|
|
2380 | rxvt_term::check_our_parents () |
|
|
2381 | { |
|
|
2382 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2383 | unsigned long nitems, bytes_after; |
|
|
2384 | Atom atype; |
|
|
2385 | unsigned char *prop = NULL; |
|
|
2386 | Window root, oldp, *list; |
|
|
2387 | Pixmap rootpixmap = None; |
|
|
2388 | XWindowAttributes wattr, wrootattr; |
|
|
2389 | dDisp; |
|
|
2390 | |
|
|
2391 | pchanged = 0; |
|
|
2392 | |
|
|
2393 | if (!(options & Opt_transparent)) |
|
|
2394 | return pchanged; /* Don't try any more */ |
|
|
2395 | |
|
|
2396 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2397 | rootdepth = wrootattr.depth; |
|
|
2398 | |
|
|
2399 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2400 | |
|
|
2401 | if (rootdepth != wattr.depth) |
|
|
2402 | { |
|
|
2403 | if (am_transparent) |
|
|
2404 | { |
|
|
2405 | pchanged = 1; |
|
|
2406 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2407 | am_transparent = am_pixmap_trans = 0; |
|
|
2408 | } |
|
|
2409 | |
|
|
2410 | return pchanged; /* Don't try any more */ |
|
|
2411 | } |
|
|
2412 | |
|
|
2413 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2414 | XSync (disp, False); |
|
|
2415 | |
|
|
2416 | /* |
|
|
2417 | * Make the frame window set by the window manager have |
|
|
2418 | * the root background. Some window managers put multiple nested frame |
|
|
2419 | * windows for each client, so we have to take care about that. |
|
|
2420 | */ |
|
|
2421 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2422 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2423 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2424 | &nitems, &bytes_after, &prop) == Success); |
|
|
2425 | |
|
|
2426 | if (!i || prop == NULL) |
|
|
2427 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2428 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2429 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2430 | &nitems, &bytes_after, &prop) == Success); |
|
|
2431 | |
|
|
2432 | if (!i || prop == NULL |
|
|
2433 | #if TINTING |
|
|
2434 | || !rs[Rs_color + Color_tint] |
|
|
2435 | #endif |
|
|
2436 | ) |
|
|
2437 | have_pixmap = 0; |
|
|
2438 | else |
|
|
2439 | { |
|
|
2440 | have_pixmap = 1; |
|
|
2441 | rootpixmap = *(Pixmap *)prop; |
|
|
2442 | XFree (prop); |
|
|
2443 | } |
|
|
2444 | |
|
|
2445 | if (have_pixmap) |
|
|
2446 | { |
|
|
2447 | /* |
|
|
2448 | * Copy display->root pixmap transparency |
|
|
2449 | */ |
|
|
2450 | int sx, sy, nx, ny; |
|
|
2451 | unsigned int nw, nh; |
|
|
2452 | Window cr; |
|
|
2453 | XImage *image; |
|
|
2454 | GC gc; |
|
|
2455 | XGCValues gcvalue; |
|
|
2456 | |
|
|
2457 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2458 | 0, 0, &sx, &sy, &cr); |
|
|
2459 | nw = (unsigned int)szHint.width; |
|
|
2460 | nh = (unsigned int)szHint.height; |
|
|
2461 | nx = ny = 0; |
|
|
2462 | |
|
|
2463 | if (sx < 0) |
|
|
2464 | { |
|
|
2465 | nw += sx; |
|
|
2466 | nx = -sx; |
|
|
2467 | sx = 0; |
|
|
2468 | } |
|
|
2469 | |
|
|
2470 | if (sy < 0) |
|
|
2471 | { |
|
|
2472 | nh += sy; |
|
|
2473 | ny = -sy; |
|
|
2474 | sy = 0; |
|
|
2475 | } |
|
|
2476 | |
|
|
2477 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2478 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2479 | |
|
|
2480 | XSync (disp, False); |
|
|
2481 | allowedxerror = -1; |
|
|
2482 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2483 | |
|
|
2484 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2485 | /* XXX: may need a delay here? */ |
|
|
2486 | allowedxerror = 0; |
|
|
2487 | |
|
|
2488 | if (image == NULL) |
|
|
2489 | { |
|
|
2490 | if (am_transparent && am_pixmap_trans) |
|
|
2491 | { |
|
|
2492 | pchanged = 1; |
|
|
2493 | if (pixmap != None) |
|
|
2494 | { |
|
|
2495 | XFreePixmap (disp, pixmap); |
|
|
2496 | pixmap = None; |
|
|
2497 | } |
|
|
2498 | } |
|
|
2499 | |
|
|
2500 | am_pixmap_trans = 0; |
|
|
2501 | } |
|
|
2502 | else |
|
|
2503 | { |
|
|
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); |
|
|
2527 | XClearWindow (disp, parent[0]); |
|
|
2528 | |
|
|
2529 | if (!am_transparent || !am_pixmap_trans) |
|
|
2530 | pchanged = 1; |
|
|
2531 | |
|
|
2532 | am_transparent = am_pixmap_trans = 1; |
|
|
2533 | } |
|
|
2534 | } |
|
|
2535 | |
|
|
2536 | if (am_pixmap_trans) |
|
|
2537 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2538 | else |
|
|
2539 | { |
|
|
2540 | unsigned int n; |
|
|
2541 | /* |
|
|
2542 | * InheritPixmap transparency |
|
|
2543 | */ |
|
|
2544 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2545 | { |
|
|
2546 | oldp = parent[i]; |
|
|
2547 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2548 | &parent[i], &list, &n); |
|
|
2549 | XFree (list); |
|
|
2550 | |
|
|
2551 | if (parent[i] == display->root) |
|
|
2552 | { |
|
|
2553 | if (oldp != None) |
|
|
2554 | pchanged = 1; |
|
|
2555 | |
|
|
2556 | break; |
|
|
2557 | } |
|
|
2558 | |
|
|
2559 | if (oldp != parent[i]) |
|
|
2560 | pchanged = 1; |
|
|
2561 | } |
|
|
2562 | |
|
|
2563 | n = 0; |
|
|
2564 | |
|
|
2565 | if (pchanged) |
|
|
2566 | { |
|
|
2567 | for (; n < (unsigned int)i; n++) |
|
|
2568 | { |
|
|
2569 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2570 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2571 | { |
|
|
2572 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2573 | break; |
|
|
2574 | } |
|
|
2575 | } |
|
|
2576 | } |
|
|
2577 | |
|
|
2578 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2579 | { |
|
|
2580 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2581 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2582 | am_transparent = 0; |
|
|
2583 | /* XXX: also turn off Opt_transparent? */ |
|
|
2584 | } |
|
|
2585 | else |
|
|
2586 | { |
|
|
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++) |
|
|
2593 | { |
|
|
2594 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2595 | XClearWindow (disp, parent[n]); |
|
|
2596 | } |
|
|
2597 | |
|
|
2598 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2599 | am_transparent = 1; |
|
|
2600 | } |
|
|
2601 | |
|
|
2602 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2603 | parent[i] = None; |
|
|
2604 | } |
|
|
2605 | |
|
|
2606 | if (scrollBar.win) |
|
|
2607 | { |
|
|
2608 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2609 | scrollBar.setIdle (); |
|
|
2610 | scrollbar_show (0); |
|
|
2611 | } |
|
|
2612 | |
|
|
2613 | if (am_transparent) |
|
|
2614 | { |
|
|
2615 | want_refresh = want_full_refresh = 1; |
|
|
2616 | if (am_pixmap_trans) |
|
|
2617 | flush (); |
|
|
2618 | } |
|
|
2619 | |
|
|
2620 | return pchanged; |
|
|
2621 | } |
|
|
2622 | #endif |
|
|
2623 | |
2226 | |
2624 | /*}}} */ |
2227 | /*}}} */ |
2625 | |
2228 | |
2626 | bool |
2229 | bool |
2627 | rxvt_term::cmd_parse () |
2230 | rxvt_term::cmd_parse () |
2628 | { |
2231 | { |
2629 | bool flag = false; |
2232 | bool flag = false; |
2630 | unicode_t ch = NOCHAR; |
2233 | wchar_t ch = NOCHAR; |
2631 | unsigned char *seq_begin; // remember start of esc-sequence here |
2234 | char *seq_begin; // remember start of esc-sequence here |
2632 | |
2235 | |
2633 | for (;;) |
2236 | for (;;) |
2634 | { |
2237 | { |
2635 | if (ch == NOCHAR) |
2238 | if (ch == NOCHAR) |
2636 | { |
2239 | { |
2637 | seq_begin = cmdbuf_ptr; |
2240 | seq_begin = cmdbuf_ptr; |
2638 | ch = next_char (); |
2241 | ch = next_char (); |
2639 | } |
|
|
2640 | |
2242 | |
2641 | if (ch == NOCHAR) // TODO: improve |
2243 | if (ch == NOCHAR) |
2642 | break; |
2244 | break; |
|
|
2245 | } |
2643 | |
2246 | |
2644 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2247 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2645 | { |
2248 | { |
2646 | if (!seen_input) |
2249 | if (!seen_input) |
2647 | { |
2250 | { |
… | |
… | |
2656 | if (seen_resize && cmd_pid) |
2259 | if (seen_resize && cmd_pid) |
2657 | kill (-cmd_pid, SIGWINCH); |
2260 | kill (-cmd_pid, SIGWINCH); |
2658 | } |
2261 | } |
2659 | |
2262 | |
2660 | /* Read a text string from the input buffer */ |
2263 | /* Read a text string from the input buffer */ |
2661 | unicode_t buf[UBUFSIZ]; |
2264 | wchar_t buf[UBUFSIZ]; |
2662 | bool refreshnow = false; |
2265 | bool refreshnow = false; |
2663 | int nlines = 0; |
2266 | int nlines = 0; |
2664 | unicode_t *str = buf; |
2267 | wchar_t *str = buf; |
2665 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2268 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2666 | |
2269 | |
2667 | for (;;) |
2270 | for (;;) |
2668 | { |
2271 | { |
2669 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2272 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2670 | break; |
2273 | break; |
… | |
… | |
2676 | if (ch == C0_LF) |
2279 | if (ch == C0_LF) |
2677 | nlines++; |
2280 | nlines++; |
2678 | |
2281 | |
2679 | refresh_count++; |
2282 | refresh_count++; |
2680 | |
2283 | |
2681 | if (!(options & Opt_jumpScroll) |
2284 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2682 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2683 | { |
2285 | { |
|
|
2286 | refresh_count = 0; |
|
|
2287 | |
|
|
2288 | if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.) |
|
|
2289 | { |
2684 | refreshnow = true; |
2290 | refreshnow = true; |
2685 | ch = NOCHAR; |
2291 | ch = NOCHAR; |
2686 | break; |
2292 | break; |
|
|
2293 | } |
2687 | } |
2294 | } |
2688 | |
2295 | |
2689 | // scr_add_lines only works for nlines <= nrow - 1. |
2296 | // scr_add_lines only works for nlines <= nrow - 1. |
2690 | if (nlines >= nrow - 1) |
2297 | if (nlines >= nrow - 1) |
2691 | { |
2298 | { |
|
|
2299 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2300 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2692 | scr_add_lines (buf, nlines, str - buf); |
2301 | scr_add_lines (buf, str - buf, nlines); |
|
|
2302 | |
2693 | nlines = 0; |
2303 | nlines = 0; |
2694 | str = buf; |
2304 | str = buf; |
2695 | eol = str + min (ncol, UBUFSIZ); |
2305 | eol = str + min (ncol, UBUFSIZ); |
2696 | } |
2306 | } |
2697 | |
2307 | |
… | |
… | |
2710 | |
2320 | |
2711 | seq_begin = cmdbuf_ptr; |
2321 | seq_begin = cmdbuf_ptr; |
2712 | ch = next_char (); |
2322 | ch = next_char (); |
2713 | } |
2323 | } |
2714 | |
2324 | |
|
|
2325 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2326 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2715 | scr_add_lines (buf, nlines, str - buf); |
2327 | scr_add_lines (buf, str - buf, nlines); |
2716 | |
2328 | |
2717 | /* |
2329 | /* |
2718 | * If there have been a lot of new lines, then update the screen |
2330 | * 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. |
2331 | * What the heck we'll cheat and only refresh less than every page-full. |
2720 | * the number of pages between refreshes is refresh_limit, which |
2332 | * if skipScroll is enabled. |
2721 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2722 | */ |
2333 | */ |
2723 | if (refreshnow) |
2334 | if (refreshnow) |
2724 | { |
2335 | { |
2725 | if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2726 | refresh_limit++; |
|
|
2727 | else |
|
|
2728 | { |
|
|
2729 | flag = true; |
2336 | flag = true; |
2730 | scr_refresh (refresh_type); |
2337 | scr_refresh (); |
2731 | } |
2338 | want_refresh = 1; |
2732 | } |
2339 | } |
2733 | |
2340 | |
2734 | } |
2341 | } |
2735 | else |
2342 | else |
2736 | { |
2343 | { |
… | |
… | |
2750 | } |
2357 | } |
2751 | |
2358 | |
2752 | return flag; |
2359 | return flag; |
2753 | } |
2360 | } |
2754 | |
2361 | |
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 |
2362 | // read the next character |
2765 | unicode_t |
2363 | wchar_t |
2766 | rxvt_term::next_char () |
2364 | rxvt_term::next_char () NOTHROW |
2767 | { |
2365 | { |
2768 | while (cmdbuf_ptr < cmdbuf_endp) |
2366 | while (cmdbuf_ptr < cmdbuf_endp) |
2769 | { |
2367 | { |
2770 | // assume 7-bit to be ascii ALWAYS |
2368 | // assume 7-bit to be ascii ALWAYS |
2771 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2369 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2772 | return *cmdbuf_ptr++; |
2370 | return *cmdbuf_ptr++; |
2773 | |
2371 | |
2774 | wchar_t wc; |
2372 | wchar_t wc; |
2775 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2373 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2776 | |
2374 | |
2777 | if (len == (size_t)-2) |
2375 | if (len == (size_t)-2) |
2778 | { |
2376 | { |
2779 | // the mbstate stores incomplete sequences. didn't know this :/ |
2377 | // the mbstate stores incomplete sequences. didn't know this :/ |
2780 | cmdbuf_ptr = cmdbuf_endp; |
2378 | cmdbuf_ptr = cmdbuf_endp; |
2781 | break; |
2379 | break; |
2782 | } |
2380 | } |
2783 | |
2381 | |
2784 | if (len == (size_t)-1) |
2382 | if (len == (size_t)-1) |
2785 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2383 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2786 | |
2384 | |
2787 | // assume wchar == unicode |
2385 | // assume wchar == unicode |
2788 | cmdbuf_ptr += len; |
2386 | cmdbuf_ptr += len; |
2789 | return wc & UNICODE_MASK; |
2387 | return wc & UNICODE_MASK; |
2790 | } |
2388 | } |
2791 | |
2389 | |
2792 | return NOCHAR; |
2390 | return NOCHAR; |
2793 | } |
2391 | } |
|
|
2392 | |
|
|
2393 | // read the next octet |
|
|
2394 | uint32_t |
|
|
2395 | rxvt_term::next_octet () NOTHROW |
|
|
2396 | { |
|
|
2397 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2398 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2399 | : NOCHAR; |
|
|
2400 | } |
|
|
2401 | |
|
|
2402 | static class out_of_input out_of_input; |
2794 | |
2403 | |
2795 | /* rxvt_cmd_getc () - Return next input character */ |
2404 | /* rxvt_cmd_getc () - Return next input character */ |
2796 | /* |
2405 | /* |
2797 | * Return the next input character after first passing any keyboard input |
2406 | * Return the next input character after first passing any keyboard input |
2798 | * to the command. |
2407 | * to the command. |
2799 | */ |
2408 | */ |
2800 | unicode_t |
2409 | wchar_t |
2801 | rxvt_term::cmd_getc () |
2410 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2802 | { |
2411 | { |
2803 | unicode_t c = next_char (); |
2412 | wchar_t c = next_char (); |
2804 | |
2413 | |
2805 | if (c == NOCHAR) |
2414 | if (c == NOCHAR) |
2806 | throw out_of_input; |
2415 | throw out_of_input; |
2807 | |
2416 | |
2808 | return c; |
2417 | return c; |
2809 | } |
2418 | } |
2810 | |
2419 | |
2811 | unicode_t |
2420 | uint32_t |
2812 | rxvt_term::cmd_get8 () |
2421 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2813 | { |
2422 | { |
2814 | unicode_t c = next_octet (); |
2423 | uint32_t c = next_octet (); |
2815 | |
2424 | |
2816 | if (c == NOCHAR) |
2425 | if (c == NOCHAR) |
2817 | throw out_of_input; |
2426 | throw out_of_input; |
2818 | |
2427 | |
2819 | return c; |
2428 | return c; |
… | |
… | |
2883 | { |
2492 | { |
2884 | if ((buf[len++] = cmd_getc ()) == 'i') |
2493 | if ((buf[len++] = cmd_getc ()) == 'i') |
2885 | break; /* done = 1 */ |
2494 | break; /* done = 1 */ |
2886 | } |
2495 | } |
2887 | } |
2496 | } |
2888 | |
2497 | |
2889 | for (i = 0; i < len; i++) |
2498 | for (i = 0; i < len; i++) |
2890 | if (putc (buf[i], fd) == EOF) |
2499 | if (putc (buf[i], fd) == EOF) |
2891 | { |
2500 | { |
2892 | done = 1; |
2501 | done = 1; |
2893 | break; |
2502 | break; |
… | |
… | |
2919 | case C0_ESC: |
2528 | case C0_ESC: |
2920 | process_escape_seq (); |
2529 | process_escape_seq (); |
2921 | break; |
2530 | break; |
2922 | case C0_ENQ: /* terminal Status */ |
2531 | case C0_ENQ: /* terminal Status */ |
2923 | if (rs[Rs_answerbackstring]) |
2532 | if (rs[Rs_answerbackstring]) |
2924 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2533 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2925 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2926 | else |
2534 | else |
2927 | tt_write ((unsigned char *)VT100_ANS, |
2535 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2928 | (unsigned int)strlen (VT100_ANS)); |
|
|
2929 | break; |
2536 | break; |
2930 | case C0_BEL: /* bell */ |
2537 | case C0_BEL: /* bell */ |
2931 | scr_bell (); |
2538 | scr_bell (); |
2932 | break; |
2539 | break; |
2933 | case C0_BS: /* backspace */ |
2540 | case C0_BS: /* backspace */ |
… | |
… | |
2957 | process_dcs_seq (); |
2564 | process_dcs_seq (); |
2958 | break; |
2565 | break; |
2959 | case 0x9b: /* CSI */ |
2566 | case 0x9b: /* CSI */ |
2960 | process_csi_seq (); |
2567 | process_csi_seq (); |
2961 | break; |
2568 | break; |
2962 | case 0x9d: /* CSI */ |
2569 | case 0x9d: /* OSC */ |
2963 | process_osc_seq (); |
2570 | process_osc_seq (); |
2964 | break; |
2571 | break; |
2965 | #endif |
2572 | #endif |
2966 | } |
2573 | } |
2967 | } |
2574 | } |
… | |
… | |
3057 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2664 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3058 | break; |
2665 | break; |
3059 | case '+': |
2666 | case '+': |
3060 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2667 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3061 | break; |
2668 | break; |
3062 | #if ENABLE_FRILLS |
2669 | #if !ENABLE_MINIMAL |
3063 | case '6': |
2670 | case '6': |
3064 | scr_backindex (); |
2671 | scr_backindex (); |
3065 | break; |
2672 | break; |
3066 | #endif |
2673 | #endif |
3067 | case '7': |
2674 | case '7': |
3068 | scr_cursor (SAVE); |
2675 | scr_cursor (SAVE); |
3069 | break; |
2676 | break; |
3070 | case '8': |
2677 | case '8': |
3071 | scr_cursor (RESTORE); |
2678 | scr_cursor (RESTORE); |
3072 | break; |
2679 | break; |
3073 | #if ENABLE_FRILLS |
2680 | #if !ENABLE_MINIMAL |
3074 | case '9': |
2681 | case '9': |
3075 | scr_forwardindex (); |
2682 | scr_forwardindex (); |
3076 | break; |
2683 | break; |
3077 | #endif |
2684 | #endif |
3078 | case '=': |
2685 | case '=': |
… | |
… | |
3088 | break; |
2695 | break; |
3089 | |
2696 | |
3090 | /* 8.3.87: NEXT LINE */ |
2697 | /* 8.3.87: NEXT LINE */ |
3091 | case C1_NEL: /* ESC E */ |
2698 | case C1_NEL: /* ESC E */ |
3092 | { |
2699 | { |
3093 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2700 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3094 | scr_add_lines (nlcr, 1, 2); |
2701 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3095 | } |
2702 | } |
3096 | break; |
2703 | break; |
3097 | |
2704 | |
3098 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2705 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3099 | case C1_ESA: /* ESC G */ |
2706 | case C1_ESA: /* ESC G */ |
… | |
… | |
3121 | process_dcs_seq (); |
2728 | process_dcs_seq (); |
3122 | break; |
2729 | break; |
3123 | |
2730 | |
3124 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2731 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3125 | case C1_SCI: /* ESC Z */ |
2732 | case C1_SCI: /* ESC Z */ |
3126 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
2733 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3127 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3128 | break; /* steal obsolete ESC [ c */ |
2734 | break; /* steal obsolete ESC [ c */ |
3129 | |
2735 | |
3130 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2736 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3131 | case C1_CSI: /* ESC [ */ |
2737 | case C1_CSI: /* ESC [ */ |
3132 | process_csi_seq (); |
2738 | process_csi_seq (); |
… | |
… | |
3196 | unicode_t ch, priv, i; |
2802 | unicode_t ch, priv, i; |
3197 | unsigned int nargs, p; |
2803 | unsigned int nargs, p; |
3198 | int n, ndef; |
2804 | int n, ndef; |
3199 | int arg[ESC_ARGS]; |
2805 | int arg[ESC_ARGS]; |
3200 | |
2806 | |
3201 | for (nargs = ESC_ARGS; nargs > 0;) |
2807 | memset (arg, 0, sizeof (arg)); |
3202 | arg[--nargs] = 0; |
2808 | nargs = 0; |
3203 | |
2809 | |
3204 | priv = 0; |
2810 | priv = 0; |
3205 | ch = cmd_getc (); |
2811 | ch = cmd_getc (); |
3206 | if (ch >= '<' && ch <= '?') |
2812 | if (ch >= '<' && ch <= '?') |
3207 | { /* '<' '=' '>' '?' */ |
2813 | { /* '<' '=' '>' '?' */ |
… | |
… | |
3241 | ndef = get_byte_array_bit (csi_defaults, i); |
2847 | ndef = get_byte_array_bit (csi_defaults, i); |
3242 | for (p = 0; p < nargs; p++) |
2848 | for (p = 0; p < nargs; p++) |
3243 | if (arg[p] == -1) |
2849 | if (arg[p] == -1) |
3244 | arg[p] = ndef; |
2850 | arg[p] = ndef; |
3245 | |
2851 | |
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 | /* |
2852 | /* |
3254 | * private mode handling |
2853 | * private mode handling |
3255 | */ |
2854 | */ |
3256 | if (priv) |
2855 | if (priv) |
3257 | { |
2856 | { |
3258 | switch (priv) |
2857 | switch (priv) |
3259 | { |
2858 | { |
3260 | case '>': |
2859 | case '>': |
3261 | if (ch == CSI_DA) /* secondary device attributes */ |
2860 | if (ch == CSI_DA) /* secondary device attributes */ |
3262 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2861 | { |
|
|
2862 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2863 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2864 | // |
|
|
2865 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2866 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
2867 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
2868 | // |
|
|
2869 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
2870 | } |
3263 | break; |
2871 | break; |
3264 | case '?': |
2872 | case '?': |
3265 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2873 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3266 | process_terminal_mode (ch, priv, nargs, arg); |
2874 | process_terminal_mode (ch, priv, nargs, arg); |
3267 | break; |
2875 | break; |
… | |
… | |
3376 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
2984 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3377 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
2985 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3378 | break; |
2986 | break; |
3379 | |
2987 | |
3380 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
2988 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3381 | tt_write ((const unsigned char *)VT100_ANS, |
2989 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3382 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3383 | break; |
2990 | break; |
3384 | |
2991 | |
3385 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
2992 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3386 | process_sgr_mode (nargs, arg); |
2993 | process_sgr_mode (nargs, arg); |
3387 | break; |
2994 | break; |
… | |
… | |
3394 | break; |
3001 | break; |
3395 | case 6: /* CPR requested */ |
3002 | case 6: /* CPR requested */ |
3396 | scr_report_position (); |
3003 | scr_report_position (); |
3397 | break; |
3004 | break; |
3398 | case 7: /* unofficial extension */ |
3005 | case 7: /* unofficial extension */ |
3399 | if (options & Opt_insecure) |
3006 | if (option (Opt_insecure)) |
3400 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3007 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3401 | break; |
3008 | break; |
3402 | case 8: /* unofficial extension */ |
3009 | case 8: /* unofficial extension */ |
3403 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3010 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3404 | break; |
3011 | break; |
… | |
… | |
3471 | break; |
3078 | break; |
3472 | case CSI_75: |
3079 | case CSI_75: |
3473 | scr_cursor (RESTORE); |
3080 | scr_cursor (RESTORE); |
3474 | break; |
3081 | break; |
3475 | |
3082 | |
3476 | #if ENABLE_FRILLS |
3083 | #if !ENABLE_MINIMAL |
3477 | case CSI_74: |
3084 | case CSI_74: |
3478 | process_window_ops (arg, nargs); |
3085 | process_window_ops (arg, nargs); |
3479 | break; |
3086 | break; |
3480 | #endif |
3087 | #endif |
3481 | |
3088 | |
… | |
… | |
3488 | break; |
3095 | break; |
3489 | } |
3096 | } |
3490 | } |
3097 | } |
3491 | /*}}} */ |
3098 | /*}}} */ |
3492 | |
3099 | |
3493 | #if ENABLE_FRILLS |
3100 | #if !ENABLE_MINIMAL |
3494 | /* ARGSUSED */ |
3101 | /* ARGSUSED */ |
3495 | void |
3102 | void |
3496 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3103 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3497 | { |
3104 | { |
3498 | int x, y; |
3105 | int x, y; |
3499 | XWindowAttributes wattr; |
3106 | XWindowAttributes wattr; |
3500 | Window wdummy; |
3107 | Window wdummy; |
3501 | dDisp; |
3108 | |
|
|
3109 | dLocal (Display *, dpy); |
3502 | |
3110 | |
3503 | if (nargs == 0) |
3111 | if (nargs == 0) |
3504 | return; |
3112 | return; |
3505 | |
3113 | |
3506 | switch (args[0]) |
3114 | switch (args[0]) |
3507 | { |
3115 | { |
3508 | /* |
3116 | /* |
3509 | * commands |
3117 | * commands |
3510 | */ |
3118 | */ |
3511 | case 1: /* deiconify window */ |
3119 | case 1: /* deiconify window */ |
3512 | XMapWindow (disp, parent[0]); |
3120 | XMapWindow (dpy, parent[0]); |
3513 | break; |
3121 | break; |
3514 | case 2: /* iconify window */ |
3122 | case 2: /* iconify window */ |
3515 | XIconifyWindow (disp, parent[0], display->screen); |
3123 | XIconifyWindow (dpy, parent[0], display->screen); |
3516 | break; |
3124 | break; |
3517 | case 3: /* set position (pixels) */ |
3125 | case 3: /* set position (pixels) */ |
3518 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3126 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3519 | break; |
3127 | break; |
3520 | case 4: /* set size (pixels) */ |
3128 | case 4: /* set size (pixels) */ |
3521 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3129 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3522 | break; |
3130 | break; |
3523 | case 5: /* raise window */ |
3131 | case 5: /* raise window */ |
3524 | XRaiseWindow (disp, parent[0]); |
3132 | XRaiseWindow (dpy, parent[0]); |
3525 | break; |
3133 | break; |
3526 | case 6: /* lower window */ |
3134 | case 6: /* lower window */ |
3527 | XLowerWindow (disp, parent[0]); |
3135 | XLowerWindow (dpy, parent[0]); |
3528 | break; |
3136 | break; |
3529 | case 7: /* refresh window */ |
3137 | case 7: /* refresh window */ |
3530 | scr_touch (true); |
3138 | scr_touch (true); |
3531 | break; |
3139 | break; |
3532 | case 8: /* set size (chars) */ |
3140 | case 8: /* set size (chars) */ |
… | |
… | |
3539 | if (args[0] >= 24) /* set height (chars) */ |
3147 | if (args[0] >= 24) /* set height (chars) */ |
3540 | set_widthheight ((unsigned int)width, |
3148 | set_widthheight ((unsigned int)width, |
3541 | (unsigned int) (args[1] * fheight)); |
3149 | (unsigned int) (args[1] * fheight)); |
3542 | break; |
3150 | break; |
3543 | |
3151 | |
3544 | |
|
|
3545 | /* |
3152 | /* |
3546 | * reports - some output format copied from XTerm |
3153 | * reports - some output format copied from XTerm |
3547 | */ |
3154 | */ |
3548 | case 11: /* report window state */ |
3155 | case 11: /* report window state */ |
3549 | XGetWindowAttributes (disp, parent[0], &wattr); |
3156 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3550 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3157 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3551 | break; |
3158 | break; |
3552 | case 13: /* report window position */ |
3159 | case 13: /* report window position */ |
3553 | XGetWindowAttributes (disp, parent[0], &wattr); |
3160 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3554 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3161 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3555 | -wattr.border_width, -wattr.border_width, |
3162 | -wattr.border_width, -wattr.border_width, |
3556 | &x, &y, &wdummy); |
3163 | &x, &y, &wdummy); |
3557 | tt_printf ("\033[3;%d;%dt", x, y); |
3164 | tt_printf ("\033[3;%d;%dt", x, y); |
3558 | break; |
3165 | break; |
3559 | case 14: /* report window size (pixels) */ |
3166 | case 14: /* report window size (pixels) */ |
3560 | XGetWindowAttributes (disp, parent[0], &wattr); |
3167 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3561 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3168 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3562 | break; |
3169 | break; |
3563 | case 18: /* report text area size (chars) */ |
3170 | case 18: /* report text area size (chars) */ |
3564 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3171 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3565 | break; |
3172 | break; |
… | |
… | |
3567 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3174 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3568 | break; |
3175 | break; |
3569 | case 20: /* report icon label */ |
3176 | case 20: /* report icon label */ |
3570 | { |
3177 | { |
3571 | char *s; |
3178 | char *s; |
3572 | XGetIconName (disp, parent[0], &s); |
3179 | XGetIconName (dpy, parent[0], &s); |
3573 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3180 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3574 | XFree (s); |
3181 | XFree (s); |
3575 | } |
3182 | } |
3576 | break; |
3183 | break; |
3577 | case 21: /* report window title */ |
3184 | case 21: /* report window title */ |
3578 | { |
3185 | { |
3579 | char *s; |
3186 | char *s; |
3580 | XFetchName (disp, parent[0], &s); |
3187 | XFetchName (dpy, parent[0], &s); |
3581 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3188 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3582 | XFree (s); |
3189 | XFree (s); |
3583 | } |
3190 | } |
3584 | break; |
3191 | break; |
3585 | } |
3192 | } |
3586 | } |
3193 | } |
… | |
… | |
3589 | /*----------------------------------------------------------------------*/ |
3196 | /*----------------------------------------------------------------------*/ |
3590 | /* |
3197 | /* |
3591 | * get input up until STRING TERMINATOR (or BEL) |
3198 | * get input up until STRING TERMINATOR (or BEL) |
3592 | * ends_how is terminator used. returned input must be free()'d |
3199 | * ends_how is terminator used. returned input must be free()'d |
3593 | */ |
3200 | */ |
3594 | unsigned char * |
3201 | char * |
3595 | rxvt_term::get_to_st (unicode_t &ends_how) |
3202 | rxvt_term::get_to_st (unicode_t &ends_how) |
3596 | { |
3203 | { |
3597 | unicode_t ch; |
3204 | unicode_t ch; |
3598 | bool seen_esc = false; |
3205 | bool seen_esc = false; |
3599 | unsigned int n = 0; |
3206 | unsigned int n = 0; |
… | |
… | |
3613 | seen_esc = true; |
3220 | seen_esc = true; |
3614 | continue; |
3221 | continue; |
3615 | } |
3222 | } |
3616 | else if (ch == C0_BEL || ch == CHAR_ST) |
3223 | else if (ch == C0_BEL || ch == CHAR_ST) |
3617 | break; |
3224 | break; |
|
|
3225 | else if (ch == C0_SYN) |
|
|
3226 | ch = cmd_get8 (); |
3618 | else if (ch < 0x20) |
3227 | else if (ch < 0x20) |
3619 | return NULL; /* other control character - exit */ |
3228 | return NULL; /* other control character - exit */ |
3620 | |
3229 | |
3621 | seen_esc = false; |
3230 | seen_esc = false; |
3622 | |
3231 | |
3623 | if (n >= STRING_MAX - 1) |
3232 | if (n >= STRING_MAX - 1) |
3624 | // stop at some sane length |
3233 | // stop at some sane length |
3625 | return NULL; |
3234 | return NULL; |
3626 | |
3235 | |
3627 | if (ch == C0_SYN) |
|
|
3628 | string[n++] = cmd_get8 (); |
|
|
3629 | else |
|
|
3630 | string[n++] = ch; |
3236 | string[n++] = ch; |
3631 | } |
3237 | } |
3632 | |
3238 | |
3633 | string[n++] = '\0'; |
3239 | string[n++] = '\0'; |
3634 | |
3240 | |
3635 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3241 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3636 | |
3242 | |
3637 | return (unsigned char *)rxvt_wcstombs (string); |
3243 | return rxvt_wcstombs (string); |
3638 | } |
3244 | } |
3639 | |
3245 | |
3640 | /*----------------------------------------------------------------------*/ |
3246 | /*----------------------------------------------------------------------*/ |
3641 | /* |
3247 | /* |
3642 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3248 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3643 | */ |
3249 | */ |
3644 | void |
3250 | void |
3645 | rxvt_term::process_dcs_seq () |
3251 | rxvt_term::process_dcs_seq () |
3646 | { |
3252 | { |
3647 | unsigned char *s; |
3253 | char *s; |
3648 | unicode_t eh; |
3254 | unicode_t eh; |
3649 | |
3255 | |
3650 | /* |
3256 | /* |
3651 | * Not handled yet |
3257 | * Not handled yet |
3652 | */ |
3258 | */ |
… | |
… | |
3671 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3277 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3672 | arg = arg * 10 + (ch - '0'); |
3278 | arg = arg * 10 + (ch - '0'); |
3673 | |
3279 | |
3674 | if (ch == ';') |
3280 | if (ch == ';') |
3675 | { |
3281 | { |
3676 | unsigned char *s = get_to_st (eh); |
3282 | char *s = get_to_st (eh); |
3677 | |
3283 | |
3678 | if (s) |
3284 | if (s) |
3679 | { |
3285 | { |
3680 | process_xterm_seq (arg, (char *)s, eh); |
3286 | process_xterm_seq (arg, s, eh); |
3681 | free (s); |
3287 | free (s); |
3682 | } |
3288 | } |
3683 | } |
3289 | } |
3684 | } |
3290 | } |
3685 | |
3291 | |
3686 | void |
3292 | void |
3687 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3293 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3688 | { |
3294 | { |
3689 | if (str[0] == '?' && !str[1]) |
3295 | if (str[0] == '?' && !str[1]) |
3690 | { |
3296 | { |
3691 | unsigned short r, g, b; |
3297 | rgba c; |
3692 | pix_colors_focused[color].get (display, r, g, b); |
3298 | pix_colors_focused[color].get (c); |
|
|
3299 | |
|
|
3300 | #if XFT |
|
|
3301 | if (c.a != rgba::MAX_CC) |
|
|
3302 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3303 | else |
|
|
3304 | #endif |
3693 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3305 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3694 | } |
3306 | } |
3695 | else |
3307 | else |
3696 | set_window_color (color, str); |
3308 | set_window_color (color, str); |
3697 | } |
3309 | } |
3698 | |
3310 | |
3699 | /* |
3311 | /* |
3700 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3312 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3701 | */ |
3313 | */ |
3702 | void |
3314 | void |
3703 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3315 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3704 | { |
3316 | { |
3705 | int changed = 0; |
|
|
3706 | int color; |
3317 | int color; |
3707 | char *buf, *name; |
3318 | char *buf, *name; |
3708 | bool query = str[0] == '?' && !str[1]; |
3319 | bool query = str[0] == '?' && !str[1]; |
3709 | int saveop = op; |
3320 | int saveop = op; |
3710 | dDisp; |
3321 | |
|
|
3322 | dLocal (Display *, dpy); |
3711 | |
3323 | |
3712 | assert (str != NULL); |
3324 | assert (str != NULL); |
|
|
3325 | |
|
|
3326 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3327 | return; |
|
|
3328 | |
3713 | switch (op) |
3329 | switch (op) |
3714 | { |
3330 | { |
3715 | case XTerm_name: |
3331 | case XTerm_name: |
3716 | set_title (str); |
3332 | set_title (str); |
3717 | /* FALLTHROUGH */ |
3333 | /* FALLTHROUGH */ |
… | |
… | |
3731 | unsigned long bytes_after; |
3347 | unsigned long bytes_after; |
3732 | unsigned char *value = 0; |
3348 | unsigned char *value = 0; |
3733 | const char *str = ""; |
3349 | const char *str = ""; |
3734 | |
3350 | |
3735 | if (prop |
3351 | if (prop |
3736 | && XGetWindowProperty (disp, parent[0], |
3352 | && XGetWindowProperty (dpy, parent[0], |
3737 | prop, 0, 1<<16, 0, AnyPropertyType, |
3353 | prop, 0, 1<<16, 0, AnyPropertyType, |
3738 | &actual_type, &actual_format, |
3354 | &actual_type, &actual_format, |
3739 | &nitems, &bytes_after, &value) == Success |
3355 | &nitems, &bytes_after, &value) == Success |
3740 | && actual_type != None |
3356 | && actual_type != None |
3741 | && actual_format == 8) |
3357 | && actual_format == 8) |
3742 | str = (const char *)(value); |
3358 | str = (const char *)(value); |
3743 | |
3359 | |
3744 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3360 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3745 | |
3361 | |
3746 | XFree (value); |
3362 | XFree (value); |
3747 | } |
3363 | } |
3748 | else |
3364 | else |
3749 | { |
3365 | { |
… | |
… | |
3753 | { |
3369 | { |
3754 | *eq = 0; |
3370 | *eq = 0; |
3755 | set_utf8_property (display->atom (str), eq + 1); |
3371 | set_utf8_property (display->atom (str), eq + 1); |
3756 | } |
3372 | } |
3757 | else |
3373 | else |
3758 | XDeleteProperty (disp, parent[0], |
3374 | XDeleteProperty (dpy, parent[0], |
3759 | display->atom (str)); |
3375 | display->atom (str)); |
3760 | } |
3376 | } |
3761 | break; |
3377 | break; |
3762 | |
3378 | |
3763 | case XTerm_Color: |
3379 | case XTerm_Color: |
… | |
… | |
3765 | { |
3381 | { |
3766 | if ((name = strchr (buf, ';')) == NULL) |
3382 | if ((name = strchr (buf, ';')) == NULL) |
3767 | break; |
3383 | break; |
3768 | |
3384 | |
3769 | *name++ = '\0'; |
3385 | *name++ = '\0'; |
3770 | color = atoi (buf); |
3386 | color = atoi (buf) + minCOLOR; |
3771 | |
3387 | |
3772 | if (color < 0 || color >= TOTAL_COLORS) |
3388 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3773 | break; |
3389 | break; |
3774 | |
3390 | |
3775 | if ((buf = strchr (name, ';')) != NULL) |
3391 | if ((buf = strchr (name, ';')) != NULL) |
3776 | *buf++ = '\0'; |
3392 | *buf++ = '\0'; |
3777 | |
3393 | |
3778 | if (name[0] == '?' && !name[1]) |
3394 | 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 | } |
3395 | } |
3787 | break; |
3396 | break; |
3788 | case XTerm_Color00: |
3397 | case XTerm_Color00: |
3789 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3398 | process_color_seq (op, Color_fg, str, resp); |
3790 | break; |
3399 | break; |
3791 | case XTerm_Color01: |
3400 | case XTerm_Color01: |
3792 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3401 | process_color_seq (op, Color_bg, str, resp); |
3793 | break; |
3402 | break; |
3794 | #ifndef NO_CURSORCOLOR |
3403 | #ifndef NO_CURSORCOLOR |
3795 | case XTerm_Color_cursor: |
3404 | case XTerm_Color_cursor: |
3796 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3405 | process_color_seq (op, Color_cursor, str, resp); |
3797 | break; |
3406 | break; |
3798 | #endif |
3407 | #endif |
3799 | case XTerm_Color_pointer_fg: |
3408 | case XTerm_Color_pointer_fg: |
3800 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3409 | process_color_seq (op, Color_pointer_fg, str, resp); |
3801 | break; |
3410 | break; |
3802 | case XTerm_Color_pointer_bg: |
3411 | case XTerm_Color_pointer_bg: |
3803 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3412 | process_color_seq (op, Color_pointer_bg, str, resp); |
3804 | break; |
3413 | break; |
3805 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3414 | #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: |
3415 | case XTerm_Color_RV: |
3813 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3416 | process_color_seq (op, Color_RV, str, resp); |
|
|
3417 | break; |
|
|
3418 | case Rxvt_Color_BD: |
|
|
3419 | case URxvt_Color_BD: |
|
|
3420 | process_color_seq (op, Color_BD, str, resp); |
|
|
3421 | break; |
|
|
3422 | case Rxvt_Color_UL: |
|
|
3423 | case URxvt_Color_UL: |
|
|
3424 | process_color_seq (op, Color_UL, str, resp); |
3814 | break; |
3425 | break; |
3815 | case URxvt_Color_IT: |
3426 | case URxvt_Color_IT: |
3816 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3427 | process_color_seq (op, Color_IT, str, resp); |
3817 | break; |
3428 | break; |
3818 | #endif |
3429 | #endif |
3819 | #if TRANSPARENT && TINTING |
3430 | #if ENABLE_TRANSPARENCY |
3820 | case URxvt_Color_tint: |
3431 | case URxvt_Color_tint: |
3821 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3432 | process_color_seq (op, Color_tint, str, resp); |
3822 | check_our_parents (); |
3433 | { |
3823 | if (am_transparent) |
3434 | bool changed = false; |
3824 | want_full_refresh = want_refresh = 1; |
3435 | if (ISSET_PIXCOLOR (Color_tint)) |
3825 | break; |
3436 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
3826 | #endif |
3437 | else |
|
|
3438 | changed = bgPixmap.unset_tint (); |
|
|
3439 | if (changed) |
|
|
3440 | bgPixmap.render (); |
|
|
3441 | } |
3827 | |
3442 | |
|
|
3443 | break; |
|
|
3444 | #endif |
|
|
3445 | |
|
|
3446 | #if XPM_BACKGROUND |
3828 | case XTerm_Pixmap: |
3447 | case Rxvt_Pixmap: |
3829 | if (*str != ';') |
3448 | if (!strcmp (str, "?")) |
3830 | { |
3449 | { |
3831 | #if XPM_BACKGROUND |
3450 | char str[256]; |
3832 | scale_pixmap (""); /* reset to default scaling */ |
3451 | |
3833 | set_bgPixmap (str); /* change pixmap */ |
3452 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3834 | #endif |
3453 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3835 | scr_touch (true); |
3454 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3455 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3836 | } |
3456 | } |
3837 | while ((str = strchr (str, ';')) != NULL) |
3457 | else |
3838 | { |
3458 | { |
|
|
3459 | int changed = 0; |
|
|
3460 | |
|
|
3461 | if (*str != ';') |
|
|
3462 | { |
|
|
3463 | /* reset to default scaling :*/ |
|
|
3464 | bgPixmap.unset_geometry (); |
|
|
3465 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3466 | changed++; |
|
|
3467 | str = strchr (str, ';'); |
|
|
3468 | if (str == NULL) |
|
|
3469 | bgPixmap.set_defaultGeometry (); |
|
|
3470 | } |
|
|
3471 | while (str) |
|
|
3472 | { |
3839 | str++; |
3473 | str++; |
3840 | #if XPM_BACKGROUND |
3474 | if (bgPixmap.set_geometry (str)) |
3841 | changed += scale_pixmap (str); |
3475 | changed++; |
3842 | #endif |
3476 | str = strchr (str, ';'); |
|
|
3477 | } |
|
|
3478 | if (changed) |
|
|
3479 | { |
|
|
3480 | bgPixmap.render (); |
|
|
3481 | scr_touch (true); |
|
|
3482 | } |
3843 | } |
3483 | } |
3844 | |
|
|
3845 | if (changed) |
|
|
3846 | { |
|
|
3847 | #ifdef XPM_BACKGROUND |
|
|
3848 | resize_pixmap (); |
|
|
3849 | #endif |
|
|
3850 | scr_touch (true); |
|
|
3851 | } |
|
|
3852 | break; |
3484 | break; |
|
|
3485 | #endif |
3853 | |
3486 | |
3854 | case XTerm_restoreFG: |
3487 | case Rxvt_restoreFG: |
3855 | set_window_color (Color_fg, str); |
3488 | set_window_color (Color_fg, str); |
3856 | break; |
3489 | break; |
3857 | case XTerm_restoreBG: |
3490 | case Rxvt_restoreBG: |
3858 | set_window_color (Color_bg, str); |
3491 | set_window_color (Color_bg, str); |
3859 | break; |
3492 | break; |
3860 | |
3493 | |
3861 | case XTerm_logfile: |
3494 | case XTerm_logfile: |
3862 | // TODO, when secure mode? |
3495 | // TODO, when secure mode? |
3863 | break; |
3496 | break; |
3864 | |
3497 | |
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 |
3498 | #if 0 |
3872 | case XTerm_dumpscreen: /* no error notices */ |
3499 | case Rxvt_dumpscreen: /* no error notices */ |
3873 | { |
3500 | { |
3874 | int fd; |
3501 | int fd; |
3875 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3502 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3876 | { |
3503 | { |
3877 | scr_dump (fd); |
3504 | scr_dump (fd); |
… | |
… | |
3888 | case URxvt_italicFont: |
3515 | case URxvt_italicFont: |
3889 | case URxvt_boldItalicFont: |
3516 | case URxvt_boldItalicFont: |
3890 | #endif |
3517 | #endif |
3891 | if (query) |
3518 | if (query) |
3892 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3519 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3893 | (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3520 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3894 | ? fontset[op - URxvt_font]->fontdesc : "", |
3521 | ? fontset[op - URxvt_font]->fontdesc : "", |
3895 | resp); |
3522 | resp); |
3896 | else |
3523 | else |
3897 | { |
3524 | { |
3898 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3525 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3901 | allocated.push_back ((void *)res); |
3528 | allocated.push_back ((void *)res); |
3902 | set_fonts (); |
3529 | set_fonts (); |
3903 | } |
3530 | } |
3904 | break; |
3531 | break; |
3905 | |
3532 | |
3906 | #if ENABLE_FRILLS |
3533 | case URxvt_version: |
|
|
3534 | if (query) |
|
|
3535 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3536 | op, |
|
|
3537 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3538 | resp); |
|
|
3539 | break; |
|
|
3540 | |
|
|
3541 | #if !ENABLE_MINIMAL |
3907 | case URxvt_locale: |
3542 | case URxvt_locale: |
3908 | if (query) |
3543 | if (query) |
3909 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
3544 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
3910 | else |
3545 | else |
3911 | { |
3546 | { |
3912 | set_locale (str); |
3547 | set_locale (str); |
3913 | pty.set_utf8_mode (enc_utf8); |
3548 | pty->set_utf8_mode (enc_utf8); |
3914 | init_xlocale (); |
3549 | init_xlocale (); |
3915 | } |
3550 | } |
3916 | break; |
3551 | break; |
3917 | |
3552 | |
3918 | case URxvt_view_up: |
3553 | case URxvt_view_up: |
3919 | case URxvt_view_down: |
3554 | case URxvt_view_down: |
|
|
3555 | { |
3920 | int lines = atoi (str); |
3556 | int lines = atoi (str); |
3921 | |
3557 | |
3922 | if (lines) |
3558 | if (lines) |
3923 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3559 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3924 | else |
3560 | else |
3925 | { |
|
|
3926 | scr_erase_savelines (); |
3561 | scr_erase_savelines (); |
3927 | } |
3562 | } |
3928 | |
3563 | |
|
|
3564 | break; |
|
|
3565 | #endif |
|
|
3566 | |
|
|
3567 | #if ENABLE_PERL |
|
|
3568 | case URxvt_perl: |
|
|
3569 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
|
|
3570 | ; // no responses yet |
3929 | break; |
3571 | break; |
3930 | #endif |
3572 | #endif |
3931 | } |
3573 | } |
3932 | } |
3574 | } |
3933 | /*----------------------------------------------------------------------*/ |
3575 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3964 | return state; |
3606 | return state; |
3965 | } |
3607 | } |
3966 | |
3608 | |
3967 | /* we're not using priv _yet_ */ |
3609 | /* we're not using priv _yet_ */ |
3968 | void |
3610 | void |
3969 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3611 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
3970 | { |
3612 | { |
3971 | unsigned int i, j; |
3613 | unsigned int i, j; |
3972 | int state; |
3614 | int state; |
3973 | |
3615 | |
3974 | static const struct |
3616 | static const struct |
3975 | { |
3617 | { |
3976 | const int argval; |
3618 | const int argval; |
3977 | const unsigned long bit; |
3619 | const unsigned long bit; |
3978 | } |
|
|
3979 | |
|
|
3980 | argtopriv[] = { |
3620 | } argtopriv[] = { |
3981 | { 1, PrivMode_aplCUR }, |
3621 | { 1, PrivMode_aplCUR }, |
3982 | { 2, PrivMode_vt52 }, |
3622 | { 2, PrivMode_vt52 }, |
3983 | { 3, PrivMode_132 }, |
3623 | { 3, PrivMode_132 }, |
3984 | { 4, PrivMode_smoothScroll }, |
3624 | { 4, PrivMode_smoothScroll }, |
3985 | { 5, PrivMode_rVideo }, |
3625 | { 5, PrivMode_rVideo }, |
3986 | { 6, PrivMode_relOrigin }, |
3626 | { 6, PrivMode_relOrigin }, |
3987 | { 7, PrivMode_Autowrap }, |
3627 | { 7, PrivMode_Autowrap }, |
3988 | // 8, bi-directional support mode |
3628 | // 8, bi-directional support mode |
3989 | { 9, PrivMode_MouseX10 }, |
3629 | { 9, PrivMode_MouseX10 }, |
3990 | #ifdef menuBar_esc |
|
|
3991 | { menuBar_esc, PrivMode_menuBar }, |
|
|
3992 | #endif |
|
|
3993 | // 18, 19 printing-related |
3630 | // 18, 19 printing-related |
3994 | { 25, PrivMode_VisibleCursor }, |
3631 | { 25, PrivMode_VisibleCursor }, |
3995 | #ifdef scrollBar_esc |
3632 | #ifdef scrollBar_esc |
3996 | { scrollBar_esc, PrivMode_scrollBar }, |
3633 | { scrollBar_esc, PrivMode_scrollBar }, |
3997 | #endif |
3634 | #endif |
… | |
… | |
4042 | } |
3679 | } |
4043 | |
3680 | |
4044 | /* extra handling for values with state unkept */ |
3681 | /* extra handling for values with state unkept */ |
4045 | switch (arg[i]) |
3682 | switch (arg[i]) |
4046 | { |
3683 | { |
|
|
3684 | #if ENABLE_STYLES |
|
|
3685 | case 1021: |
|
|
3686 | set_option (Opt_intensityStyles, mode); |
|
|
3687 | |
|
|
3688 | scr_touch (true); |
|
|
3689 | break; |
|
|
3690 | #endif |
4047 | case 1048: /* alternative cursor save */ |
3691 | case 1048: /* alternative cursor save */ |
4048 | case 1049: |
3692 | case 1049: |
4049 | if (options & Opt_secondaryScreen) |
3693 | if (option (Opt_secondaryScreen)) |
4050 | if (mode == 0) |
3694 | if (mode == 0) |
4051 | scr_cursor (RESTORE); |
3695 | scr_cursor (RESTORE); |
4052 | else if (mode == 1) |
3696 | else if (mode == 1) |
4053 | scr_cursor (SAVE); |
3697 | scr_cursor (SAVE); |
4054 | break; |
3698 | break; |
… | |
… | |
4069 | case 3: /* 80/132 */ |
3713 | case 3: /* 80/132 */ |
4070 | if (priv_modes & PrivMode_132OK) |
3714 | if (priv_modes & PrivMode_132OK) |
4071 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3715 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4072 | break; |
3716 | break; |
4073 | case 4: /* smooth scrolling */ |
3717 | case 4: /* smooth scrolling */ |
4074 | if (state) |
|
|
4075 | options &= ~Opt_jumpScroll; |
|
|
4076 | else |
|
|
4077 | options |= Opt_jumpScroll; |
3718 | set_option (Opt_jumpScroll, !state); |
4078 | break; |
3719 | break; |
4079 | case 5: /* reverse video */ |
3720 | case 5: /* reverse video */ |
4080 | scr_rvideo_mode (state); |
3721 | scr_rvideo_mode (state); |
4081 | break; |
3722 | break; |
4082 | case 6: /* relative/absolute origins */ |
3723 | case 6: /* relative/absolute origins */ |
… | |
… | |
4088 | /* case 8: - auto repeat, can't do on a per window basis */ |
3729 | /* case 8: - auto repeat, can't do on a per window basis */ |
4089 | case 9: /* X10 mouse reporting */ |
3730 | case 9: /* X10 mouse reporting */ |
4090 | if (state) /* orthogonal */ |
3731 | if (state) /* orthogonal */ |
4091 | priv_modes &= ~PrivMode_MouseX11; |
3732 | priv_modes &= ~PrivMode_MouseX11; |
4092 | break; |
3733 | 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 |
3734 | #ifdef scrollBar_esc |
4101 | case scrollBar_esc: |
3735 | case scrollBar_esc: |
4102 | if (scrollbar_mapping (state)) |
3736 | if (scrollbar_mapping (state)) |
4103 | { |
3737 | { |
4104 | resize_all_windows (0, 0, 0); |
3738 | resize_all_windows (0, 0, 0); |
… | |
… | |
4123 | #if 0 |
3757 | #if 0 |
4124 | case 1001: |
3758 | case 1001: |
4125 | break; /* X11 mouse highlighting */ |
3759 | break; /* X11 mouse highlighting */ |
4126 | #endif |
3760 | #endif |
4127 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3761 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4128 | if (state) |
|
|
4129 | options &= ~Opt_scrollTtyOutput; |
|
|
4130 | else |
|
|
4131 | options |= Opt_scrollTtyOutput; |
3762 | set_option (Opt_scrollTtyOutput, !state); |
4132 | break; |
3763 | break; |
4133 | case 1011: /* scroll to bottom on key press */ |
3764 | case 1011: /* scroll to bottom on key press */ |
4134 | if (state) |
|
|
4135 | options |= Opt_scrollTtyKeypress; |
3765 | set_option (Opt_scrollTtyKeypress, state); |
4136 | else |
|
|
4137 | options &= ~Opt_scrollTtyKeypress; |
|
|
4138 | break; |
3766 | break; |
4139 | case 1047: /* secondary screen w/ clearing last */ |
3767 | case 1047: /* secondary screen w/ clearing last */ |
4140 | if (options & Opt_secondaryScreen) |
3768 | if (option (Opt_secondaryScreen)) |
4141 | if (current_screen != PRIMARY) |
3769 | if (current_screen != PRIMARY) |
4142 | scr_erase_screen (2); |
3770 | scr_erase_screen (2); |
4143 | scr_change_screen (state); |
3771 | scr_change_screen (state); |
4144 | break; |
3772 | break; |
4145 | case 1049: /* secondary screen w/ clearing first */ |
3773 | case 1049: /* secondary screen w/ clearing first */ |
4146 | scr_change_screen (state); |
3774 | scr_change_screen (state); |
4147 | if (options & Opt_secondaryScreen) |
3775 | if (option (Opt_secondaryScreen)) |
4148 | if (current_screen != PRIMARY) |
3776 | if (current_screen != PRIMARY) |
4149 | scr_erase_screen (2); |
3777 | scr_erase_screen (2); |
4150 | break; |
3778 | break; |
4151 | default: |
3779 | default: |
4152 | break; |
3780 | break; |
… | |
… | |
4280 | scr_color (Color_bg, Color_bg); |
3908 | scr_color (Color_bg, Color_bg); |
4281 | break; |
3909 | break; |
4282 | |
3910 | |
4283 | //case 50: // not variable spacing |
3911 | //case 50: // not variable spacing |
4284 | |
3912 | |
4285 | #ifndef NO_BRIGHTCOLOR |
3913 | #if !ENABLE_MINIMAL |
4286 | case 90: |
3914 | case 90: |
4287 | case 91: /* set bright fg color */ |
3915 | case 91: /* set bright fg color */ |
4288 | case 92: |
3916 | case 92: |
4289 | case 93: |
3917 | case 93: |
4290 | case 94: |
3918 | case 94: |
… | |
… | |
4302 | case 106: |
3930 | case 106: |
4303 | case 107: |
3931 | case 107: |
4304 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
3932 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4305 | break; |
3933 | break; |
4306 | #endif |
3934 | #endif |
4307 | |
|
|
4308 | } |
3935 | } |
4309 | } |
3936 | } |
4310 | } |
3937 | } |
4311 | /*}}} */ |
3938 | /*}}} */ |
4312 | |
3939 | |
… | |
… | |
4336 | */ |
3963 | */ |
4337 | void |
3964 | void |
4338 | rxvt_term::tt_printf (const char *fmt,...) |
3965 | rxvt_term::tt_printf (const char *fmt,...) |
4339 | { |
3966 | { |
4340 | va_list arg_ptr; |
3967 | va_list arg_ptr; |
4341 | unsigned char buf[256]; |
3968 | char buf[256]; |
4342 | |
3969 | |
4343 | va_start (arg_ptr, fmt); |
3970 | va_start (arg_ptr, fmt); |
4344 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
3971 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4345 | va_end (arg_ptr); |
3972 | va_end (arg_ptr); |
4346 | tt_write (buf, strlen (buf)); |
3973 | tt_write (buf, strlen (buf)); |
… | |
… | |
4351 | * or generated by us in response to a query ESC sequence. |
3978 | * or generated by us in response to a query ESC sequence. |
4352 | */ |
3979 | */ |
4353 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
3980 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4354 | |
3981 | |
4355 | void |
3982 | void |
4356 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
3983 | rxvt_term::tt_write (const char *data, unsigned int len) |
4357 | { |
3984 | { |
|
|
3985 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
3986 | return; |
|
|
3987 | |
|
|
3988 | if (pty->pty < 0) |
|
|
3989 | return; |
|
|
3990 | |
4358 | if (v_buflen == 0) |
3991 | if (v_buflen == 0) |
4359 | { |
3992 | { |
4360 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
3993 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4361 | |
3994 | |
4362 | if ((unsigned int)written == len) |
3995 | if ((unsigned int)written == len) |
4363 | return; |
3996 | return; |
4364 | |
3997 | |
4365 | data += written; |
3998 | data += written; |
4366 | len -= written; |
3999 | len -= written; |
4367 | } |
4000 | } |
4368 | |
4001 | |
4369 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4002 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4370 | |
4003 | |
4371 | memcpy (v_buffer + v_buflen, data, len); |
4004 | memcpy (v_buffer + v_buflen, data, len); |
4372 | v_buflen += len; |
4005 | v_buflen += len; |
4373 | |
4006 | |
4374 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4007 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4375 | } |
4008 | } |
4376 | |
4009 | |
4377 | void rxvt_term::pty_write () |
4010 | void rxvt_term::pty_write () |
4378 | { |
4011 | { |
4379 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4012 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4380 | |
4013 | |
4381 | if (written > 0) |
4014 | if (written > 0) |
4382 | { |
4015 | { |
4383 | v_buflen -= written; |
4016 | v_buflen -= written; |
4384 | |
4017 | |