… | |
… | |
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-2007 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de> |
31 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
31 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
32 | * |
32 | * |
33 | * 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 |
34 | * 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 |
35 | * the Free Software Foundation; either version 2 of the License, or |
35 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
162 | |
162 | |
163 | void |
163 | void |
164 | 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) |
165 | { |
165 | { |
166 | rxvt_fontset *fs = FONTSET (r); |
166 | rxvt_fontset *fs = FONTSET (r); |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
|
|
168 | wchar_t *chr, *alloc, ch2, *fname; |
167 | wchar_t *chr, *alloc, ch2, **fname; |
169 | int len; |
168 | int len; |
170 | |
|
|
171 | fname = rxvt_utf8towcs (f->name); |
|
|
172 | |
169 | |
173 | # if ENABLE_COMBINING |
170 | # if ENABLE_COMBINING |
174 | if (IS_COMPOSE (ch)) |
171 | if (IS_COMPOSE (ch)) |
175 | { |
172 | { |
176 | len = rxvt_composite.expand (ch, 0); |
173 | len = rxvt_composite.expand (ch, 0); |
… | |
… | |
197 | r & RS_Blink ? " blink" : "", |
194 | r & RS_Blink ? " blink" : "", |
198 | r & RS_RVid ? " rvid" : "", |
195 | r & RS_RVid ? " rvid" : "", |
199 | r & RS_Uline ? " uline" : "", |
196 | r & RS_Uline ? " uline" : "", |
200 | r & RS_Careful ? " careful" : ""); |
197 | r & RS_Careful ? " careful" : ""); |
201 | |
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); |
202 | int width = wcswidth (fname, wcslen (fname)); |
205 | max_it (width, wcswidth (fname[i], wcslen (fname[i]))); |
|
|
206 | } |
203 | |
207 | |
204 | max_it (width, 8+5); // for char + hex |
208 | max_it (width, 8+5); // for char + hex |
205 | max_it (width, strlen (attr)); |
209 | max_it (width, strlen (attr)); |
206 | |
210 | |
207 | if (y >= 0) |
211 | if (y >= 0) |
208 | { |
212 | { |
209 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
213 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
210 | x = 0; |
214 | x = 0; |
211 | } |
215 | } |
212 | |
216 | |
213 | scr_overlay_new (x, y, width, len + 2); |
217 | scr_overlay_new (x, y, width, len * 2 + 1); |
214 | |
218 | |
215 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
219 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
216 | |
220 | |
217 | for (int y = 0; y < len; y++) |
221 | for (int y = 0; y < len; y++) |
218 | { |
222 | { |
… | |
… | |
237 | // char buf[4+4+3+1]; |
241 | // char buf[4+4+3+1]; |
238 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
242 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
239 | // scr_overlay_set (0, 0, buf); |
243 | // scr_overlay_set (0, 0, buf); |
240 | // } |
244 | // } |
241 | scr_overlay_set (0, len , attr); |
245 | scr_overlay_set (0, len , attr); |
|
|
246 | for (int i = 0; i < len; i++) |
|
|
247 | { |
242 | scr_overlay_set (0, len + 1, fname); |
248 | scr_overlay_set (0, len + 1 + i, fname[i]); |
243 | |
|
|
244 | free (fname); |
249 | free (fname[i]); |
|
|
250 | } |
245 | |
251 | |
246 | # if ENABLE_COMBINING |
252 | # if ENABLE_COMBINING |
247 | if (alloc) |
253 | if (alloc) |
248 | delete [] alloc; |
254 | delete [] alloc; |
249 | # endif |
255 | # endif |
… | |
… | |
282 | } |
288 | } |
283 | |
289 | |
284 | static int |
290 | static int |
285 | hex_keyval (XKeyEvent &ev) |
291 | hex_keyval (XKeyEvent &ev) |
286 | { |
292 | { |
287 | // check wether this event corresponds to a hex digit |
293 | // check whether this event corresponds to a hex digit |
288 | // if the modifiers had not been pressed. |
294 | // if the modifiers had not been pressed. |
289 | for (int index = 0; index < 8; index++) |
295 | for (int index = 0; index < 8; index++) |
290 | { |
296 | { |
291 | KeySym k = XLookupKeysym (&ev, index); |
297 | KeySym k = XLookupKeysym (&ev, index); |
292 | |
298 | |
… | |
… | |
334 | # endif |
340 | # endif |
335 | #endif |
341 | #endif |
336 | return keysym; |
342 | return keysym; |
337 | } |
343 | } |
338 | |
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 | |
339 | void |
404 | void |
340 | rxvt_term::key_press (XKeyEvent &ev) |
405 | rxvt_term::key_press (XKeyEvent &ev) |
341 | { |
406 | { |
342 | int ctrl, meta, shft, len; |
407 | int ctrl, meta, shft, len; |
343 | KeySym keysym; |
408 | KeySym keysym; |
… | |
… | |
356 | * Always permit `shift' to override the current setting |
421 | * Always permit `shift' to override the current setting |
357 | */ |
422 | */ |
358 | shft = ev.state & ShiftMask; |
423 | shft = ev.state & ShiftMask; |
359 | ctrl = ev.state & ControlMask; |
424 | ctrl = ev.state & ControlMask; |
360 | meta = ev.state & ModMetaMask; |
425 | meta = ev.state & ModMetaMask; |
361 | |
|
|
362 | if (numlock_state || (ev.state & ModNumLockMask)) |
|
|
363 | { |
|
|
364 | numlock_state = (ev.state & ModNumLockMask); |
|
|
365 | PrivMode ((!numlock_state), PrivMode_aplKP); |
|
|
366 | } |
|
|
367 | |
426 | |
368 | kbuf[0] = 0; |
427 | kbuf[0] = 0; |
369 | |
428 | |
370 | #ifdef USE_XIM |
429 | #ifdef USE_XIM |
371 | if (Input_Context) |
430 | if (Input_Context) |
… | |
… | |
446 | #ifdef PAGING_CONTEXT_LINES |
505 | #ifdef PAGING_CONTEXT_LINES |
447 | lnsppg = nrow - PAGING_CONTEXT_LINES; |
506 | lnsppg = nrow - PAGING_CONTEXT_LINES; |
448 | #else |
507 | #else |
449 | lnsppg = nrow * 4 / 5; |
508 | lnsppg = nrow * 4 / 5; |
450 | #endif |
509 | #endif |
|
|
510 | max_it (lnsppg, 1); |
|
|
511 | |
451 | if (keysym == XK_Prior) |
512 | if (keysym == XK_Prior) |
452 | { |
513 | { |
453 | scr_page (UP, lnsppg); |
514 | scr_page (UP, lnsppg); |
454 | return; |
515 | return; |
455 | } |
516 | } |
… | |
… | |
508 | selection_request (ev.time); |
569 | selection_request (ev.time); |
509 | return; |
570 | return; |
510 | #if TODO |
571 | #if TODO |
511 | /* rxvt extras */ |
572 | /* rxvt extras */ |
512 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
573 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
513 | change_font (FONT_UP); |
|
|
514 | return; |
574 | return; |
515 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
575 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
516 | change_font (FONT_DN); |
|
|
517 | return; |
576 | return; |
518 | #endif |
577 | #endif |
519 | } |
578 | } |
520 | } |
579 | } |
521 | } |
580 | } |
522 | |
581 | |
523 | #if ENABLE_FRILLS || ISO_14755 |
582 | #if ENABLE_FRILLS || ISO_14755 |
524 | // ISO 14755 support |
583 | // ISO 14755 support |
525 | if (shft && ctrl) |
584 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51)) |
526 | { |
585 | { |
527 | int hv; |
586 | int hv; |
528 | |
587 | |
529 | if (iso14755buf & ISO_14755_51 |
588 | if (iso14755buf & ISO_14755_51 |
530 | && (keysym == XK_space || keysym == XK_KP_Space |
589 | && (keysym == XK_space || keysym == XK_KP_Space |
… | |
… | |
560 | scr_overlay_off (); |
619 | scr_overlay_off (); |
561 | # endif |
620 | # endif |
562 | iso14755buf = 0; |
621 | iso14755buf = 0; |
563 | } |
622 | } |
564 | } |
623 | } |
|
|
624 | else if (option (Opt_iso14755) && |
565 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
625 | ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
566 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
626 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))) |
567 | if (!(iso14755buf & ISO_14755_STARTED)) |
627 | if (!(iso14755buf & ISO_14755_STARTED)) |
568 | { |
628 | { |
569 | iso14755buf |= ISO_14755_STARTED; |
629 | iso14755buf |= ISO_14755_STARTED; |
570 | # if ISO_14755 |
630 | # if ISO_14755 |
571 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
631 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
… | |
… | |
582 | } |
642 | } |
583 | #endif |
643 | #endif |
584 | |
644 | |
585 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
645 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
586 | { |
646 | { |
587 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
647 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
588 | unsigned int newlen = 1; |
648 | unsigned int newlen = 1; |
589 | |
649 | |
|
|
650 | if (ev.state & ModNumLockMask) |
|
|
651 | kp = false; |
|
|
652 | |
590 | switch (translate_keypad (keysym, kp)) |
653 | keysym = translate_keypad (keysym, kp); |
|
|
654 | |
|
|
655 | switch (keysym) |
|
|
656 | { |
|
|
657 | #ifndef NO_BACKSPACE_KEY |
|
|
658 | case XK_BackSpace: |
|
|
659 | if (priv_modes & PrivMode_HaveBackSpace) |
|
|
660 | { |
|
|
661 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
662 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
663 | kbuf[1] = '\0'; |
|
|
664 | } |
|
|
665 | else |
|
|
666 | strcpy (kbuf, rs[Rs_backspace_key]); |
|
|
667 | break; |
|
|
668 | #endif |
|
|
669 | #ifndef NO_DELETE_KEY |
|
|
670 | case XK_Delete: |
|
|
671 | strcpy (kbuf, rs[Rs_delete_key]); |
|
|
672 | break; |
|
|
673 | #endif |
|
|
674 | case XK_Tab: |
|
|
675 | if (shft) |
|
|
676 | strcpy (kbuf, "\033[Z"); |
|
|
677 | else |
|
|
678 | { |
|
|
679 | #ifdef CTRL_TAB_MAKES_META |
|
|
680 | if (ctrl) |
|
|
681 | meta = 1; |
|
|
682 | #endif |
|
|
683 | #ifdef MOD4_TAB_MAKES_META |
|
|
684 | if (ev.state & Mod4Mask) |
|
|
685 | meta = 1; |
|
|
686 | #endif |
|
|
687 | newlen = 0; |
|
|
688 | } |
|
|
689 | break; |
|
|
690 | |
|
|
691 | case XK_Up: /* "\033[A" */ |
|
|
692 | case XK_Down: /* "\033[B" */ |
|
|
693 | case XK_Right: /* "\033[C" */ |
|
|
694 | case XK_Left: /* "\033[D" */ |
|
|
695 | strcpy (kbuf, "\033[Z"); |
|
|
696 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
697 | /* do Shift first */ |
|
|
698 | if (shft) |
|
|
699 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
700 | else if (ctrl) |
|
|
701 | { |
|
|
702 | kbuf[1] = 'O'; |
|
|
703 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
704 | } |
|
|
705 | else if (priv_modes & PrivMode_aplCUR) |
|
|
706 | kbuf[1] = 'O'; |
|
|
707 | break; |
|
|
708 | |
|
|
709 | case XK_KP_Enter: |
|
|
710 | /* allow shift to override */ |
|
|
711 | if (kp) |
|
|
712 | { |
|
|
713 | strcpy (kbuf, "\033OM"); |
|
|
714 | break; |
|
|
715 | } |
|
|
716 | |
|
|
717 | /* FALLTHROUGH */ |
|
|
718 | |
|
|
719 | case XK_Return: |
|
|
720 | if (priv_modes & PrivMode_LFNL) |
|
|
721 | { |
|
|
722 | kbuf[0] = '\015'; |
|
|
723 | kbuf[1] = '\012'; |
|
|
724 | kbuf[2] = '\0'; |
|
|
725 | } |
|
|
726 | else |
|
|
727 | { |
|
|
728 | kbuf[0] = '\015'; |
|
|
729 | kbuf[1] = '\0'; |
|
|
730 | } |
|
|
731 | break; |
|
|
732 | |
|
|
733 | case XK_KP_F1: /* "\033OP" */ |
|
|
734 | case XK_KP_F2: /* "\033OQ" */ |
|
|
735 | case XK_KP_F3: /* "\033OR" */ |
|
|
736 | case XK_KP_F4: /* "\033OS" */ |
|
|
737 | strcpy (kbuf, "\033OP"); |
|
|
738 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
739 | break; |
|
|
740 | |
|
|
741 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
742 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
743 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
744 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
745 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
746 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
747 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
748 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
749 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
750 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
751 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
752 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
753 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
754 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
755 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
756 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
757 | /* allow shift to override */ |
|
|
758 | if (kp) |
|
|
759 | { |
|
|
760 | strcpy (kbuf, "\033Oj"); |
|
|
761 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
762 | } |
|
|
763 | else |
|
|
764 | { |
|
|
765 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
766 | kbuf[1] = '\0'; |
|
|
767 | } |
|
|
768 | break; |
|
|
769 | |
|
|
770 | default: |
591 | { |
771 | { |
592 | #ifndef NO_BACKSPACE_KEY |
772 | int param = map_function_key (keysym); |
593 | case XK_BackSpace: |
773 | if (param > 0) |
594 | if (priv_modes & PrivMode_HaveBackSpace) |
774 | sprintf (kbuf,"\033[%d~", param); |
595 | { |
|
|
596 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
|
|
597 | ^ !!ctrl) ? '\b' : '\177'; |
|
|
598 | kbuf[1] = '\0'; |
|
|
599 | } |
|
|
600 | else |
775 | else |
601 | strcpy (kbuf, rs[Rs_backspace_key]); |
|
|
602 | break; |
|
|
603 | #endif |
|
|
604 | #ifndef NO_DELETE_KEY |
|
|
605 | case XK_Delete: |
|
|
606 | strcpy (kbuf, rs[Rs_delete_key]); |
|
|
607 | break; |
|
|
608 | #endif |
|
|
609 | case XK_Tab: |
|
|
610 | if (shft) |
|
|
611 | strcpy (kbuf, "\033[Z"); |
|
|
612 | else |
|
|
613 | { |
|
|
614 | #ifdef CTRL_TAB_MAKES_META |
|
|
615 | if (ctrl) |
|
|
616 | meta = 1; |
|
|
617 | #endif |
|
|
618 | #ifdef MOD4_TAB_MAKES_META |
|
|
619 | if (ev.state & Mod4Mask) |
|
|
620 | meta = 1; |
|
|
621 | #endif |
|
|
622 | newlen = 0; |
|
|
623 | } |
|
|
624 | break; |
|
|
625 | |
|
|
626 | case XK_Up: /* "\033[A" */ |
|
|
627 | case XK_Down: /* "\033[B" */ |
|
|
628 | case XK_Right: /* "\033[C" */ |
|
|
629 | case XK_Left: /* "\033[D" */ |
|
|
630 | strcpy (kbuf, "\033[Z"); |
|
|
631 | kbuf[2] = "DACB"[keysym - XK_Left]; |
|
|
632 | /* do Shift first */ |
|
|
633 | if (shft) |
|
|
634 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
635 | else if (ctrl) |
|
|
636 | { |
|
|
637 | kbuf[1] = 'O'; |
|
|
638 | kbuf[2] = "dacb"[keysym - XK_Left]; |
|
|
639 | } |
|
|
640 | else if (priv_modes & PrivMode_aplCUR) |
|
|
641 | kbuf[1] = 'O'; |
|
|
642 | break; |
|
|
643 | |
|
|
644 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
645 | case XK_Prior: |
|
|
646 | strcpy (kbuf, "\033[5~"); |
|
|
647 | break; |
|
|
648 | case XK_Next: |
|
|
649 | strcpy (kbuf, "\033[6~"); |
|
|
650 | break; |
|
|
651 | #endif |
|
|
652 | case XK_KP_Enter: |
|
|
653 | /* allow shift to override */ |
|
|
654 | if (kp) |
|
|
655 | { |
|
|
656 | strcpy (kbuf, "\033OM"); |
|
|
657 | break; |
|
|
658 | } |
|
|
659 | |
|
|
660 | /* FALLTHROUGH */ |
|
|
661 | |
|
|
662 | case XK_Return: |
|
|
663 | if (priv_modes & PrivMode_LFNL) |
|
|
664 | { |
|
|
665 | kbuf[0] = '\015'; |
|
|
666 | kbuf[1] = '\012'; |
|
|
667 | kbuf[2] = '\0'; |
|
|
668 | } |
|
|
669 | else |
|
|
670 | { |
|
|
671 | kbuf[0] = '\015'; |
|
|
672 | kbuf[1] = '\0'; |
|
|
673 | } |
|
|
674 | break; |
|
|
675 | |
|
|
676 | case XK_KP_F1: /* "\033OP" */ |
|
|
677 | case XK_KP_F2: /* "\033OQ" */ |
|
|
678 | case XK_KP_F3: /* "\033OR" */ |
|
|
679 | case XK_KP_F4: /* "\033OS" */ |
|
|
680 | strcpy (kbuf, "\033OP"); |
|
|
681 | kbuf[2] += (keysym - XK_KP_F1); |
|
|
682 | break; |
|
|
683 | |
|
|
684 | case XK_KP_Multiply: /* "\033Oj" : "*" */ |
|
|
685 | case XK_KP_Add: /* "\033Ok" : "+" */ |
|
|
686 | case XK_KP_Separator: /* "\033Ol" : "," */ |
|
|
687 | case XK_KP_Subtract: /* "\033Om" : "-" */ |
|
|
688 | case XK_KP_Decimal: /* "\033On" : "." */ |
|
|
689 | case XK_KP_Divide: /* "\033Oo" : "/" */ |
|
|
690 | case XK_KP_0: /* "\033Op" : "0" */ |
|
|
691 | case XK_KP_1: /* "\033Oq" : "1" */ |
|
|
692 | case XK_KP_2: /* "\033Or" : "2" */ |
|
|
693 | case XK_KP_3: /* "\033Os" : "3" */ |
|
|
694 | case XK_KP_4: /* "\033Ot" : "4" */ |
|
|
695 | case XK_KP_5: /* "\033Ou" : "5" */ |
|
|
696 | case XK_KP_6: /* "\033Ov" : "6" */ |
|
|
697 | case XK_KP_7: /* "\033Ow" : "7" */ |
|
|
698 | case XK_KP_8: /* "\033Ox" : "8" */ |
|
|
699 | case XK_KP_9: /* "\033Oy" : "9" */ |
|
|
700 | /* allow shift to override */ |
|
|
701 | if (kp) |
|
|
702 | { |
|
|
703 | strcpy (kbuf, "\033Oj"); |
|
|
704 | kbuf[2] += (keysym - XK_KP_Multiply); |
|
|
705 | } |
|
|
706 | else |
|
|
707 | { |
|
|
708 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
|
|
709 | kbuf[1] = '\0'; |
|
|
710 | } |
|
|
711 | break; |
|
|
712 | |
|
|
713 | case XK_Find: |
|
|
714 | strcpy (kbuf, "\033[1~"); |
|
|
715 | break; |
|
|
716 | |
|
|
717 | case XK_Insert: |
|
|
718 | strcpy (kbuf, "\033[2~"); |
|
|
719 | break; |
|
|
720 | #ifdef DXK_Remove /* support for DEC remove like key */ |
|
|
721 | case DXK_Remove: |
|
|
722 | /* FALLTHROUGH */ |
|
|
723 | #endif |
|
|
724 | case XK_Execute: |
|
|
725 | strcpy (kbuf, "\033[3~"); |
|
|
726 | break; |
|
|
727 | case XK_Select: |
|
|
728 | strcpy (kbuf, "\033[4~"); |
|
|
729 | break; |
|
|
730 | case XK_End: |
|
|
731 | strcpy (kbuf, KS_END); |
|
|
732 | break; |
|
|
733 | case XK_Home: |
|
|
734 | strcpy (kbuf, KS_HOME); |
|
|
735 | break; |
|
|
736 | |
|
|
737 | #define FKEY(n, fkey) \ |
|
|
738 | sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey))) |
|
|
739 | |
|
|
740 | case XK_F1: /* "\033[11~" */ |
|
|
741 | case XK_F2: /* "\033[12~" */ |
|
|
742 | case XK_F3: /* "\033[13~" */ |
|
|
743 | case XK_F4: /* "\033[14~" */ |
|
|
744 | case XK_F5: /* "\033[15~" */ |
|
|
745 | FKEY (11, XK_F1); |
|
|
746 | break; |
|
|
747 | case XK_F6: /* "\033[17~" */ |
|
|
748 | case XK_F7: /* "\033[18~" */ |
|
|
749 | case XK_F8: /* "\033[19~" */ |
|
|
750 | case XK_F9: /* "\033[20~" */ |
|
|
751 | case XK_F10: /* "\033[21~" */ |
|
|
752 | FKEY (17, XK_F6); |
|
|
753 | break; |
|
|
754 | case XK_F11: /* "\033[23~" */ |
|
|
755 | case XK_F12: /* "\033[24~" */ |
|
|
756 | case XK_F13: /* "\033[25~" */ |
|
|
757 | case XK_F14: /* "\033[26~" */ |
|
|
758 | FKEY (23, XK_F11); |
|
|
759 | break; |
|
|
760 | case XK_F15: /* "\033[28~" */ |
|
|
761 | case XK_F16: /* "\033[29~" */ |
|
|
762 | FKEY (28, XK_F15); |
|
|
763 | break; |
|
|
764 | case XK_Help: /* "\033[28~" */ |
|
|
765 | FKEY (28, XK_Help); |
|
|
766 | break; |
|
|
767 | case XK_Menu: /* "\033[29~" */ |
|
|
768 | FKEY (29, XK_Menu); |
|
|
769 | break; |
|
|
770 | case XK_F17: /* "\033[31~" */ |
|
|
771 | case XK_F18: /* "\033[32~" */ |
|
|
772 | case XK_F19: /* "\033[33~" */ |
|
|
773 | case XK_F20: /* "\033[34~" */ |
|
|
774 | case XK_F21: /* "\033[35~" */ |
|
|
775 | case XK_F22: /* "\033[36~" */ |
|
|
776 | case XK_F23: /* "\033[37~" */ |
|
|
777 | case XK_F24: /* "\033[38~" */ |
|
|
778 | case XK_F25: /* "\033[39~" */ |
|
|
779 | case XK_F26: /* "\033[40~" */ |
|
|
780 | case XK_F27: /* "\033[41~" */ |
|
|
781 | case XK_F28: /* "\033[42~" */ |
|
|
782 | case XK_F29: /* "\033[43~" */ |
|
|
783 | case XK_F30: /* "\033[44~" */ |
|
|
784 | case XK_F31: /* "\033[45~" */ |
|
|
785 | case XK_F32: /* "\033[46~" */ |
|
|
786 | case XK_F33: /* "\033[47~" */ |
|
|
787 | case XK_F34: /* "\033[48~" */ |
|
|
788 | case XK_F35: /* "\033[49~" */ |
|
|
789 | FKEY (31, XK_F17); |
|
|
790 | break; |
|
|
791 | #undef FKEY |
|
|
792 | default: |
|
|
793 | newlen = 0; |
776 | newlen = 0; |
794 | break; |
|
|
795 | } |
777 | } |
|
|
778 | break; |
|
|
779 | } |
796 | |
780 | |
797 | if (newlen) |
781 | if (newlen) |
798 | len = strlen (kbuf); |
782 | len = strlen (kbuf); |
799 | |
783 | |
800 | /* |
784 | /* |
801 | * Pass meta for all function keys, if 'meta' option set |
785 | * Pass meta for all function keys, if 'meta' option set |
802 | */ |
786 | */ |
803 | #ifdef META8_OPTION |
787 | #ifdef META8_OPTION |
… | |
… | |
903 | commit_iso14755 (); |
887 | commit_iso14755 (); |
904 | |
888 | |
905 | return; |
889 | return; |
906 | } |
890 | } |
907 | |
891 | |
908 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
892 | for (unsigned short *i = iso14755_symtab; i[0]; i += 2) |
909 | if (i[0] == keysym) |
893 | if (i[0] == keysym) |
910 | { |
894 | { |
911 | iso14755buf = ISO_14755_51 | i[1]; |
895 | iso14755buf = ISO_14755_51 | i[1]; |
912 | commit_iso14755 (); |
896 | commit_iso14755 (); |
913 | |
897 | |
… | |
… | |
950 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
934 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
951 | mouse_slip_wheel_speed = 0; |
935 | mouse_slip_wheel_speed = 0; |
952 | #endif |
936 | #endif |
953 | } |
937 | } |
954 | |
938 | |
955 | #if defined (KEYSYM_RESOURCE) |
|
|
956 | unsigned int |
|
|
957 | rxvt_term::cmd_write (const char *str, unsigned int count) |
|
|
958 | { |
|
|
959 | unsigned int n, s; |
|
|
960 | |
|
|
961 | n = cmdbuf_ptr - cmdbuf_base; |
|
|
962 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
|
|
963 | |
|
|
964 | if (n > 0 && s < count) |
|
|
965 | { |
|
|
966 | memmove (cmdbuf_base, cmdbuf_ptr, |
|
|
967 | (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); |
|
|
968 | cmdbuf_ptr = cmdbuf_base; |
|
|
969 | cmdbuf_endp -= n; |
|
|
970 | s += n; |
|
|
971 | } |
|
|
972 | |
|
|
973 | if (count > s) |
|
|
974 | { |
|
|
975 | rxvt_warn ("data loss: cmd_write too large, continuing.\n"); |
|
|
976 | count = s; |
|
|
977 | } |
|
|
978 | |
|
|
979 | for (; count--;) |
|
|
980 | *cmdbuf_endp++ = *str++; |
|
|
981 | |
|
|
982 | cmd_parse (); |
|
|
983 | |
|
|
984 | return 0; |
|
|
985 | } |
|
|
986 | #endif |
|
|
987 | |
|
|
988 | void |
939 | void |
989 | rxvt_term::flush () |
940 | rxvt_term::flush () |
990 | { |
941 | { |
991 | flush_ev.stop (); |
942 | flush_ev.stop (); |
992 | |
943 | |
993 | #ifdef HAVE_BG_PIXMAP |
944 | #ifdef HAVE_BG_PIXMAP |
994 | if (bgPixmap.check_clearChanged ()) |
945 | if (bg_flags & BG_NEEDS_REFRESH) |
995 | { |
946 | { |
996 | // scr_clear (true); This needs to be researched further! |
947 | bg_flags &= ~BG_NEEDS_REFRESH; |
997 | scr_touch (false); |
948 | scr_touch (false); |
998 | } |
949 | } |
999 | #endif |
950 | #endif |
1000 | |
951 | |
1001 | if (want_refresh) |
952 | if (want_refresh) |
… | |
… | |
1037 | } |
988 | } |
1038 | while (row < end_row); |
989 | while (row < end_row); |
1039 | } |
990 | } |
1040 | |
991 | |
1041 | scr_refresh (); |
992 | scr_refresh (); |
1042 | scrollbar_show (1); |
993 | scrollBar.show (1); |
1043 | #ifdef USE_XIM |
994 | #ifdef USE_XIM |
1044 | IMSendSpot (); |
995 | IMSendSpot (); |
1045 | #endif |
996 | #endif |
1046 | } |
997 | } |
1047 | |
998 | |
1048 | display->flush (); |
999 | display->flush (); |
1049 | } |
1000 | } |
1050 | |
1001 | |
1051 | /* checks wether a refresh is requested and starts the refresh timer */ |
1002 | /* checks whether a refresh is requested and starts the refresh timer */ |
1052 | void |
1003 | void |
1053 | rxvt_term::refresh_check () |
1004 | rxvt_term::refresh_check () |
1054 | { |
1005 | { |
1055 | if (want_refresh && !flush_ev.is_active ()) |
1006 | if (want_refresh && !flush_ev.is_active ()) |
1056 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
1007 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
… | |
… | |
1149 | { |
1100 | { |
1150 | // this should really be sched_yield(), but the linux guys thought |
1101 | // this should really be sched_yield(), but the linux guys thought |
1151 | // that giving a process calling sched_yield () less cpu time than |
1102 | // that giving a process calling sched_yield () less cpu time than |
1152 | // ones with high nice levels is a useful thing to do. It surely is is |
1103 | // ones with high nice levels is a useful thing to do. It surely is is |
1153 | // allowed by the sus... as is returning ENOSYS. |
1104 | // allowed by the sus... as is returning ENOSYS. |
|
|
1105 | // since the linux guys additionally thought that breaking the only |
|
|
1106 | // known workaround against their unusable sched_yield hack is cool, |
|
|
1107 | // we just nanosleep a bit and hope for the best. |
1154 | |
1108 | |
1155 | struct timespec ts = { 0, 0 }; |
1109 | struct timespec ts = { 0, 1000 }; |
1156 | nanosleep (&ts, 0); |
1110 | nanosleep (&ts, 0); |
1157 | |
1111 | |
1158 | w.stop (); |
1112 | w.stop (); |
1159 | } |
1113 | } |
1160 | |
1114 | |
… | |
… | |
1163 | { |
1117 | { |
1164 | } |
1118 | } |
1165 | } event_handler; |
1119 | } event_handler; |
1166 | #endif |
1120 | #endif |
1167 | |
1121 | |
|
|
1122 | /* make sure all the cmd data is at beginning of cmdbuf */ |
|
|
1123 | void |
|
|
1124 | rxvt_term::cmdbuf_reify () |
|
|
1125 | { |
|
|
1126 | if (cmdbuf_ptr == cmdbuf_base) |
|
|
1127 | return; |
|
|
1128 | |
|
|
1129 | ssize_t used = cmdbuf_endp - cmdbuf_ptr; |
|
|
1130 | |
|
|
1131 | memmove (cmdbuf_base, cmdbuf_ptr, used); |
|
|
1132 | cmdbuf_ptr = cmdbuf_base; |
|
|
1133 | cmdbuf_endp = cmdbuf_ptr + used; |
|
|
1134 | |
|
|
1135 | } |
|
|
1136 | |
|
|
1137 | #if defined (KEYSYM_RESOURCE) |
|
|
1138 | void |
|
|
1139 | rxvt_term::cmdbuf_append (const char *str, size_t count) |
|
|
1140 | { |
|
|
1141 | cmdbuf_reify (); |
|
|
1142 | |
|
|
1143 | size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp; |
|
|
1144 | |
|
|
1145 | if (count > avail) |
|
|
1146 | return; |
|
|
1147 | |
|
|
1148 | memcpy (cmdbuf_endp, str, count); |
|
|
1149 | cmdbuf_endp += count; |
|
|
1150 | |
|
|
1151 | cmd_parse (); |
|
|
1152 | } |
|
|
1153 | #endif |
|
|
1154 | |
1168 | bool |
1155 | bool |
1169 | rxvt_term::pty_fill () |
1156 | rxvt_term::pty_fill () |
1170 | { |
1157 | { |
1171 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1158 | cmdbuf_reify (); |
1172 | |
1159 | |
1173 | if (CBUFSIZ == n) |
1160 | size_t avail = cmdbuf_base + CBUFSIZ - cmdbuf_endp; |
1174 | { |
1161 | |
1175 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1162 | if (!avail) |
1176 | n = 0; |
|
|
1177 | } |
1163 | { |
1178 | |
1164 | // normally this indicates a "too long" command sequence - just drop the data we have |
1179 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
|
|
1180 | cmdbuf_ptr = cmdbuf_base; |
1165 | cmdbuf_ptr = cmdbuf_base; |
1181 | cmdbuf_endp = cmdbuf_ptr + n; |
1166 | cmdbuf_endp = cmdbuf_ptr; |
|
|
1167 | avail = CBUFSIZ; |
|
|
1168 | } |
1182 | |
1169 | |
1183 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1170 | ssize_t r = read (pty->pty, cmdbuf_endp, avail); |
1184 | |
1171 | |
1185 | if (r > 0) |
1172 | if (r > 0) |
1186 | { |
1173 | { |
1187 | cmdbuf_endp += r; |
1174 | cmdbuf_endp += r; |
1188 | return true; |
1175 | return true; |
… | |
… | |
1210 | { |
1197 | { |
1211 | make_current (); |
1198 | make_current (); |
1212 | |
1199 | |
1213 | if (revents & ev::READ) |
1200 | if (revents & ev::READ) |
1214 | // loop, but don't allow a single term to monopolize us |
1201 | // loop, but don't allow a single term to monopolize us |
1215 | while (pty_fill ()) |
1202 | for (int i = CBUFCNT; i-- && pty_fill (); ) |
1216 | if (cmd_parse ()) |
1203 | cmd_parse (); |
1217 | break; |
|
|
1218 | |
1204 | |
1219 | if (revents & ev::WRITE) |
1205 | if (revents & ev::WRITE) |
1220 | pty_write (); |
1206 | pty_write (); |
1221 | |
1207 | |
1222 | refresh_check (); |
1208 | refresh_check (); |
… | |
… | |
1263 | { |
1249 | { |
1264 | int button_number, key_state = 0; |
1250 | int button_number, key_state = 0; |
1265 | int x, y; |
1251 | int x, y; |
1266 | int code = 32; |
1252 | int code = 32; |
1267 | |
1253 | |
1268 | x = Pixel2Col (ev.x); |
1254 | x = Pixel2Col (ev.x) + 1; |
1269 | y = Pixel2Row (ev.y); |
1255 | y = Pixel2Row (ev.y) + 1; |
|
|
1256 | |
1270 | if (ev.type == MotionNotify) |
1257 | if (ev.type == MotionNotify) |
1271 | { |
1258 | { |
1272 | if (x == mouse_row && y == mouse_col) |
1259 | if (x == mouse_row && y == mouse_col) |
1273 | return; |
1260 | return; |
|
|
1261 | |
1274 | mouse_row = x; |
1262 | mouse_row = x; |
1275 | mouse_col = y; |
1263 | mouse_col = y; |
1276 | code += 32; |
1264 | code += 32; |
1277 | } |
1265 | } |
1278 | |
1266 | |
… | |
… | |
1281 | else |
1269 | else |
1282 | { |
1270 | { |
1283 | button_number = MEvent.button - Button1; |
1271 | button_number = MEvent.button - Button1; |
1284 | /* add 0x3D for wheel events, like xterm does */ |
1272 | /* add 0x3D for wheel events, like xterm does */ |
1285 | if (button_number >= 3) |
1273 | if (button_number >= 3) |
1286 | button_number += (64 - 3); |
1274 | button_number += 64 - 3; |
1287 | } |
1275 | } |
1288 | |
1276 | |
1289 | if (priv_modes & PrivMode_MouseX10) |
1277 | if (priv_modes & PrivMode_MouseX10) |
1290 | { |
1278 | { |
1291 | /* |
1279 | /* |
… | |
… | |
1323 | fputc ('A', stderr); |
1311 | fputc ('A', stderr); |
1324 | if (key_state & 32) |
1312 | if (key_state & 32) |
1325 | fputc ('2', stderr); |
1313 | fputc ('2', stderr); |
1326 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1314 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1327 | button_number, |
1315 | button_number, |
1328 | x + 1, |
1316 | x, |
1329 | y + 1); |
1317 | y); |
1330 | #endif |
1318 | #endif |
1331 | |
1319 | |
|
|
1320 | #if ENABLE_FRILLS |
|
|
1321 | if (priv_modes & PrivMode_ExtMouseRight) |
|
|
1322 | tt_printf ("\033[%d;%d;%dM", |
|
|
1323 | code + button_number + key_state, |
|
|
1324 | x, |
|
|
1325 | y); |
|
|
1326 | else if (priv_modes & PrivMode_ExtModeMouse) |
|
|
1327 | tt_printf ("\033[M%c%lc%lc", |
|
|
1328 | code + button_number + key_state, |
|
|
1329 | wint_t (32 + x), |
|
|
1330 | wint_t (32 + y)); |
|
|
1331 | else |
|
|
1332 | #endif |
1332 | tt_printf ("\033[M%c%c%c", |
1333 | tt_printf ("\033[M%c%c%c", |
1333 | (code + button_number + key_state), |
1334 | code + button_number + key_state, |
1334 | (32 + x + 1), |
1335 | 32 + x, |
1335 | (32 + y + 1)); |
1336 | 32 + y); |
1336 | } |
1337 | } |
1337 | |
1338 | |
1338 | /*{{{ process an X event */ |
1339 | /*{{{ process an X event */ |
1339 | void |
1340 | void |
1340 | rxvt_term::x_cb (XEvent &ev) |
1341 | rxvt_term::x_cb (XEvent &ev) |
… | |
… | |
1442 | && ev.xfocus.mode != NotifyGrab) |
1443 | && ev.xfocus.mode != NotifyGrab) |
1443 | focus_out (); |
1444 | focus_out (); |
1444 | break; |
1445 | break; |
1445 | |
1446 | |
1446 | case ConfigureNotify: |
1447 | case ConfigureNotify: |
1447 | /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", |
|
|
1448 | ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, |
|
|
1449 | szHint.width, szHint.height);*/ |
|
|
1450 | if (ev.xconfigure.window == parent[0]) |
1448 | if (ev.xconfigure.window == parent) |
1451 | { |
1449 | { |
1452 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1450 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1453 | ; |
1451 | ; |
|
|
1452 | |
|
|
1453 | #ifdef HAVE_BG_PIXMAP |
|
|
1454 | bool moved = false; |
|
|
1455 | if (bg_window_position_sensitive ()) |
|
|
1456 | { |
|
|
1457 | int x, y; |
|
|
1458 | if (ev.xconfigure.send_event) |
|
|
1459 | { |
|
|
1460 | x = ev.xconfigure.x; |
|
|
1461 | y = ev.xconfigure.y; |
|
|
1462 | } |
|
|
1463 | else |
|
|
1464 | get_window_origin (x, y); |
|
|
1465 | |
|
|
1466 | if (bg_set_position (x, y) |
|
|
1467 | || !(bg_flags & BG_IS_VALID)) |
|
|
1468 | moved = true; |
|
|
1469 | } |
|
|
1470 | #endif |
1454 | |
1471 | |
1455 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1472 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1456 | { |
1473 | { |
1457 | seen_resize = 1; |
1474 | seen_resize = 1; |
1458 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1475 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1459 | } |
1476 | } |
1460 | else |
1477 | else |
1461 | { |
1478 | { |
1462 | #ifdef HAVE_BG_PIXMAP |
1479 | #ifdef HAVE_BG_PIXMAP |
1463 | if (bgPixmap.window_position_sensitive ()) |
1480 | if (moved) |
1464 | { |
1481 | { |
1465 | if (mapped) |
1482 | if (mapped) |
1466 | update_background (); |
1483 | update_background (); |
1467 | else |
1484 | else |
1468 | bgPixmap.invalidate (); |
1485 | bg_invalidate (); |
1469 | } |
1486 | } |
1470 | #endif |
1487 | #endif |
1471 | } |
1488 | } |
1472 | |
1489 | |
1473 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1490 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1474 | } |
1491 | } |
1475 | break; |
1492 | break; |
1476 | |
1493 | |
1477 | case PropertyNotify: |
1494 | case PropertyNotify: |
1478 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1495 | HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1479 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
|
|
1480 | && ev.xproperty.state == PropertyNewValue) |
|
|
1481 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
|
|
1482 | |
|
|
1483 | break; |
1496 | break; |
1484 | |
1497 | |
1485 | case SelectionClear: |
1498 | case SelectionClear: |
1486 | selection_clear (); |
1499 | selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]); |
1487 | break; |
|
|
1488 | |
|
|
1489 | case SelectionNotify: |
|
|
1490 | if (selection_wait == Sel_normal) |
|
|
1491 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
|
|
1492 | break; |
1500 | break; |
1493 | |
1501 | |
1494 | case SelectionRequest: |
1502 | case SelectionRequest: |
1495 | selection_send (ev.xselectionrequest); |
1503 | selection_send (ev.xselectionrequest); |
1496 | break; |
1504 | break; |
1497 | |
1505 | |
1498 | case MapNotify: |
1506 | case MapNotify: |
1499 | #ifdef HAVE_BG_PIXMAP |
1507 | #ifdef HAVE_BG_PIXMAP |
1500 | /* This is needed spcifically to fix the case of no window manager or a |
1508 | /* This is needed specifically to fix the case of no window manager or a |
1501 | * non-reparenting window manager. In those cases we never get first |
1509 | * non-reparenting window manager. In those cases we never get first |
1502 | * ConfigureNotify. Also that speeds startup under normal WM, by taking |
1510 | * ConfigureNotify. Also that speeds startup under normal WM, by taking |
1503 | * care of multiplicity of ConfigureNotify events arriwing while WM does |
1511 | * care of multiplicity of ConfigureNotify events arriving while WM does |
1504 | * reparenting. |
1512 | * reparenting. |
1505 | * We should not render background immidiately, as there could be several |
1513 | * We should not render background immediately, as there could be several |
1506 | * ConfigureNotify's to follow. Lets take care of all of them in one scoop |
1514 | * ConfigureNotify's to follow. Lets take care of all of them in one scoop |
1507 | * by scheduling background redraw as soon as we can, but giving a short |
1515 | * by scheduling background redraw as soon as we can, but giving a short |
1508 | * bit of time for ConfigureNotifies to arrive. |
1516 | * bit of time for ConfigureNotifies to arrive. |
1509 | * We should render background PRIOR to drawing any text, but AFTER all |
1517 | * We should render background PRIOR to drawing any text, but AFTER all |
1510 | * of ConfigureNotifys for the best results. |
1518 | * of ConfigureNotifys for the best results. |
1511 | */ |
1519 | */ |
1512 | if (bgPixmap.flags & bgPixmap_t::isInvalid) |
1520 | if (!(bg_flags & BG_IS_VALID)) |
1513 | update_background_ev.start (0.025); |
1521 | update_background_ev.start (0.025); |
1514 | #endif |
1522 | #endif |
1515 | mapped = 1; |
1523 | mapped = 1; |
1516 | #ifdef TEXT_BLINK |
1524 | #ifdef TEXT_BLINK |
1517 | text_blink_ev.start (); |
1525 | text_blink_ev.start (); |
… | |
… | |
1532 | if (ev.xany.window == vt) |
1540 | if (ev.xany.window == vt) |
1533 | { |
1541 | { |
1534 | do |
1542 | do |
1535 | { |
1543 | { |
1536 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1544 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1537 | ev.xexpose.width, ev.xexpose.height, False); |
1545 | ev.xexpose.width, ev.xexpose.height, false); |
1538 | } |
1546 | } |
1539 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1547 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1540 | |
1548 | |
1541 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1549 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1542 | |
1550 | |
1543 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1551 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1544 | { |
1552 | { |
1545 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1553 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1546 | ev.xexpose.width, ev.xexpose.height, False); |
1554 | ev.xexpose.width, ev.xexpose.height, false); |
1547 | } |
1555 | } |
1548 | |
1556 | |
1549 | want_refresh = 1; |
1557 | want_refresh = 1; |
1550 | } |
1558 | } |
1551 | else |
1559 | else |
… | |
… | |
1558 | ; |
1566 | ; |
1559 | |
1567 | |
1560 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1568 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1561 | { |
1569 | { |
1562 | scrollBar.state = STATE_IDLE; |
1570 | scrollBar.state = STATE_IDLE; |
1563 | scrollbar_show (0); |
1571 | scrollBar.show (0); |
1564 | } |
1572 | } |
1565 | } |
1573 | } |
1566 | break; |
1574 | break; |
1567 | |
1575 | |
1568 | case MotionNotify: |
1576 | case MotionNotify: |
… | |
… | |
1667 | &unused_root, &unused_child, |
1675 | &unused_root, &unused_child, |
1668 | &unused_root_x, &unused_root_y, |
1676 | &unused_root_x, &unused_root_y, |
1669 | &ev.xbutton.x, &ev.xbutton.y, |
1677 | &ev.xbutton.x, &ev.xbutton.y, |
1670 | &unused_mask); |
1678 | &unused_mask); |
1671 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1679 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1672 | scrollbar_size ()); |
1680 | scrollBar.size ()); |
1673 | want_refresh = 1; |
1681 | want_refresh = 1; |
1674 | scrollbar_show (1); |
1682 | scrollBar.show (1); |
1675 | } |
1683 | } |
1676 | break; |
1684 | break; |
1677 | } |
1685 | } |
1678 | |
1686 | |
1679 | #if defined(CURSOR_BLINK) |
1687 | #if defined(CURSOR_BLINK) |
… | |
… | |
1704 | #endif |
1712 | #endif |
1705 | |
1713 | |
1706 | refresh_check (); |
1714 | refresh_check (); |
1707 | } |
1715 | } |
1708 | |
1716 | |
|
|
1717 | #if ENABLE_FRILLS |
|
|
1718 | void |
|
|
1719 | rxvt_term::set_urgency (bool enable) |
|
|
1720 | { |
|
|
1721 | if (enable == urgency_hint) |
|
|
1722 | return; |
|
|
1723 | |
|
|
1724 | if (XWMHints *h = XGetWMHints (dpy, parent)) |
|
|
1725 | { |
|
|
1726 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
|
|
1727 | XSetWMHints (dpy, parent, h); |
|
|
1728 | urgency_hint = enable; |
|
|
1729 | } |
|
|
1730 | } |
|
|
1731 | #endif |
|
|
1732 | |
1709 | void |
1733 | void |
1710 | rxvt_term::focus_in () |
1734 | rxvt_term::focus_in () |
1711 | { |
1735 | { |
1712 | if (!focus) |
1736 | if (!focus) |
1713 | { |
1737 | { |
1714 | focus = 1; |
1738 | focus = 1; |
1715 | want_refresh = 1; |
1739 | want_refresh = 1; |
1716 | |
|
|
1717 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1718 | |
1740 | |
1719 | #if USE_XIM |
1741 | #if USE_XIM |
1720 | if (Input_Context != NULL) |
1742 | if (Input_Context != NULL) |
1721 | { |
1743 | { |
1722 | IMSetPosition (); |
1744 | IMSetPosition (); |
… | |
… | |
1734 | scr_recolour (); |
1756 | scr_recolour (); |
1735 | } |
1757 | } |
1736 | #endif |
1758 | #endif |
1737 | #if ENABLE_FRILLS |
1759 | #if ENABLE_FRILLS |
1738 | if (option (Opt_urgentOnBell)) |
1760 | if (option (Opt_urgentOnBell)) |
1739 | { |
1761 | set_urgency (0); |
1740 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1741 | { |
|
|
1742 | h->flags &= ~XUrgencyHint; |
|
|
1743 | XSetWMHints (dpy, parent[0], h); |
|
|
1744 | } |
|
|
1745 | } |
|
|
1746 | #endif |
1762 | #endif |
|
|
1763 | |
|
|
1764 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1747 | } |
1765 | } |
1748 | } |
1766 | } |
1749 | |
1767 | |
1750 | void |
1768 | void |
1751 | rxvt_term::focus_out () |
1769 | rxvt_term::focus_out () |
… | |
… | |
1753 | if (focus) |
1771 | if (focus) |
1754 | { |
1772 | { |
1755 | focus = 0; |
1773 | focus = 0; |
1756 | want_refresh = 1; |
1774 | want_refresh = 1; |
1757 | |
1775 | |
1758 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1776 | #if ENABLE_FRILLS |
1759 | |
1777 | if (option (Opt_urgentOnBell)) |
|
|
1778 | set_urgency (0); |
|
|
1779 | #endif |
1760 | #if ENABLE_FRILLS || ISO_14755 |
1780 | #if ENABLE_FRILLS || ISO_14755 |
1761 | if (iso14755buf) |
1781 | if (iso14755buf) |
1762 | { |
1782 | { |
1763 | iso14755buf = 0; |
1783 | iso14755buf = 0; |
1764 | # if ISO_14755 |
1784 | # if ISO_14755 |
… | |
… | |
1781 | { |
1801 | { |
1782 | pix_colors = pix_colors_unfocused; |
1802 | pix_colors = pix_colors_unfocused; |
1783 | scr_recolour (); |
1803 | scr_recolour (); |
1784 | } |
1804 | } |
1785 | #endif |
1805 | #endif |
|
|
1806 | |
|
|
1807 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1786 | } |
1808 | } |
1787 | } |
1809 | } |
1788 | |
1810 | |
1789 | void |
1811 | void |
1790 | rxvt_term::update_fade_color (unsigned int idx) |
1812 | rxvt_term::update_fade_color (unsigned int idx) |
… | |
… | |
1818 | * use the property to determine the pixmap. We use it later on. |
1840 | * use the property to determine the pixmap. We use it later on. |
1819 | */ |
1841 | */ |
1820 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1842 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1821 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1843 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1822 | { |
1844 | { |
1823 | bgPixmap.set_root_pixmap (); |
1845 | bg_set_root_pixmap (); |
1824 | update_background (); |
1846 | update_background (); |
1825 | } |
1847 | } |
1826 | |
1848 | |
1827 | break; |
1849 | break; |
1828 | } |
1850 | } |
… | |
… | |
1867 | /* save the xbutton state (for ButtonRelease) */ |
1889 | /* save the xbutton state (for ButtonRelease) */ |
1868 | MEvent.state = ev.state; |
1890 | MEvent.state = ev.state; |
1869 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1891 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1870 | if (ev.button == MEvent.button && clickintime) |
1892 | if (ev.button == MEvent.button && clickintime) |
1871 | { |
1893 | { |
1872 | /* same button, within alloted time */ |
1894 | /* same button, within allowed time */ |
1873 | MEvent.clicks++; |
1895 | MEvent.clicks++; |
1874 | |
1896 | |
1875 | if (MEvent.clicks > 1) |
1897 | if (MEvent.clicks > 1) |
1876 | { |
1898 | { |
1877 | /* only report double clicks */ |
1899 | /* only report double clicks */ |
… | |
… | |
2032 | } |
2054 | } |
2033 | |
2055 | |
2034 | if (scrollBar.style == R_SB_XTERM |
2056 | if (scrollBar.style == R_SB_XTERM |
2035 | || scrollbar_above_slider (ev.y) |
2057 | || scrollbar_above_slider (ev.y) |
2036 | || scrollbar_below_slider (ev.y)) |
2058 | || scrollbar_below_slider (ev.y)) |
2037 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2059 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ()); |
2038 | |
2060 | |
2039 | scrollBar.state = STATE_MOTION; |
2061 | scrollBar.state = STATE_MOTION; |
2040 | break; |
2062 | break; |
2041 | |
2063 | |
2042 | case Button1: |
2064 | case Button1: |
… | |
… | |
2065 | else |
2087 | else |
2066 | { |
2088 | { |
2067 | scr_page ((ev.button == Button1 ? DN : UP), |
2089 | scr_page ((ev.button == Button1 ? DN : UP), |
2068 | (nrow |
2090 | (nrow |
2069 | * scrollbar_position (ev.y) |
2091 | * scrollbar_position (ev.y) |
2070 | / scrollbar_size ())); |
2092 | / scrollBar.size ())); |
2071 | } |
2093 | } |
2072 | |
2094 | |
2073 | break; |
2095 | break; |
2074 | } |
2096 | } |
2075 | } |
2097 | } |
… | |
… | |
2088 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2110 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2089 | |
2111 | |
2090 | if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
2112 | if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
2091 | { |
2113 | { |
2092 | scrollBar.state = STATE_IDLE; |
2114 | scrollBar.state = STATE_IDLE; |
2093 | scrollbar_show (0); |
2115 | scrollBar.show (0); |
2094 | } |
2116 | } |
2095 | |
2117 | |
2096 | #ifdef SELECTION_SCROLLING |
2118 | #ifdef SELECTION_SCROLLING |
2097 | sel_scroll_ev.stop(); |
2119 | sel_scroll_ev.stop(); |
2098 | #endif |
2120 | #endif |
… | |
… | |
2148 | selection_make (ev.time); |
2170 | selection_make (ev.time); |
2149 | break; |
2171 | break; |
2150 | |
2172 | |
2151 | case Button2: |
2173 | case Button2: |
2152 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2174 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2153 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2175 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2154 | break; |
2176 | break; |
2155 | |
2177 | |
2156 | #ifdef MOUSE_WHEEL |
2178 | #ifdef MOUSE_WHEEL |
2157 | case Button4: |
2179 | case Button4: |
2158 | case Button5: |
2180 | case Button5: |
… | |
… | |
2181 | } |
2203 | } |
2182 | else |
2204 | else |
2183 | # endif |
2205 | # endif |
2184 | { |
2206 | { |
2185 | scr_page (v, i); |
2207 | scr_page (v, i); |
2186 | scrollbar_show (1); |
2208 | scrollBar.show (1); |
2187 | } |
2209 | } |
2188 | } |
2210 | } |
2189 | break; |
2211 | break; |
2190 | #endif |
2212 | #endif |
2191 | } |
2213 | } |
2192 | } |
2214 | } |
2193 | } |
2215 | } |
2194 | |
2216 | |
2195 | /*}}} */ |
2217 | /*}}} */ |
2196 | |
2218 | |
2197 | bool |
2219 | void |
2198 | rxvt_term::cmd_parse () |
2220 | rxvt_term::cmd_parse () |
2199 | { |
2221 | { |
2200 | bool flag = false; |
|
|
2201 | wchar_t ch = NOCHAR; |
2222 | wchar_t ch = NOCHAR; |
2202 | char *seq_begin; // remember start of esc-sequence here |
2223 | char *seq_begin; // remember start of esc-sequence here |
2203 | |
2224 | |
2204 | for (;;) |
2225 | for (;;) |
2205 | { |
2226 | { |
2206 | if (ch == NOCHAR) |
2227 | if (expect_false (ch == NOCHAR)) |
2207 | { |
2228 | { |
2208 | seq_begin = cmdbuf_ptr; |
2229 | seq_begin = cmdbuf_ptr; |
2209 | ch = next_char (); |
2230 | ch = next_char (); |
2210 | |
2231 | |
2211 | if (ch == NOCHAR) |
2232 | if (ch == NOCHAR) |
2212 | break; |
2233 | break; |
2213 | } |
2234 | } |
2214 | |
2235 | |
2215 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2236 | if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) |
2216 | { |
2237 | { |
2217 | if (!seen_input) |
2238 | if (expect_false (!seen_input)) |
2218 | { |
2239 | { |
2219 | seen_input = 1; |
2240 | seen_input = 1; |
2220 | // many badly-written programs (e.g. jed) contain a race condition: |
2241 | // many badly-written programs (e.g. jed) contain a race condition: |
2221 | // they first read the screensize and then install a SIGWINCH handler. |
2242 | // they first read the screensize and then install a SIGWINCH handler. |
2222 | // some window managers resize the window early, and these programs |
2243 | // some window managers resize the window early, and these programs |
… | |
… | |
2235 | wchar_t *str = buf; |
2256 | wchar_t *str = buf; |
2236 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2257 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2237 | |
2258 | |
2238 | for (;;) |
2259 | for (;;) |
2239 | { |
2260 | { |
2240 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2261 | if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) |
2241 | break; |
2262 | break; |
2242 | |
2263 | |
2243 | *str++ = ch; |
2264 | *str++ = ch; |
2244 | |
2265 | |
2245 | if (ch == C0_LF || str >= eol) |
2266 | if (expect_false (ch == C0_LF || str >= eol)) |
2246 | { |
2267 | { |
2247 | if (ch == C0_LF) |
2268 | if (ch == C0_LF) |
2248 | nlines++; |
2269 | nlines++; |
2249 | |
2270 | |
2250 | refresh_count++; |
2271 | refresh_count++; |
… | |
… | |
2299 | * What the heck we'll cheat and only refresh less than every page-full. |
2320 | * What the heck we'll cheat and only refresh less than every page-full. |
2300 | * if skipScroll is enabled. |
2321 | * if skipScroll is enabled. |
2301 | */ |
2322 | */ |
2302 | if (refreshnow) |
2323 | if (refreshnow) |
2303 | { |
2324 | { |
2304 | flag = true; |
|
|
2305 | scr_refresh (); |
2325 | scr_refresh (); |
2306 | want_refresh = 1; |
2326 | want_refresh = 1; |
2307 | } |
2327 | } |
2308 | |
|
|
2309 | } |
2328 | } |
2310 | else |
2329 | else |
2311 | { |
2330 | { |
2312 | try |
2331 | try |
2313 | { |
2332 | { |
… | |
… | |
2321 | } |
2340 | } |
2322 | |
2341 | |
2323 | ch = NOCHAR; |
2342 | ch = NOCHAR; |
2324 | } |
2343 | } |
2325 | } |
2344 | } |
2326 | |
|
|
2327 | return flag; |
|
|
2328 | } |
2345 | } |
2329 | |
2346 | |
2330 | // read the next character |
2347 | // read the next character |
2331 | wchar_t |
2348 | wchar_t |
2332 | rxvt_term::next_char () NOTHROW |
2349 | rxvt_term::next_char () NOTHROW |
2333 | { |
2350 | { |
2334 | while (cmdbuf_ptr < cmdbuf_endp) |
2351 | while (cmdbuf_ptr < cmdbuf_endp) |
2335 | { |
2352 | { |
2336 | // assume 7-bit to be ascii ALWAYS |
2353 | // assume 7-bit to be ascii ALWAYS |
2337 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2354 | if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) |
2338 | return *cmdbuf_ptr++; |
2355 | return *cmdbuf_ptr++; |
2339 | |
2356 | |
2340 | wchar_t wc; |
2357 | wchar_t wc; |
2341 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2358 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2342 | |
2359 | |
… | |
… | |
2346 | cmdbuf_ptr = cmdbuf_endp; |
2363 | cmdbuf_ptr = cmdbuf_endp; |
2347 | break; |
2364 | break; |
2348 | } |
2365 | } |
2349 | |
2366 | |
2350 | if (len == (size_t)-1) |
2367 | if (len == (size_t)-1) |
|
|
2368 | { |
|
|
2369 | mbstate.reset (); // reset now undefined conversion state |
2351 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2370 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
|
|
2371 | } |
2352 | |
2372 | |
2353 | // assume wchar == unicode |
2373 | // assume wchar == unicode |
2354 | cmdbuf_ptr += len; |
2374 | cmdbuf_ptr += len; |
2355 | return wc & UNICODE_MASK; |
2375 | return wc & UNICODE_MASK; |
2356 | } |
2376 | } |
… | |
… | |
2367 | : NOCHAR; |
2387 | : NOCHAR; |
2368 | } |
2388 | } |
2369 | |
2389 | |
2370 | static class out_of_input out_of_input; |
2390 | static class out_of_input out_of_input; |
2371 | |
2391 | |
2372 | /* rxvt_cmd_getc () - Return next input character */ |
|
|
2373 | /* |
|
|
2374 | * Return the next input character after first passing any keyboard input |
|
|
2375 | * to the command. |
|
|
2376 | */ |
|
|
2377 | wchar_t |
2392 | wchar_t |
2378 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2393 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2379 | { |
2394 | { |
2380 | wchar_t c = next_char (); |
2395 | wchar_t c = next_char (); |
2381 | |
2396 | |
… | |
… | |
2400 | /*----------------------------------------------------------------------*/ |
2415 | /*----------------------------------------------------------------------*/ |
2401 | #ifdef PRINTPIPE |
2416 | #ifdef PRINTPIPE |
2402 | FILE * |
2417 | FILE * |
2403 | rxvt_term::popen_printer () |
2418 | rxvt_term::popen_printer () |
2404 | { |
2419 | { |
2405 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2420 | FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); |
2406 | |
2421 | |
2407 | if (stream == NULL) |
2422 | if (stream == NULL) |
2408 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2423 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2409 | |
2424 | |
2410 | return stream; |
2425 | return stream; |
… | |
… | |
2421 | * simulate attached vt100 printer |
2436 | * simulate attached vt100 printer |
2422 | */ |
2437 | */ |
2423 | void |
2438 | void |
2424 | rxvt_term::process_print_pipe () |
2439 | rxvt_term::process_print_pipe () |
2425 | { |
2440 | { |
2426 | int done; |
2441 | FILE *fd = popen_printer (); |
2427 | FILE *fd; |
|
|
2428 | |
2442 | |
2429 | if ((fd = popen_printer ()) == NULL) |
2443 | if (!fd) |
2430 | return; |
2444 | return; |
2431 | |
2445 | |
2432 | /* |
2446 | /* |
2433 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2447 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2434 | * is received. |
2448 | * is received. |
2435 | */ |
2449 | */ |
2436 | for (done = 0; !done;) |
2450 | for (int done = 0; !done; ) |
2437 | { |
2451 | { |
2438 | unsigned char buf[8]; |
2452 | unsigned char buf[8]; |
2439 | unicode_t ch; |
2453 | unicode_t ch; |
2440 | unsigned int i, len; |
2454 | unsigned int i, len; |
2441 | |
2455 | |
… | |
… | |
2586 | break; |
2600 | break; |
2587 | case 'Z': /* identify the terminal type */ |
2601 | case 'Z': /* identify the terminal type */ |
2588 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2602 | tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ |
2589 | break; |
2603 | break; |
2590 | case '<': /* turn off VT52 mode */ |
2604 | case '<': /* turn off VT52 mode */ |
2591 | PrivMode (0, PrivMode_vt52); |
2605 | set_privmode (PrivMode_vt52, 0); |
2592 | break; |
2606 | break; |
2593 | case 'F': /* use special graphics character set */ |
2607 | case 'F': /* use special graphics character set */ |
2594 | case 'G': /* use regular character set */ |
2608 | case 'G': /* use regular character set */ |
2595 | /* unimplemented */ |
2609 | /* unimplemented */ |
2596 | break; |
2610 | break; |
… | |
… | |
2650 | scr_forwardindex (); |
2664 | scr_forwardindex (); |
2651 | break; |
2665 | break; |
2652 | #endif |
2666 | #endif |
2653 | case '=': |
2667 | case '=': |
2654 | case '>': |
2668 | case '>': |
2655 | PrivMode ((ch == '='), PrivMode_aplKP); |
2669 | set_privmode (PrivMode_aplKP, ch == '='); |
2656 | break; |
2670 | break; |
2657 | |
2671 | |
2658 | case C1_40: |
2672 | case C1_40: |
2659 | cmd_getc (); |
2673 | cmd_getc (); |
2660 | break; |
2674 | break; |
… | |
… | |
2664 | |
2678 | |
2665 | /* 8.3.87: NEXT LINE */ |
2679 | /* 8.3.87: NEXT LINE */ |
2666 | case C1_NEL: /* ESC E */ |
2680 | case C1_NEL: /* ESC E */ |
2667 | { |
2681 | { |
2668 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
2682 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
2669 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
2683 | scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1); |
2670 | } |
2684 | } |
2671 | break; |
2685 | break; |
2672 | |
2686 | |
2673 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2687 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2674 | case C1_ESA: /* ESC G */ |
2688 | case C1_ESA: /* ESC G */ |
2675 | process_graphics (); |
2689 | // used by original rxvt for rob nations own graphics mode |
|
|
2690 | if (cmd_getc () == 'Q') |
|
|
2691 | tt_printf ("\033G0\012"); /* query graphics - no graphics */ |
2676 | break; |
2692 | break; |
2677 | |
2693 | |
2678 | /* 8.3.63: CHARACTER TABULATION SET */ |
2694 | /* 8.3.63: CHARACTER TABULATION SET */ |
2679 | case C1_HTS: /* ESC H */ |
2695 | case C1_HTS: /* ESC H */ |
2680 | scr_set_tab (1); |
2696 | scr_set_tab (1); |
… | |
… | |
2699 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2715 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2700 | case C1_SCI: /* ESC Z */ |
2716 | case C1_SCI: /* ESC Z */ |
2701 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2717 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2702 | break; /* steal obsolete ESC [ c */ |
2718 | break; /* steal obsolete ESC [ c */ |
2703 | |
2719 | |
2704 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2720 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */ |
2705 | case C1_CSI: /* ESC [ */ |
2721 | case C1_CSI: /* ESC [ */ |
2706 | process_csi_seq (); |
2722 | process_csi_seq (); |
2707 | break; |
2723 | break; |
2708 | |
2724 | |
2709 | /* 8.3.90: OPERATING SYSTEM COMMAND */ |
2725 | /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */ |
2710 | case C1_OSC: /* ESC ] */ |
2726 | case C1_OSC: /* ESC ] */ |
2711 | process_osc_seq (); |
2727 | process_osc_seq (); |
2712 | break; |
2728 | break; |
2713 | |
2729 | |
2714 | /* 8.3.106: RESET TO INITIAL STATE */ |
2730 | /* 8.3.106: RESET TO INITIAL STATE (RIS) */ |
2715 | case 'c': |
2731 | case 'c': |
2716 | mbstate.reset (); |
2732 | mbstate.reset (); |
2717 | scr_poweron (); |
2733 | scr_poweron (); |
2718 | scrollbar_show (1); |
2734 | scrollBar.show (1); |
2719 | break; |
2735 | break; |
2720 | |
2736 | |
2721 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
2737 | /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ |
2722 | case 'n': |
2738 | case 'n': |
2723 | scr_charset_choose (2); |
2739 | scr_charset_choose (2); |
… | |
… | |
2743 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2759 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2744 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
2760 | CSI_70 , CSI_71 , CSI_72 , CSI_73 , CSI_74 , CSI_75 , CSI_76 , CSI_77 , |
2745 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
2761 | CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F |
2746 | }; |
2762 | }; |
2747 | |
2763 | |
2748 | #define make_byte(b7,b6,b5,b4,b3,b2,b1,b0) \ |
2764 | #define make_byte(b0,b1,b2,b3,b4,b5,b6,b7) \ |
2749 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
2765 | (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ |
2750 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
2766 | | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) |
2751 | #define get_byte_array_bit(array, bit) \ |
2767 | #define get_byte_array_bit(array, bit) \ |
2752 | (!! ((array)[ (bit) / 8] & (128 >> ((bit) & 7)))) |
2768 | (!! ((array)[(bit) >> 3] & (1 << ((bit) & 7)))) |
2753 | |
2769 | |
2754 | const unsigned char csi_defaults[] = |
2770 | static const unsigned char csi_defaults[] = |
2755 | { |
2771 | { |
2756 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
2772 | make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ |
2757 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
2773 | make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ |
2758 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
2774 | make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ |
2759 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
2775 | make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ |
… | |
… | |
2774 | |
2790 | |
2775 | nargs = 0; |
2791 | nargs = 0; |
2776 | |
2792 | |
2777 | priv = 0; |
2793 | priv = 0; |
2778 | ch = cmd_getc (); |
2794 | ch = cmd_getc (); |
2779 | if (ch >= '<' && ch <= '?') |
2795 | if ((ch >= '<' && ch <= '?') || ch == '!') |
2780 | { |
2796 | { |
2781 | /* '<' '=' '>' '?' */ |
2797 | /* '<' '=' '>' '?' '!' */ |
2782 | priv = ch; |
2798 | priv = ch; |
2783 | ch = cmd_getc (); |
2799 | ch = cmd_getc (); |
2784 | } |
2800 | } |
2785 | |
2801 | |
2786 | /* read any numerical arguments */ |
2802 | /* read any numerical arguments */ |
… | |
… | |
2840 | |
2856 | |
2841 | case '?': |
2857 | case '?': |
2842 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2858 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2843 | process_terminal_mode (ch, priv, nargs, arg); |
2859 | process_terminal_mode (ch, priv, nargs, arg); |
2844 | break; |
2860 | break; |
|
|
2861 | |
|
|
2862 | case '!': |
|
|
2863 | if (ch == CSI_70) |
|
|
2864 | { |
|
|
2865 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
|
|
2866 | scr_soft_reset (); |
|
|
2867 | |
|
|
2868 | static const int pm_h[] = { 7, 25 }; |
|
|
2869 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; |
|
|
2870 | |
|
|
2871 | process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h); |
|
|
2872 | process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l); |
2845 | } |
2873 | } |
|
|
2874 | break; |
|
|
2875 | } |
|
|
2876 | |
2846 | return; |
2877 | return; |
2847 | } |
2878 | } |
2848 | |
2879 | |
2849 | switch (ch) |
2880 | switch (ch) |
2850 | { |
2881 | { |
… | |
… | |
3084 | { |
3115 | { |
3085 | /* |
3116 | /* |
3086 | * commands |
3117 | * commands |
3087 | */ |
3118 | */ |
3088 | case 1: /* deiconify window */ |
3119 | case 1: /* deiconify window */ |
3089 | XMapWindow (dpy, parent[0]); |
3120 | XMapWindow (dpy, parent); |
3090 | break; |
3121 | break; |
3091 | case 2: /* iconify window */ |
3122 | case 2: /* iconify window */ |
3092 | XIconifyWindow (dpy, parent[0], display->screen); |
3123 | XIconifyWindow (dpy, parent, display->screen); |
3093 | break; |
3124 | break; |
3094 | case 3: /* set position (pixels) */ |
3125 | case 3: /* set position (pixels) */ |
3095 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3126 | XMoveWindow (dpy, parent, args[1], args[2]); |
3096 | break; |
3127 | break; |
3097 | case 4: /* set size (pixels) */ |
3128 | case 4: /* set size (pixels) */ |
3098 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3129 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3099 | break; |
3130 | break; |
3100 | case 5: /* raise window */ |
3131 | case 5: /* raise window */ |
3101 | XRaiseWindow (dpy, parent[0]); |
3132 | XRaiseWindow (dpy, parent); |
3102 | break; |
3133 | break; |
3103 | case 6: /* lower window */ |
3134 | case 6: /* lower window */ |
3104 | XLowerWindow (dpy, parent[0]); |
3135 | XLowerWindow (dpy, parent); |
3105 | break; |
3136 | break; |
3106 | case 7: /* refresh window */ |
3137 | case 7: /* refresh window */ |
3107 | scr_touch (true); |
3138 | scr_touch (true); |
3108 | break; |
3139 | break; |
3109 | case 8: /* set size (chars) */ |
3140 | case 8: /* set size (chars) */ |
… | |
… | |
3120 | |
3151 | |
3121 | /* |
3152 | /* |
3122 | * reports - some output format copied from XTerm |
3153 | * reports - some output format copied from XTerm |
3123 | */ |
3154 | */ |
3124 | case 11: /* report window state */ |
3155 | case 11: /* report window state */ |
3125 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3156 | XGetWindowAttributes (dpy, parent, &wattr); |
3126 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3157 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3127 | break; |
3158 | break; |
3128 | case 13: /* report window position */ |
3159 | case 13: /* report window position */ |
3129 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3160 | XGetWindowAttributes (dpy, parent, &wattr); |
3130 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3161 | XTranslateCoordinates (dpy, parent, wattr.root, |
3131 | -wattr.border_width, -wattr.border_width, |
3162 | -wattr.border_width, -wattr.border_width, |
3132 | &x, &y, &wdummy); |
3163 | &x, &y, &wdummy); |
3133 | tt_printf ("\033[3;%d;%dt", x, y); |
3164 | tt_printf ("\033[3;%d;%dt", x, y); |
3134 | break; |
3165 | break; |
3135 | case 14: /* report window size (pixels) */ |
3166 | case 14: /* report window size (pixels) */ |
3136 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3167 | XGetWindowAttributes (dpy, parent, &wattr); |
3137 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3168 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3138 | break; |
3169 | break; |
3139 | case 18: /* report text area size (chars) */ |
3170 | case 18: /* report text area size (chars) */ |
3140 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3171 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3141 | break; |
3172 | break; |
… | |
… | |
3143 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3174 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3144 | break; |
3175 | break; |
3145 | case 20: /* report icon label */ |
3176 | case 20: /* report icon label */ |
3146 | { |
3177 | { |
3147 | char *s; |
3178 | char *s; |
3148 | XGetIconName (dpy, parent[0], &s); |
3179 | XGetIconName (dpy, parent, &s); |
3149 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3180 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3150 | XFree (s); |
3181 | XFree (s); |
3151 | } |
3182 | } |
3152 | break; |
3183 | break; |
3153 | case 21: /* report window title */ |
3184 | case 21: /* report window title */ |
3154 | { |
3185 | { |
3155 | char *s; |
3186 | char *s; |
3156 | XFetchName (dpy, parent[0], &s); |
3187 | XFetchName (dpy, parent, &s); |
3157 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3188 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3158 | XFree (s); |
3189 | XFree (s); |
3159 | } |
3190 | } |
3160 | break; |
3191 | break; |
3161 | } |
3192 | } |
… | |
… | |
3217 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3248 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3218 | */ |
3249 | */ |
3219 | void |
3250 | void |
3220 | rxvt_term::process_dcs_seq () |
3251 | rxvt_term::process_dcs_seq () |
3221 | { |
3252 | { |
3222 | char *s; |
|
|
3223 | unicode_t eh; |
|
|
3224 | |
|
|
3225 | /* |
3253 | /* |
3226 | * Not handled yet |
3254 | * Not handled yet |
3227 | */ |
3255 | */ |
|
|
3256 | |
|
|
3257 | unicode_t eh; |
3228 | s = get_to_st (eh); |
3258 | char *s = get_to_st (eh); |
3229 | if (s) |
3259 | if (s) |
3230 | free (s); |
3260 | free (s); |
3231 | |
3261 | |
3232 | return; |
3262 | return; |
3233 | } |
3263 | } |
… | |
… | |
3237 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3267 | * process OPERATING SYSTEM COMMAND sequence `ESC ] Ps ; Pt (ST|BEL)' |
3238 | */ |
3268 | */ |
3239 | void |
3269 | void |
3240 | rxvt_term::process_osc_seq () |
3270 | rxvt_term::process_osc_seq () |
3241 | { |
3271 | { |
3242 | unicode_t ch, eh; |
|
|
3243 | int arg; |
3272 | int arg; |
3244 | |
3273 | |
3245 | ch = cmd_getc (); |
3274 | unicode_t ch = cmd_getc (); |
3246 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3275 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3247 | arg = arg * 10 + (ch - '0'); |
3276 | arg = arg * 10 + (ch - '0'); |
3248 | |
3277 | |
3249 | if (ch == ';') |
3278 | if (ch == ';') |
3250 | { |
3279 | { |
|
|
3280 | unicode_t eh; |
3251 | char *s = get_to_st (eh); |
3281 | char *s = get_to_st (eh); |
3252 | |
3282 | |
3253 | if (s) |
3283 | if (s) |
3254 | { |
3284 | { |
3255 | process_xterm_seq (arg, s, eh); |
3285 | process_xterm_seq (arg, s, eh); |
… | |
… | |
3279 | |
3309 | |
3280 | /* |
3310 | /* |
3281 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3311 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3282 | */ |
3312 | */ |
3283 | void |
3313 | void |
3284 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3314 | rxvt_term::process_xterm_seq (int op, char *str, char resp) |
3285 | { |
3315 | { |
3286 | int color; |
3316 | int color; |
3287 | char *buf, *name; |
3317 | char *buf, *name; |
3288 | bool query = str[0] == '?' && !str[1]; |
3318 | bool query = str[0] == '?' && !str[1]; |
3289 | int saveop = op; |
3319 | int saveop = op; |
… | |
… | |
3316 | unsigned long bytes_after; |
3346 | unsigned long bytes_after; |
3317 | unsigned char *value = 0; |
3347 | unsigned char *value = 0; |
3318 | const char *str = ""; |
3348 | const char *str = ""; |
3319 | |
3349 | |
3320 | if (prop |
3350 | if (prop |
3321 | && XGetWindowProperty (dpy, parent[0], |
3351 | && XGetWindowProperty (dpy, parent, |
3322 | prop, 0, 1<<16, 0, AnyPropertyType, |
3352 | prop, 0, 1<<16, 0, AnyPropertyType, |
3323 | &actual_type, &actual_format, |
3353 | &actual_type, &actual_format, |
3324 | &nitems, &bytes_after, &value) == Success |
3354 | &nitems, &bytes_after, &value) == Success |
3325 | && actual_type != None |
3355 | && actual_type != None |
3326 | && actual_format == 8) |
3356 | && actual_format == 8) |
… | |
… | |
3330 | |
3360 | |
3331 | XFree (value); |
3361 | XFree (value); |
3332 | } |
3362 | } |
3333 | else |
3363 | else |
3334 | { |
3364 | { |
3335 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3365 | char *eq = strchr (str, '='); |
3336 | |
3366 | |
3337 | if (eq) |
3367 | if (eq) |
3338 | { |
3368 | { |
3339 | *eq = 0; |
3369 | *eq = 0; |
3340 | set_utf8_property (display->atom (str), eq + 1); |
3370 | set_utf8_property (display->atom (str), eq + 1); |
3341 | } |
3371 | } |
3342 | else |
3372 | else |
3343 | XDeleteProperty (dpy, parent[0], |
3373 | XDeleteProperty (dpy, parent, |
3344 | display->atom (str)); |
3374 | display->atom (str)); |
3345 | } |
3375 | } |
3346 | break; |
3376 | break; |
3347 | |
3377 | |
3348 | case XTerm_Color: |
3378 | case XTerm_Color: |
… | |
… | |
3380 | process_color_seq (op, Color_pointer_fg, str, resp); |
3410 | process_color_seq (op, Color_pointer_fg, str, resp); |
3381 | break; |
3411 | break; |
3382 | case XTerm_Color_pointer_bg: |
3412 | case XTerm_Color_pointer_bg: |
3383 | process_color_seq (op, Color_pointer_bg, str, resp); |
3413 | process_color_seq (op, Color_pointer_bg, str, resp); |
3384 | break; |
3414 | break; |
|
|
3415 | #ifdef OPTION_HC |
|
|
3416 | case XTerm_Color_HC: |
|
|
3417 | process_color_seq (op, Color_HC, str, resp); |
|
|
3418 | break; |
|
|
3419 | case XTerm_Color_HTC: |
|
|
3420 | process_color_seq (op, Color_HTC, str, resp); |
|
|
3421 | break; |
|
|
3422 | #endif |
3385 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3423 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3386 | case XTerm_Color_RV: |
|
|
3387 | process_color_seq (op, Color_RV, str, resp); |
|
|
3388 | break; |
|
|
3389 | case Rxvt_Color_BD: |
|
|
3390 | case URxvt_Color_BD: |
3424 | case URxvt_Color_BD: |
3391 | process_color_seq (op, Color_BD, str, resp); |
3425 | process_color_seq (op, Color_BD, str, resp); |
3392 | break; |
3426 | break; |
3393 | case Rxvt_Color_UL: |
|
|
3394 | case URxvt_Color_UL: |
3427 | case URxvt_Color_UL: |
3395 | process_color_seq (op, Color_UL, str, resp); |
3428 | process_color_seq (op, Color_UL, str, resp); |
3396 | break; |
3429 | break; |
3397 | case URxvt_Color_IT: |
3430 | case URxvt_Color_IT: |
3398 | process_color_seq (op, Color_IT, str, resp); |
3431 | process_color_seq (op, Color_IT, str, resp); |
3399 | break; |
3432 | break; |
3400 | #endif |
3433 | #endif |
|
|
3434 | case URxvt_Color_border: |
|
|
3435 | process_color_seq (op, Color_border, str, resp); |
|
|
3436 | break; |
3401 | #if ENABLE_TRANSPARENCY |
3437 | #if ENABLE_TRANSPARENCY |
3402 | case URxvt_Color_tint: |
3438 | case URxvt_Color_tint: |
3403 | process_color_seq (op, Color_tint, str, resp); |
3439 | process_color_seq (op, Color_tint, str, resp); |
3404 | { |
3440 | { |
3405 | bool changed = false; |
3441 | bool changed = false; |
3406 | |
3442 | |
3407 | if (ISSET_PIXCOLOR (Color_tint)) |
3443 | if (ISSET_PIXCOLOR (Color_tint)) |
3408 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
3444 | changed = bg_set_tint (pix_colors_focused [Color_tint]); |
3409 | else |
|
|
3410 | changed = bgPixmap.unset_tint (); |
|
|
3411 | |
3445 | |
3412 | if (changed) |
3446 | if (changed) |
3413 | update_background (); |
3447 | update_background (); |
3414 | } |
3448 | } |
3415 | |
3449 | |
… | |
… | |
3420 | case Rxvt_Pixmap: |
3454 | case Rxvt_Pixmap: |
3421 | if (!strcmp (str, "?")) |
3455 | if (!strcmp (str, "?")) |
3422 | { |
3456 | { |
3423 | char str[256]; |
3457 | char str[256]; |
3424 | |
3458 | |
3425 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3459 | sprintf (str, "[%dx%d+%d+%d]", |
3426 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3460 | min (h_scale, 32767), min (v_scale, 32767), |
3427 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
3461 | min (h_align, 32767), min (v_align, 32767)); |
3428 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3462 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3429 | } |
3463 | } |
3430 | else |
3464 | else |
3431 | { |
3465 | { |
3432 | int changed = 0; |
3466 | int changed = 0; |
3433 | |
3467 | |
3434 | if (*str != ';') |
3468 | if (*str != ';') |
3435 | { |
3469 | { |
3436 | /* reset to default scaling :*/ |
|
|
3437 | bgPixmap.unset_geometry (); |
|
|
3438 | if (bgPixmap.set_file (str)) /* change pixmap */ |
3470 | if (bg_set_file (str)) /* change pixmap */ |
|
|
3471 | { |
3439 | changed++; |
3472 | changed++; |
3440 | str = strchr (str, ';'); |
3473 | str = strchr (str, ';'); |
3441 | if (str == NULL) |
3474 | if (str == NULL) |
3442 | bgPixmap.set_defaultGeometry (); |
3475 | bg_set_default_geometry (); |
|
|
3476 | else |
|
|
3477 | bg_set_geometry (str+1); |
|
|
3478 | } |
3443 | } |
3479 | } |
3444 | |
3480 | else |
3445 | while (str) |
|
|
3446 | { |
3481 | { |
3447 | str++; |
3482 | str++; |
3448 | if (bgPixmap.set_geometry (str)) |
3483 | if (bg_set_geometry (str, true)) |
3449 | changed++; |
3484 | changed++; |
3450 | str = strchr (str, ';'); |
|
|
3451 | } |
3485 | } |
3452 | |
3486 | |
3453 | if (changed) |
3487 | if (changed) |
|
|
3488 | { |
|
|
3489 | if (bg_window_position_sensitive ()) |
|
|
3490 | { |
|
|
3491 | int x, y; |
|
|
3492 | get_window_origin (x, y); |
|
|
3493 | bg_set_position (x, y); |
|
|
3494 | } |
3454 | update_background (); |
3495 | update_background (); |
|
|
3496 | } |
3455 | } |
3497 | } |
3456 | break; |
3498 | break; |
3457 | #endif |
3499 | #endif |
3458 | |
3500 | |
3459 | case XTerm_logfile: |
3501 | case XTerm_logfile: |
… | |
… | |
3529 | break; |
3571 | break; |
3530 | #endif |
3572 | #endif |
3531 | |
3573 | |
3532 | #if ENABLE_PERL |
3574 | #if ENABLE_PERL |
3533 | case URxvt_perl: |
3575 | case URxvt_perl: |
3534 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
3576 | HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); |
3535 | ; // no responses yet |
|
|
3536 | break; |
3577 | break; |
3537 | #endif |
3578 | #endif |
3538 | } |
3579 | } |
3539 | } |
3580 | } |
3540 | /*----------------------------------------------------------------------*/ |
3581 | /*----------------------------------------------------------------------*/ |
… | |
… | |
3563 | { |
3604 | { |
3564 | if (mode == 'r') |
3605 | if (mode == 'r') |
3565 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3606 | state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ |
3566 | else |
3607 | else |
3567 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3608 | state = (mode == 't') ? ! (priv_modes & bit) : mode; |
3568 | PrivMode (state, bit); |
3609 | |
|
|
3610 | set_privmode (bit, state); |
3569 | } |
3611 | } |
3570 | |
3612 | |
3571 | return state; |
3613 | return state; |
3572 | } |
3614 | } |
3573 | |
3615 | |
… | |
… | |
3581 | static const struct |
3623 | static const struct |
3582 | { |
3624 | { |
3583 | const int argval; |
3625 | const int argval; |
3584 | const unsigned long bit; |
3626 | const unsigned long bit; |
3585 | } argtopriv[] = { |
3627 | } argtopriv[] = { |
3586 | { 1, PrivMode_aplCUR }, |
3628 | { 1, PrivMode_aplCUR }, // DECCKM |
3587 | { 2, PrivMode_vt52 }, |
3629 | { 2, PrivMode_vt52 }, |
3588 | { 3, PrivMode_132 }, |
3630 | { 3, PrivMode_132 }, // DECCOLM |
3589 | { 4, PrivMode_smoothScroll }, |
3631 | { 4, PrivMode_smoothScroll }, // DECSCLM |
3590 | { 5, PrivMode_rVideo }, |
3632 | { 5, PrivMode_rVideo }, // DECSCNM |
3591 | { 6, PrivMode_relOrigin }, |
3633 | { 6, PrivMode_relOrigin }, // DECOM |
3592 | { 7, PrivMode_Autowrap }, |
3634 | { 7, PrivMode_Autowrap }, // DECAWM |
3593 | // 8, bi-directional support mode |
3635 | // 8, auto-repeat keys // DECARM |
3594 | { 9, PrivMode_MouseX10 }, |
3636 | { 9, PrivMode_MouseX10 }, |
3595 | // 18, 19 printing-related |
3637 | // 18 end FF to printer after print screen |
|
|
3638 | // 19 Print screen prints full screen/scroll region |
3596 | { 25, PrivMode_VisibleCursor }, |
3639 | { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis |
3597 | #ifdef scrollBar_esc |
3640 | #ifdef scrollBar_esc |
3598 | { scrollBar_esc, PrivMode_scrollBar }, |
3641 | { scrollBar_esc, PrivMode_scrollBar }, |
3599 | #endif |
3642 | #endif |
3600 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3643 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
|
|
3644 | // 38, tektronix mode // DECTEK |
3601 | { 40, PrivMode_132OK }, |
3645 | { 40, PrivMode_132OK }, |
3602 | // 41 xterm more fixes NYI |
3646 | // 41 xterm more fixes NYI |
3603 | // 45 margin bell NYI |
3647 | // 45 margin bell NYI |
3604 | // 46 start logging |
3648 | // 46 start logging |
3605 | { 47, PrivMode_Screen }, |
3649 | { 47, PrivMode_Screen }, |
3606 | { 66, PrivMode_aplKP }, |
3650 | { 66, PrivMode_aplKP }, // DECPAM/DECPNM |
3607 | #ifndef NO_BACKSPACE_KEY |
3651 | #ifndef NO_BACKSPACE_KEY |
3608 | { 67, PrivMode_BackSpace }, |
3652 | { 67, PrivMode_BackSpace }, // DECBKM |
3609 | #endif |
3653 | #endif |
3610 | { 1000, PrivMode_MouseX11 }, |
3654 | { 1000, PrivMode_MouseX11 }, |
3611 | { 1002, PrivMode_MouseBtnEvent }, |
3655 | { 1002, PrivMode_MouseBtnEvent }, |
3612 | { 1003, PrivMode_MouseAnyEvent }, |
3656 | { 1003, PrivMode_MouseAnyEvent }, |
|
|
3657 | #if ENABLE_FRILLS |
|
|
3658 | { 1005, PrivMode_ExtModeMouse }, |
|
|
3659 | #endif |
3613 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3660 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3614 | { 1011, PrivMode_Keypress }, // rxvt extension |
3661 | { 1011, PrivMode_Keypress }, // rxvt extension |
|
|
3662 | #if ENABLE_FRILLS |
|
|
3663 | { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 |
|
|
3664 | #endif |
3615 | // 1035 enable modifiers for alt, numlock NYI |
3665 | // 1035 enable modifiers for alt, numlock NYI |
3616 | // 1036 send ESC for meta keys NYI |
3666 | // 1036 send ESC for meta keys NYI |
3617 | // 1037 send DEL for keypad delete NYI |
3667 | // 1037 send DEL for keypad delete NYI |
3618 | { 1047, PrivMode_Screen }, |
3668 | { 1047, PrivMode_Screen }, |
3619 | // 1048 save and restore cursor |
3669 | // 1048 save and restore cursor, implemented in code |
3620 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3670 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3621 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3671 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3622 | { 2004, PrivMode_BracketPaste }, |
3672 | { 2004, PrivMode_BracketPaste }, |
3623 | }; |
3673 | }; |
3624 | |
3674 | |
… | |
… | |
3634 | for (i = 0; i < nargs; i++) |
3684 | for (i = 0; i < nargs; i++) |
3635 | { |
3685 | { |
3636 | state = -1; |
3686 | state = -1; |
3637 | |
3687 | |
3638 | /* basic handling */ |
3688 | /* basic handling */ |
3639 | for (j = 0; j < (sizeof (argtopriv)/sizeof (argtopriv[0])); j++) |
3689 | for (j = 0; j < ARRAY_LENGTH(argtopriv); j++) |
3640 | if (argtopriv[j].argval == arg[i]) |
3690 | if (argtopriv[j].argval == arg[i]) |
3641 | { |
3691 | { |
3642 | state = privcases (mode, argtopriv[j].bit); |
3692 | state = privcases (mode, argtopriv[j].bit); |
3643 | break; |
3693 | break; |
3644 | } |
3694 | } |
… | |
… | |
3652 | |
3702 | |
3653 | scr_touch (true); |
3703 | scr_touch (true); |
3654 | break; |
3704 | break; |
3655 | #endif |
3705 | #endif |
3656 | case 1048: /* alternative cursor save */ |
3706 | case 1048: /* alternative cursor save */ |
3657 | case 1049: |
|
|
3658 | if (option (Opt_secondaryScreen)) |
3707 | if (option (Opt_secondaryScreen)) |
3659 | if (mode == 0) |
3708 | if (mode == 0) |
3660 | scr_cursor (RESTORE); |
3709 | scr_cursor (RESTORE); |
3661 | else if (mode == 1) |
3710 | else if (mode == 1) |
3662 | scr_cursor (SAVE); |
3711 | scr_cursor (SAVE); |
… | |
… | |
3671 | case 2: /* VT52 mode */ |
3720 | case 2: /* VT52 mode */ |
3672 | /* oddball mode. should be set regardless of set/reset |
3721 | /* oddball mode. should be set regardless of set/reset |
3673 | * parameter. Return from VT52 mode with an ESC < from |
3722 | * parameter. Return from VT52 mode with an ESC < from |
3674 | * within VT52 mode |
3723 | * within VT52 mode |
3675 | */ |
3724 | */ |
3676 | PrivMode (1, PrivMode_vt52); |
3725 | set_privmode (PrivMode_vt52, 1); |
3677 | break; |
3726 | break; |
3678 | case 3: /* 80/132 */ |
3727 | case 3: /* 80/132 */ |
3679 | if (priv_modes & PrivMode_132OK) |
3728 | if (priv_modes & PrivMode_132OK) |
3680 | { |
|
|
3681 | scr_poweron (); |
|
|
3682 | set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); |
3729 | set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); |
3683 | } |
|
|
3684 | break; |
3730 | break; |
3685 | case 4: /* smooth scrolling */ |
3731 | case 4: /* smooth scrolling */ |
3686 | set_option (Opt_jumpScroll, !state); |
3732 | set_option (Opt_jumpScroll, !state); |
3687 | break; |
3733 | break; |
3688 | case 5: /* reverse video */ |
3734 | case 5: /* reverse video */ |
… | |
… | |
3699 | if (state) /* orthogonal */ |
3745 | if (state) /* orthogonal */ |
3700 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
3746 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
3701 | break; |
3747 | break; |
3702 | #ifdef scrollBar_esc |
3748 | #ifdef scrollBar_esc |
3703 | case scrollBar_esc: |
3749 | case scrollBar_esc: |
3704 | if (scrollbar_mapping (state)) |
3750 | if (scrollBar.map (state)) |
3705 | { |
3751 | { |
3706 | resize_all_windows (0, 0, 0); |
3752 | resize_all_windows (0, 0, 0); |
3707 | scr_touch (true); |
3753 | scr_touch (true); |
3708 | } |
3754 | } |
3709 | break; |
3755 | break; |
… | |
… | |
3726 | case 1003: |
3772 | case 1003: |
3727 | if (state) |
3773 | if (state) |
3728 | { |
3774 | { |
3729 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
3775 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
3730 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
3776 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3777 | mouse_row = mouse_col = 0; |
3731 | vt_emask_mouse = PointerMotionMask; |
3778 | vt_emask_mouse = PointerMotionMask; |
3732 | } |
3779 | } |
3733 | else |
3780 | else |
3734 | vt_emask_mouse = NoEventMask; |
3781 | vt_emask_mouse = NoEventMask; |
|
|
3782 | |
3735 | vt_select_input (); |
3783 | vt_select_input (); |
3736 | break; |
3784 | break; |
3737 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3785 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3738 | set_option (Opt_scrollTtyOutput, !state); |
3786 | set_option (Opt_scrollTtyOutput, !state); |
3739 | break; |
3787 | break; |
3740 | case 1011: /* scroll to bottom on key press */ |
3788 | case 1011: /* scroll to bottom on key press */ |
3741 | set_option (Opt_scrollTtyKeypress, state); |
3789 | set_option (Opt_scrollTtyKeypress, state); |
3742 | break; |
3790 | break; |
3743 | case 1047: /* secondary screen w/ clearing last */ |
3791 | case 1047: /* secondary screen w/ clearing last */ |
3744 | if (option (Opt_secondaryScreen)) |
3792 | if (option (Opt_secondaryScreen)) |
3745 | if (current_screen != PRIMARY) |
3793 | if (!state) |
3746 | scr_erase_screen (2); |
3794 | scr_erase_screen (2); |
|
|
3795 | |
3747 | scr_change_screen (state); |
3796 | scr_change_screen (state); |
3748 | break; |
3797 | break; |
3749 | case 1049: /* secondary screen w/ clearing first */ |
3798 | case 1049: /* secondary screen w/ clearing first */ |
|
|
3799 | if (option (Opt_secondaryScreen)) |
|
|
3800 | if (state) |
|
|
3801 | scr_cursor (SAVE); |
|
|
3802 | |
3750 | scr_change_screen (state); |
3803 | scr_change_screen (state); |
|
|
3804 | |
3751 | if (option (Opt_secondaryScreen)) |
3805 | if (option (Opt_secondaryScreen)) |
3752 | if (current_screen != PRIMARY) |
3806 | if (state) |
3753 | scr_erase_screen (2); |
3807 | scr_erase_screen (2); |
|
|
3808 | else |
|
|
3809 | scr_cursor (RESTORE); |
3754 | break; |
3810 | break; |
3755 | default: |
3811 | default: |
3756 | break; |
3812 | break; |
3757 | } |
3813 | } |
3758 | } |
3814 | } |
… | |
… | |
3911 | } |
3967 | } |
3912 | } |
3968 | } |
3913 | } |
3969 | } |
3914 | /*}}} */ |
3970 | /*}}} */ |
3915 | |
3971 | |
3916 | /*{{{ (do not) process Rob Nation's own graphics mode sequences */ |
|
|
3917 | void |
|
|
3918 | rxvt_term::process_graphics () |
|
|
3919 | { |
|
|
3920 | unicode_t ch, cmd = cmd_getc (); |
|
|
3921 | |
|
|
3922 | if (cmd == 'Q') |
|
|
3923 | { |
|
|
3924 | /* query graphics */ |
|
|
3925 | tt_printf ("\033G0\012"); /* no graphics */ |
|
|
3926 | return; |
|
|
3927 | } |
|
|
3928 | /* swallow other graphics sequences until terminating ':' */ |
|
|
3929 | do |
|
|
3930 | ch = cmd_getc (); |
|
|
3931 | while (ch != ':'); |
|
|
3932 | } |
|
|
3933 | /*}}} */ |
|
|
3934 | |
|
|
3935 | /* ------------------------------------------------------------------------- */ |
3972 | /* ------------------------------------------------------------------------- */ |
3936 | |
3973 | |
3937 | /* |
3974 | /* |
3938 | * Send printf () formatted output to the command. |
3975 | * Send printf () formatted output to the command. |
3939 | * Only use for small amounts of data. |
3976 | * Only use for small amounts of data. |
… | |
… | |
3952 | |
3989 | |
3953 | /* ---------------------------------------------------------------------- */ |
3990 | /* ---------------------------------------------------------------------- */ |
3954 | /* Write data to the pty as typed by the user, pasted with the mouse, |
3991 | /* Write data to the pty as typed by the user, pasted with the mouse, |
3955 | * or generated by us in response to a query ESC sequence. |
3992 | * or generated by us in response to a query ESC sequence. |
3956 | */ |
3993 | */ |
3957 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
3994 | static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
3958 | |
3995 | |
3959 | void |
3996 | void |
3960 | rxvt_term::tt_write (const char *data, unsigned int len) |
3997 | rxvt_term::tt_write (const char *data, unsigned int len) |
3961 | { |
3998 | { |
3962 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
3999 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
… | |
… | |
3967 | |
4004 | |
3968 | if (v_buflen == 0) |
4005 | if (v_buflen == 0) |
3969 | { |
4006 | { |
3970 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4007 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
3971 | |
4008 | |
|
|
4009 | max_it (written, 0); |
|
|
4010 | |
3972 | if ((unsigned int)written == len) |
4011 | if (written == len) |
3973 | return; |
4012 | return; |
3974 | |
4013 | |
3975 | data += written; |
4014 | data += written; |
3976 | len -= written; |
4015 | len -= written; |
3977 | } |
4016 | } |
3978 | |
4017 | |
3979 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4018 | v_buffer = (char *)rxvt_realloc (v_buffer, v_buflen + len); |
3980 | |
4019 | |
3981 | memcpy (v_buffer + v_buflen, data, len); |
4020 | memcpy (v_buffer + v_buflen, data, len); |
3982 | v_buflen += len; |
4021 | v_buflen += len; |
3983 | |
4022 | |
3984 | pty_ev.set (ev::READ | ev::WRITE); |
4023 | pty_ev.set (ev::READ | ev::WRITE); |