From 3ec5dbd52ed34e48fefee989b4ea9d095ab094a7 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Fri, 18 Sep 2026 13:09:04 +0200 Subject: bokftui: caret follows field_pos in header fields (template/voucher forms) Namn/Serie/Text (and the voucher date) drew the caret at the end of the string; editing worked but the cursor never appeared to move. --- clients/bokftui.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'clients') diff --git a/clients/bokftui.c b/clients/bokftui.c index ceaf525..4895704 100644 --- a/clients/bokftui.c +++ b/clients/bokftui.c @@ -1738,7 +1738,12 @@ static int64_t vouchers_new(struct app *a) if (field == k) { attron(A_REVERSE); caret_y = hy[k]; - int cw = disp_width(hvals[k]); + size_t slen = strlen(hvals[k]); + size_t cp = (field_fresh || field_pos == (size_t)-1 || + field_pos > slen) + ? slen + : field_pos; + int cw = (int)disp_width_n(hvals[k], cp); caret_x = hx[k] + (cw > w ? w : cw); } mvaddstr(hy[k], hx[k], padded); @@ -2888,7 +2893,12 @@ static int template_form(struct app *a, const char *load_name) if (field == k) { attron(A_REVERSE); caret_y = hy[k]; - int cw = disp_width(hvals[k]); + size_t slen = strlen(hvals[k]); + size_t cp = (field_fresh || field_pos == (size_t)-1 || + field_pos > slen) + ? slen + : field_pos; + int cw = (int)disp_width_n(hvals[k], cp); caret_x = hx[k] + (cw > w ? w : cw); } mvaddstr(hy[k], hx[k], padded); -- cgit v1.3