aboutsummaryrefslogtreecommitdiff
path: root/src/binds.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2018-11-26 21:27:29 +0000
committerHarry Jeffery <harry@exec64.co.uk>2018-11-26 21:27:29 +0000
commit2fa568c628f5a66c5ca2cb8ef79528a1b4287080 (patch)
tree7d430f8ba2d0f24464c0a42052224f12526ea6ac /src/binds.c
parentd2b8d20d43b01a37737c39e35effbf334a21617d (diff)
downloadimv-2fa568c628f5a66c5ca2cb8ef79528a1b4287080.tar.gz
binds: Add imv_binds_clear_key
Diffstat (limited to 'src/binds.c')
-rw-r--r--src/binds.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/binds.c b/src/binds.c
index 9e268b4..3408ad9 100644
--- a/src/binds.c
+++ b/src/binds.c
@@ -130,6 +130,30 @@ void imv_binds_clear(struct imv_binds *binds)
init_bind_node(&binds->bind_tree);
}
+void imv_binds_clear_key(struct imv_binds *binds, const struct list *keys)
+{
+ struct bind_node *node = &binds->bind_tree;
+
+ for(size_t i = 0; i < keys->len; ++i) {
+ /* Traverse the trie to find the right node for the input keys */
+ int child_index = list_find(node->suffixes, &compare_node_key, keys->items[i]);
+ if(child_index == -1) {
+ /* No such node, no more work to do */
+ return;
+ } else {
+ node = node->suffixes->items[child_index];
+ }
+ }
+
+ /* We've now found the correct node for the input */
+
+ /* Clear the commands for this node */
+ if(node->commands) {
+ list_deep_free(node->commands);
+ node->commands = NULL;
+ }
+}
+
enum lookup_result {
LOOKUP_PARTIAL,
LOOKUP_INVALID,