From 1f2d7a8190876e3d1c541251e079a11a2cc637f2 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Sat, 19 Sep 2026 23:53:09 +0200 Subject: tui: bokslut hub with year fields, reports and the posting action --- clients/tui.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'clients/tui.h') diff --git a/clients/tui.h b/clients/tui.h index 0950eac..d0656da 100644 --- a/clients/tui.h +++ b/clients/tui.h @@ -185,6 +185,41 @@ void tui_form_hint(const char *hint); /* overrides the footer for the next run * 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); +/* --- 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, + drawn dim like a menu section and skipped by navigation. */ +struct tui_form_action { + const char *label; + int enabled; + const char *disabled_reason; +}; + +#define TUI_FORM_ACTION 1000 /* action i is returned as TUI_FORM_ACTION + i */ + +/* Focus ring over fields (0..nf-1) and actions (nf..nf+na-1); heading rows + are skipped and the ring wraps. dir +1 = Tab/Down, -1 = Shift-Tab/Up. */ +int tui_form_act_step(int focus, int nf, const struct tui_form_action *acts, + int na, int dir); +/* Same ring for one key, plus Home/End/PgUp/PgDn and the form return keys + (F5/^Enter/F9/Esc/q). Returns the new focus, a TUI_FORM_* code or + TUI_NAV_NONE. */ +int tui_form_act_key(int sel, int nf, const struct tui_form_action *acts, + int na, int ch); +/* Index of the first focusable row (field 0 when fields exist, else the + first selectable action), or -1. */ +int tui_form_act_first(int nf, const struct tui_form_action *acts, int na); +/* "label", or "label (reason)" for a disabled selectable action. */ +void tui_form_act_label(const struct tui_form_action *a, char *buf, size_t n); + +/* Form with fields and an action list below them (see TUI-GUIDELINES.md). + Returns a field index after an edit, TUI_FORM_ACTION + i for a chosen + action, or TUI_FORM_BACK/REFRESH/SUBMIT. `hint` overrides the default + footer; tui_form_hint() still takes precedence. */ +int tui_form_run_actions(const char *title, struct tui_form_field *f, int nf, + int can_edit, const struct tui_form_action *acts, + int na, const char *hint); + /* --- row table --- */ enum { TUI_RT_EDIT = 0, TUI_RT_INFO, TUI_RT_DATE }; -- cgit v1.3