mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 18:08:51 +00:00
Trim menu item text correctly, GitHub issue 3197.
This commit is contained in:
parent
58c8ea1209
commit
86a184b288
14
menu.c
14
menu.c
@ -56,7 +56,7 @@ menu_add_item(struct menu *menu, const struct menu_item *item,
|
|||||||
{
|
{
|
||||||
struct menu_item *new_item;
|
struct menu_item *new_item;
|
||||||
const char *key = NULL, *cmd, *suffix = "";
|
const char *key = NULL, *cmd, *suffix = "";
|
||||||
char *s, *name;
|
char *s, *trimmed, *name;
|
||||||
u_int width, max_width;
|
u_int width, max_width;
|
||||||
int line;
|
int line;
|
||||||
size_t keylen, slen;
|
size_t keylen, slen;
|
||||||
@ -103,11 +103,13 @@ menu_add_item(struct menu *menu, const struct menu_item *item,
|
|||||||
max_width--;
|
max_width--;
|
||||||
suffix = ">";
|
suffix = ">";
|
||||||
}
|
}
|
||||||
if (key != NULL)
|
trimmed = format_trim_right(s, max_width);
|
||||||
xasprintf(&name, "%.*s%s#[default] #[align=right](%s)",
|
if (key != NULL) {
|
||||||
(int)max_width, s, suffix, key);
|
xasprintf(&name, "%s%s#[default] #[align=right](%s)",
|
||||||
else
|
trimmed, suffix, key);
|
||||||
xasprintf(&name, "%.*s%s", (int)max_width, s, suffix);
|
} else
|
||||||
|
xasprintf(&name, "%s%s", trimmed, suffix);
|
||||||
|
free(trimmed);
|
||||||
|
|
||||||
new_item->name = name;
|
new_item->name = name;
|
||||||
free(s);
|
free(s);
|
||||||
|
Loading…
Reference in New Issue
Block a user