aboutsummaryrefslogtreecommitdiff
path: root/clients/tui.h
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-19 22:33:33 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-19 22:33:33 +0200
commite352cd34d30acc1955c62027c779ac98004ac201 (patch)
tree8a94163b837fdc16e334c159d91a9f622d42763d /clients/tui.h
parent84c4fdcf138ad6ef4f7edfea76f2318b7a7a5e3e (diff)
downloadbokf-e352cd34d30acc1955c62027c779ac98004ac201.tar.gz
bokf-e352cd34d30acc1955c62027c779ac98004ac201.zip
tui: migrate the remaining screens to the widget layerv0.1.38
Diffstat (limited to 'clients/tui.h')
-rw-r--r--clients/tui.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/clients/tui.h b/clients/tui.h
index d41d58c..39ea913 100644
--- a/clients/tui.h
+++ b/clients/tui.h
@@ -15,6 +15,13 @@
#define TUI_KEY_CTRL_X 0x18
#define TUI_KEY_CTRL_ENTER (KEY_MAX + 1)
+/* Key hooks: widgets call the screen's hook for keys they do not handle. */
+#define TUI_HOOK_NONE 0 /* not handled: process the key normally */
+#define TUI_HOOK_STAY 1 /* handled: redraw and keep the widget up */
+#define TUI_HOOK_BACK 2 /* handled: return "back" */
+#define TUI_HOOK_REFRESH 3 /* handled: return "refresh" */
+#define TUI_HOOK_SUBMIT 4 /* handled: return "submit" (forms only) */
+
/* The application supplies input, frame/hints drawing and a quit hook so
this module stays free of app state (and testable). */
void tui_set_input(int (*fn)(void));
@@ -92,6 +99,10 @@ int tui_nav_key(struct tui_list_nav *v, int ch, int allow_new,
int tui_select_list(const char *title, char **items, int n, int start,
int allow_refresh, int *cursor, int allow_new,
const char *archive_action, int allow_toggle);
+int tui_select_list_hook(const char *title, char **items, int n, int start,
+ int allow_refresh, int *cursor, int allow_new,
+ const char *archive_action, int allow_toggle,
+ int (*key)(void *ud, int ch), void *ud);
int tui_menu(const char *title, const char *const *items, int n,
int allow_new, int *cursor);
@@ -99,7 +110,12 @@ int tui_menu(const char *title, const char *const *items, int n,
void tui_set_status(const char *status, const char *right);
void tui_frame(const char *title);
void tui_hints(const char *s);
+void tui_redraw(void);
+#define TUI_PAGER_SAVE 0x1 /* 's' returns 2 (the save action) */
int tui_pager(const char *title, const char *text, const char *action_hint);
+int tui_pager_hook(const char *title, const char *text,
+ const char *extra_hint, unsigned flags,
+ int (*key)(void *ud, int ch), void *ud);
/* --- forms --- */
enum {
@@ -112,13 +128,14 @@ enum {
#define TUI_FORM_BACK (-1)
#define TUI_FORM_REFRESH (-2)
-#define TUI_FORM_SUBMIT (-3)
+#define TUI_FORM_SUBMIT (-8)
struct tui_form_field {
const char *label;
- char *value; /* text storage for TEXT/DATE (also CHOICE labels) */
+ char *value; /* text storage for TEXT/DATE (also CHOICE labels/ACTION) */
size_t cap;
int kind;
+ int mask; /* TEXT: '*' instead of the content */
int64_t *ore; /* TUI_F_AMOUNT */
const char *const *choices; /* TUI_F_CHOICE */
int nchoices;
@@ -128,6 +145,8 @@ 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 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);
/* --- row table --- */
enum { TUI_RT_EDIT = 0, TUI_RT_INFO, TUI_RT_DATE };
@@ -149,16 +168,24 @@ struct tui_rt {
void (*cell)(void *, int, int, char **, size_t *);
void (*info)(void *, int, char *, size_t);
void *ud;
+ int (*key)(void *, int);
+ /* Writes the dim status lines shown under the table ('\n' separated). */
+ void (*footer)(void *, char *, size_t);
};
void tui_rt_init(struct tui_rt *t, int nrows, int maxrows, int ncols,
const struct tui_rt_col *cols, int y,
void (*cell)(void *, int, int, char **, size_t *),
void (*info)(void *, int, char *, size_t), void *ud);
+void tui_rt_set_key(struct tui_rt *t, int (*key)(void *ud, int ch));
+void tui_rt_set_footer(struct tui_rt *t,
+ void (*footer)(void *ud, char *buf, size_t n));
int tui_rt_blank_row(struct tui_rt *t, int row);
int tui_rt_normalize(struct tui_rt *t);
int tui_rt_move(struct tui_rt *t, int dr, int dc);
+int tui_rt_tab(struct tui_rt *t, int dir);
int tui_rt_clear(struct tui_rt *t);
+int tui_rt_col_of(const struct tui_rt *t, int ecol);
int tui_rt_run(const char *title, struct tui_rt *t, const char *hint);
#endif