diff options
author | Darkvater <darkvater@openttd.org> | 2007-03-04 00:49:40 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2007-03-04 00:49:40 +0000 |
commit | 0d643c624b0195c6c24fceb4ae4019956a6579ac (patch) | |
tree | 95ff058757206f56039f036e53389e09510090b5 /src/misc_gui.cpp | |
parent | ead8c82ab69799f2e0c2f91905b3b71f1c9dc7ef (diff) | |
download | openttd-0d643c624b0195c6c24fceb4ae4019956a6579ac.tar.xz |
(svn r9003) -Codechange: Introduce a function Utf8PrevCharLen that finds the starting character of an UTF-8 sequence from a given position and returns the length to the first UTF-8 encoding byte of that sequence.
Diffstat (limited to 'src/misc_gui.cpp')
-rw-r--r-- | src/misc_gui.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index b736de9c4..306289eab 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -805,11 +805,7 @@ static void DelChar(Textbuf *tb, bool backspace) uint width; size_t len; - if (backspace) { - do { - tb->caretpos--; - } while (IsUtf8Part(*(tb->buf + tb->caretpos))); - } + if (backspace) tb->caretpos -= Utf8PrevCharLen(tb->buf + tb->caretpos); len = Utf8Decode(&c, tb->buf + tb->caretpos); width = GetCharacterWidth(FS_NORMAL, c); @@ -892,10 +888,7 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode) if (tb->caretpos != 0) { WChar c; - do { - tb->caretpos--; - } while (IsUtf8Part(*(tb->buf + tb->caretpos))); - + tb->caretpos -= Utf8PrevCharLen(tb->buf + tb->caretpos); Utf8Decode(&c, tb->buf + tb->caretpos); tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, c); |