mirror of https://github.com/OpenTTD/OpenTTD
(svn r7945) -Backport from trunk (r7700):
- Caret randomly jumping back&forth for new randomseed (r7182)release/0.5
parent
58d18a3ef3
commit
563857d5bd
|
@ -942,12 +942,13 @@ void UpdateTextBufferSize(Textbuf *tb)
|
||||||
WChar c = Utf8Consume(&buf);
|
WChar c = Utf8Consume(&buf);
|
||||||
|
|
||||||
tb->width = 0;
|
tb->width = 0;
|
||||||
|
tb->length = 0;
|
||||||
|
|
||||||
for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) {
|
for (; c != '\0' && tb->length < (tb->maxlength - 1); c = Utf8Consume(&buf)) {
|
||||||
tb->width += GetCharacterWidth(FS_NORMAL, c);
|
tb->width += GetCharacterWidth(FS_NORMAL, c);
|
||||||
|
tb->length += Utf8CharLen(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
tb->length = buf - tb->buf - 1;
|
|
||||||
tb->caretpos = tb->length;
|
tb->caretpos = tb->length;
|
||||||
tb->caretxoffs = tb->width;
|
tb->caretxoffs = tb->width;
|
||||||
}
|
}
|
||||||
|
|
6
window.h
6
window.h
|
@ -283,10 +283,10 @@ enum {
|
||||||
|
|
||||||
typedef struct Textbuf {
|
typedef struct Textbuf {
|
||||||
char *buf; /* buffer in which text is saved */
|
char *buf; /* buffer in which text is saved */
|
||||||
uint16 maxlength, maxwidth; /* the maximum size of the buffer. Maxwidth 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 */
|
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 */
|
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 */
|
uint16 caretxoffs; /* the current position of the caret in pixels */
|
||||||
} Textbuf;
|
} Textbuf;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue