From 6159042d0cb3870e6a7c6f8d9a97e175d59e6f80 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Wed, 23 Sep 2026 09:24:40 +0200 Subject: tui: 'g' + a letter searches list rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The goto prompt decides on its first key: digits jump to a row number as before, any other printable key searches the row texts of the list or menu (case-insensitive, also åäö), with up/down stepping through the matches. Keys typed into the prompt no longer reach the screen's key hook, and Enter in the action menu closes an open prompt. Co-Authored-By: Claude Opus 5.5 --- clients/tui.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'clients/tui.h') diff --git a/clients/tui.h b/clients/tui.h index c4fe116..4ae0da6 100644 --- a/clients/tui.h +++ b/clients/tui.h @@ -130,14 +130,23 @@ int tui_choice_prompt(const char *label, const char *const *opts, int n, struct tui_list_nav { int n, sel, top, view, numw; - char gotobuf[12]; + char gotobuf[64]; char gotolabel[32]; int goto_active; + /* The goto prompt became a search: its first key was not a digit. */ + int goto_search; + int goto_miss; /* the search text matches no row */ /* Optional row flags: 0 marks a non-selectable row (a menu section header). Navigation, numbering and goto skip them. */ const unsigned char *selectable; + /* Optional row texts for the goto search; NULL: digits only. */ + const char *const *items; }; +/* Whether needle occurs in hay, ignoring case for ASCII and the Latin-1 + letters (Å/Ä/Ö/É…). An empty needle matches. Pure. */ +int tui_text_match(const char *hay, const char *needle); + /* Returns the selected index, or -1 back, -2 refresh, -4 new, -6 remove, -7 toggle, TUI_NAV_NONE when nothing happened. */ int tui_nav_key(struct tui_list_nav *v, int ch, int allow_new, -- cgit v1.3