Cygwin: console: Add support for REP escape sequence to xterm mode.

- In Win10 upto 1809, xterm compatible mode does not have REP
  escape sequence which terminfo declares. This patch adds support
  for "CSI Ps b" (REP). With this patch, bvi (binary editor) works
  normally in Win10 1809. Also, xterm compatible mode does not have
  "CSI Pm `" (HPA), "CSI Pm a" (HPR) and "CSI Ps e" (VPR). However,
  they do not appear to be declared by terminfo. Therefore, these
  have been pending.
This commit is contained in:
Takashi Yano 2020-02-27 00:33:01 +09:00 committed by Corinna Vinschen
parent 3b42762e0b
commit 0d7bbc0bc3
3 changed files with 45 additions and 0 deletions

View File

@ -62,6 +62,7 @@ static struct fhandler_base::rabuf_t con_ra;
#define WPBUF_LEN 256
static unsigned char wpbuf[WPBUF_LEN];
static int wpixput;
static unsigned char last_char;
#define wpbuf_put(x) \
wpbuf[wpixput++] = x; \
if (wpixput > WPBUF_LEN) \
@ -2009,6 +2010,37 @@ fhandler_console::char_command (char c)
DWORD wn;
switch (c)
{
#if 0 /* These sequences, which are supported by real xterm, are
not supported by xterm compatible mode. Therefore they
were implemented once. However, these are not declared
in terminfo of xterm-256color, therefore, do not appear
to be necessary. */
case '`': /* HPA */
if (con.args[0] == 0)
con.args[0] = 1;
cursor_get (&x, &y);
cursor_set (false, con.args[0]-1, y);
break;
case 'a': /* HPR */
if (con.args[0] == 0)
con.args[0] = 1;
cursor_rel (con.args[0], 0);
break;
case 'e': /* VPR */
if (con.args[0] == 0)
con.args[0] = 1;
cursor_rel (0, con.args[0]);
break;
#endif
case 'b': /* REP */
wpbuf_put (c);
if (wincap.has_con_esc_rep ())
/* Just send the sequence */
WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
else if (last_char && last_char != '\n')
for (int i = 0; i < con.args[0]; i++)
WriteConsoleA (get_output_handle (), &last_char, 1, &wn, 0);
break;
case 'r': /* DECSTBM */
con.scroll_region.Top = con.args[0] ? con.args[0] - 1 : 0;
con.scroll_region.Bottom = con.args[1] ? con.args[1] - 1 : -1;
@ -2746,6 +2778,7 @@ fhandler_console::write_normal (const unsigned char *src,
break;
default:
found += ret;
last_char = *(found - 1);
break;
}
}

View File

@ -44,6 +44,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -73,6 +74,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -102,6 +104,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -131,6 +134,7 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -160,6 +164,7 @@ wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
has_con_24bit_colors:false,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -189,6 +194,7 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -218,6 +224,7 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -247,6 +254,7 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -276,6 +284,7 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_24bit_colors:true,
has_con_broken_csi3j:true,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
},
};
@ -305,6 +314,7 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_24bit_colors:true,
has_con_broken_csi3j:false,
has_con_broken_il_dl:true,
has_con_esc_rep:true,
},
};

View File

@ -38,6 +38,7 @@ struct wincaps
unsigned has_con_24bit_colors : 1;
unsigned has_con_broken_csi3j : 1;
unsigned has_con_broken_il_dl : 1;
unsigned has_con_esc_rep : 1;
};
};
@ -99,6 +100,7 @@ public:
bool IMPLEMENT (has_con_24bit_colors)
bool IMPLEMENT (has_con_broken_csi3j)
bool IMPLEMENT (has_con_broken_il_dl)
bool IMPLEMENT (has_con_esc_rep)
void disable_case_sensitive_dirs ()
{