diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-19 23:05:44 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-19 23:05:44 +0200 |
| commit | 8da6a7e849513e1cb63410d95b121df729260d0c (patch) | |
| tree | 77de7f5b3952d153e072cda8cc7c4f4bcd5f0c87 /clients/tui.h | |
| parent | 730d7159e3b9b3adfba2c3779893fdb4e107647a (diff) | |
| download | bokf-0.1.40.tar.gz bokf-0.1.40.zip | |
tui: themes, pager markup, menu sections; merge Bokslut and year infov0.1.40
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 061edbf..ecaa141 100644 --- a/clients/tui.h +++ b/clients/tui.h @@ -15,6 +15,35 @@ #define TUI_KEY_CTRL_X 0x18 #define TUI_KEY_CTRL_ENTER (KEY_MAX + 1) +/* Semantic styles: the widget layer maps them to colour pairs when the + terminal supports colour and NO_COLOR is unset, otherwise to plain + attributes. "Ordinary" drawing uses the terminal default. */ +enum tui_style { + TUI_TITLE = 0, + TUI_HEADING, + TUI_SUBHEADING, + TUI_DIM, + TUI_ACCENT, + TUI_POS, + TUI_NEG, + TUI_RULE, + TUI_STATUS, +}; + +/* Attribute bits for a style; pure so the colour/no-colour fallback is + unit-tested. colours_ok is the terminal capability, no_color the env. */ +int tui_style_attrs(enum tui_style s, int colours_ok, int no_color); +void tui_style(enum tui_style s); +void tui_style_reset(void); + +/* Pager line markup. A leading marker selects a style; \x03 is a rule and + is drawn full width as ACS_HLINE. tui_markup returns the text after the + marker and sets *style to the matching style, or -1 for plain text. */ +#define TUI_MARK_HEADING 0x01 +#define TUI_MARK_DIM 0x02 +#define TUI_MARK_RULE 0x03 +const char *tui_markup(const char *line, int *style); + /* 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 */ @@ -89,6 +118,9 @@ struct tui_list_nav { char gotobuf[12]; char gotolabel[32]; int goto_active; + /* Optional row flags: 0 marks a non-selectable row (a menu section + header). Navigation, numbering and goto skip them. */ + const unsigned char *selectable; }; /* Returns the selected index, or -1 back, -2 refresh, -4 new, -6 remove, @@ -103,6 +135,9 @@ 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); +/* Menu items whose text starts with TUI_MARK_HEADING are non-selectable + section headers: drawn dim, not numbered and never highlighted. Numbering + and 1-9/g continue over the selectable items only. */ int tui_menu(const char *title, const char *const *items, int n, int allow_new, int *cursor); |
