tvi: cursor position after put command - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 09cb6ffbd817e3ad3b6755e3a59e7841ac2f009c
(DIR) parent d1f4855224db5c5e09d987e742cd43bace5139ba
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Sat, 16 May 2015 09:10:39 +0430
vi: cursor position after put command
Diffstat:
M vi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/vi.c b/vi.c
t@@ -830,7 +830,7 @@ static int vc_put(int cmd)
sbuf_str(sb, s);
free(s);
}
- for (i = 0; i < MAX(cnt, 1); i++)
+ for (i = 0; i < cnt; i++)
sbuf_str(sb, buf);
if (ln) {
char *s = uc_sub(ln, off, -1);
t@@ -842,6 +842,10 @@ static int vc_put(int cmd)
if (ln)
lbuf_rm(xb, xrow, xrow + 1);
lbuf_put(xb, xrow, sbuf_buf(sb));
+ if (ln)
+ xcol = ren_pos(lbuf_get(xb, xrow), off + uc_slen(buf) * cnt - 1);
+ else
+ lbuf_postindents(xb, &xrow, &xcol);
sbuf_free(sb);
return 0;
}