12 #ifndef TEXTBUF_TYPE_H 13 #define TEXTBUF_TYPE_H 17 #include "string_base.h" 48 explicit Textbuf(uint16 max_bytes, uint16 max_chars = UINT16_MAX);
52 void Assign(
const char *text);
53 void CDECL
Print(
const char *format, ...) WARN_FORMAT(2, 3);
59 bool InsertString(const
char *str,
bool marked, const
char *caret = NULL, const
char *insert_location = NULL, const
char *replacement_end = NULL);
76 void DeleteText(uint16 from, uint16 to,
bool update);
bool MovePos(uint16 keycode)
Handle text navigation with arrow keys left/right.
uint16 markend
the end position of the marked area in the buffer, in bytes
uint16 chars
the current size of the string in characters (including terminating '\0')
void CDECL void DeleteAll()
Delete every character in the textbuffer.
void CDECL Print(const char *format,...) WARN_FORMAT(2
Print a formatted string into the textbuffer.
bool InsertChar(uint32 key)
Insert a character to a textbuffer.
Helper/buffer for input fields.
uint16 bytes
the current size of the string in bytes (including terminating '\0')
Non-text change, e.g. cursor position.
void UpdateCaretPosition()
Update pixel position of the caret.
void UpdateStringIter()
Update the character iter after the text has changed.
void UpdateWidth()
Update pixel width of the text.
void UpdateMarkedText()
Update pixel positions of the marked text area.
bool InsertString(const char *str, bool marked, const char *caret=NULL, const char *insert_location=NULL, const char *replacement_end=NULL)
Insert a string into the text buffer.
bool caret
is the caret ("_") visible or not
uint16 markxoffs
the start position of the marked area in pixels
uint16 pixels
the current size of the string in pixels
Key does not affect editboxes.
HandleKeyPressResult
Return values for Textbuf::HandleKeypress.
bool InsertClipboard()
Insert a chunk of text from the clipboard onto the textbuffer.
bool CanDelChar(bool backspace)
Checks if it is possible to delete a character.
void DeleteText(uint16 from, uint16 to, bool update)
Delete a part of the text.
uint16 caretpos
the current position of the caret in the buffer, in bytes
uint32 StringID
Numeric value that represents a string, independent of the selected language.
CharSetFilter
Valid filter types for IsValidChar.
void Assign(StringID string)
Render a string into the textbuffer.
void DiscardMarkedText(bool update=true)
Discard any marked text.
Return or enter key pressed.
char *const buf
buffer in which text is saved
uint16 max_bytes
the maximum size of the buffer in bytes (including terminating '\0')
bool HandleCaret()
Handle the flashing of the caret.
uint16 max_chars
the maximum size of the buffer in characters (including terminating '\0')
uint16 caretxoffs
the current position of the caret in pixels
Class for iterating over different kind of parts of a string.
Types related to strings.
bool DeleteChar(uint16 keycode)
Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete fro...
CharSetFilter afilter
Allowed characters.
uint16 marklength
the length of the marked area in pixels
Textbuf(uint16 max_bytes, uint16 max_chars=UINT16_MAX)
Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buf...
uint32 WChar
Type for wide characters, i.e.
uint16 markpos
the start position of the marked area in the buffer, in bytes
void UpdateSize()
Update Textbuf type with its actual physical character and screenlength Get the count of characters i...