Cygwin: console: Add workaround for broken CSI3J in Win10 1809.

- In Win10 1809, the cursor position sometimes goes out of screen
  by clear command in console. This seems to be caused by escape
  sequence CSI3J (ESC[3J). This happens only for 1809. This patch
  is a workaround for the issue.
This commit is contained in:
Takashi Yano 2020-01-14 10:53:59 +09:00 committed by Corinna Vinschen
parent d7478090d6
commit f03806b68a
3 changed files with 54 additions and 1 deletions

View File

@ -1658,6 +1658,18 @@ bool fhandler_console::write_console (PWCHAR buf, DWORD len, DWORD& done)
if (wincap.has_con_24bit_colors () && !con_is_legacy
&& memmem (buf, len*sizeof (WCHAR), L"\033[?1049", 7*sizeof (WCHAR)))
need_fix_tab_position = true;
/* Workaround for broken CSI3J (ESC[3J) support in xterm compatible mode. */
if (wincap.has_con_24bit_colors () && !con_is_legacy &&
wincap.has_con_broken_csi3j ())
{
WCHAR *p = buf;
while ((p = (WCHAR *) memmem (p, (len - (p - buf))*sizeof (WCHAR),
L"\033[3J", 4*sizeof (WCHAR))))
{
memmove (p, p+4, (len - (p+4 - buf))*sizeof (WCHAR));
len -= 4;
}
}
if (con.iso_2022_G1
? con.vt100_graphics_mode_G1

View File

@ -42,6 +42,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:true,
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
},
};
@ -69,6 +70,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:true,
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
},
};
@ -96,6 +98,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
},
};
@ -123,6 +126,7 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
},
};
@ -150,6 +154,7 @@ wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
},
};
@ -177,6 +182,7 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
},
};
@ -204,6 +210,7 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
},
};
@ -231,6 +238,7 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
has_posix_rename_semantics:false,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
},
};
@ -258,6 +266,35 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) =
has_posix_rename_semantics:true,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:true,
has_con_broken_csi3j:true,
},
};
wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) = {
def_guard_pages:2,
mmap_storage_high:0x700000000000LL,
{
is_server:false,
needs_count_in_si_lpres2:false,
needs_query_information:false,
has_gaa_largeaddress_bug:false,
has_broken_alloc_console:true,
has_console_logon_sid:true,
has_precise_system_time:true,
has_microsoft_accounts:true,
has_processor_groups:true,
has_broken_prefetchvm:false,
has_new_pebteb_region:true,
has_broken_whoami:false,
has_unprivileged_createsymlink:true,
has_unbiased_interrupt_time:true,
has_precise_interrupt_time:true,
has_posix_unlink_semantics:true,
has_case_sensitive_dirs:true,
has_posix_rename_semantics:true,
no_msv1_0_s4u_logon_in_wow64:false,
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
},
};
@ -301,7 +338,9 @@ wincapc::init ()
break;
case 10:
default:
if (likely (version.dwBuildNumber >= 17763))
if (likely (version.dwBuildNumber >= 18362))
caps = &wincap_10_1903;
else if (version.dwBuildNumber >= 17763)
caps = &wincap_10_1809;
else if (version.dwBuildNumber >= 17134)
caps = &wincap_10_1803;

View File

@ -36,6 +36,7 @@ struct wincaps
unsigned has_posix_rename_semantics : 1;
unsigned no_msv1_0_s4u_logon_in_wow64 : 1;
unsigned has_con_24bit_colors : 1;
unsigned has_con_broken_csi3j : 1;
};
};
@ -95,6 +96,7 @@ public:
bool IMPLEMENT (has_posix_rename_semantics)
bool IMPLEMENT (no_msv1_0_s4u_logon_in_wow64)
bool IMPLEMENT (has_con_24bit_colors)
bool IMPLEMENT (has_con_broken_csi3j)
void disable_case_sensitive_dirs ()
{