From 9d8db4146d025e3a967700414a9fc68fa186045e Mon Sep 17 00:00:00 2001 From: Riley Beckett Date: Thu, 23 Oct 2025 00:07:26 -0400 Subject: add basic cursor movement --- font.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'font.c') diff --git a/font.c b/font.c index 93cbeca..2795ab3 100644 --- a/font.c +++ b/font.c @@ -156,6 +156,15 @@ int atlas_get_strwidth(client_state* state, const char* str) { return (int)ceil(width); } +int atlas_get_strwidth_len(client_state* state, const char* str, size_t len) { + float width = 0; + // TODO - UNICODE MAKE WORKY + for (int i = 0; i < len; i++) { + width += ceil(state->atlas.metrics[(int)str[i]].advance_x); + } + return (int)ceil(width); +} + void atlas_calc_item_widths(client_state* state) { if (state->items) { array_for_all(item_t, item, state->items) { -- cgit v1.2.3