mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Add -no-clear variants of copy-selection and copy-pipe which do not
clear the selection after copying. Make copy-pipe clear the selection by default to be consistent with copy-selection. From Avi Halachmi.
This commit is contained in:
parent
6752f41c2a
commit
564e44adc6
4
tmux.1
4
tmux.1
@ -1143,8 +1143,10 @@ The following commands are supported in copy mode:
|
||||
.It Li "copy-end-of-line [<prefix>]" Ta "D" Ta "C-k"
|
||||
.It Li "copy-line [<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 ""
|
||||
.It Li "copy-selection [<prefix>]" Ta "" Ta ""
|
||||
.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-left" Ta "h" Ta "Left"
|
||||
@ -1206,6 +1208,8 @@ The
|
||||
.Ql -and-cancel
|
||||
variants of some commands exit copy mode after they have completed (for copy
|
||||
commands) or when the cursor reaches the bottom (for scrolling commands).
|
||||
.Ql -no-clear
|
||||
variants do not clear the selection.
|
||||
.Pp
|
||||
The next and previous word keys use space and the
|
||||
.Ql - ,
|
||||
|
@ -734,7 +734,7 @@ window_copy_cmd_copy_line(struct window_copy_cmd_state *cs)
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_copy_selection(struct window_copy_cmd_state *cs)
|
||||
window_copy_cmd_copy_selection_no_clear(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
struct window_mode_entry *wme = cs->wme;
|
||||
struct client *c = cs->c;
|
||||
@ -748,9 +748,18 @@ window_copy_cmd_copy_selection(struct window_copy_cmd_state *cs)
|
||||
|
||||
if (s != NULL)
|
||||
window_copy_copy_selection(wme, prefix);
|
||||
window_copy_clear_selection(wme);
|
||||
|
||||
free(prefix);
|
||||
return (WINDOW_COPY_CMD_NOTHING);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_copy_selection(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
struct window_mode_entry *wme = cs->wme;
|
||||
|
||||
window_copy_cmd_copy_selection_no_clear(cs);
|
||||
window_copy_clear_selection(wme);
|
||||
return (WINDOW_COPY_CMD_REDRAW);
|
||||
}
|
||||
|
||||
@ -758,20 +767,9 @@ static enum window_copy_cmd_action
|
||||
window_copy_cmd_copy_selection_and_cancel(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;
|
||||
char *prefix = NULL;
|
||||
|
||||
if (cs->args->argc == 2)
|
||||
prefix = format_single(NULL, cs->args->argv[1], c, s, wl, wp);
|
||||
|
||||
if (s != NULL)
|
||||
window_copy_copy_selection(wme, prefix);
|
||||
window_copy_cmd_copy_selection_no_clear(cs);
|
||||
window_copy_clear_selection(wme);
|
||||
|
||||
free(prefix);
|
||||
return (WINDOW_COPY_CMD_CANCEL);
|
||||
}
|
||||
|
||||
@ -1256,7 +1254,7 @@ window_copy_cmd_top_line(struct window_copy_cmd_state *cs)
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_copy_pipe(struct window_copy_cmd_state *cs)
|
||||
window_copy_cmd_copy_pipe_no_clear(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
struct window_mode_entry *wme = cs->wme;
|
||||
struct client *c = cs->c;
|
||||
@ -1279,31 +1277,24 @@ window_copy_cmd_copy_pipe(struct window_copy_cmd_state *cs)
|
||||
return (WINDOW_COPY_CMD_NOTHING);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_copy_pipe(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
struct window_mode_entry *wme = cs->wme;
|
||||
|
||||
window_copy_cmd_copy_pipe_no_clear(cs);
|
||||
window_copy_clear_selection(wme);
|
||||
return (WINDOW_COPY_CMD_REDRAW);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_copy_pipe_and_cancel(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;
|
||||
char *command = NULL;
|
||||
char *prefix = NULL;
|
||||
|
||||
if (cs->args->argc == 3)
|
||||
prefix = format_single(NULL, cs->args->argv[2], c, s, wl, wp);
|
||||
|
||||
if (s != NULL && *cs->args->argv[1] != '\0') {
|
||||
command = format_single(NULL, cs->args->argv[1], c, s, wl, wp);
|
||||
window_copy_copy_pipe(wme, s, prefix, command);
|
||||
free(command);
|
||||
|
||||
free(prefix);
|
||||
return (WINDOW_COPY_CMD_CANCEL);
|
||||
}
|
||||
|
||||
free(prefix);
|
||||
return (WINDOW_COPY_CMD_NOTHING);
|
||||
window_copy_cmd_copy_pipe_no_clear(cs);
|
||||
window_copy_clear_selection(wme);
|
||||
return (WINDOW_COPY_CMD_CANCEL);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
@ -1542,10 +1533,14 @@ static const struct {
|
||||
window_copy_cmd_copy_end_of_line },
|
||||
{ "copy-line", 0, 1,
|
||||
window_copy_cmd_copy_line },
|
||||
{ "copy-pipe-no-clear", 1, 2,
|
||||
window_copy_cmd_copy_pipe_no_clear },
|
||||
{ "copy-pipe", 1, 2,
|
||||
window_copy_cmd_copy_pipe },
|
||||
{ "copy-pipe-and-cancel", 1, 2,
|
||||
window_copy_cmd_copy_pipe_and_cancel },
|
||||
{ "copy-selection-no-clear", 0, 1,
|
||||
window_copy_cmd_copy_selection_no_clear },
|
||||
{ "copy-selection", 0, 1,
|
||||
window_copy_cmd_copy_selection },
|
||||
{ "copy-selection-and-cancel", 0, 1,
|
||||
|
Loading…
Reference in New Issue
Block a user