| 119 | } |
| 120 | |
| 121 | export class CustomEditor extends Editor { |
| 122 | public onEscape?: () => void; |
| 123 | /** |
| 124 | * Fired for every input that is not a lone Escape. Used to disarm a pending |
| 125 | * double-Esc so only two consecutive Escape presses trigger the shortcut. |
| 126 | */ |
| 127 | public onNonEscapeInput?: () => void; |
| 128 | public onCtrlD?: () => void; |
| 129 | public onCtrlC?: () => void; |
| 130 | public onToggleToolExpand?: () => void; |
| 131 | public onOpenExternalEditor?: () => void; |
| 132 | public onCtrlS?: () => void; |
| 133 | /** Return `true` to consume Ctrl+B; return `false`/`undefined` to fall through to the editor default (cursor-left). */ |
| 134 | public onCtrlB?: () => boolean; |
| 135 | /** Return `true` to consume Ctrl+T (the todo list had overflow to toggle); return `false`/`undefined` to fall through to the editor default. */ |
| 136 | public onToggleTodoExpand?: () => boolean; |
| 137 | public onUndo?: () => void; |
| 138 | public onTextPaste?: () => void; |
| 139 | /** |
| 140 | * Called when ↑ is pressed in an empty editor. Return `true` to consume |
| 141 | * the key (e.g. recalled a queued message); return `false` to fall |
| 142 | * through so pi-tui's built-in history navigation runs. |
| 143 | */ |
| 144 | public onUpArrowEmpty?: () => boolean; |
| 145 | public onDownArrowEmpty?: () => boolean; |
| 146 | public onShiftTab?: () => void; |
| 147 | /** 'bash' when entering a `!` shell command. The `!` is never part of the |
| 148 | * text buffer — it is a separate mode + prompt symbol (see handleInput). */ |
| 149 | public inputMode: 'prompt' | 'bash' = 'prompt'; |
| 150 | public onInputModeChange?: (mode: 'prompt' | 'bash') => void; |
| 151 | public connectedAbove = false; |
| 152 | public borderHighlighted = false; |
| 153 | /** |
| 154 | * Called when the user triggers "paste image" (Ctrl-V on Unix, |
| 155 | * Alt-V on Windows — Ctrl-V is terminal-reserved there). Return |
| 156 | * `true` to consume the key (image was read and handled); return |
| 157 | * `false` to let the key fall through to the normal paste path. |
| 158 | * The callback may be async; pi-tui awaits it before dispatching |
| 159 | * the next keystroke. |
| 160 | */ |
| 161 | public onPasteImage?: () => Promise<boolean>; |
| 162 | |
| 163 | private consumingPaste = false; |
| 164 | private consumeBuffer = ''; |
| 165 | private argumentHints: ReadonlyMap<string, string> = new Map(); |
| 166 | |
| 167 | setArgumentHints(hints: ReadonlyMap<string, string>): void { |
| 168 | this.argumentHints = hints; |
| 169 | } |
| 170 | |
| 171 | constructor(tui: TUI, options: CustomEditorOptions = {}) { |
| 172 | // paddingX: 4 reserves column 0 for the left vertical border (│), |
| 173 | // column 1 as a single space between border and prompt, column 2 for |
| 174 | // the `>` prompt token, and column 3 as the space between prompt and |
| 175 | // content. The right side mirrors with 3 padding columns and the right |
| 176 | // border at the last column. |
| 177 | const theme = createEditorTheme(); |
| 178 | super(tui, theme, { paddingX: 4, disablePasteBurst: options.disablePasteBurst }); |
nothing calls this directly
no outgoing calls
no test coverage detected