diff options
author | Ron Yorston <rmy@pobox.com> | 2014-04-09 20:27:34 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-04-09 20:32:13 +0100 |
commit | 60d938a3579786138cdec207b73fe24af47908ad (patch) | |
tree | 477bcc356d61ad284ed53b1d816d7ea72074bba9 | |
parent | 612f6c6c4ef0ff01dfdb6c87712209e2f80d18b7 (diff) | |
download | busybox-w32-60d938a3579786138cdec207b73fe24af47908ad.tar.gz busybox-w32-60d938a3579786138cdec207b73fe24af47908ad.tar.bz2 busybox-w32-60d938a3579786138cdec207b73fe24af47908ad.zip |
lineedit: improve appearance of forward cursor movement
-rw-r--r-- | libbb/lineedit.c | 40 |
1 files changed, 40 insertions, 0 deletions
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) | |||
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | #if ENABLE_PLATFORM_MINGW32 | ||
413 | static void inc_cursor(void) | ||
414 | { | ||
415 | CHAR_T c = command_ps[cursor]; | ||
416 | unsigned width = 0; | ||
417 | int ofs_to_right; | ||
418 | |||
419 | /* advance cursor */ | ||
420 | cursor++; | ||
421 | if (unicode_status == UNICODE_ON) { | ||
422 | IF_UNICODE_WIDE_WCHARS(width = cmdedit_x;) | ||
423 | c = adjust_width_and_validate_wc(&cmdedit_x, c); | ||
424 | IF_UNICODE_WIDE_WCHARS(width = cmdedit_x - width;) | ||
425 | } else { | ||
426 | cmdedit_x++; | ||
427 | } | ||
428 | |||
429 | ofs_to_right = cmdedit_x - cmdedit_termw; | ||
430 | if (!ENABLE_UNICODE_WIDE_WCHARS || ofs_to_right <= 0) { | ||
431 | /* cursor remains on this line */ | ||
432 | printf(ESC"[1C"); | ||
433 | } | ||
434 | |||
435 | if (ofs_to_right >= 0) { | ||
436 | /* we go to the next line */ | ||
437 | printf(ESC"[1B"); | ||
438 | bb_putchar('\r'); | ||
439 | cmdedit_y++; | ||
440 | if (!ENABLE_UNICODE_WIDE_WCHARS || ofs_to_right == 0) { | ||
441 | width = 0; | ||
442 | } | ||
443 | cmdedit_x = width; | ||
444 | } | ||
445 | } | ||
446 | #endif | ||
447 | |||
412 | /* Move to end of line (by printing all chars till the end) */ | 448 | /* Move to end of line (by printing all chars till the end) */ |
413 | static void put_till_end_and_adv_cursor(void) | 449 | static void put_till_end_and_adv_cursor(void) |
414 | { | 450 | { |
@@ -610,7 +646,11 @@ static void input_backspace(void) | |||
610 | static void input_forward(void) | 646 | static void input_forward(void) |
611 | { | 647 | { |
612 | if (cursor < command_len) | 648 | if (cursor < command_len) |
649 | #if !ENABLE_PLATFORM_MINGW32 | ||
613 | put_cur_glyph_and_inc_cursor(); | 650 | put_cur_glyph_and_inc_cursor(); |
651 | #else | ||
652 | inc_cursor(); | ||
653 | #endif | ||
614 | } | 654 | } |
615 | 655 | ||
616 | #if ENABLE_FEATURE_TAB_COMPLETION | 656 | #if ENABLE_FEATURE_TAB_COMPLETION |