From 173c87aa3875e29fb0342a6777113fb84d424434 Mon Sep 17 00:00:00 2001 From: Gennadiy Volkov Date: Tue, 8 Oct 2019 15:30:07 +1100 Subject: [PATCH 1/2] copymode: Place cursor at end of buffer content More convenient as that's where the most recent command and output is. Additionally the original code placed the cursor one line off (base 0, but vis expects base 1). --- dvtm.c | 2 +- vt.c | 6 ++++++ vt.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dvtm.c b/dvtm.c index 2b7ebdc..e6fde85 100644 --- a/dvtm.c +++ b/dvtm.c @@ -1112,7 +1112,7 @@ copymode(const char *args[]) { const char *argv[3] = { args[0], NULL, NULL }; char argline[32]; - int line = vt_content_start(sel->app); + int line = 1 + vt_content_end(sel->app); snprintf(argline, sizeof(argline), "+%d", line); argv[1] = argline; diff --git a/vt.c b/vt.c index 8a78ada..c1c7d1f 100644 --- a/vt.c +++ b/vt.c @@ -1966,3 +1966,9 @@ int vt_content_start(Vt *t) { return t->buffer->scroll_above; } + +int vt_content_end(Vt *t) +{ + int curs_row = t->buffer->curs_row - t->buffer->lines; + return vt_content_start(t) + curs_row; +} diff --git a/vt.h b/vt.h index 0cd9e8a..6d1c3d6 100644 --- a/vt.h +++ b/vt.h @@ -62,5 +62,6 @@ void vt_noscroll(Vt*); pid_t vt_pid_get(Vt*); size_t vt_content_get(Vt*, char **s, bool colored); int vt_content_start(Vt*); +int vt_content_end(Vt*); #endif /* VT_H */ From 56292227c3184a57efdb29753cec3b00967ffa45 Mon Sep 17 00:00:00 2001 From: Gennadiy Volkov Date: Sun, 20 Oct 2019 17:27:53 +1100 Subject: [PATCH 2/2] copymode: Place cursor at end of prev cmd output --- dvtm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvtm.c b/dvtm.c index e6fde85..d6efe2d 100644 --- a/dvtm.c +++ b/dvtm.c @@ -1112,7 +1112,7 @@ copymode(const char *args[]) { const char *argv[3] = { args[0], NULL, NULL }; char argline[32]; - int line = 1 + vt_content_end(sel->app); + int line = vt_content_end(sel->app); snprintf(argline, sizeof(argline), "+%d", line); argv[1] = argline;