initializer fix for !VIRTUAL_TERMINAL_SEQUENCES

For windows sys/windows/consoletty.c.

Resolves #1169
This commit is contained in:
nhmall
2023-12-08 13:01:52 -05:00
parent dbb41f4a2d
commit 7259ae21f5

View File

@@ -186,15 +186,8 @@ struct console_t {
WCHAR cpMap[256];
boolean font_changed;
CONSOLE_FONT_INFOEX orig_font_info;
#ifndef VIRTUAL_TERMINAL_SEQUENCES
UINT original_code_page;
} console = {
0,
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED),
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED),
NO_COLOR,
#else /* VIRTUAL_TERMINAL_SEQUENCES */
UINT orig_code_page;
#ifdef VIRTUAL_TERMINAL_SEQUENCES
char *orig_localestr;
DWORD orig_in_cmode;
DWORD orig_out_cmode;
@@ -205,33 +198,17 @@ struct console_t {
DWORD out_cmode;
long color24;
int color256idx;
#endif /* VIRTUAL_TERMINAL_SEQUENCES */
} console = {
FALSE,
0,
FALSE, /* is_ready */
0, /* hWnd */
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* background */
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */
0, /* attr */
0, /* current_nhcolor */
0, /* current_nhbkcolor */
#endif /* VIRTUAL_TERMINAL_SEQUENCES */
{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
#ifndef VIRTUAL_TERMINAL_SEQUENCES
{0, 0},
NULL,
NULL,
{ 0 },
0,
0,
FALSE,
0,
NULL,
NULL,
{ 0 },
FALSE,
{ 0 },
0
#else /* VIRTUAL_TERMINAL_SEQUENCES */
{ 0, 0 }, /* cursor */
{0, 0}, /* cursor */
NULL, /* hConOut*/
NULL, /* hConIn */
{ 0 }, /* cbsi */
@@ -245,6 +222,7 @@ struct console_t {
FALSE, /* font_changed */
{ 0 }, /* orig_font_info */
0U, /* orig_code_page */
#ifdef VIRTUAL_TERMINAL_SEQUENCES
NULL, /* orig_localestr */
0, /* orig_in_cmode */
0, /* orig_out_cmode */
@@ -1446,8 +1424,6 @@ g_putch(int in_ch)
buffer_write(console.back_buffer, &cell, console.cursor);
}
#ifdef VIRTUAL_TERMINAL_SEQUENCES
#ifdef UTF8_FROM_CORE
/*
* Overrides wintty.c function of the same name
* for win32. It is used for glyphs only, not text and
@@ -1458,6 +1434,8 @@ g_putch(int in_ch)
void
g_pututf8(uint8 *sequence)
{
#ifdef VIRTUAL_TERMINAL_SEQUENCES
#ifdef UTF8_FROM_CORE
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
cell_t cell;
cell.attr = console.attr;
@@ -1468,23 +1446,27 @@ g_pututf8(uint8 *sequence)
Snprintf((char *) cell.utf8str, sizeof cell.utf8str, "%s",
(char *) sequence);
buffer_write(console.back_buffer, &cell, console.cursor);
}
#endif /* UTF8_FROM_CORE */
#endif
}
void
term_start_24bitcolor(struct unicode_representation *uval)
{
#ifdef VIRTUAL_TERMINAL_SEQUENCES
console.color24 = uval->ucolor; /* color 0 has bit 0x1000000 set */
console.color256idx = uval->u256coloridx;
#endif
}
void
term_end_24bitcolor(void)
{
#ifdef VIRTUAL_TERMINAL_SEQUENCES
console.color24 = 0L;
console.color256idx = 0;
#endif
}
#endif /* VIRTUAL_TERMINAL_SEQUENCES */
void
cl_end(void)
@@ -2210,7 +2192,7 @@ set_known_good_console_font(void)
console.font_changed = TRUE;
#ifndef VIRTUAL_TERMINAL_SEQUENCES
console.orig_font_info = console_font_info;
console.original_code_page = GetConsoleOutputCP();
console.orig_code_page = GetConsoleOutputCP();
#else /* VIRTUAL_TERMINAL_SEQUENCES */
console.code_page = GetConsoleOutputCP();
@@ -2245,7 +2227,7 @@ restore_original_console_font(void)
BOOL success;
#ifndef VIRTUAL_TERMINAL_SEQUENCES
raw_print("Restoring original font and code page\n");
success = SetConsoleOutputCP(console.original_code_page);
success = SetConsoleOutputCP(console.orig_code_page);
#else /* VIRTUAL_TERMINAL_SEQUENCES */
if (wizard)
raw_print("Restoring original font, code page and locale\n");