Include key bindings in customize mode.

This commit is contained in:
Nicholas Marriott
2020-05-12 08:57:55 +01:00
parent c489bf0a1e
commit 5a34f51d33
5 changed files with 496 additions and 59 deletions

View File

@ -80,6 +80,7 @@ struct mode_tree_item {
int expanded;
int tagged;
int draw_as_parent;
struct mode_tree_list children;
TAILQ_ENTRY(mode_tree_item) entry;
@ -248,6 +249,12 @@ mode_tree_get_current(struct mode_tree_data *mtd)
return (mtd->line_list[mtd->current].item->itemdata);
}
const char *
mode_tree_get_current_name(struct mode_tree_data *mtd)
{
return (mtd->line_list[mtd->current].item->name);
}
void
mode_tree_expand_current(struct mode_tree_data *mtd)
{
@ -257,6 +264,15 @@ mode_tree_expand_current(struct mode_tree_data *mtd)
}
}
void
mode_tree_collapse_current(struct mode_tree_data *mtd)
{
if (mtd->line_list[mtd->current].item->expanded) {
mtd->line_list[mtd->current].item->expanded = 0;
mode_tree_build(mtd);
}
}
static int
mode_tree_get_tag(struct mode_tree_data *mtd, uint64_t tag, u_int *found)
{
@ -543,6 +559,12 @@ mode_tree_add(struct mode_tree_data *mtd, struct mode_tree_item *parent,
return (mti);
}
void
mode_tree_draw_as_parent(struct mode_tree_item *mti)
{
mti->draw_as_parent = 1;
}
void
mode_tree_remove(struct mode_tree_data *mtd, struct mode_tree_item *mti)
{
@ -683,6 +705,8 @@ mode_tree_draw(struct mode_tree_data *mtd)
line = &mtd->line_list[mtd->current];
mti = line->item;
if (mti->draw_as_parent)
mti = mti->parent;
screen_write_cursormove(&ctx, 0, h, 0);
screen_write_box(&ctx, w, sy - h);