summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--catgirl.16
-rw-r--r--chat.c2
-rw-r--r--command.c19
-rw-r--r--ui.c7
4 files changed, 34 insertions, 0 deletions
diff --git a/catgirl.1 b/catgirl.1
index eb7310d..5772db3 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -179,6 +179,12 @@ or matching
 Toggle logging in the
 .Sy <debug>
 window.
+.It Ic /help Op Ar search
+View this manual.
+Type
+.Ic q
+to return to
+.Nm .
 .It Ic /open Op Ar count
 Open each of
 .Ar count
diff --git a/chat.c b/chat.c
index dbad242..ff74485 100644
--- a/chat.c
+++ b/chat.c
@@ -191,6 +191,7 @@ int main(int argc, char *argv[]) {
 		if (signals[SIGINT] || signals[SIGTERM]) break;
 
 		if (signals[SIGCHLD]) {
+			signals[SIGCHLD] = 0;
 			int status;
 			while (0 < waitpid(-1, &status, WNOHANG)) {
 				if (WIFEXITED(status) && WEXITSTATUS(status)) {
@@ -206,6 +207,7 @@ int main(int argc, char *argv[]) {
 					);
 				}
 			}
+			uiShow();
 		}
 
 		if (signals[SIGWINCH]) {
diff --git a/command.c b/command.c
index f88a6d5..44d0d54 100644
--- a/command.c
+++ b/command.c
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "chat.h"
 
@@ -158,6 +159,23 @@ static void commandCopy(size_t id, char *params) {
 	urlCopyMatch(id, params);
 }
 
+static void commandHelp(size_t id, char *params) {
+	(void)id;
+	uiHide();
+
+	pid_t pid = fork();
+	if (pid < 0) err(EX_OSERR, "fork");
+	if (pid) return;
+
+	char buf[256];
+	snprintf(buf, sizeof(buf), "ip%s$", (params ? params : "COMMANDS"));
+	setenv("LESS", buf, 1);
+	execlp("man", "man", "1", "catgirl", NULL);
+	dup2(procPipe[1], STDERR_FILENO);
+	warn("man");
+	_exit(EX_UNAVAILABLE);
+}
+
 static const struct Handler {
 	const char *cmd;
 	Command *fn;
@@ -165,6 +183,7 @@ static const struct Handler {
 	{ "/close", commandClose },
 	{ "/copy", commandCopy },
 	{ "/debug", commandDebug },
+	{ "/help", commandHelp },
 	{ "/join", commandJoin },
 	{ "/me", commandMe },
 	{ "/names", commandNames },
diff --git a/ui.c b/ui.c
index 9abfffc..66a9c59 100644
--- a/ui.c
+++ b/ui.c
@@ -156,13 +156,18 @@ static const char *ExitFocusMode  = "\33[?1004l";
 static const char *EnterPasteMode = "\33[?2004h";
 static const char *ExitPasteMode  = "\33[?2004l";
 
+static bool hidden;
+
 void uiShow(void) {
 	putp(EnterFocusMode);
 	putp(EnterPasteMode);
 	fflush(stdout);
+	hidden = false;
+	uiDraw();
 }
 
 void uiHide(void) {
+	hidden = true;
 	putp(ExitFocusMode);
 	putp(ExitPasteMode);
 	endwin();
@@ -250,6 +255,7 @@ void uiInit(void) {
 }
 
 void uiDraw(void) {
+	if (hidden) return;
 	wnoutrefresh(status);
 	struct Window *window = windows.active;
 	pnoutrefresh(
@@ -755,6 +761,7 @@ static void keyStyle(wchar_t ch) {
 }
 
 void uiRead(void) {
+	if (hidden) return;
 	int ret;
 	wint_t ch;
 	static bool style;