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:
@@ -4,8 +4,7 @@
|
||||
* Usage: pi --extension ./examples/extensions/rainbow-editor.ts
|
||||
*/
|
||||
|
||||
import { CustomEditor, type ExtensionAPI, type KeybindingsManager } from "@mariozechner/pi-coding-agent";
|
||||
import type { EditorTheme, TUI } from "@mariozechner/pi-tui";
|
||||
import { CustomEditor, type ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
// Base colors (coral → yellow → green → teal → blue → purple → pink)
|
||||
const COLORS: [number, number, number][] = [
|
||||
@@ -44,14 +43,8 @@ function colorize(text: string, shinePos: number): string {
|
||||
|
||||
class RainbowEditor extends CustomEditor {
|
||||
private animationTimer?: ReturnType<typeof setInterval>;
|
||||
private tui: TUI;
|
||||
private frame = 0;
|
||||
|
||||
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
|
||||
super(theme, keybindings);
|
||||
this.tui = tui;
|
||||
}
|
||||
|
||||
private hasUltrathink(): boolean {
|
||||
return /ultrathink/i.test(this.getText());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user