nxt::tui::TextField struct

Single-line editable text with a UTF-8-aware cursor.

cursor_byte is always at a UTF-8 boundary in the range [0, text.size()]. Edit methods clamp it defensively in case text was modified directly.

Public functions

auto cell_count() const →  width_t noexcept
Display column count.
void clear() noexcept
Clear the field and reset the cursor to the beginning.
auto cursor_cell() const →  width_t noexcept
Cursor column.
auto empty() const →  bool noexcept
True when the field contains no text.
auto erase_left() →  bool noexcept
auto erase_right() →  bool noexcept
Delete the UTF-8 cell to the right of the cursor (forward delete).
void insert(std::string_view bytes)
Insert UTF-8 bytes at the cursor and advance.
auto move_end() →  bool noexcept
Move the cursor to the end of the field.
auto move_home() →  bool noexcept
Move the cursor to the beginning of the field.
auto move_left() →  bool noexcept
Move the cursor one UTF-8 cell left.
auto move_right() →  bool noexcept
Move the cursor one UTF-8 cell right.

Public variables

std::string text
utf8::byte_offset_t cursor_byte

Function documentation

bool nxt::tui::TextField::erase_left() noexcept

Delete the UTF-8 cell to the left of the cursor (backspace). Returns true if anything was deleted.