summaryrefslogtreecommitdiff
path: root/fw/fe310/eos
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos')
-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);