Cygwin: console: Add a workaround for "ESC 7" and "ESC 8".
- In xterm compatible mode, "ESC 7" and "ESC 8" do not work properly in the senario: 1) Execute /bin/ls /bin to fill screen. 2) Sned CSI?1049h to alternate screen. 3) Reduce window size. 4) Send CSI?1049l to resume screen. 5) Send "ESC 7" and "ESC 8". After sending "ESC 8", the cursor goes to incorrect position. This patch adds a workaround for this issue.
This commit is contained in:
parent
750cd6e5b2
commit
b4bc238311
|
@ -1869,6 +1869,7 @@ class dev_console
|
||||||
bool alternate_charset_active;
|
bool alternate_charset_active;
|
||||||
bool metabit;
|
bool metabit;
|
||||||
char backspace_keycode;
|
char backspace_keycode;
|
||||||
|
bool screen_alternated; /* For xterm compatible mode only */
|
||||||
|
|
||||||
char my_title_buf [TITLESIZE + 1];
|
char my_title_buf [TITLESIZE + 1];
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,8 @@ fhandler_console::setup ()
|
||||||
con.dwLastCursorPosition.Y = -1;
|
con.dwLastCursorPosition.Y = -1;
|
||||||
con.dwLastMousePosition.X = -1;
|
con.dwLastMousePosition.X = -1;
|
||||||
con.dwLastMousePosition.Y = -1;
|
con.dwLastMousePosition.Y = -1;
|
||||||
|
con.savex = con.savey = -1;
|
||||||
|
con.screen_alternated = false;
|
||||||
con.dwLastButtonState = 0; /* none pressed */
|
con.dwLastButtonState = 0; /* none pressed */
|
||||||
con.last_button_code = 3; /* released */
|
con.last_button_code = 3; /* released */
|
||||||
con.underline_color = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
con.underline_color = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||||
|
@ -2130,6 +2132,10 @@ fhandler_console::char_command (char c)
|
||||||
break;
|
break;
|
||||||
case 'h': /* DECSET */
|
case 'h': /* DECSET */
|
||||||
case 'l': /* DECRST */
|
case 'l': /* DECRST */
|
||||||
|
if (c == 'h')
|
||||||
|
con.screen_alternated = true;
|
||||||
|
else
|
||||||
|
con.screen_alternated = false;
|
||||||
wpbuf_put (c);
|
wpbuf_put (c);
|
||||||
/* Just send the sequence */
|
/* Just send the sequence */
|
||||||
WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
|
WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
|
||||||
|
@ -2989,6 +2995,36 @@ fhandler_console::write (const void *vsrc, size_t len)
|
||||||
con.saw_space = false;
|
con.saw_space = false;
|
||||||
con.saw_exclamation_mark = false;
|
con.saw_exclamation_mark = false;
|
||||||
}
|
}
|
||||||
|
else if (*src == '8') /* DECRC Restore cursor position */
|
||||||
|
{
|
||||||
|
if (con.screen_alternated)
|
||||||
|
{
|
||||||
|
/* For xterm mode only */
|
||||||
|
DWORD n;
|
||||||
|
/* Just send the sequence */
|
||||||
|
wpbuf_put (*src);
|
||||||
|
WriteConsoleA (get_output_handle (), wpbuf, wpixput, &n, 0);
|
||||||
|
}
|
||||||
|
else if (con.savex >= 0 && con.savey >= 0)
|
||||||
|
cursor_set (false, con.savex, con.savey);
|
||||||
|
con.state = normal;
|
||||||
|
wpixput = 0;
|
||||||
|
}
|
||||||
|
else if (*src == '7') /* DECSC Save cursor position */
|
||||||
|
{
|
||||||
|
if (con.screen_alternated)
|
||||||
|
{
|
||||||
|
/* For xterm mode only */
|
||||||
|
DWORD n;
|
||||||
|
/* Just send the sequence */
|
||||||
|
wpbuf_put (*src);
|
||||||
|
WriteConsoleA (get_output_handle (), wpbuf, wpixput, &n, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cursor_get (&con.savex, &con.savey);
|
||||||
|
con.state = normal;
|
||||||
|
wpixput = 0;
|
||||||
|
}
|
||||||
else if (wincap.has_con_24bit_colors () && !con_is_legacy
|
else if (wincap.has_con_24bit_colors () && !con_is_legacy
|
||||||
&& wincap.has_con_broken_il_dl () && *src == 'M')
|
&& wincap.has_con_broken_il_dl () && *src == 'M')
|
||||||
{ /* Reverse Index (scroll down) */
|
{ /* Reverse Index (scroll down) */
|
||||||
|
@ -3019,12 +3055,15 @@ fhandler_console::write (const void *vsrc, size_t len)
|
||||||
wpixput = 0;
|
wpixput = 0;
|
||||||
}
|
}
|
||||||
else if (wincap.has_con_24bit_colors () && !con_is_legacy)
|
else if (wincap.has_con_24bit_colors () && !con_is_legacy)
|
||||||
{ /* Only CSI is handled in xterm compatible mode. */
|
{
|
||||||
if (*src == 'c') /* RIS Full reset */
|
if (*src == 'c') /* RIS Full reset */
|
||||||
{
|
{
|
||||||
con.scroll_region.Top = 0;
|
con.scroll_region.Top = 0;
|
||||||
con.scroll_region.Bottom = -1;
|
con.scroll_region.Bottom = -1;
|
||||||
}
|
}
|
||||||
|
/* ESC sequences below (e.g. OSC, etc) are left to xterm
|
||||||
|
emulation in xterm compatible mode, therefore, are not
|
||||||
|
handled and just sent them. */
|
||||||
wpbuf_put (*src);
|
wpbuf_put (*src);
|
||||||
/* Just send the sequence */
|
/* Just send the sequence */
|
||||||
DWORD n;
|
DWORD n;
|
||||||
|
@ -3067,18 +3106,6 @@ fhandler_console::write (const void *vsrc, size_t len)
|
||||||
con.state = normal;
|
con.state = normal;
|
||||||
wpixput = 0;
|
wpixput = 0;
|
||||||
}
|
}
|
||||||
else if (*src == '8') /* DECRC Restore cursor position */
|
|
||||||
{
|
|
||||||
cursor_set (false, con.savex, con.savey);
|
|
||||||
con.state = normal;
|
|
||||||
wpixput = 0;
|
|
||||||
}
|
|
||||||
else if (*src == '7') /* DECSC Save cursor position */
|
|
||||||
{
|
|
||||||
cursor_get (&con.savex, &con.savey);
|
|
||||||
con.state = normal;
|
|
||||||
wpixput = 0;
|
|
||||||
}
|
|
||||||
else if (*src == 'R') /* ? */
|
else if (*src == 'R') /* ? */
|
||||||
{
|
{
|
||||||
con.state = normal;
|
con.state = normal;
|
||||||
|
|
Loading…
Reference in New Issue