diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-10-03 17:08:40 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-10-03 17:08:40 -0700 |
commit | 30214bf817c1e18235fcddacac851ecc5cbe66a0 (patch) | |
tree | af42c9c9170096a15d4de9bb27d13385b4b70b7b /src/libs/txt | |
parent | f97c10d4fa915a7730a814b8de05cafb3750fdae (diff) |
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.
Diffstat (limited to 'src/libs/txt')
-rw-r--r-- | src/libs/txt/txt.c | 19 | ||||
-rw-r--r-- | src/libs/txt/txt.h | 2 |
2 files changed, 15 insertions, 6 deletions
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 |