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