diff options
author | Ron Yorston <rmy@pobox.com> | 2016-04-26 13:13:59 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-04-26 13:48:18 +0100 |
commit | aa3595b3d38ecc6b86b351ac215829f0de58d911 (patch) | |
tree | 2f78acabf0a2babca275f0ef4d32ad9cd1968b43 /win32 | |
parent | fd476d8629d489245e18ec278d3c846ab1359eec (diff) | |
download | busybox-w32-ansi.tar.gz busybox-w32-ansi.tar.bz2 busybox-w32-ansi.zip |
winansi: add a routine to clear the screen bufferansi
And use it to restore the old behaviour of vi and less: they reset
the cursor to the top of the buffer and clear it.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/winansi.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index ebe831593..d61e8a2cf 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -122,7 +122,25 @@ static void erase_till_end_of_screen(void) | |||
122 | &dummy); | 122 | &dummy); |
123 | FillConsoleOutputAttribute(console, plain_attr, len, sbi.dwCursorPosition, | 123 | FillConsoleOutputAttribute(console, plain_attr, len, sbi.dwCursorPosition, |
124 | &dummy); | 124 | &dummy); |
125 | } | ||
126 | |||
127 | void reset_screen(void) | ||
128 | { | ||
129 | CONSOLE_SCREEN_BUFFER_INFO sbi; | ||
130 | COORD pos; | ||
131 | DWORD dummy, len; | ||
125 | 132 | ||
133 | if (!console) | ||
134 | return; | ||
135 | |||
136 | /* move to start of screen buffer and clear it all */ | ||
137 | GetConsoleScreenBufferInfo(console, &sbi); | ||
138 | pos.X = 0; | ||
139 | pos.Y = 0; | ||
140 | SetConsoleCursorPosition(console, pos); | ||
141 | len = sbi.dwSize.X * sbi.dwSize.Y; | ||
142 | FillConsoleOutputCharacterA(console, ' ', len, pos, &dummy); | ||
143 | FillConsoleOutputAttribute(console, plain_attr, len, pos, &dummy); | ||
126 | } | 144 | } |
127 | 145 | ||
128 | void move_cursor_row(int n) | 146 | void move_cursor_row(int n) |