diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2020-02-27 11:33:50 +0900 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-02-28 15:32:51 +0100 |
commit | 002206dc7cac5f3cc4d1282439c7a0c619a37b7f (patch) | |
tree | f459adc3c50812f81b1dc6163a982a694d8bff10 /winsup/cygwin/fhandler_console.cc | |
parent | 729cb70bcf232a1da956ec3725c1f76e28b3caa5 (diff) | |
download | newlib-002206dc7cac5f3cc4d1282439c7a0c619a37b7f.zip newlib-002206dc7cac5f3cc4d1282439c7a0c619a37b7f.tar.gz newlib-002206dc7cac5f3cc4d1282439c7a0c619a37b7f.tar.bz2 |
Cygwin: console: Adjust the detailed behaviour of ESC sequences.
- This patch makes some detailed behaviour of ESC sequences such as
"CSI Ps L" (IL), "CSI Ps M" (DL) and "ESC M" (RI) in xterm mode
match with real xterm.
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 4ab9bca..64e12b8 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -2053,6 +2053,19 @@ fhandler_console::char_command (char c) { /* Use "CSI Ps T" instead */ cursor_get (&x, &y); + if (y < srTop || y > srBottom) + break; + if (y == con.b.srWindow.Top + && srBottom == con.b.srWindow.Bottom) + { + /* Erase scroll down area */ + n = con.args[0] ? : 1; + __small_sprintf (buf, "\033[%d;1H\033[J\033[%d;%dH", + srBottom - (n-1) - con.b.srWindow.Top + 1, + y + 1 - con.b.srWindow.Top, x + 1); + WriteConsoleA (get_output_handle (), + buf, strlen (buf), &wn, 0); + } __small_sprintf (buf, "\033[%d;%dr", y + 1 - con.b.srWindow.Top, srBottom + 1 - con.b.srWindow.Top); @@ -2079,6 +2092,8 @@ fhandler_console::char_command (char c) { /* Use "CSI Ps S" instead */ cursor_get (&x, &y); + if (y < srTop || y > srBottom) + break; __small_sprintf (buf, "\033[%d;%dr", y + 1 - con.b.srWindow.Top, srBottom + 1 - con.b.srWindow.Top); @@ -2137,6 +2152,16 @@ fhandler_console::char_command (char c) fix_tab_position (); } break; + case 'p': + if (con.saw_exclamation_mark) /* DECSTR Soft reset */ + { + con.scroll_region.Top = 0; + con.scroll_region.Bottom = -1; + } + wpbuf_put (c); + /* Just send the sequence */ + WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0); + break; default: /* Other escape sequences */ wpbuf_put (c); @@ -2970,6 +2995,7 @@ fhandler_console::write (const void *vsrc, size_t len) con.saw_question_mark = false; con.saw_greater_than_sign = false; con.saw_space = false; + con.saw_exclamation_mark = false; } else if (wincap.has_con_24bit_colors () && !con_is_legacy && wincap.has_con_broken_il_dl () && *src == 'M') @@ -2979,13 +3005,17 @@ fhandler_console::write (const void *vsrc, size_t len) cursor_get (&x, &y); if (y == srTop) { - /* Erase scroll down area */ - char buf[] = "\033[32768;1H\033[J\033[32768;32768"; - __small_sprintf (buf, "\033[%d;1H\033[J\033[%d;%dH", - srBottom - con.b.srWindow.Top + 1, - y + 1 - con.b.srWindow.Top, x + 1); - WriteConsoleA (get_output_handle (), - buf, strlen (buf), &n, 0); + if (y == con.b.srWindow.Top + && srBottom == con.b.srWindow.Bottom) + { + /* Erase scroll down area */ + char buf[] = "\033[32768;1H\033[J\033[32768;32768"; + __small_sprintf (buf, "\033[%d;1H\033[J\033[%d;%dH", + srBottom - con.b.srWindow.Top + 1, + y + 1 - con.b.srWindow.Top, x + 1); + WriteConsoleA (get_output_handle (), + buf, strlen (buf), &n, 0); + } /* Substitute "CSI Ps T" */ wpbuf_put ('['); wpbuf_put ('T'); @@ -2998,6 +3028,11 @@ fhandler_console::write (const void *vsrc, size_t len) } else if (wincap.has_con_24bit_colors () && !con_is_legacy) { /* Only CSI is handled in xterm compatible mode. */ + if (*src == 'c') /* RIS Full reset */ + { + con.scroll_region.Top = 0; + con.scroll_region.Bottom = -1; + } wpbuf_put (*src); /* Just send the sequence */ DWORD n; @@ -3169,6 +3204,8 @@ fhandler_console::write (const void *vsrc, size_t len) con.saw_question_mark = true; else if (*src == '>') con.saw_greater_than_sign = true; + else if (*src == '!') + con.saw_exclamation_mark = true; wpbuf_put (*src); /* ignore any extra chars between [ and first arg or command */ src++; |