@mariozechner/pi-tui 0.70.4 → 0.70.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Minimal terminal UI framework with differential rendering and synchronized outpu
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { TUI, Text, Editor, ProcessTerminal } from "@mariozechner/pi-tui";
|
|
19
|
+
import { TUI, Text, Editor, ProcessTerminal, matchesKey } from "@mariozechner/pi-tui";
|
|
20
20
|
|
|
21
21
|
// Create terminal
|
|
22
22
|
const terminal = new ProcessTerminal();
|
|
@@ -27,6 +27,7 @@ const tui = new TUI(terminal);
|
|
|
27
27
|
// Add components
|
|
28
28
|
tui.addChild(new Text("Welcome to my app!"));
|
|
29
29
|
|
|
30
|
+
import { defaultEditorTheme as editorTheme } from './test/test-themes.ts';
|
|
30
31
|
const editor = new Editor(tui, editorTheme);
|
|
31
32
|
editor.onSubmit = (text) => {
|
|
32
33
|
console.log("Submitted:", text);
|
|
@@ -34,6 +35,17 @@ editor.onSubmit = (text) => {
|
|
|
34
35
|
};
|
|
35
36
|
tui.addChild(editor);
|
|
36
37
|
|
|
38
|
+
// Focus the editor so it receives keyboard input
|
|
39
|
+
tui.setFocus(editor);
|
|
40
|
+
|
|
41
|
+
// In raw mode Ctrl+C doesn't send SIGINT — intercept it here to allow exit
|
|
42
|
+
tui.addInputListener((data) => {
|
|
43
|
+
if (matchesKey(data, 'ctrl+c')) {
|
|
44
|
+
tui.stop();
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
37
49
|
// Start
|
|
38
50
|
tui.start();
|
|
39
51
|
```
|
package/package.json
CHANGED