[PATCH v2 4/4] Cygwin: console: Add emulation of CSI3J on Win10 1809.
Takashi Yano
takashi.yano@nifty.ne.jp
Wed Feb 26 15:34:00 GMT 2020
- This patch add emulation of CSI3J, which is broken in Win10 1809,
rather than ignoring it as before.
---
winsup/cygwin/fhandler_console.cc | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index b0951497a..7f2e8af5c 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2102,8 +2102,23 @@ fhandler_console::char_command (char c)
break;
case 'J': /* ED */
wpbuf_put (c);
- /* Ignore CSI3J in Win10 1809 because it is broken. */
- if (con.args[0] != 3 || !wincap.has_con_broken_csi3j ())
+ if (con.args[0] == 3 && wincap.has_con_broken_csi3j ())
+ { /* Workaround for broken CSI3J in Win10 1809 */
+ CONSOLE_SCREEN_BUFFER_INFO sbi;
+ GetConsoleScreenBufferInfo (get_output_handle (), &sbi);
+ SMALL_RECT r = {0, sbi.srWindow.Top,
+ (SHORT) (sbi.dwSize.X - 1), (SHORT) (sbi.dwSize.Y - 1)};
+ CHAR_INFO f = {' ', sbi.wAttributes};
+ COORD d = {0, 0};
+ ScrollConsoleScreenBufferA (get_output_handle (),
+ &r, NULL, d, &f);
+ SetConsoleCursorPosition (get_output_handle (), d);
+ d = sbi.dwCursorPosition;
+ d.Y -= sbi.srWindow.Top;
+ SetConsoleCursorPosition (get_output_handle (), d);
+ }
+ else
+ /* Just send the sequence */
WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
break;
case 'h': /* DECSET */
--
2.21.0
More information about the Cygwin-patches
mailing list