summaryrefslogtreecommitdiffstats
path: root/src/tk
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-08-06 22:23:09 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-08-06 22:23:09 (EDT)
commit9c6c2d41417246a711381352185b9b4340ce6857 (patch)
tree7e85b17f0d107b9940af90a75d1ded46912e10a9 /src/tk
parent6a45a31b8b7e1a88dc5b6354f12ad40ea43e7dd3 (diff)
downloadmazefight-9c6c2d41417246a711381352185b9b4340ce6857.zip
mazefight-9c6c2d41417246a711381352185b9b4340ce6857.tar.gz
mazefight-9c6c2d41417246a711381352185b9b4340ce6857.tar.bz2
tk: Fix text insertion
Diffstat (limited to 'src/tk')
-rw-r--r--src/tk/text.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/tk/text.c b/src/tk/text.c
index 6a89b44..4a8196d 100644
--- a/src/tk/text.c
+++ b/src/tk/text.c
@@ -136,6 +136,7 @@ _mftk_text_key_event(struct mftk_widget *w, SDL_Event *e)
if (len + newlen > t->len) {
newlen = t->len - len;
}
+ memcpy(t->curval, t->val + t->cur, len - t->cur);
for (i = 0, j = 0;
i < newlen && e->text.text[j] != '\0';
++j) {
@@ -145,6 +146,8 @@ _mftk_text_key_event(struct mftk_widget *w, SDL_Event *e)
++i;
}
t->cur += i;
+ memcpy(t->val + t->cur, t->curval, len - t->cur + i);
+ t->val[len + i] = '\0';
SDL_DestroyTexture(t->texture);
t->texture = NULL;
if (t->action == NULL) {