aboutsummaryrefslogtreecommitdiff
path: root/clients/bokftui.c
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-20 10:24:18 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-20 10:24:18 +0200
commitae60b7d2c87cc9ed6878faa57cd4233f77f6f7c3 (patch)
tree918e717a5d226dcd54890901682a980c41d7e1d0 /clients/bokftui.c
parent5097941fa96ce0c309e5f1af034993781a70fc66 (diff)
downloadbokf-0.1.48.tar.gz
bokf-0.1.48.zip
tui: pinned report headers, voucher detail headers, clamped pagingv0.1.48
Diffstat (limited to 'clients/bokftui.c')
-rw-r--r--clients/bokftui.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/clients/bokftui.c b/clients/bokftui.c
index 05a845c..fef9100 100644
--- a/clients/bokftui.c
+++ b/clients/bokftui.c
@@ -29,6 +29,7 @@
#define MK_HEAD "\001"
#define MK_DIM "\002"
#define MK_RULE "\003"
+#define MK_STICKY "\004"
/* Menu item prefix for a non-selectable section header. */
#define MK_SECTION MK_HEAD
/* ^C quits the application; Esc is navigation only */
@@ -993,6 +994,10 @@ static int voucher_detail(struct app *a, int64_t id, int64_t *out_new)
series ? series : "", (long long)number, date ? date : "",
desc ? desc : "");
buf_append(&text, line, strlen(line));
+ int hdr = snprintf(
+ line, sizeof line, MK_HEAD " %-6s %-34s D %12s K %12s\n",
+ "Konto", "Benämning", "Debet", "Kredit");
+ buf_append(&text, line, (size_t)hdr);
size_t nrows = jarr_size(resp, "result.rows");
for (size_t i = 0; i < nrows; i++) {
char path[64];
@@ -1020,7 +1025,13 @@ static int voucher_detail(struct app *a, int64_t id, int64_t *out_new)
}
size_t natts = jarr_size(resp, "result.attachments");
if (natts) {
- buf_append(&text, "\nUnderlag:\n", 11);
+ buf_append(&text, "\n", 1);
+ line[0] = MK_RULE[0];
+ for (int i = 1; i <= 98; i++)
+ line[i] = '-';
+ line[99] = '\n';
+ buf_append(&text, line, 100);
+ buf_append(&text, MK_HEAD "Underlag:\n", 11);
for (size_t i = 0; i < natts; i++) {
char path[64];
snprintf(path, sizeof path, "result.attachments.%zu.filename",
@@ -1833,8 +1844,9 @@ static void accounts_report(struct app *a)
buf_init(&text);
char line[2048];
int hdr = snprintf(line, sizeof line,
- "%-6s %-*s %-12s %-5s %-6s %-8s\n", "Konto",
- name_w, "Namn", "Typ", "Aktiv", "SRU", "Moms");
+ MK_STICKY "%-6s %-*s %-12s %-5s %-6s %-8s\n",
+ "Konto", name_w, "Namn", "Typ", "Aktiv", "SRU",
+ "Moms");
buf_append(&text, line, (size_t)hdr);
int sep_w = 6 + 1 + name_w + 1 + 12 + 1 + 5 + 1 + 6 + 1 + 8;
for (int i = 0; i < sep_w && i < (int)sizeof line - 1; i++)
@@ -1976,10 +1988,11 @@ struct bs_sum {
int64_t ib, per, ub;
};
-static void bs_col_head(struct buf *t)
+static void bs_col_head(struct buf *t, int sticky)
{
- buf_line(t, " %5s %-48s %14s %14s %14s %14s\n", "", "", "Ing balans",
- "Ing saldo", "Period", "Utg balans");
+ buf_line(t, "%s %5s %-48s %14s %14s %14s %14s\n",
+ sticky ? MK_STICKY MK_HEAD : "", "", "", "Ing balans", "Ing saldo",
+ "Period", "Utg balans");
buf_rule(t, BS_RULE_W);
}
@@ -2065,7 +2078,7 @@ static void fmt_balans(struct buf *t, const struct app *a, yyjson_val *res)
struct bs_sum anl = { 0, 0, 0 }, oms = { 0, 0, 0 };
struct bs_sum eget = { 0, 0, 0 }, skuld = { 0, 0, 0 };
buf_line(t, MK_HEAD "TILLGÅNGAR\n");
- bs_col_head(t);
+ bs_col_head(t, 1);
buf_line(t, "\n" MK_HEAD "Anläggningstillgångar\n");
bs_rows(t, res, 1000, 1399, &anl);
bs_sum_line(t, "Summa anläggningstillgångar", &anl);
@@ -2087,7 +2100,7 @@ static void fmt_balans(struct buf *t, const struct app *a, yyjson_val *res)
bs_sum_line(t, "Summa tillgångar", &as);
buf_line(t, "\n" MK_HEAD "EGET KAPITAL OCH SKULDER\n");
- bs_col_head(t);
+ bs_col_head(t, 0);
buf_line(t, "\n" MK_HEAD "Eget kapital\n");
bs_group(t, res, "Bundet eget kapital", "Summa bundet eget kapital", 2000,
2090, &eget);
@@ -2280,8 +2293,8 @@ static void fmt_resultat(struct buf *t, const struct app *a, yyjson_val *res,
tui_pad_hdr(h1, sizeof h1, 15, "Period");
tui_pad_hdr(h2, sizeof h2, 15, "Ackumulerat");
tui_pad_hdr(h3, sizeof h3, 15, "Föreg. per.");
- buf_line(t, MK_HEAD " %5s %s %s %s %s\n", "", lbl, h1, h2,
- h3);
+ buf_line(t, MK_STICKY MK_HEAD " %5s %s %s %s %s\n", "", lbl,
+ h1, h2, h3);
buf_rule(t, IS_RULE_W);
buf_line(t, "\n");
buf_line(t, MK_HEAD "%s\n", gr->title);
@@ -2362,8 +2375,8 @@ static void fmt_saldobalans(struct buf *t, const struct app *a,
tui_pad_hdr(h2, sizeof h2, 14, "Debet");
tui_pad_hdr(h3, sizeof h3, 14, "Kredit");
tui_pad_hdr(h4, sizeof h4, 14, "Utgående");
- buf_line(t, MK_HEAD " %5s %s %s %s %s %s\n", "Konto", nmh, h1, h2, h3,
- h4);
+ buf_line(t, MK_STICKY MK_HEAD " %5s %s %s %s %s %s\n", "Konto", nmh, h1,
+ h2, h3, h4);
buf_rule(t, BS_RULE_W);
yyjson_val *arr = yyjson_obj_get(res, "accounts");
size_t n = yyjson_arr_size(arr);
@@ -2541,8 +2554,8 @@ static void fmt_huvudbok(struct buf *t, const struct app *a, yyjson_val *res)
if (lv)
buf_line(t, MK_DIM "Senaste ver.: %s%lld\n\n", vstr(lv, "series"),
(long long)vint(lv, "number"));
- buf_line(t, MK_HEAD "%-8s %-58s %14s %14s %16s\n", "Konto", "", "Debet",
- "Kredit", "Saldo");
+ buf_line(t, MK_STICKY MK_HEAD "%-8s %-58s %14s %14s %16s\n", "Konto", "",
+ "Debet", "Kredit", "Saldo");
buf_rule(t, 114);
yyjson_val *accs = yyjson_obj_get(res, "accounts");
size_t n = yyjson_arr_size(accs);
@@ -2604,8 +2617,8 @@ static void fmt_verifikationslista(struct buf *t, const struct app *a,
(long long)vint(lv, "number"));
char nmh[64];
tui_pad_label(nmh, sizeof nmh, "Benämning", 48);
- buf_line(t, MK_HEAD "%-8s %-11s %s %14s %14s\n", "Ver.", "Datum/Konto",
- nmh, "Debet", "Kredit");
+ buf_line(t, MK_STICKY MK_HEAD "%-8s %-11s %s %14s %14s\n", "Ver.",
+ "Datum/Konto", nmh, "Debet", "Kredit");
buf_rule(t, 98);
yyjson_val *vs = yyjson_obj_get(res, "vouchers");
size_t n = yyjson_arr_size(vs);
@@ -5385,7 +5398,7 @@ static void strip_markup(const char *in, struct buf *out)
for (const char *p = in; *p;) {
const char *nl = strchr(p, '\n');
size_t len = nl ? (size_t)(nl - p) : strlen(p);
- if (len && p[0] >= TUI_MARK_HEADING && p[0] <= TUI_MARK_RULE) {
+ if (len && p[0] >= TUI_MARK_HEADING && p[0] <= TUI_MARK_STICKY) {
p++;
len--;
}