1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

windows: make redirected console detection available to other modules

This commit is contained in:
vitalyster 2019-10-08 03:11:26 +03:00 committed by Alexander Medvednikov
parent 60d4f47f7a
commit 0963328aed
2 changed files with 4 additions and 2 deletions

View File

@ -141,7 +141,9 @@ byteptr g_str_buf;
int load_so(byteptr);
void reload_so();
void init_consts();
#ifdef _WIN32
BOOL isConsole;
#endif
'
js_headers = '

View File

@ -402,7 +402,7 @@ fn (v mut V) generate_main() {
cgen.genln('void init_consts() {
#ifdef _WIN32
DWORD consoleMode;
BOOL isConsole = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &consoleMode);
isConsole = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &consoleMode);
int mode = isConsole ? _O_U16TEXT : _O_U8TEXT;
_setmode(_fileno(stdin), mode);
_setmode(_fileno(stdout), _O_U8TEXT);