From 58e1d5b4e2fabead1aae356dd060bfc9748bdd5e Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Sat, 8 Feb 2020 00:01:59 -0500 Subject: Handle NICK --- complete.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'complete.c') diff --git a/complete.c b/complete.c index 437bb7d..c194536 100644 --- a/complete.c +++ b/complete.c @@ -110,6 +110,27 @@ void completeReject(void) { match = NULL; } +size_t completeID(const char *str) { + for (match = (match ? match->next : head); match; match = match->next) { + if (match->id && !strcmp(match->str, str)) return match->id; + } + return None; +} + +void completeReplace(size_t id, const char *old, const char *new) { + struct Node *next = NULL; + for (struct Node *node = head; node; node = node->next) { + next = node->next; + if (id && node->id != id) continue; + if (strcmp(node->str, old)) continue; + if (match == node) match = NULL; + free(node->str); + node->str = strdup(new); + if (!node->str) err(EX_OSERR, "strdup"); + prepend(detach(node)); + } +} + void completeRemove(size_t id, const char *str) { struct Node *next = NULL; for (struct Node *node = head; node; node = next) { -- cgit 1.4.1-2-gfad0