diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-24 17:52:05 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-24 17:52:41 (EDT) |
commit | 276079b32eeeaacc154f22c545da8386cd3dbc52 (patch) | |
tree | 09ae994288bb8f34341beba514e19ac98f60fa3a /src | |
parent | c6599dff561e0dbb1df584b50ba9eeea5d3a58e9 (diff) | |
download | marquee-276079b32eeeaacc154f22c545da8386cd3dbc52.zip marquee-276079b32eeeaacc154f22c545da8386cd3dbc52.tar.gz marquee-276079b32eeeaacc154f22c545da8386cd3dbc52.tar.bz2 |
mq_tab_seek(): New function
Diffstat (limited to 'src')
-rw-r--r-- | src/tab.c | 22 | ||||
-rw-r--r-- | src/tab.h | 3 |
2 files changed, 25 insertions, 0 deletions
@@ -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); +} @@ -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 |