mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Issue #113 Color console support for windows 10
Use SetConsoleMode winapi function to enable ANSI escape codes if we can.
This commit is contained in:
		| @@ -23,6 +23,13 @@ | ||||
| #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(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose