summary refs log tree commit diff
path: root/complete.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-08 00:01:59 -0500
committerJune McEnroe <june@causal.agency>2020-02-08 00:01:59 -0500
commit58e1d5b4e2fabead1aae356dd060bfc9748bdd5e (patch)
tree81ef7706e6ba1579bb90130bc92c60177adaf06f /complete.c
parentOnly treat the first tab as the alignment point (diff)
downloadcatgirl-58e1d5b4e2fabead1aae356dd060bfc9748bdd5e.tar.gz
catgirl-58e1d5b4e2fabead1aae356dd060bfc9748bdd5e.zip
Handle NICK
Diffstat (limited to '')
-rw-r--r--complete.c21
1 files changed, 21 insertions, 0 deletions
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) {