diff options
author | Ron Yorston <rmy@pobox.com> | 2016-04-26 11:12:42 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-04-26 11:12:42 +0100 |
commit | fd476d8629d489245e18ec278d3c846ab1359eec (patch) | |
tree | da17890f38659af2d2fb6b00872fe7b81a2472b9 /win32 | |
parent | 9a7f488564610817a7b9d9d44d7db154e444eb7d (diff) | |
download | busybox-w32-fd476d8629d489245e18ec278d3c846ab1359eec.tar.gz busybox-w32-fd476d8629d489245e18ec278d3c846ab1359eec.tar.bz2 busybox-w32-fd476d8629d489245e18ec278d3c846ab1359eec.zip |
libbb/lineedit: scroll to cursor position on any keypress
Also improve erase_till_end_of_screen. Based on suggestions from
GitHub user avih.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/winansi.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index 78d5d5f5c..ebe831593 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -109,31 +109,23 @@ static void erase_in_line(void) | |||
109 | static void erase_till_end_of_screen(void) | 109 | static void erase_till_end_of_screen(void) |
110 | { | 110 | { |
111 | CONSOLE_SCREEN_BUFFER_INFO sbi; | 111 | CONSOLE_SCREEN_BUFFER_INFO sbi; |
112 | COORD pos; | 112 | DWORD dummy, len; |
113 | DWORD dummy; | ||
114 | 113 | ||
115 | if (!console) | 114 | if (!console) |
116 | return; | 115 | return; |
117 | 116 | ||
118 | GetConsoleScreenBufferInfo(console, &sbi); | 117 | GetConsoleScreenBufferInfo(console, &sbi); |
119 | FillConsoleOutputCharacterA(console, ' ', | 118 | len = sbi.dwSize.X - sbi.dwCursorPosition.X + |
120 | sbi.dwSize.X - sbi.dwCursorPosition.X, sbi.dwCursorPosition, | 119 | sbi.dwSize.X * (sbi.srWindow.Bottom - sbi.dwCursorPosition.Y); |
120 | |||
121 | FillConsoleOutputCharacterA(console, ' ', len, sbi.dwCursorPosition, | ||
121 | &dummy); | 122 | &dummy); |
122 | FillConsoleOutputAttribute(console, plain_attr, | 123 | FillConsoleOutputAttribute(console, plain_attr, len, sbi.dwCursorPosition, |
123 | sbi.dwSize.X - sbi.dwCursorPosition.X, sbi.dwCursorPosition, | ||
124 | &dummy); | 124 | &dummy); |
125 | 125 | ||
126 | pos.X = 0; | ||
127 | for (pos.Y = sbi.dwCursorPosition.Y+1; pos.Y <= sbi.srWindow.Bottom; | ||
128 | pos.Y++) { | ||
129 | FillConsoleOutputCharacterA(console, ' ', sbi.dwSize.X, | ||
130 | pos, &dummy); | ||
131 | FillConsoleOutputAttribute(console, plain_attr, sbi.dwSize.X, | ||
132 | pos, &dummy); | ||
133 | } | ||
134 | } | 126 | } |
135 | 127 | ||
136 | static void move_cursor_row(int n) | 128 | void move_cursor_row(int n) |
137 | { | 129 | { |
138 | CONSOLE_SCREEN_BUFFER_INFO sbi; | 130 | CONSOLE_SCREEN_BUFFER_INFO sbi; |
139 | 131 | ||