| 263 | } |
| 264 | |
| 265 | export class Editor implements Component, Focusable { |
| 266 | private state: EditorState = { |
| 267 | lines: [""], |
| 268 | cursorLine: 0, |
| 269 | cursorCol: 0, |
| 270 | }; |
| 271 | |
| 272 | /** Focusable interface - set by TUI when focus changes */ |
| 273 | focused: boolean = false; |
| 274 | |
| 275 | protected tui: TUI; |
| 276 | private theme: EditorTheme; |
| 277 | private paddingX: number = 0; |
| 278 | |
| 279 | // Store last render width for cursor navigation |
| 280 | private lastWidth: number = 80; |
| 281 | |
| 282 | // Vertical scrolling support |
| 283 | private scrollOffset: number = 0; |
| 284 | |
| 285 | // Border color (can be changed dynamically) |
| 286 | public borderColor: (str: string) => string; |
| 287 | |
| 288 | // Autocomplete support |
| 289 | private autocompleteProvider?: AutocompleteProvider; |
| 290 | private autocompleteTriggerCharacters = [...DEFAULT_AUTOCOMPLETE_TRIGGER_CHARACTERS]; |
| 291 | private autocompleteTriggerPattern = buildTriggerPattern(this.autocompleteTriggerCharacters); |
| 292 | private autocompleteDebouncePattern = buildDebouncePattern(this.autocompleteTriggerCharacters); |
| 293 | private autocompleteList?: SelectList; |
| 294 | private autocompleteState: "regular" | "force" | null = null; |
| 295 | private autocompletePrefix: string = ""; |
| 296 | private autocompleteMaxVisible: number = 5; |
| 297 | private autocompleteAbort?: AbortController; |
| 298 | private autocompleteDebounceTimer?: ReturnType<typeof setTimeout>; |
| 299 | private autocompleteRequestTask: Promise<void> = Promise.resolve(); |
| 300 | private autocompleteStartToken: number = 0; |
| 301 | private autocompleteRequestId: number = 0; |
| 302 | |
| 303 | // Paste tracking for large pastes |
| 304 | private pastes: Map<number, string> = new Map(); |
| 305 | private pasteCounter: number = 0; |
| 306 | |
| 307 | // Bracketed paste mode buffering |
| 308 | private pasteBuffer: string = ""; |
| 309 | private isInPaste: boolean = false; |
| 310 | |
| 311 | // Non-bracketed paste-burst fallback |
| 312 | private pasteBurst = new PasteBurst(); |
| 313 | private disablePasteBurst: boolean = false; |
| 314 | |
| 315 | // Prompt history for up/down navigation |
| 316 | private history: string[] = []; |
| 317 | private historyIndex: number = -1; // -1 = not browsing, 0 = most recent, 1 = older, etc. |
| 318 | private historyDraft: EditorState | null = null; |
| 319 | private hostHistoryDraft: unknown = undefined; |
| 320 | private historyFilter: ((entry: string) => boolean) | null = null; |
| 321 | |
| 322 | // Kill ring for Emacs-style kill/yank operations |
nothing calls this directly
no test coverage detected