From 4c855b46134007428c372898d72aec57c3154485 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 31 Dec 2006 14:34:26 +0000 Subject: [PATCH] (svn r7700) -Fix (r7182): the caret 'randomly' jumped back and forth when getting a new randomised seed in the Generation World GUI. --- misc_gui.c | 3 ++- window.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/misc_gui.c b/misc_gui.c index 1bca0f997c..94917cfdf6 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -942,12 +942,13 @@ void UpdateTextBufferSize(Textbuf *tb) WChar c = Utf8Consume(&buf); tb->width = 0; + tb->length = 0; for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) { tb->width += GetCharacterWidth(FS_NORMAL, c); + tb->length += Utf8CharLen(c); } - tb->length = buf - tb->buf - 1; tb->caretpos = tb->length; tb->caretxoffs = tb->width; } diff --git a/window.h b/window.h index 877bf94438..2e6fd8b947 100644 --- a/window.h +++ b/window.h @@ -284,10 +284,10 @@ enum WindowDefaultPosition { typedef struct Textbuf { char *buf; /* buffer in which text is saved */ - uint16 maxlength, maxwidth; /* the maximum size of the buffer. Maxwidth specifies screensize in pixels */ - uint16 length, width; /* the current size of the string. Width specifies screensize in pixels */ + uint16 maxlength, maxwidth; /* the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes */ + uint16 length, width; /* the current size of the string. Width specifies screensize in pixels, length is in bytes */ bool caret; /* is the caret ("_") visible or not */ - uint16 caretpos; /* the current position of the caret in the buffer */ + uint16 caretpos; /* the current position of the caret in the buffer, in bytes */ uint16 caretxoffs; /* the current position of the caret in pixels */ } Textbuf;