/** * [WHO]: EditorComponent * [FROM]: No external dependencies * [TO]: Consumed by core/lib/tui/src/index.ts * [HERE]: core/lib/tui/src/editor-component.ts - */ import type { AutocompleteProvider } from "./autocomplete.js"; import type { Component } from "./tui.js"; /** * Interface for custom editor components. * * This allows extensions to provide their own editor implementation * (e.g., vim mode, emacs mode, custom keybindings) while maintaining * compatibility with the core application. */ export interface EditorComponent extends Component { /** Get the current text content */ getText(): string; /** Set the text content */ setText(text: string): void; /** Handle raw terminal input (key presses, paste sequences, etc.) */ handleInput(data: string): void; /** Called when user submits (e.g., Enter key) */ onSubmit?: (text: string) => void; /** Called when text changes */ onChange?: (text: string) => void; /** Add text to history for up/down navigation */ addToHistory?(text: string): void; /** * Whether the cursor is on the first visual line (accounts for soft wrapping). * Used to decide whether ↑ should leave the editor (e.g. into an attachments * bar above it) instead of moving the cursor. Optional: callers fall back to a * single-line check when an editor implementation does not provide it. */ isCursorOnFirstVisualLine?(): boolean; /** Insert text at current cursor position */ insertTextAtCursor?(text: string): void; /** * Get text with any markers expanded (e.g., paste markers). * Falls back to getText() if not implemented. */ getExpandedText?(): string; /** Set the autocomplete provider */ setAutocompleteProvider?(provider: AutocompleteProvider): void; /** Border color function */ borderColor?: (str: string) => string; /** Set horizontal padding */ setPaddingX?(padding: number): void; /** Set max visible items in autocomplete dropdown */ setAutocompleteMaxVisible?(maxVisible: number): void; }