forgot windows has to be fucking special

This commit is contained in:
Lily Tsuru 2023-08-22 16:53:16 -04:00
parent 8b6d939678
commit 158cae043b
1 changed files with 28 additions and 0 deletions

View File

@ -1,6 +1,31 @@
#include "fprint.hpp"
#include "worker.hpp"
#ifdef _WIN32
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
std::uint32_t lastVtMode = 0;
void EnableVtMode() {
GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &lastVtMode);
auto newMode = lastVtMode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), newMode);
}
void DisableVtMode() {
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), lastVtMode);
}
struct ScopedVtMode {
ScopedVtMode() { EnableVtMode(); }
~ScopedVtMode() { DisableVtMode(); }
ScopedVtMode(const ScopedVtMode&) = delete;
ScopedVtMode(ScopedVtMode&&) = delete;
};
#endif
struct Arguments {
bool exact { false };
std::uint32_t startLength = 2;
@ -119,6 +144,9 @@ struct Arguments {
};
int main(int argc, char** argv) {
#ifdef _WIN32
ScopedVtMode vtmode;
#endif
auto args = Arguments::FromArgv(argc, argv);
if(!args.Validate()) {
return 1;