diff options
author | Georgi Gerganov <ggerganov@gmail.com> | 2023-03-25 21:53:39 +0200 |
---|---|---|
committer | Georgi Gerganov <ggerganov@gmail.com> | 2023-03-25 21:53:39 +0200 |
commit | c2b25b6912662d2637d9c6e6df3a5de931e0d7ce (patch) | |
tree | 6f6ea2bd4592d2ea4c2f75ef22786400cb3d6141 /examples/main/main.cpp | |
parent | 79b2b266db6b198b5af450982c3cd61120fac951 (diff) |
Fix colors enabling on WIN32
Diffstat (limited to 'examples/main/main.cpp')
-rw-r--r-- | examples/main/main.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/main/main.cpp b/examples/main/main.cpp index a453743..7bb2b6b 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -46,13 +46,11 @@ static bool con_use_color = false; void enable_console_colors() { #if defined (_WIN32) - if (params.use_color) { - // Enable ANSI colors on Windows 10+ - unsigned long dwMode = 0; - void* hConOut = GetStdHandle((unsigned long)-11); // STD_OUTPUT_HANDLE (-11) - if (hConOut && hConOut != (void*)-1 && GetConsoleMode(hConOut, &dwMode) && !(dwMode & 0x4)) { - SetConsoleMode(hConOut, dwMode | 0x4); // ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x4) - } + // Enable ANSI colors on Windows 10+ + unsigned long dwMode = 0; + void* hConOut = GetStdHandle((unsigned long)-11); // STD_OUTPUT_HANDLE (-11) + if (hConOut && hConOut != (void*)-1 && GetConsoleMode(hConOut, &dwMode) && !(dwMode & 0x4)) { + SetConsoleMode(hConOut, dwMode | 0x4); // ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x4) } #endif } @@ -287,7 +285,9 @@ int main(int argc, char ** argv) { int n_consumed = 0; // the first thing we will do is to output the prompt, so set color accordingly - enable_console_colors(); + if (params.use_color) { + enable_console_colors(); + } set_console_state(CONSOLE_STATE_PROMPT); std::vector<llama_token> embd; |