diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2024-03-17 20:48:51 -0400 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2024-03-17 20:48:59 -0400 |
commit | 45daf1cd375b9835d913f689e1bce2b4fc93ac54 (patch) | |
tree | a1d6de1de85173edc369a3e29988b426a49084a5 /src/lpm.c | |
parent | d1fa522c4063e4c0738d3cd800ed9c598c2a92c4 (diff) | |
download | lite-xl-plugin-manager-45daf1cd375b9835d913f689e1bce2b4fc93ac54.tar.gz lite-xl-plugin-manager-45daf1cd375b9835d913f689e1bce2b4fc93ac54.zip |
Added in a fix to detect windows consoles from cmd.exe.
Diffstat (limited to 'src/lpm.c')
-rw-r--r-- | src/lpm.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1471,7 +1471,21 @@ int main(int argc, char* argv[]) { lua_setglobal(L, "VERSION"); lua_pushliteral(L, ARCH_PLATFORM); lua_setglobal(L, "PLATFORM"); - lua_pushboolean(L, isatty(fileno(stdout))); + #if _WIN32 + DWORD handles[] = { STD_OUTPUT_HANDLE, STD_ERROR_HANDLE }; + int setVirtualProcessing = 0; + for (int i = 0; i < 2; ++i) { + DWORD mode = 0; + if (GetConsoleMode(GetStdHandle(handles[i]), &mode)) { + if (SetConsoleMode(GetStdHandle(handles[i]), mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) + setVirtualProcessing = 1; + } + } + // This will fail with mintty, see here: https://github.com/mintty/mintty/issues/482 + lua_pushboolean(L, setVirtualProcessing || isatty(fileno(stdout))); + #else + lua_pushboolean(L, isatty(fileno(stdout))); + #endif lua_setglobal(L, "TTY"); #if _WIN32 lua_pushliteral(L, "\\"); |