summaryrefslogtreecommitdiffstats
path: root/src/tab.c
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-24 17:52:05 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-24 17:52:41 (EDT)
commit276079b32eeeaacc154f22c545da8386cd3dbc52 (patch)
tree09ae994288bb8f34341beba514e19ac98f60fa3a /src/tab.c
parentc6599dff561e0dbb1df584b50ba9eeea5d3a58e9 (diff)
downloadmarquee-276079b32eeeaacc154f22c545da8386cd3dbc52.zip
marquee-276079b32eeeaacc154f22c545da8386cd3dbc52.tar.gz
marquee-276079b32eeeaacc154f22c545da8386cd3dbc52.tar.bz2
mq_tab_seek(): New function
Diffstat (limited to 'src/tab.c')
-rw-r--r--src/tab.c22
1 files changed, 22 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);
+}