Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
2.5 kB · 80 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081import type { AutocompleteProvider } from "./autocomplete.js";import type { Component } from "./tui.js";
export interface EditorPasteSnapshot { pastes: readonly (readonly [number, string])[]; pasteCounter: number;}
/** * 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;
/** Prompt history entries available for up/down navigation (most recent first). */ getHistory?(): readonly string[];
/** Clear prompt history (e.g. when switching to a different session). */ clearHistory?(): void;
/** 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;
getPasteSnapshot?(): EditorPasteSnapshot;
restorePasteSnapshot?(snapshot: EditorPasteSnapshot): void;
/** Hook called when text is pasted. If it returns true, normal paste insertion is bypassed. */ onPasteText?: (text: string) => boolean | undefined;
/** Callback after a paste has been inserted in the editor. */ onPasteRecorded?: (info: { pasteId?: number; text: string; marker?: string }) => void;
/** Get raw content of a paste by its paste ID. */ getPaste?(id: number): string | undefined;
/** Delete a paste entry by ID so it won't expand. */ deletePaste?(id: number): boolean;
/** Set the autocomplete provider */ setAutocompleteProvider?(provider: AutocompleteProvider): void;
/** Border color function */ borderColor?: (str: string) => string;
/** Background color function */ backgroundColor?: (str: string) => string;
/** Set horizontal padding */ setPaddingX?(padding: number): void;
/** Set max visible items in autocomplete dropdown */ setAutocompleteMaxVisible?(maxVisible: number): void;}