From ad85fec9f3c913b2a8cafb24900966b13dc7fc5c Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 25 Apr 2016 08:50:48 +0100 Subject: winansi: interpret absolute cursor positions relative to screen Cursor positions in ANSI emulation were being treated as relative to the start of the buffer. This resulted in the contents of the buffer being lost when the screen was cleared. Treat absolute cursor postions as screen-relative. You still lose the part of the buffer that was on-screen. --- win32/winansi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/win32/winansi.c b/win32/winansi.c index 0a637670c..d9e0835ce 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -124,7 +124,7 @@ static void erase_till_end_of_screen(void) &dummy); pos.X = 0; - for (pos.Y = sbi.dwCursorPosition.Y+1; pos.Y < sbi.dwSize.Y; pos.Y++) { + for (pos.Y = sbi.dwCursorPosition.Y+1; pos.Y < sbi.srWindow.Bottom; pos.Y++) { FillConsoleOutputCharacterA(console, ' ', sbi.dwSize.X, pos, &dummy); FillConsoleOutputAttribute(console, plain_attr, sbi.dwSize.X, @@ -159,12 +159,14 @@ static void move_cursor_column(int n) static void move_cursor(int x, int y) { COORD pos; + CONSOLE_SCREEN_BUFFER_INFO sbi; if (!console) return; - pos.X = x; - pos.Y = y; + GetConsoleScreenBufferInfo(console, &sbi); + pos.X = sbi.srWindow.Left + x; + pos.Y = sbi.srWindow.Top + y; SetConsoleCursorPosition(console, pos); } -- cgit v1.2.3-55-g6feb