commit 5ee1873a1ec3bc220efc5e1d1203b6fec97b8b71
parent 25d90f4630b45e2b609d2e3daecb32cf5ff065fd
Author: shuall <shualloret@gmail.com>
Date: Tue, 18 Jul 2017 18:56:07 -0400
insert works correctly
- adding character was always adding to end,
- the insert logic was extending the buffer based on the character
that was there and not based on the size of the character to be inserted
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/slackline.c b/slackline.c
@@ -207,14 +207,14 @@ sl_keystroke(struct slackline *sl, int key)
/* add character to buffer */
if (sl->rcur < sl->rlen) { /* insert into buffer */
- char *ncur = sl_postoptr(sl, sl->rcur + 1);
char *cur = sl_postoptr(sl, sl->rcur);
char *end = sl_postoptr(sl, sl->rlen);
+ char *ncur = cur + sl->ubuf_len;
memmove(ncur, cur, end - cur);
}
- memcpy(sl->last, sl->ubuf, sl->ubuf_len);
+ memcpy(sl_postoptr(sl, sl->rcur), sl->ubuf, sl->ubuf_len);
sl->ptr += sl->ubuf_len;
sl->last += sl->ubuf_len;