diff --git a/packages/widgets/src/input/TextInput.ts b/packages/widgets/src/input/TextInput.ts index b2d04af5..9b9856a5 100644 --- a/packages/widgets/src/input/TextInput.ts +++ b/packages/widgets/src/input/TextInput.ts @@ -6,28 +6,40 @@ import { type Screen, type Style, styleToCellAttrs, - stringWidth, truncate, type KeyEvent, splitGraphemes } from '@termuijs/core'; + import { Widget } from '../base/Widget.js'; import { type VimMode } from './vim.js'; export type { VimMode }; /** - * TextInput — a single-line text input field. + * TextInput — a single-line text input field + * with optional command auto-completion support. */ export class TextInput extends Widget { private _value = ''; private _cursorPos = 0; + private _placeholder: string; private _mask: string | null; private _maxLength: number; + private _onChange?: (value: string) => void; private _onSubmit?: (value: string) => void; - private _vimMode: VimMode = process.env.TERMUI_KEYBINDINGS === 'vim' ? 'normal' : 'insert'; + + // Auto-complete + private _suggestions: string[] = []; + private _suggestionIndex = 0; + + // Vim mode support + private _vimMode: VimMode = + process.env.TERMUI_KEYBINDINGS === 'vim' + ? 'normal' + : 'insert'; constructor( style: Partial