summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clients/bokftui.c3
-rw-r--r--clients/tui.c21
-rw-r--r--clients/tui.h1
3 files changed, 20 insertions, 5 deletions
diff --git a/clients/bokftui.c b/clients/bokftui.c
index 64bed07..aa7233b 100644
--- a/clients/bokftui.c
+++ b/clients/bokftui.c
@@ -4539,6 +4539,9 @@ static void bokslut_screen(struct app *a)
ff[7].value = rate;
ff[7].cap = sizeof rate;
ff[7].kind = TUI_F_TEXT;
+ tui_form_hint("upp/ned/Home/End Enter = ändra F5 = visa"
+ " bokslutsplan ^Enter = bokför planen (frågar"
+ " först) Esc/q = tillbaka ^C = avsluta");
int r = tui_form_run("Bokslut", ff, nf + 2, can_edit);
if (r >= 0 && r < nf) {
yyjson_mut_doc *d = yyjson_mut_doc_new(NULL);
diff --git a/clients/tui.c b/clients/tui.c
index 8f410c2..a964f65 100644
--- a/clients/tui.c
+++ b/clients/tui.c
@@ -1145,9 +1145,15 @@ int tui_menu(const char *title, const char *const *items, int n,
/* frame, status and hints */
/* ------------------------------------------------------------------ */
+static const char *g_form_hint;
static char g_status[512];
static char g_right[160];
+void tui_form_hint(const char *hint)
+{
+ g_form_hint = hint;
+}
+
void tui_set_status(const char *status, const char *right)
{
snprintf(g_status, sizeof g_status, "%s", status ? status : "");
@@ -1390,11 +1396,16 @@ int tui_form_run_hook(const char *title, struct tui_form_field *f, int n,
else if (!can_edit)
attroff(tui_style_attrs(TUI_DIM, g_colours, 0));
}
- tui_hints(can_edit
- ? "upp/ned Enter = ändra F5 = uppdatera"
- " ^Enter = spara Esc/q = tillbaka ^C = avsluta"
- : "upp/ned F5 = uppdatera Esc/q = tillbaka"
- " ^C = avsluta (endast behöriga kan ändra)");
+ tui_hints(g_form_hint
+ ? g_form_hint
+ : (can_edit
+ ? "upp/ned/Home/End Enter = ändra"
+ " F5 = uppdatera ^Enter = spara"
+ " Esc/q = tillbaka ^C = avsluta"
+ : "upp/ned/Home/End F5 = uppdatera"
+ " Esc/q = tillbaka ^C = avsluta"
+ " (endast behöriga kan ändra)"));
+ g_form_hint = NULL;
refresh();
int ch = in_key();
int nxt = tui_form_next(sel, n, ch);
diff --git a/clients/tui.h b/clients/tui.h
index ecaa141..0950eac 100644
--- a/clients/tui.h
+++ b/clients/tui.h
@@ -181,6 +181,7 @@ 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);
+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);