From 946bee1946040a5ec91947d624bbf062e748f34c Mon Sep 17 00:00:00 2001 From: Yves Jutard <481983+Yvem@users.noreply.github.com> Date: Tue, 28 Apr 2026 16:48:21 +1000 Subject: [PATCH] doc(README): update "quick start" (#3740) --- packages/tui/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/tui/README.md b/packages/tui/README.md index 75d9668b..88210cc7 100644 --- a/packages/tui/README.md +++ b/packages/tui/README.md @@ -16,7 +16,7 @@ Minimal terminal UI framework with differential rendering and synchronized outpu ## Quick Start ```typescript -import { TUI, Text, Editor, ProcessTerminal } from "@mariozechner/pi-tui"; +import { TUI, Text, Editor, ProcessTerminal, matchesKey } from "@mariozechner/pi-tui"; // Create terminal const terminal = new ProcessTerminal(); @@ -27,6 +27,7 @@ const tui = new TUI(terminal); // Add components tui.addChild(new Text("Welcome to my app!")); +import { defaultEditorTheme as editorTheme } from './test/test-themes.ts'; const editor = new Editor(tui, editorTheme); editor.onSubmit = (text) => { console.log("Submitted:", text); @@ -34,6 +35,17 @@ editor.onSubmit = (text) => { }; tui.addChild(editor); +// Focus the editor so it receives keyboard input +tui.setFocus(editor); + +// In raw mode Ctrl+C doesn't send SIGINT — intercept it here to allow exit +tui.addInputListener((data) => { + if (matchesKey(data, 'ctrl+c')) { + tui.stop(); + process.exit(0); + } +}); + // Start tui.start(); ```