# HG changeset patch # User Darkvater # Date 1168169843 0 # Node ID 7431074c65eec7e21876bf25aa6eac455d1a3625 # Parent 3047d553859c3892159ad81e7dc10e9d54ead0be (svn r7945) -Backport from trunk (r7700): - Caret randomly jumping back&forth for new randomseed (r7182) diff -r 3047d553859c -r 7431074c65ee misc_gui.c --- a/misc_gui.c Sun Jan 07 11:34:20 2007 +0000 +++ b/misc_gui.c Sun Jan 07 11:37:23 2007 +0000 @@ -942,12 +942,13 @@ 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 -r 3047d553859c -r 7431074c65ee window.h --- a/window.h Sun Jan 07 11:34:20 2007 +0000 +++ b/window.h Sun Jan 07 11:37:23 2007 +0000 @@ -283,10 +283,10 @@ 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;