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:
@@ -1,4 +1,4 @@
|
||||
import { Editor, type EditorTheme } from "@mariozechner/pi-tui";
|
||||
import { Editor, type EditorTheme, type TUI } from "@mariozechner/pi-tui";
|
||||
import type { AppAction, KeybindingsManager } from "../../../core/keybindings.js";
|
||||
|
||||
/**
|
||||
@@ -15,8 +15,8 @@ export class CustomEditor extends Editor {
|
||||
/** Handler for extension-registered shortcuts. Returns true if handled. */
|
||||
public onExtensionShortcut?: (data: string) => boolean;
|
||||
|
||||
constructor(theme: EditorTheme, keybindings: KeybindingsManager) {
|
||||
super(theme);
|
||||
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
|
||||
super(tui, theme);
|
||||
this.keybindings = keybindings;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export class ExtensionEditorComponent extends Container {
|
||||
this.addChild(new Spacer(1));
|
||||
|
||||
// Create editor
|
||||
this.editor = new Editor(getEditorTheme());
|
||||
this.editor = new Editor(tui, getEditorTheme());
|
||||
if (prefill) {
|
||||
this.editor.setText(prefill);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user