From b2e0a63e0840247d2662f0b7b0ac97b95cebb382 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 25 Sep 2017 22:43:38 +0800 Subject: enable colors output for windows cmd --- core/src/xmake/machine.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core') diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index ad1c4d366..75fc9548d 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -549,6 +549,21 @@ xm_machine_ref_t xm_machine_init() lua_newtable(impl->lua); lua_setglobal(impl->lua, "xmake"); +#ifdef TB_CONFIG_OS_WINDOWS + // enable terminal colors output for windows cmd + HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE); + if (output != INVALID_HANDLE_VALUE) + { + DWORD mode; + if (GetConsoleMode(output, &mode)) + { + // attempt to enable 0x4: ENABLE_VIRTUAL_TERMINAL_PROCESSING + if (SetConsoleMode(output, mode | 0x4)) + tb_environment_set("COLORTERM", "color256"); + } + } +#endif + // ok ok = tb_true; -- cgit v1.3.1