summary refs log tree commit diff
diff options
context:
space:
mode:
authorC. McEnroe2021-05-28 20:38:43 -0400
committerC. McEnroe2021-05-28 20:40:25 -0400
commitf559322224cc3bfa6c1d37631fb6dc5fa93449b9 (patch)
treeaf54593bc7b2fa0f28df12345b97a523a10eeb56
parent1deee3c81bd7862be52bb2f03da7648756f1e3c9 (diff)
List windows with /window 1.8
Reuse the /window command to preserve /wi abbreviation.
-rw-r--r--catgirl.14
-rw-r--r--chat.h1
-rw-r--r--command.c5
-rw-r--r--ui.c10
4 files changed, 17 insertions, 3 deletions
diff --git a/catgirl.1 b/catgirl.1
index 8ae7313..23615af 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd May 27, 2021
+.Dd May 28, 2021
 .Dt CATGIRL 1
 .Os
 .
@@ -517,6 +517,8 @@ or matching
 Temporarily remove a message highlight pattern.
 .It Ic /unignore Ar 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 num | Ic / Ns Ar num
diff --git a/chat.h b/chat.h
index 44ec9b8..e48799c 100644
--- a/chat.h
+++ b/chat.h
@@ -302,6 +302,7 @@ void uiInitLate(void);
 void uiShow(void);
 void uiHide(void);
 void uiDraw(void);
+void uiWindows(void);
 void uiShowID(uint id);
 void uiShowNum(uint num);
 void uiMoveID(uint id, uint num);
diff --git a/command.c b/command.c
index ef82d30..4c290fc 100644
--- a/command.c
+++ b/command.c
@@ -373,8 +373,9 @@ static void commandQuery(uint id, char *params) {
 }
 
 static void commandWindow(uint id, char *params) {
-	if (!params) return;
-	if (isdigit(params[0])) {
+	if (!params) {
+		uiWindows();
+	} else if (isdigit(params[0])) {
 		uiShowNum(strtoul(params, NULL, 10));
 	} else {
 		id = idFind(params);
diff --git a/ui.c b/ui.c
index add6eb3..6449e27 100644
--- a/ui.c
+++ b/ui.c
@@ -797,6 +797,16 @@ static void inputUpdate(void) {
 	wmove(input, y, x);
 }
 
+void uiWindows(void) {
+	for (uint num = 0; num < windows.len; ++num) {
+		const struct Window *window = windows.ptrs[num];
+		uiFormat(
+			Network, Warm, NULL, "\3%02d%u %s",
+			idColors[window->id], num, idNames[window->id]
+		);
+	}
+}
+
 static void windowShow(uint num) {
 	if (num != windows.show) {
 		windows.swap = windows.show;