diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-19 23:53:09 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-19 23:53:09 +0200 |
| commit | 1f2d7a8190876e3d1c541251e079a11a2cc637f2 (patch) | |
| tree | 284427385e9c140dddb0c97df318fc85852fe8e1 /clients/tui.h | |
| parent | 86c0ef0e30f6cb24db04f20a326cf5fb4b616c3c (diff) | |
| download | bokf-1f2d7a8190876e3d1c541251e079a11a2cc637f2.tar.gz bokf-1f2d7a8190876e3d1c541251e079a11a2cc637f2.zip | |
tui: bokslut hub with year fields, reports and the posting actionv0.1.43
Diffstat (limited to 'clients/tui.h')
| -rw-r--r-- | clients/tui.h | 35 |
1 files changed, 35 insertions, 0 deletions
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 }; |
