class TextBox
extends Box
import { TextBox } from "https://deno.land/x/tui@2.0.0/src/components/mod.ts";
Component for creating interactive mutliline text input
If you need singleline input use Input
component.
Examples
Example 1
Example 1
new TextBox({
parent: tui,
lineNumbering: true,
lineHighlighting: true,
theme: {
base: crayon.bgGreen,
focused: crayon.bgLightGreen,
active: crayon.bgYellow,
},
rectangle: {
column: 1,
row: 1,
width: 10,
height: 5,
},
zIndex: 0,
});
It supports validating input, e.g. number input would look like this:
Example 2
Example 2
new TextBox({
...,
validator: /\d+/,
});
If you need to use emojis or other multi codepoint characters set multiCodePointSupport
property to true.
Example 3
Example 3
new TextBox({
...,
placeholder: "🧡",
multiCodePointCharacter: true,
});
Constructors
new
TextBox(options: TextBoxOptions)Properties
cursorPosition: Signal<CursorPosition>
drawnObjects: { box: BoxObject; lines: TextObject[]; lineNumbers: TextObject[]; cursor: TextObject; }
lineHighlighting: Signal<boolean>
lineNumbering: Signal<boolean>
multiCodePointSupport: Signal<boolean>
text: Signal<string>
theme: TextBoxTheme