mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 03:10:01 +08:00
Request Windows to emulate VT100.
This was previously supported on ScreenInteractive, this is now universally supported. This partially address: https://github.com/ArthurSonzogni/FTXUI/issues/27
This commit is contained in:
parent
454b14c5c6
commit
22afacc28b
@ -48,6 +48,29 @@ bool In(const Box& stencil, int x, int y) {
|
||||
|
||||
Pixel dev_null_pixel;
|
||||
|
||||
#if defined(_WIN32)
|
||||
void WindowsEmulateVT100Terminal() {
|
||||
static bool done = false;
|
||||
if (done)
|
||||
return;
|
||||
done = true;
|
||||
|
||||
// Enable VT processing on stdout and stdin
|
||||
auto stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
DWORD out_mode = 0;
|
||||
GetConsoleMode(stdout_handle, &out_mode);
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/console/setconsolemode
|
||||
const int enable_virtual_terminal_processing = 0x0004;
|
||||
const int disable_newline_auto_return = 0x0008;
|
||||
out_mode |= enable_virtual_terminal_processing;
|
||||
out_mode |= disable_newline_auto_return;
|
||||
|
||||
SetConsoleMode(stdout_handle, out_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
Dimension Dimension::Fixed(int v) {
|
||||
@ -89,6 +112,7 @@ Screen::Screen(int dimx, int dimy)
|
||||
// UTF8 encoding here
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
SetConsoleCP(CP_UTF8);
|
||||
WindowsEmulateVT100Terminal();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user