From 30214bf817c1e18235fcddacac851ecc5cbe66a0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 3 Oct 2023 17:08:40 -0700 Subject: libs/txt,modules/*: rename txt_render_fragment() Mechanical rename to txt_render_fragment_aligned(), updating all existing call sites accordingly. This is a preparatory commit for introducing an offsetted variant of txt_render_fragment() (txt_render_fragment_offsetted()). No functional difference, purely naming changes. --- src/libs/txt/txt.c | 19 ++++++++++++++----- src/libs/txt/txt.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src/libs') diff --git a/src/libs/txt/txt.c b/src/libs/txt/txt.c index 883cd3e..d575821 100644 --- a/src/libs/txt/txt.c +++ b/src/libs/txt/txt.c @@ -168,22 +168,19 @@ static inline void draw_char(til_fb_fragment_t *fragment, uint32_t color, int x, } -void txt_render_fragment(txt_t *txt, til_fb_fragment_t *fragment, uint32_t color, int x, int y, txt_align_t alignment) +static void txt_render(txt_t *txt, til_fb_fragment_t *fragment, uint32_t color, int jx, int jy) { - int jx, jy, col, row; + int col, row; char *str; assert(txt); assert(fragment); - justify(alignment, x, y, txt->width, txt->height, &jx, &jy); - if (!overlaps(jx, jy, txt->width, txt->height, fragment->x, fragment->y, fragment->width, fragment->height)) return; - for (col = 0, row = 0, str = txt->str; *str; str++) { switch (*str) { case ' '...'~': @@ -201,3 +198,15 @@ void txt_render_fragment(txt_t *txt, til_fb_fragment_t *fragment, uint32_t color } } } + + +void txt_render_fragment_aligned(txt_t *txt, til_fb_fragment_t *fragment, uint32_t color, int x, int y, txt_align_t alignment) +{ + int jx, jy; + + assert(txt); + + justify(alignment, x, y, txt->width, txt->height, &jx, &jy); + + return txt_render(txt, fragment, color, jx, jy); +} diff --git a/src/libs/txt/txt.h b/src/libs/txt/txt.h index a924b25..9318546 100644 --- a/src/libs/txt/txt.h +++ b/src/libs/txt/txt.h @@ -28,6 +28,6 @@ typedef struct txt_align_t { txt_t * txt_new(const char *str); txt_t * txt_newf(const char *fmt, ...); txt_t * txt_free(txt_t *txt); -void txt_render_fragment(txt_t *txt, til_fb_fragment_t *fragment, uint32_t color, int x, int y, txt_align_t alignment); +void txt_render_fragment_aligned(txt_t *txt, til_fb_fragment_t *fragment, uint32_t color, int x, int y, txt_align_t alignment); #endif -- cgit v1.2.1