diff options
author | Ron Yorston <rmy@pobox.com> | 2016-04-26 16:45:09 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-04-26 16:45:09 +0100 |
commit | 601f47a2ebcc54c995359c6f87e0eed932329e89 (patch) | |
tree | da17890f38659af2d2fb6b00872fe7b81a2472b9 | |
parent | 0d9e95c2dbc422ffa3db10132db3154357c461be (diff) | |
download | busybox-w32-601f47a2ebcc54c995359c6f87e0eed932329e89.tar.gz busybox-w32-601f47a2ebcc54c995359c6f87e0eed932329e89.tar.bz2 busybox-w32-601f47a2ebcc54c995359c6f87e0eed932329e89.zip |
lineedit: move console viewport to cursor on keypress
When a normal *nix terminal has been scrolled back through its
buffer, any keypress will return to the cursor position. Add code
to lineedit.c to do the same for the Windows console.
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | libbb/lineedit.c | 5 | ||||
-rw-r--r-- | win32/winansi.c | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/include/mingw.h b/include/mingw.h index f30338ba8..5faef41bf 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -154,6 +154,7 @@ int mingw_pclose(FILE *fd); | |||
154 | * ANSI emulation wrappers | 154 | * ANSI emulation wrappers |
155 | */ | 155 | */ |
156 | 156 | ||
157 | void move_cursor_row(int n); | ||
157 | int winansi_putchar(int c); | 158 | int winansi_putchar(int c); |
158 | int winansi_puts(const char *s); | 159 | int winansi_puts(const char *s); |
159 | size_t winansi_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); | 160 | size_t winansi_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 04361b509..e7b9ddfa1 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -2440,6 +2440,11 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2440 | 2440 | ||
2441 | fflush_all(); | 2441 | fflush_all(); |
2442 | ic = ic_raw = lineedit_read_key(read_key_buffer, timeout); | 2442 | ic = ic_raw = lineedit_read_key(read_key_buffer, timeout); |
2443 | #if ENABLE_PLATFORM_MINGW32 | ||
2444 | /* scroll to cursor position on any keypress */ | ||
2445 | if (isatty(fileno(stdin)) && isatty(fileno(stdout))) | ||
2446 | move_cursor_row(0); | ||
2447 | #endif | ||
2443 | 2448 | ||
2444 | #if ENABLE_FEATURE_REVERSE_SEARCH | 2449 | #if ENABLE_FEATURE_REVERSE_SEARCH |
2445 | again: | 2450 | again: |
diff --git a/win32/winansi.c b/win32/winansi.c index 5d4adbec8..ebe831593 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -125,7 +125,7 @@ static void erase_till_end_of_screen(void) | |||
125 | 125 | ||
126 | } | 126 | } |
127 | 127 | ||
128 | static void move_cursor_row(int n) | 128 | void move_cursor_row(int n) |
129 | { | 129 | { |
130 | CONSOLE_SCREEN_BUFFER_INFO sbi; | 130 | CONSOLE_SCREEN_BUFFER_INFO sbi; |
131 | 131 | ||