From 07f5b140922d13519ad7a0d1dad67a9b403be9f1 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Tue, 22 Sep 2026 12:43:52 +0200 Subject: tui: kundutkast, , explicit Spara och F2-åtgärder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clients/tui.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'clients/tui.h') diff --git a/clients/tui.h b/clients/tui.h index 6df27fb..1785a32 100644 --- a/clients/tui.h +++ b/clients/tui.h @@ -191,10 +191,33 @@ int tui_form_next(int sel, int n, int ch); int tui_form_run(const char *title, struct tui_form_field *f, int n, int can_edit, int *focus); void tui_form_hint(const char *hint); /* overrides the footer for the next run */ +/* Extra text appended to the form/list footer until changed (NULL clears). */ +void tui_form_hint_extra(const char *extra); +void tui_list_hint_extra(const char *extra); int tui_form_run_hook(const char *title, struct tui_form_field *f, int n, int can_edit, int (*key)(void *ud, int ch), void *ud, int *focus); +/* --- action registry (docs/TUI-GUIDELINES.md "Interaction model") --- */ +struct tui_action { + const char *id; /* stable, e.g. "customer.archive" */ + const char *label; /* Swedish UI text */ + int key; /* accelerator; 0 = menu only */ + int enabled; /* 1 runnable, 0 dim + reason, -1 heading */ + const char *reason; /* why a disabled action is dim */ +}; + +/* "label", or "label (reason)" when the action is disabled. */ +void tui_action_label(const struct tui_action *a, char *buf, size_t n); +/* Builds "F9 = spara F2 = fler", showing at most max keyed actions. */ +void tui_action_hint(const struct tui_action *acts, int n, int max, + char *buf, size_t cap); +/* Modal action list: arrows/Tab/Home/End/PgUp/PgDn/1-9/g navigate, Enter + runs (a disabled action shows its reason), Esc cancels. Returns the + chosen index or -1. *focus remembers the row. */ +int tui_action_menu(const char *title, const struct tui_action *acts, int n, + int *focus); + /* --- action list in a form (tui_form_run_actions) --- */ /* enabled: 1 = selectable and runs; 0 = dimmed but selectable (Enter shows disabled_reason in a message); -1 = non-selectable heading/status row, -- cgit v1.3