← All 40 libraries

SugarQuickpick

SugarQuickpick

Fuzzy finder overlay for terminal UIs

inspired by Genekkion/theHermit fuzzyfinderoverlaysearch

SugarQuickpick code coverage

Fuzzy-search overlay — type to filter a list, arrow keys to select, Enter to confirm. Ships as a model wrapper that composes into any SugarCraft app. Supports structured Item objects, custom filter predicates, and persistent JSONL history.

Install

composer require sugarcraft/sugar-quickpick

Quickstart — plain strings

use SugarCraft\QuickPick\QuickPick;

$hermit = QuickPick::new(
    items: ['Ruby', 'PHP', 'Go', 'Rust', 'Python'],
)->setPrompt('Choose language: ');

Quickstart — numbered items + history

use SugarCraft\QuickPick\QuickPick;
use SugarCraft\QuickPick\FilteredItem;
use SugarCraft\QuickPick\History\FileHistory;

$items = [
    new FilteredItem(1, 'apple'),
    new FilteredItem(2, 'banana'),
    new FilteredItem(3, 'cherry'),
];

$hermit = QuickPick::new($items)
    ->setFilterFn(fn($item) => $item->number() > 0)
    ->setPrompt('> ');

// Persist selections
$history = new FileHistory('/tmp/hermit.jsonl');
$history->append($hermit->selected());
$allItems = $history->all();

What's in the box

Fuzzy matchingAnchor-aware substring filter on item text as you type.
QuickPick modelFull init / update / view model.
ConfigurableCustom formatter, prompt, match highlight style, window size.
Item interfaceStructured Item objects with number() + value() instead of raw strings.
Custom filter predicatessetFilterFn() applies arbitrary Closure(Item): bool logic.
Persistent historyFileHistory stores items as JSONL lines, one item per line.
Border & StylewithBorder() / withStyle() compose sugar-style Border and Style objects.
HelpBar / StatusBarKeyboard-shortcut summary and status message rendered below the overlay.
SIGWINCH resizewithOnResize() + attachSigwinch() forward terminal resize events via SignalForwarder.

Source & demos

Try the quickstart →

API

ClassMethodDescription
QuickPicknew(array $items, ?Closure $itemFormatter)Create fuzzy finder (items: string[] or Item[])
QuickPickwithItems(array $items)Replace items and reset filter state
QuickPicksetPrompt(string)Set filter prompt string
QuickPicksetFilterFn(Closure)Set custom filter predicate: Closure(Item): bool
QuickPicksetItemFormatter(Closure)Set item formatter: Closure(item, isSelected): string
QuickPicksetMatchStyle(string)Set ANSI SGR codes for match highlighting
QuickPicksetWindowHeight(int)Set visible item window height
QuickPicksetWindowWidth(int)Set overlay width (0 = auto)
QuickPicksetOffset(int $x, int $y)Position overlay and show
QuickPickshow() / hide()Show or hide the overlay
QuickPicktype(string) / backspace() / clear()Modify filter text
QuickPickcursorUp/Down/Top/Bottom()Navigate item cursor
QuickPickselected()Get currently selected Item
QuickPickitems() / itemCount() / allCount()Query filtered/all item state
QuickPickwithBorder(?Border)Apply sugar-style Border to overlay window
QuickPickwithStyle(?Style)Apply sugar-style Style to overlay window
QuickPickwithHelpBar(?HelpBar)Attach keyboard-shortcut summary below filter list
QuickPickwithStatusBar(?StatusBar)Attach status message line at overlay bottom
QuickPickwithOnResize(Closure)Register callback invoked on SIGWINCH (cols, rows)
QuickPickattachSigwinch()Install SIGWINCH handler via SignalForwarder (requires ext-pcntl)
QuickPickborder() / style() / helpBar() / statusBar()Query attached border, style, help bar, status bar
QuickPickView(string $backgroundView)Render composited overlay over background
HelpBarnew(array $shortcuts, bool $visible)Create help bar with key→description pairs
HelpBarwithShortcut(key, desc) / withoutShortcut(key)Add/remove shortcut entry
HelpBarshow() / hide() / isVisible()Control visibility
HelpBarrender()Render as "key: desc │ key: desc ..." string
StatusBarnew(string $message, bool $visible)Create status bar with message
StatusBarwithMessage(string) / withNoMessage()Set or clear primary message
StatusBarwithSegment(name, value) / withoutSegment(name)Add/remove named segment
StatusBarshow() / hide() / isVisible()Control visibility
StatusBarrender()Render as "[name: value] message" string
Iteminterface number(), value()Contract for filterable items
FilteredItemnew(int $number, string $value)Numbered Item implementation
FileHistorynew(string $path)Open/create JSONL history file
FileHistoryappend(Item)Append item as JSON line
FileHistoryall()Read all items from history
FileHistoryclear() / path()Clear history or get file path
Modelinterface update(QuickPick, string), view(QuickPick)Model–Update–View embedding contract

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Background + overlay

Background + overlay

QuickPick overlay over a sample background, four filter states.
Filter interaction

Filter interaction

Filter narrowing the candidate list as you type.