|
OpenTTD Source
14.0-beta3
|
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 std::string_view text);
56 bool InsertString(
const char *str,
bool marked,
const char *
caret =
nullptr,
const char *insert_location =
nullptr,
const char *replacement_end =
nullptr);
71 std::unique_ptr<StringIterator> char_iter;
75 void DeleteText(uint16_t from, uint16_t to,
bool update);
@ HKPR_EDITING
Textbuf content changed.
bool InsertChar(char32_t key)
Insert a character to a textbuffer.
@ HKPR_CONFIRM
Return or enter key pressed.
uint16_t markend
the end position of the marked area in the buffer, in bytes
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void Assign(StringID string)
Render a string into the textbuffer.
uint16_t max_bytes
the maximum size of the buffer in bytes (including terminating '\0')
uint16_t pixels
the current size of the string in pixels
uint16_t caretpos
the current position of the caret in the buffer, in bytes
uint16_t markpos
the start position of the marked area in the buffer, in bytes
bool MovePos(uint16_t keycode)
Handle text navigation with arrow keys left/right.
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.
char *const buf
buffer in which text is saved
bool HandleCaret()
Handle the flashing of the caret.
uint16_t markxoffs
the start position of the marked area in pixels
uint16_t bytes
the current size of the string in bytes (including terminating '\0')
const char * GetText() const
Get the current text.
HandleKeyPressResult
Return values for Textbuf::HandleKeypress.
void UpdateMarkedText()
Update pixel positions of the marked text area.
bool caret
is the caret ("_") visible or not
void UpdateCaretPosition()
Update pixel position of the caret.
CharSetFilter afilter
Allowed characters.
bool DeleteChar(uint16_t keycode)
Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete fro...
Textbuf(uint16_t max_bytes, uint16_t max_chars=UINT16_MAX)
Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buf...
bool InsertClipboard()
Insert a chunk of text from the clipboard onto the textbuffer.
uint16_t max_chars
the maximum size of the buffer in characters (including terminating '\0')
void DeleteText(uint16_t from, uint16_t to, bool update)
Delete a part of the text.
void UpdateSize()
Update Textbuf type with its actual physical character and screenlength Get the count of characters i...
uint16_t marklength
the length of the marked area in pixels
@ HKPR_CANCEL
Escape key pressed.
void UpdateStringIter()
Update the character iter after the text has changed.
uint16_t chars
the current size of the string in characters (including terminating '\0')
@ HKPR_NOT_HANDLED
Key does not affect editboxes.
void UpdateWidth()
Update pixel width of the text.
uint16_t caretxoffs
the current position of the caret in pixels
bool CanDelChar(bool backspace)
Checks if it is possible to delete a character.
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.