Issue Color console support for windows 10
Use SetConsoleMode winapi function to enable ANSI
escape codes if we can.
#include <janet.h>
#include "line.h"
+#ifdef _WIN32
+#include <windows.h>
+#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
+#endif
+#endif
+
extern const unsigned char *janet_gen_init;
extern int32_t janet_gen_init_size;
@@ -31,6 +38,15 @@ int main(int argc, char **argv) {
JanetArray *args;
JanetTable *env;
+ /* Enable color console on windows 10 console. */
+#ifdef _WIN32
+ HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ DWORD dwMode = 0;
+ GetConsoleMode(hOut, &dwMode);
+ dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+ SetConsoleMode(hOut, dwMode);
+#endif
+
/* Set up VM */
janet_init();
