X-Git-Url: https://git.josue.xyz/?p=VSoRC%2F.git;a=blobdiff_plain;f=node_modules%2Fnode-pty%2Fdeps%2Fwinpty%2Fmisc%2FIsNewConsole.cc;fp=node_modules%2Fnode-pty%2Fdeps%2Fwinpty%2Fmisc%2FIsNewConsole.cc;h=0000000000000000000000000000000000000000;hp=2b554c72c9fdc4a063e68a30251f0e9cdd51b183;hb=5e96dd57ddd883604e87f62bdddcb111c63a6e1a;hpb=acb5f682a2b75b972710cabd81658f63071324b0 diff --git a/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc b/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc deleted file mode 100644 index 2b554c7..0000000 --- a/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Determines whether this is a new console by testing whether MARK moves the -// cursor. -// -// WARNING: This test program may behave erratically if run under winpty. -// - -#include - -#include -#include - -#include "TestUtil.cc" - -const int SC_CONSOLE_MARK = 0xFFF2; -const int SC_CONSOLE_SELECT_ALL = 0xFFF5; - -static COORD getWindowPos(HANDLE conout) { - CONSOLE_SCREEN_BUFFER_INFO info = {}; - BOOL ret = GetConsoleScreenBufferInfo(conout, &info); - ASSERT(ret && "GetConsoleScreenBufferInfo failed"); - return { info.srWindow.Left, info.srWindow.Top }; -} - -static COORD getWindowSize(HANDLE conout) { - CONSOLE_SCREEN_BUFFER_INFO info = {}; - BOOL ret = GetConsoleScreenBufferInfo(conout, &info); - ASSERT(ret && "GetConsoleScreenBufferInfo failed"); - return { - static_cast(info.srWindow.Right - info.srWindow.Left + 1), - static_cast(info.srWindow.Bottom - info.srWindow.Top + 1) - }; -} - -static COORD getCursorPos(HANDLE conout) { - CONSOLE_SCREEN_BUFFER_INFO info = {}; - BOOL ret = GetConsoleScreenBufferInfo(conout, &info); - ASSERT(ret && "GetConsoleScreenBufferInfo failed"); - return info.dwCursorPosition; -} - -static void setCursorPos(HANDLE conout, COORD pos) { - BOOL ret = SetConsoleCursorPosition(conout, pos); - ASSERT(ret && "SetConsoleCursorPosition failed"); -} - -int main() { - const HANDLE conout = openConout(); - const HWND hwnd = GetConsoleWindow(); - ASSERT(hwnd != NULL && "GetConsoleWindow() returned NULL"); - - // With the legacy console, the Mark command moves the the cursor to the - // top-left cell of the visible console window. Determine whether this - // is the new console by seeing if the cursor moves. - - const auto windowSize = getWindowSize(conout); - if (windowSize.X <= 1) { - printf("Error: console window must be at least 2 columns wide\n"); - trace("Error: console window must be at least 2 columns wide"); - return 1; - } - - bool cursorMoved = false; - const auto initialPos = getCursorPos(conout); - - const auto windowPos = getWindowPos(conout); - setCursorPos(conout, { static_cast(windowPos.X + 1), windowPos.Y }); - - { - const auto posA = getCursorPos(conout); - SendMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_MARK, 0); - const auto posB = getCursorPos(conout); - cursorMoved = memcmp(&posA, &posB, sizeof(posA)) != 0; - SendMessage(hwnd, WM_CHAR, 27, 0x00010001); // Send ESCAPE - } - - setCursorPos(conout, initialPos); - - if (cursorMoved) { - printf("Legacy console (i.e. MARK moved cursor)\n"); - trace("Legacy console (i.e. MARK moved cursor)"); - } else { - printf("Windows 10 new console (i.e MARK did not move cursor)\n"); - trace("Windows 10 new console (i.e MARK did not move cursor)"); - } - - return 0; -}