Skip to content
Snippets Groups Projects
Commit 79962d0d authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Set the size of the CONSOLE_SCREEN_BUFFER_INFOEX first

This allows GetConsoleScreenBufferInfoEx() to work for palette
changes, allowing Console to not suck.  However, we now prefer
ANSI mode over Win32 Console, so make that so it can actually
fail on Windows of stdout is a TTY and we can't set the
ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.

With this, ANSI mode is used in Windows Terminal, and Win32 Console
is used in Legacy Console, and all should be good with the world.
parent 566a09f5
No related branches found
No related tags found
No related merge requests found
Pipeline #6915 passed
......@@ -961,6 +961,10 @@ int ansi_initio_cb(void)
conmode = ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT;
if(!SetConsoleMode(h, conmode))
return(0);
if (!GetConsoleMode(h, &conmode))
return(0);
if (!(conmode & ENABLE_VIRTUAL_TERMINAL_PROCESSING))
return(0);
}
fflush(stderr);
fflush(stdout);
......@@ -992,7 +996,7 @@ int ansi_initio_cb(void)
atexit(ansi_fixterm);
}
#endif
return(0);
return(1);
}
#if defined(__BORLANDC__)
......@@ -1009,7 +1013,8 @@ int ansi_initciolib(int inmode)
ansi_textmode(1);
cio_textinfo.screenheight=24;
cio_textinfo.screenwidth=80;
ciolib_ansi_initio_cb();
if (!ciolib_ansi_initio_cb())
return 0;
sem_init(&got_key,0,0);
sem_init(&got_input,0,0);
......
......@@ -467,12 +467,15 @@ CIOLIBEXPORT int initciolib(int mode)
#if defined(WITH_SDL)
if(!try_sdl_init(CIOLIB_MODE_SDL))
#endif
#ifndef _WIN32
if(!try_curses_init(mode))
#endif
if (!try_ansi_init(mode))
#ifdef _WIN32
if(!try_conio_init(mode))
if(!try_conio_init(mode));
#else
if(!try_curses_init(mode))
;
#endif
try_ansi_init(mode);
break;
#ifdef _WIN32
case CIOLIB_MODE_CONIO:
......
......@@ -761,13 +761,13 @@ void win32_textmode(int mode)
cio_textinfo.wintop=1;
cio_textinfo.winright=cio_textinfo.screenwidth;
cio_textinfo.winbottom=cio_textinfo.screenheight;
bi.cbSize = sizeof(bi);
if (GetConsoleScreenBufferInfoEx(h, &bi)) {
for (i = 0; i < 16; i++) {
bi.ColorTable[i] = RGB(dac_default[palettes[vparams[modeidx].palette][i]].red, dac_default[palettes[vparams[modeidx].palette][i]].green, dac_default[palettes[vparams[modeidx].palette][i]].blue);
}
if (SetConsoleScreenBufferInfoEx(h, &bi)) {
if (SetConsoleScreenBufferInfoEx(h, &bi))
cio_api.options |= CONIO_OPT_PALETTE_SETTING;
}
}
if (GetConsoleMode(h, &oldmode)) {
cmode = oldmode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT;
......@@ -1053,6 +1053,7 @@ int win32_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b)
if (entry > 15)
return 0;
bi.cbSize = sizeof(bi);
if (!GetConsoleScreenBufferInfoEx(h, &bi))
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment