summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-11-29 12:54:46 +0000
committernicm <nicm@openbsd.org>2016-11-29 12:54:46 +0000
commit6ea8b4b1aa0423b1dcc1be2c345f0f4b0166e5e4 (patch)
tree9ac4ca3da0bbccdac34f9bb8d43a7b11d4fcd427
parentReplace the hand-rolled semaphore with a read-write lock (diff)
downloadwireguard-openbsd-6ea8b4b1aa0423b1dcc1be2c345f0f4b0166e5e4.tar.xz
wireguard-openbsd-6ea8b4b1aa0423b1dcc1be2c345f0f4b0166e5e4.zip
Make send -N work for all keys, not just in copy mode. From Artem Fokin.
-rw-r--r--usr.bin/tmux/cmd-send-keys.c42
-rw-r--r--usr.bin/tmux/tmux.16
2 files changed, 22 insertions, 26 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c
index eeeb5f437f6..4bc3c6ab64c 100644
--- a/usr.bin/tmux/cmd-send-keys.c
+++ b/usr.bin/tmux/cmd-send-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-send-keys.c,v 1.33 2016/10/16 19:04:05 nicm Exp $ */
+/* $OpenBSD: cmd-send-keys.c,v 1.34 2016/11/29 12:54:46 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -66,21 +66,16 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
const u_char *keystr;
int i, literal;
key_code key;
- u_int np;
+ u_int np = 1;
char *cause = NULL;
if (args_has(args, 'N')) {
- if (wp->mode == NULL || wp->mode->command == NULL) {
- cmdq_error(item, "not in a mode");
- return (CMD_RETURN_ERROR);
- }
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause);
if (cause != NULL) {
- cmdq_error(item, "prefix %s", cause);
+ cmdq_error(item, "repeat count %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
- wp->modeprefix = np;
}
if (args_has(args, 'X')) {
@@ -88,6 +83,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "not in a mode");
return (CMD_RETURN_ERROR);
}
+ wp->modeprefix = np;
if (!m->valid)
wp->mode->command(wp, c, s, args, NULL);
else
@@ -95,9 +91,6 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL);
}
- if (args_has(args, 'N')) /* only with -X */
- return (CMD_RETURN_NORMAL);
-
if (args_has(args, 'M')) {
wp = cmd_mouse_pane(m, &s, NULL);
if (wp == NULL) {
@@ -120,19 +113,22 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'R'))
input_reset(wp, 1);
- for (i = 0; i < args->argc; i++) {
- literal = args_has(args, 'l');
- if (!literal) {
- key = key_string_lookup_string(args->argv[i]);
- if (key != KEYC_NONE && key != KEYC_UNKNOWN)
- window_pane_key(wp, NULL, s, key, NULL);
- else
- literal = 1;
- }
- if (literal) {
- for (keystr = args->argv[i]; *keystr != '\0'; keystr++)
- window_pane_key(wp, NULL, s, *keystr, NULL);
+ for (; np != 0; np--) {
+ for (i = 0; i < args->argc; i++) {
+ literal = args_has(args, 'l');
+ if (!literal) {
+ key = key_string_lookup_string(args->argv[i]);
+ if (key != KEYC_NONE && key != KEYC_UNKNOWN)
+ window_pane_key(wp, NULL, s, key, NULL);
+ else
+ literal = 1;
+ }
+ if (literal) {
+ for (keystr = args->argv[i]; *keystr != '\0'; keystr++)
+ window_pane_key(wp, NULL, s, *keystr, NULL);
+ }
}
+
}
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index e058739eb0b..72bb8227b82 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.515 2016/11/24 13:38:44 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.516 2016/11/29 12:54:46 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" 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: November 24 2016 $
+.Dd $Mdocdate: November 29 2016 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -2215,7 +2215,7 @@ the
.Sx WINDOWS AND PANES
section.
.Fl N
-specifies a repeat count to a copy mode command.
+specifies a repeat count.
.It Xo Ic send-prefix
.Op Fl 2
.Op Fl t Ar target-pane