Add /help

Now with automatic search! Also had to fix the SIGCHLD handling...
weechat-hashes
C. McEnroe 2020-02-09 14:09:27 -05:00
parent f0e2c089c9
commit 5254e1035c
4 changed files with 34 additions and 0 deletions

View File

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

2
chat.c
View File

@ -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]) {

View File

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

7
ui.c
View File

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