mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Sync OpenBSD patchset 512:
key_string_lookup_key uses a static buffer, so copy its output into the working buffer before calling the command print function which can also use it (eg send-keys).
This commit is contained in:
parent
7d288e7fd8
commit
f18b224983
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-keys.c,v 1.20 2009-07-28 23:19:06 tcunha Exp $ */
|
/* $Id: cmd-list-keys.c,v 1.21 2009-11-08 23:30:42 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -47,7 +47,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct cmd_target_data *data = self->data;
|
struct cmd_target_data *data = self->data;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
const char *key;
|
const char *key;
|
||||||
char tmp[BUFSIZ], keytmp[64];
|
char tmp[BUFSIZ];
|
||||||
|
size_t used;
|
||||||
int width, keywidth;
|
int width, keywidth;
|
||||||
|
|
||||||
if (data->target != NULL)
|
if (data->target != NULL)
|
||||||
@ -70,14 +71,15 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
if (!(bd->key & KEYC_PREFIX))
|
||||||
|
used = xsnprintf(tmp, sizeof tmp, "[%s]: ", key);
|
||||||
|
else
|
||||||
|
used = xsnprintf(tmp, sizeof tmp, "%*s: ", width, key);
|
||||||
|
if (used >= sizeof tmp)
|
||||||
|
continue;
|
||||||
|
|
||||||
*tmp = '\0';
|
cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
|
||||||
cmd_list_print(bd->cmdlist, tmp, sizeof tmp);
|
ctx->print(ctx, "%s", tmp);
|
||||||
if (!(bd->key & KEYC_PREFIX)) {
|
|
||||||
xsnprintf(keytmp, sizeof keytmp, "[%s]", key);
|
|
||||||
key = keytmp;
|
|
||||||
}
|
|
||||||
ctx->print(ctx, "%*s: %s", width, key, tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user