diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-18 13:27:04 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-18 13:27:04 +0200 |
| commit | 1c1cd947335d30e6f13d2d440da8a188c992d71a (patch) | |
| tree | a500a6373d1c52d7d4f8b73f0adb852506a40939 | |
| parent | 8d015643ded1f5c982105ff6fed7dece632846e4 (diff) | |
| download | bokf-0.1.22.tar.gz bokf-0.1.22.zip | |
bokftui: pad user text by display width in list columnsv0.1.22
Template names, org names, filenames and the account-list type column
were padded with byte widths, so Swedish characters broke the alignment.
| -rw-r--r-- | clients/bokftui.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/clients/bokftui.c b/clients/bokftui.c index f111570..be94429 100644 --- a/clients/bokftui.c +++ b/clients/bokftui.c @@ -1197,10 +1197,12 @@ static void select_fiscal_year(struct app *a) snprintf(ranges[i], sizeof ranges[i], "%s - %s", sdate ? sdate : "?", edate ? edate : "?"); snprintf(labels[i], sizeof labels[i], "%s", label ? label : ""); - char line[256]; - snprintf(line, sizeof line, "%-25s %-5s %s", ranges[i], + char line[256], stbuf[16]; + snprintf(stbuf, sizeof stbuf, "%s", strcmp(status ? status : "", "closed") == 0 ? "stängd" - : "öppen", + : "öppen"); + pad_field(stbuf, sizeof stbuf, 6); + snprintf(line, sizeof line, "%-25s %s %s", ranges[i], stbuf, labels[i]); lines[i] = xstrdup(line); if (ids[i] == prefer) @@ -1908,9 +1910,11 @@ static int64_t vouchers_new(struct app *a) snprintf(path, sizeof path, "result.items.%zu.description", i); char *ds = jstr_dup(lresp, path); - snprintf(line, sizeof line, "%-24s %-3s %2lld rader %s", - nm ? nm : "", ser ? ser : "", (long long)rc, - ds ? ds : ""); + char nmbuf[128]; + snprintf(nmbuf, sizeof nmbuf, "%s", nm ? nm : ""); + pad_field(nmbuf, sizeof nmbuf, 24); + snprintf(line, sizeof line, "%s %-3s %2lld rader %s", nmbuf, + ser ? ser : "", (long long)rc, ds ? ds : ""); names[i] = xstrdup(nm ? nm : ""); lines[i] = xstrdup(line); free(nm); @@ -2479,10 +2483,13 @@ static void accounts_report(struct app *a) char *vat = jstr_dup(resp, path); char ncol[512]; char vatbuf[32]; + char tibuf[32]; snprintf(ncol, sizeof ncol, "%s", name ? name : ""); pad_field(ncol, sizeof ncol, name_w); - snprintf(line, sizeof line, "%-6s %s %-12s %-5s %-6s %-8s\n", - number ? number : "", ncol, type_sv(type), + snprintf(tibuf, sizeof tibuf, "%s", type_sv(type)); + pad_field(tibuf, sizeof tibuf, 12); + snprintf(line, sizeof line, "%-6s %s %s %-5s %-6s %-8s\n", + number ? number : "", ncol, tibuf, active ? "ja" : "nej", sru ? sru : "", vat_display(name, vat, vatbuf, sizeof vatbuf)); buf_append(&text, line, strlen(line)); @@ -2602,7 +2609,10 @@ static void inbox_screen(struct app *a) char *fn = jstr_dup(resp, path); snprintf(path, sizeof path, "result.items.%zu.size_bytes", i); int64_t size = jint_val(resp, path, 0); - snprintf(line, sizeof line, "%-40s %8lld byte", fn ? fn : "", + char fnbuf[256]; + snprintf(fnbuf, sizeof fnbuf, "%s", fn ? fn : ""); + pad_field(fnbuf, sizeof fnbuf, 40); + snprintf(line, sizeof line, "%s %8lld byte", fnbuf, (long long)size); items[i] = xstrdup(line); free(fn); @@ -3930,9 +3940,11 @@ static void templates_screen(struct app *a) int64_t rc = jint_val(resp, path, 0); snprintf(path, sizeof path, "result.items.%zu.description", i); char *ds = jstr_dup(resp, path); - snprintf(line, sizeof line, "%-24s %-3s %2lld rader %s", - nm ? nm : "", ser ? ser : "", (long long)rc, - ds ? ds : ""); + char nmbuf[128]; + snprintf(nmbuf, sizeof nmbuf, "%s", nm ? nm : ""); + pad_field(nmbuf, sizeof nmbuf, 24); + snprintf(line, sizeof line, "%s %-3s %2lld rader %s", nmbuf, + ser ? ser : "", (long long)rc, ds ? ds : ""); names[i] = xstrdup(nm ? nm : ""); lines[i] = xstrdup(line); free(nm); @@ -4354,9 +4366,10 @@ static int select_org(struct app *a) char *name = jstr_dup(resp, path); snprintf(path, sizeof path, "result.items.%zu.role", i); char *role = jstr_dup(resp, path); - char line[256]; - snprintf(line, sizeof line, "%-30s (%s)", name ? name : "", - role ? role : ""); + char nbuf[128], line[256]; + snprintf(nbuf, sizeof nbuf, "%s", name ? name : ""); + pad_field(nbuf, sizeof nbuf, 30); + snprintf(line, sizeof line, "%s (%s)", nbuf, role ? role : ""); items[i] = xstrdup(line); snprintf(path, sizeof path, "result.items.%zu.id", i); ids[i] = jint_val(resp, path, 0); |
