summaryrefslogtreecommitdiffstats
path: root/menu.c
diff options
context:
space:
mode:
authornicm <nicm>2019-05-12 08:58:09 +0000
committernicm <nicm>2019-05-12 08:58:09 +0000
commita13165523598fa7670ebc95f3cfb5c892d08745a (patch)
treebb0c7517763302160f96709d6eb3480dc7618535 /menu.c
parentc91323e4d6a4bd5f2c646e315d57ead1a7c568ea (diff)
Add simple menus to tree, client, buffer modes.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/menu.c b/menu.c
index bd5996da..945b62c4 100644
--- a/menu.c
+++ b/menu.c
@@ -56,7 +56,11 @@ menu_add_item(struct menu *menu, struct menu_item *item, struct client *c,
if (item == NULL || *item->name == '\0') /* horizontal line */
return;
- name = format_single(NULL, item->name, c, fs->s, fs->wl, fs->wp);
+ if (fs != NULL) {
+ name = format_single(NULL, item->name, c, fs->s, fs->wl,
+ fs->wp);
+ } else
+ name = xstrdup(item->name);
if (*name == '\0') { /* no item if empty after format expanded */
menu->count--;
return;
@@ -118,7 +122,6 @@ menu_create(const char *s, struct client *c, struct cmd_find_state *fs,
copy = string = xstrdup(s);
do {
next = (char *)format_skip(string, "|");
- log_debug("XXX %s -- %s", next, string);
if (next != NULL)
*next++ = '\0';
if (*string == '\0')
@@ -180,6 +183,9 @@ menu_free_cb(struct client *c)
if (md->item != NULL)
md->item->flags &= ~CMDQ_WAITING;
+ if (md->cb != NULL)
+ md->cb(md->menu, UINT_MAX, KEYC_NONE, md->data);
+
screen_free(&md->s);
menu_free(md->menu);
free(md);
@@ -274,6 +280,7 @@ chosen:
return (1);
if (md->cb != NULL) {
md->cb(md->menu, md->choice, item->key, md->data);
+ md->cb = NULL;
return (1);
}
cmdlist = cmd_string_parse(item->command, NULL, 0, &cause);
@@ -308,7 +315,8 @@ menu_display(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
md->item = item;
md->flags = flags;
- cmd_find_copy_state(&md->fs, fs);
+ if (fs != NULL)
+ cmd_find_copy_state(&md->fs, fs);
screen_init(&md->s, menu->width + 4, menu->count + 2, 0);
md->px = px;