mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
3c1f34c208
@ -33,9 +33,9 @@ const struct cmd_entry cmd_bind_key_entry = {
|
|||||||
.name = "bind-key",
|
.name = "bind-key",
|
||||||
.alias = "bind",
|
.alias = "bind",
|
||||||
|
|
||||||
.args = { "nrN:T:", 2, -1 },
|
.args = { "nrN:T:", 1, -1 },
|
||||||
.usage = "[-nr] [-T key-table] [-N note] key "
|
.usage = "[-nr] [-T key-table] [-N note] key "
|
||||||
"command [arguments]",
|
"[command [arguments]]",
|
||||||
|
|
||||||
.flags = CMD_AFTERHOOK,
|
.flags = CMD_AFTERHOOK,
|
||||||
.exec = cmd_bind_key_exec
|
.exec = cmd_bind_key_exec
|
||||||
@ -46,7 +46,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
{
|
{
|
||||||
struct args *args = cmd_get_args(self);
|
struct args *args = cmd_get_args(self);
|
||||||
key_code key;
|
key_code key;
|
||||||
const char *tablename, *note;
|
const char *tablename, *note = args_get(args, 'N');
|
||||||
struct cmd_parse_result *pr;
|
struct cmd_parse_result *pr;
|
||||||
char **argv = args->argv;
|
char **argv = args->argv;
|
||||||
int argc = args->argc, repeat;
|
int argc = args->argc, repeat;
|
||||||
@ -65,22 +65,24 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
tablename = "prefix";
|
tablename = "prefix";
|
||||||
repeat = args_has(args, 'r');
|
repeat = args_has(args, 'r');
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc != 1) {
|
||||||
pr = cmd_parse_from_string(argv[1], NULL);
|
if (argc == 2)
|
||||||
else
|
pr = cmd_parse_from_string(argv[1], NULL);
|
||||||
pr = cmd_parse_from_arguments(argc - 1, argv + 1, NULL);
|
else
|
||||||
switch (pr->status) {
|
pr = cmd_parse_from_arguments(argc - 1, argv + 1, NULL);
|
||||||
case CMD_PARSE_EMPTY:
|
switch (pr->status) {
|
||||||
cmdq_error(item, "empty command");
|
case CMD_PARSE_EMPTY:
|
||||||
return (CMD_RETURN_ERROR);
|
cmdq_error(item, "empty command");
|
||||||
case CMD_PARSE_ERROR:
|
return (CMD_RETURN_ERROR);
|
||||||
cmdq_error(item, "%s", pr->error);
|
case CMD_PARSE_ERROR:
|
||||||
free(pr->error);
|
cmdq_error(item, "%s", pr->error);
|
||||||
return (CMD_RETURN_ERROR);
|
free(pr->error);
|
||||||
case CMD_PARSE_SUCCESS:
|
return (CMD_RETURN_ERROR);
|
||||||
break;
|
case CMD_PARSE_SUCCESS:
|
||||||
}
|
break;
|
||||||
note = args_get(args, 'N');
|
}
|
||||||
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
|
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
|
||||||
|
} else
|
||||||
|
key_bindings_add(tablename, key, note, repeat, NULL);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,16 @@ key_bindings_add(const char *name, key_code key, const char *note, int repeat,
|
|||||||
table = key_bindings_get_table(name, 1);
|
table = key_bindings_get_table(name, 1);
|
||||||
|
|
||||||
bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS);
|
bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS);
|
||||||
|
if (cmdlist == NULL) {
|
||||||
|
if (bd != NULL) {
|
||||||
|
free((void *)bd->note);
|
||||||
|
if (note != NULL)
|
||||||
|
bd->note = xstrdup(note);
|
||||||
|
else
|
||||||
|
bd->note = NULL;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (bd != NULL) {
|
if (bd != NULL) {
|
||||||
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
RB_REMOVE(key_bindings, &table->key_bindings, bd);
|
||||||
key_bindings_free(bd);
|
key_bindings_free(bd);
|
||||||
|
Loading…
Reference in New Issue
Block a user