diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-08-07 17:27:40 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-08-07 17:51:28 (EDT) |
commit | 3bfc960bce1f9b81a6d43601165de38a6b4e2ad3 (patch) | |
tree | ea4108dfe5f9affa1d23bf38ba6dc127d182cc3c /src/tk | |
parent | b16bd8260a484a7be8df0528225794a54c42767f (diff) | |
download | mazefight-3bfc960bce1f9b81a6d43601165de38a6b4e2ad3.zip mazefight-3bfc960bce1f9b81a6d43601165de38a6b4e2ad3.tar.gz mazefight-3bfc960bce1f9b81a6d43601165de38a6b4e2ad3.tar.bz2 |
tk: Add text widget value setter
Diffstat (limited to 'src/tk')
-rw-r--r-- | src/tk/text.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tk/text.c b/src/tk/text.c index 7406b0b..3b95d2a 100644 --- a/src/tk/text.c +++ b/src/tk/text.c @@ -354,3 +354,19 @@ mftk_text_new(char min_char, char max_char, int len, const char *val, return w; } + +void +mftk_text_set_value(struct mftk_widget *w, const char *val) +{ + struct mftk_text *t = (struct mftk_text *) w; + + t->cur = strlen(val); + if (t->cur > t->len) { + t->cur = t->len; + } + memcpy(t->val, val, t->cur); + t->val[t->cur] = '\0'; + + SDL_DestroyTexture(t->texture); + t->texture = NULL; +} |