Widgets / Input & TextArea

Input & TextArea

Single-line and multi-line editors: block cursor, selection highlight, soft-wrap.

Input · TextAreahello world ┌──────────────────────────────────────────┐│This is a longer paragraph that ││soft-wraps across visual rows. │└──────────────────────────────────────────┘

Signature

Input.render
    (width: int) (textStyle: Style) (cursorStyle: Style)
    (focused: bool) (buf: TextBuffer)
    : LayoutNode<'msg>

TextArea.renderWrapped
    (width: int) (height: int) (textStyle: Style) (cursorStyle: Style)
    (focused: bool) (buf: TextBuffer)
    : LayoutNode<'msg>

Parameters

parameter type what it is
width / height int The cell box. Input scrolls horizontally to the cursor; renderWrapped word-wraps.
cursorStyle Style The block cursor and the selection highlight (inverse video reads as selected).
focused bool Draw the cursor and selection only when focused.
buf TextBuffer Text, cursor, and selection — your model owns it.

Notes

Both render a TextBuffer; the editing itself is the pure TextBuffer/TextEdit stack. Input scrolls horizontally to keep the cursor visible; TextArea.render scrolls both axes; TextArea.renderWrapped word-wraps each line and scrolls over the visual rows.

Example

// in update: feed input events through the keymap
{ m with Buffer = TextEdit.applyInput e m.Buffer }

// in view:
Input.render 40 theme.fg theme.selection m.Focused m.Buffer