summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-09-09 08:01:22 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-09-09 08:01:22 +0000
commitded54cd76479c8246a3cde1e5cd6dc1ce71ff382 (patch)
treef2fdc71da65aa4b070d1f2aa1cb526ee4f17838f
parent392636159a9c073f3e36c0e6b2680a8feb236694 (diff)
Add cursor-down-and-cancel, from Mark Kelly.
-rw-r--r--usr.bin/tmux/tmux.13
-rw-r--r--usr.bin/tmux/window-copy.c19
2 files changed, 20 insertions, 2 deletions
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index c17ba4ac0a1..16572a6356f 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.684 2019/09/09 07:57:30 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.685 2019/09/09 08:01:21 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -1445,6 +1445,7 @@ The following commands are supported in copy mode:
.It Li "copy-selection-no-clear [<prefix>]" Ta "" Ta ""
.It Li "copy-selection-and-cancel [<prefix>]" Ta "Enter" Ta "M-w"
.It Li "cursor-down" Ta "j" Ta "Down"
+.It Li "cursor-down-and-cancel" Ta "" Ta ""
.It Li "cursor-left" Ta "h" Ta "Left"
.It Li "cursor-right" Ta "l" Ta "Right"
.It Li "cursor-up" Ta "k" Ta "Up"
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index f8e13010136..072a1aeb08c 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.233 2019/08/14 10:02:24 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.234 2019/09/09 08:01:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -820,6 +820,21 @@ window_copy_cmd_cursor_down(struct window_copy_cmd_state *cs)
}
static enum window_copy_cmd_action
+window_copy_cmd_cursor_down_and_cancel(struct window_copy_cmd_state *cs)
+{
+ struct window_mode_entry *wme = cs->wme;
+ struct window_copy_mode_data *data = wme->data;
+ u_int np = wme->prefix, cy;
+
+ cy = data->cy;
+ for (; np != 0; np--)
+ window_copy_cursor_down(wme, 0);
+ if (cy == data->cy && data->oy == 0)
+ return (WINDOW_COPY_CMD_CANCEL);
+ return (WINDOW_COPY_CMD_NOTHING);
+}
+
+static enum window_copy_cmd_action
window_copy_cmd_cursor_left(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
@@ -1810,6 +1825,8 @@ static const struct {
window_copy_cmd_copy_selection_and_cancel },
{ "cursor-down", 0, 0,
window_copy_cmd_cursor_down },
+ { "cursor-down-and-cancel", 0, 0,
+ window_copy_cmd_cursor_down_and_cancel },
{ "cursor-left", 0, 0,
window_copy_cmd_cursor_left },
{ "cursor-right", 0, 0,