From 942eaabe001d5dd98a7efb07ef128df177a2f75e Mon Sep 17 00:00:00 2001 From: jainiksha Date: Sun, 21 Jun 2026 01:48:46 +0530 Subject: [PATCH 1/3] feat: add command auto-completion support to TextInput --- packages/widgets/src/input/TextInput.ts | 363 ++++++++++++++---------- 1 file changed, 216 insertions(+), 147 deletions(-) diff --git a/packages/widgets/src/input/TextInput.ts b/packages/widgets/src/input/TextInput.ts index eda1655b..95df7528 100644 --- a/packages/widgets/src/input/TextInput.ts +++ b/packages/widgets/src/input/TextInput.ts @@ -11,23 +11,36 @@ import { 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