mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 16:43:11 +01:00
PatchSet 784
Date: 2010/11/11 20:54:06 Author: nicm Branch: HEAD Tag: (none) Log: Flag to flush all key bindings from Rob Paisley. Members: cmd-unbind-key.c:1.7->1.8 tmux.1:1.188->1.189
This commit is contained in:
parent
3a4b82d27a
commit
fe4f760eba
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-unbind-key.c,v 1.22 2010-01-25 17:12:44 tcunha Exp $ */
|
/* $Id: cmd-unbind-key.c,v 1.23 2010-12-06 21:51:02 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -33,13 +33,14 @@ int cmd_unbind_key_table(struct cmd *, struct cmd_ctx *);
|
|||||||
struct cmd_unbind_key_data {
|
struct cmd_unbind_key_data {
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
|
int flag_all;
|
||||||
int command_key;
|
int command_key;
|
||||||
char *tablename;
|
char *tablename;
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct cmd_entry cmd_unbind_key_entry = {
|
const struct cmd_entry cmd_unbind_key_entry = {
|
||||||
"unbind-key", "unbind",
|
"unbind-key", "unbind",
|
||||||
"[-cn] [-t key-table] key",
|
"[-acn] [-t key-table] key",
|
||||||
0, "",
|
0, "",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_unbind_key_parse,
|
cmd_unbind_key_parse,
|
||||||
@ -55,11 +56,15 @@ cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
int opt, no_prefix = 0;
|
int opt, no_prefix = 0;
|
||||||
|
|
||||||
self->data = data = xmalloc(sizeof *data);
|
self->data = data = xmalloc(sizeof *data);
|
||||||
|
data->flag_all = 0;
|
||||||
data->command_key = 0;
|
data->command_key = 0;
|
||||||
data->tablename = NULL;
|
data->tablename = NULL;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "cnt:")) != -1) {
|
while ((opt = getopt(argc, argv, "acnt:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'a':
|
||||||
|
data->flag_all = 1;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
data->command_key = 1;
|
data->command_key = 1;
|
||||||
break;
|
break;
|
||||||
@ -76,15 +81,20 @@ cmd_unbind_key_parse(struct cmd *self, int argc, char **argv, char **cause)
|
|||||||
}
|
}
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (argc != 1)
|
if (data->flag_all && (argc != 0 || data->tablename))
|
||||||
|
goto usage;
|
||||||
|
if (!data->flag_all && argc != 1)
|
||||||
goto usage;
|
goto usage;
|
||||||
|
|
||||||
if ((data->key = key_string_lookup_string(argv[0])) == KEYC_NONE) {
|
if (!data->flag_all) {
|
||||||
|
data->key = key_string_lookup_string(argv[0]);
|
||||||
|
if (data->key == KEYC_NONE) {
|
||||||
xasprintf(cause, "unknown key: %s", argv[0]);
|
xasprintf(cause, "unknown key: %s", argv[0]);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!no_prefix)
|
if (!no_prefix)
|
||||||
data->key |= KEYC_PREFIX;
|
data->key |= KEYC_PREFIX;
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
@ -100,13 +110,23 @@ int
|
|||||||
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct cmd_unbind_key_data *data = self->data;
|
struct cmd_unbind_key_data *data = self->data;
|
||||||
|
struct key_binding *bd;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
if (data->flag_all) {
|
||||||
|
while (!SPLAY_EMPTY(&key_bindings)) {
|
||||||
|
bd = SPLAY_ROOT(&key_bindings);
|
||||||
|
SPLAY_REMOVE(key_bindings, &key_bindings, bd);
|
||||||
|
cmd_list_free(bd->cmdlist);
|
||||||
|
xfree(bd);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (data->tablename != NULL)
|
if (data->tablename != NULL)
|
||||||
return (cmd_unbind_key_table(self, ctx));
|
return (cmd_unbind_key_table(self, ctx));
|
||||||
|
|
||||||
key_bindings_remove(data->key);
|
key_bindings_remove(data->key);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
9
tmux.1
9
tmux.1
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: tmux.1,v 1.270 2010-12-06 21:49:57 nicm Exp $
|
.\" $Id: tmux.1,v 1.271 2010-12-06 21:51:02 nicm Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
.\"
|
.\"
|
||||||
@ -14,7 +14,7 @@
|
|||||||
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: November 1 2010 $
|
.Dd $Mdocdate: November 11 2010 $
|
||||||
.Dt TMUX 1
|
.Dt TMUX 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -1479,7 +1479,7 @@ All arguments are sent sequentially from first to last.
|
|||||||
Send the prefix key to a window as if it was pressed.
|
Send the prefix key to a window as if it was pressed.
|
||||||
If multiple prefix keys are configured, only the first is sent.
|
If multiple prefix keys are configured, only the first is sent.
|
||||||
.It Xo Ic unbind-key
|
.It Xo Ic unbind-key
|
||||||
.Op Fl cn
|
.Op Fl acn
|
||||||
.Op Fl t Ar key-table
|
.Op Fl t Ar key-table
|
||||||
.Ar key
|
.Ar key
|
||||||
.Xc
|
.Xc
|
||||||
@ -1493,6 +1493,9 @@ the primary key bindings are modified; in this case, if
|
|||||||
is specified, the command bound to
|
is specified, the command bound to
|
||||||
.Ar key
|
.Ar key
|
||||||
without a prefix (if any) is removed.
|
without a prefix (if any) is removed.
|
||||||
|
If
|
||||||
|
.Fl a
|
||||||
|
is present, all key bindings are removed.
|
||||||
.Pp
|
.Pp
|
||||||
If
|
If
|
||||||
.Fl t
|
.Fl t
|
||||||
|
Loading…
Reference in New Issue
Block a user