-/* $OpenBSD: key-bindings.c,v 1.135 2021/06/10 07:52:56 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.136 2021/08/09 13:08:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
"bind -Tcopy-mode C-f send -X cursor-right",
"bind -Tcopy-mode C-b send -X cursor-left",
"bind -Tcopy-mode C-g send -X clear-selection",
- "bind -Tcopy-mode C-k send -X copy-end-of-line",
+ "bind -Tcopy-mode C-k send -X copy-end-of-line-and-cancel",
"bind -Tcopy-mode C-n send -X cursor-down",
"bind -Tcopy-mode C-p send -X cursor-up",
"bind -Tcopy-mode C-r command-prompt -T search -ip'(search up)' -I'#{pane_search_string}' 'send -X search-backward-incremental \"%%%\"'",
"bind -Tcopy-mode-vi ? command-prompt -T search -p'(search up)' 'send -X search-backward \"%%%\"'",
"bind -Tcopy-mode-vi A send -X append-selection-and-cancel",
"bind -Tcopy-mode-vi B send -X previous-space",
- "bind -Tcopy-mode-vi D send -X copy-end-of-line",
+ "bind -Tcopy-mode-vi D send -X copy-end-of-line-and-cancel",
"bind -Tcopy-mode-vi E send -X next-space-end",
"bind -Tcopy-mode-vi F command-prompt -1p'(jump backward)' 'send -X jump-backward \"%%%\"'",
"bind -Tcopy-mode-vi G send -X history-bottom",
-.\" $OpenBSD: tmux.1,v 1.846 2021/08/06 09:19:02 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.847 2021/08/09 13:08:08 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 6 2021 $
+.Dd $Mdocdate: August 9 2021 $
.Dt TMUX 1
.Os
.Sh NAME
.It Li "bottom-line" Ta "L" Ta ""
.It Li "cancel" Ta "q" Ta "Escape"
.It Li "clear-selection" Ta "Escape" Ta "C-g"
-.It Li "copy-end-of-line [<prefix>]" Ta "D" Ta "C-k"
+.It Li "copy-end-of-line [<prefix>]" Ta "" Ta ""
+.It Li "copy-end-of-line-and-cancel [<prefix>]" Ta "D" Ta "C-k"
.It Li "copy-line [<prefix>]" Ta "" Ta ""
+.It Li "copy-line-and-cancel [<prefix>]" Ta "" Ta ""
.It Li "copy-pipe [<command>] [<prefix>]" Ta "" Ta ""
.It Li "copy-pipe-no-clear [<command>] [<prefix>]" Ta "" Ta ""
.It Li "copy-pipe-and-cancel [<command>] [<prefix>]" Ta "" Ta ""
-/* $OpenBSD: window-copy.c,v 1.324 2021/06/10 07:58:42 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.325 2021/08/09 13:08:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
static enum window_copy_cmd_action
window_copy_cmd_copy_end_of_line(struct window_copy_cmd_state *cs)
+{
+ struct window_mode_entry *wme = cs->wme;
+ struct client *c = cs->c;
+ struct session *s = cs->s;
+ struct winlink *wl = cs->wl;
+ struct window_pane *wp = wme->wp;
+ u_int np = wme->prefix, ocx, ocy, ooy;
+ struct window_copy_mode_data *data = wme->data;
+ char *prefix = NULL;
+
+ if (cs->args->argc == 2)
+ prefix = format_single(NULL, cs->args->argv[1], c, s, wl, wp);
+
+ ocx = data->cx;
+ ocy = data->cy;
+ ooy = data->oy;
+
+ window_copy_start_selection(wme);
+ for (; np > 1; np--)
+ window_copy_cursor_down(wme, 0);
+ window_copy_cursor_end_of_line(wme);
+
+ if (s != NULL)
+ window_copy_copy_selection(wme, prefix);
+ window_copy_clear_selection(wme);
+
+ data->cx = ocx;
+ data->cy = ocy;
+ data->oy = ooy;
+
+ free(prefix);
+ return (WINDOW_COPY_CMD_REDRAW);
+}
+
+static enum window_copy_cmd_action
+window_copy_cmd_copy_end_of_line_and_cancel(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
struct client *c = cs->c;
static enum window_copy_cmd_action
window_copy_cmd_copy_line(struct window_copy_cmd_state *cs)
+{
+ struct window_mode_entry *wme = cs->wme;
+ struct client *c = cs->c;
+ struct session *s = cs->s;
+ struct winlink *wl = cs->wl;
+ struct window_pane *wp = wme->wp;
+ struct window_copy_mode_data *data = wme->data;
+ u_int np = wme->prefix, ocx, ocy, ooy;
+ char *prefix = NULL;
+
+ if (cs->args->argc == 2)
+ prefix = format_single(NULL, cs->args->argv[1], c, s, wl, wp);
+
+ ocx = data->cx;
+ ocy = data->cy;
+ ooy = data->oy;
+
+ data->selflag = SEL_CHAR;
+ window_copy_cursor_start_of_line(wme);
+ window_copy_start_selection(wme);
+ for (; np > 1; np--)
+ window_copy_cursor_down(wme, 0);
+ window_copy_cursor_end_of_line(wme);
+
+ if (s != NULL)
+ window_copy_copy_selection(wme, prefix);
+ window_copy_clear_selection(wme);
+
+ data->cx = ocx;
+ data->cy = ocy;
+ data->oy = ooy;
+
+ free(prefix);
+ return (WINDOW_COPY_CMD_REDRAW);
+}
+
+static enum window_copy_cmd_action
+window_copy_cmd_copy_line_and_cancel(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
struct client *c = cs->c;
window_copy_cmd_clear_selection },
{ "copy-end-of-line", 0, 1, WINDOW_COPY_CMD_CLEAR_ALWAYS,
window_copy_cmd_copy_end_of_line },
+ { "copy-end-of-line-and-cancel", 0, 1, WINDOW_COPY_CMD_CLEAR_ALWAYS,
+ window_copy_cmd_copy_end_of_line_and_cancel },
{ "copy-line", 0, 1, WINDOW_COPY_CMD_CLEAR_ALWAYS,
window_copy_cmd_copy_line },
+ { "copy-line-and-cancel", 0, 1, WINDOW_COPY_CMD_CLEAR_ALWAYS,
+ window_copy_cmd_copy_line_and_cancel },
{ "copy-pipe-no-clear", 0, 2, WINDOW_COPY_CMD_CLEAR_NEVER,
window_copy_cmd_copy_pipe_no_clear },
{ "copy-pipe", 0, 2, WINDOW_COPY_CMD_CLEAR_ALWAYS,