From adcb9fad55475f8800ad0dddb809a9b842e1d41a Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Sun, 20 Jun 2021 03:46:36 +0100 Subject: [PATCH] Fix console scrolling issues on windows (#609) * Fix console scrolling issues on windows * Add super extremely important spaces --- common/log/log.cpp | 29 ++++++++++++++++++++++------- decompiler/util/data_decompile.cpp | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/common/log/log.cpp b/common/log/log.cpp index 0ef99fcd74..c560507fd4 100644 --- a/common/log/log.cpp +++ b/common/log/log.cpp @@ -103,20 +103,35 @@ void initialize() { assert(!gLogger.initialized); #ifdef _WIN32 - // Always enable VIRTUAL_TERMINAL_PROCESSING, this console mode allows the console (stdout) to - // support ANSI colors in the outputted text, which are used by the logging tool. - // This mode may not be enabled by default, and changing that involves modifying the registry, - // so it seems like a better solution would be enabling it ourselves. + // Enable some console terminal flags. Some of these may not be enabled by default, unless + // the user edits their registry. This is clearly unwanted, so we just set them here ourselves. + + // VIRTUAL_TERMINAL_PROCESSING enables support for ANSI colors in the stdout text, used by the + // logging tool. + // ENABLE_QUICK_EDIT_MODE enables various mouse-related stdin functions, such as right-click for + // copy-paste, scroll wheel to - shocker - scroll, etc. // Get handle to stdout HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); // get current stdout mode DWORD modeStdOut; GetConsoleMode(hStdOut, &modeStdOut); - // enable VIRTUAL_TERMINAL_PROCESSING. As a bitwise OR it will not do anything if it is - // already set + // printf("stdout mode is: %08x", modeStdOut); + + // Get handle to stdin + HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE); + // get current stdin mode + DWORD modeStdIn; + GetConsoleMode(hStdIn, &modeStdIn); + // printf("stdin mode is: %08x", modeStdIn); + + // enable VIRTUAL_TERMINAL_PROCESSING on stdout modeStdOut |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; SetConsoleMode(hStdOut, modeStdOut); + + // enable ENABLE_QUICK_EDIT_MODE on stdin + modeStdIn |= ENABLE_QUICK_EDIT_MODE; + SetConsoleMode(hStdIn, modeStdIn); #endif gLogger.initialized = true; @@ -132,4 +147,4 @@ void finish() { } } -} // namespace lg \ No newline at end of file +} // namespace lg diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 1656ea15da..beaac8b79d 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -2,6 +2,7 @@ #include "data_decompile.h" #include "third-party/fmt/core.h" +#include "common/type_system/Type.h" #include "common/goos/PrettyPrinter.h" #include "common/util/math_util.h" #include "common/log/log.h"