… | |
… | |
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 (); |
… | |
… | |
2182 | } |
2184 | } |
2183 | } |
2185 | } |
2184 | |
2186 | |
2185 | /*}}} */ |
2187 | /*}}} */ |
2186 | |
2188 | |
2187 | bool |
2189 | void |
2188 | rxvt_term::cmd_parse () |
2190 | rxvt_term::cmd_parse () |
2189 | { |
2191 | { |
2190 | bool flag = false; |
|
|
2191 | wchar_t ch = NOCHAR; |
2192 | wchar_t ch = NOCHAR; |
2192 | char *seq_begin; // remember start of esc-sequence here |
2193 | char *seq_begin; // remember start of esc-sequence here |
2193 | |
2194 | |
2194 | for (;;) |
2195 | for (;;) |
2195 | { |
2196 | { |
… | |
… | |
2289 | * What the heck we'll cheat and only refresh less than every page-full. |
2290 | * What the heck we'll cheat and only refresh less than every page-full. |
2290 | * if skipScroll is enabled. |
2291 | * if skipScroll is enabled. |
2291 | */ |
2292 | */ |
2292 | if (refreshnow) |
2293 | if (refreshnow) |
2293 | { |
2294 | { |
2294 | flag = true; |
|
|
2295 | scr_refresh (); |
2295 | scr_refresh (); |
2296 | want_refresh = 1; |
2296 | want_refresh = 1; |
2297 | } |
2297 | } |
2298 | |
|
|
2299 | } |
2298 | } |
2300 | else |
2299 | else |
2301 | { |
2300 | { |
2302 | try |
2301 | try |
2303 | { |
2302 | { |
… | |
… | |
2311 | } |
2310 | } |
2312 | |
2311 | |
2313 | ch = NOCHAR; |
2312 | ch = NOCHAR; |
2314 | } |
2313 | } |
2315 | } |
2314 | } |
2316 | |
|
|
2317 | return flag; |
|
|
2318 | } |
2315 | } |
2319 | |
2316 | |
2320 | // read the next character |
2317 | // read the next character |
2321 | wchar_t |
2318 | wchar_t |
2322 | rxvt_term::next_char () NOTHROW |
2319 | rxvt_term::next_char () NOTHROW |
… | |
… | |
2691 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2688 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2692 | case C1_SCI: /* ESC Z */ |
2689 | case C1_SCI: /* ESC Z */ |
2693 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2690 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
2694 | break; /* steal obsolete ESC [ c */ |
2691 | break; /* steal obsolete ESC [ c */ |
2695 | |
2692 | |
2696 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2693 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */ |
2697 | case C1_CSI: /* ESC [ */ |
2694 | case C1_CSI: /* ESC [ */ |
2698 | process_csi_seq (); |
2695 | process_csi_seq (); |
2699 | break; |
2696 | break; |
2700 | |
2697 | |
2701 | /* 8.3.90: OPERATING SYSTEM COMMAND */ |
2698 | /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */ |
2702 | case C1_OSC: /* ESC ] */ |
2699 | case C1_OSC: /* ESC ] */ |
2703 | process_osc_seq (); |
2700 | process_osc_seq (); |
2704 | break; |
2701 | break; |
2705 | |
2702 | |
2706 | /* 8.3.106: RESET TO INITIAL STATE */ |
2703 | /* 8.3.106: RESET TO INITIAL STATE (RIS) */ |
2707 | case 'c': |
2704 | case 'c': |
2708 | mbstate.reset (); |
2705 | mbstate.reset (); |
2709 | scr_poweron (); |
2706 | scr_poweron (); |
2710 | scrollBar.show (1); |
2707 | scrollBar.show (1); |
2711 | break; |
2708 | break; |
… | |
… | |
2766 | |
2763 | |
2767 | nargs = 0; |
2764 | nargs = 0; |
2768 | |
2765 | |
2769 | priv = 0; |
2766 | priv = 0; |
2770 | ch = cmd_getc (); |
2767 | ch = cmd_getc (); |
2771 | if (ch >= '<' && ch <= '?') |
2768 | if ((ch >= '<' && ch <= '?') || ch == '!') |
2772 | { |
2769 | { |
2773 | /* '<' '=' '>' '?' */ |
2770 | /* '<' '=' '>' '?' '!' */ |
2774 | priv = ch; |
2771 | priv = ch; |
2775 | ch = cmd_getc (); |
2772 | ch = cmd_getc (); |
2776 | } |
2773 | } |
2777 | |
2774 | |
2778 | /* read any numerical arguments */ |
2775 | /* read any numerical arguments */ |
… | |
… | |
2832 | |
2829 | |
2833 | case '?': |
2830 | case '?': |
2834 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2831 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2835 | process_terminal_mode (ch, priv, nargs, arg); |
2832 | process_terminal_mode (ch, priv, nargs, arg); |
2836 | break; |
2833 | break; |
|
|
2834 | |
|
|
2835 | case '!': |
|
|
2836 | if (ch == CSI_70) |
|
|
2837 | { |
|
|
2838 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
|
|
2839 | scr_soft_reset (); |
|
|
2840 | |
|
|
2841 | static const int pm_h[] = { 7, 25 }; |
|
|
2842 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 }; |
|
|
2843 | |
|
|
2844 | process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h); |
|
|
2845 | process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l); |
2837 | } |
2846 | } |
|
|
2847 | break; |
|
|
2848 | } |
|
|
2849 | |
2838 | return; |
2850 | return; |
2839 | } |
2851 | } |
2840 | |
2852 | |
2841 | switch (ch) |
2853 | switch (ch) |
2842 | { |
2854 | { |
… | |
… | |
3572 | static const struct |
3584 | static const struct |
3573 | { |
3585 | { |
3574 | const int argval; |
3586 | const int argval; |
3575 | const unsigned long bit; |
3587 | const unsigned long bit; |
3576 | } argtopriv[] = { |
3588 | } argtopriv[] = { |
3577 | { 1, PrivMode_aplCUR }, |
3589 | { 1, PrivMode_aplCUR }, // DECCKM |
3578 | { 2, PrivMode_vt52 }, |
3590 | { 2, PrivMode_vt52 }, |
3579 | { 3, PrivMode_132 }, |
3591 | { 3, PrivMode_132 }, // DECCOLM |
3580 | { 4, PrivMode_smoothScroll }, |
3592 | { 4, PrivMode_smoothScroll }, // DECSCLM |
3581 | { 5, PrivMode_rVideo }, |
3593 | { 5, PrivMode_rVideo }, // DECSCNM |
3582 | { 6, PrivMode_relOrigin }, |
3594 | { 6, PrivMode_relOrigin }, // DECOM |
3583 | { 7, PrivMode_Autowrap }, |
3595 | { 7, PrivMode_Autowrap }, // DECAWM |
3584 | // 8, bi-directional support mode |
3596 | // 8, auto-repeat keys // DECARM |
3585 | { 9, PrivMode_MouseX10 }, |
3597 | { 9, PrivMode_MouseX10 }, |
3586 | // 18, 19 printing-related |
3598 | // 18, 19 printing-related |
3587 | { 25, PrivMode_VisibleCursor }, |
3599 | { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis |
3588 | #ifdef scrollBar_esc |
3600 | #ifdef scrollBar_esc |
3589 | { scrollBar_esc, PrivMode_scrollBar }, |
3601 | { scrollBar_esc, PrivMode_scrollBar }, |
3590 | #endif |
3602 | #endif |
3591 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3603 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
|
|
3604 | // 38, tektronix mode // DECTEK |
3592 | { 40, PrivMode_132OK }, |
3605 | { 40, PrivMode_132OK }, |
3593 | // 41 xterm more fixes NYI |
3606 | // 41 xterm more fixes NYI |
3594 | // 45 margin bell NYI |
3607 | // 45 margin bell NYI |
3595 | // 46 start logging |
3608 | // 46 start logging |
3596 | { 47, PrivMode_Screen }, |
3609 | { 47, PrivMode_Screen }, |
3597 | { 66, PrivMode_aplKP }, |
3610 | { 66, PrivMode_aplKP }, // DECPAM/DECPNM |
3598 | #ifndef NO_BACKSPACE_KEY |
3611 | #ifndef NO_BACKSPACE_KEY |
3599 | { 67, PrivMode_BackSpace }, |
3612 | { 67, PrivMode_BackSpace }, // DECBKM |
3600 | #endif |
3613 | #endif |
3601 | { 1000, PrivMode_MouseX11 }, |
3614 | { 1000, PrivMode_MouseX11 }, |
3602 | { 1002, PrivMode_MouseBtnEvent }, |
3615 | { 1002, PrivMode_MouseBtnEvent }, |
3603 | { 1003, PrivMode_MouseAnyEvent }, |
3616 | { 1003, PrivMode_MouseAnyEvent }, |
3604 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3617 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
… | |
… | |
3666 | */ |
3679 | */ |
3667 | set_privmode (PrivMode_vt52, 1); |
3680 | set_privmode (PrivMode_vt52, 1); |
3668 | break; |
3681 | break; |
3669 | case 3: /* 80/132 */ |
3682 | case 3: /* 80/132 */ |
3670 | if (priv_modes & PrivMode_132OK) |
3683 | if (priv_modes & PrivMode_132OK) |
3671 | { |
|
|
3672 | scr_poweron (); |
|
|
3673 | set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); |
3684 | set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight); |
3674 | } |
|
|
3675 | break; |
3685 | break; |
3676 | case 4: /* smooth scrolling */ |
3686 | case 4: /* smooth scrolling */ |
3677 | set_option (Opt_jumpScroll, !state); |
3687 | set_option (Opt_jumpScroll, !state); |
3678 | break; |
3688 | break; |
3679 | case 5: /* reverse video */ |
3689 | case 5: /* reverse video */ |
… | |
… | |
3721 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
3731 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
3722 | vt_emask_mouse = PointerMotionMask; |
3732 | vt_emask_mouse = PointerMotionMask; |
3723 | } |
3733 | } |
3724 | else |
3734 | else |
3725 | vt_emask_mouse = NoEventMask; |
3735 | vt_emask_mouse = NoEventMask; |
|
|
3736 | |
3726 | vt_select_input (); |
3737 | vt_select_input (); |
3727 | break; |
3738 | break; |
3728 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3739 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3729 | set_option (Opt_scrollTtyOutput, !state); |
3740 | set_option (Opt_scrollTtyOutput, !state); |
3730 | break; |
3741 | break; |
… | |
… | |
3733 | break; |
3744 | break; |
3734 | case 1047: /* secondary screen w/ clearing last */ |
3745 | case 1047: /* secondary screen w/ clearing last */ |
3735 | if (option (Opt_secondaryScreen)) |
3746 | if (option (Opt_secondaryScreen)) |
3736 | if (current_screen != PRIMARY) |
3747 | if (current_screen != PRIMARY) |
3737 | scr_erase_screen (2); |
3748 | scr_erase_screen (2); |
|
|
3749 | |
3738 | scr_change_screen (state); |
3750 | scr_change_screen (state); |
3739 | break; |
3751 | break; |
3740 | case 1049: /* secondary screen w/ clearing first */ |
3752 | case 1049: /* secondary screen w/ clearing first */ |
3741 | scr_change_screen (state); |
3753 | scr_change_screen (state); |
3742 | if (option (Opt_secondaryScreen)) |
3754 | if (option (Opt_secondaryScreen)) |