fix bug in paste at point - gramscii - A simple editor for ASCII box-and-arrow charts
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 6da2f3f89afda08eeba385da1c36414154113d47
(DIR) parent eebc645dee0d15871d6cc46f156d424cd916b191
(HTM) Author: KatolaZ <katolaz@freaknet.org>
Date: Tue, 30 Jul 2019 16:25:49 +0100
fix bug in paste at point
Diffstat:
M lineset.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/lineset.c b/lineset.c
@@ -102,16 +102,25 @@ void yank_region(int x1, int y1, int x2, int y2){
void paste_region(int x1, int y1){
- int i, curlen;
+ int i, curlen, pastelen;
i = y1;
while( i < HEIGHT && i < y1 + cutbuf.num){
- memcpy(screen.l[i].s + x1, cutbuf.l[i-y1].s, strlen(cutbuf.l[i-y1].s));
+ pastelen = strlen(cutbuf.l[i-y1].s);
curlen = strlen(screen.l[i].s);
+ memcpy(screen.l[i].s + x1, cutbuf.l[i-y1].s, pastelen);
if (curlen <= x1)
/* double-check this line below */
- pad_line_to_length(screen.l[i].s+curlen, x1 - curlen);
+ pad_line_to_length(screen.l[i].s + curlen, x1 - curlen);
+ if (curlen <= x1 + pastelen)
+ screen.l[i].s[x1 + pastelen] = '\0';
+
+ screen.l[i].lst = strlen(screen.l[i].s) - 1;
+#ifdef DEBUG
+ fprintf(stderr, "%d.lst: %d\n", i, screen.l[i].lst);
+#endif
i += 1;
modified = 1;
}
+ redraw();
}