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.
This commit is contained in:
Nicholas Marriott
2009-03-28 14:08:09 +00:00
parent 587badecdb
commit cb2ac5c269
12 changed files with 89 additions and 83 deletions

View File

@ -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);