Add color output to Windows 10 command prompt

This commit is contained in:
Joshua Granick
2017-09-22 14:45:11 -07:00
parent a6b88222ee
commit a4d232d715
5 changed files with 104 additions and 1 deletions

View File

@@ -1439,6 +1439,17 @@ namespace lime {
}
int lime_system_get_windows_console_mode (int handleType) {
#ifdef HX_WINDOWS
return System::GetWindowsConsoleMode (handleType);
#else
return 0;
#endif
}
void lime_system_open_file (HxString path) {
#ifdef IPHONE
@@ -1464,6 +1475,17 @@ namespace lime {
}
bool lime_system_set_windows_console_mode (int handleType, int mode) {
#ifdef HX_WINDOWS
return System::SetWindowsConsoleMode (handleType, mode);
#else
return false;
#endif
}
void lime_text_event_manager_register (value callback, value eventObject) {
TextEvent::callback = new AutoGCRoot (callback);
@@ -1896,9 +1918,11 @@ namespace lime {
DEFINE_PRIME0 (lime_system_get_ios_tablet);
DEFINE_PRIME0 (lime_system_get_num_displays);
DEFINE_PRIME0 (lime_system_get_timer);
DEFINE_PRIME1 (lime_system_get_windows_console_mode);
DEFINE_PRIME1v (lime_system_open_file);
DEFINE_PRIME2v (lime_system_open_url);
DEFINE_PRIME1 (lime_system_set_allow_screen_timeout);
DEFINE_PRIME2 (lime_system_set_windows_console_mode);
DEFINE_PRIME2v (lime_text_event_manager_register);
DEFINE_PRIME3 (lime_text_layout_create);
DEFINE_PRIME5 (lime_text_layout_position);

View File

@@ -1,3 +1,51 @@
#ifdef HX_WINDOWS
#include <Windows.h>
#endif
#include <system/System.h>
namespace lime {
#ifdef HX_WINDOWS
int System::GetWindowsConsoleMode (int handleType) {
HANDLE handle = GetStdHandle ((DWORD)handleType);
DWORD mode = 0;
if (handle) {
bool result = GetConsoleMode (handle, &mode);
}
return mode;
}
#endif
#ifdef HX_WINDOWS
bool System::SetWindowsConsoleMode (int handleType, int mode) {
HANDLE handle = GetStdHandle ((DWORD)handleType);
if (handle) {
return SetConsoleMode (handle, (DWORD)mode);
}
return false;
}
#endif
}
#ifdef HX_LINUX
// Improve compatibility with old glibc