summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h3
-rw-r--r--command.c21
-rw-r--r--ui.c23
3 files changed, 42 insertions, 5 deletions
diff --git a/chat.h b/chat.h
index 90c7da8..b73cf40 100644
--- a/chat.h
+++ b/chat.h
@@ -112,6 +112,9 @@ void ircFormat(const char *format, ...)
 
 void handle(struct Message msg);
 void command(size_t id, char *input);
+const char *commandIsPrivmsg(size_t id, const char *input);
+const char *commandIsNotice(size_t id, const char *input);
+const char *commandIsAction(size_t id, const char *input);
 
 enum Heat { Cold, Warm, Hot };
 void uiInit(void);
diff --git a/command.c b/command.c
index ef27888..928f470 100644
--- a/command.c
+++ b/command.c
@@ -19,6 +19,27 @@
 
 #include "chat.h"
 
+const char *commandIsPrivmsg(size_t id, const char *input) {
+	if (id == Network || id == Debug) return NULL;
+	if (input[0] != '/') return input;
+	const char *space = strchr(&input[1], ' ');
+	const char *slash = strchr(&input[1], '/');
+	if (slash && (!space || slash < space)) return input;
+	return NULL;
+}
+
+const char *commandIsNotice(size_t id, const char *input) {
+	if (id == Network || id == Debug) return NULL;
+	if (strncmp(input, "/notice ", 8)) return NULL;
+	return &input[8];
+}
+
+const char *commandIsAction(size_t id, const char *input) {
+	if (id == Network || id == Debug) return NULL;
+	if (strncmp(input, "/me ", 4)) return NULL;
+	return &input[4];
+}
+
 void command(size_t id, char *input) {
 	if (id == Debug) {
 		ircFormat("%s\r\n", input);
diff --git a/ui.c b/ui.c
index 12c8541..daa6dec 100644
--- a/ui.c
+++ b/ui.c
@@ -479,16 +479,29 @@ static void inputUpdate(void) {
 		colorPair(mapColor(self.color), -1),
 		NULL
 	);
+	const char *head = editHead();
+	const char *skip = NULL;
 	if (self.nick) {
-		// TODO: Check if input is command or action.
-		waddch(input, '<');
-		waddstr(input, self.nick);
-		waddstr(input, "> ");
+		size_t id = windows.active->id;
+		if (NULL != (skip = commandIsPrivmsg(id, head))) {
+			waddch(input, '<');
+			waddstr(input, self.nick);
+			waddstr(input, "> ");
+		} else if (NULL != (skip = commandIsNotice(id, head))) {
+			waddch(input, '-');
+			waddstr(input, self.nick);
+			waddstr(input, "- ");
+		} else if (NULL != (skip = commandIsAction(id, head))) {
+			waddstr(input, "* ");
+			waddstr(input, self.nick);
+			waddch(input, ' ');
+		}
 	}
+	if (skip) head = skip;
 
 	int y, x;
 	struct Style style = Reset;
-	inputAdd(&style, editHead());
+	inputAdd(&style, head);
 	getyx(input, y, x);
 	inputAdd(&style, editTail());
 	wclrtoeol(input);
rl&id=bc29082f9d904b1996cb269d70e474b91cc608ef&follow=1'>Remove use of "%n" to appease de RaadtJune McEnroe Sure, it was completely unnecessary, but I resent being told how to use snprintf. https://cvsweb.openbsd.org/src/lib/libc/stdio/vfprintf.c?rev=1.79&content-type=text/x-cvsweb-markup 2021-01-23Drop filesystem access iff possibleKlemens Nanni Log files and state save/restore both require read/write access to the filesystem, both during start and exit. If neither features are used, catgirl may run with "stdio tty". 2021-01-23Drop exec capability iff restrictedKlemens Nanni Nothing must be executed when running /copy, et al. 2021-01-23Drop network capability after ircConnect()Klemens Nanni catgirl has no reconnect feature and generally must not do anything but read/write from/to the connected socket which does not require "inet" or "dns" promises. 2021-01-23Call pledge(2) after unveil(2)Klemens Nanni Simplify logic, be more idiomatic and finalize by pledging after all unveiling is done by omitting the "unveil" promise and thereby not allowing further calls to it. 2021-01-23Separate kiosk mode from restrict modeJune McEnroe Restrict mode will focus on sandboxing, while kiosk will continue to restrict IRC access through a public kiosk. Kiosk mode without restrict mode allows execution of man 1 catgirl with /help, assuming external sandboxing. The /list and /part commands are also added to the list of disabled commands in kiosk mode, since they are pointless without access to /join. 2021-01-21Simplify windowUpdate loops and factor out windowTopJune McEnroe No idea why I made that more complicated than it had to be looping backwards. 2021-01-21Document that M-l shows timestampsJune McEnroe 2021-01-19Don't lose swapped window when navigating to current bufferJeremy O'Brien 2021-01-19Use Warm heat for manually inserted blank linesJune McEnroe Oops, forgot about these. 2021-01-18Add example tmux(1) configKlemens Nanni Spawn one catgirl per network and handle reconnects through tmux, no extra tool required. 2021-01-17Use Warm heat for blank linesJune McEnroe So they're not hidden by M-+. 2021-01-16Add -I highlight option and /highlightJune McEnroe