summaryrefslogtreecommitdiff
path: root/src/libs/txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/txt')
-rw-r--r--src/libs/txt/txt.c19
-rw-r--r--src/libs/txt/txt.h2
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
© All Rights Reserved