From 60d938a3579786138cdec207b73fe24af47908ad Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 9 Apr 2014 20:27:34 +0100 Subject: lineedit: improve appearance of forward cursor movement --- libbb/lineedit.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index a49149921..71dd12a61 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -409,6 +409,42 @@ static void put_cur_glyph_and_inc_cursor(void) } } +#if ENABLE_PLATFORM_MINGW32 +static void inc_cursor(void) +{ + CHAR_T c = command_ps[cursor]; + unsigned width = 0; + int ofs_to_right; + + /* advance cursor */ + cursor++; + if (unicode_status == UNICODE_ON) { + IF_UNICODE_WIDE_WCHARS(width = cmdedit_x;) + c = adjust_width_and_validate_wc(&cmdedit_x, c); + IF_UNICODE_WIDE_WCHARS(width = cmdedit_x - width;) + } else { + cmdedit_x++; + } + + ofs_to_right = cmdedit_x - cmdedit_termw; + if (!ENABLE_UNICODE_WIDE_WCHARS || ofs_to_right <= 0) { + /* cursor remains on this line */ + printf(ESC"[1C"); + } + + if (ofs_to_right >= 0) { + /* we go to the next line */ + printf(ESC"[1B"); + bb_putchar('\r'); + cmdedit_y++; + if (!ENABLE_UNICODE_WIDE_WCHARS || ofs_to_right == 0) { + width = 0; + } + cmdedit_x = width; + } +} +#endif + /* Move to end of line (by printing all chars till the end) */ static void put_till_end_and_adv_cursor(void) { @@ -610,7 +646,11 @@ static void input_backspace(void) static void input_forward(void) { if (cursor < command_len) +#if !ENABLE_PLATFORM_MINGW32 put_cur_glyph_and_inc_cursor(); +#else + inc_cursor(); +#endif } #if ENABLE_FEATURE_TAB_COMPLETION -- cgit v1.2.3-55-g6feb