Textboxes

EsTextboxCreate

EsTextbox *EsTextboxCreate(EsElement *parent, EsTextboxFlags flags = ES_FLAGS_DEFAULT, EsStyleID style = 0);

Creates a new empty textbox. Single-line by default; use ES_TEXTBOX_MULTILINE for multiple lines.

EsTextboxFind

bool EsTextboxFind(EsTextbox *textbox, STRING string, int32_t *line, int32_t *byte, EsTextboxFindFlags flags);

Searches for the given string, starting at the position in line/byte. Returns true if found and writes the found position back to line/byte. The search wraps around the end of the text.

EsTextboxInsert

void EsTextboxInsert(EsTextbox *textbox, STRING string = BLANK_STRING, bool sendUpdatedMessage = true);

Deletes existing selection first.

EsTextboxAppend

void EsTextboxAppend(EsTextbox *textbox, STRING string = BLANK_STRING, bool sendUpdatedMessage = true);

Ignores the user's selection.

EsTextboxGetContents

char *EsTextboxGetContents(EsTextbox *textbox, size_t *bytes = ES_NULL, EsTextboxGetContentsFlags flags = ES_FLAGS_DEFAULT);

Result will be zero-terminated; free with EsHeapFree.

EsTextboxGetContentsAsDouble

double EsTextboxGetContentsAsDouble(EsTextbox *textbox, EsTextboxGetContentsFlags flags = ES_FLAGS_DEFAULT);

Parses the current contents of the textbox as a double and returns the result.

EsTextboxGetLineLength

size_t EsTextboxGetLineLength(EsTextbox *textbox, uintptr_t line = 0);

Returns the length of the given line, in bytes.

EsTextboxGetSelection

void EsTextboxGetSelection(EsTextbox *textbox, int32_t *fromLine, int32_t *fromByte, int32_t *toLine, int32_t *toByte);

Writes the current selection to the output parameters. The two positions are the two carets; an equal start and end means no selection.

EsTextboxMoveCaret

void EsTextboxMoveCaret(EsTextbox *textbox, int32_t line, int32_t byte);

Moves both carets to the given position, clearing the selection.

EsTextboxSetSelection

void EsTextboxSetSelection(EsTextbox *textbox, int32_t fromLine, int32_t fromByte, int32_t toLine, int32_t toByte);

Sets the selection range. A byte position of -1 means the end of the line.

EsTextboxSelectAll

void EsTextboxSelectAll(EsTextbox *textbox);

Selects all the text in the textbox.

EsTextboxClear

void EsTextboxClear(EsTextbox *textbox, bool sendUpdatedMessage);

Deletes all the text. If sendUpdatedMessage is true, sends the update message.

EsTextboxUseNumberOverlay

void EsTextboxUseNumberOverlay(EsTextbox *textbox, bool defaultBehaviour);

Enables an overlay for editing a number by dragging vertically or using the arrow keys. Requires edit-based mode and a single-line textbox. If defaultBehaviour is true, the textbox applies the value changes itself.

EsTextboxUseBreadcrumbOverlay

void EsTextboxUseBreadcrumbOverlay(EsTextbox *textbox);

Enables a breadcrumb bar overlay above the textbox contents. Requires edit-based mode. The application must handle the ES_MSG_TEXTBOX_GET_BREADCRUMB and ES_MSG_TEXTBOX_ACTIVATE_BREADCRUMB messages.

EsTextboxMoveCaretRelative

void EsTextboxMoveCaretRelative(EsTextbox *textbox, EsTextboxMoveCaretRelativeFlags flags);

Moves one or both carets by a unit selected by the flags. The unit is one of the ES_TEXTBOX_MOVE_CARET_SINGLE/WORD/LINE/VERTICAL/ALL values.

EsTextboxEnsureCaretVisible

void EsTextboxEnsureCaretVisible(EsTextbox *textbox, bool verticallyCenter = false);

Scrolls the textbox so that the caret is visible. If verticallyCenter is true, the caret is centered vertically.

EsTextboxSetUndoManager

void EsTextboxSetUndoManager(EsTextbox *textbox, EsUndoManager *manager);

Replaces the textbox's undo manager. Must be called while the textbox is not focused, and only once.

EsTextboxSetTextSize

void EsTextboxSetTextSize(EsTextbox *textbox, uint16_t size);

Sets the text size of the textbox, in pixels.

EsTextboxSetFont

void EsTextboxSetFont(EsTextbox *textbox, EsFont font);

Sets the font of the textbox's text.

EsTextboxSetupSyntaxHighlighting

void EsTextboxSetupSyntaxHighlighting(EsTextbox *textbox, EsSyntaxHighlightingLanguage language, const uint32_t *customColors = ES_NULL, size_t customColorCount = 0);

Enables syntax highlighting with the given language. customColors overrides the built-in colors; at most 8 colors are used.

EsTextboxStartEdit

void EsTextboxStartEdit(EsTextbox *textbox);

Starts an edit for an edit-based textbox and sends the ES_MSG_TEXTBOX_EDIT_START message. If the message is not handled, the whole text is selected first.

EsTextboxEnableSmartReplacement

void EsTextboxEnableSmartReplacement(EsTextbox *textbox, bool enabled);

e.g. smart quotes.

EsTextboxSetReadOnly

void EsTextboxSetReadOnly(EsTextbox *textbox, bool readOnly);

Prevents the user from modifying the contents of the textbox; EsTextboxInsert will still work. Incompatible with ES_TEXTBOX_EDIT_BASED. Undo events will not be created.