summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-07-30 16:25:49 +0100
committerKatolaZ <katolaz@freaknet.org>2019-07-30 16:25:49 +0100
commit6da2f3f89afda08eeba385da1c36414154113d47 (patch)
treef4eafa7a316e52555a0c8afb5c3874d0c3b65f1f
parenteebc645dee0d15871d6cc46f156d424cd916b191 (diff)
fix bug in paste at point
-rw-r--r--lineset.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lineset.c b/lineset.c
index faabb30..f672798 100644
--- 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();
}