Skip to content

Modern Tui TuiTextInputState

Paul Squires edited this page Oct 19, 2026 · 6 revisions

Home › Terminal TUI Library › Input Widgets › TuiTextInputState

TuiTextInputState

Holds a text box's text, cursor, selection and scroll position.

Syntax

type TuiTextInputState
    as ustring text
    as int32 cursor      '' CODE UNITS
    as int32 selAnchor   '' -1 = no selection
    as int32 scrollX     '' COLUMNS
end type

Description

The editor's state, owned by you. Note the units: cursor and selAnchor are UTF-16 code-unit indices while scrollX is columns -- they are different things and conflating them is how a cursor ends up half inside a CJK glyph.

Example

#import "std/tui"
using tui

dim as TuiTextInputState st
TuiTextInputStateInit( st )
print st.cursor, st.selAnchor     '' 0 -1 -- no selection

st.text = "hello"
st.cursor = 5
print st.text, st.cursor          '' hello 5

See also

TuiTextInput TuiTextInput.SelectionEnd TuiTextArea TuiCheckbox
TuiTextInputStateInit TuiTextInput.DeleteSelection TuiTextAreaState TuiRadioGroup
TuiTextInput.SelectionStart TuiTextInput.Insert TuiTextAreaStateInit TuiSelect

Library: Terminal TUI Library
Category: Terminal TUI Library
Documented under: Input Widgets
Working examples: hello.tiko · form.tiko · dashboard.tiko


Home · Keyword Index

Clone this wiki locally