]> git.wh0rd.org Git - nano.git/commitdiff
make the "smart home" routines handle multibyte blank characters
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 12 Jan 2005 05:10:53 +0000 (05:10 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Wed, 12 Jan 2005 05:10:53 +0000 (05:10 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2250 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/move.c
src/winio.c

index 2258d3b1ed6753b5c728902322e4dca75854f4a4..33f4e35c2614faa7fa3fc3ccdef52c35db9e51c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -97,11 +97,12 @@ CVS code -
          control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(), and
          make_mbchar(); changes to is_blank_char() (moved to chars.c),
          is_cntrl_char() (moved to chars.c), parse_char() (renamed
-         parse_mbchar() and moved to chars.c), do_verbatim_input(),
-         do_delete(), do_tab(), do_input(), do_output(), get_buffer(),
-         unget_input(), unget_kbinput(), get_input(), parse_kbinput(),
-         unparse_kbinput(), parse_verbatim_kbinput(),
-         do_statusbar_input(), do_statusbar_verbatim_kbinput(),
+         parse_mbchar() and moved to chars.c), do_home(),
+         do_verbatim_input(), do_delete(), do_tab(), do_input(),
+         do_output(), get_buffer(), unget_input(), unget_kbinput(),
+         get_input(), parse_kbinput(), unparse_kbinput(),
+         parse_verbatim_kbinput(), do_statusbar_input(),
+         do_statusbar_home(), do_statusbar_verbatim_kbinput(),
          do_statusbar_output(), and display_string(); removal of
          buffer_to_keys() and keys_to_buffer(). (DLR)
 - cut.c:
index 73729030a6e24b8bc87f1c3be0a5deee168917d8..3a81159248a92c0aa2433fb4c80fd9ac77c1d8e5 100644 (file)
@@ -57,10 +57,26 @@ void do_home(void)
 #ifndef NANO_SMALL
     if (ISSET(SMART_HOME)) {
        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->data[current_x] != '\0'; current_x++)
-           ;
+       current_x = 0;
+
+       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 ||
                current->data[current_x] == '\0')
index 328fafc3f9acb18f4f2d19fc7d91c8250710c6b1..f670e33f3ed9b45dd04db1c843eee96d6e20bc9e 100644 (file)
@@ -1803,9 +1803,27 @@ void do_statusbar_home(void)
 #ifndef NANO_SMALL
     if (ISSET(SMART_HOME)) {
        size_t statusbar_x_save = statusbar_x;
-       for (statusbar_x = 0; is_blank_char(answer[statusbar_x]) &&
-               statusbar_x < statusbar_xend; statusbar_x++)
-           ;
+       char *blank_mb = charalloc(mb_cur_max());
+       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 ||
                statusbar_x == statusbar_xend)
            statusbar_x = 0;