summary refs log tree commit diff
path: root/command.c
diff options
context:
space:
mode:
authorJune McEnroe2022-07-30 18:47:26 -0400
committerJune McEnroe2022-07-30 18:47:26 -0400
commit14a6486b9b2b9522982cde12c05b20931fe34999 (patch)
tree672349f06f9e998e6859a937230cc32787af2d9f /command.c
parentc0be6fe4b207fe8f57e8a9a97734302b15733831 (diff)
Switch to cache interfaces
Diffstat (limited to 'command.c')
-rw-r--r--command.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/command.c b/command.c
index dcd0e22..f5d9dbf 100644
--- a/command.c
+++ b/command.c
@@ -139,7 +139,7 @@ static void commandMsg(uint id, char *params) {
 	char *nick = strsep(&params, " ");
 	uint msg = idFor(nick);
 	if (idColors[msg] == Default) {
-		idColors[msg] = completeColor(id, nick);
+		idColors[msg] = cacheColor(id, nick);
 	}
 	if (params) {
 		splitMessage("PRIVMSG", msg, params);
@@ -380,7 +380,7 @@ static void commandQuery(uint id, char *params) {
 	if (!params) return;
 	uint query = idFor(params);
 	if (idColors[query] == Default) {
-		idColors[query] = completeColor(id, params);
+		idColors[query] = cacheColor(id, params);
 	}
 	windowShow(windowFor(query));
 }
@@ -396,10 +396,11 @@ static void commandWindow(uint id, char *params) {
 			windowShow(windowFor(id));
 			return;
 		}
-		for (const char *match; (match = completeSubstr(None, params));) {
+		struct Cursor curs = {0};
+		for (const char *match; (match = cacheSubstr(&curs, None, params));) {
 			id = idFind(match);
 			if (!id) continue;
-			completeAccept();
+			cacheAccept(&curs);
 			windowShow(windowFor(id));
 			break;
 		}
@@ -669,11 +670,11 @@ void command(uint id, char *input) {
 		return;
 	}
 
+	struct Cursor curs = {0};
 	const char *cmd = strsep(&input, " ");
-	const char *unique = complete(None, cmd);
-	if (unique && !complete(None, cmd)) {
+	const char *unique = cachePrefix(&curs, None, cmd);
+	if (unique && !cachePrefix(&curs, None, cmd)) {
 		cmd = unique;
-		completeReject();
 	}
 
 	const struct Handler *handler = bsearch(
@@ -700,9 +701,9 @@ void command(uint id, char *input) {
 	handler->fn(id, input);
 }
 
-void commandCompleteAdd(void) {
+void commandCache(void) {
 	for (size_t i = 0; i < ARRAY_LEN(Commands); ++i) {
 		if (!commandAvailable(&Commands[i])) continue;
-		completeAdd(None, Commands[i].cmd, Default);
+		cacheInsert(false, None, Commands[i].cmd);
 	}
 }