summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tab.c22
-rw-r--r--src/tab.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/src/tab.c b/src/tab.c
index 458b56d..1fdd2ee 100644
--- a/src/tab.c
+++ b/src/tab.c
@@ -375,3 +375,25 @@ mq_tab_update_position(MqTab *tab, guint position)
tab->position = position;
update_tab_label(tab);
}
+
+MqTab *
+mq_tab_seek(MqTab *node, guint position)
+{
+ /* Skip forward to the containing subtree. */
+ while (node && node->position + node->tree_size <= position) {
+ node->next;
+ }
+
+ /* Check whether we've gone past the end of the tree. */
+ if (!node) {
+ return NULL;
+ }
+
+ /* Check whether the sibling we've reached is the node we want. */
+ if (node->position == position) {
+ return node;
+ }
+
+ /* Recurse down the subtree. */
+ return mq_tab_seek(node->first_child, position);
+}
diff --git a/src/tab.h b/src/tab.h
index b7c15d6..1042f21 100644
--- a/src/tab.h
+++ b/src/tab.h
@@ -66,4 +66,7 @@ mq_tab_get_container(MqTab *tab);
void
mq_tab_update_position(MqTab *tab, guint position);
+MqTab *
+mq_tab_seek(MqTab *node, guint position);
+
#endif