make the "smart home" routines handle multibyte blank characters

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2250 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2005-01-12 05:10:53 +00:00
parent 4c6956b433
commit 8a31afdc55
3 changed files with 46 additions and 11 deletions

View File

@ -97,11 +97,12 @@ CVS code -
control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(), and control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(), and
make_mbchar(); changes to is_blank_char() (moved to chars.c), make_mbchar(); changes to is_blank_char() (moved to chars.c),
is_cntrl_char() (moved to chars.c), parse_char() (renamed is_cntrl_char() (moved to chars.c), parse_char() (renamed
parse_mbchar() and moved to chars.c), do_verbatim_input(), parse_mbchar() and moved to chars.c), do_home(),
do_delete(), do_tab(), do_input(), do_output(), get_buffer(), do_verbatim_input(), do_delete(), do_tab(), do_input(),
unget_input(), unget_kbinput(), get_input(), parse_kbinput(), do_output(), get_buffer(), unget_input(), unget_kbinput(),
unparse_kbinput(), parse_verbatim_kbinput(), get_input(), parse_kbinput(), unparse_kbinput(),
do_statusbar_input(), do_statusbar_verbatim_kbinput(), parse_verbatim_kbinput(), do_statusbar_input(),
do_statusbar_home(), do_statusbar_verbatim_kbinput(),
do_statusbar_output(), and display_string(); removal of do_statusbar_output(), and display_string(); removal of
buffer_to_keys() and keys_to_buffer(). (DLR) buffer_to_keys() and keys_to_buffer(). (DLR)
- cut.c: - cut.c:

View File

@ -57,10 +57,26 @@ void do_home(void)
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(SMART_HOME)) { if (ISSET(SMART_HOME)) {
size_t current_x_save = current_x; size_t current_x_save = current_x;
char *blank_mb = charalloc(mb_cur_max());
int blank_mb_len;
for (current_x = 0; is_blank_char(current->data[current_x]) && current_x = 0;
current->data[current_x] != '\0'; current_x++)
; while (current->data[current_x] != '\0') {
blank_mb_len = parse_mbchar(current->data + current_x,
blank_mb
#ifdef NANO_WIDE
, NULL
#endif
, NULL);
if (!is_blank_mbchar(blank_mb))
break;
current_x += blank_mb_len;
}
free(blank_mb);
if (current_x == current_x_save || if (current_x == current_x_save ||
current->data[current_x] == '\0') current->data[current_x] == '\0')

View File

@ -1803,9 +1803,27 @@ void do_statusbar_home(void)
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(SMART_HOME)) { if (ISSET(SMART_HOME)) {
size_t statusbar_x_save = statusbar_x; size_t statusbar_x_save = statusbar_x;
for (statusbar_x = 0; is_blank_char(answer[statusbar_x]) && char *blank_mb = charalloc(mb_cur_max());
statusbar_x < statusbar_xend; statusbar_x++) int blank_mb_len;
;
statusbar_x = 0;
while (statusbar_x < statusbar_xend) {
blank_mb_len = parse_mbchar(answer + statusbar_x,
blank_mb
#ifdef NANO_WIDE
, NULL
#endif
, NULL);
if (!is_blank_mbchar(blank_mb))
break;
statusbar_x += blank_mb_len;
}
free(blank_mb);
if (statusbar_x == statusbar_x_save || if (statusbar_x == statusbar_x_save ||
statusbar_x == statusbar_xend) statusbar_x == statusbar_xend)
statusbar_x = 0; statusbar_x = 0;