]> granicus.if.org Git - neomutt/commitdiff
More wide-char patches from EGE.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 3 Jan 2001 13:39:48 +0000 (13:39 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 3 Jan 2001 13:39:48 +0000 (13:39 +0000)
enter.c
mbyte.c

diff --git a/enter.c b/enter.c
index 169e64d63932942dc86235f92071759b6d953eac..50dca39ada3a3a67c6d405518f9cdca6b4c7dcc7 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -45,6 +45,9 @@ static int my_wcwidth (wchar_t wc)
   return 10;
 }
 
+/* combining mark / non-spacing character */
+#define COMB_CHAR(wc) (IsWPrint (wc) && !wcwidth (wc))
+
 static int my_wcswidth (const wchar_t *s, size_t n)
 {
   int w = 0;
@@ -283,7 +286,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
          else
          {
            i = state->curpos;
-           while (i && !wcwidth (state->wbuf[i - 1]))
+           while (i && COMB_CHAR (state->wbuf[i - 1]))
              --i;
            if (i)
              --i;
@@ -314,7 +317,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
            BEEP ();
          else
          {
-           while (state->curpos && !wcwidth (state->wbuf[state->curpos - 1]))
+           while (state->curpos && COMB_CHAR (state->wbuf[state->curpos - 1]))
              state->curpos--;
            if (state->curpos)
              state->curpos--;
@@ -327,7 +330,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
          else
          {
            ++state->curpos;
-           while (state->curpos < state->lastchar && !wcwidth (state->wbuf[state->curpos]))
+           while (state->curpos < state->lastchar && COMB_CHAR (state->wbuf[state->curpos]))
              ++state->curpos;
          }
          break;
@@ -388,11 +391,11 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
          else
          {
            i = state->curpos;
-           while (i < state->lastchar && !wcwidth (state->wbuf[i]))
+           while (i < state->lastchar && COMB_CHAR (state->wbuf[i]))
              ++i;
            if (i < state->lastchar)
              ++i;
-           while (i < state->lastchar && !wcwidth (state->wbuf[i]))
+           while (i < state->lastchar && COMB_CHAR (state->wbuf[i]))
              ++i;
            memmove (state->wbuf + state->curpos, state->wbuf + i, (state->lastchar - i) * sizeof (wchar_t));
            state->lastchar -= i - state->curpos;
diff --git a/mbyte.c b/mbyte.c
index f895a17941757762f533eba792c77c9c7193cd23..b64961c4f0813349654f7f41ae3f8fd5b56942b7 100644 (file)
--- a/mbyte.c
+++ b/mbyte.c
@@ -348,8 +348,10 @@ int wcwidth (wchar_t wc)
     if (!charset_is_ja)
     {
       /* 8-bit case */
-      if (0 <= wc && wc < 256)
-       return IsPrint (wc) ? 1 : -1;
+      if (!wc)
+       return 0;
+      else if ((0 <= wc && wc < 256) && IsPrint (wc))
+       return 1;
       else
        return -1;
     }