From cb7b4cdc484d2a20c6147c2a415fade252d14122 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Tue, 18 Feb 2025 17:26:43 -0600 Subject: [PATCH] really fix windows console --- library/Console-windows.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/Console-windows.cpp b/library/Console-windows.cpp index 83ed0f64ee..12a3e0c2eb 100644 --- a/library/Console-windows.cpp +++ b/library/Console-windows.cpp @@ -233,13 +233,16 @@ namespace DFHack size_t len = raw_buffer.size(); int cooked_cursor = raw_cursor; - int adj = std::min(plen + cooked_cursor - cols, len); - buf += adj; - len -= adj; - cooked_cursor -= adj; + if (plen + cooked_cursor > cols) + { + int adj = std::min(plen + cooked_cursor - cols, len); + buf += adj; + len -= adj; + cooked_cursor -= adj; + } - int adj2 = std::min(plen + len - cols, len); - len -= adj2; + if (len + plen > cols) + len = cols - plen; CONSOLE_SCREEN_BUFFER_INFO inf = { 0 }; GetConsoleScreenBufferInfo(console_out, &inf);