diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-20 00:05:51 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-20 00:05:51 +0200 |
| commit | a61cfeefb0599e74fc9189b189b16dd0b6d36f0f (patch) | |
| tree | 83e0934e190744605e91e69cd032e91c85eecf57 /clients/tui.h | |
| parent | 1f2d7a8190876e3d1c541251e079a11a2cc637f2 (diff) | |
| download | bokf-0.1.44.tar.gz bokf-0.1.44.zip | |
tui: remember the focused row in forms and the bokslut hubv0.1.44
Diffstat (limited to 'clients/tui.h')
| -rw-r--r-- | clients/tui.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clients/tui.h b/clients/tui.h index d0656da..7250c0b 100644 --- a/clients/tui.h +++ b/clients/tui.h @@ -179,11 +179,13 @@ struct tui_form_field { }; 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 can_edit, int *focus); 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); + int can_edit, int (*key)(void *ud, int ch), void *ud, + int *focus); /* --- action list in a form (tui_form_run_actions) --- */ /* enabled: 1 = selectable and runs; 0 = dimmed but selectable (Enter shows @@ -197,6 +199,15 @@ struct tui_form_action { #define TUI_FORM_ACTION 1000 /* action i is returned as TUI_FORM_ACTION + i */ +/* Focus memory: the screen owns an int and passes its address to + tui_form_run*; on entry *focus is clamped to a selectable row — out of + range snaps to the nearest end and a heading row snaps forward, wrapping + — and on every return the row the form stopped on is written back. + Passing NULL starts at the first focusable row and stores nothing. */ +int tui_form_focus_clamp(int focus, int nf, + const struct tui_form_action *acts, int na); +int tui_form_focus_store(int *focus, int sel, int ret); + /* 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, @@ -218,7 +229,7 @@ void tui_form_act_label(const struct tui_form_action *a, char *buf, size_t n); 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); + int na, const char *hint, int *focus); /* --- row table --- */ enum { TUI_RT_EDIT = 0, TUI_RT_INFO, TUI_RT_DATE }; |
