Skip to main content

Textarea

Textarea widgetTextarea widget

Multi-line text input. It collects a string that may contain newlines.

$p->textarea('notes', 'Tasting notes')
->default("Crisp and sweet\nHint of citrus") // Initial value (newlines allowed).
->externalEditor(); // Allow a handoff to $EDITOR / $VISUAL.

Runnable script: playground/02-widgets/textarea.php.

Options

NameDescriptionRequiredDefault
default()Initial value; may contain newlines.No'' (empty)
externalEditor()Allow a handoff to the reader's $EDITOR / $VISUAL.NoOff

With externalEditor() on, Ctrl-E suspends the TUI, opens the editor seeded with the current value, and captures the saved buffer on return: saving commits it, while an aborted edit (a non-zero editor exit) keeps the inline value. When no editor is available the option is silently ignored and the field stays a plain inline textarea.

Keyboard

KeyAction
printable keysInsert at the caret
EnterInsert a newline
TabAccept (note: Enter adds a line, it does not accept)
/ Move between lines, keeping the column
/ Move the caret
BackspaceDelete the character before the caret
Ctrl-EOpen the external editor (when enabled)
EscCancel

Display modes

In all four display modes - Unicode or ASCII, colour on or off:

ANSINo ANSI
UnicodeTextarea: Unicode + ANSITextarea: Unicode + ANSITextarea: Unicode + No ANSITextarea: Unicode + No ANSI
ASCIITextarea: ASCII + ANSITextarea: ASCII + ANSITextarea: ASCII + No ANSITextarea: ASCII + No ANSI