summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-05-20 18:36:10 +0200
committerUros Majstorovic <majstor@majstor.org>2021-05-20 18:36:10 +0200
commitad43c402b05ef05c7bf5a7104a4f896e65b3ac4d (patch)
tree170f55788ea5a815f6fd2307ff3342cb556e9c19 /fw
parent2aaa54722c78e4739026d8ed608e8c7ff162a38c (diff)
string widget update added
Diffstat (limited to 'fw')
-rw-r--r--fw/fe310/eos/eve/widget/strw.c12
-rw-r--r--fw/fe310/eos/eve/widget/strw.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index 232e52c..e78cf46 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -62,6 +62,18 @@ void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEFont *fon
if (_widget->g.h == 0) _widget->g.h = eve_font_h(widget->font);
}
+int eve_strw_update(EVEStrWidget *widget) {
+ int rv, str_len;
+
+ rv = utf8_verify(widget->str, widget->str_size, &str_len);
+ if (rv != UTF_OK) {
+ if (str_len >= widget->str_size) str_len = 0;
+ widget->str[str_len] = '\0';
+ }
+ widget->str_len = str_len;
+ return (rv == UTF_OK) ? EVE_OK : EVE_ERR;
+}
+
void eve_strw_destroy(EVEStrWidget *widget) {
eve_free(widget->str);
}
diff --git a/fw/fe310/eos/eve/widget/strw.h b/fw/fe310/eos/eve/widget/strw.h
index aaa83fe..44e5e2d 100644
--- a/fw/fe310/eos/eve/widget/strw.h
+++ b/fw/fe310/eos/eve/widget/strw.h
@@ -34,6 +34,7 @@ typedef struct EVEStrSpec {
int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEStrSpec *spec);
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *str, uint16_t str_size);
void eve_strw_destroy(EVEStrWidget *widget);
+int eve_strw_update(EVEStrWidget *widget);
uint8_t eve_strw_draw(EVEWidget *_widget, uint8_t tag0);
int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt);