text_input (cellium v0.1.0)
View SourceText input widget module for editable text fields.
This module provides an interactive text input widget that handles keyboard events and supports optional word wrapping with vertical scrolling.
Usage
Basic text input:
text_input:new(my_input)Text input with wrapping (requires expand or size to get width/height from layout):
(text_input:new(my_input))#{wrap => true, expand => true}Properties
wrap(boolean): Enable word wrapping. When true, text wraps at the widget's width and shows only the last N lines that fit in height. Default: falseexpand(boolean): Request the layout system to assign width and height. Required when using wrap. Default: falsewidth(integer): Set by the layout system when expand is true. Determines wrap width.height(integer): Set by the layout system when expand is true. Determines how many wrapped lines to show (shows last N lines).state(map): Text input state containing text and cursor position
Wrapping Behavior
When wrap is enabled:
- Text wraps horizontally at word boundaries (using greedy wrap algorithm)
- Only the last N lines (fitting in height) are displayed
- Earlier lines are hidden but not discarded
- Cursor follows correctly across wrapped lines
Summary
Functions
Handles keyboard events for the text input.
Creates a new text input widget.
Renders the text input widget (unfocused state).
Renders the text input widget (focused state) with cursor.
Creates a text input state with the given text.
Functions
Handles keyboard events for the text input.
Processes keyboard input including character insertion, backspace, and cursor movement (left/right arrow keys).
Creates a new text input widget.
To enable word wrapping, set the wrap property to true and add expand
so the layout system assigns width and height:
(text_input:new(my_id))#{wrap => true, expand => true}
Renders the text input widget (unfocused state).
If wrap is enabled and width/height are set by layout:
- Text wraps at word boundaries at the widget's width
- Only the last N lines (fitting in height) are displayed
Renders the text input widget (focused state) with cursor.
If wrap is enabled and width/height are set by layout:
- Text wraps at word boundaries at the widget's width
- Only the last N lines (fitting in height) are displayed
- Cursor position is calculated correctly across wrapped lines
Creates a text input state with the given text.