Skip to content

Commit

Permalink
Default to Windows virtual terminal processing
Browse files Browse the repository at this point in the history
Bypass the legacy Windows virtual terminal processing if the Windows
console supports virtual terminal processing.
  • Loading branch information
lzybkr committed Oct 14, 2019
1 parent 7759fdb commit 163de2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
11 changes: 3 additions & 8 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern int so_fg_color, so_bg_color;
extern int bl_fg_color, bl_bg_color;
extern int sgr_mode;
#if MSDOS_COMPILER==WIN32C
extern int have_ul;
extern int vt_enabled;
#endif
#endif

Expand Down Expand Up @@ -115,7 +115,7 @@ flush(VOID_PARAM)
if (is_tty && any_display)
{
*ob = '\0';
if (ctldisp != OPT_ONPLUS)
if (ctldisp != OPT_ONPLUS || vt_enabled)
WIN32textout(obuf, ob - obuf);
else
{
Expand Down Expand Up @@ -259,12 +259,7 @@ flush(VOID_PARAM)
at |= 2;
break;
case 4: /* underline on */
#if MSDOS_COMPILER==WIN32C
if (have_ul)
bgi = COMMON_LVB_UNDERSCORE >> 4;
else
#endif
bgi = 8;
bgi = 8;
at |= 4;
break;
case 5: /* slow blink on */
Expand Down
21 changes: 17 additions & 4 deletions screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int sy_fg_color; /* Color of system text (before less) */
static int sy_bg_color;
public int sgr_mode; /* Honor ANSI sequences rather than using above */
#if MSDOS_COMPILER==WIN32C
public int have_ul; /* Is underline available? */
public int vt_enabled; /* Is virtual terminal processing available? */
#endif
#else

Expand Down Expand Up @@ -1510,11 +1510,11 @@ win32_init_term(VOID_PARAM)
CONSOLE_TEXTMODE_BUFFER,
(LPVOID) NULL);
/*
* Enable underline, if available.
* Enable virtual terminal processing, if available.
*/
GetConsoleMode(con_out_ours, &output_mode);
have_ul = SetConsoleMode(con_out_ours,
output_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
vt_enabled = SetConsoleMode(con_out_ours,
output_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
}

size.X = scr.srWindow.Right - scr.srWindow.Left + 1;
Expand Down Expand Up @@ -1608,7 +1608,20 @@ init(VOID_PARAM)
#else
#if MSDOS_COMPILER==WIN32C
if (!no_init)
{
win32_init_term();
}
else
{
DWORD output_mode;

/*
* Enable virtual terminal processing, if available.
*/
GetConsoleMode(con_out, &output_mode);
vt_enabled = SetConsoleMode(con_out,
output_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
}
#endif
initcolor();
flush();
Expand Down

0 comments on commit 163de2d

Please sign in to comment.