ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.418 by root, Fri Oct 10 00:11:44 2008 UTC vs.
Revision 1.435 by sf-exg, Wed Jan 6 12:10:44 2010 UTC

579 } 579 }
580 } 580 }
581 581
582#if ENABLE_FRILLS || ISO_14755 582#if ENABLE_FRILLS || ISO_14755
583 // ISO 14755 support 583 // ISO 14755 support
584 if (shft && ctrl) 584 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51))
585 { 585 {
586 int hv; 586 int hv;
587 587
588 if (iso14755buf & ISO_14755_51 588 if (iso14755buf & ISO_14755_51
589 && (keysym == XK_space || keysym == XK_KP_Space 589 && (keysym == XK_space || keysym == XK_KP_Space
619 scr_overlay_off (); 619 scr_overlay_off ();
620# endif 620# endif
621 iso14755buf = 0; 621 iso14755buf = 0;
622 } 622 }
623 } 623 }
624 else if (option (Opt_iso14755) &&
624 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 625 ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
625 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 626 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))))
626 if (!(iso14755buf & ISO_14755_STARTED)) 627 if (!(iso14755buf & ISO_14755_STARTED))
627 { 628 {
628 iso14755buf |= ISO_14755_STARTED; 629 iso14755buf |= ISO_14755_STARTED;
629# if ISO_14755 630# if ISO_14755
630 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 631 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
1127 { 1128 {
1128 // this should really be sched_yield(), but the linux guys thought 1129 // this should really be sched_yield(), but the linux guys thought
1129 // that giving a process calling sched_yield () less cpu time than 1130 // that giving a process calling sched_yield () less cpu time than
1130 // ones with high nice levels is a useful thing to do. It surely is is 1131 // ones with high nice levels is a useful thing to do. It surely is is
1131 // allowed by the sus... as is returning ENOSYS. 1132 // allowed by the sus... as is returning ENOSYS.
1133 // since the linux guys additionally thought that breaking the only
1134 // known workaroudn against their unusable sched_yield hack is cool,
1135 // we just nanosleep a bit and hope for the best.
1132 1136
1133 struct timespec ts = { 0, 0 }; 1137 struct timespec ts = { 0, 1000 };
1134 nanosleep (&ts, 0); 1138 nanosleep (&ts, 0);
1135 1139
1136 w.stop (); 1140 w.stop ();
1137 } 1141 }
1138 1142
1188{ 1192{
1189 make_current (); 1193 make_current ();
1190 1194
1191 if (revents & ev::READ) 1195 if (revents & ev::READ)
1192 // loop, but don't allow a single term to monopolize us 1196 // loop, but don't allow a single term to monopolize us
1193 while (pty_fill ()) 1197 for (int i = CBUFCNT; i-- && pty_fill (); )
1194 if (cmd_parse ()) 1198 cmd_parse ();
1195 break;
1196 1199
1197 if (revents & ev::WRITE) 1200 if (revents & ev::WRITE)
1198 pty_write (); 1201 pty_write ();
1199 1202
1200 refresh_check (); 1203 refresh_check ();
1682#endif 1685#endif
1683 1686
1684 refresh_check (); 1687 refresh_check ();
1685} 1688}
1686 1689
1690#if ENABLE_FRILLS
1691void
1692rxvt_term::set_urgency (bool enable)
1693{
1694 if (enable == urgency_hint)
1695 return;
1696
1697 if (XWMHints *h = XGetWMHints (dpy, parent[0]))
1698 {
1699 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1700 XSetWMHints (dpy, parent[0], h);
1701 urgency_hint = enable;
1702 }
1703}
1704#endif
1705
1687void 1706void
1688rxvt_term::focus_in () 1707rxvt_term::focus_in ()
1689{ 1708{
1690 if (!focus) 1709 if (!focus)
1691 { 1710 {
1692 focus = 1; 1711 focus = 1;
1693 want_refresh = 1; 1712 want_refresh = 1;
1694
1695 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1696 1713
1697#if USE_XIM 1714#if USE_XIM
1698 if (Input_Context != NULL) 1715 if (Input_Context != NULL)
1699 { 1716 {
1700 IMSetPosition (); 1717 IMSetPosition ();
1712 scr_recolour (); 1729 scr_recolour ();
1713 } 1730 }
1714#endif 1731#endif
1715#if ENABLE_FRILLS 1732#if ENABLE_FRILLS
1716 if (option (Opt_urgentOnBell)) 1733 if (option (Opt_urgentOnBell))
1717 { 1734 set_urgency (0);
1718 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1719 {
1720 h->flags &= ~XUrgencyHint;
1721 XSetWMHints (dpy, parent[0], h);
1722 }
1723 }
1724#endif 1735#endif
1736
1737 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1725 } 1738 }
1726} 1739}
1727 1740
1728void 1741void
1729rxvt_term::focus_out () 1742rxvt_term::focus_out ()
1731 if (focus) 1744 if (focus)
1732 { 1745 {
1733 focus = 0; 1746 focus = 0;
1734 want_refresh = 1; 1747 want_refresh = 1;
1735 1748
1736 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1749#if ENABLE_FRILLS
1737 1750 if (option (Opt_urgentOnBell))
1751 set_urgency (0);
1752#endif
1738#if ENABLE_FRILLS || ISO_14755 1753#if ENABLE_FRILLS || ISO_14755
1739 if (iso14755buf) 1754 if (iso14755buf)
1740 { 1755 {
1741 iso14755buf = 0; 1756 iso14755buf = 0;
1742# if ISO_14755 1757# if ISO_14755
1759 { 1774 {
1760 pix_colors = pix_colors_unfocused; 1775 pix_colors = pix_colors_unfocused;
1761 scr_recolour (); 1776 scr_recolour ();
1762 } 1777 }
1763#endif 1778#endif
1779
1780 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1764 } 1781 }
1765} 1782}
1766 1783
1767void 1784void
1768rxvt_term::update_fade_color (unsigned int idx) 1785rxvt_term::update_fade_color (unsigned int idx)
2170 } 2187 }
2171} 2188}
2172 2189
2173/*}}} */ 2190/*}}} */
2174 2191
2175bool 2192void
2176rxvt_term::cmd_parse () 2193rxvt_term::cmd_parse ()
2177{ 2194{
2178 bool flag = false;
2179 wchar_t ch = NOCHAR; 2195 wchar_t ch = NOCHAR;
2180 char *seq_begin; // remember start of esc-sequence here 2196 char *seq_begin; // remember start of esc-sequence here
2181 2197
2182 for (;;) 2198 for (;;)
2183 { 2199 {
2277 * What the heck we'll cheat and only refresh less than every page-full. 2293 * What the heck we'll cheat and only refresh less than every page-full.
2278 * if skipScroll is enabled. 2294 * if skipScroll is enabled.
2279 */ 2295 */
2280 if (refreshnow) 2296 if (refreshnow)
2281 { 2297 {
2282 flag = true;
2283 scr_refresh (); 2298 scr_refresh ();
2284 want_refresh = 1; 2299 want_refresh = 1;
2285 } 2300 }
2286
2287 } 2301 }
2288 else 2302 else
2289 { 2303 {
2290 try 2304 try
2291 { 2305 {
2299 } 2313 }
2300 2314
2301 ch = NOCHAR; 2315 ch = NOCHAR;
2302 } 2316 }
2303 } 2317 }
2304
2305 return flag;
2306} 2318}
2307 2319
2308// read the next character 2320// read the next character
2309wchar_t 2321wchar_t
2310rxvt_term::next_char () NOTHROW 2322rxvt_term::next_char () NOTHROW
2325 break; 2337 break;
2326 } 2338 }
2327 2339
2328 if (len == (size_t)-1) 2340 if (len == (size_t)-1)
2329 { 2341 {
2330 mbrtowc (0, 0, 0, mbstate); // reset now undefined conversion state 2342 mbstate.reset (); // reset now undefined conversion state
2331 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2343 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2332 } 2344 }
2333 2345
2334 // assume wchar == unicode 2346 // assume wchar == unicode
2335 cmdbuf_ptr += len; 2347 cmdbuf_ptr += len;
2679 /* 8.3.110: SINGLE CHARACTER INTRODUCER */ 2691 /* 8.3.110: SINGLE CHARACTER INTRODUCER */
2680 case C1_SCI: /* ESC Z */ 2692 case C1_SCI: /* ESC Z */
2681 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); 2693 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1);
2682 break; /* steal obsolete ESC [ c */ 2694 break; /* steal obsolete ESC [ c */
2683 2695
2684 /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ 2696 /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */
2685 case C1_CSI: /* ESC [ */ 2697 case C1_CSI: /* ESC [ */
2686 process_csi_seq (); 2698 process_csi_seq ();
2687 break; 2699 break;
2688 2700
2689 /* 8.3.90: OPERATING SYSTEM COMMAND */ 2701 /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */
2690 case C1_OSC: /* ESC ] */ 2702 case C1_OSC: /* ESC ] */
2691 process_osc_seq (); 2703 process_osc_seq ();
2692 break; 2704 break;
2693 2705
2694 /* 8.3.106: RESET TO INITIAL STATE */ 2706 /* 8.3.106: RESET TO INITIAL STATE (RIS) */
2695 case 'c': 2707 case 'c':
2696 mbstate.reset (); 2708 mbstate.reset ();
2697 scr_poweron (); 2709 scr_poweron ();
2698 scrollBar.show (1); 2710 scrollBar.show (1);
2699 break; 2711 break;
2754 2766
2755 nargs = 0; 2767 nargs = 0;
2756 2768
2757 priv = 0; 2769 priv = 0;
2758 ch = cmd_getc (); 2770 ch = cmd_getc ();
2759 if (ch >= '<' && ch <= '?') 2771 if ((ch >= '<' && ch <= '?') || ch == '!')
2760 { 2772 {
2761 /* '<' '=' '>' '?' */ 2773 /* '<' '=' '>' '?' '!' */
2762 priv = ch; 2774 priv = ch;
2763 ch = cmd_getc (); 2775 ch = cmd_getc ();
2764 } 2776 }
2765 2777
2766 /* read any numerical arguments */ 2778 /* read any numerical arguments */
2820 2832
2821 case '?': 2833 case '?':
2822 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2834 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
2823 process_terminal_mode (ch, priv, nargs, arg); 2835 process_terminal_mode (ch, priv, nargs, arg);
2824 break; 2836 break;
2837
2838 case '!':
2839 if (ch == CSI_70)
2840 {
2841 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */
2842 scr_soft_reset ();
2843
2844 static const int pm_h[] = { 7, 25 };
2845 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 };
2846
2847 process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h);
2848 process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l);
2825 } 2849 }
2850 break;
2851 }
2852
2826 return; 2853 return;
2827 } 2854 }
2828 2855
2829 switch (ch) 2856 switch (ch)
2830 { 2857 {
3259 3286
3260/* 3287/*
3261 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3288 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3262 */ 3289 */
3263void 3290void
3264rxvt_term::process_xterm_seq (int op, const char *str, char resp) 3291rxvt_term::process_xterm_seq (int op, char *str, char resp)
3265{ 3292{
3266 int color; 3293 int color;
3267 char *buf, *name; 3294 char *buf, *name;
3268 bool query = str[0] == '?' && !str[1]; 3295 bool query = str[0] == '?' && !str[1];
3269 int saveop = op; 3296 int saveop = op;
3272 3299
3273 assert (str != NULL); 3300 assert (str != NULL);
3274 3301
3275 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) 3302 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3276 return; 3303 return;
3277 fprintf (stderr, "op %d<%s>\n", op, str);//D
3278 3304
3279 switch (op) 3305 switch (op)
3280 { 3306 {
3281 case XTerm_name: 3307 case XTerm_name:
3282 set_title (str); 3308 set_title (str);
3311 3337
3312 XFree (value); 3338 XFree (value);
3313 } 3339 }
3314 else 3340 else
3315 { 3341 {
3316 char *eq = strchr (str, '='); // constness lost, but verified to be ok 3342 char *eq = strchr (str, '=');
3317 3343
3318 if (eq) 3344 if (eq)
3319 { 3345 {
3320 *eq = 0; 3346 *eq = 0;
3321 set_utf8_property (display->atom (str), eq + 1); 3347 set_utf8_property (display->atom (str), eq + 1);
3377 break; 3403 break;
3378 case URxvt_Color_IT: 3404 case URxvt_Color_IT:
3379 process_color_seq (op, Color_IT, str, resp); 3405 process_color_seq (op, Color_IT, str, resp);
3380 break; 3406 break;
3381#endif 3407#endif
3408 case URxvt_Color_border:
3409 process_color_seq (op, Color_border, str, resp);
3410 break;
3382#if ENABLE_TRANSPARENCY 3411#if ENABLE_TRANSPARENCY
3383 case URxvt_Color_tint: 3412 case URxvt_Color_tint:
3384 process_color_seq (op, Color_tint, str, resp); 3413 process_color_seq (op, Color_tint, str, resp);
3385 { 3414 {
3386 bool changed = false; 3415 bool changed = false;
3561 static const struct 3590 static const struct
3562 { 3591 {
3563 const int argval; 3592 const int argval;
3564 const unsigned long bit; 3593 const unsigned long bit;
3565 } argtopriv[] = { 3594 } argtopriv[] = {
3566 { 1, PrivMode_aplCUR }, 3595 { 1, PrivMode_aplCUR }, // DECCKM
3567 { 2, PrivMode_vt52 }, 3596 { 2, PrivMode_vt52 },
3568 { 3, PrivMode_132 }, 3597 { 3, PrivMode_132 }, // DECCOLM
3569 { 4, PrivMode_smoothScroll }, 3598 { 4, PrivMode_smoothScroll }, // DECSCLM
3570 { 5, PrivMode_rVideo }, 3599 { 5, PrivMode_rVideo }, // DECSCNM
3571 { 6, PrivMode_relOrigin }, 3600 { 6, PrivMode_relOrigin }, // DECOM
3572 { 7, PrivMode_Autowrap }, 3601 { 7, PrivMode_Autowrap }, // DECAWM
3573 // 8, bi-directional support mode 3602 // 8, auto-repeat keys // DECARM
3574 { 9, PrivMode_MouseX10 }, 3603 { 9, PrivMode_MouseX10 },
3575 // 18, 19 printing-related 3604 // 18 end FF to printer after print screen
3605 // 19 Print screen prints full screen/scorll region
3576 { 25, PrivMode_VisibleCursor }, 3606 { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis
3577#ifdef scrollBar_esc 3607#ifdef scrollBar_esc
3578 { scrollBar_esc, PrivMode_scrollBar }, 3608 { scrollBar_esc, PrivMode_scrollBar },
3579#endif 3609#endif
3580 { 35, PrivMode_ShiftKeys }, // rxvt extension 3610 { 35, PrivMode_ShiftKeys }, // rxvt extension
3611 // 38, tektronix mode // DECTEK
3581 { 40, PrivMode_132OK }, 3612 { 40, PrivMode_132OK },
3582 // 41 xterm more fixes NYI 3613 // 41 xterm more fixes NYI
3583 // 45 margin bell NYI 3614 // 45 margin bell NYI
3584 // 46 start logging 3615 // 46 start logging
3585 { 47, PrivMode_Screen }, 3616 { 47, PrivMode_Screen },
3586 { 66, PrivMode_aplKP }, 3617 { 66, PrivMode_aplKP }, // DECPAM/DECPNM
3587#ifndef NO_BACKSPACE_KEY 3618#ifndef NO_BACKSPACE_KEY
3588 { 67, PrivMode_BackSpace }, 3619 { 67, PrivMode_BackSpace }, // DECBKM
3589#endif 3620#endif
3590 { 1000, PrivMode_MouseX11 }, 3621 { 1000, PrivMode_MouseX11 },
3591 { 1002, PrivMode_MouseBtnEvent }, 3622 { 1002, PrivMode_MouseBtnEvent },
3592 { 1003, PrivMode_MouseAnyEvent }, 3623 { 1003, PrivMode_MouseAnyEvent },
3593 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3624 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3632 3663
3633 scr_touch (true); 3664 scr_touch (true);
3634 break; 3665 break;
3635#endif 3666#endif
3636 case 1048: /* alternative cursor save */ 3667 case 1048: /* alternative cursor save */
3637 case 1049:
3638 if (option (Opt_secondaryScreen)) 3668 if (option (Opt_secondaryScreen))
3639 if (mode == 0) 3669 if (mode == 0)
3640 scr_cursor (RESTORE); 3670 scr_cursor (RESTORE);
3641 else if (mode == 1) 3671 else if (mode == 1)
3642 scr_cursor (SAVE); 3672 scr_cursor (SAVE);
3655 */ 3685 */
3656 set_privmode (PrivMode_vt52, 1); 3686 set_privmode (PrivMode_vt52, 1);
3657 break; 3687 break;
3658 case 3: /* 80/132 */ 3688 case 3: /* 80/132 */
3659 if (priv_modes & PrivMode_132OK) 3689 if (priv_modes & PrivMode_132OK)
3660 {
3661 scr_poweron ();
3662 set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); 3690 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight);
3663 }
3664 break; 3691 break;
3665 case 4: /* smooth scrolling */ 3692 case 4: /* smooth scrolling */
3666 set_option (Opt_jumpScroll, !state); 3693 set_option (Opt_jumpScroll, !state);
3667 break; 3694 break;
3668 case 5: /* reverse video */ 3695 case 5: /* reverse video */
3710 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; 3737 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3711 vt_emask_mouse = PointerMotionMask; 3738 vt_emask_mouse = PointerMotionMask;
3712 } 3739 }
3713 else 3740 else
3714 vt_emask_mouse = NoEventMask; 3741 vt_emask_mouse = NoEventMask;
3742
3715 vt_select_input (); 3743 vt_select_input ();
3716 break; 3744 break;
3717 case 1010: /* scroll to bottom on TTY output inhibit */ 3745 case 1010: /* scroll to bottom on TTY output inhibit */
3718 set_option (Opt_scrollTtyOutput, !state); 3746 set_option (Opt_scrollTtyOutput, !state);
3719 break; 3747 break;
3720 case 1011: /* scroll to bottom on key press */ 3748 case 1011: /* scroll to bottom on key press */
3721 set_option (Opt_scrollTtyKeypress, state); 3749 set_option (Opt_scrollTtyKeypress, state);
3722 break; 3750 break;
3723 case 1047: /* secondary screen w/ clearing last */ 3751 case 1047: /* secondary screen w/ clearing last */
3724 if (option (Opt_secondaryScreen)) 3752 if (option (Opt_secondaryScreen))
3725 if (current_screen != PRIMARY) 3753 if (!state)
3726 scr_erase_screen (2); 3754 scr_erase_screen (2);
3755
3727 scr_change_screen (state); 3756 scr_change_screen (state);
3728 break; 3757 break;
3729 case 1049: /* secondary screen w/ clearing first */ 3758 case 1049: /* secondary screen w/ clearing first */
3759 if (option (Opt_secondaryScreen))
3760 if (state)
3761 scr_cursor (SAVE);
3762
3730 scr_change_screen (state); 3763 scr_change_screen (state);
3764
3731 if (option (Opt_secondaryScreen)) 3765 if (option (Opt_secondaryScreen))
3732 if (current_screen != PRIMARY) 3766 if (state)
3733 scr_erase_screen (2); 3767 scr_erase_screen (2);
3768 else
3769 scr_cursor (RESTORE);
3734 break; 3770 break;
3735 default: 3771 default:
3736 break; 3772 break;
3737 } 3773 }
3738 } 3774 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines