Workarounds for multiple ConEmu issues. Mixed ANSI and direct writes

left ANSI colors on screen, while pure ANSI mode scrolled when the last
cell was written. (That will still happen if extended colors are used in
the last cell, but is otherwise fixed.) Also, ConEmu doesn't support
init_color().
This commit is contained in:
William McBrine
2018-02-07 20:06:36 -05:00
parent bdeaf04a5f
commit 5e96e51b1f
4 changed files with 31 additions and 7 deletions

View File

@@ -144,9 +144,13 @@ void _set_ansi_color(short f, short b, attr_t attr)
if (strlen(esc) > 2)
{
sprintf(p, "m");
SetConsoleMode(pdc_con_out, 0x0015);
if (!pdc_conemu)
SetConsoleMode(pdc_con_out, 0x0015);
WriteConsoleA(pdc_con_out, esc, strlen(esc), NULL, NULL);
SetConsoleMode(pdc_con_out, 0x0010);
if (!pdc_conemu)
SetConsoleMode(pdc_con_out, 0x0010);
}
}
@@ -165,8 +169,20 @@ void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp)
short fore, back;
bool blink, ansi;
if (pdc_conemu && pdc_ansi &&
(lineno == (SP->lines - 1)) && ((x + len) == SP->cols))
{
len--;
if (len)
_new_packet(attr, lineno, x, len, srcp);
pdc_ansi = FALSE;
_new_packet(attr, lineno, x + len, 1, srcp + len);
pdc_ansi = TRUE;
return;
}
PDC_pair_content(PAIR_NUMBER(attr), &fore, &back);
ansi = (fore >= 16 || back >= 16);
ansi = pdc_ansi || (fore >= 16 || back >= 16);
blink = (SP->termattrs & A_BLINK) && (attr & A_BLINK);
if (blink)

View File

@@ -32,6 +32,7 @@ static short ansitocurs[16] =
short pdc_curstoreal[16], pdc_curstoansi[16];
short pdc_oldf, pdc_oldb, pdc_oldu;
bool pdc_conemu, pdc_ansi;
enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER };
@@ -392,6 +393,10 @@ int PDC_scr_open(int argc, char **argv)
is_nt = !(GetVersion() & 0x80000000);
str = getenv("ConEmuANSI");
pdc_conemu = !!str;
pdc_ansi = pdc_conemu ? !strcmp(str, "ON") : FALSE;
GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
GetConsoleMode(pdc_con_in, &old_console_mode);
@@ -625,7 +630,7 @@ int PDC_pair_content(short pair, short *fg, short *bg)
bool PDC_can_change_color(void)
{
return is_nt;
return is_nt && !pdc_conemu;
}
int PDC_color_content(short color, short *red, short *green, short *blue)

View File

@@ -91,12 +91,14 @@ int PDC_set_blink(bool blinkon)
if (pdc_color_started)
{
COLORS = 16;
if (PDC_can_change_color()) // is_nt
if (pdc_conemu && pdc_ansi)
COLORS = 256;
else if (PDC_can_change_color()) /* is_nt */
{
if (SetConsoleMode(pdc_con_out, 0x0004)) // VT
if (SetConsoleMode(pdc_con_out, 0x0004)) /* VT */
COLORS = 256;
SetConsoleMode(pdc_con_out, 0x0010); // LVB
SetConsoleMode(pdc_con_out, 0x0010); /* LVB */
}
}

View File

@@ -18,6 +18,7 @@ extern DWORD pdc_quick_edit;
extern DWORD pdc_last_blink;
extern short pdc_curstoreal[16], pdc_curstoansi[16];
extern short pdc_oldf, pdc_oldb, pdc_oldu;
extern bool pdc_conemu, pdc_ansi;
extern int PDC_get_buffer_rows(void);
extern void PDC_blink_text(void);