From 248a2600a2f4b442101ad568d1994b908bb28d4b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 26 Apr 2016 16:48:38 +0100 Subject: winansi: revert to previous console behaviour for vi/less Recent changes to make the Windows console behave more like a *nix terminal didn't work too well for vi/less. On *nix the terminal buffer can't be scrolled while such screen-based applications are running. In the Windows console this remained possible and led to confusion. Add a new routine to allow vi/less to revert to their previous behaviour where the cursor is positioned at the top of the buffer and the entire buffer is cleared. --- win32/winansi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'win32') 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) &dummy); FillConsoleOutputAttribute(console, plain_attr, len, sbi.dwCursorPosition, &dummy); +} + +void reset_screen(void) +{ + CONSOLE_SCREEN_BUFFER_INFO sbi; + COORD pos; + DWORD dummy, len; + if (!console) + return; + + /* move to start of screen buffer and clear it all */ + GetConsoleScreenBufferInfo(console, &sbi); + pos.X = 0; + pos.Y = 0; + SetConsoleCursorPosition(console, pos); + len = sbi.dwSize.X * sbi.dwSize.Y; + FillConsoleOutputCharacterA(console, ' ', len, pos, &dummy); + FillConsoleOutputAttribute(console, plain_attr, len, pos, &dummy); } void move_cursor_row(int n) -- cgit v1.2.3-55-g6feb