… | |
… | |
1127 | { |
1127 | { |
1128 | // this should really be sched_yield(), but the linux guys thought |
1128 | // this should really be sched_yield(), but the linux guys thought |
1129 | // that giving a process calling sched_yield () less cpu time than |
1129 | // 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 |
1130 | // ones with high nice levels is a useful thing to do. It surely is is |
1131 | // allowed by the sus... as is returning ENOSYS. |
1131 | // allowed by the sus... as is returning ENOSYS. |
|
|
1132 | // since the linux guys additionally thought that breaking the only |
|
|
1133 | // known workaroudn against their unusable sched_yield hack is cool, |
|
|
1134 | // we just nanosleep a bit and hope for the best. |
1132 | |
1135 | |
1133 | struct timespec ts = { 0, 0 }; |
1136 | struct timespec ts = { 0, 1000 }; |
1134 | nanosleep (&ts, 0); |
1137 | nanosleep (&ts, 0); |
1135 | |
1138 | |
1136 | w.stop (); |
1139 | w.stop (); |
1137 | } |
1140 | } |
1138 | |
1141 | |
… | |
… | |
1188 | { |
1191 | { |
1189 | make_current (); |
1192 | make_current (); |
1190 | |
1193 | |
1191 | if (revents & ev::READ) |
1194 | if (revents & ev::READ) |
1192 | // loop, but don't allow a single term to monopolize us |
1195 | // loop, but don't allow a single term to monopolize us |
1193 | while (pty_fill ()) |
1196 | for (int i = CBUFCNT; i-- && pty_fill (); ) |
1194 | if (cmd_parse ()) |
1197 | cmd_parse (); |
1195 | break; |
|
|
1196 | |
1198 | |
1197 | if (revents & ev::WRITE) |
1199 | if (revents & ev::WRITE) |
1198 | pty_write (); |
1200 | pty_write (); |
1199 | |
1201 | |
1200 | refresh_check (); |
1202 | refresh_check (); |
… | |
… | |
1682 | #endif |
1684 | #endif |
1683 | |
1685 | |
1684 | refresh_check (); |
1686 | refresh_check (); |
1685 | } |
1687 | } |
1686 | |
1688 | |
|
|
1689 | #if ENABLE_FRILLS |
1687 | void |
1690 | void |
1688 | rxvt_term::set_urgency (bool enable) |
1691 | rxvt_term::set_urgency (bool enable) |
1689 | { |
1692 | { |
1690 | if (enable == urgency_hint) |
1693 | if (enable == urgency_hint) |
1691 | return; |
1694 | return; |
… | |
… | |
1695 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
1698 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
1696 | XSetWMHints (dpy, parent[0], h); |
1699 | XSetWMHints (dpy, parent[0], h); |
1697 | urgency_hint = enable; |
1700 | urgency_hint = enable; |
1698 | } |
1701 | } |
1699 | } |
1702 | } |
|
|
1703 | #endif |
1700 | |
1704 | |
1701 | void |
1705 | void |
1702 | rxvt_term::focus_in () |
1706 | rxvt_term::focus_in () |
1703 | { |
1707 | { |
1704 | if (!focus) |
1708 | if (!focus) |
… | |
… | |
2182 | } |
2186 | } |
2183 | } |
2187 | } |
2184 | |
2188 | |
2185 | /*}}} */ |
2189 | /*}}} */ |
2186 | |
2190 | |
2187 | bool |
2191 | void |
2188 | rxvt_term::cmd_parse () |
2192 | rxvt_term::cmd_parse () |
2189 | { |
2193 | { |
2190 | bool flag = false; |
|
|
2191 | wchar_t ch = NOCHAR; |
2194 | wchar_t ch = NOCHAR; |
2192 | char *seq_begin; // remember start of esc-sequence here |
2195 | char *seq_begin; // remember start of esc-sequence here |
2193 | |
2196 | |
2194 | for (;;) |
2197 | for (;;) |
2195 | { |
2198 | { |
… | |
… | |
2289 | * What the heck we'll cheat and only refresh less than every page-full. |
2292 | * What the heck we'll cheat and only refresh less than every page-full. |
2290 | * if skipScroll is enabled. |
2293 | * if skipScroll is enabled. |
2291 | */ |
2294 | */ |
2292 | if (refreshnow) |
2295 | if (refreshnow) |
2293 | { |
2296 | { |
2294 | flag = true; |
|
|
2295 | scr_refresh (); |
2297 | scr_refresh (); |
2296 | want_refresh = 1; |
2298 | want_refresh = 1; |
2297 | } |
2299 | } |
2298 | |
|
|
2299 | } |
2300 | } |
2300 | else |
2301 | else |
2301 | { |
2302 | { |
2302 | try |
2303 | try |
2303 | { |
2304 | { |
… | |
… | |
2311 | } |
2312 | } |
2312 | |
2313 | |
2313 | ch = NOCHAR; |
2314 | ch = NOCHAR; |
2314 | } |
2315 | } |
2315 | } |
2316 | } |
2316 | |
|
|
2317 | return flag; |
|
|
2318 | } |
2317 | } |
2319 | |
2318 | |
2320 | // read the next character |
2319 | // read the next character |
2321 | wchar_t |
2320 | wchar_t |
2322 | rxvt_term::next_char () NOTHROW |
2321 | rxvt_term::next_char () NOTHROW |
… | |
… | |
2337 | break; |
2336 | break; |
2338 | } |
2337 | } |
2339 | |
2338 | |
2340 | if (len == (size_t)-1) |
2339 | if (len == (size_t)-1) |
2341 | { |
2340 | { |
2342 | mbrtowc (0, 0, 0, mbstate); // reset now undefined conversion state |
2341 | mbstate.reset (); // reset now undefined conversion state |
2343 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2342 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2344 | } |
2343 | } |
2345 | |
2344 | |
2346 | // assume wchar == unicode |
2345 | // assume wchar == unicode |
2347 | cmdbuf_ptr += len; |
2346 | cmdbuf_ptr += len; |
… | |
… | |
2691 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2690 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2692 | case C1_SCI: /* ESC Z */ |
2691 | case C1_SCI: /* ESC Z */ |
2693 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2692 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2694 | break; /* steal obsolete ESC [ c */ |
2693 | break; /* steal obsolete ESC [ c */ |
2695 | |
2694 | |
2696 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2695 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */ |
2697 | case C1_CSI: /* ESC [ */ |
2696 | case C1_CSI: /* ESC [ */ |
2698 | process_csi_seq (); |
2697 | process_csi_seq (); |
2699 | break; |
2698 | break; |
2700 | |
2699 | |
2701 | /* 8.3.90: OPERATING SYSTEM COMMAND */ |
2700 | /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */ |
2702 | case C1_OSC: /* ESC ] */ |
2701 | case C1_OSC: /* ESC ] */ |
2703 | process_osc_seq (); |
2702 | process_osc_seq (); |
2704 | break; |
2703 | break; |
2705 | |
2704 | |
2706 | /* 8.3.106: RESET TO INITIAL STATE */ |
2705 | /* 8.3.106: RESET TO INITIAL STATE (RIS) */ |
2707 | case 'c': |
2706 | case 'c': |
2708 | mbstate.reset (); |
2707 | mbstate.reset (); |
2709 | scr_poweron (); |
2708 | scr_poweron (); |
2710 | scrollBar.show (1); |
2709 | scrollBar.show (1); |
2711 | break; |
2710 | break; |
… | |
… | |
2766 | |
2765 | |
2767 | nargs = 0; |
2766 | nargs = 0; |
2768 | |
2767 | |
2769 | priv = 0; |
2768 | priv = 0; |
2770 | ch = cmd_getc (); |
2769 | ch = cmd_getc (); |
2771 | if (ch >= '<' && ch <= '?') |
2770 | if ((ch >= '<' && ch <= '?') || ch == '!') |
2772 | { |
2771 | { |
2773 | /* '<' '=' '>' '?' */ |
2772 | /* '<' '=' '>' '?' '!' */ |
2774 | priv = ch; |
2773 | priv = ch; |
2775 | ch = cmd_getc (); |
2774 | ch = cmd_getc (); |
2776 | } |
2775 | } |
2777 | |
2776 | |
2778 | /* read any numerical arguments */ |
2777 | /* read any numerical arguments */ |
… | |
… | |
2832 | |
2831 | |
2833 | case '?': |
2832 | case '?': |
2834 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2833 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2835 | process_terminal_mode (ch, priv, nargs, arg); |
2834 | process_terminal_mode (ch, priv, nargs, arg); |
2836 | break; |
2835 | break; |
|
|
2836 | |
|
|
2837 | case '!': |
|
|
2838 | if (ch == CSI_70) |
|
|
2839 | { |
|
|
2840 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
|
|
2841 | scr_soft_reset (); |
|
|
2842 | |
|
|
2843 | static const int pm_h[] = { 7, 25 }; |
|
|
2844 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 }; |
|
|
2845 | |
|
|
2846 | process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h); |
|
|
2847 | process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l); |
2837 | } |
2848 | } |
|
|
2849 | break; |
|
|
2850 | } |
|
|
2851 | |
2838 | return; |
2852 | return; |
2839 | } |
2853 | } |
2840 | |
2854 | |
2841 | switch (ch) |
2855 | switch (ch) |
2842 | { |
2856 | { |
… | |
… | |
3271 | |
3285 | |
3272 | /* |
3286 | /* |
3273 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3287 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3274 | */ |
3288 | */ |
3275 | void |
3289 | void |
3276 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3290 | rxvt_term::process_xterm_seq (int op, char *str, char resp) |
3277 | { |
3291 | { |
3278 | int color; |
3292 | int color; |
3279 | char *buf, *name; |
3293 | char *buf, *name; |
3280 | bool query = str[0] == '?' && !str[1]; |
3294 | bool query = str[0] == '?' && !str[1]; |
3281 | int saveop = op; |
3295 | int saveop = op; |
… | |
… | |
3388 | break; |
3402 | break; |
3389 | case URxvt_Color_IT: |
3403 | case URxvt_Color_IT: |
3390 | process_color_seq (op, Color_IT, str, resp); |
3404 | process_color_seq (op, Color_IT, str, resp); |
3391 | break; |
3405 | break; |
3392 | #endif |
3406 | #endif |
|
|
3407 | case URxvt_Color_border: |
|
|
3408 | process_color_seq (op, Color_border, str, resp); |
|
|
3409 | break; |
3393 | #if ENABLE_TRANSPARENCY |
3410 | #if ENABLE_TRANSPARENCY |
3394 | case URxvt_Color_tint: |
3411 | case URxvt_Color_tint: |
3395 | process_color_seq (op, Color_tint, str, resp); |
3412 | process_color_seq (op, Color_tint, str, resp); |
3396 | { |
3413 | { |
3397 | bool changed = false; |
3414 | bool changed = false; |
… | |
… | |
3572 | static const struct |
3589 | static const struct |
3573 | { |
3590 | { |
3574 | const int argval; |
3591 | const int argval; |
3575 | const unsigned long bit; |
3592 | const unsigned long bit; |
3576 | } argtopriv[] = { |
3593 | } argtopriv[] = { |
3577 | { 1, PrivMode_aplCUR }, |
3594 | { 1, PrivMode_aplCUR }, // DECCKM |
3578 | { 2, PrivMode_vt52 }, |
3595 | { 2, PrivMode_vt52 }, |
3579 | { 3, PrivMode_132 }, |
3596 | { 3, PrivMode_132 }, // DECCOLM |
3580 | { 4, PrivMode_smoothScroll }, |
3597 | { 4, PrivMode_smoothScroll }, // DECSCLM |
3581 | { 5, PrivMode_rVideo }, |
3598 | { 5, PrivMode_rVideo }, // DECSCNM |
3582 | { 6, PrivMode_relOrigin }, |
3599 | { 6, PrivMode_relOrigin }, // DECOM |
3583 | { 7, PrivMode_Autowrap }, |
3600 | { 7, PrivMode_Autowrap }, // DECAWM |
3584 | // 8, bi-directional support mode |
3601 | // 8, auto-repeat keys // DECARM |
3585 | { 9, PrivMode_MouseX10 }, |
3602 | { 9, PrivMode_MouseX10 }, |
3586 | // 18, 19 printing-related |
3603 | // 18 end FF to printer after print screen |
|
|
3604 | // 19 Print screen prints full screen/scorll region |
3587 | { 25, PrivMode_VisibleCursor }, |
3605 | { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis |
3588 | #ifdef scrollBar_esc |
3606 | #ifdef scrollBar_esc |
3589 | { scrollBar_esc, PrivMode_scrollBar }, |
3607 | { scrollBar_esc, PrivMode_scrollBar }, |
3590 | #endif |
3608 | #endif |
3591 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3609 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
|
|
3610 | // 38, tektronix mode // DECTEK |
3592 | { 40, PrivMode_132OK }, |
3611 | { 40, PrivMode_132OK }, |
3593 | // 41 xterm more fixes NYI |
3612 | // 41 xterm more fixes NYI |
3594 | // 45 margin bell NYI |
3613 | // 45 margin bell NYI |
3595 | // 46 start logging |
3614 | // 46 start logging |
3596 | { 47, PrivMode_Screen }, |
3615 | { 47, PrivMode_Screen }, |
3597 | { 66, PrivMode_aplKP }, |
3616 | { 66, PrivMode_aplKP }, // DECPAM/DECPNM |
3598 | #ifndef NO_BACKSPACE_KEY |
3617 | #ifndef NO_BACKSPACE_KEY |
3599 | { 67, PrivMode_BackSpace }, |
3618 | { 67, PrivMode_BackSpace }, // DECBKM |
3600 | #endif |
3619 | #endif |
3601 | { 1000, PrivMode_MouseX11 }, |
3620 | { 1000, PrivMode_MouseX11 }, |
3602 | { 1002, PrivMode_MouseBtnEvent }, |
3621 | { 1002, PrivMode_MouseBtnEvent }, |
3603 | { 1003, PrivMode_MouseAnyEvent }, |
3622 | { 1003, PrivMode_MouseAnyEvent }, |
3604 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3623 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
… | |
… | |
3643 | |
3662 | |
3644 | scr_touch (true); |
3663 | scr_touch (true); |
3645 | break; |
3664 | break; |
3646 | #endif |
3665 | #endif |
3647 | case 1048: /* alternative cursor save */ |
3666 | case 1048: /* alternative cursor save */ |
3648 | case 1049: |
|
|
3649 | if (option (Opt_secondaryScreen)) |
3667 | if (option (Opt_secondaryScreen)) |
3650 | if (mode == 0) |
3668 | if (mode == 0) |
3651 | scr_cursor (RESTORE); |
3669 | scr_cursor (RESTORE); |
3652 | else if (mode == 1) |
3670 | else if (mode == 1) |
3653 | scr_cursor (SAVE); |
3671 | scr_cursor (SAVE); |
… | |
… | |
3666 | */ |
3684 | */ |
3667 | set_privmode (PrivMode_vt52, 1); |
3685 | set_privmode (PrivMode_vt52, 1); |
3668 | break; |
3686 | break; |
3669 | case 3: /* 80/132 */ |
3687 | case 3: /* 80/132 */ |
3670 | if (priv_modes & PrivMode_132OK) |
3688 | if (priv_modes & PrivMode_132OK) |
3671 | { |
|
|
3672 | scr_poweron (); |
|
|
3673 | set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); |
3689 | set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); |
3674 | } |
|
|
3675 | break; |
3690 | break; |
3676 | case 4: /* smooth scrolling */ |
3691 | case 4: /* smooth scrolling */ |
3677 | set_option (Opt_jumpScroll, !state); |
3692 | set_option (Opt_jumpScroll, !state); |
3678 | break; |
3693 | break; |
3679 | case 5: /* reverse video */ |
3694 | case 5: /* reverse video */ |
… | |
… | |
3721 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
3736 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
3722 | vt_emask_mouse = PointerMotionMask; |
3737 | vt_emask_mouse = PointerMotionMask; |
3723 | } |
3738 | } |
3724 | else |
3739 | else |
3725 | vt_emask_mouse = NoEventMask; |
3740 | vt_emask_mouse = NoEventMask; |
|
|
3741 | |
3726 | vt_select_input (); |
3742 | vt_select_input (); |
3727 | break; |
3743 | break; |
3728 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3744 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3729 | set_option (Opt_scrollTtyOutput, !state); |
3745 | set_option (Opt_scrollTtyOutput, !state); |
3730 | break; |
3746 | break; |
3731 | case 1011: /* scroll to bottom on key press */ |
3747 | case 1011: /* scroll to bottom on key press */ |
3732 | set_option (Opt_scrollTtyKeypress, state); |
3748 | set_option (Opt_scrollTtyKeypress, state); |
3733 | break; |
3749 | break; |
3734 | case 1047: /* secondary screen w/ clearing last */ |
3750 | case 1047: /* secondary screen w/ clearing last */ |
3735 | if (option (Opt_secondaryScreen)) |
3751 | if (option (Opt_secondaryScreen)) |
3736 | if (current_screen != PRIMARY) |
3752 | if (!state) |
3737 | scr_erase_screen (2); |
3753 | scr_erase_screen (2); |
|
|
3754 | |
3738 | scr_change_screen (state); |
3755 | scr_change_screen (state); |
3739 | break; |
3756 | break; |
3740 | case 1049: /* secondary screen w/ clearing first */ |
3757 | case 1049: /* secondary screen w/ clearing first */ |
|
|
3758 | if (option (Opt_secondaryScreen)) |
|
|
3759 | if (state) |
|
|
3760 | scr_cursor (SAVE); |
|
|
3761 | |
3741 | scr_change_screen (state); |
3762 | scr_change_screen (state); |
|
|
3763 | |
3742 | if (option (Opt_secondaryScreen)) |
3764 | if (option (Opt_secondaryScreen)) |
3743 | if (current_screen != PRIMARY) |
3765 | if (state) |
3744 | scr_erase_screen (2); |
3766 | scr_erase_screen (2); |
|
|
3767 | else |
|
|
3768 | scr_cursor (RESTORE); |
3745 | break; |
3769 | break; |
3746 | default: |
3770 | default: |
3747 | break; |
3771 | break; |
3748 | } |
3772 | } |
3749 | } |
3773 | } |