From ded54cd76479c8246a3cde1e5cd6dc1ce71ff382 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 9 Sep 2019 08:01:22 +0000 Subject: Add cursor-down-and-cancel, from Mark Kelly. --- usr.bin/tmux/tmux.1 | 3 ++- usr.bin/tmux/window-copy.c | 19 ++++++++++++++++++- 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 .\" @@ -1445,6 +1445,7 @@ The following commands are supported in copy mode: .It Li "copy-selection-no-clear []" Ta "" Ta "" .It Li "copy-selection-and-cancel []" 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 @@ -819,6 +819,21 @@ window_copy_cmd_cursor_down(struct window_copy_cmd_state *cs) return (WINDOW_COPY_CMD_NOTHING); } +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) { @@ -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, -- cgit v1.2.3