Changeset - r17572:9626d63a5636
[Not reviewed]
master
0 2 0
terkhen - 13 years ago 2011-04-17 18:45:36
terkhen@openttd.org
(svn r22346) -Cleanup: Textbuf::max_pixels is not required anymore.
2 files changed with 1 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/misc_gui.cpp
Show inline comments
 
@@ -1042,7 +1042,7 @@ bool InsertTextBufferChar(Textbuf *tb, W
 
{
 
	const byte charwidth = GetCharacterWidth(FS_NORMAL, key);
 
	uint16 len = (uint16)Utf8CharLen(key);
 
	if (tb->bytes + len <= tb->max_bytes && tb->chars + 1 <= tb->max_chars && (tb->max_pixels == 0 || tb->pixels + charwidth <= tb->max_pixels)) {
 
	if (tb->bytes + len <= tb->max_bytes && tb->chars + 1 <= tb->max_chars) {
 
		memmove(tb->buf + tb->caretpos + len, tb->buf + tb->caretpos, tb->bytes - tb->caretpos);
 
		Utf8Encode(tb->buf + tb->caretpos, key);
 
		tb->chars++;
 
@@ -1079,7 +1079,6 @@ bool InsertTextBufferClipboard(Textbuf *
 
		if (tb->chars + chars + 1   > tb->max_chars) break;
 

	
 
		byte char_pixels = GetCharacterWidth(FS_NORMAL, c);
 
		if (tb->max_pixels != 0 && pixels + tb->pixels + char_pixels > tb->max_pixels) break;
 

	
 
		pixels += char_pixels;
 
		bytes += len;
 
@@ -1181,7 +1180,6 @@ void InitializeTextBuffer(Textbuf *tb, c
 
	tb->buf        = buf;
 
	tb->max_bytes  = max_bytes;
 
	tb->max_chars  = max_chars;
 
	tb->max_pixels = 0;
 
	tb->caret      = true;
 
	UpdateTextBufferSize(tb);
 
}
src/textbuf_gui.h
Show inline comments
 
@@ -22,7 +22,6 @@ struct Textbuf {
 
	char *buf;                ///< buffer in which text is saved
 
	uint16 max_bytes;         ///< the maximum size of the buffer in bytes (including terminating '\0')
 
	uint16 max_chars;         ///< the maximum size of the buffer in characters (including terminating '\0')
 
	uint16 max_pixels;        ///< the maximum size of the buffer in pixels
 
	uint16 bytes;             ///< the current size of the string in bytes (including terminating '\0')
 
	uint16 chars;             ///< the current size of the string in characters (including terminating '\0')
 
	uint16 pixels;            ///< the current size of the string in pixels
0 comments (0 inline, 0 general)