aboutsummaryrefslogtreecommitdiff
path: root/mode-tree.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-04-23 02:01:33 +0100
committerThomas Adam <thomas@xteddy.org>2020-04-23 02:01:33 +0100
commitcf5f93b2b39c9730095a42af9e21d6960b7c0071 (patch)
treed8b8cd07b9f3624fdb94c7b9feaa350556d1ee1c /mode-tree.c
parent4a31eedc26284c04d679fe62e2a1986be74825d0 (diff)
parent950af3363678de5b88cb6713f4837f1001e46d47 (diff)
downloadrtmux-cf5f93b2b39c9730095a42af9e21d6960b7c0071.tar.gz
rtmux-cf5f93b2b39c9730095a42af9e21d6960b7c0071.tar.bz2
rtmux-cf5f93b2b39c9730095a42af9e21d6960b7c0071.zip
Merge branch 'obsd-master'
Diffstat (limited to 'mode-tree.c')
-rw-r--r--mode-tree.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/mode-tree.c b/mode-tree.c
index 0177d618..783ffcfa 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -256,8 +256,8 @@ mode_tree_expand_current(struct mode_tree_data *mtd)
}
}
-void
-mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag)
+static int
+mode_tree_get_tag(struct mode_tree_data *mtd, uint64_t tag, u_int *found)
{
u_int i;
@@ -266,15 +266,41 @@ mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag)
break;
}
if (i != mtd->line_size) {
- mtd->current = i;
+ *found = i;
+ return (1);
+ }
+ return (0);
+}
+
+void
+mode_tree_expand(struct mode_tree_data *mtd, uint64_t tag)
+{
+ u_int found;
+
+ if (!mode_tree_get_tag(mtd, tag, &found))
+ return;
+ if (!mtd->line_list[found].item->expanded) {
+ mtd->line_list[found].item->expanded = 1;
+ mode_tree_build(mtd);
+ }
+}
+
+int
+mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag)
+{
+ u_int found;
+
+ if (mode_tree_get_tag(mtd, tag, &found)) {
+ mtd->current = found;
if (mtd->current > mtd->height - 1)
mtd->offset = mtd->current - mtd->height + 1;
else
mtd->offset = 0;
- } else {
- mtd->current = 0;
- mtd->offset = 0;
+ return (1);
}
+ mtd->current = 0;
+ mtd->offset = 0;
+ return (0);
}
u_int