aboutsummaryrefslogtreecommitdiff
path: root/cmd-bind-key.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-03-28 14:08:09 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-03-28 14:08:09 +0000
commitcb2ac5c269d42d1f95e6dc6e5585c4ac01a360e4 (patch)
tree073904bbde12e7de88bf481cb50ca29436251a89 /cmd-bind-key.c
parent587badecdb4eed64835e076a589631ceda3bcae5 (diff)
downloadrtmux-cb2ac5c269d42d1f95e6dc6e5585c4ac01a360e4.tar.gz
rtmux-cb2ac5c269d42d1f95e6dc6e5585c4ac01a360e4.tar.bz2
rtmux-cb2ac5c269d42d1f95e6dc6e5585c4ac01a360e4.zip
Key repeating is now a property of the key binding not of the command. Repeat
is turned on when the key is bound with the -r flag to bind-key. next/previous- window no longer repeat by default as it turned out to annoy me.
Diffstat (limited to 'cmd-bind-key.c')
-rw-r--r--cmd-bind-key.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/cmd-bind-key.c b/cmd-bind-key.c
index d8dc0dff..1991bae9 100644
--- a/cmd-bind-key.c
+++ b/cmd-bind-key.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-bind-key.c,v 1.19 2009-01-19 18:23:40 nicm Exp $ */
+/* $Id: cmd-bind-key.c,v 1.20 2009-03-28 14:08:09 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -33,12 +33,13 @@ size_t cmd_bind_key_print(struct cmd *, char *, size_t);
struct cmd_bind_key_data {
int key;
+ int can_repeat;
struct cmd_list *cmdlist;
};
const struct cmd_entry cmd_bind_key_entry = {
"bind-key", "bind",
- "key command [arguments]",
+ "[-r] key command [arguments]",
0,
NULL,
cmd_bind_key_parse,
@@ -56,11 +57,15 @@ cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
int opt;
self->data = data = xmalloc(sizeof *data);
+ data->can_repeat = 0;
data->cmdlist = NULL;
- while ((opt = getopt(argc, argv, "")) != -1) {
+ while ((opt = getopt(argc, argv, "r")) != -1) {
switch (opt) {
- default:
+ case 'r':
+ data->can_repeat = 1;
+ break;
+ default:
goto usage;
}
}
@@ -97,7 +102,7 @@ cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
if (data == NULL)
return (0);
- key_bindings_add(data->key, data->cmdlist);
+ key_bindings_add(data->key, data->can_repeat, data->cmdlist);
data->cmdlist = NULL; /* avoid free */
return (0);