-/* $OpenBSD: cmd-bind-key.c,v 1.19 2014/10/20 22:29:25 nicm Exp $ */
+/* $OpenBSD: cmd-bind-key.c,v 1.20 2015/04/10 16:00:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
return (CMD_RETURN_ERROR);
}
- if (cmd != MODEKEYCOPY_COPYPIPE) {
- if (args->argc != 2) {
- cmdq_error(cmdq, "no argument allowed");
- return (CMD_RETURN_ERROR);
+ switch (cmd) {
+ case MODEKEYCOPY_APPENDSELECTION:
+ case MODEKEYCOPY_COPYSELECTION:
+ case MODEKEYCOPY_STARTNAMEDBUFFER:
+ if (args->argc == 2)
+ arg = NULL;
+ else {
+ arg = args->argv[2];
+ if (strcmp(arg, "-x") != 0) {
+ cmdq_error(cmdq, "unknown argument");
+ return (CMD_RETURN_ERROR);
+ }
}
- arg = NULL;
- } else {
+ break;
+ case MODEKEYCOPY_COPYPIPE:
if (args->argc != 3) {
cmdq_error(cmdq, "no argument given");
return (CMD_RETURN_ERROR);
}
arg = args->argv[2];
+ break;
+ default:
+ if (args->argc != 2) {
+ cmdq_error(cmdq, "no argument allowed");
+ return (CMD_RETURN_ERROR);
+ }
+ arg = NULL;
+ break;
}
mtmp.key = key;
-.\" $OpenBSD: tmux.1,v 1.416 2015/04/10 07:23:14 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.417 2015/04/10 16:00:08 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
.Ic bind-key
and
.Ic unbind-key .
-One command accepts an argument,
-.Ic copy-pipe ,
-which copies the selection and pipes it to a command.
+If
+.Ic append-selection ,
+.Ic copy-selection ,
+or
+.Ic start-named-buffer
+are given the
+.Fl x
+flag,
+.Nm
+will not exit copy mode after copying.
+.Ic copy-pipe
+copies the selection and pipes it to a command.
For example the following will bind
+.Ql C-w
+not to exit after copying and
.Ql C-q
to copy the selection into
.Pa /tmp
as well as the paste buffer:
.Bd -literal -offset indent
+bind-key -temacs-copy C-w copy-selection -x
bind-key -temacs-copy C-q copy-pipe "cat >/tmp/out"
.Ed
.Pp
-/* $OpenBSD: window-copy.c,v 1.124 2015/03/31 17:45:10 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.125 2015/04/10 16:00:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
enum window_copy_input_type inputtype;
const char *inputprompt;
char *inputstr;
+ int inputexit;
int numprefix;
case MODEKEYCOPY_APPENDSELECTION:
if (sess != NULL) {
window_copy_append_selection(wp, NULL);
- window_pane_reset_mode(wp);
- return;
+ if (arg == NULL) {
+ window_pane_reset_mode(wp);
+ return;
+ }
+ window_copy_clear_selection(wp);
+ window_copy_redraw_screen(wp);
}
break;
case MODEKEYCOPY_CANCEL:
case MODEKEYCOPY_COPYSELECTION:
if (sess != NULL) {
window_copy_copy_selection(wp, NULL);
- window_pane_reset_mode(wp);
- return;
+ if (arg == NULL) {
+ window_pane_reset_mode(wp);
+ return;
+ }
+ window_copy_clear_selection(wp);
+ window_copy_redraw_screen(wp);
}
break;
case MODEKEYCOPY_STARTOFLINE:
goto input_on;
case MODEKEYCOPY_STARTNAMEDBUFFER:
data->inputtype = WINDOW_COPY_NAMEDBUFFER;
+ data->inputexit = (arg == NULL);
data->inputprompt = "Buffer";
*data->inputstr = '\0';
goto input_on;
case WINDOW_COPY_NAMEDBUFFER:
window_copy_copy_selection(wp, data->inputstr);
*data->inputstr = '\0';
- window_pane_reset_mode(wp);
- return (0);
+ if (data->inputexit) {
+ window_pane_reset_mode(wp);
+ return (0);
+ }
+ window_copy_clear_selection(wp);
+ window_copy_redraw_screen(wp);
+ break;
case WINDOW_COPY_GOTOLINE:
window_copy_goto_line(wp, data->inputstr);
*data->inputstr = '\0';