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-2006 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> |
|
|
31 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
31 | * |
32 | * |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * 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 |
34 | * 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 |
35 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
36 | * (at your option) any later version. |
… | |
… | |
49 | #include "rxvt.h" |
50 | #include "rxvt.h" |
50 | #include "rxvtperl.h" |
51 | #include "rxvtperl.h" |
51 | #include "version.h" |
52 | #include "version.h" |
52 | #include "command.h" |
53 | #include "command.h" |
53 | |
54 | |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #ifdef KEYSYM_RESOURCE |
55 | #ifdef KEYSYM_RESOURCE |
60 | # include "keyboard.h" |
56 | # include "keyboard.h" |
61 | #endif |
57 | #endif |
62 | |
58 | |
63 | #include <csignal> |
59 | #include <csignal> |
64 | |
60 | |
|
|
61 | #if LINUX_YIELD_HACK |
|
|
62 | # include <ctime> |
|
|
63 | #endif |
|
|
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
68 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
70 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
99 | XK_Shift_L, 0x21e7, |
96 | XK_Shift_L, 0x21e7, |
100 | XK_Shift_R, 0x21e7, |
97 | XK_Shift_R, 0x21e7, |
101 | |
98 | |
102 | XK_Shift_Lock, 0x21eb, |
99 | XK_Shift_Lock, 0x21eb, |
103 | XK_ISO_Lock, 0x21eb, |
100 | XK_ISO_Lock, 0x21eb, |
104 | XK_ISO_Lock, 0x21eb, |
|
|
105 | XK_Caps_Lock, 0x21ec, |
101 | XK_Caps_Lock, 0x21ec, |
106 | XK_Num_Lock, 0x21ed, |
102 | XK_Num_Lock, 0x21ed, |
107 | XK_ISO_Level3_Shift, 0x21ee, |
103 | XK_ISO_Level3_Shift, 0x21ee, |
108 | XK_ISO_Level3_Lock, 0x21ef, |
104 | XK_ISO_Level3_Lock, 0x21ef, |
109 | XK_ISO_Group_Lock, 0x21f0, |
105 | XK_ISO_Group_Lock, 0x21f0, |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
144 | return; |
149 | |
145 | |
150 | for (;;) |
146 | for (;;) |
151 | { |
147 | { |
152 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
153 | |
149 | |
154 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
155 | |
151 | |
156 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
157 | { |
153 | { |
… | |
… | |
166 | |
162 | |
167 | void |
163 | void |
168 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) |
169 | { |
165 | { |
170 | rxvt_fontset *fs = FONTSET (r); |
166 | rxvt_fontset *fs = FONTSET (r); |
171 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
|
|
172 | wchar_t *chr, *alloc, ch2, *fname; |
167 | wchar_t *chr, *alloc, ch2, **fname; |
173 | int len; |
168 | int len; |
174 | |
|
|
175 | fname = rxvt_utf8towcs (f->name); |
|
|
176 | |
169 | |
177 | # if ENABLE_COMBINING |
170 | # if ENABLE_COMBINING |
178 | if (IS_COMPOSE (ch)) |
171 | if (IS_COMPOSE (ch)) |
179 | { |
172 | { |
180 | len = rxvt_composite.expand (ch, 0); |
173 | len = rxvt_composite.expand (ch, 0); |
… | |
… | |
201 | r & RS_Blink ? " blink" : "", |
194 | r & RS_Blink ? " blink" : "", |
202 | r & RS_RVid ? " rvid" : "", |
195 | r & RS_RVid ? " rvid" : "", |
203 | r & RS_Uline ? " uline" : "", |
196 | r & RS_Uline ? " uline" : "", |
204 | r & RS_Careful ? " careful" : ""); |
197 | r & RS_Careful ? " careful" : ""); |
205 | |
198 | |
|
|
199 | int width = 0; |
|
|
200 | fname = rxvt_temp_buf<wchar_t *> (len); |
|
|
201 | for (int i = 0; i < len; i++) |
|
|
202 | { |
|
|
203 | rxvt_font *f = (*fs)[fs->find_font_idx (chr[i])]; |
|
|
204 | fname[i] = rxvt_utf8towcs (f->name); |
206 | int width = wcswidth (fname, wcslen (fname)); |
205 | max_it (width, wcswidth (fname[i], wcslen (fname[i]))); |
|
|
206 | } |
207 | |
207 | |
208 | max_it (width, 8+5); // for char + hey |
208 | max_it (width, 8+5); // for char + hex |
209 | max_it (width, strlen (attr)); |
209 | max_it (width, strlen (attr)); |
210 | |
210 | |
211 | if (y >= 0) |
211 | if (y >= 0) |
212 | { |
212 | { |
213 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
213 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
214 | x = 0; |
214 | x = 0; |
215 | } |
215 | } |
216 | |
216 | |
217 | scr_overlay_new (x, y, width, len + 2); |
217 | scr_overlay_new (x, y, width, len * 2 + 1); |
218 | |
218 | |
219 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
219 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
220 | |
220 | |
221 | for (int y = 0; y < len; y++) |
221 | for (int y = 0; y < len; y++) |
222 | { |
222 | { |
… | |
… | |
225 | ch = *chr++; |
225 | ch = *chr++; |
226 | |
226 | |
227 | sprintf (buf, "%8x", ch); |
227 | sprintf (buf, "%8x", ch); |
228 | scr_overlay_set (0, y, buf); |
228 | scr_overlay_set (0, y, buf); |
229 | scr_overlay_set (9, y, '='); |
229 | scr_overlay_set (9, y, '='); |
230 | # if !UNICODE3 |
230 | # if !UNICODE_3 |
231 | if (ch >= 0x10000) |
231 | if (ch >= 0x10000) |
232 | ch = 0xfffd; |
232 | ch = 0xfffd; |
233 | # endif |
233 | # endif |
234 | scr_overlay_set (11, y, ch, r); |
234 | scr_overlay_set (11, y, ch, r); |
|
|
235 | |
|
|
236 | if (WCWIDTH (ch) >= 2) |
235 | scr_overlay_set (12, y, NOCHAR, r); |
237 | scr_overlay_set (12, y, NOCHAR, r); |
236 | } |
238 | } |
237 | |
239 | |
|
|
240 | // { |
|
|
241 | // char buf[4+4+3+1]; |
|
|
242 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
243 | // scr_overlay_set (0, 0, buf); |
|
|
244 | // } |
238 | scr_overlay_set (0, len , attr); |
245 | scr_overlay_set (0, len , attr); |
|
|
246 | for (int i = 0; i < len; i++) |
|
|
247 | { |
239 | scr_overlay_set (0, len + 1, fname); |
248 | scr_overlay_set (0, len + 1 + i, fname[i]); |
240 | |
|
|
241 | free (fname); |
249 | free (fname[i]); |
|
|
250 | } |
242 | |
251 | |
243 | # if ENABLE_COMBINING |
252 | # if ENABLE_COMBINING |
244 | if (alloc) |
253 | if (alloc) |
245 | delete [] alloc; |
254 | delete [] alloc; |
246 | # endif |
255 | # endif |
… | |
… | |
276 | } |
285 | } |
277 | |
286 | |
278 | iso14755buf = 0; |
287 | iso14755buf = 0; |
279 | } |
288 | } |
280 | |
289 | |
281 | int |
290 | static int |
282 | rxvt_term::hex_keyval (XKeyEvent &ev) |
291 | hex_keyval (XKeyEvent &ev) |
283 | { |
292 | { |
284 | // check wether this event corresponds to a hex digit |
293 | // check whether this event corresponds to a hex digit |
285 | // if the modifiers had not been pressed. |
294 | // if the modifiers had not been pressed. |
286 | for (int index = 0; index < 8; index++) |
295 | for (int index = 0; index < 8; index++) |
287 | { |
296 | { |
288 | KeySym k = XLookupKeysym (&ev, index); |
297 | KeySym k = XLookupKeysym (&ev, index); |
289 | |
298 | |
… | |
… | |
295 | |
304 | |
296 | return -1; |
305 | return -1; |
297 | } |
306 | } |
298 | #endif |
307 | #endif |
299 | |
308 | |
300 | /*{{{ Convert the keypress event into a string */ |
309 | static inline KeySym |
|
|
310 | translate_keypad (KeySym keysym, bool kp) |
|
|
311 | { |
|
|
312 | #ifdef XK_KP_Home |
|
|
313 | static const KeySym keypadtrans[] = { |
|
|
314 | XK_KP_7, // XK_KP_Home |
|
|
315 | XK_KP_4, // XK_KP_Left |
|
|
316 | XK_KP_8, // XK_KP_Up |
|
|
317 | XK_KP_6, // XK_KP_Right |
|
|
318 | XK_KP_2, // XK_KP_Down |
|
|
319 | # ifndef UNSHIFTED_SCROLLKEYS |
|
|
320 | XK_KP_9, // XK_KP_Prior |
|
|
321 | XK_KP_3, // XK_KP_Next |
|
|
322 | # else |
|
|
323 | XK_Prior, |
|
|
324 | XK_Next, |
|
|
325 | # endif |
|
|
326 | XK_KP_1, // XK_KP_End |
|
|
327 | XK_KP_5, // XK_KP_Begin |
|
|
328 | }; |
|
|
329 | |
|
|
330 | if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) |
|
|
331 | { |
|
|
332 | unsigned int index = keysym - XK_KP_Home; |
|
|
333 | keysym = kp ? keypadtrans[index] : XK_Home + index; |
|
|
334 | } |
|
|
335 | else if (keysym == XK_KP_Insert) |
|
|
336 | keysym = kp ? XK_KP_0 : XK_Insert; |
|
|
337 | # ifndef NO_DELETE_KEY |
|
|
338 | else if (keysym == XK_KP_Delete) |
|
|
339 | keysym = kp ? XK_KP_Decimal : XK_Delete; |
|
|
340 | # endif |
|
|
341 | #endif |
|
|
342 | return keysym; |
|
|
343 | } |
|
|
344 | |
|
|
345 | static inline int |
|
|
346 | map_function_key (KeySym keysym) |
|
|
347 | { |
|
|
348 | int param = 0; |
|
|
349 | |
|
|
350 | if (IN_RANGE_INC (keysym, XK_F1, XK_F35)) |
|
|
351 | { |
|
|
352 | param = 11 + keysym - XK_F1; |
|
|
353 | if (keysym >= XK_F17) |
|
|
354 | param += 4; |
|
|
355 | else if (keysym >= XK_F15) |
|
|
356 | param += 3; |
|
|
357 | else if (keysym >= XK_F11) |
|
|
358 | param += 2; |
|
|
359 | else if (keysym >= XK_F6) |
|
|
360 | param += 1; |
|
|
361 | } |
|
|
362 | else |
|
|
363 | switch (keysym) |
|
|
364 | { |
|
|
365 | case XK_Find: |
|
|
366 | param = 1; |
|
|
367 | break; |
|
|
368 | case XK_Insert: |
|
|
369 | param = 2; |
|
|
370 | break; |
|
|
371 | #ifdef DXK_Remove |
|
|
372 | case DXK_Remove: |
|
|
373 | #endif |
|
|
374 | case XK_Execute: |
|
|
375 | param = 3; |
|
|
376 | break; |
|
|
377 | case XK_Select: |
|
|
378 | param = 4; |
|
|
379 | break; |
|
|
380 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
381 | case XK_Prior: |
|
|
382 | param = 5; |
|
|
383 | break; |
|
|
384 | case XK_Next: |
|
|
385 | param = 6; |
|
|
386 | break; |
|
|
387 | case XK_Home: |
|
|
388 | param = 7; |
|
|
389 | break; |
|
|
390 | case XK_End: |
|
|
391 | param = 8; |
|
|
392 | break; |
|
|
393 | #endif |
|
|
394 | case XK_Help: |
|
|
395 | param = 28; |
|
|
396 | break; |
|
|
397 | case XK_Menu: |
|
|
398 | param = 29; |
|
|
399 | break; |
|
|
400 | } |
|
|
401 | return param; |
|
|
402 | } |
|
|
403 | |
301 | void |
404 | void |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
405 | rxvt_term::key_press (XKeyEvent &ev) |
303 | { |
406 | { |
304 | int ctrl, meta, shft, len; |
407 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
|
|
306 | KeySym keysym; |
408 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
409 | int valid_keysym; |
311 | char kbuf[KBUFSZ]; |
410 | char kbuf[KBUFSZ]; |
|
|
411 | |
|
|
412 | #if ISO_14755 |
|
|
413 | if (iso14755buf & ISO_14755_52) |
|
|
414 | return; |
|
|
415 | #endif |
312 | |
416 | |
313 | /* |
417 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
418 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
315 | * escape sequence to toggle the Keypad. |
419 | * escape sequence to toggle the Keypad. |
316 | * |
420 | * |
317 | * Always permit `shift' to override the current setting |
421 | * Always permit `shift' to override the current setting |
318 | */ |
422 | */ |
319 | shft = ev.state & ShiftMask; |
423 | shft = ev.state & ShiftMask; |
320 | ctrl = ev.state & ControlMask; |
424 | ctrl = ev.state & ControlMask; |
321 | meta = ev.state & ModMetaMask; |
425 | meta = ev.state & ModMetaMask; |
322 | |
|
|
323 | if (numlock_state || (ev.state & ModNumLockMask)) |
|
|
324 | { |
|
|
325 | numlock_state = (ev.state & ModNumLockMask); |
|
|
326 | PrivMode ((!numlock_state), PrivMode_aplKP); |
|
|
327 | } |
|
|
328 | |
426 | |
329 | kbuf[0] = 0; |
427 | kbuf[0] = 0; |
330 | |
428 | |
331 | #ifdef USE_XIM |
429 | #ifdef USE_XIM |
332 | if (Input_Context) |
430 | if (Input_Context) |
… | |
… | |
407 | #ifdef PAGING_CONTEXT_LINES |
505 | #ifdef PAGING_CONTEXT_LINES |
408 | lnsppg = nrow - PAGING_CONTEXT_LINES; |
506 | lnsppg = nrow - PAGING_CONTEXT_LINES; |
409 | #else |
507 | #else |
410 | lnsppg = nrow * 4 / 5; |
508 | lnsppg = nrow * 4 / 5; |
411 | #endif |
509 | #endif |
|
|
510 | max_it (lnsppg, 1); |
|
|
511 | |
412 | if (keysym == XK_Prior) |
512 | if (keysym == XK_Prior) |
413 | { |
513 | { |
414 | scr_page (UP, lnsppg); |
514 | scr_page (UP, lnsppg); |
415 | return; |
515 | return; |
416 | } |
516 | } |
… | |
… | |
443 | scr_move_to (0, 1); |
543 | scr_move_to (0, 1); |
444 | return; |
544 | return; |
445 | } |
545 | } |
446 | else if (keysym == XK_End) |
546 | else if (keysym == XK_End) |
447 | { |
547 | { |
448 | scr_move_to (1, 0); |
548 | scr_move_to (1, 1); |
449 | return; |
549 | return; |
450 | } |
550 | } |
451 | } |
551 | } |
452 | #endif |
552 | #endif |
453 | } |
553 | } |
… | |
… | |
464 | { |
564 | { |
465 | switch (keysym) |
565 | switch (keysym) |
466 | { |
566 | { |
467 | /* normal XTerm key bindings */ |
567 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
568 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
569 | selection_request (ev.time); |
470 | return; |
570 | return; |
471 | #if TODO |
571 | #if TODO |
472 | /* rxvt extras */ |
572 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
573 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
574 | change_font (FONT_UP); |
… | |
… | |
481 | } |
581 | } |
482 | } |
582 | } |
483 | |
583 | |
484 | #if ENABLE_FRILLS || ISO_14755 |
584 | #if ENABLE_FRILLS || ISO_14755 |
485 | // ISO 14755 support |
585 | // ISO 14755 support |
486 | if (shft && ctrl) |
586 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51)) |
487 | { |
587 | { |
488 | int hv; |
588 | int hv; |
489 | |
589 | |
490 | if (iso14755buf & ISO_14755_51 |
590 | if (iso14755buf & ISO_14755_51 |
491 | && (keysym == XK_space || keysym == XK_KP_Space |
591 | && (keysym == XK_space || keysym == XK_KP_Space |
… | |
… | |
493 | { |
593 | { |
494 | commit_iso14755 (); |
594 | commit_iso14755 (); |
495 | iso14755buf = ISO_14755_51; |
595 | iso14755buf = ISO_14755_51; |
496 | # if ISO_14755 |
596 | # if ISO_14755 |
497 | iso14755_51 (0); |
597 | iso14755_51 (0); |
|
|
598 | # endif |
|
|
599 | return; |
|
|
600 | } |
|
|
601 | else if (keysym == XK_BackSpace) |
|
|
602 | { |
|
|
603 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
604 | # if ISO_14755 |
|
|
605 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
498 | # endif |
606 | # endif |
499 | return; |
607 | return; |
500 | } |
608 | } |
501 | else if ((hv = hex_keyval (ev)) >= 0) |
609 | else if ((hv = hex_keyval (ev)) >= 0) |
502 | { |
610 | { |
… | |
… | |
507 | # endif |
615 | # endif |
508 | return; |
616 | return; |
509 | } |
617 | } |
510 | else |
618 | else |
511 | { |
619 | { |
512 | # if ENABLE_OVERLAY |
620 | # if ISO_14755 |
513 | scr_overlay_off (); |
621 | scr_overlay_off (); |
514 | # endif |
622 | # endif |
515 | iso14755buf = 0; |
623 | iso14755buf = 0; |
516 | } |
624 | } |
517 | } |
625 | } |
|
|
626 | else if (option (Opt_iso14755) && |
518 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
627 | ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
519 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
628 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))) |
520 | if (!(iso14755buf & ISO_14755_STARTED)) |
629 | if (!(iso14755buf & ISO_14755_STARTED)) |
521 | { |
630 | { |
522 | iso14755buf |= ISO_14755_STARTED; |
631 | iso14755buf |= ISO_14755_STARTED; |
523 | # if ENABLE_OVERLAY |
632 | # if ISO_14755 |
524 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
633 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
525 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
634 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
526 | # endif |
635 | # endif |
527 | } |
636 | } |
528 | #endif |
637 | #endif |
529 | |
638 | |
530 | #ifdef PRINTPIPE |
639 | #ifdef PRINTPIPE |
531 | if (keysym == XK_Print) |
640 | if (keysym == XK_Print) |
532 | { |
641 | { |
533 | scr_printscreen (ctrl | shft); |
642 | scr_printscreen (ctrl | shft); |
534 | return; |
643 | return; |
535 | } |
644 | } |
536 | #endif |
645 | #endif |
537 | |
646 | |
538 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
647 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
539 | { |
648 | { |
|
|
649 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
|
|
650 | unsigned int newlen = 1; |
|
|
651 | |
|
|
652 | if (ev.state & ModNumLockMask) |
|
|
653 | kp = false; |
|
|
654 | |
|
|
655 | keysym = translate_keypad (keysym, kp); |
|
|
656 | |
|
|
657 | switch (keysym) |
540 | { |
658 | { |
|
|
659 | #ifndef NO_BACKSPACE_KEY |
|
|
660 | case XK_BackSpace: |
|
|
661 | if (priv_modes & PrivMode_HaveBackSpace) |
|
|
662 | { |
|
|
663 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
664 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
665 | kbuf[1] = '\0'; |
|
|
666 | } |
|
|
667 | else |
|
|
668 | strcpy (kbuf, rs[Rs_backspace_key]); |
|
|
669 | break; |
|
|
670 | #endif |
|
|
671 | #ifndef NO_DELETE_KEY |
|
|
672 | case XK_Delete: |
|
|
673 | strcpy (kbuf, rs[Rs_delete_key]); |
|
|
674 | break; |
|
|
675 | #endif |
|
|
676 | case XK_Tab: |
|
|
677 | if (shft) |
|
|
678 | strcpy (kbuf, "\033[Z"); |
|
|
679 | else |
|
|
680 | { |
|
|
681 | #ifdef CTRL_TAB_MAKES_META |
|
|
682 | if (ctrl) |
|
|
683 | meta = 1; |
|
|
684 | #endif |
|
|
685 | #ifdef MOD4_TAB_MAKES_META |
|
|
686 | if (ev.state & Mod4Mask) |
|
|
687 | meta = 1; |
|
|
688 | #endif |
541 | newlen = 1; |
689 | newlen = 0; |
542 | switch (keysym) |
690 | } |
|
|
691 | break; |
|
|
692 | |
|
|
693 | case XK_Up: /* "\033[A" */ |
|
|
694 | case XK_Down: /* "\033[B" */ |
|
|
695 | case XK_Right: /* "\033[C" */ |
|
|
696 | case XK_Left: /* "\033[D" */ |
|
|
697 | strcpy (kbuf, "\033[Z"); |
|
|
698 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
699 | /* do Shift first */ |
|
|
700 | if (shft) |
|
|
701 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
702 | else if (ctrl) |
|
|
703 | { |
|
|
704 | kbuf[1] = 'O'; |
|
|
705 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
706 | } |
|
|
707 | else if (priv_modes & PrivMode_aplCUR) |
|
|
708 | kbuf[1] = 'O'; |
|
|
709 | break; |
|
|
710 | |
|
|
711 | case XK_KP_Enter: |
|
|
712 | /* allow shift to override */ |
|
|
713 | if (kp) |
|
|
714 | { |
|
|
715 | strcpy (kbuf, "\033OM"); |
|
|
716 | break; |
|
|
717 | } |
|
|
718 | |
|
|
719 | /* FALLTHROUGH */ |
|
|
720 | |
|
|
721 | case XK_Return: |
|
|
722 | if (priv_modes & PrivMode_LFNL) |
|
|
723 | { |
|
|
724 | kbuf[0] = '\015'; |
|
|
725 | kbuf[1] = '\012'; |
|
|
726 | kbuf[2] = '\0'; |
|
|
727 | } |
|
|
728 | else |
|
|
729 | { |
|
|
730 | kbuf[0] = '\015'; |
|
|
731 | kbuf[1] = '\0'; |
|
|
732 | } |
|
|
733 | break; |
|
|
734 | |
|
|
735 | case XK_KP_F1: /* "\033OP" */ |
|
|
736 | case XK_KP_F2: /* "\033OQ" */ |
|
|
737 | case XK_KP_F3: /* "\033OR" */ |
|
|
738 | case XK_KP_F4: /* "\033OS" */ |
|
|
739 | strcpy (kbuf, "\033OP"); |
|
|
740 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
741 | break; |
|
|
742 | |
|
|
743 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
744 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
745 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
746 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
747 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
748 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
749 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
750 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
751 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
752 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
753 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
754 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
755 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
756 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
757 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
758 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
759 | /* allow shift to override */ |
|
|
760 | if (kp) |
|
|
761 | { |
|
|
762 | strcpy (kbuf, "\033Oj"); |
|
|
763 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
764 | } |
|
|
765 | else |
|
|
766 | { |
|
|
767 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
768 | kbuf[1] = '\0'; |
|
|
769 | } |
|
|
770 | break; |
|
|
771 | |
|
|
772 | default: |
543 | { |
773 | { |
544 | #ifndef NO_BACKSPACE_KEY |
774 | int param = map_function_key (keysym); |
545 | case XK_BackSpace: |
775 | if (param > 0) |
546 | if (priv_modes & PrivMode_HaveBackSpace) |
776 | sprintf (kbuf,"\033[%d~", param); |
547 | { |
|
|
548 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
549 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
550 | kbuf[1] = '\0'; |
|
|
551 | } |
|
|
552 | else |
777 | else |
553 | strcpy (kbuf, key_backspace); |
|
|
554 | break; |
|
|
555 | #endif |
|
|
556 | #ifndef NO_DELETE_KEY |
|
|
557 | # ifdef XK_KP_Prior |
|
|
558 | case XK_KP_Delete: |
|
|
559 | /* allow shift to override */ |
|
|
560 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
561 | { |
|
|
562 | strcpy (kbuf, "\033On"); |
|
|
563 | break; |
|
|
564 | } |
|
|
565 | /* FALLTHROUGH */ |
|
|
566 | # endif |
|
|
567 | case XK_Delete: |
|
|
568 | strcpy (kbuf, key_delete); |
|
|
569 | break; |
|
|
570 | #endif |
|
|
571 | case XK_Tab: |
|
|
572 | if (shft) |
|
|
573 | strcpy (kbuf, "\033[Z"); |
|
|
574 | else |
|
|
575 | { |
|
|
576 | #ifdef CTRL_TAB_MAKES_META |
|
|
577 | if (ctrl) |
|
|
578 | meta = 1; |
|
|
579 | #endif |
|
|
580 | #ifdef MOD4_TAB_MAKES_META |
|
|
581 | if (ev.state & Mod4Mask) |
|
|
582 | meta = 1; |
|
|
583 | #endif |
|
|
584 | newlen = 0; |
|
|
585 | } |
|
|
586 | break; |
|
|
587 | |
|
|
588 | #ifdef XK_KP_Left |
|
|
589 | case XK_KP_Up: /* \033Ox or standard */ |
|
|
590 | case XK_KP_Down: /* \033Or or standard */ |
|
|
591 | case XK_KP_Right: /* \033Ov or standard */ |
|
|
592 | case XK_KP_Left: /* \033Ot or standard */ |
|
|
593 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
594 | { |
|
|
595 | strcpy (kbuf, "\033OZ"); |
|
|
596 | kbuf[2] = "txvr"[keysym - XK_KP_Left]; |
|
|
597 | break; |
|
|
598 | } |
|
|
599 | else |
|
|
600 | /* translate to std. cursor key */ |
|
|
601 | keysym = XK_Left + (keysym - XK_KP_Left); |
|
|
602 | /* FALLTHROUGH */ |
|
|
603 | #endif |
|
|
604 | case XK_Up: /* "\033[A" */ |
|
|
605 | case XK_Down: /* "\033[B" */ |
|
|
606 | case XK_Right: /* "\033[C" */ |
|
|
607 | case XK_Left: /* "\033[D" */ |
|
|
608 | strcpy (kbuf, "\033[Z"); |
|
|
609 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
610 | /* do Shift first */ |
|
|
611 | if (shft) |
|
|
612 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
613 | else if (ctrl) |
|
|
614 | { |
|
|
615 | kbuf[1] = 'O'; |
|
|
616 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
617 | } |
|
|
618 | else if (priv_modes & PrivMode_aplCUR) |
|
|
619 | kbuf[1] = 'O'; |
|
|
620 | break; |
|
|
621 | |
|
|
622 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
623 | # ifdef XK_KP_Prior |
|
|
624 | case XK_KP_Prior: |
|
|
625 | /* allow shift to override */ |
|
|
626 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
627 | { |
|
|
628 | strcpy (kbuf, "\033Oy"); |
|
|
629 | break; |
|
|
630 | } |
|
|
631 | /* FALLTHROUGH */ |
|
|
632 | # endif |
|
|
633 | case XK_Prior: |
|
|
634 | strcpy (kbuf, "\033[5~"); |
|
|
635 | break; |
|
|
636 | # ifdef XK_KP_Next |
|
|
637 | case XK_KP_Next: |
|
|
638 | /* allow shift to override */ |
|
|
639 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
640 | { |
|
|
641 | strcpy (kbuf, "\033Os"); |
|
|
642 | break; |
|
|
643 | } |
|
|
644 | /* FALLTHROUGH */ |
|
|
645 | # endif |
|
|
646 | case XK_Next: |
|
|
647 | strcpy (kbuf, "\033[6~"); |
|
|
648 | break; |
|
|
649 | #endif |
|
|
650 | case XK_KP_Enter: |
|
|
651 | /* allow shift to override */ |
|
|
652 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
653 | { |
|
|
654 | strcpy (kbuf, "\033OM"); |
|
|
655 | break; |
|
|
656 | } |
|
|
657 | |
|
|
658 | /* FALLTHROUGH */ |
|
|
659 | |
|
|
660 | case XK_Return: |
|
|
661 | if (priv_modes & PrivMode_LFNL) |
|
|
662 | { |
|
|
663 | kbuf[0] = '\015'; |
|
|
664 | kbuf[1] = '\012'; |
|
|
665 | kbuf[2] = '\0'; |
|
|
666 | } |
|
|
667 | else |
|
|
668 | { |
|
|
669 | kbuf[0] = '\015'; |
|
|
670 | kbuf[1] = '\0'; |
|
|
671 | } |
|
|
672 | break; |
|
|
673 | |
|
|
674 | #ifdef XK_KP_Begin |
|
|
675 | case XK_KP_Begin: |
|
|
676 | strcpy (kbuf, "\033Ou"); |
|
|
677 | break; |
|
|
678 | |
|
|
679 | #endif |
|
|
680 | case XK_KP_F1: /* "\033OP" */ |
|
|
681 | case XK_KP_F2: /* "\033OQ" */ |
|
|
682 | case XK_KP_F3: /* "\033OR" */ |
|
|
683 | case XK_KP_F4: /* "\033OS" */ |
|
|
684 | strcpy (kbuf, "\033OP"); |
|
|
685 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
686 | break; |
|
|
687 | |
|
|
688 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
689 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
690 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
691 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
692 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
693 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
694 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
695 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
696 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
697 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
698 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
699 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
700 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
701 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
702 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
703 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
704 | /* allow shift to override */ |
|
|
705 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
706 | { |
|
|
707 | strcpy (kbuf, "\033Oj"); |
|
|
708 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
709 | } |
|
|
710 | else |
|
|
711 | { |
|
|
712 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
713 | kbuf[1] = '\0'; |
|
|
714 | } |
|
|
715 | break; |
|
|
716 | |
|
|
717 | case XK_Find: |
|
|
718 | strcpy (kbuf, "\033[1~"); |
|
|
719 | break; |
|
|
720 | |
|
|
721 | #ifdef XK_KP_End |
|
|
722 | case XK_KP_Insert: |
|
|
723 | /* allow shift to override */ |
|
|
724 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
725 | { |
|
|
726 | strcpy (kbuf, "\033Op"); |
|
|
727 | break; |
|
|
728 | } |
|
|
729 | /* FALLTHROUGH */ |
|
|
730 | #endif |
|
|
731 | case XK_Insert: |
|
|
732 | strcpy (kbuf, "\033[2~"); |
|
|
733 | break; |
|
|
734 | #ifdef DXK_Remove /* support for DEC remove like key */ |
|
|
735 | case DXK_Remove: |
|
|
736 | /* FALLTHROUGH */ |
|
|
737 | #endif |
|
|
738 | case XK_Execute: |
|
|
739 | strcpy (kbuf, "\033[3~"); |
|
|
740 | break; |
|
|
741 | case XK_Select: |
|
|
742 | strcpy (kbuf, "\033[4~"); |
|
|
743 | break; |
|
|
744 | #ifdef XK_KP_End |
|
|
745 | case XK_KP_End: |
|
|
746 | /* allow shift to override */ |
|
|
747 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
748 | { |
|
|
749 | strcpy (kbuf, "\033Oq"); |
|
|
750 | break; |
|
|
751 | } |
|
|
752 | /* FALLTHROUGH */ |
|
|
753 | #endif |
|
|
754 | case XK_End: |
|
|
755 | strcpy (kbuf, KS_END); |
|
|
756 | break; |
|
|
757 | #ifdef XK_KP_Home |
|
|
758 | case XK_KP_Home: |
|
|
759 | /* allow shift to override */ |
|
|
760 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
761 | { |
|
|
762 | strcpy (kbuf, "\033Ow"); |
|
|
763 | break; |
|
|
764 | } |
|
|
765 | /* FALLTHROUGH */ |
|
|
766 | #endif |
|
|
767 | case XK_Home: |
|
|
768 | strcpy (kbuf, KS_HOME); |
|
|
769 | break; |
|
|
770 | |
|
|
771 | #define FKEY(n, fkey) \ |
|
|
772 | sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey))) |
|
|
773 | |
|
|
774 | case XK_F1: /* "\033[11~" */ |
|
|
775 | case XK_F2: /* "\033[12~" */ |
|
|
776 | case XK_F3: /* "\033[13~" */ |
|
|
777 | case XK_F4: /* "\033[14~" */ |
|
|
778 | case XK_F5: /* "\033[15~" */ |
|
|
779 | FKEY (11, XK_F1); |
|
|
780 | break; |
|
|
781 | case XK_F6: /* "\033[17~" */ |
|
|
782 | case XK_F7: /* "\033[18~" */ |
|
|
783 | case XK_F8: /* "\033[19~" */ |
|
|
784 | case XK_F9: /* "\033[20~" */ |
|
|
785 | case XK_F10: /* "\033[21~" */ |
|
|
786 | FKEY (17, XK_F6); |
|
|
787 | break; |
|
|
788 | case XK_F11: /* "\033[23~" */ |
|
|
789 | case XK_F12: /* "\033[24~" */ |
|
|
790 | case XK_F13: /* "\033[25~" */ |
|
|
791 | case XK_F14: /* "\033[26~" */ |
|
|
792 | FKEY (23, XK_F11); |
|
|
793 | break; |
|
|
794 | case XK_F15: /* "\033[28~" */ |
|
|
795 | case XK_F16: /* "\033[29~" */ |
|
|
796 | FKEY (28, XK_F15); |
|
|
797 | break; |
|
|
798 | case XK_Help: /* "\033[28~" */ |
|
|
799 | FKEY (28, XK_Help); |
|
|
800 | break; |
|
|
801 | case XK_Menu: /* "\033[29~" */ |
|
|
802 | FKEY (29, XK_Menu); |
|
|
803 | break; |
|
|
804 | case XK_F17: /* "\033[31~" */ |
|
|
805 | case XK_F18: /* "\033[32~" */ |
|
|
806 | case XK_F19: /* "\033[33~" */ |
|
|
807 | case XK_F20: /* "\033[34~" */ |
|
|
808 | case XK_F21: /* "\033[35~" */ |
|
|
809 | case XK_F22: /* "\033[36~" */ |
|
|
810 | case XK_F23: /* "\033[37~" */ |
|
|
811 | case XK_F24: /* "\033[38~" */ |
|
|
812 | case XK_F25: /* "\033[39~" */ |
|
|
813 | case XK_F26: /* "\033[40~" */ |
|
|
814 | case XK_F27: /* "\033[41~" */ |
|
|
815 | case XK_F28: /* "\033[42~" */ |
|
|
816 | case XK_F29: /* "\033[43~" */ |
|
|
817 | case XK_F30: /* "\033[44~" */ |
|
|
818 | case XK_F31: /* "\033[45~" */ |
|
|
819 | case XK_F32: /* "\033[46~" */ |
|
|
820 | case XK_F33: /* "\033[47~" */ |
|
|
821 | case XK_F34: /* "\033[48~" */ |
|
|
822 | case XK_F35: /* "\033[49~" */ |
|
|
823 | FKEY (31, XK_F17); |
|
|
824 | break; |
|
|
825 | #undef FKEY |
|
|
826 | default: |
|
|
827 | newlen = 0; |
778 | newlen = 0; |
828 | break; |
|
|
829 | } |
779 | } |
830 | |
780 | break; |
831 | if (newlen) |
|
|
832 | len = strlen (kbuf); |
|
|
833 | } |
781 | } |
|
|
782 | |
|
|
783 | if (newlen) |
|
|
784 | len = strlen (kbuf); |
834 | |
785 | |
835 | /* |
786 | /* |
836 | * Pass meta for all function keys, if 'meta' option set |
787 | * Pass meta for all function keys, if 'meta' option set |
837 | */ |
788 | */ |
838 | #ifdef META8_OPTION |
789 | #ifdef META8_OPTION |
… | |
… | |
867 | #endif |
818 | #endif |
868 | /* nil */ ; |
819 | /* nil */ ; |
869 | } |
820 | } |
870 | } |
821 | } |
871 | |
822 | |
872 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STR_LEN, kbuf, len, DT_END))) |
823 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
873 | return; |
824 | return; |
874 | |
825 | |
875 | if (len <= 0) |
826 | if (len <= 0) |
876 | return; /* not mapped */ |
827 | return; /* not mapped */ |
877 | |
828 | |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
829 | if (option (Opt_scrollTtyKeypress)) |
879 | if (view_start) |
830 | if (view_start) |
880 | { |
831 | { |
881 | view_start = 0; |
832 | view_start = 0; |
882 | want_refresh = 1; |
833 | want_refresh = 1; |
883 | } |
834 | } |
… | |
… | |
905 | { |
856 | { |
906 | const char ch = C0_ESC; |
857 | const char ch = C0_ESC; |
907 | tt_write (&ch, 1); |
858 | tt_write (&ch, 1); |
908 | } |
859 | } |
909 | |
860 | |
910 | #if defined(DEBUG_CMD) |
|
|
911 | /* Display keyboard buffer contents */ |
|
|
912 | unsigned char *p; |
|
|
913 | int i; |
|
|
914 | |
|
|
915 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
916 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
917 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
918 | fprintf (stderr, "'\n"); |
|
|
919 | #endif /* DEBUG_CMD */ |
|
|
920 | tt_write (kbuf, (unsigned int)len); |
861 | tt_write (kbuf, (unsigned int)len); |
921 | } |
862 | } |
922 | /*}}} */ |
|
|
923 | |
863 | |
|
|
864 | void |
|
|
865 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
866 | { |
|
|
867 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
868 | KeySym keysym; |
|
|
869 | |
|
|
870 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
871 | #endif |
|
|
872 | |
|
|
873 | #if ENABLE_FRILLS || ISO_14755 |
|
|
874 | // ISO 14755 support |
|
|
875 | if (iso14755buf) |
|
|
876 | if (iso14755buf & ISO_14755_52) |
|
|
877 | { |
|
|
878 | # if ISO_14755 |
|
|
879 | scr_overlay_off (); |
|
|
880 | # endif |
|
|
881 | # if ISO_14755 |
|
|
882 | // iso14755 part 5.2 handling: release time |
|
|
883 | // first: controls |
|
|
884 | if ((ev.state & ControlMask) |
|
|
885 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
886 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
887 | { |
|
|
888 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
889 | commit_iso14755 (); |
|
|
890 | |
|
|
891 | return; |
|
|
892 | } |
|
|
893 | |
|
|
894 | for (unsigned short *i = iso14755_symtab; i[0]; i += 2) |
|
|
895 | if (i[0] == keysym) |
|
|
896 | { |
|
|
897 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
898 | commit_iso14755 (); |
|
|
899 | |
|
|
900 | return; |
|
|
901 | } |
|
|
902 | |
|
|
903 | scr_bell (); |
|
|
904 | # endif |
|
|
905 | iso14755buf = 0; |
|
|
906 | |
|
|
907 | return; |
|
|
908 | } |
|
|
909 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
910 | { |
|
|
911 | # if ISO_14755 |
|
|
912 | scr_overlay_off (); |
|
|
913 | # endif |
|
|
914 | if (iso14755buf & ISO_14755_51) |
|
|
915 | commit_iso14755 (); |
|
|
916 | #if ISO_14755 |
|
|
917 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
918 | { |
|
|
919 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
920 | |
|
|
921 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
922 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
923 | } |
|
|
924 | # endif |
|
|
925 | else |
|
|
926 | iso14755buf = 0; |
|
|
927 | } |
|
|
928 | #endif |
|
|
929 | |
|
|
930 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
931 | return; |
|
|
932 | |
|
|
933 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
934 | if (!(ev.state & ControlMask)) |
|
|
935 | slip_wheel_ev.stop (); |
|
|
936 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
937 | mouse_slip_wheel_speed = 0; |
|
|
938 | #endif |
|
|
939 | } |
|
|
940 | |
924 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
941 | #if defined (KEYSYM_RESOURCE) |
925 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
926 | /* attempt to `write' count to the input buffer */ |
|
|
927 | unsigned int |
942 | unsigned int |
928 | rxvt_term::cmd_write (const char *str, unsigned int count) |
943 | rxvt_term::cmd_write (const char *str, unsigned int count) |
929 | { |
944 | { |
930 | unsigned int n, s; |
945 | unsigned int n, s; |
931 | |
946 | |
… | |
… | |
959 | void |
974 | void |
960 | rxvt_term::flush () |
975 | rxvt_term::flush () |
961 | { |
976 | { |
962 | flush_ev.stop (); |
977 | flush_ev.stop (); |
963 | |
978 | |
964 | #ifdef TRANSPARENT |
979 | #ifdef HAVE_BG_PIXMAP |
965 | if (want_full_refresh) |
980 | if (bgPixmap.flags & bgPixmap_t::hasChanged) |
966 | { |
981 | { |
967 | want_full_refresh = 0; |
982 | bgPixmap.flags &= ~bgPixmap_t::hasChanged; |
968 | scr_clear (); |
983 | // scr_clear (true); This needs to be researched further! |
969 | scr_touch (false); |
984 | scr_touch (false); |
970 | } |
985 | } |
971 | #endif |
986 | #endif |
972 | |
987 | |
973 | if (want_refresh) |
988 | if (want_refresh) |
974 | { |
989 | { |
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
990 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
976 | { |
991 | { |
977 | int row = -view_start; |
992 | int row = view_start; |
|
|
993 | int end_row = row + nrow; |
978 | |
994 | |
979 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
995 | while (row > top_row && ROW (row - 1).is_longer ()) |
980 | --row; |
996 | --row; |
981 | |
997 | |
982 | while (row < -view_start + nrow) |
998 | do |
983 | { |
999 | { |
984 | int start_row = row; |
1000 | int start_row = row; |
985 | line_t *l; |
1001 | line_t *l; |
986 | |
1002 | |
987 | do |
1003 | do |
988 | { |
1004 | { |
989 | l = &ROW (row); |
1005 | l = &ROW (row++); |
990 | |
1006 | |
991 | if (!(l->f & LINE_FILTERED)) |
1007 | if (!(l->f & LINE_FILTERED)) |
992 | { |
1008 | { |
993 | // line not filtered, mark it as filtered |
1009 | // line not filtered, mark it as filtered |
994 | l->f |= LINE_FILTERED; |
1010 | l->f |= LINE_FILTERED; |
995 | while (l->is_longer ()) |
1011 | while (l->is_longer ()) |
996 | { |
1012 | { |
997 | l = &ROW (++row); |
1013 | l = &ROW (row++); |
998 | l->f |= LINE_FILTERED; |
1014 | l->f |= LINE_FILTERED; |
999 | } |
1015 | } |
1000 | |
1016 | |
1001 | // and filter it |
1017 | // and filter it |
1002 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
1018 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
1003 | |
1019 | |
1004 | break; |
1020 | break; |
1005 | } |
1021 | } |
1006 | } |
1022 | } |
1007 | while (l->is_longer ()); |
1023 | while (l->is_longer () && row < end_row); |
1008 | |
|
|
1009 | row++; |
|
|
1010 | } |
1024 | } |
|
|
1025 | while (row < end_row); |
1011 | |
1026 | } |
1012 | } |
|
|
1013 | |
1027 | |
1014 | scr_refresh (refresh_type); |
1028 | scr_refresh (); |
1015 | scrollbar_show (1); |
1029 | scrollBar.show (1); |
1016 | #ifdef USE_XIM |
1030 | #ifdef USE_XIM |
1017 | IMSendSpot (); |
1031 | IMSendSpot (); |
1018 | #endif |
1032 | #endif |
1019 | } |
1033 | } |
1020 | |
1034 | |
1021 | display->flush (); |
1035 | display->flush (); |
1022 | } |
1036 | } |
1023 | |
1037 | |
|
|
1038 | /* checks whether a refresh is requested and starts the refresh timer */ |
1024 | void |
1039 | void |
1025 | rxvt_term::check_cb (check_watcher &w) |
1040 | rxvt_term::refresh_check () |
1026 | { |
1041 | { |
1027 | SET_R (this); |
1042 | if (want_refresh && !flush_ev.is_active ()) |
1028 | SET_LOCALE (locale); |
1043 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
1029 | |
1044 | |
1030 | display->flush (); |
1045 | display->flush (); |
1031 | |
|
|
1032 | if (want_refresh && !flush_ev.active) |
|
|
1033 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
|
|
1034 | } |
1046 | } |
1035 | |
1047 | |
1036 | void |
1048 | void |
1037 | rxvt_term::flush_cb (time_watcher &w) |
1049 | rxvt_term::flush_cb (ev::timer &w, int revents) |
1038 | { |
1050 | { |
1039 | SET_R (this); |
1051 | make_current (); |
1040 | SET_LOCALE (locale); |
|
|
1041 | |
1052 | |
1042 | refresh_limit = 1; |
|
|
1043 | refresh_count = 0; |
1053 | refresh_count = 0; |
1044 | flush (); |
1054 | flush (); |
1045 | } |
1055 | } |
1046 | |
1056 | |
1047 | #ifdef CURSOR_BLINK |
1057 | #ifdef CURSOR_BLINK |
1048 | void |
1058 | void |
1049 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1059 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
1050 | { |
1060 | { |
1051 | hidden_cursor = !hidden_cursor; |
1061 | hidden_cursor = !hidden_cursor; |
1052 | want_refresh = 1; |
1062 | want_refresh = 1; |
1053 | |
1063 | refresh_check (); |
1054 | w.start (w.at + BLINK_INTERVAL); |
|
|
1055 | } |
1064 | } |
1056 | #endif |
1065 | #endif |
1057 | |
1066 | |
1058 | #ifdef TEXT_BLINK |
1067 | #ifdef TEXT_BLINK |
1059 | void |
1068 | void |
1060 | rxvt_term::text_blink_cb (time_watcher &w) |
1069 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
1061 | { |
1070 | { |
1062 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1071 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1063 | { |
1072 | { |
1064 | hidden_text = !hidden_text; |
1073 | hidden_text = !hidden_text; |
1065 | want_refresh = 1; |
1074 | want_refresh = 1; |
1066 | w.start (w.at + TEXT_BLINK_INTERVAL); |
1075 | refresh_check (); |
1067 | } |
1076 | } |
|
|
1077 | else |
|
|
1078 | w.stop (); |
1068 | } |
1079 | } |
1069 | #endif |
1080 | #endif |
1070 | |
1081 | |
1071 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1082 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1072 | void |
1083 | void |
1073 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1084 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1074 | { |
1085 | { |
1075 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1086 | if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
1076 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1087 | && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1)) |
1077 | { |
1088 | { |
1078 | refresh_type |= SMOOTH_REFRESH; |
|
|
1079 | want_refresh = 1; |
1089 | want_refresh = 1; |
1080 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1090 | refresh_check (); |
1081 | } |
1091 | } |
|
|
1092 | else |
|
|
1093 | w.stop (); |
1082 | } |
1094 | } |
1083 | #endif |
1095 | #endif |
1084 | |
1096 | |
1085 | #ifdef SELECTION_SCROLLING |
1097 | #ifdef SELECTION_SCROLLING |
1086 | void |
1098 | void |
1087 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1099 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1088 | { |
1100 | { |
1089 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1101 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1090 | { |
1102 | { |
1091 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1103 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1092 | refresh_type |= SMOOTH_REFRESH; |
|
|
1093 | want_refresh = 1; |
1104 | want_refresh = 1; |
1094 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1105 | refresh_check (); |
1095 | } |
1106 | } |
|
|
1107 | else |
|
|
1108 | w.stop (); |
1096 | } |
1109 | } |
1097 | #endif |
1110 | #endif |
1098 | |
1111 | |
1099 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1112 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1100 | void |
1113 | void |
1101 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1114 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1102 | { |
1115 | { |
1103 | if (mouse_slip_wheel_speed == 0 |
1116 | if (scr_changeview (view_start - mouse_slip_wheel_speed)) |
1104 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
1105 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
1106 | { |
1117 | { |
1107 | if (view_start == nsaved || |
|
|
1108 | view_start == 0) |
|
|
1109 | mouse_slip_wheel_speed = 0; |
|
|
1110 | |
|
|
1111 | refresh_type |= SMOOTH_REFRESH; |
|
|
1112 | want_refresh = 1; |
1118 | want_refresh = 1; |
1113 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1119 | refresh_check (); |
|
|
1120 | } |
|
|
1121 | |
|
|
1122 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
1114 | } |
1123 | { |
|
|
1124 | mouse_slip_wheel_speed = 0; |
|
|
1125 | w.stop (); |
|
|
1126 | } |
1115 | } |
1127 | } |
1116 | #endif |
1128 | #endif |
1117 | |
1129 | |
1118 | #if HAVE_SCHED_YIELD |
1130 | #if LINUX_YIELD_HACK |
1119 | static struct event_handler |
1131 | static struct event_handler |
1120 | { |
1132 | { |
1121 | check_watcher cw_yield; |
1133 | ev::prepare yield_ev; |
1122 | |
1134 | |
1123 | void yield (check_watcher &w) |
1135 | void yield_cb (ev::prepare &w, int revents) |
1124 | { |
1136 | { |
1125 | sched_yield (); |
1137 | // this should really be sched_yield(), but the linux guys thought |
|
|
1138 | // that giving a process calling sched_yield () less cpu time than |
|
|
1139 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1140 | // allowed by the sus... as is returning ENOSYS. |
|
|
1141 | // since the linux guys additionally thought that breaking the only |
|
|
1142 | // known workaround against their unusable sched_yield hack is cool, |
|
|
1143 | // we just nanosleep a bit and hope for the best. |
|
|
1144 | |
|
|
1145 | struct timespec ts = { 0, 1000 }; |
|
|
1146 | nanosleep (&ts, 0); |
|
|
1147 | |
1126 | w.stop (); |
1148 | w.stop (); |
1127 | } |
1149 | } |
1128 | |
1150 | |
1129 | event_handler () |
1151 | event_handler () |
1130 | : cw_yield (this, &event_handler::yield) |
1152 | : yield_ev (this, &event_handler::yield_cb) |
1131 | { |
1153 | { |
1132 | } |
1154 | } |
1133 | } event_handler; |
1155 | } event_handler; |
1134 | #endif |
1156 | #endif |
1135 | |
1157 | |
… | |
… | |
1146 | |
1168 | |
1147 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1169 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1148 | cmdbuf_ptr = cmdbuf_base; |
1170 | cmdbuf_ptr = cmdbuf_base; |
1149 | cmdbuf_endp = cmdbuf_ptr + n; |
1171 | cmdbuf_endp = cmdbuf_ptr + n; |
1150 | |
1172 | |
1151 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1173 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1152 | |
1174 | |
1153 | if (r > 0) |
1175 | if (r > 0) |
1154 | { |
1176 | { |
1155 | cmdbuf_endp += r; |
1177 | cmdbuf_endp += r; |
1156 | return true; |
1178 | return true; |
1157 | } |
1179 | } |
1158 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1180 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1159 | { |
1181 | { |
1160 | #if HAVE_SCHED_YIELD |
1182 | #if LINUX_YIELD_HACK |
1161 | if (display->is_local) |
1183 | if (display->is_local) |
1162 | event_handler.cw_yield.start (); |
1184 | event_handler.yield_ev.start (); |
1163 | #endif |
1185 | #endif |
1164 | } |
1186 | } |
1165 | else |
1187 | else |
1166 | { |
1188 | { |
1167 | pty_ev.stop (); |
1189 | pty_ev.stop (); |
1168 | |
1190 | |
1169 | if (!OPTION (Opt_hold)) |
1191 | if (!option (Opt_hold)) |
1170 | destroy (); |
1192 | destroy (); |
1171 | } |
1193 | } |
1172 | |
1194 | |
1173 | return false; |
1195 | return false; |
1174 | } |
1196 | } |
1175 | |
1197 | |
1176 | void |
1198 | void |
1177 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1199 | rxvt_term::pty_cb (ev::io &w, int revents) |
1178 | { |
1200 | { |
1179 | SET_R (this); |
1201 | make_current (); |
1180 | SET_LOCALE (locale); |
|
|
1181 | |
1202 | |
1182 | if (revents & EVENT_READ) |
1203 | if (revents & ev::READ) |
1183 | // loop, but don't allow a single term to monopolize us |
1204 | // loop, but don't allow a single term to monopolize us |
1184 | while (pty_fill ()) |
1205 | for (int i = CBUFCNT; i-- && pty_fill (); ) |
1185 | if (cmd_parse ()) |
1206 | cmd_parse (); |
1186 | break; |
|
|
1187 | |
1207 | |
1188 | if (revents & EVENT_WRITE) |
1208 | if (revents & ev::WRITE) |
1189 | pty_write (); |
1209 | pty_write (); |
|
|
1210 | |
|
|
1211 | refresh_check (); |
1190 | } |
1212 | } |
1191 | |
1213 | |
1192 | void |
1214 | void |
1193 | rxvt_term::pointer_unblank () |
1215 | rxvt_term::pointer_unblank () |
1194 | { |
1216 | { |
1195 | XDefineCursor (display->display, vt, TermWin_cursor); |
1217 | XDefineCursor (dpy, vt, TermWin_cursor); |
1196 | recolour_cursor (); |
1218 | recolour_cursor (); |
1197 | |
1219 | |
1198 | #ifdef POINTER_BLANK |
1220 | #ifdef POINTER_BLANK |
1199 | hidden_pointer = 0; |
1221 | hidden_pointer = 0; |
1200 | |
1222 | |
1201 | if (OPTION (Opt_pointerBlank)) |
1223 | if (option (Opt_pointerBlank)) |
1202 | pointer_ev.start (NOW + pointerBlankDelay); |
1224 | pointer_ev.start (pointerBlankDelay); |
1203 | #endif |
1225 | #endif |
1204 | } |
1226 | } |
1205 | |
1227 | |
1206 | #ifdef POINTER_BLANK |
1228 | #ifdef POINTER_BLANK |
1207 | void |
1229 | void |
1208 | rxvt_term::pointer_blank () |
1230 | rxvt_term::pointer_blank () |
1209 | { |
1231 | { |
1210 | if (!OPTION (Opt_pointerBlank)) |
1232 | if (!option (Opt_pointerBlank)) |
1211 | return; |
1233 | return; |
1212 | |
1234 | |
1213 | XDefineCursor (display->display, vt, display->blank_cursor); |
1235 | XDefineCursor (dpy, vt, display->blank_cursor); |
1214 | XFlush (display->display); |
1236 | XFlush (dpy); |
1215 | |
1237 | |
1216 | hidden_pointer = 1; |
1238 | hidden_pointer = 1; |
1217 | } |
1239 | } |
1218 | |
1240 | |
1219 | void |
1241 | void |
1220 | rxvt_term::pointer_cb (time_watcher &w) |
1242 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1221 | { |
1243 | { |
1222 | SET_R (this); |
1244 | make_current (); |
1223 | SET_LOCALE (locale); |
|
|
1224 | |
1245 | |
1225 | pointer_blank (); |
1246 | pointer_blank (); |
1226 | } |
1247 | } |
1227 | #endif |
1248 | #endif |
1228 | |
1249 | |
1229 | void |
1250 | void |
1230 | rxvt_term::mouse_report (XButtonEvent &ev) |
1251 | rxvt_term::mouse_report (XButtonEvent &ev) |
1231 | { |
1252 | { |
1232 | int button_number, key_state = 0; |
1253 | int button_number, key_state = 0; |
1233 | int x, y; |
1254 | int x, y; |
|
|
1255 | int code = 32; |
1234 | |
1256 | |
1235 | x = ev.x; |
1257 | x = Pixel2Col (ev.x) + 1; |
1236 | y = ev.y; |
1258 | y = Pixel2Row (ev.y) + 1; |
1237 | pixel_position (&x, &y); |
1259 | |
|
|
1260 | if (ev.type == MotionNotify) |
|
|
1261 | { |
|
|
1262 | if (x == mouse_row && y == mouse_col) |
|
|
1263 | return; |
|
|
1264 | |
|
|
1265 | mouse_row = x; |
|
|
1266 | mouse_col = y; |
|
|
1267 | code += 32; |
|
|
1268 | } |
1238 | |
1269 | |
1239 | if (MEvent.button == AnyButton) |
1270 | if (MEvent.button == AnyButton) |
1240 | button_number = 3; |
1271 | button_number = 3; |
1241 | else |
1272 | else |
1242 | { |
1273 | { |
1243 | button_number = MEvent.button - Button1; |
1274 | button_number = MEvent.button - Button1; |
1244 | /* add 0x3D for wheel events, like xterm does */ |
1275 | /* add 0x3D for wheel events, like xterm does */ |
1245 | if (button_number >= 3) |
1276 | if (button_number >= 3) |
1246 | button_number += (64 - 3); |
1277 | button_number += 64 - 3; |
1247 | } |
1278 | } |
1248 | |
1279 | |
1249 | if (priv_modes & PrivMode_MouseX10) |
1280 | if (priv_modes & PrivMode_MouseX10) |
1250 | { |
1281 | { |
1251 | /* |
1282 | /* |
… | |
… | |
1283 | fputc ('A', stderr); |
1314 | fputc ('A', stderr); |
1284 | if (key_state & 32) |
1315 | if (key_state & 32) |
1285 | fputc ('2', stderr); |
1316 | fputc ('2', stderr); |
1286 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1317 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1287 | button_number, |
1318 | button_number, |
1288 | x + 1, |
1319 | x, |
1289 | y + 1); |
1320 | y); |
1290 | #endif |
1321 | #endif |
1291 | |
1322 | |
|
|
1323 | #if ENABLE_FRILLS |
|
|
1324 | if (priv_modes & PrivMode_ExtMouseRight) |
|
|
1325 | tt_printf ("\033[%d;%d;%dM", |
|
|
1326 | code + button_number + key_state, |
|
|
1327 | x, |
|
|
1328 | y); |
|
|
1329 | else if (priv_modes & PrivMode_ExtModeMouse) |
|
|
1330 | tt_printf ("\033[M%c%lc%lc", |
|
|
1331 | code + button_number + key_state, |
|
|
1332 | wint_t (32 + x), |
|
|
1333 | wint_t (32 + y)); |
|
|
1334 | else |
|
|
1335 | #endif |
1292 | tt_printf ("\033[M%c%c%c", |
1336 | tt_printf ("\033[M%c%c%c", |
1293 | (32 + button_number + key_state), |
1337 | code + button_number + key_state, |
1294 | (32 + x + 1), |
1338 | 32 + x, |
1295 | (32 + y + 1)); |
1339 | 32 + y); |
1296 | } |
1340 | } |
1297 | |
|
|
1298 | #ifdef USING_W11LIB |
|
|
1299 | void |
|
|
1300 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1301 | { |
|
|
1302 | rxvt_t *r = rxvt_get_r (); |
|
|
1303 | |
|
|
1304 | x_cb (*ev); |
|
|
1305 | } |
|
|
1306 | #endif |
|
|
1307 | |
1341 | |
1308 | /*{{{ process an X event */ |
1342 | /*{{{ process an X event */ |
1309 | void |
1343 | void |
1310 | rxvt_term::x_cb (XEvent &ev) |
1344 | rxvt_term::x_cb (XEvent &ev) |
1311 | { |
1345 | { |
1312 | dDisp; |
1346 | make_current (); |
1313 | |
1347 | |
1314 | SET_R (this); |
1348 | dLocal (Display *, dpy); |
1315 | SET_LOCALE (locale); |
|
|
1316 | |
1349 | |
1317 | #if defined(CURSOR_BLINK) |
1350 | if (ev.xany.window == vt |
1318 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1351 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1319 | { |
1352 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1320 | if (hidden_cursor) |
1353 | return; |
1321 | { |
|
|
1322 | hidden_cursor = 0; |
|
|
1323 | want_refresh = 1; |
|
|
1324 | } |
|
|
1325 | |
1354 | |
1326 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1355 | // for XQueryPointer |
1327 | } |
|
|
1328 | #endif |
|
|
1329 | |
|
|
1330 | #if defined(POINTER_BLANK) |
|
|
1331 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1332 | { |
|
|
1333 | if (ev.type == MotionNotify |
|
|
1334 | || ev.type == ButtonPress |
|
|
1335 | || ev.type == ButtonRelease) |
|
|
1336 | if (hidden_pointer) |
|
|
1337 | pointer_unblank (); |
|
|
1338 | |
|
|
1339 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1340 | pointer_blank (); |
|
|
1341 | } |
|
|
1342 | #endif |
|
|
1343 | |
|
|
1344 | Window unused_root, unused_child; |
1356 | Window unused_root, unused_child; |
1345 | int unused_root_x, unused_root_y; |
1357 | int unused_root_x, unused_root_y; |
1346 | unsigned int unused_mask; |
1358 | unsigned int unused_mask; |
1347 | |
1359 | |
1348 | switch (ev.type) |
1360 | switch (ev.type) |
1349 | { |
1361 | { |
1350 | case KeyPress: |
1362 | case KeyPress: |
1351 | #if ISO_14755 |
1363 | key_press (ev.xkey); |
1352 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1353 | #endif |
|
|
1354 | lookup_key (ev.xkey); |
|
|
1355 | |
|
|
1356 | break; |
1364 | break; |
1357 | |
1365 | |
1358 | case KeyRelease: |
1366 | case KeyRelease: |
1359 | { |
1367 | key_release (ev.xkey); |
1360 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1361 | KeySym ks; |
|
|
1362 | |
|
|
1363 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1364 | #endif |
|
|
1365 | |
|
|
1366 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1367 | // ISO 14755 support |
|
|
1368 | if (iso14755buf) |
|
|
1369 | if (iso14755buf & ISO_14755_52) |
|
|
1370 | { |
|
|
1371 | # if ENABLE_OVERLAY |
|
|
1372 | scr_overlay_off (); |
|
|
1373 | # endif |
|
|
1374 | # if ISO_14755 |
|
|
1375 | // iso14755 part 5.2 handling: release time |
|
|
1376 | // first: controls |
|
|
1377 | if ((ev.xkey.state & ControlMask) |
|
|
1378 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1379 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1380 | { |
|
|
1381 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1382 | commit_iso14755 (); |
|
|
1383 | return; // case-break; |
|
|
1384 | } |
|
|
1385 | |
|
|
1386 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1387 | if (i[0] == ks) |
|
|
1388 | { |
|
|
1389 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1390 | commit_iso14755 (); |
|
|
1391 | return; // case-break; |
|
|
1392 | } |
|
|
1393 | |
|
|
1394 | scr_bell (); |
|
|
1395 | # endif |
|
|
1396 | iso14755buf = 0; |
|
|
1397 | break; |
|
|
1398 | } |
|
|
1399 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1400 | { |
|
|
1401 | # if ENABLE_OVERLAY |
|
|
1402 | scr_overlay_off (); |
|
|
1403 | # endif |
|
|
1404 | if (iso14755buf & ISO_14755_51) |
|
|
1405 | commit_iso14755 (); |
|
|
1406 | #if ISO_14755 |
|
|
1407 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1408 | { |
|
|
1409 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1410 | |
|
|
1411 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1412 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1413 | } |
|
|
1414 | # endif |
|
|
1415 | else |
|
|
1416 | iso14755buf = 0; |
|
|
1417 | } |
|
|
1418 | #endif |
|
|
1419 | |
|
|
1420 | if (ev.xany.window == vt |
|
|
1421 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
1422 | break; |
|
|
1423 | |
|
|
1424 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1425 | if (!(ev.xkey.state & ControlMask)) |
|
|
1426 | slip_wheel_ev.stop (); |
|
|
1427 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1428 | mouse_slip_wheel_speed = 0; |
|
|
1429 | #endif |
|
|
1430 | break; |
1368 | break; |
1431 | } |
|
|
1432 | |
1369 | |
1433 | case ButtonPress: |
1370 | case ButtonPress: |
1434 | button_press (ev.xbutton); |
1371 | button_press (ev.xbutton); |
1435 | break; |
1372 | break; |
1436 | |
1373 | |
… | |
… | |
1438 | button_release (ev.xbutton); |
1375 | button_release (ev.xbutton); |
1439 | break; |
1376 | break; |
1440 | |
1377 | |
1441 | case ClientMessage: |
1378 | case ClientMessage: |
1442 | if (ev.xclient.format == 32 |
1379 | if (ev.xclient.format == 32 |
1443 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1380 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1444 | { |
1381 | { |
|
|
1382 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1383 | { |
|
|
1384 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1385 | { |
1445 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1386 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1387 | { |
|
|
1388 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1446 | destroy (); |
1389 | destroy (); |
|
|
1390 | } |
1447 | #if ENABLE_EWMH |
1391 | #if ENABLE_EWMH |
1448 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1392 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1449 | XSendEvent (disp, ev.xclient.window = display->root, |
1393 | XSendEvent (dpy, ev.xclient.window = display->root, |
1450 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1394 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1451 | &ev); |
1395 | &ev); |
|
|
1396 | #endif |
|
|
1397 | } |
|
|
1398 | } |
|
|
1399 | #if ENABLE_XEMBED |
|
|
1400 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1401 | { |
|
|
1402 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1403 | focus_in (); |
|
|
1404 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1405 | focus_out (); |
|
|
1406 | } |
1452 | #endif |
1407 | #endif |
1453 | } |
1408 | } |
1454 | #if ENABLE_XEMBED |
|
|
1455 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1456 | { |
|
|
1457 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1458 | focus_in (); |
|
|
1459 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1460 | focus_out (); |
|
|
1461 | } |
|
|
1462 | #endif |
|
|
1463 | #ifdef OFFIX_DND |
|
|
1464 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1465 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1466 | && (ev.xclient.data.l[0] == DndFile |
|
|
1467 | || ev.xclient.data.l[0] == DndDir |
|
|
1468 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1469 | { |
|
|
1470 | /* Get Dnd data */ |
|
|
1471 | Atom ActualType; |
|
|
1472 | int ActualFormat; |
|
|
1473 | unsigned char *data; |
|
|
1474 | unsigned long Size, RemainingBytes; |
|
|
1475 | |
|
|
1476 | XGetWindowProperty (disp, display->root, |
|
|
1477 | xa[XA_DNDSELECTION], |
|
|
1478 | 0L, 1000000L, |
|
|
1479 | False, AnyPropertyType, |
|
|
1480 | &ActualType, &ActualFormat, |
|
|
1481 | &Size, &RemainingBytes, |
|
|
1482 | &data); |
|
|
1483 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1484 | XFree (data); |
|
|
1485 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1486 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1487 | } |
|
|
1488 | #endif /* OFFIX_DND */ |
|
|
1489 | break; |
|
|
1490 | |
|
|
1491 | case MappingNotify: |
|
|
1492 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1493 | break; |
1409 | break; |
1494 | |
1410 | |
1495 | /* |
1411 | /* |
1496 | * XXX: this is not the _current_ arrangement |
1412 | * XXX: this is not the _current_ arrangement |
1497 | * Here's my conclusion: |
1413 | * Here's my conclusion: |
… | |
… | |
1516 | break; |
1432 | break; |
1517 | } |
1433 | } |
1518 | break; |
1434 | break; |
1519 | |
1435 | |
1520 | case FocusIn: |
1436 | case FocusIn: |
|
|
1437 | if (ev.xfocus.detail != NotifyInferior |
|
|
1438 | && ev.xfocus.detail != NotifyPointer |
|
|
1439 | && ev.xfocus.mode != NotifyGrab) |
1521 | focus_in (); |
1440 | focus_in (); |
1522 | break; |
1441 | break; |
1523 | |
1442 | |
1524 | case FocusOut: |
1443 | case FocusOut: |
|
|
1444 | if (ev.xfocus.detail != NotifyInferior |
|
|
1445 | && ev.xfocus.detail != NotifyPointer |
|
|
1446 | && ev.xfocus.mode != NotifyGrab) |
1525 | focus_out (); |
1447 | focus_out (); |
1526 | break; |
1448 | break; |
1527 | |
1449 | |
1528 | case ConfigureNotify: |
1450 | case ConfigureNotify: |
1529 | if (ev.xconfigure.window == parent[0]) |
1451 | if (ev.xconfigure.window == parent[0]) |
1530 | { |
1452 | { |
1531 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1453 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1532 | ; |
1454 | ; |
|
|
1455 | |
|
|
1456 | #ifdef HAVE_BG_PIXMAP |
|
|
1457 | bool moved = false; |
|
|
1458 | if (bgPixmap.window_position_sensitive ()) |
|
|
1459 | { |
|
|
1460 | int x, y; |
|
|
1461 | if (ev.xconfigure.send_event) |
|
|
1462 | { |
|
|
1463 | x = ev.xconfigure.x; |
|
|
1464 | y = ev.xconfigure.y; |
|
|
1465 | } |
|
|
1466 | else |
|
|
1467 | get_window_origin (x, y); |
|
|
1468 | |
|
|
1469 | if (bgPixmap.set_position (x, y) |
|
|
1470 | || (bgPixmap.flags & bgPixmap_t::isInvalid)) |
|
|
1471 | moved = true; |
|
|
1472 | } |
|
|
1473 | #endif |
1533 | |
1474 | |
1534 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1475 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1535 | { |
1476 | { |
1536 | seen_resize = 1; |
1477 | seen_resize = 1; |
1537 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1478 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1538 | } |
1479 | } |
1539 | |
1480 | else |
1540 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1481 | { |
1541 | if (OPTION (Opt_transparent)) |
1482 | #ifdef HAVE_BG_PIXMAP |
1542 | check_our_parents (); |
1483 | if (moved) |
|
|
1484 | { |
|
|
1485 | if (mapped) |
|
|
1486 | update_background (); |
|
|
1487 | else |
|
|
1488 | bgPixmap.invalidate (); |
|
|
1489 | } |
1543 | #endif |
1490 | #endif |
|
|
1491 | } |
|
|
1492 | |
|
|
1493 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1544 | } |
1494 | } |
1545 | break; |
1495 | break; |
1546 | |
1496 | |
1547 | case PropertyNotify: |
1497 | case PropertyNotify: |
|
|
1498 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1548 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1499 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1549 | && ev.xproperty.state == PropertyNewValue) |
1500 | && ev.xproperty.state == PropertyNewValue) |
1550 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1501 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1551 | |
1502 | |
1552 | break; |
1503 | break; |
1553 | |
1504 | |
1554 | case SelectionClear: |
1505 | case SelectionClear: |
1555 | selection_clear (); |
1506 | selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]); |
1556 | break; |
1507 | break; |
1557 | |
1508 | |
1558 | case SelectionNotify: |
1509 | case SelectionNotify: |
1559 | if (selection_wait == Sel_normal) |
1510 | if (selection_wait == Sel_normal) |
1560 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1511 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
… | |
… | |
1563 | case SelectionRequest: |
1514 | case SelectionRequest: |
1564 | selection_send (ev.xselectionrequest); |
1515 | selection_send (ev.xselectionrequest); |
1565 | break; |
1516 | break; |
1566 | |
1517 | |
1567 | case MapNotify: |
1518 | case MapNotify: |
|
|
1519 | #ifdef HAVE_BG_PIXMAP |
|
|
1520 | /* This is needed specifically to fix the case of no window manager or a |
|
|
1521 | * non-reparenting window manager. In those cases we never get first |
|
|
1522 | * ConfigureNotify. Also that speeds startup under normal WM, by taking |
|
|
1523 | * care of multiplicity of ConfigureNotify events arriving while WM does |
|
|
1524 | * reparenting. |
|
|
1525 | * We should not render background immediately, as there could be several |
|
|
1526 | * ConfigureNotify's to follow. Lets take care of all of them in one scoop |
|
|
1527 | * by scheduling background redraw as soon as we can, but giving a short |
|
|
1528 | * bit of time for ConfigureNotifies to arrive. |
|
|
1529 | * We should render background PRIOR to drawing any text, but AFTER all |
|
|
1530 | * of ConfigureNotifys for the best results. |
|
|
1531 | */ |
|
|
1532 | if (bgPixmap.flags & bgPixmap_t::isInvalid) |
|
|
1533 | update_background_ev.start (0.025); |
|
|
1534 | #endif |
1568 | mapped = 1; |
1535 | mapped = 1; |
1569 | #ifdef TEXT_BLINK |
1536 | #ifdef TEXT_BLINK |
1570 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
1537 | text_blink_ev.start (); |
1571 | #endif |
1538 | #endif |
1572 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1539 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1573 | break; |
1540 | break; |
1574 | |
1541 | |
1575 | case UnmapNotify: |
1542 | case UnmapNotify: |
… | |
… | |
1577 | #ifdef TEXT_BLINK |
1544 | #ifdef TEXT_BLINK |
1578 | text_blink_ev.stop (); |
1545 | text_blink_ev.stop (); |
1579 | #endif |
1546 | #endif |
1580 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1547 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1581 | break; |
1548 | break; |
1582 | |
|
|
1583 | #ifdef TRANSPARENT |
|
|
1584 | case ReparentNotify: |
|
|
1585 | rootwin_cb (ev); |
|
|
1586 | break; |
|
|
1587 | #endif /* TRANSPARENT */ |
|
|
1588 | |
1549 | |
1589 | case GraphicsExpose: |
1550 | case GraphicsExpose: |
1590 | case Expose: |
1551 | case Expose: |
1591 | if (ev.xany.window == vt) |
1552 | if (ev.xany.window == vt) |
1592 | { |
1553 | { |
1593 | do |
1554 | do |
|
|
1555 | { |
1594 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1556 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1595 | ev.xexpose.width, ev.xexpose.height, False); |
1557 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1558 | } |
1596 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1559 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1597 | |
1560 | |
1598 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1561 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1599 | |
1562 | |
1600 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1563 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1564 | { |
1601 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1565 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1602 | ev.xexpose.width, ev.xexpose.height, False); |
1566 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1567 | } |
1603 | |
1568 | |
1604 | scr_refresh (refresh_type); |
1569 | want_refresh = 1; |
1605 | } |
1570 | } |
1606 | else |
1571 | else |
1607 | { |
1572 | { |
1608 | XEvent unused_event; |
1573 | XEvent unused_event; |
1609 | |
1574 | |
1610 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1575 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1611 | ; |
1576 | ; |
1612 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1577 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1613 | ; |
1578 | ; |
1614 | |
1579 | |
1615 | if (isScrollbarWindow (ev.xany.window)) |
1580 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1616 | { |
1581 | { |
1617 | scrollBar.setIdle (); |
1582 | scrollBar.state = STATE_IDLE; |
1618 | scrollbar_show (0); |
1583 | scrollBar.show (0); |
1619 | } |
1584 | } |
1620 | #ifdef MENUBAR |
|
|
1621 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1622 | menubar_expose (); |
|
|
1623 | #endif |
|
|
1624 | |
|
|
1625 | #ifdef TRANSPARENT |
|
|
1626 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1627 | XClearWindow (disp, ev.xany.window); |
|
|
1628 | #endif |
|
|
1629 | } |
1585 | } |
1630 | break; |
1586 | break; |
1631 | |
1587 | |
1632 | case MotionNotify: |
1588 | case MotionNotify: |
1633 | #ifdef POINTER_BLANK |
1589 | #ifdef POINTER_BLANK |
1634 | if (hidden_pointer) |
1590 | if (hidden_pointer) |
1635 | pointer_unblank (); |
1591 | pointer_unblank (); |
1636 | #endif |
1592 | #endif |
1637 | #if MENUBAR |
1593 | if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
1638 | if (isMenuBarWindow (ev.xany.window)) |
1594 | || priv_modes & PrivMode_MouseAnyEvent) |
1639 | { |
|
|
1640 | menubar_control (ev.xbutton); |
1595 | mouse_report (ev.xbutton); |
1641 | break; |
|
|
1642 | } |
|
|
1643 | #endif |
|
|
1644 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1596 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1645 | break; |
1597 | break; |
1646 | |
1598 | |
1647 | if (ev.xany.window == vt) |
1599 | if (ev.xany.window == vt) |
1648 | { |
1600 | { |
|
|
1601 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1649 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1602 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1650 | ; // nop |
1603 | ; // nop |
1651 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1604 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1652 | { |
1605 | { |
1653 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1606 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1654 | ; |
1607 | ; |
1655 | |
1608 | |
1656 | XQueryPointer (disp, vt, |
1609 | XQueryPointer (dpy, vt, |
1657 | &unused_root, &unused_child, |
1610 | &unused_root, &unused_child, |
1658 | &unused_root_x, &unused_root_y, |
1611 | &unused_root_x, &unused_root_y, |
1659 | &ev.xbutton.x, &ev.xbutton.y, |
1612 | &ev.xbutton.x, &ev.xbutton.y, |
1660 | &ev.xbutton.state); |
1613 | &ev.xbutton.state); |
1661 | #ifdef MOUSE_THRESHOLD |
1614 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1681 | int dist; |
1634 | int dist; |
1682 | |
1635 | |
1683 | /* don't clobber the current delay if we are |
1636 | /* don't clobber the current delay if we are |
1684 | * already in the middle of scrolling. |
1637 | * already in the middle of scrolling. |
1685 | */ |
1638 | */ |
1686 | if (!sel_scroll_ev.active) |
1639 | if (!sel_scroll_ev.is_active ()) |
1687 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1640 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1688 | |
1641 | |
1689 | /* save the event params so we can highlight |
1642 | /* save the event params so we can highlight |
1690 | * the selection in the pending-scroll loop |
1643 | * the selection in the pending-scroll loop |
1691 | */ |
1644 | */ |
1692 | selection_save_x = ev.xbutton.x; |
1645 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1714 | else |
1667 | else |
1715 | { |
1668 | { |
1716 | /* we are within the text window, so we |
1669 | /* we are within the text window, so we |
1717 | * shouldn't be scrolling |
1670 | * shouldn't be scrolling |
1718 | */ |
1671 | */ |
1719 | if (sel_scroll_ev.active) |
|
|
1720 | sel_scroll_ev.stop(); |
1672 | sel_scroll_ev.stop(); |
1721 | } |
1673 | } |
1722 | #endif |
1674 | #endif |
1723 | #ifdef MOUSE_THRESHOLD |
1675 | #ifdef MOUSE_THRESHOLD |
1724 | } |
1676 | } |
1725 | #endif |
1677 | #endif |
1726 | } |
1678 | } |
1727 | } |
1679 | } |
1728 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1680 | else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) |
1729 | { |
1681 | { |
1730 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1682 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1731 | MotionNotify, &ev)) |
1683 | MotionNotify, &ev)) |
1732 | ; |
1684 | ; |
1733 | |
1685 | |
1734 | XQueryPointer (disp, scrollBar.win, |
1686 | XQueryPointer (dpy, scrollBar.win, |
1735 | &unused_root, &unused_child, |
1687 | &unused_root, &unused_child, |
1736 | &unused_root_x, &unused_root_y, |
1688 | &unused_root_x, &unused_root_y, |
1737 | &ev.xbutton.x, &ev.xbutton.y, |
1689 | &ev.xbutton.x, &ev.xbutton.y, |
1738 | &unused_mask); |
1690 | &unused_mask); |
1739 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1691 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1740 | scrollbar_size ()); |
1692 | scrollBar.size ()); |
1741 | scr_refresh (refresh_type); |
|
|
1742 | refresh_limit = 0; |
1693 | want_refresh = 1; |
1743 | scrollbar_show (1); |
1694 | scrollBar.show (1); |
1744 | } |
1695 | } |
1745 | break; |
1696 | break; |
1746 | } |
1697 | } |
|
|
1698 | |
|
|
1699 | #if defined(CURSOR_BLINK) |
|
|
1700 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1701 | { |
|
|
1702 | if (hidden_cursor) |
|
|
1703 | { |
|
|
1704 | hidden_cursor = 0; |
|
|
1705 | want_refresh = 1; |
|
|
1706 | } |
|
|
1707 | |
|
|
1708 | cursor_blink_ev.again (); |
|
|
1709 | } |
|
|
1710 | #endif |
|
|
1711 | |
|
|
1712 | #if defined(POINTER_BLANK) |
|
|
1713 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1714 | { |
|
|
1715 | if (ev.type == MotionNotify |
|
|
1716 | || ev.type == ButtonPress |
|
|
1717 | || ev.type == ButtonRelease) |
|
|
1718 | if (hidden_pointer) |
|
|
1719 | pointer_unblank (); |
|
|
1720 | |
|
|
1721 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1722 | pointer_blank (); |
|
|
1723 | } |
|
|
1724 | #endif |
|
|
1725 | |
|
|
1726 | refresh_check (); |
1747 | } |
1727 | } |
|
|
1728 | |
|
|
1729 | #if ENABLE_FRILLS |
|
|
1730 | void |
|
|
1731 | rxvt_term::set_urgency (bool enable) |
|
|
1732 | { |
|
|
1733 | if (enable == urgency_hint) |
|
|
1734 | return; |
|
|
1735 | |
|
|
1736 | if (XWMHints *h = XGetWMHints (dpy, parent[0])) |
|
|
1737 | { |
|
|
1738 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
|
|
1739 | XSetWMHints (dpy, parent[0], h); |
|
|
1740 | urgency_hint = enable; |
|
|
1741 | } |
|
|
1742 | } |
|
|
1743 | #endif |
1748 | |
1744 | |
1749 | void |
1745 | void |
1750 | rxvt_term::focus_in () |
1746 | rxvt_term::focus_in () |
1751 | { |
1747 | { |
1752 | if (!focus) |
1748 | if (!focus) |
1753 | { |
1749 | { |
1754 | focus = 1; |
1750 | focus = 1; |
1755 | want_refresh = 1; |
1751 | want_refresh = 1; |
1756 | |
1752 | |
1757 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1758 | |
|
|
1759 | #if USE_XIM |
1753 | #if USE_XIM |
1760 | if (Input_Context != NULL) |
1754 | if (Input_Context != NULL) |
1761 | { |
1755 | { |
1762 | IMSetStatusPosition (); |
1756 | IMSetPosition (); |
1763 | XSetICFocus (Input_Context); |
1757 | XSetICFocus (Input_Context); |
1764 | } |
1758 | } |
1765 | #endif |
1759 | #endif |
1766 | #if CURSOR_BLINK |
1760 | #if CURSOR_BLINK |
1767 | if (OPTION (Opt_cursorBlink)) |
1761 | if (option (Opt_cursorBlink)) |
1768 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1762 | cursor_blink_ev.again (); |
1769 | #endif |
1763 | #endif |
1770 | #if OFF_FOCUS_FADING |
1764 | #if OFF_FOCUS_FADING |
1771 | if (rs[Rs_fade]) |
1765 | if (rs[Rs_fade]) |
1772 | { |
1766 | { |
1773 | pix_colors = pix_colors_focused; |
1767 | pix_colors = pix_colors_focused; |
1774 | scr_recolour (); |
1768 | scr_recolour (); |
1775 | } |
1769 | } |
1776 | #endif |
1770 | #endif |
|
|
1771 | #if ENABLE_FRILLS |
|
|
1772 | if (option (Opt_urgentOnBell)) |
|
|
1773 | set_urgency (0); |
|
|
1774 | #endif |
|
|
1775 | |
|
|
1776 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1777 | } |
1777 | } |
1778 | } |
1778 | } |
1779 | |
1779 | |
1780 | void |
1780 | void |
1781 | rxvt_term::focus_out () |
1781 | rxvt_term::focus_out () |
… | |
… | |
1783 | if (focus) |
1783 | if (focus) |
1784 | { |
1784 | { |
1785 | focus = 0; |
1785 | focus = 0; |
1786 | want_refresh = 1; |
1786 | want_refresh = 1; |
1787 | |
1787 | |
1788 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1788 | #if ENABLE_FRILLS |
1789 | |
1789 | if (option (Opt_urgentOnBell)) |
|
|
1790 | set_urgency (0); |
|
|
1791 | #endif |
1790 | #if ENABLE_FRILLS || ISO_14755 |
1792 | #if ENABLE_FRILLS || ISO_14755 |
1791 | if (iso14755buf) |
1793 | if (iso14755buf) |
1792 | { |
1794 | { |
1793 | iso14755buf = 0; |
1795 | iso14755buf = 0; |
1794 | # if ENABLE_OVERLAY |
1796 | # if ISO_14755 |
1795 | scr_overlay_off (); |
1797 | scr_overlay_off (); |
1796 | # endif |
1798 | # endif |
1797 | } |
1799 | } |
1798 | #endif |
1800 | #endif |
1799 | #if USE_XIM |
1801 | #if USE_XIM |
1800 | if (Input_Context != NULL) |
1802 | if (Input_Context != NULL) |
1801 | XUnsetICFocus (Input_Context); |
1803 | XUnsetICFocus (Input_Context); |
1802 | #endif |
1804 | #endif |
1803 | #if CURSOR_BLINK |
1805 | #if CURSOR_BLINK |
1804 | if (OPTION (Opt_cursorBlink)) |
1806 | if (option (Opt_cursorBlink)) |
1805 | cursor_blink_ev.stop (); |
1807 | cursor_blink_ev.stop (); |
|
|
1808 | |
1806 | hidden_cursor = 0; |
1809 | hidden_cursor = 0; |
1807 | #endif |
1810 | #endif |
1808 | #if OFF_FOCUS_FADING |
1811 | #if OFF_FOCUS_FADING |
1809 | if (rs[Rs_fade]) |
1812 | if (rs[Rs_fade]) |
1810 | { |
1813 | { |
1811 | pix_colors = pix_colors_unfocused; |
1814 | pix_colors = pix_colors_unfocused; |
1812 | scr_recolour (); |
1815 | scr_recolour (); |
1813 | } |
1816 | } |
1814 | #endif |
1817 | #endif |
|
|
1818 | |
|
|
1819 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
|
|
1820 | } |
|
|
1821 | } |
|
|
1822 | |
|
|
1823 | void |
|
|
1824 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1825 | { |
|
|
1826 | #if OFF_FOCUS_FADING |
|
|
1827 | if (rs[Rs_fade]) |
1815 | } |
1828 | { |
|
|
1829 | rgba c; |
|
|
1830 | pix_colors [Color_fade].get (c); |
|
|
1831 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1832 | } |
|
|
1833 | #endif |
1816 | } |
1834 | } |
1817 | |
1835 | |
1818 | #if TRANSPARENT |
1836 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1819 | void |
1837 | void |
1820 | rxvt_term::rootwin_cb (XEvent &ev) |
1838 | rxvt_term::rootwin_cb (XEvent &ev) |
1821 | { |
1839 | { |
1822 | SET_R (this); |
1840 | make_current (); |
1823 | SET_LOCALE (locale); |
|
|
1824 | |
1841 | |
|
|
1842 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1843 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1844 | return; |
|
|
1845 | |
|
|
1846 | # if ENABLE_TRANSPARENCY |
1825 | switch (ev.type) |
1847 | switch (ev.type) |
1826 | { |
1848 | { |
1827 | case PropertyNotify: |
1849 | case PropertyNotify: |
1828 | /* |
1850 | /* |
1829 | * if user used some Esetroot compatible prog to set the root bg, |
1851 | * if user used some Esetroot compatible prog to set the root bg, |
1830 | * use the property to determine the pixmap. We use it later on. |
1852 | * use the property to determine the pixmap. We use it later on. |
1831 | */ |
1853 | */ |
1832 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1854 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1833 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1855 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1834 | return; |
1856 | { |
|
|
1857 | bgPixmap.set_root_pixmap (); |
|
|
1858 | update_background (); |
|
|
1859 | } |
1835 | |
1860 | |
1836 | /* FALLTHROUGH */ |
|
|
1837 | case ReparentNotify: |
|
|
1838 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1839 | want_refresh = want_full_refresh = 1; |
|
|
1840 | break; |
1861 | break; |
1841 | } |
1862 | } |
|
|
1863 | # endif |
|
|
1864 | |
|
|
1865 | refresh_check (); |
1842 | } |
1866 | } |
1843 | #endif |
1867 | #endif |
1844 | |
1868 | |
1845 | void |
1869 | void |
1846 | rxvt_term::button_press (XButtonEvent &ev) |
1870 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1855 | /* |
1879 | /* |
1856 | * VT window processing of button press |
1880 | * VT window processing of button press |
1857 | */ |
1881 | */ |
1858 | if (ev.window == vt) |
1882 | if (ev.window == vt) |
1859 | { |
1883 | { |
|
|
1884 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1885 | return; |
|
|
1886 | |
1860 | #if ISO_14755 |
1887 | #if ISO_14755 |
1861 | // 5.4 |
1888 | // 5.4 |
1862 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1889 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1863 | { |
1890 | { |
1864 | iso14755_54 (ev.x, ev.y); |
1891 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1874 | /* save the xbutton state (for ButtonRelease) */ |
1901 | /* save the xbutton state (for ButtonRelease) */ |
1875 | MEvent.state = ev.state; |
1902 | MEvent.state = ev.state; |
1876 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1903 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1877 | if (ev.button == MEvent.button && clickintime) |
1904 | if (ev.button == MEvent.button && clickintime) |
1878 | { |
1905 | { |
1879 | /* same button, within alloted time */ |
1906 | /* same button, within allowed time */ |
1880 | MEvent.clicks++; |
1907 | MEvent.clicks++; |
1881 | |
1908 | |
1882 | if (MEvent.clicks > 1) |
1909 | if (MEvent.clicks > 1) |
1883 | { |
1910 | { |
1884 | /* only report double clicks */ |
1911 | /* only report double clicks */ |
… | |
… | |
1898 | mouse_report (ev); |
1925 | mouse_report (ev); |
1899 | } |
1926 | } |
1900 | #else |
1927 | #else |
1901 | MEvent.button = ev.button; |
1928 | MEvent.button = ev.button; |
1902 | mouse_report (ev); |
1929 | mouse_report (ev); |
1903 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1930 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1904 | |
1931 | |
1905 | } |
1932 | } |
1906 | else |
1933 | else |
1907 | { |
1934 | { |
1908 | if (ev.button != MEvent.button) |
1935 | if (ev.button != MEvent.button) |
1909 | MEvent.clicks = 0; |
1936 | MEvent.clicks = 0; |
1910 | |
1937 | |
1911 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1912 | switch (ev.button) |
1938 | switch (ev.button) |
1913 | { |
1939 | { |
1914 | case Button1: |
1940 | case Button1: |
1915 | /* allow meta + click to select rectangular areas */ |
1941 | /* allow meta + click to select rectangular areas */ |
1916 | /* should be done in screen.C */ |
1942 | /* should be done in screen.C */ |
1917 | #if ENABLE_FRILLS |
1943 | #if ENABLE_FRILLS |
1918 | selection.rect = !!(ev.state & ModMetaMask); |
1944 | selection.rect = !!(ev.state & ModMetaMask); |
1919 | #else |
1945 | #else |
1920 | selection.rect = false; |
1946 | selection.rect = false; |
1921 | #endif |
1947 | #endif |
1922 | |
1948 | |
1923 | /* allow shift+left click to extend selection */ |
1949 | /* allow shift+left click to extend selection */ |
1924 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1950 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1925 | { |
1951 | { |
1926 | if (MEvent.button == Button1 && clickintime) |
1952 | if (MEvent.button == Button1 && clickintime) |
1927 | selection_rotate (ev.x, ev.y); |
1953 | selection_rotate (ev.x, ev.y); |
1928 | else |
1954 | else |
1929 | selection_extend (ev.x, ev.y, 1); |
1955 | selection_extend (ev.x, ev.y, 1); |
1930 | } |
1956 | } |
1931 | else |
1957 | else |
1932 | { |
1958 | { |
1933 | if (MEvent.button == Button1 && clickintime) |
1959 | if (MEvent.button == Button1 && clickintime) |
1934 | MEvent.clicks++; |
1960 | MEvent.clicks++; |
1935 | else |
1961 | else |
1936 | MEvent.clicks = 1; |
1962 | MEvent.clicks = 1; |
1937 | |
1963 | |
1938 | selection_click (MEvent.clicks, ev.x, ev.y); |
1964 | selection_click (MEvent.clicks, ev.x, ev.y); |
1939 | } |
1965 | } |
1940 | |
1966 | |
1941 | MEvent.button = Button1; |
1967 | MEvent.button = Button1; |
1942 | break; |
1968 | break; |
1943 | |
1969 | |
1944 | case Button3: |
1970 | case Button3: |
1945 | if (MEvent.button == Button3 && clickintime) |
1971 | if (MEvent.button == Button3 && clickintime) |
1946 | selection_rotate (ev.x, ev.y); |
1972 | selection_rotate (ev.x, ev.y); |
1947 | else |
1973 | else |
1948 | selection_extend (ev.x, ev.y, 1); |
1974 | selection_extend (ev.x, ev.y, 1); |
1949 | |
1975 | |
1950 | MEvent.button = Button3; |
1976 | MEvent.button = Button3; |
1951 | break; |
1977 | break; |
1952 | } |
1978 | } |
1953 | } |
1979 | } |
1954 | |
1980 | |
1955 | MEvent.time = ev.time; |
1981 | MEvent.time = ev.time; |
1956 | return; |
1982 | return; |
1957 | } |
1983 | } |
1958 | |
1984 | |
1959 | /* |
1985 | /* |
1960 | * Scrollbar window processing of button press |
1986 | * Scrollbar window processing of button press |
1961 | */ |
1987 | */ |
1962 | if (isScrollbarWindow (ev.window)) |
1988 | if (scrollBar.state && ev.window == scrollBar.win) |
1963 | { |
1989 | { |
1964 | scrollBar.setIdle (); |
1990 | page_dirn direction = NO_DIR; |
|
|
1991 | |
|
|
1992 | if (scrollBar.upButton (ev.y)) |
|
|
1993 | direction = UP; /* up */ |
|
|
1994 | else if (scrollBar.dnButton (ev.y)) |
|
|
1995 | direction = DN; /* down */ |
|
|
1996 | |
|
|
1997 | scrollBar.state = STATE_IDLE; |
1965 | /* |
1998 | /* |
1966 | * Rxvt-style scrollbar: |
1999 | * Rxvt-style scrollbar: |
1967 | * move up if mouse is above slider |
2000 | * move up if mouse is above slider |
1968 | * move dn if mouse is below slider |
2001 | * move dn if mouse is below slider |
1969 | * |
2002 | * |
… | |
… | |
1978 | /* |
2011 | /* |
1979 | * Mouse report disabled scrollbar: |
2012 | * Mouse report disabled scrollbar: |
1980 | * arrow buttons - send up/down |
2013 | * arrow buttons - send up/down |
1981 | * click on scrollbar - send pageup/down |
2014 | * click on scrollbar - send pageup/down |
1982 | */ |
2015 | */ |
1983 | if ((scrollBar.style == R_SB_NEXT |
2016 | if (direction == UP) |
1984 | && scrollbarnext_upButton (ev.y)) |
|
|
1985 | || (scrollBar.style == R_SB_RXVT |
|
|
1986 | && scrollbarrxvt_upButton (ev.y))) |
|
|
1987 | tt_printf ("\033[A"); |
2017 | tt_printf ("\033[A"); |
1988 | else if ((scrollBar.style == R_SB_NEXT |
2018 | else if (direction == DN) |
1989 | && scrollbarnext_dnButton (ev.y)) |
|
|
1990 | || (scrollBar.style == R_SB_RXVT |
|
|
1991 | && scrollbarrxvt_dnButton (ev.y))) |
|
|
1992 | tt_printf ("\033[B"); |
2019 | tt_printf ("\033[B"); |
1993 | else |
2020 | else |
1994 | switch (ev.button) |
2021 | switch (ev.button) |
1995 | { |
2022 | { |
1996 | case Button2: |
2023 | case Button2: |
… | |
… | |
2003 | tt_printf ("\033[5~"); |
2030 | tt_printf ("\033[5~"); |
2004 | break; |
2031 | break; |
2005 | } |
2032 | } |
2006 | } |
2033 | } |
2007 | else |
2034 | else |
2008 | #endif /* NO_SCROLLBAR_REPORT */ |
2035 | #endif /* NO_SCROLLBAR_REPORT */ |
2009 | |
|
|
2010 | { |
|
|
2011 | char upordown = 0; |
|
|
2012 | |
|
|
2013 | if (scrollBar.style == R_SB_NEXT) |
|
|
2014 | { |
2036 | { |
2015 | if (scrollbarnext_upButton (ev.y)) |
2037 | if (direction != NO_DIR) |
2016 | upordown = -1; /* up */ |
|
|
2017 | else if (scrollbarnext_dnButton (ev.y)) |
|
|
2018 | upordown = 1; /* down */ |
|
|
2019 | } |
|
|
2020 | else if (scrollBar.style == R_SB_RXVT) |
|
|
2021 | { |
|
|
2022 | if (scrollbarrxvt_upButton (ev.y)) |
|
|
2023 | upordown = -1; /* up */ |
|
|
2024 | else if (scrollbarrxvt_dnButton (ev.y)) |
|
|
2025 | upordown = 1; /* down */ |
|
|
2026 | } |
|
|
2027 | if (upordown) |
|
|
2028 | { |
2038 | { |
2029 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
2039 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2040 | if (!cont_scroll_ev.is_active ()) |
2030 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
2041 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2031 | #endif |
2042 | #endif |
2032 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
2043 | if (scr_page (direction, 1)) |
2033 | { |
2044 | { |
2034 | if (upordown < 0) |
2045 | if (direction == UP) |
2035 | scrollBar.setUp (); |
2046 | scrollBar.state = STATE_UP; |
2036 | else |
2047 | else |
2037 | scrollBar.setDn (); |
2048 | scrollBar.state = STATE_DOWN; |
2038 | } |
2049 | } |
2039 | } |
2050 | } |
2040 | else |
2051 | else |
2041 | switch (ev.button) |
2052 | switch (ev.button) |
2042 | { |
2053 | { |
2043 | case Button2: |
2054 | case Button2: |
2044 | switch (scrollbar_align) |
2055 | switch (scrollBar.align) |
2045 | { |
2056 | { |
2046 | case R_SB_ALIGN_TOP: |
2057 | case R_SB_ALIGN_TOP: |
2047 | csrO = 0; |
2058 | csrO = 0; |
2048 | break; |
2059 | break; |
2049 | case R_SB_ALIGN_CENTRE: |
2060 | case R_SB_ALIGN_CENTRE: |
… | |
… | |
2055 | } |
2066 | } |
2056 | |
2067 | |
2057 | if (scrollBar.style == R_SB_XTERM |
2068 | if (scrollBar.style == R_SB_XTERM |
2058 | || scrollbar_above_slider (ev.y) |
2069 | || scrollbar_above_slider (ev.y) |
2059 | || scrollbar_below_slider (ev.y)) |
2070 | || scrollbar_below_slider (ev.y)) |
2060 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2071 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ()); |
2061 | |
2072 | |
2062 | scrollBar.setMotion (); |
2073 | scrollBar.state = STATE_MOTION; |
2063 | break; |
2074 | break; |
2064 | |
2075 | |
2065 | case Button1: |
2076 | case Button1: |
2066 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
2077 | if (scrollBar.align == R_SB_ALIGN_CENTRE) |
2067 | csrO = ev.y - scrollBar.top; |
2078 | csrO = ev.y - scrollBar.top; |
2068 | /* FALLTHROUGH */ |
2079 | /* FALLTHROUGH */ |
2069 | |
2080 | |
2070 | case Button3: |
2081 | case Button3: |
2071 | if (scrollBar.style != R_SB_XTERM) |
2082 | if (scrollBar.style != R_SB_XTERM) |
… | |
… | |
2081 | scr_page (DN, nrow - 1); |
2092 | scr_page (DN, nrow - 1); |
2082 | # else |
2093 | # else |
2083 | scr_page (DN, nrow / 4); |
2094 | scr_page (DN, nrow / 4); |
2084 | # endif |
2095 | # endif |
2085 | else |
2096 | else |
2086 | scrollBar.setMotion (); |
2097 | scrollBar.state = STATE_MOTION; |
2087 | } |
2098 | } |
2088 | else |
2099 | else |
2089 | { |
2100 | { |
2090 | scr_page ((ev.button == Button1 ? DN : UP), |
2101 | scr_page ((ev.button == Button1 ? DN : UP), |
2091 | (nrow |
2102 | (nrow |
2092 | * scrollbar_position (ev.y) |
2103 | * scrollbar_position (ev.y) |
2093 | / scrollbar_size ())); |
2104 | / scrollBar.size ())); |
2094 | } |
2105 | } |
2095 | |
2106 | |
2096 | break; |
2107 | break; |
2097 | } |
2108 | } |
2098 | } |
2109 | } |
2099 | |
2110 | |
2100 | return; |
2111 | return; |
2101 | } |
2112 | } |
2102 | |
|
|
2103 | #if MENUBAR |
|
|
2104 | /* |
|
|
2105 | * Menubar window processing of button press |
|
|
2106 | */ |
|
|
2107 | if (isMenuBarWindow (ev.window)) |
|
|
2108 | menubar_control (ev); |
|
|
2109 | #endif |
|
|
2110 | } |
2113 | } |
2111 | |
2114 | |
2112 | void |
2115 | void |
2113 | rxvt_term::button_release (XButtonEvent &ev) |
2116 | rxvt_term::button_release (XButtonEvent &ev) |
2114 | { |
2117 | { |
… | |
… | |
2116 | |
2119 | |
2117 | csrO = 0; /* reset csr Offset */ |
2120 | csrO = 0; /* reset csr Offset */ |
2118 | if (!bypass_keystate) |
2121 | if (!bypass_keystate) |
2119 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2122 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2120 | |
2123 | |
2121 | if (scrollbar_isUpDn ()) |
2124 | if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
2122 | { |
2125 | { |
2123 | scrollBar.setIdle (); |
2126 | scrollBar.state = STATE_IDLE; |
2124 | scrollbar_show (0); |
2127 | scrollBar.show (0); |
2125 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2126 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2127 | #endif |
|
|
2128 | } |
2128 | } |
2129 | |
2129 | |
2130 | #ifdef SELECTION_SCROLLING |
2130 | #ifdef SELECTION_SCROLLING |
2131 | if (sel_scroll_ev.active) |
|
|
2132 | sel_scroll_ev.stop(); |
2131 | sel_scroll_ev.stop(); |
2133 | #endif |
2132 | #endif |
2134 | |
2133 | |
2135 | if (ev.window == vt) |
2134 | if (ev.window == vt) |
2136 | { |
2135 | { |
|
|
2136 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2137 | return; |
|
|
2138 | |
2137 | #if ISO_14755 |
2139 | #if ISO_14755 |
2138 | // 5.4 |
2140 | // 5.4 |
2139 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2141 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2140 | return; |
2142 | return; |
2141 | #endif |
2143 | #endif |
|
|
2144 | |
2142 | if (reportmode) |
2145 | if (reportmode) |
2143 | { |
2146 | { |
2144 | /* mouse report from vt window */ |
2147 | /* mouse report from vt window */ |
2145 | /* don't report release of wheel "buttons" */ |
2148 | /* don't report release of wheel "buttons" */ |
2146 | if (ev.button >= 4) |
2149 | if (ev.button >= 4) |
… | |
… | |
2157 | mouse_report (ev); |
2160 | mouse_report (ev); |
2158 | } |
2161 | } |
2159 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2162 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2160 | MEvent.button = AnyButton; |
2163 | MEvent.button = AnyButton; |
2161 | mouse_report (ev); |
2164 | mouse_report (ev); |
2162 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2165 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2163 | return; |
2166 | return; |
2164 | } |
2167 | } |
2165 | |
2168 | |
2166 | /* |
2169 | /* |
2167 | * dumb hack to compensate for the failure of click-and-drag |
2170 | * dumb hack to compensate for the failure of click-and-drag |
… | |
… | |
2170 | if (priv_modes & PrivMode_mouse_report |
2173 | if (priv_modes & PrivMode_mouse_report |
2171 | && bypass_keystate |
2174 | && bypass_keystate |
2172 | && ev.button == Button1 && MEvent.clicks <= 1) |
2175 | && ev.button == Button1 && MEvent.clicks <= 1) |
2173 | selection_extend (ev.x, ev.y, 0); |
2176 | selection_extend (ev.x, ev.y, 0); |
2174 | |
2177 | |
2175 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2176 | return; |
|
|
2177 | |
|
|
2178 | switch (ev.button) |
2178 | switch (ev.button) |
2179 | { |
2179 | { |
2180 | case Button1: |
2180 | case Button1: |
2181 | case Button3: |
2181 | case Button3: |
2182 | selection_make (ev.time); |
2182 | selection_make (ev.time); |
2183 | break; |
2183 | break; |
|
|
2184 | |
2184 | case Button2: |
2185 | case Button2: |
2185 | selection_request (ev.time, ev.x, ev.y); |
2186 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2187 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2186 | break; |
2188 | break; |
|
|
2189 | |
2187 | #ifdef MOUSE_WHEEL |
2190 | #ifdef MOUSE_WHEEL |
2188 | case Button4: |
2191 | case Button4: |
2189 | case Button5: |
2192 | case Button5: |
2190 | { |
2193 | { |
2191 | int i; |
2194 | int i; |
… | |
… | |
2193 | |
2196 | |
2194 | v = ev.button == Button4 ? UP : DN; |
2197 | v = ev.button == Button4 ? UP : DN; |
2195 | |
2198 | |
2196 | if (ev.state & ShiftMask) |
2199 | if (ev.state & ShiftMask) |
2197 | i = 1; |
2200 | i = 1; |
2198 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2201 | else if (option (Opt_mouseWheelScrollPage)) |
2199 | i = nrow - 1; |
2202 | i = nrow - 1; |
2200 | else |
2203 | else |
2201 | i = 5; |
2204 | i = 5; |
2202 | |
2205 | |
2203 | # ifdef MOUSE_SLIP_WHEELING |
2206 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2205 | { |
2208 | { |
2206 | mouse_slip_wheel_speed += v ? -1 : 1; |
2209 | mouse_slip_wheel_speed += v ? -1 : 1; |
2207 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2210 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2208 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2211 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2209 | |
2212 | |
2210 | if (slip_wheel_ev.at < NOW) |
2213 | if (!slip_wheel_ev.is_active ()) |
2211 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
2214 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2212 | |
|
|
2213 | slip_wheel_ev.start (); |
|
|
2214 | } |
2215 | } |
2215 | else |
2216 | else |
|
|
2217 | # endif |
2216 | { |
2218 | { |
2217 | # endif |
|
|
2218 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2219 | scr_page (v, i); |
2219 | scr_page (v, i); |
2220 | scr_refresh (SMOOTH_REFRESH); |
|
|
2221 | scrollbar_show (1); |
2220 | scrollBar.show (1); |
2222 | # else |
|
|
2223 | while (i--) |
|
|
2224 | { |
|
|
2225 | scr_page (v, 1); |
|
|
2226 | scr_refresh (SMOOTH_REFRESH); |
|
|
2227 | scrollbar_show (1); |
|
|
2228 | } |
|
|
2229 | # endif |
|
|
2230 | # ifdef MOUSE_SLIP_WHEELING |
|
|
2231 | } |
2221 | } |
2232 | #endif |
|
|
2233 | } |
2222 | } |
2234 | break; |
2223 | break; |
2235 | #endif |
2224 | #endif |
2236 | } |
2225 | } |
2237 | } |
2226 | } |
2238 | #ifdef MENUBAR |
|
|
2239 | else if (isMenuBarWindow (ev.window)) |
|
|
2240 | menubar_control (ev); |
|
|
2241 | #endif |
|
|
2242 | } |
2227 | } |
2243 | |
|
|
2244 | #ifdef TRANSPARENT |
|
|
2245 | #if TINTING |
|
|
2246 | /* taken from aterm-0.4.2 */ |
|
|
2247 | |
|
|
2248 | typedef uint32_t RUINT32T; |
|
|
2249 | |
|
|
2250 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2251 | { |
|
|
2252 | int sh_r, sh_g, sh_b; |
|
|
2253 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2254 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2255 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2256 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2257 | int i; |
|
|
2258 | |
|
|
2259 | Visual *visual = display->visual; |
|
|
2260 | |
|
|
2261 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2262 | |
|
|
2263 | /* for convenience */ |
|
|
2264 | mask_r = visual->red_mask; |
|
|
2265 | mask_g = visual->green_mask; |
|
|
2266 | mask_b = visual->blue_mask; |
|
|
2267 | |
|
|
2268 | /* boring lookup table pre-initialization */ |
|
|
2269 | switch (srcImage->bits_per_pixel) { |
|
|
2270 | case 15: |
|
|
2271 | if ((mask_r != 0x7c00) || |
|
|
2272 | (mask_g != 0x03e0) || |
|
|
2273 | (mask_b != 0x001f)) |
|
|
2274 | return; |
|
|
2275 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2276 | lookup_r = lookup; |
|
|
2277 | lookup_g = lookup+32; |
|
|
2278 | lookup_b = lookup+32+32; |
|
|
2279 | sh_r = 10; |
|
|
2280 | sh_g = 5; |
|
|
2281 | sh_b = 0; |
|
|
2282 | break; |
|
|
2283 | case 16: |
|
|
2284 | if ((mask_r != 0xf800) || |
|
|
2285 | (mask_g != 0x07e0) || |
|
|
2286 | (mask_b != 0x001f)) |
|
|
2287 | return; |
|
|
2288 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2289 | lookup_r = lookup; |
|
|
2290 | lookup_g = lookup+32; |
|
|
2291 | lookup_b = lookup+32+64; |
|
|
2292 | sh_r = 11; |
|
|
2293 | sh_g = 5; |
|
|
2294 | sh_b = 0; |
|
|
2295 | break; |
|
|
2296 | case 24: |
|
|
2297 | if ((mask_r != 0xff0000) || |
|
|
2298 | (mask_g != 0x00ff00) || |
|
|
2299 | (mask_b != 0x0000ff)) |
|
|
2300 | return; |
|
|
2301 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2302 | lookup_r = lookup; |
|
|
2303 | lookup_g = lookup+256; |
|
|
2304 | lookup_b = lookup+256+256; |
|
|
2305 | sh_r = 16; |
|
|
2306 | sh_g = 8; |
|
|
2307 | sh_b = 0; |
|
|
2308 | break; |
|
|
2309 | case 32: |
|
|
2310 | if ((mask_r != 0xff0000) || |
|
|
2311 | (mask_g != 0x00ff00) || |
|
|
2312 | (mask_b != 0x0000ff)) |
|
|
2313 | return; |
|
|
2314 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2315 | lookup_r = lookup; |
|
|
2316 | lookup_g = lookup+256; |
|
|
2317 | lookup_b = lookup+256+256; |
|
|
2318 | sh_r = 16; |
|
|
2319 | sh_g = 8; |
|
|
2320 | sh_b = 0; |
|
|
2321 | break; |
|
|
2322 | default: |
|
|
2323 | return; /* we do not support this color depth */ |
|
|
2324 | } |
|
|
2325 | |
|
|
2326 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2327 | if (shade < 0) { |
|
|
2328 | shade = -shade; |
|
|
2329 | if (shade < 0) shade = 0; |
|
|
2330 | if (shade > 100) shade = 100; |
|
|
2331 | |
|
|
2332 | lower_lim_r = 65535-rm; |
|
|
2333 | lower_lim_g = 65535-gm; |
|
|
2334 | lower_lim_b = 65535-bm; |
|
|
2335 | |
|
|
2336 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2337 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2338 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2339 | |
|
|
2340 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2341 | } else { |
|
|
2342 | if (shade < 0) shade = 0; |
|
|
2343 | if (shade > 100) shade = 100; |
|
|
2344 | |
|
|
2345 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2346 | |
|
|
2347 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2348 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2349 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2350 | } |
|
|
2351 | |
|
|
2352 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2353 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2354 | { |
|
|
2355 | unsigned int tmp; |
|
|
2356 | |
|
|
2357 | tmp = lower_lim_r; |
|
|
2358 | lower_lim_r = lower_lim_b; |
|
|
2359 | lower_lim_b = tmp; |
|
|
2360 | |
|
|
2361 | tmp = upper_lim_r; |
|
|
2362 | upper_lim_r = upper_lim_b; |
|
|
2363 | upper_lim_b = tmp; |
|
|
2364 | } |
|
|
2365 | |
|
|
2366 | /* fill our lookup tables */ |
|
|
2367 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2368 | { |
|
|
2369 | RUINT32T tmp; |
|
|
2370 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2371 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2372 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2373 | } |
|
|
2374 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2375 | { |
|
|
2376 | RUINT32T tmp; |
|
|
2377 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2378 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2379 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2380 | } |
|
|
2381 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2382 | { |
|
|
2383 | RUINT32T tmp; |
|
|
2384 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2385 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2386 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2387 | } |
|
|
2388 | |
|
|
2389 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2390 | switch (srcImage->bits_per_pixel) |
|
|
2391 | { |
|
|
2392 | case 15: |
|
|
2393 | { |
|
|
2394 | unsigned short *p1, *pf, *p, *pl; |
|
|
2395 | p1 = (unsigned short *) srcImage->data; |
|
|
2396 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2397 | while (p1 < pf) |
|
|
2398 | { |
|
|
2399 | p = p1; |
|
|
2400 | pl = p1 + srcImage->width; |
|
|
2401 | for (; p < pl; p++) |
|
|
2402 | { |
|
|
2403 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2404 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2405 | lookup_b[(*p & 0x001f)]; |
|
|
2406 | } |
|
|
2407 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2408 | } |
|
|
2409 | break; |
|
|
2410 | } |
|
|
2411 | case 16: |
|
|
2412 | { |
|
|
2413 | unsigned short *p1, *pf, *p, *pl; |
|
|
2414 | p1 = (unsigned short *) srcImage->data; |
|
|
2415 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2416 | while (p1 < pf) |
|
|
2417 | { |
|
|
2418 | p = p1; |
|
|
2419 | pl = p1 + srcImage->width; |
|
|
2420 | for (; p < pl; p++) |
|
|
2421 | { |
|
|
2422 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2423 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2424 | lookup_b[(*p & 0x001f)]; |
|
|
2425 | } |
|
|
2426 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2427 | } |
|
|
2428 | break; |
|
|
2429 | } |
|
|
2430 | case 24: |
|
|
2431 | { |
|
|
2432 | unsigned char *p1, *pf, *p, *pl; |
|
|
2433 | p1 = (unsigned char *) srcImage->data; |
|
|
2434 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2435 | while (p1 < pf) |
|
|
2436 | { |
|
|
2437 | p = p1; |
|
|
2438 | pl = p1 + srcImage->width * 3; |
|
|
2439 | for (; p < pl; p += 3) |
|
|
2440 | { |
|
|
2441 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2442 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2443 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2444 | } |
|
|
2445 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2446 | } |
|
|
2447 | break; |
|
|
2448 | } |
|
|
2449 | case 32: |
|
|
2450 | { |
|
|
2451 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2452 | p1 = (RUINT32T *) srcImage->data; |
|
|
2453 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2454 | |
|
|
2455 | while (p1 < pf) |
|
|
2456 | { |
|
|
2457 | p = p1; |
|
|
2458 | pl = p1 + srcImage->width; |
|
|
2459 | for (; p < pl; p++) |
|
|
2460 | { |
|
|
2461 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2462 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2463 | lookup_b[(*p & 0x0000ff)] | |
|
|
2464 | (*p & ~0xffffff); |
|
|
2465 | } |
|
|
2466 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2467 | } |
|
|
2468 | break; |
|
|
2469 | } |
|
|
2470 | } |
|
|
2471 | |
|
|
2472 | free (lookup); |
|
|
2473 | } |
|
|
2474 | #endif |
|
|
2475 | |
|
|
2476 | /* |
|
|
2477 | * Check our parents are still who we think they are. |
|
|
2478 | * Do transparency updates if required |
|
|
2479 | */ |
|
|
2480 | int |
|
|
2481 | rxvt_term::check_our_parents () |
|
|
2482 | { |
|
|
2483 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2484 | unsigned long nitems, bytes_after; |
|
|
2485 | Atom atype; |
|
|
2486 | unsigned char *prop = NULL; |
|
|
2487 | Window root, oldp, *list; |
|
|
2488 | Pixmap rootpixmap = None; |
|
|
2489 | XWindowAttributes wattr, wrootattr; |
|
|
2490 | dDisp; |
|
|
2491 | |
|
|
2492 | pchanged = 0; |
|
|
2493 | |
|
|
2494 | if (!OPTION (Opt_transparent)) |
|
|
2495 | return pchanged; /* Don't try any more */ |
|
|
2496 | |
|
|
2497 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2498 | rootdepth = wrootattr.depth; |
|
|
2499 | |
|
|
2500 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2501 | |
|
|
2502 | if (rootdepth != wattr.depth) |
|
|
2503 | { |
|
|
2504 | if (am_transparent) |
|
|
2505 | { |
|
|
2506 | pchanged = 1; |
|
|
2507 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2508 | am_transparent = am_pixmap_trans = 0; |
|
|
2509 | } |
|
|
2510 | |
|
|
2511 | return pchanged; /* Don't try any more */ |
|
|
2512 | } |
|
|
2513 | |
|
|
2514 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2515 | XSync (disp, False); |
|
|
2516 | |
|
|
2517 | /* |
|
|
2518 | * Make the frame window set by the window manager have |
|
|
2519 | * the root background. Some window managers put multiple nested frame |
|
|
2520 | * windows for each client, so we have to take care about that. |
|
|
2521 | */ |
|
|
2522 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2523 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2524 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2525 | &nitems, &bytes_after, &prop) == Success); |
|
|
2526 | |
|
|
2527 | if (!i || prop == NULL) |
|
|
2528 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2529 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2530 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2531 | &nitems, &bytes_after, &prop) == Success); |
|
|
2532 | |
|
|
2533 | if (!i || prop == NULL |
|
|
2534 | #if TINTING |
|
|
2535 | || !rs[Rs_color + Color_tint] |
|
|
2536 | #endif |
|
|
2537 | ) |
|
|
2538 | have_pixmap = 0; |
|
|
2539 | else |
|
|
2540 | { |
|
|
2541 | have_pixmap = 1; |
|
|
2542 | rootpixmap = *(Pixmap *)prop; |
|
|
2543 | XFree (prop); |
|
|
2544 | } |
|
|
2545 | |
|
|
2546 | if (have_pixmap) |
|
|
2547 | { |
|
|
2548 | /* |
|
|
2549 | * Copy display->root pixmap transparency |
|
|
2550 | */ |
|
|
2551 | int sx, sy, nx, ny; |
|
|
2552 | unsigned int nw, nh; |
|
|
2553 | Window cr; |
|
|
2554 | XImage *image; |
|
|
2555 | GC gc; |
|
|
2556 | XGCValues gcvalue; |
|
|
2557 | |
|
|
2558 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2559 | 0, 0, &sx, &sy, &cr); |
|
|
2560 | nw = (unsigned int)szHint.width; |
|
|
2561 | nh = (unsigned int)szHint.height; |
|
|
2562 | nx = ny = 0; |
|
|
2563 | |
|
|
2564 | if (sx < 0) |
|
|
2565 | { |
|
|
2566 | nw += sx; |
|
|
2567 | nx = -sx; |
|
|
2568 | sx = 0; |
|
|
2569 | } |
|
|
2570 | |
|
|
2571 | if (sy < 0) |
|
|
2572 | { |
|
|
2573 | nh += sy; |
|
|
2574 | ny = -sy; |
|
|
2575 | sy = 0; |
|
|
2576 | } |
|
|
2577 | |
|
|
2578 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2579 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2580 | |
|
|
2581 | XSync (disp, False); |
|
|
2582 | allowedxerror = -1; |
|
|
2583 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2584 | |
|
|
2585 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2586 | /* XXX: may need a delay here? */ |
|
|
2587 | allowedxerror = 0; |
|
|
2588 | |
|
|
2589 | if (image == NULL) |
|
|
2590 | { |
|
|
2591 | if (am_transparent && am_pixmap_trans) |
|
|
2592 | { |
|
|
2593 | pchanged = 1; |
|
|
2594 | if (pixmap != None) |
|
|
2595 | { |
|
|
2596 | XFreePixmap (disp, pixmap); |
|
|
2597 | pixmap = None; |
|
|
2598 | } |
|
|
2599 | } |
|
|
2600 | |
|
|
2601 | am_pixmap_trans = 0; |
|
|
2602 | } |
|
|
2603 | else |
|
|
2604 | { |
|
|
2605 | if (pixmap != None) |
|
|
2606 | XFreePixmap (disp, pixmap); |
|
|
2607 | |
|
|
2608 | #if TINTING |
|
|
2609 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2610 | { |
|
|
2611 | unsigned short rm, gm, bm; |
|
|
2612 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2613 | |
|
|
2614 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2615 | |
|
|
2616 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2617 | } |
|
|
2618 | #endif |
|
|
2619 | |
|
|
2620 | pixmap = XCreatePixmap (disp, vt, |
|
|
2621 | szHint.width, szHint.height, image->depth); |
|
|
2622 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2623 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2624 | nx, ny, image->width, image->height); |
|
|
2625 | XFreeGC (disp, gc); |
|
|
2626 | XDestroyImage (image); |
|
|
2627 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2628 | XClearWindow (disp, parent[0]); |
|
|
2629 | |
|
|
2630 | if (!am_transparent || !am_pixmap_trans) |
|
|
2631 | pchanged = 1; |
|
|
2632 | |
|
|
2633 | am_transparent = am_pixmap_trans = 1; |
|
|
2634 | } |
|
|
2635 | } |
|
|
2636 | |
|
|
2637 | if (am_pixmap_trans) |
|
|
2638 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2639 | else |
|
|
2640 | { |
|
|
2641 | unsigned int n; |
|
|
2642 | /* |
|
|
2643 | * InheritPixmap transparency |
|
|
2644 | */ |
|
|
2645 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2646 | { |
|
|
2647 | oldp = parent[i]; |
|
|
2648 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2649 | &parent[i], &list, &n); |
|
|
2650 | XFree (list); |
|
|
2651 | |
|
|
2652 | if (parent[i] == display->root) |
|
|
2653 | { |
|
|
2654 | if (oldp != None) |
|
|
2655 | pchanged = 1; |
|
|
2656 | |
|
|
2657 | break; |
|
|
2658 | } |
|
|
2659 | |
|
|
2660 | if (oldp != parent[i]) |
|
|
2661 | pchanged = 1; |
|
|
2662 | } |
|
|
2663 | |
|
|
2664 | n = 0; |
|
|
2665 | |
|
|
2666 | if (pchanged) |
|
|
2667 | { |
|
|
2668 | for (; n < (unsigned int)i; n++) |
|
|
2669 | { |
|
|
2670 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2671 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2672 | { |
|
|
2673 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2674 | break; |
|
|
2675 | } |
|
|
2676 | } |
|
|
2677 | } |
|
|
2678 | |
|
|
2679 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2680 | { |
|
|
2681 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2682 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2683 | am_transparent = 0; |
|
|
2684 | /* XXX: also turn off Opt_transparent? */ |
|
|
2685 | } |
|
|
2686 | else |
|
|
2687 | { |
|
|
2688 | #if WAIT_FOR_WM |
|
|
2689 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2690 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2691 | sleep (1); |
|
|
2692 | #endif |
|
|
2693 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2694 | { |
|
|
2695 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2696 | XClearWindow (disp, parent[n]); |
|
|
2697 | } |
|
|
2698 | |
|
|
2699 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2700 | am_transparent = 1; |
|
|
2701 | } |
|
|
2702 | |
|
|
2703 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2704 | parent[i] = None; |
|
|
2705 | } |
|
|
2706 | |
|
|
2707 | if (scrollBar.win) |
|
|
2708 | { |
|
|
2709 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2710 | scrollBar.setIdle (); |
|
|
2711 | scrollbar_show (0); |
|
|
2712 | } |
|
|
2713 | |
|
|
2714 | if (am_transparent) |
|
|
2715 | { |
|
|
2716 | want_refresh = want_full_refresh = 1; |
|
|
2717 | if (am_pixmap_trans) |
|
|
2718 | flush (); |
|
|
2719 | } |
|
|
2720 | |
|
|
2721 | return pchanged; |
|
|
2722 | } |
|
|
2723 | #endif |
|
|
2724 | |
2228 | |
2725 | /*}}} */ |
2229 | /*}}} */ |
2726 | |
2230 | |
2727 | bool |
2231 | void |
2728 | rxvt_term::cmd_parse () |
2232 | rxvt_term::cmd_parse () |
2729 | { |
2233 | { |
2730 | bool flag = false; |
|
|
2731 | wchar_t ch = NOCHAR; |
2234 | wchar_t ch = NOCHAR; |
2732 | char *seq_begin; // remember start of esc-sequence here |
2235 | char *seq_begin; // remember start of esc-sequence here |
2733 | |
2236 | |
2734 | for (;;) |
2237 | for (;;) |
2735 | { |
2238 | { |
2736 | if (ch == NOCHAR) |
2239 | if (expect_false (ch == NOCHAR)) |
2737 | { |
2240 | { |
2738 | seq_begin = cmdbuf_ptr; |
2241 | seq_begin = cmdbuf_ptr; |
2739 | ch = next_char (); |
2242 | ch = next_char (); |
2740 | |
2243 | |
2741 | if (ch == NOCHAR) |
2244 | if (ch == NOCHAR) |
2742 | break; |
2245 | break; |
2743 | } |
2246 | } |
2744 | |
2247 | |
2745 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2248 | if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) |
2746 | { |
2249 | { |
2747 | if (!seen_input) |
2250 | if (expect_false (!seen_input)) |
2748 | { |
2251 | { |
2749 | seen_input = 1; |
2252 | seen_input = 1; |
2750 | // many badly-written programs (e.g. jed) contain a race condition: |
2253 | // many badly-written programs (e.g. jed) contain a race condition: |
2751 | // they first read the screensize and then install a SIGWINCH handler. |
2254 | // they first read the screensize and then install a SIGWINCH handler. |
2752 | // some window managers resize the window early, and these programs |
2255 | // some window managers resize the window early, and these programs |
… | |
… | |
2765 | wchar_t *str = buf; |
2268 | wchar_t *str = buf; |
2766 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2269 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2767 | |
2270 | |
2768 | for (;;) |
2271 | for (;;) |
2769 | { |
2272 | { |
2770 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2273 | if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) |
2771 | break; |
2274 | break; |
2772 | |
2275 | |
2773 | *str++ = ch; |
2276 | *str++ = ch; |
2774 | |
2277 | |
2775 | if (ch == C0_LF || str >= eol) |
2278 | if (expect_false (ch == C0_LF || str >= eol)) |
2776 | { |
2279 | { |
2777 | if (ch == C0_LF) |
2280 | if (ch == C0_LF) |
2778 | nlines++; |
2281 | nlines++; |
2779 | |
2282 | |
2780 | refresh_count++; |
2283 | refresh_count++; |
2781 | |
2284 | |
2782 | if (!OPTION (Opt_jumpScroll) |
2285 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2783 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2784 | { |
2286 | { |
2785 | refreshnow = true; |
|
|
2786 | refresh_count = 0; |
2287 | refresh_count = 0; |
|
|
2288 | |
|
|
2289 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2290 | { |
|
|
2291 | refreshnow = true; |
2787 | ch = NOCHAR; |
2292 | ch = NOCHAR; |
2788 | break; |
2293 | break; |
|
|
2294 | } |
2789 | } |
2295 | } |
2790 | |
2296 | |
2791 | // scr_add_lines only works for nlines <= nrow - 1. |
2297 | // scr_add_lines only works for nlines <= nrow - 1. |
2792 | if (nlines >= nrow - 1) |
2298 | if (nlines >= nrow - 1) |
2793 | { |
2299 | { |
|
|
2300 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2794 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2301 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2795 | scr_add_lines (buf, str - buf, nlines); |
2302 | scr_add_lines (buf, str - buf, nlines); |
2796 | |
2303 | |
2797 | nlines = 0; |
2304 | nlines = 0; |
2798 | str = buf; |
2305 | str = buf; |
2799 | eol = str + min (ncol, UBUFSIZ); |
2306 | eol = str + min (ncol, UBUFSIZ); |
… | |
… | |
2814 | |
2321 | |
2815 | seq_begin = cmdbuf_ptr; |
2322 | seq_begin = cmdbuf_ptr; |
2816 | ch = next_char (); |
2323 | ch = next_char (); |
2817 | } |
2324 | } |
2818 | |
2325 | |
|
|
2326 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2819 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2327 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2820 | scr_add_lines (buf, str - buf, nlines); |
2328 | scr_add_lines (buf, str - buf, nlines); |
2821 | |
2329 | |
2822 | /* |
2330 | /* |
2823 | * If there have been a lot of new lines, then update the screen |
2331 | * If there have been a lot of new lines, then update the screen |
2824 | * What the heck I'll cheat and only refresh less than every page-full. |
2332 | * What the heck we'll cheat and only refresh less than every page-full. |
2825 | * the number of pages between refreshes is refresh_limit, which |
2333 | * if skipScroll is enabled. |
2826 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2827 | */ |
2334 | */ |
2828 | if (refreshnow) |
2335 | if (refreshnow) |
2829 | { |
2336 | { |
2830 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2831 | refresh_limit++; |
|
|
2832 | else |
|
|
2833 | { |
|
|
2834 | flag = true; |
|
|
2835 | scr_refresh (refresh_type); |
2337 | scr_refresh (); |
2836 | flush_ev.stop (); |
2338 | want_refresh = 1; |
2837 | } |
|
|
2838 | } |
2339 | } |
2839 | |
|
|
2840 | } |
2340 | } |
2841 | else |
2341 | else |
2842 | { |
2342 | { |
2843 | try |
2343 | try |
2844 | { |
2344 | { |
… | |
… | |
2852 | } |
2352 | } |
2853 | |
2353 | |
2854 | ch = NOCHAR; |
2354 | ch = NOCHAR; |
2855 | } |
2355 | } |
2856 | } |
2356 | } |
2857 | |
|
|
2858 | return flag; |
|
|
2859 | } |
2357 | } |
2860 | |
2358 | |
2861 | // read the next character |
2359 | // read the next character |
2862 | wchar_t |
2360 | wchar_t |
2863 | rxvt_term::next_char () |
2361 | rxvt_term::next_char () NOTHROW |
2864 | { |
2362 | { |
2865 | while (cmdbuf_ptr < cmdbuf_endp) |
2363 | while (cmdbuf_ptr < cmdbuf_endp) |
2866 | { |
2364 | { |
2867 | // assume 7-bit to be ascii ALWAYS |
2365 | // assume 7-bit to be ascii ALWAYS |
2868 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2366 | if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) |
2869 | return *cmdbuf_ptr++; |
2367 | return *cmdbuf_ptr++; |
2870 | |
2368 | |
2871 | wchar_t wc; |
2369 | wchar_t wc; |
2872 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2370 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2873 | |
2371 | |
… | |
… | |
2877 | cmdbuf_ptr = cmdbuf_endp; |
2375 | cmdbuf_ptr = cmdbuf_endp; |
2878 | break; |
2376 | break; |
2879 | } |
2377 | } |
2880 | |
2378 | |
2881 | if (len == (size_t)-1) |
2379 | if (len == (size_t)-1) |
|
|
2380 | { |
|
|
2381 | mbstate.reset (); // reset now undefined conversion state |
2882 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2382 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
2383 | } |
2883 | |
2384 | |
2884 | // assume wchar == unicode |
2385 | // assume wchar == unicode |
2885 | cmdbuf_ptr += len; |
2386 | cmdbuf_ptr += len; |
2886 | return wc & UNICODE_MASK; |
2387 | return wc & UNICODE_MASK; |
2887 | } |
2388 | } |
… | |
… | |
2889 | return NOCHAR; |
2390 | return NOCHAR; |
2890 | } |
2391 | } |
2891 | |
2392 | |
2892 | // read the next octet |
2393 | // read the next octet |
2893 | uint32_t |
2394 | uint32_t |
2894 | rxvt_term::next_octet () |
2395 | rxvt_term::next_octet () NOTHROW |
2895 | { |
2396 | { |
2896 | return cmdbuf_ptr < cmdbuf_endp |
2397 | return cmdbuf_ptr < cmdbuf_endp |
2897 | ? (unsigned char)*cmdbuf_ptr++ |
2398 | ? (unsigned char)*cmdbuf_ptr++ |
2898 | : NOCHAR; |
2399 | : NOCHAR; |
2899 | } |
2400 | } |
|
|
2401 | |
|
|
2402 | static class out_of_input out_of_input; |
2900 | |
2403 | |
2901 | /* rxvt_cmd_getc () - Return next input character */ |
2404 | /* rxvt_cmd_getc () - Return next input character */ |
2902 | /* |
2405 | /* |
2903 | * Return the next input character after first passing any keyboard input |
2406 | * Return the next input character after first passing any keyboard input |
2904 | * to the command. |
2407 | * to the command. |
2905 | */ |
2408 | */ |
2906 | wchar_t |
2409 | wchar_t |
2907 | rxvt_term::cmd_getc () |
2410 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2908 | { |
2411 | { |
2909 | wchar_t c = next_char (); |
2412 | wchar_t c = next_char (); |
2910 | |
2413 | |
2911 | if (c == NOCHAR) |
2414 | if (c == NOCHAR) |
2912 | throw out_of_input; |
2415 | throw out_of_input; |
2913 | |
2416 | |
2914 | return c; |
2417 | return c; |
2915 | } |
2418 | } |
2916 | |
2419 | |
2917 | uint32_t |
2420 | uint32_t |
2918 | rxvt_term::cmd_get8 () |
2421 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2919 | { |
2422 | { |
2920 | uint32_t c = next_octet (); |
2423 | uint32_t c = next_octet (); |
2921 | |
2424 | |
2922 | if (c == NOCHAR) |
2425 | if (c == NOCHAR) |
2923 | throw out_of_input; |
2426 | throw out_of_input; |
… | |
… | |
2929 | /*----------------------------------------------------------------------*/ |
2432 | /*----------------------------------------------------------------------*/ |
2930 | #ifdef PRINTPIPE |
2433 | #ifdef PRINTPIPE |
2931 | FILE * |
2434 | FILE * |
2932 | rxvt_term::popen_printer () |
2435 | rxvt_term::popen_printer () |
2933 | { |
2436 | { |
2934 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2437 | FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); |
2935 | |
2438 | |
2936 | if (stream == NULL) |
2439 | if (stream == NULL) |
2937 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2440 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2938 | |
2441 | |
2939 | return stream; |
2442 | return stream; |
… | |
… | |
2950 | * simulate attached vt100 printer |
2453 | * simulate attached vt100 printer |
2951 | */ |
2454 | */ |
2952 | void |
2455 | void |
2953 | rxvt_term::process_print_pipe () |
2456 | rxvt_term::process_print_pipe () |
2954 | { |
2457 | { |
2955 | int done; |
2458 | FILE *fd = popen_printer (); |
2956 | FILE *fd; |
|
|
2957 | |
2459 | |
2958 | if ((fd = popen_printer ()) == NULL) |
2460 | if (!fd) |
2959 | return; |
2461 | return; |
2960 | |
2462 | |
2961 | /* |
2463 | /* |
2962 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2464 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2963 | * is received. |
2465 | * is received. |
2964 | */ |
2466 | */ |
2965 | for (done = 0; !done;) |
2467 | for (int done = 0; !done; ) |
2966 | { |
2468 | { |
2967 | unsigned char buf[8]; |
2469 | unsigned char buf[8]; |
2968 | unicode_t ch; |
2470 | unicode_t ch; |
2969 | unsigned int i, len; |
2471 | unsigned int i, len; |
2970 | |
2472 | |
… | |
… | |
2989 | { |
2491 | { |
2990 | if ((buf[len++] = cmd_getc ()) == 'i') |
2492 | if ((buf[len++] = cmd_getc ()) == 'i') |
2991 | break; /* done = 1 */ |
2493 | break; /* done = 1 */ |
2992 | } |
2494 | } |
2993 | } |
2495 | } |
2994 | |
2496 | |
2995 | for (i = 0; i < len; i++) |
2497 | for (i = 0; i < len; i++) |
2996 | if (putc (buf[i], fd) == EOF) |
2498 | if (putc (buf[i], fd) == EOF) |
2997 | { |
2499 | { |
2998 | done = 1; |
2500 | done = 1; |
2999 | break; |
2501 | break; |
… | |
… | |
3001 | } |
2503 | } |
3002 | } |
2504 | } |
3003 | |
2505 | |
3004 | pclose_printer (fd); |
2506 | pclose_printer (fd); |
3005 | } |
2507 | } |
3006 | #endif /* PRINTPIPE */ |
2508 | #endif /* PRINTPIPE */ |
3007 | /*}}} */ |
2509 | /*}}} */ |
3008 | |
2510 | |
3009 | /* *INDENT-OFF* */ |
2511 | /* *INDENT-OFF* */ |
3010 | enum { |
2512 | enum { |
3011 | C1_40 = 0x40, |
2513 | C1_40 = 0x40, |
… | |
… | |
3061 | process_dcs_seq (); |
2563 | process_dcs_seq (); |
3062 | break; |
2564 | break; |
3063 | case 0x9b: /* CSI */ |
2565 | case 0x9b: /* CSI */ |
3064 | process_csi_seq (); |
2566 | process_csi_seq (); |
3065 | break; |
2567 | break; |
3066 | case 0x9d: /* CSI */ |
2568 | case 0x9d: /* OSC */ |
3067 | process_osc_seq (); |
2569 | process_osc_seq (); |
3068 | break; |
2570 | break; |
3069 | #endif |
2571 | #endif |
3070 | } |
2572 | } |
3071 | } |
2573 | } |
… | |
… | |
3115 | break; |
2617 | break; |
3116 | case 'Z': /* identify the terminal type */ |
2618 | case 'Z': /* identify the terminal type */ |
3117 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2619 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
3118 | break; |
2620 | break; |
3119 | case '<': /* turn off VT52 mode */ |
2621 | case '<': /* turn off VT52 mode */ |
3120 | PrivMode (0, PrivMode_vt52); |
2622 | set_privmode (PrivMode_vt52, 0); |
3121 | break; |
2623 | break; |
3122 | case 'F': /* use special graphics character set */ |
2624 | case 'F': /* use special graphics character set */ |
3123 | case 'G': /* use regular character set */ |
2625 | case 'G': /* use regular character set */ |
3124 | /* unimplemented */ |
2626 | /* unimplemented */ |
3125 | break; |
2627 | break; |
… | |
… | |
3161 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2663 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3162 | break; |
2664 | break; |
3163 | case '+': |
2665 | case '+': |
3164 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2666 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3165 | break; |
2667 | break; |
3166 | #if ENABLE_FRILLS |
2668 | #if !ENABLE_MINIMAL |
3167 | case '6': |
2669 | case '6': |
3168 | scr_backindex (); |
2670 | scr_backindex (); |
3169 | break; |
2671 | break; |
3170 | #endif |
2672 | #endif |
3171 | case '7': |
2673 | case '7': |
3172 | scr_cursor (SAVE); |
2674 | scr_cursor (SAVE); |
3173 | break; |
2675 | break; |
3174 | case '8': |
2676 | case '8': |
3175 | scr_cursor (RESTORE); |
2677 | scr_cursor (RESTORE); |
3176 | break; |
2678 | break; |
3177 | #if ENABLE_FRILLS |
2679 | #if !ENABLE_MINIMAL |
3178 | case '9': |
2680 | case '9': |
3179 | scr_forwardindex (); |
2681 | scr_forwardindex (); |
3180 | break; |
2682 | break; |
3181 | #endif |
2683 | #endif |
3182 | case '=': |
2684 | case '=': |
3183 | case '>': |
2685 | case '>': |
3184 | PrivMode ((ch == '='), PrivMode_aplKP); |
2686 | set_privmode (PrivMode_aplKP, ch == '='); |
3185 | break; |
2687 | break; |
3186 | |
2688 | |
3187 | case C1_40: |
2689 | case C1_40: |
3188 | cmd_getc (); |
2690 | cmd_getc (); |
3189 | break; |
2691 | break; |
… | |
… | |
3193 | |
2695 | |
3194 | /* 8.3.87: NEXT LINE */ |
2696 | /* 8.3.87: NEXT LINE */ |
3195 | case C1_NEL: /* ESC E */ |
2697 | case C1_NEL: /* ESC E */ |
3196 | { |
2698 | { |
3197 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
2699 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3198 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
2700 | scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1); |
3199 | } |
2701 | } |
3200 | break; |
2702 | break; |
3201 | |
2703 | |
3202 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2704 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3203 | case C1_ESA: /* ESC G */ |
2705 | case C1_ESA: /* ESC G */ |
… | |
… | |
3228 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2730 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3229 | case C1_SCI: /* ESC Z */ |
2731 | case C1_SCI: /* ESC Z */ |
3230 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2732 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3231 | break; /* steal obsolete ESC [ c */ |
2733 | break; /* steal obsolete ESC [ c */ |
3232 | |
2734 | |
3233 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2735 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */ |
3234 | case C1_CSI: /* ESC [ */ |
2736 | case C1_CSI: /* ESC [ */ |
3235 | process_csi_seq (); |
2737 | process_csi_seq (); |
3236 | break; |
2738 | break; |
3237 | |
2739 | |
3238 | /* 8.3.90: OPERATING SYSTEM COMMAND */ |
2740 | /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */ |
3239 | case C1_OSC: /* ESC ] */ |
2741 | case C1_OSC: /* ESC ] */ |
3240 | process_osc_seq (); |
2742 | process_osc_seq (); |
3241 | break; |
2743 | break; |
3242 | |
2744 | |
3243 | /* 8.3.106: RESET TO INITIAL STATE */ |
2745 | /* 8.3.106: RESET TO INITIAL STATE (RIS) */ |
3244 | case 'c': |
2746 | case 'c': |
3245 | mbstate.reset (); |
2747 | mbstate.reset (); |
3246 | scr_poweron (); |
2748 | scr_poweron (); |
3247 | scrollbar_show (1); |
2749 | scrollBar.show (1); |
3248 | break; |
2750 | break; |
3249 | |
2751 | |
3250 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
2752 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
3251 | case 'n': |
2753 | case 'n': |
3252 | scr_charset_choose (2); |
2754 | scr_charset_choose (2); |
… | |
… | |
3272 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2774 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
3273 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
2775 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
3274 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
2776 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
3275 | }; |
2777 | }; |
3276 | |
2778 | |
3277 | #define make_byte(b7,b6,b5,b4,b3,b2,b1,b0) \ |
2779 | #define make_byte(b0,b1,b2,b3,b4,b5,b6,b7) \ |
3278 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
2780 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
3279 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
2781 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
3280 | #define get_byte_array_bit(array, bit) \ |
2782 | #define get_byte_array_bit(array, bit) \ |
3281 | (!! ((array)[ (bit) / 8] & (128 >> ((bit) & 7)))) |
2783 | (!! ((array)[(bit) >> 3] & (1 << ((bit) & 7)))) |
3282 | |
2784 | |
3283 | const unsigned char csi_defaults[] = |
2785 | static const unsigned char csi_defaults[] = |
3284 | { |
2786 | { |
3285 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
2787 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
3286 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
2788 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
3287 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
2789 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
3288 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
2790 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
… | |
… | |
3297 | rxvt_term::process_csi_seq () |
2799 | rxvt_term::process_csi_seq () |
3298 | { |
2800 | { |
3299 | unicode_t ch, priv, i; |
2801 | unicode_t ch, priv, i; |
3300 | unsigned int nargs, p; |
2802 | unsigned int nargs, p; |
3301 | int n, ndef; |
2803 | int n, ndef; |
3302 | int arg[ESC_ARGS]; |
2804 | int arg[ESC_ARGS] = { }; |
3303 | |
2805 | |
3304 | for (nargs = ESC_ARGS; nargs > 0;) |
2806 | nargs = 0; |
3305 | arg[--nargs] = 0; |
|
|
3306 | |
2807 | |
3307 | priv = 0; |
2808 | priv = 0; |
3308 | ch = cmd_getc (); |
2809 | ch = cmd_getc (); |
3309 | if (ch >= '<' && ch <= '?') |
2810 | if ((ch >= '<' && ch <= '?') || ch == '!') |
|
|
2811 | { |
3310 | { /* '<' '=' '>' '?' */ |
2812 | /* '<' '=' '>' '?' '!' */ |
3311 | priv = ch; |
2813 | priv = ch; |
3312 | ch = cmd_getc (); |
2814 | ch = cmd_getc (); |
3313 | } |
2815 | } |
3314 | |
2816 | |
3315 | /* read any numerical arguments */ |
2817 | /* read any numerical arguments */ |
… | |
… | |
3344 | ndef = get_byte_array_bit (csi_defaults, i); |
2846 | ndef = get_byte_array_bit (csi_defaults, i); |
3345 | for (p = 0; p < nargs; p++) |
2847 | for (p = 0; p < nargs; p++) |
3346 | if (arg[p] == -1) |
2848 | if (arg[p] == -1) |
3347 | arg[p] = ndef; |
2849 | arg[p] = ndef; |
3348 | |
2850 | |
3349 | #ifdef DEBUG_CMD |
|
|
3350 | fprintf (stderr, "CSI "); |
|
|
3351 | for (p = 0; p < nargs; p++) |
|
|
3352 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3353 | fprintf (stderr, "%c\n", ch); |
|
|
3354 | #endif |
|
|
3355 | |
|
|
3356 | /* |
2851 | /* |
3357 | * private mode handling |
2852 | * private mode handling |
3358 | */ |
2853 | */ |
3359 | if (priv) |
2854 | if (priv) |
3360 | { |
2855 | { |
3361 | switch (priv) |
2856 | switch (priv) |
3362 | { |
2857 | { |
3363 | case '>': |
2858 | case '>': |
3364 | if (ch == CSI_DA) /* secondary device attributes */ |
2859 | if (ch == CSI_DA) /* secondary device attributes */ |
3365 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2860 | { |
|
|
2861 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2862 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2863 | // |
|
|
2864 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2865 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
|
|
2866 | // versions. |
|
|
2867 | // |
|
|
2868 | tt_printf ("\033[>%d;95;0c", 'U'); |
|
|
2869 | } |
3366 | break; |
2870 | break; |
|
|
2871 | |
3367 | case '?': |
2872 | case '?': |
3368 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2873 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3369 | process_terminal_mode (ch, priv, nargs, arg); |
2874 | process_terminal_mode (ch, priv, nargs, arg); |
3370 | break; |
2875 | break; |
|
|
2876 | |
|
|
2877 | case '!': |
|
|
2878 | if (ch == CSI_70) |
|
|
2879 | { |
|
|
2880 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
|
|
2881 | scr_soft_reset (); |
|
|
2882 | |
|
|
2883 | static const int pm_h[] = { 7, 25 }; |
|
|
2884 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; |
|
|
2885 | |
|
|
2886 | process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h); |
|
|
2887 | process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l); |
3371 | } |
2888 | } |
|
|
2889 | break; |
|
|
2890 | } |
|
|
2891 | |
3372 | return; |
2892 | return; |
3373 | } |
2893 | } |
3374 | |
2894 | |
3375 | switch (ch) |
2895 | switch (ch) |
3376 | { |
2896 | { |
… | |
… | |
3496 | break; |
3016 | break; |
3497 | case 6: /* CPR requested */ |
3017 | case 6: /* CPR requested */ |
3498 | scr_report_position (); |
3018 | scr_report_position (); |
3499 | break; |
3019 | break; |
3500 | case 7: /* unofficial extension */ |
3020 | case 7: /* unofficial extension */ |
3501 | if (OPTION (Opt_insecure)) |
3021 | if (option (Opt_insecure)) |
3502 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3022 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3503 | break; |
3023 | break; |
3504 | case 8: /* unofficial extension */ |
3024 | case 8: /* unofficial extension */ |
3505 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3025 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3506 | break; |
3026 | break; |
… | |
… | |
3573 | break; |
3093 | break; |
3574 | case CSI_75: |
3094 | case CSI_75: |
3575 | scr_cursor (RESTORE); |
3095 | scr_cursor (RESTORE); |
3576 | break; |
3096 | break; |
3577 | |
3097 | |
3578 | #if ENABLE_FRILLS |
3098 | #if !ENABLE_MINIMAL |
3579 | case CSI_74: |
3099 | case CSI_74: |
3580 | process_window_ops (arg, nargs); |
3100 | process_window_ops (arg, nargs); |
3581 | break; |
3101 | break; |
3582 | #endif |
3102 | #endif |
3583 | |
3103 | |
… | |
… | |
3590 | break; |
3110 | break; |
3591 | } |
3111 | } |
3592 | } |
3112 | } |
3593 | /*}}} */ |
3113 | /*}}} */ |
3594 | |
3114 | |
3595 | #if ENABLE_FRILLS |
3115 | #if !ENABLE_MINIMAL |
3596 | /* ARGSUSED */ |
3116 | /* ARGSUSED */ |
3597 | void |
3117 | void |
3598 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3118 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3599 | { |
3119 | { |
3600 | int x, y; |
3120 | int x, y; |
3601 | XWindowAttributes wattr; |
3121 | XWindowAttributes wattr; |
3602 | Window wdummy; |
3122 | Window wdummy; |
3603 | dDisp; |
3123 | |
|
|
3124 | dLocal (Display *, dpy); |
3604 | |
3125 | |
3605 | if (nargs == 0) |
3126 | if (nargs == 0) |
3606 | return; |
3127 | return; |
3607 | |
3128 | |
3608 | switch (args[0]) |
3129 | switch (args[0]) |
3609 | { |
3130 | { |
3610 | /* |
3131 | /* |
3611 | * commands |
3132 | * commands |
3612 | */ |
3133 | */ |
3613 | case 1: /* deiconify window */ |
3134 | case 1: /* deiconify window */ |
3614 | XMapWindow (disp, parent[0]); |
3135 | XMapWindow (dpy, parent[0]); |
3615 | break; |
3136 | break; |
3616 | case 2: /* iconify window */ |
3137 | case 2: /* iconify window */ |
3617 | XIconifyWindow (disp, parent[0], display->screen); |
3138 | XIconifyWindow (dpy, parent[0], display->screen); |
3618 | break; |
3139 | break; |
3619 | case 3: /* set position (pixels) */ |
3140 | case 3: /* set position (pixels) */ |
3620 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3141 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3621 | break; |
3142 | break; |
3622 | case 4: /* set size (pixels) */ |
3143 | case 4: /* set size (pixels) */ |
3623 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3144 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3624 | break; |
3145 | break; |
3625 | case 5: /* raise window */ |
3146 | case 5: /* raise window */ |
3626 | XRaiseWindow (disp, parent[0]); |
3147 | XRaiseWindow (dpy, parent[0]); |
3627 | break; |
3148 | break; |
3628 | case 6: /* lower window */ |
3149 | case 6: /* lower window */ |
3629 | XLowerWindow (disp, parent[0]); |
3150 | XLowerWindow (dpy, parent[0]); |
3630 | break; |
3151 | break; |
3631 | case 7: /* refresh window */ |
3152 | case 7: /* refresh window */ |
3632 | scr_touch (true); |
3153 | scr_touch (true); |
3633 | break; |
3154 | break; |
3634 | case 8: /* set size (chars) */ |
3155 | case 8: /* set size (chars) */ |
… | |
… | |
3641 | if (args[0] >= 24) /* set height (chars) */ |
3162 | if (args[0] >= 24) /* set height (chars) */ |
3642 | set_widthheight ((unsigned int)width, |
3163 | set_widthheight ((unsigned int)width, |
3643 | (unsigned int) (args[1] * fheight)); |
3164 | (unsigned int) (args[1] * fheight)); |
3644 | break; |
3165 | break; |
3645 | |
3166 | |
3646 | |
|
|
3647 | /* |
3167 | /* |
3648 | * reports - some output format copied from XTerm |
3168 | * reports - some output format copied from XTerm |
3649 | */ |
3169 | */ |
3650 | case 11: /* report window state */ |
3170 | case 11: /* report window state */ |
3651 | XGetWindowAttributes (disp, parent[0], &wattr); |
3171 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3652 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3172 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3653 | break; |
3173 | break; |
3654 | case 13: /* report window position */ |
3174 | case 13: /* report window position */ |
3655 | XGetWindowAttributes (disp, parent[0], &wattr); |
3175 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3656 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3176 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3657 | -wattr.border_width, -wattr.border_width, |
3177 | -wattr.border_width, -wattr.border_width, |
3658 | &x, &y, &wdummy); |
3178 | &x, &y, &wdummy); |
3659 | tt_printf ("\033[3;%d;%dt", x, y); |
3179 | tt_printf ("\033[3;%d;%dt", x, y); |
3660 | break; |
3180 | break; |
3661 | case 14: /* report window size (pixels) */ |
3181 | case 14: /* report window size (pixels) */ |
3662 | XGetWindowAttributes (disp, parent[0], &wattr); |
3182 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3663 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3183 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3664 | break; |
3184 | break; |
3665 | case 18: /* report text area size (chars) */ |
3185 | case 18: /* report text area size (chars) */ |
3666 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3186 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3667 | break; |
3187 | break; |
… | |
… | |
3669 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3189 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3670 | break; |
3190 | break; |
3671 | case 20: /* report icon label */ |
3191 | case 20: /* report icon label */ |
3672 | { |
3192 | { |
3673 | char *s; |
3193 | char *s; |
3674 | XGetIconName (disp, parent[0], &s); |
3194 | XGetIconName (dpy, parent[0], &s); |
3675 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3195 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3676 | XFree (s); |
3196 | XFree (s); |
3677 | } |
3197 | } |
3678 | break; |
3198 | break; |
3679 | case 21: /* report window title */ |
3199 | case 21: /* report window title */ |
3680 | { |
3200 | { |
3681 | char *s; |
3201 | char *s; |
3682 | XFetchName (disp, parent[0], &s); |
3202 | XFetchName (dpy, parent[0], &s); |
3683 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3203 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3684 | XFree (s); |
3204 | XFree (s); |
3685 | } |
3205 | } |
3686 | break; |
3206 | break; |
3687 | } |
3207 | } |
3688 | } |
3208 | } |
… | |
… | |
3715 | seen_esc = true; |
3235 | seen_esc = true; |
3716 | continue; |
3236 | continue; |
3717 | } |
3237 | } |
3718 | else if (ch == C0_BEL || ch == CHAR_ST) |
3238 | else if (ch == C0_BEL || ch == CHAR_ST) |
3719 | break; |
3239 | break; |
|
|
3240 | else if (ch == C0_SYN) |
|
|
3241 | ch = cmd_get8 (); |
3720 | else if (ch < 0x20) |
3242 | else if (ch < 0x20) |
3721 | return NULL; /* other control character - exit */ |
3243 | return NULL; /* other control character - exit */ |
3722 | |
3244 | |
3723 | seen_esc = false; |
3245 | seen_esc = false; |
3724 | |
3246 | |
3725 | if (n >= STRING_MAX - 1) |
3247 | if (n >= STRING_MAX - 1) |
3726 | // stop at some sane length |
3248 | // stop at some sane length |
3727 | return NULL; |
3249 | return NULL; |
3728 | |
3250 | |
3729 | if (ch == C0_SYN) |
|
|
3730 | string[n++] = cmd_get8 (); |
|
|
3731 | else |
|
|
3732 | string[n++] = ch; |
3251 | string[n++] = ch; |
3733 | } |
3252 | } |
3734 | |
3253 | |
3735 | string[n++] = '\0'; |
3254 | string[n++] = '\0'; |
3736 | |
3255 | |
3737 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3256 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3744 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3263 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3745 | */ |
3264 | */ |
3746 | void |
3265 | void |
3747 | rxvt_term::process_dcs_seq () |
3266 | rxvt_term::process_dcs_seq () |
3748 | { |
3267 | { |
3749 | char *s; |
|
|
3750 | unicode_t eh; |
|
|
3751 | |
|
|
3752 | /* |
3268 | /* |
3753 | * Not handled yet |
3269 | * Not handled yet |
3754 | */ |
3270 | */ |
|
|
3271 | |
|
|
3272 | unicode_t eh; |
3755 | s = get_to_st (eh); |
3273 | char *s = get_to_st (eh); |
3756 | if (s) |
3274 | if (s) |
3757 | free (s); |
3275 | free (s); |
3758 | |
3276 | |
3759 | return; |
3277 | return; |
3760 | } |
3278 | } |
… | |
… | |
3764 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3282 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3765 | */ |
3283 | */ |
3766 | void |
3284 | void |
3767 | rxvt_term::process_osc_seq () |
3285 | rxvt_term::process_osc_seq () |
3768 | { |
3286 | { |
3769 | unicode_t ch, eh; |
|
|
3770 | int arg; |
3287 | int arg; |
3771 | |
3288 | |
3772 | ch = cmd_getc (); |
3289 | unicode_t ch = cmd_getc (); |
3773 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3290 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3774 | arg = arg * 10 + (ch - '0'); |
3291 | arg = arg * 10 + (ch - '0'); |
3775 | |
3292 | |
3776 | if (ch == ';') |
3293 | if (ch == ';') |
3777 | { |
3294 | { |
|
|
3295 | unicode_t eh; |
3778 | char *s = get_to_st (eh); |
3296 | char *s = get_to_st (eh); |
3779 | |
3297 | |
3780 | if (s) |
3298 | if (s) |
3781 | { |
3299 | { |
3782 | process_xterm_seq (arg, s, eh); |
3300 | process_xterm_seq (arg, s, eh); |
… | |
… | |
3788 | void |
3306 | void |
3789 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3307 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3790 | { |
3308 | { |
3791 | if (str[0] == '?' && !str[1]) |
3309 | if (str[0] == '?' && !str[1]) |
3792 | { |
3310 | { |
3793 | unsigned short r, g, b; |
3311 | rgba c; |
3794 | pix_colors_focused[color].get (display, r, g, b); |
3312 | pix_colors_focused[color].get (c); |
|
|
3313 | |
|
|
3314 | #if XFT |
|
|
3315 | if (c.a != rgba::MAX_CC) |
|
|
3316 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3317 | else |
|
|
3318 | #endif |
3795 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3319 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3796 | } |
3320 | } |
3797 | else |
3321 | else |
3798 | set_window_color (color, str); |
3322 | set_window_color (color, str); |
3799 | } |
3323 | } |
3800 | |
3324 | |
3801 | /* |
3325 | /* |
3802 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3326 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3803 | */ |
3327 | */ |
3804 | void |
3328 | void |
3805 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3329 | rxvt_term::process_xterm_seq (int op, char *str, char resp) |
3806 | { |
3330 | { |
3807 | int changed = 0; |
|
|
3808 | int color; |
3331 | int color; |
3809 | char *buf, *name; |
3332 | char *buf, *name; |
3810 | bool query = str[0] == '?' && !str[1]; |
3333 | bool query = str[0] == '?' && !str[1]; |
3811 | int saveop = op; |
3334 | int saveop = op; |
3812 | dDisp; |
3335 | |
|
|
3336 | dLocal (Display *, dpy); |
3813 | |
3337 | |
3814 | assert (str != NULL); |
3338 | assert (str != NULL); |
|
|
3339 | |
|
|
3340 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3341 | return; |
|
|
3342 | |
3815 | switch (op) |
3343 | switch (op) |
3816 | { |
3344 | { |
3817 | case XTerm_name: |
3345 | case XTerm_name: |
3818 | set_title (str); |
3346 | set_title (str); |
3819 | /* FALLTHROUGH */ |
3347 | /* FALLTHROUGH */ |
… | |
… | |
3833 | unsigned long bytes_after; |
3361 | unsigned long bytes_after; |
3834 | unsigned char *value = 0; |
3362 | unsigned char *value = 0; |
3835 | const char *str = ""; |
3363 | const char *str = ""; |
3836 | |
3364 | |
3837 | if (prop |
3365 | if (prop |
3838 | && XGetWindowProperty (disp, parent[0], |
3366 | && XGetWindowProperty (dpy, parent[0], |
3839 | prop, 0, 1<<16, 0, AnyPropertyType, |
3367 | prop, 0, 1<<16, 0, AnyPropertyType, |
3840 | &actual_type, &actual_format, |
3368 | &actual_type, &actual_format, |
3841 | &nitems, &bytes_after, &value) == Success |
3369 | &nitems, &bytes_after, &value) == Success |
3842 | && actual_type != None |
3370 | && actual_type != None |
3843 | && actual_format == 8) |
3371 | && actual_format == 8) |
3844 | str = (const char *)(value); |
3372 | str = (const char *)(value); |
3845 | |
3373 | |
3846 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3374 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3847 | |
3375 | |
3848 | XFree (value); |
3376 | XFree (value); |
3849 | } |
3377 | } |
3850 | else |
3378 | else |
3851 | { |
3379 | { |
3852 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3380 | char *eq = strchr (str, '='); |
3853 | |
3381 | |
3854 | if (eq) |
3382 | if (eq) |
3855 | { |
3383 | { |
3856 | *eq = 0; |
3384 | *eq = 0; |
3857 | set_utf8_property (display->atom (str), eq + 1); |
3385 | set_utf8_property (display->atom (str), eq + 1); |
3858 | } |
3386 | } |
3859 | else |
3387 | else |
3860 | XDeleteProperty (disp, parent[0], |
3388 | XDeleteProperty (dpy, parent[0], |
3861 | display->atom (str)); |
3389 | display->atom (str)); |
3862 | } |
3390 | } |
3863 | break; |
3391 | break; |
3864 | |
3392 | |
3865 | case XTerm_Color: |
3393 | case XTerm_Color: |
… | |
… | |
3867 | { |
3395 | { |
3868 | if ((name = strchr (buf, ';')) == NULL) |
3396 | if ((name = strchr (buf, ';')) == NULL) |
3869 | break; |
3397 | break; |
3870 | |
3398 | |
3871 | *name++ = '\0'; |
3399 | *name++ = '\0'; |
3872 | color = atoi (buf); |
3400 | color = atoi (buf) + minCOLOR; |
3873 | |
3401 | |
3874 | if (color < 0 || color >= TOTAL_COLORS) |
3402 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3875 | break; |
3403 | break; |
3876 | |
3404 | |
3877 | if ((buf = strchr (name, ';')) != NULL) |
3405 | if ((buf = strchr (name, ';')) != NULL) |
3878 | *buf++ = '\0'; |
3406 | *buf++ = '\0'; |
3879 | |
3407 | |
3880 | if (name[0] == '?' && !name[1]) |
3408 | process_color_seq (op, color, name, resp); |
|
|
3409 | } |
|
|
3410 | break; |
|
|
3411 | case Rxvt_restoreFG: |
|
|
3412 | case XTerm_Color00: |
|
|
3413 | process_color_seq (op, Color_fg, str, resp); |
|
|
3414 | break; |
|
|
3415 | case Rxvt_restoreBG: |
|
|
3416 | case XTerm_Color01: |
|
|
3417 | process_color_seq (op, Color_bg, str, resp); |
|
|
3418 | break; |
|
|
3419 | #ifndef NO_CURSORCOLOR |
|
|
3420 | case XTerm_Color_cursor: |
|
|
3421 | process_color_seq (op, Color_cursor, str, resp); |
|
|
3422 | break; |
|
|
3423 | #endif |
|
|
3424 | case XTerm_Color_pointer_fg: |
|
|
3425 | process_color_seq (op, Color_pointer_fg, str, resp); |
|
|
3426 | break; |
|
|
3427 | case XTerm_Color_pointer_bg: |
|
|
3428 | process_color_seq (op, Color_pointer_bg, str, resp); |
|
|
3429 | break; |
|
|
3430 | #ifdef OPTION_HC |
|
|
3431 | case XTerm_Color_HC: |
|
|
3432 | process_color_seq (op, Color_HC, str, resp); |
|
|
3433 | break; |
|
|
3434 | case XTerm_Color_HTC: |
|
|
3435 | process_color_seq (op, Color_HTC, str, resp); |
|
|
3436 | break; |
|
|
3437 | #endif |
|
|
3438 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
3439 | case URxvt_Color_BD: |
|
|
3440 | process_color_seq (op, Color_BD, str, resp); |
|
|
3441 | break; |
|
|
3442 | case URxvt_Color_UL: |
|
|
3443 | process_color_seq (op, Color_UL, str, resp); |
|
|
3444 | break; |
|
|
3445 | case URxvt_Color_IT: |
|
|
3446 | process_color_seq (op, Color_IT, str, resp); |
|
|
3447 | break; |
|
|
3448 | #endif |
|
|
3449 | case URxvt_Color_border: |
|
|
3450 | process_color_seq (op, Color_border, str, resp); |
|
|
3451 | break; |
|
|
3452 | #if ENABLE_TRANSPARENCY |
|
|
3453 | case URxvt_Color_tint: |
|
|
3454 | process_color_seq (op, Color_tint, str, resp); |
|
|
3455 | { |
|
|
3456 | bool changed = false; |
|
|
3457 | |
|
|
3458 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
3459 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
|
|
3460 | else |
|
|
3461 | changed = bgPixmap.unset_tint (); |
|
|
3462 | |
|
|
3463 | if (changed) |
|
|
3464 | update_background (); |
|
|
3465 | } |
|
|
3466 | |
|
|
3467 | break; |
|
|
3468 | #endif |
|
|
3469 | |
|
|
3470 | #if BG_IMAGE_FROM_FILE |
|
|
3471 | case Rxvt_Pixmap: |
|
|
3472 | if (!strcmp (str, "?")) |
|
|
3473 | { |
|
|
3474 | char str[256]; |
|
|
3475 | |
|
|
3476 | sprintf (str, "[%dx%d+%d+%d]", |
|
|
3477 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
|
|
3478 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3479 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
|
|
3480 | } |
|
|
3481 | else |
|
|
3482 | { |
|
|
3483 | int changed = 0; |
|
|
3484 | |
|
|
3485 | if (*str != ';') |
3881 | { |
3486 | { |
3882 | unsigned short r, g, b; |
3487 | if (bgPixmap.set_file (str)) /* change pixmap */ |
3883 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3488 | { |
3884 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3489 | changed++; |
|
|
3490 | str = strchr (str, ';'); |
|
|
3491 | if (str == NULL) |
|
|
3492 | bgPixmap.set_defaultGeometry (); |
|
|
3493 | else |
|
|
3494 | bgPixmap.set_geometry (str+1); |
|
|
3495 | } |
3885 | } |
3496 | } |
3886 | else |
3497 | else |
3887 | set_window_color (color + minCOLOR, name); |
3498 | { |
|
|
3499 | str++; |
|
|
3500 | if (bgPixmap.set_geometry (str, true)) |
|
|
3501 | changed++; |
|
|
3502 | } |
|
|
3503 | |
|
|
3504 | if (changed) |
|
|
3505 | { |
|
|
3506 | if (bgPixmap.window_position_sensitive ()) |
|
|
3507 | { |
|
|
3508 | int x, y; |
|
|
3509 | get_window_origin (x, y); |
|
|
3510 | bgPixmap.set_position (x, y); |
|
|
3511 | } |
|
|
3512 | update_background (); |
|
|
3513 | } |
3888 | } |
3514 | } |
3889 | break; |
3515 | break; |
3890 | case XTerm_Color00: |
|
|
3891 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
|
|
3892 | break; |
|
|
3893 | case XTerm_Color01: |
|
|
3894 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
|
|
3895 | break; |
|
|
3896 | #ifndef NO_CURSORCOLOR |
|
|
3897 | case XTerm_Color_cursor: |
|
|
3898 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
|
|
3899 | break; |
|
|
3900 | #endif |
3516 | #endif |
3901 | case XTerm_Color_pointer_fg: |
|
|
3902 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
|
|
3903 | break; |
|
|
3904 | case XTerm_Color_pointer_bg: |
|
|
3905 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
|
|
3906 | break; |
|
|
3907 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
3908 | case XTerm_Color_BD: |
|
|
3909 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3910 | break; |
|
|
3911 | case XTerm_Color_UL: |
|
|
3912 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3913 | break; |
|
|
3914 | case XTerm_Color_RV: |
|
|
3915 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3916 | break; |
|
|
3917 | case URxvt_Color_IT: |
|
|
3918 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
|
|
3919 | break; |
|
|
3920 | #endif |
|
|
3921 | #if TRANSPARENT && TINTING |
|
|
3922 | case URxvt_Color_tint: |
|
|
3923 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
|
|
3924 | check_our_parents (); |
|
|
3925 | if (am_transparent) |
|
|
3926 | want_full_refresh = want_refresh = 1; |
|
|
3927 | break; |
|
|
3928 | #endif |
|
|
3929 | |
|
|
3930 | case XTerm_Pixmap: |
|
|
3931 | if (*str != ';') |
|
|
3932 | { |
|
|
3933 | #if XPM_BACKGROUND |
|
|
3934 | scale_pixmap (""); /* reset to default scaling */ |
|
|
3935 | set_bgPixmap (str); /* change pixmap */ |
|
|
3936 | #endif |
|
|
3937 | scr_touch (true); |
|
|
3938 | } |
|
|
3939 | while ((str = strchr (str, ';')) != NULL) |
|
|
3940 | { |
|
|
3941 | str++; |
|
|
3942 | #if XPM_BACKGROUND |
|
|
3943 | changed += scale_pixmap (str); |
|
|
3944 | #endif |
|
|
3945 | } |
|
|
3946 | |
|
|
3947 | if (changed) |
|
|
3948 | { |
|
|
3949 | #ifdef XPM_BACKGROUND |
|
|
3950 | resize_pixmap (); |
|
|
3951 | #endif |
|
|
3952 | scr_touch (true); |
|
|
3953 | } |
|
|
3954 | break; |
|
|
3955 | |
|
|
3956 | case XTerm_restoreFG: |
|
|
3957 | set_window_color (Color_fg, str); |
|
|
3958 | break; |
|
|
3959 | case XTerm_restoreBG: |
|
|
3960 | set_window_color (Color_bg, str); |
|
|
3961 | break; |
|
|
3962 | |
3517 | |
3963 | case XTerm_logfile: |
3518 | case XTerm_logfile: |
3964 | // TODO, when secure mode? |
3519 | // TODO, when secure mode? |
3965 | break; |
3520 | break; |
3966 | |
3521 | |
3967 | #ifdef MENUBAR |
|
|
3968 | case URxvt_Menu: |
|
|
3969 | if (OPTION (Opt_insecure)) |
|
|
3970 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3971 | break; |
|
|
3972 | #endif |
|
|
3973 | #if 0 |
3522 | #if 0 |
3974 | case XTerm_dumpscreen: /* no error notices */ |
3523 | case Rxvt_dumpscreen: /* no error notices */ |
3975 | { |
3524 | { |
3976 | int fd; |
3525 | int fd; |
3977 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3526 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3978 | { |
3527 | { |
3979 | scr_dump (fd); |
3528 | scr_dump (fd); |
… | |
… | |
3990 | case URxvt_italicFont: |
3539 | case URxvt_italicFont: |
3991 | case URxvt_boldItalicFont: |
3540 | case URxvt_boldItalicFont: |
3992 | #endif |
3541 | #endif |
3993 | if (query) |
3542 | if (query) |
3994 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3543 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3995 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3544 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3996 | ? fontset[op - URxvt_font]->fontdesc : "", |
3545 | ? fontset[op - URxvt_font]->fontdesc : "", |
3997 | resp); |
3546 | resp); |
3998 | else |
3547 | else |
3999 | { |
3548 | { |
4000 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3549 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
4003 | allocated.push_back ((void *)res); |
3552 | allocated.push_back ((void *)res); |
4004 | set_fonts (); |
3553 | set_fonts (); |
4005 | } |
3554 | } |
4006 | break; |
3555 | break; |
4007 | |
3556 | |
4008 | #if ENABLE_FRILLS |
3557 | case URxvt_version: |
|
|
3558 | if (query) |
|
|
3559 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3560 | op, |
|
|
3561 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3562 | resp); |
|
|
3563 | break; |
|
|
3564 | |
|
|
3565 | #if !ENABLE_MINIMAL |
4009 | case URxvt_locale: |
3566 | case URxvt_locale: |
4010 | if (query) |
3567 | if (query) |
4011 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3568 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
4012 | else |
3569 | else |
4013 | { |
3570 | { |
4014 | set_locale (str); |
3571 | set_locale (str); |
4015 | pty.set_utf8_mode (enc_utf8); |
3572 | pty->set_utf8_mode (enc_utf8); |
4016 | init_xlocale (); |
3573 | init_xlocale (); |
4017 | } |
3574 | } |
4018 | break; |
3575 | break; |
4019 | |
3576 | |
4020 | case URxvt_view_up: |
3577 | case URxvt_view_up: |
… | |
… | |
4031 | break; |
3588 | break; |
4032 | #endif |
3589 | #endif |
4033 | |
3590 | |
4034 | #if ENABLE_PERL |
3591 | #if ENABLE_PERL |
4035 | case URxvt_perl: |
3592 | case URxvt_perl: |
4036 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3593 | HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); |
4037 | ; // no responses yet |
|
|
4038 | break; |
3594 | break; |
4039 | #endif |
3595 | #endif |
4040 | } |
3596 | } |
4041 | } |
3597 | } |
4042 | /*----------------------------------------------------------------------*/ |
3598 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4065 | { |
3621 | { |
4066 | if (mode == 'r') |
3622 | if (mode == 'r') |
4067 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3623 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
4068 | else |
3624 | else |
4069 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3625 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
4070 | PrivMode (state, bit); |
3626 | |
|
|
3627 | set_privmode (bit, state); |
4071 | } |
3628 | } |
4072 | |
3629 | |
4073 | return state; |
3630 | return state; |
4074 | } |
3631 | } |
4075 | |
3632 | |
4076 | /* we're not using priv _yet_ */ |
3633 | /* we're not using priv _yet_ */ |
4077 | void |
3634 | void |
4078 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3635 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4079 | { |
3636 | { |
4080 | unsigned int i, j; |
3637 | unsigned int i, j; |
4081 | int state; |
3638 | int state; |
4082 | |
3639 | |
4083 | static const struct |
3640 | static const struct |
4084 | { |
3641 | { |
4085 | const int argval; |
3642 | const int argval; |
4086 | const unsigned long bit; |
3643 | const unsigned long bit; |
4087 | } |
|
|
4088 | |
|
|
4089 | argtopriv[] = { |
3644 | } argtopriv[] = { |
4090 | { 1, PrivMode_aplCUR }, |
3645 | { 1, PrivMode_aplCUR }, // DECCKM |
4091 | { 2, PrivMode_vt52 }, |
3646 | { 2, PrivMode_vt52 }, |
4092 | { 3, PrivMode_132 }, |
3647 | { 3, PrivMode_132 }, // DECCOLM |
4093 | { 4, PrivMode_smoothScroll }, |
3648 | { 4, PrivMode_smoothScroll }, // DECSCLM |
4094 | { 5, PrivMode_rVideo }, |
3649 | { 5, PrivMode_rVideo }, // DECSCNM |
4095 | { 6, PrivMode_relOrigin }, |
3650 | { 6, PrivMode_relOrigin }, // DECOM |
4096 | { 7, PrivMode_Autowrap }, |
3651 | { 7, PrivMode_Autowrap }, // DECAWM |
4097 | // 8, bi-directional support mode |
3652 | // 8, auto-repeat keys // DECARM |
4098 | { 9, PrivMode_MouseX10 }, |
3653 | { 9, PrivMode_MouseX10 }, |
4099 | #ifdef menuBar_esc |
3654 | // 18 end FF to printer after print screen |
4100 | { menuBar_esc, PrivMode_menuBar }, |
3655 | // 19 Print screen prints full screen/scroll region |
4101 | #endif |
|
|
4102 | // 18, 19 printing-related |
|
|
4103 | { 25, PrivMode_VisibleCursor }, |
3656 | { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis |
4104 | #ifdef scrollBar_esc |
3657 | #ifdef scrollBar_esc |
4105 | { scrollBar_esc, PrivMode_scrollBar }, |
3658 | { scrollBar_esc, PrivMode_scrollBar }, |
4106 | #endif |
3659 | #endif |
4107 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3660 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
|
|
3661 | // 38, tektronix mode // DECTEK |
4108 | { 40, PrivMode_132OK }, |
3662 | { 40, PrivMode_132OK }, |
4109 | // 41 xterm more fixes NYI |
3663 | // 41 xterm more fixes NYI |
4110 | // 45 margin bell NYI |
3664 | // 45 margin bell NYI |
4111 | // 46 start logging |
3665 | // 46 start logging |
4112 | { 47, PrivMode_Screen }, |
3666 | { 47, PrivMode_Screen }, |
4113 | { 66, PrivMode_aplKP }, |
3667 | { 66, PrivMode_aplKP }, // DECPAM/DECPNM |
4114 | #ifndef NO_BACKSPACE_KEY |
3668 | #ifndef NO_BACKSPACE_KEY |
4115 | { 67, PrivMode_BackSpace }, |
3669 | { 67, PrivMode_BackSpace }, // DECBKM |
4116 | #endif |
3670 | #endif |
4117 | { 1000, PrivMode_MouseX11 }, |
3671 | { 1000, PrivMode_MouseX11 }, |
4118 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3672 | { 1002, PrivMode_MouseBtnEvent }, |
4119 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3673 | { 1003, PrivMode_MouseAnyEvent }, |
4120 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
3674 | #if ENABLE_FRILLS |
|
|
3675 | { 1005, PrivMode_ExtModeMouse }, |
|
|
3676 | #endif |
4121 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3677 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
4122 | { 1011, PrivMode_Keypress }, // rxvt extension |
3678 | { 1011, PrivMode_Keypress }, // rxvt extension |
|
|
3679 | #if ENABLE_FRILLS |
|
|
3680 | { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 |
|
|
3681 | #endif |
4123 | // 1035 enable modifiers for alt, numlock NYI |
3682 | // 1035 enable modifiers for alt, numlock NYI |
4124 | // 1036 send ESC for meta keys NYI |
3683 | // 1036 send ESC for meta keys NYI |
4125 | // 1037 send DEL for keypad delete NYI |
3684 | // 1037 send DEL for keypad delete NYI |
4126 | { 1047, PrivMode_Screen }, |
3685 | { 1047, PrivMode_Screen }, |
4127 | // 1048 save and restore cursor |
3686 | // 1048 save and restore cursor, implemented in code |
4128 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3687 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
4129 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3688 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
|
|
3689 | { 2004, PrivMode_BracketPaste }, |
4130 | }; |
3690 | }; |
4131 | |
3691 | |
4132 | if (nargs == 0) |
3692 | if (nargs == 0) |
4133 | return; |
3693 | return; |
4134 | |
3694 | |
… | |
… | |
4141 | for (i = 0; i < nargs; i++) |
3701 | for (i = 0; i < nargs; i++) |
4142 | { |
3702 | { |
4143 | state = -1; |
3703 | state = -1; |
4144 | |
3704 | |
4145 | /* basic handling */ |
3705 | /* basic handling */ |
4146 | for (j = 0; j < (sizeof (argtopriv)/sizeof (argtopriv[0])); j++) |
3706 | for (j = 0; j < ARRAY_LENGTH(argtopriv); j++) |
4147 | if (argtopriv[j].argval == arg[i]) |
3707 | if (argtopriv[j].argval == arg[i]) |
4148 | { |
3708 | { |
4149 | state = privcases (mode, argtopriv[j].bit); |
3709 | state = privcases (mode, argtopriv[j].bit); |
4150 | break; |
3710 | break; |
4151 | } |
3711 | } |
… | |
… | |
4153 | /* extra handling for values with state unkept */ |
3713 | /* extra handling for values with state unkept */ |
4154 | switch (arg[i]) |
3714 | switch (arg[i]) |
4155 | { |
3715 | { |
4156 | #if ENABLE_STYLES |
3716 | #if ENABLE_STYLES |
4157 | case 1021: |
3717 | case 1021: |
4158 | if (mode) |
3718 | set_option (Opt_intensityStyles, mode); |
4159 | SET_OPTION (Opt_intensityStyles); |
|
|
4160 | else |
|
|
4161 | CLR_OPTION (Opt_intensityStyles); |
|
|
4162 | |
3719 | |
4163 | scr_touch (true); |
3720 | scr_touch (true); |
4164 | break; |
3721 | break; |
4165 | #endif |
3722 | #endif |
4166 | case 1048: /* alternative cursor save */ |
3723 | case 1048: /* alternative cursor save */ |
4167 | case 1049: |
|
|
4168 | if (OPTION (Opt_secondaryScreen)) |
3724 | if (option (Opt_secondaryScreen)) |
4169 | if (mode == 0) |
3725 | if (mode == 0) |
4170 | scr_cursor (RESTORE); |
3726 | scr_cursor (RESTORE); |
4171 | else if (mode == 1) |
3727 | else if (mode == 1) |
4172 | scr_cursor (SAVE); |
3728 | scr_cursor (SAVE); |
4173 | break; |
3729 | break; |
… | |
… | |
4181 | case 2: /* VT52 mode */ |
3737 | case 2: /* VT52 mode */ |
4182 | /* oddball mode. should be set regardless of set/reset |
3738 | /* oddball mode. should be set regardless of set/reset |
4183 | * parameter. Return from VT52 mode with an ESC < from |
3739 | * parameter. Return from VT52 mode with an ESC < from |
4184 | * within VT52 mode |
3740 | * within VT52 mode |
4185 | */ |
3741 | */ |
4186 | PrivMode (1, PrivMode_vt52); |
3742 | set_privmode (PrivMode_vt52, 1); |
4187 | break; |
3743 | break; |
4188 | case 3: /* 80/132 */ |
3744 | case 3: /* 80/132 */ |
4189 | if (priv_modes & PrivMode_132OK) |
3745 | if (priv_modes & PrivMode_132OK) |
4190 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3746 | set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); |
4191 | break; |
3747 | break; |
4192 | case 4: /* smooth scrolling */ |
3748 | case 4: /* smooth scrolling */ |
4193 | if (!state) |
3749 | set_option (Opt_jumpScroll, !state); |
4194 | SET_OPTION (Opt_jumpScroll); |
|
|
4195 | else |
|
|
4196 | CLR_OPTION (Opt_jumpScroll); |
|
|
4197 | break; |
3750 | break; |
4198 | case 5: /* reverse video */ |
3751 | case 5: /* reverse video */ |
4199 | scr_rvideo_mode (state); |
3752 | scr_rvideo_mode (state); |
4200 | break; |
3753 | break; |
4201 | case 6: /* relative/absolute origins */ |
3754 | case 6: /* relative/absolute origins */ |
… | |
… | |
4205 | scr_autowrap (state); |
3758 | scr_autowrap (state); |
4206 | break; |
3759 | break; |
4207 | /* case 8: - auto repeat, can't do on a per window basis */ |
3760 | /* case 8: - auto repeat, can't do on a per window basis */ |
4208 | case 9: /* X10 mouse reporting */ |
3761 | case 9: /* X10 mouse reporting */ |
4209 | if (state) /* orthogonal */ |
3762 | if (state) /* orthogonal */ |
4210 | priv_modes &= ~PrivMode_MouseX11; |
3763 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4211 | break; |
3764 | break; |
4212 | #ifdef menuBar_esc |
|
|
4213 | case menuBar_esc: |
|
|
4214 | #ifdef MENUBAR |
|
|
4215 | map_menuBar (state); |
|
|
4216 | #endif |
|
|
4217 | break; |
|
|
4218 | #endif |
|
|
4219 | #ifdef scrollBar_esc |
3765 | #ifdef scrollBar_esc |
4220 | case scrollBar_esc: |
3766 | case scrollBar_esc: |
4221 | if (scrollbar_mapping (state)) |
3767 | if (scrollBar.map (state)) |
4222 | { |
3768 | { |
4223 | resize_all_windows (0, 0, 0); |
3769 | resize_all_windows (0, 0, 0); |
4224 | scr_touch (true); |
3770 | scr_touch (true); |
4225 | } |
3771 | } |
4226 | break; |
3772 | break; |
… | |
… | |
4235 | break; |
3781 | break; |
4236 | /* case 66: - application key pad */ |
3782 | /* case 66: - application key pad */ |
4237 | /* case 67: - backspace key */ |
3783 | /* case 67: - backspace key */ |
4238 | case 1000: /* X11 mouse reporting */ |
3784 | case 1000: /* X11 mouse reporting */ |
4239 | if (state) /* orthogonal */ |
3785 | if (state) /* orthogonal */ |
4240 | priv_modes &= ~PrivMode_MouseX10; |
3786 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4241 | break; |
3787 | break; |
4242 | #if 0 |
|
|
4243 | case 1001: |
3788 | case 1002: |
4244 | break; /* X11 mouse highlighting */ |
3789 | case 1003: |
4245 | #endif |
3790 | if (state) |
|
|
3791 | { |
|
|
3792 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3793 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3794 | mouse_row = mouse_col = 0; |
|
|
3795 | vt_emask_mouse = PointerMotionMask; |
|
|
3796 | } |
|
|
3797 | else |
|
|
3798 | vt_emask_mouse = NoEventMask; |
|
|
3799 | |
|
|
3800 | vt_select_input (); |
|
|
3801 | break; |
4246 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3802 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4247 | if (!state) |
3803 | set_option (Opt_scrollTtyOutput, !state); |
4248 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4249 | else |
|
|
4250 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4251 | break; |
3804 | break; |
4252 | case 1011: /* scroll to bottom on key press */ |
3805 | case 1011: /* scroll to bottom on key press */ |
4253 | if (state) |
3806 | set_option (Opt_scrollTtyKeypress, state); |
4254 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4255 | else |
|
|
4256 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4257 | break; |
3807 | break; |
4258 | case 1047: /* secondary screen w/ clearing last */ |
3808 | case 1047: /* secondary screen w/ clearing last */ |
4259 | if (OPTION (Opt_secondaryScreen)) |
3809 | if (option (Opt_secondaryScreen)) |
4260 | if (current_screen != PRIMARY) |
3810 | if (!state) |
4261 | scr_erase_screen (2); |
3811 | scr_erase_screen (2); |
|
|
3812 | |
4262 | scr_change_screen (state); |
3813 | scr_change_screen (state); |
4263 | break; |
3814 | break; |
4264 | case 1049: /* secondary screen w/ clearing first */ |
3815 | case 1049: /* secondary screen w/ clearing first */ |
|
|
3816 | if (option (Opt_secondaryScreen)) |
|
|
3817 | if (state) |
|
|
3818 | scr_cursor (SAVE); |
|
|
3819 | |
4265 | scr_change_screen (state); |
3820 | scr_change_screen (state); |
|
|
3821 | |
4266 | if (OPTION (Opt_secondaryScreen)) |
3822 | if (option (Opt_secondaryScreen)) |
4267 | if (current_screen != PRIMARY) |
3823 | if (state) |
4268 | scr_erase_screen (2); |
3824 | scr_erase_screen (2); |
|
|
3825 | else |
|
|
3826 | scr_cursor (RESTORE); |
4269 | break; |
3827 | break; |
4270 | default: |
3828 | default: |
4271 | break; |
3829 | break; |
4272 | } |
3830 | } |
4273 | } |
3831 | } |
… | |
… | |
4399 | scr_color (Color_bg, Color_bg); |
3957 | scr_color (Color_bg, Color_bg); |
4400 | break; |
3958 | break; |
4401 | |
3959 | |
4402 | //case 50: // not variable spacing |
3960 | //case 50: // not variable spacing |
4403 | |
3961 | |
4404 | #if ENABLE_FRILLS |
3962 | #if !ENABLE_MINIMAL |
4405 | case 90: |
3963 | case 90: |
4406 | case 91: /* set bright fg color */ |
3964 | case 91: /* set bright fg color */ |
4407 | case 92: |
3965 | case 92: |
4408 | case 93: |
3966 | case 93: |
4409 | case 94: |
3967 | case 94: |
… | |
… | |
4433 | rxvt_term::process_graphics () |
3991 | rxvt_term::process_graphics () |
4434 | { |
3992 | { |
4435 | unicode_t ch, cmd = cmd_getc (); |
3993 | unicode_t ch, cmd = cmd_getc (); |
4436 | |
3994 | |
4437 | if (cmd == 'Q') |
3995 | if (cmd == 'Q') |
|
|
3996 | { |
4438 | { /* query graphics */ |
3997 | /* query graphics */ |
4439 | tt_printf ("\033G0\012"); /* no graphics */ |
3998 | tt_printf ("\033G0\012"); /* no graphics */ |
4440 | return; |
3999 | return; |
4441 | } |
4000 | } |
4442 | /* swallow other graphics sequences until terminating ':' */ |
4001 | /* swallow other graphics sequences until terminating ':' */ |
4443 | do |
4002 | do |
… | |
… | |
4466 | |
4025 | |
4467 | /* ---------------------------------------------------------------------- */ |
4026 | /* ---------------------------------------------------------------------- */ |
4468 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4027 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4469 | * or generated by us in response to a query ESC sequence. |
4028 | * or generated by us in response to a query ESC sequence. |
4470 | */ |
4029 | */ |
4471 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4030 | static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4472 | |
4031 | |
4473 | void |
4032 | void |
4474 | rxvt_term::tt_write (const char *data, unsigned int len) |
4033 | rxvt_term::tt_write (const char *data, unsigned int len) |
4475 | { |
4034 | { |
4476 | if (pty.pty < 0) |
4035 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4477 | return; |
4036 | return; |
4478 | |
4037 | |
|
|
4038 | if (pty->pty < 0) |
|
|
4039 | return; |
|
|
4040 | |
4479 | if (v_buflen == 0) |
4041 | if (v_buflen == 0) |
4480 | { |
4042 | { |
4481 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4043 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4482 | |
4044 | |
4483 | if ((unsigned int)written == len) |
4045 | if ((unsigned int)written == len) |
4484 | return; |
4046 | return; |
4485 | |
4047 | |
4486 | data += written; |
4048 | data += written; |
4487 | len -= written; |
4049 | len -= written; |
4488 | } |
4050 | } |
4489 | |
4051 | |
4490 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4052 | v_buffer = (char *)rxvt_realloc (v_buffer, v_buflen + len); |
4491 | |
4053 | |
4492 | memcpy (v_buffer + v_buflen, data, len); |
4054 | memcpy (v_buffer + v_buflen, data, len); |
4493 | v_buflen += len; |
4055 | v_buflen += len; |
4494 | |
4056 | |
4495 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4057 | pty_ev.set (ev::READ | ev::WRITE); |
4496 | } |
4058 | } |
4497 | |
4059 | |
4498 | void rxvt_term::pty_write () |
4060 | void rxvt_term::pty_write () |
4499 | { |
4061 | { |
4500 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4062 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4501 | |
4063 | |
4502 | if (written > 0) |
4064 | if (written > 0) |
4503 | { |
4065 | { |
4504 | v_buflen -= written; |
4066 | v_buflen -= written; |
4505 | |
4067 | |
4506 | if (v_buflen == 0) |
4068 | if (v_buflen == 0) |
4507 | { |
4069 | { |
4508 | free (v_buffer); |
4070 | free (v_buffer); |
4509 | v_buffer = 0; |
4071 | v_buffer = 0; |
4510 | v_buflen = 0; |
|
|
4511 | |
4072 | |
4512 | pty_ev.set (EVENT_READ); |
4073 | pty_ev.set (ev::READ); |
4513 | return; |
4074 | return; |
4514 | } |
4075 | } |
4515 | |
4076 | |
4516 | memmove (v_buffer, v_buffer + written, v_buflen); |
4077 | memmove (v_buffer, v_buffer + written, v_buflen); |
4517 | } |
4078 | } |
4518 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4079 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4519 | pty_ev.set (EVENT_READ); |
4080 | pty_ev.set (ev::READ); |
4520 | } |
4081 | } |
4521 | |
4082 | |
4522 | /*----------------------- end-of-file (C source) -----------------------*/ |
4083 | /*----------------------- end-of-file (C source) -----------------------*/ |
4523 | |
4084 | |