diff options
author | Ron Yorston <rmy@pobox.com> | 2016-04-25 08:50:48 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-04-25 08:50:48 +0100 |
commit | ad85fec9f3c913b2a8cafb24900966b13dc7fc5c (patch) | |
tree | 662d8d81c5a2d8ec6bb2d4f5cdc7b21cc3a46dd7 | |
parent | a93d86689d85015b5bf465ab0ef810449bb55d41 (diff) | |
download | busybox-w32-ad85fec9f3c913b2a8cafb24900966b13dc7fc5c.tar.gz busybox-w32-ad85fec9f3c913b2a8cafb24900966b13dc7fc5c.tar.bz2 busybox-w32-ad85fec9f3c913b2a8cafb24900966b13dc7fc5c.zip |
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.
-rw-r--r-- | win32/winansi.c | 8 |
1 files 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) | |||
124 | &dummy); | 124 | &dummy); |
125 | 125 | ||
126 | pos.X = 0; | 126 | pos.X = 0; |
127 | for (pos.Y = sbi.dwCursorPosition.Y+1; pos.Y < sbi.dwSize.Y; pos.Y++) { | 127 | for (pos.Y = sbi.dwCursorPosition.Y+1; pos.Y < sbi.srWindow.Bottom; pos.Y++) { |
128 | FillConsoleOutputCharacterA(console, ' ', sbi.dwSize.X, | 128 | FillConsoleOutputCharacterA(console, ' ', sbi.dwSize.X, |
129 | pos, &dummy); | 129 | pos, &dummy); |
130 | FillConsoleOutputAttribute(console, plain_attr, sbi.dwSize.X, | 130 | FillConsoleOutputAttribute(console, plain_attr, sbi.dwSize.X, |
@@ -159,12 +159,14 @@ static void move_cursor_column(int n) | |||
159 | static void move_cursor(int x, int y) | 159 | static void move_cursor(int x, int y) |
160 | { | 160 | { |
161 | COORD pos; | 161 | COORD pos; |
162 | CONSOLE_SCREEN_BUFFER_INFO sbi; | ||
162 | 163 | ||
163 | if (!console) | 164 | if (!console) |
164 | return; | 165 | return; |
165 | 166 | ||
166 | pos.X = x; | 167 | GetConsoleScreenBufferInfo(console, &sbi); |
167 | pos.Y = y; | 168 | pos.X = sbi.srWindow.Left + x; |
169 | pos.Y = sbi.srWindow.Top + y; | ||
168 | SetConsoleCursorPosition(console, pos); | 170 | SetConsoleCursorPosition(console, pos); |
169 | } | 171 | } |
170 | 172 | ||