diff options
author | nicm <nicm> | 2019-05-28 07:18:42 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-05-28 07:18:42 +0000 |
commit | 799a154b91c6e6ff7dbe62b67272f09578c99914 (patch) | |
tree | 1524162e444623f07f5492f9382c9edd07c19bba /mode-tree.c | |
parent | 90cd045cf354000cbf9c1f66e27366868a040588 (diff) | |
download | rtmux-799a154b91c6e6ff7dbe62b67272f09578c99914.tar.gz rtmux-799a154b91c6e6ff7dbe62b67272f09578c99914.tar.bz2 rtmux-799a154b91c6e6ff7dbe62b67272f09578c99914.zip |
Change display-menu from taking a single string to a set of arguments,
which is much easier to work with. Based on a diff from Avi Halachmi.
Diffstat (limited to 'mode-tree.c')
-rw-r--r-- | mode-tree.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/mode-tree.c b/mode-tree.c index add17c82..75034675 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -35,7 +35,7 @@ struct mode_tree_data { struct window_pane *wp; void *modedata; - const char *menu; + const struct menu_item *menu; const char **sort_list; u_int sort_size; @@ -100,11 +100,14 @@ struct mode_tree_menu { static void mode_tree_free_items(struct mode_tree_list *); -#define MODE_TREE_MENU \ - "Scroll Left,<,|" \ - "Scroll Right,>,|" \ - "|" \ - "Cancel,q," +static const struct menu_item mode_tree_menu_items[] = { + { "Scroll Left", '<', NULL }, + { "Scroll Right", '>', NULL }, + { "", KEYC_NONE, NULL }, + { "Cancel", 'q', NULL }, + + { NULL, KEYC_NONE, NULL } +}; static struct mode_tree_item * mode_tree_find_item(struct mode_tree_list *mtl, uint64_t tag) @@ -315,7 +318,7 @@ struct mode_tree_data * mode_tree_start(struct window_pane *wp, struct args *args, mode_tree_build_cb buildcb, mode_tree_draw_cb drawcb, mode_tree_search_cb searchcb, mode_tree_menu_cb menucb, void *modedata, - const char *menu, const char **sort_list, u_int sort_size, + const struct menu_item *menu, const char **sort_list, u_int sort_size, struct screen **s) { struct mode_tree_data *mtd; @@ -812,8 +815,8 @@ mode_tree_display_menu(struct mode_tree_data *mtd, struct client *c, u_int x, { struct mode_tree_item *mti; struct menu *menu; + const struct menu_item *items; struct mode_tree_menu *mtm; - const char *s; char *title; u_int line; @@ -824,16 +827,15 @@ mode_tree_display_menu(struct mode_tree_data *mtd, struct client *c, u_int x, mti = mtd->line_list[line].item; if (!outside) { - s = mtd->menu; + items = mtd->menu; xasprintf(&title, "#[align=centre]%s", mti->name); } else { - s = MODE_TREE_MENU; + items = mode_tree_menu_items; title = xstrdup(""); } - menu = menu_create(s, NULL, c, NULL, title); + menu = menu_create(title); + menu_add_items(menu, items, NULL, NULL, NULL); free(title); - if (menu == NULL) - return; mtm = xmalloc(sizeof *mtm); mtm->data = mtd; |