aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-04-24 21:41:10 +0100
committerRon Yorston <rmy@pobox.com>2016-04-24 21:41:10 +0100
commitca947374282755978a257e50f3ab8cc35080a529 (patch)
tree28b94c4842766d27acc9b788a462696dc7f48bed
parenta89270b2be310c4255e9baa9a22966d3cd8ed9c8 (diff)
downloadbusybox-w32-ca947374282755978a257e50f3ab8cc35080a529.tar.gz
busybox-w32-ca947374282755978a257e50f3ab8cc35080a529.tar.bz2
busybox-w32-ca947374282755978a257e50f3ab8cc35080a529.zip
libbb/lineedit: limit cases where redraw clears to end of screen
The redraw() function only needs to clear to the end of the screen for ^L. In all other cases only clear to end of line.
-rw-r--r--libbb/lineedit.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 9f96d4a0b..7cd6ff0ce 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -568,6 +568,7 @@ static void input_backward(unsigned num)
568} 568}
569 569
570/* draw prompt, editor line, and clear tail */ 570/* draw prompt, editor line, and clear tail */
571#if !ENABLE_PLATFORM_MINGW32
571static void redraw(int y, int back_cursor) 572static void redraw(int y, int back_cursor)
572{ 573{
573 if (y > 0) /* up y lines */ 574 if (y > 0) /* up y lines */
@@ -578,6 +579,22 @@ static void redraw(int y, int back_cursor)
578 printf(SEQ_CLEAR_TILL_END_OF_SCREEN); 579 printf(SEQ_CLEAR_TILL_END_OF_SCREEN);
579 input_backward(back_cursor); 580 input_backward(back_cursor);
580} 581}
582#else
583static void mingw_redraw(int y, int back_cursor, int clear_screen)
584{
585 if (y > 0) /* up y lines */
586 printf(ESC"[%uA", y);
587 bb_putchar('\r');
588 put_prompt();
589 put_till_end_and_adv_cursor();
590 printf(clear_screen ?
591 SEQ_CLEAR_TILL_END_OF_SCREEN : SEQ_CLEAR_TILL_END_OF_LINE);
592 input_backward(back_cursor);
593}
594
595#define redraw(y, bc) mingw_redraw(y, bc, FALSE)
596#define redraw_and_clear_screen(y, bc) mingw_redraw(y, bc, TRUE)
597#endif
581 598
582/* Delete the char in front of the cursor, optionally saving it 599/* Delete the char in front of the cursor, optionally saving it
583 * for later putback */ 600 * for later putback */
@@ -611,7 +628,11 @@ static void input_delete(int save)
611 command_len--; 628 command_len--;
612 put_till_end_and_adv_cursor(); 629 put_till_end_and_adv_cursor();
613 /* Last char is still visible, erase it (and more) */ 630 /* Last char is still visible, erase it (and more) */
631#if !ENABLE_PLATFORM_MINGW32
632 printf(SEQ_CLEAR_TILL_END_OF_SCREEN);
633#else
614 printf(SEQ_CLEAR_TILL_END_OF_LINE); 634 printf(SEQ_CLEAR_TILL_END_OF_LINE);
635#endif
615 input_backward(cursor - j); /* back to old pos cursor */ 636 input_backward(cursor - j); /* back to old pos cursor */
616} 637}
617 638
@@ -2511,7 +2532,11 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2511 vi_case(CTRL('L')|VI_CMDMODE_BIT:) 2532 vi_case(CTRL('L')|VI_CMDMODE_BIT:)
2512 /* Control-l -- clear screen */ 2533 /* Control-l -- clear screen */
2513 printf(ESC"[H"); /* cursor to top,left */ 2534 printf(ESC"[H"); /* cursor to top,left */
2535#if !ENABLE_PLATFORM_MINGW32
2514 redraw(0, command_len - cursor); 2536 redraw(0, command_len - cursor);
2537#else
2538 redraw_and_clear_screen(0, command_len - cursor);
2539#endif
2515 break; 2540 break;
2516#if MAX_HISTORY > 0 2541#if MAX_HISTORY > 0
2517 case CTRL('N'): 2542 case CTRL('N'):