Skip to content
pi-c Artifact [8a94ab01ff]
Login

Artifact [8a94ab01ff]

Artifact 8a94ab01ff8d0ab75158cd2a2c8c03032e7a87f85e72182c46e5e15817d20cdc:


/* Fuzzy matching, ported from Pi (reference/pi/packages/tui/src/fuzzy.ts)
 * so filtering ranks as Pi's does: the model picker and the slash-command
 * menu (fuzzy.c). */
#ifndef PIC_TUI_FUZZY_H
#define PIC_TUI_FUZZY_H

#include <stddef.h>

/* Pi's fuzzyMatch: whether QUERY matches TEXT and its score (lower is a
 * better match, as in Pi). */
int tui_fuzzy_match(const char *query, const char *text, double *score);

/* Pi's fuzzyFilter over N texts: writes the indexes of the matching texts
 * to order[] (capacity n) best first, ties in input order, and returns how
 * many matched. An empty or all-space query matches everything in input
 * order. */
size_t tui_fuzzy_filter(const char *query, const char *const *texts, size_t n, size_t *order);

#endif