(svn r21407) -Codechange: prepare the text buffer code for limiting on number of characters besides the number of bytes

This commit is contained in:
rubidium
2010-12-05 22:22:54 +00:00
parent bbaa262b0d
commit 66c7f00b60
4 changed files with 43 additions and 11 deletions

View File

@@ -21,8 +21,10 @@
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
bool caret; ///< is the caret ("_") visible or not
uint16 caretpos; ///< the current position of the caret in the buffer, in bytes
@@ -37,6 +39,7 @@ bool InsertTextBufferChar(Textbuf *tb, uint32 key);
bool InsertTextBufferClipboard(Textbuf *tb);
bool MoveTextBufferPos(Textbuf *tb, int navmode);
void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 max_bytes, uint16 max_pixels);
void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 max_bytes, uint16 max_chars, uint16 max_pixels);
void UpdateTextBufferSize(Textbuf *tb);
/** Flags used in ShowQueryString() call */
@@ -44,6 +47,7 @@ enum QueryStringFlags {
QSF_NONE = 0,
QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change
QSF_ENABLE_DEFAULT = 0x02, ///< enable the 'Default' button ("\0" is returned)
QSF_LEN_IN_CHARS = 0x04, ///< the length of the string is counted in characters
};
DECLARE_ENUM_AS_BIT_SET(QueryStringFlags)