summaryrefslogtreecommitdiffstats
path: root/cmd-send-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2016-11-29 12:54:46 +0000
committernicm <nicm>2016-11-29 12:54:46 +0000
commit6b46c62bb49c3ab532d4eba7eee226df2877490b (patch)
treeb549a0950442df891450f55d6975088221ba9c6a /cmd-send-keys.c
parent9fc925ac51cb1a6217d46b36b286edd6c39d890f (diff)
Make send -N work for all keys, not just in copy mode. From Artem Fokin.
Diffstat (limited to 'cmd-send-keys.c')
-rw-r--r--cmd-send-keys.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/cmd-send-keys.c b/cmd-send-keys.c
index f94b8f6d..dff4f51e 100644
--- a/cmd-send-keys.c
+++ b/cmd-send-keys.c
@@ -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);