diff options
author | KatolaZ <katolaz@freaknet.org> | 2019-07-30 16:25:49 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2019-07-30 16:25:49 +0100 |
commit | 6da2f3f89afda08eeba385da1c36414154113d47 (patch) | |
tree | f4eafa7a316e52555a0c8afb5c3874d0c3b65f1f /lineset.c | |
parent | eebc645dee0d15871d6cc46f156d424cd916b191 (diff) |
fix bug in paste at point
Diffstat (limited to 'lineset.c')
-rw-r--r-- | lineset.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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(); } |