From 9c6c2d41417246a711381352185b9b4340ce6857 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 06 Aug 2021 22:23:09 -0400 Subject: tk: Fix text insertion --- 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) { -- cgit v0.9.1