summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--catgirl.17
-rw-r--r--chat.h1
-rw-r--r--command.c12
-rw-r--r--complete.c9
4 files changed, 25 insertions, 4 deletions
diff --git a/catgirl.1 b/catgirl.1
index 213b504..19a12f2 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd May 28, 2021
+.Dd June 17, 2021
 .Dt CATGIRL 1
 .Os
 .
@@ -521,8 +521,9 @@ Temporarily remove a message highlight pattern.
 Temporarily remove a message ignore pattern.
 .It Ic /window
 List all windows.
-.It Ic /window Ar name
-Switch to window by name.
+.It Ic /window Ar name | substring
+Switch to window by name
+or matching substring.
 .It Ic /window Ar num | Ic / Ns Ar num
 Switch to window by number.
 .El
diff --git a/chat.h b/chat.h
index 8c99cf5..3b6ac6a 100644
--- a/chat.h
+++ b/chat.h
@@ -360,6 +360,7 @@ char *editBuffer(size_t *pos);
 void editCompleteAdd(void);
 
 const char *complete(uint id, const char *prefix);
+const char *completeSubstr(uint id, const char *substr);
 void completeAccept(void);
 void completeReject(void);
 void completeAdd(uint id, const char *str, enum Color color);
diff --git a/command.c b/command.c
index b345e11..84cb68f 100644
--- a/command.c
+++ b/command.c
@@ -379,7 +379,17 @@ static void commandWindow(uint id, char *params) {
 		uiShowNum(strtoul(params, NULL, 10));
 	} else {
 		id = idFind(params);
-		if (id) uiShowID(id);
+		if (id) {
+			uiShowID(id);
+			return;
+		}
+		for (const char *match; (match = completeSubstr(None, params));) {
+			id = idFind(match);
+			if (!id) continue;
+			completeAccept();
+			uiShowID(id);
+			break;
+		}
 	}
 }
 
diff --git a/complete.c b/complete.c
index 5835926..ead2457 100644
--- a/complete.c
+++ b/complete.c
@@ -119,6 +119,15 @@ const char *complete(uint id, const char *prefix) {
 	return NULL;
 }
 
+const char *completeSubstr(uint id, const char *substr) {
+	for (match = (match ? match->next : head); match; match = match->next) {
+		if (match->id && match->id != id) continue;
+		if (!strcasestr(match->str, substr)) continue;
+		return match->str;
+	}
+	return NULL;
+}
+
 void completeAccept(void) {
 	if (match) prepend(detach(match));
 	match = NULL;
1ee57045f4f569fecaf4b7e2d382f5e6&follow=1'>Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe Aborting the request and leaving data around may be causing intermittent errors. Just discard the rest of the data. 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe Because apparently it's fine for servers to respond with Content-Encoding you didn't ask for, and curl won't decode it if you didn't ask for it. 2019-09-08Set title User-AgentJune McEnroe Some things don't like you if you don't send one. 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe Allows restarting consumers safely. 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe Oops, didn't see this. 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe