fix(tui): add vertical scrolling to Editor when content exceeds terminal height
The Editor component now accepts TUI as the first constructor parameter, enabling it to query terminal dimensions. When content exceeds available height, the editor scrolls vertically keeping the cursor visible. Features: - Max editor height is 30% of terminal rows (minimum 5 lines) - Page Up/Down keys scroll by page size - Scroll indicators show lines above/below: ─── ↑ 5 more ─── Breaking change: Editor constructor signature changed from new Editor(theme) to new Editor(tui, theme) fixes #732
This commit is contained in:
@@ -27,7 +27,7 @@ const tui = new TUI(terminal);
|
||||
// Add components
|
||||
tui.addChild(new Text("Welcome to my app!"));
|
||||
|
||||
const editor = new Editor(editorTheme);
|
||||
const editor = new Editor(tui, editorTheme);
|
||||
editor.onSubmit = (text) => {
|
||||
console.log("Submitted:", text);
|
||||
tui.addChild(new Text(`You said: ${text}`));
|
||||
@@ -212,7 +212,7 @@ input.getValue();
|
||||
|
||||
### Editor
|
||||
|
||||
Multi-line text editor with autocomplete, file completion, and paste handling.
|
||||
Multi-line text editor with autocomplete, file completion, paste handling, and vertical scrolling when content exceeds terminal height.
|
||||
|
||||
```typescript
|
||||
interface EditorTheme {
|
||||
@@ -220,7 +220,7 @@ interface EditorTheme {
|
||||
selectList: SelectListTheme;
|
||||
}
|
||||
|
||||
const editor = new Editor(theme);
|
||||
const editor = new Editor(tui, theme); // tui is required for height-aware scrolling
|
||||
editor.onSubmit = (text) => console.log(text);
|
||||
editor.onChange = (text) => console.log("Changed:", text);
|
||||
editor.disableSubmit = true; // Disable submit temporarily
|
||||
|
||||
Reference in New Issue
Block a user