List windows with /window

Reuse the /window command to preserve /wi abbreviation.
master
C. McEnroe 2021-05-28 20:38:43 -04:00
parent 1deee3c81b
commit f559322224
4 changed files with 17 additions and 3 deletions

View File

@ -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

1
chat.h
View File

@ -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);

View File

@ -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);

10
ui.c
View File

@ -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;