summary refs log tree commit diff
path: root/input.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-11 19:30:30 -0400
committerJune McEnroe <june@causal.agency>2018-08-11 20:02:03 -0400
commita281f89592cf5531ebf53863768fccd054de252c (patch)
tree502042617c3909ed5143d3e51562a7314666b250 /input.c
parentAdd term.c for extra terminal features (diff)
downloadcatgirl-a281f89592cf5531ebf53863768fccd054de252c.tar.gz
catgirl-a281f89592cf5531ebf53863768fccd054de252c.zip
Rework UI code for multi-channel
Tags are now permanently assigned (and I'm betting on never needing more
than 256 of them) and the UI maps tags to a linked list of views for
easy reordering and removal. Currently, views can only be added. Views
don't have a topic window until they need one. All UI code wants to be
functional reactive.

Beeping is temporarily removed until message priorities (status,
message, ping) can be added to the UI. At that point spawning
notify-send should also be possible. Priorities will also help with
unnecessary markers, which will not appear for status messages.

The tab system is now used to send QUIT and NICK messages to all the
relevant tags. Verbose output now goes to its own tag, and sending to
it sends raw IRC.

IRC colors are now listed in chat.h and handler functions for numeric
replies have real names. The color algorithm now uses a real hash
function for hopefully better results. QUIT, PART and KICK messages are
scanned for URLs.
Diffstat (limited to 'input.c')
-rw-r--r--input.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/input.c b/input.c
index f4e3106..cb7575f 100644
--- a/input.c
+++ b/input.c
@@ -24,7 +24,6 @@
 #include "chat.h"
 
 static void privmsg(struct Tag tag, bool action, const char *mesg) {
-	if (tag.id == TAG_DEFAULT.id) return;
 	char *line;
 	int send;
 	asprintf(
@@ -50,7 +49,7 @@ static void inputNick(struct Tag tag, char *params) {
 	if (nick) {
 		ircFmt("NICK %s\r\n", nick);
 	} else {
-		uiLog(TAG_DEFAULT, L"/nick requires a name");
+		uiLog(TAG_STATUS, L"/nick requires a name");
 	}
 }
 
@@ -60,7 +59,7 @@ static void inputJoin(struct Tag tag, char *params) {
 	if (chan) {
 		ircFmt("JOIN %s\r\n", chan);
 	} else {
-		uiLog(TAG_DEFAULT, L"/join requires a channel");
+		uiLog(TAG_STATUS, L"/join requires a channel");
 	}
 }
 
@@ -104,9 +103,12 @@ static void inputOpen(struct Tag tag, char *params) {
 static void inputView(struct Tag tag, char *params) {
 	char *view = strsep(&params, " ");
 	if (!view) return;
-	size_t num = strtoul(view, &view, 0);
-	tag = (view[0] ? tagName(view) : tagNum(num));
-	if (tag.name) uiFocus(tag);
+	int num = strtol(view, &view, 0);
+	if (view[0]) {
+		uiViewTag(tagFor(view));
+	} else {
+		uiViewNum(num);
+	}
 }
 
 static const struct {
@@ -128,7 +130,11 @@ static const size_t COMMANDS_LEN = sizeof(COMMANDS) / sizeof(COMMANDS[0]);
 
 void input(struct Tag tag, char *input) {
 	if (input[0] != '/') {
-		privmsg(tag, false, input);
+		if (tag.id == TAG_VERBOSE.id) {
+			ircFmt("%s\r\n", input);
+		} else if (tag.id != TAG_STATUS.id) {
+			privmsg(tag, false, input);
+		}
 		return;
 	}
 	char *command = strsep(&input, " ");
@@ -138,11 +144,11 @@ void input(struct Tag tag, char *input) {
 		COMMANDS[i].handler(tag, input);
 		return;
 	}
-	uiFmt(TAG_DEFAULT, "%s isn't a recognized command", command);
+	uiFmt(TAG_STATUS, "%s isn't a recognized command", command);
 }
 
 void inputTab(void) {
 	for (size_t i = 0; i < COMMANDS_LEN; ++i) {
-		tabTouch(TAG_DEFAULT, COMMANDS[i].command);
+		tabTouch(TAG_NONE, COMMANDS[i].command);
 	}
 }
span>Hack clang into checking uiFmt format stringsJune McEnroe 2018-08-07Handle PART and QUIT without messagesJune McEnroe 2018-08-07Make safe filling the who bufferJune McEnroe 2018-08-07Add reverse and reset IRC formatting codesJune McEnroe 2018-08-06Rewrite line editing again, add formattingJune McEnroe 2018-08-06Fix allocation size in vaswprintfJune McEnroe This is so embarrassing. It only started crashing once it had strings that were long enough, and then it took me so long to notice this mistake. I was worried I was still doing va_list wrong somehow. 2018-08-06Implement word wrappingJune McEnroe 2018-08-06Use wchar_t strings for all of UIJune McEnroe vaswprintf is a nightmare. 2018-08-06Rename line editing functionsJune McEnroe 2018-08-05Initialize all possible color pairsJune McEnroe This is actually possible with use_default_colors! 2018-08-05Refactor color initializationJune McEnroe 2018-08-05Add ^L redrawJune McEnroe 2018-08-05Use 16 colors if availableJune McEnroe Fall back to using bold if there are only 8 colors. This also allowed bright background colors in 16-color terminals. I must port this system to torus. I'll be able to remove the awful termcap patch hack. 2018-08-05Limit parsed colors to number of mIRC colorsJune McEnroe Oh boy that's embarrassing. 2018-08-04Show source link on exitJune McEnroe 2018-08-04Implement line editing, scrollingJune McEnroe Don't really have a way to implement the M-* keys, and currently missing C-w. 2018-08-04Handle /topicJune McEnroe