summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--input.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/input.c b/input.c
index dee50f2..45de9f1 100644
--- a/input.c
+++ b/input.c
@@ -41,7 +41,8 @@ static void privmsg(struct Tag tag, bool action, const char *mesg) {
 typedef void Handler(struct Tag tag, char *params);
 
 static void inputJoin(struct Tag tag, char *params) {
-	ircFmt("JOIN :%s\r\n", params ? params : tag.name);
+	char *chan = strsep(&params, " ");
+	ircFmt("JOIN :%s\r\n", chan ? chan : tag.name);
 }
 
 static void inputMe(struct Tag tag, char *params) {
@@ -49,8 +50,9 @@ static void inputMe(struct Tag tag, char *params) {
 }
 
 static void inputNick(struct Tag tag, char *params) {
-	if (params) {
-		ircFmt("NICK :%s\r\n", params);
+	char *nick = strsep(&params, " ");
+	if (nick) {
+		ircFmt("NICK :%s\r\n", nick);
 	} else {
 		uiLog(tag, UIHot, L"/nick requires a nickname");
 	}
@@ -90,8 +92,9 @@ static void inputWho(struct Tag tag, char *params) {
 }
 
 static void inputWhois(struct Tag tag, char *params) {
-	if (params) {
-		ircFmt("WHOIS :%s\r\n", params);
+	char *nick = strsep(&params, " ");
+	if (nick) {
+		ircFmt("WHOIS :%s\r\n", nick);
 	} else {
 		uiLog(tag, UIHot, L"/whois requires a nick");
 	}
@@ -142,20 +145,22 @@ static void inputURL(struct Tag tag, char *params) {
 }
 
 static void inputWindow(struct Tag tag, char *params) {
-	if (!params) {
+	char *word = strsep(&params, " ");
+	if (!word) {
 		uiLog(tag, UIHot, L"/window requires a name or number");
 		return;
 	}
-	bool relative = (params[0] == '+' || params[0] == '-');
-	int num = strtol(params, &params, 0);
-	if (!params[0]) {
+	bool relative = (word[0] == '+' || word[0] == '-');
+	char *trail;
+	int num = strtol(word, &trail, 0);
+	if (!trail[0]) {
 		uiShowNum(num, relative);
 	} else {
-		struct Tag name = tagFind(params);
+		struct Tag name = tagFind(word);
 		if (name.id != TagNone.id) {
 			uiShowTag(name);
 		} else {
-			uiFmt(tag, UIHot, "No window for %s", params);
+			uiFmt(tag, UIHot, "No window for %s", word);
 		}
 	}
 }
tle='2019-02-23 12:44:20 -0500'>2019-02-23Use first word of params in input commandsJune McEnroe Prevents anything weird from happening when tab-completing, which inserts a space. 2019-02-23Add C-n and C-p key bindings to switch windowsJune McEnroe 2019-02-23Change example command to join #ascii.town on freenodeJune McEnroe 2019-02-23Call def_prog_mode after termNoFlowJune McEnroe So that the settings get restored after /url or /man. 2019-02-22Move IRC formatting reset to C-sJune McEnroe Opens C-n for window switching. 2019-02-22Disable terminal flow controlJune McEnroe This opens up C-o, C-q and C-s for key bindings without C-v. 2019-02-22Bind up and down arrows to scrollJune McEnroe Honestly it's kind of weird that IRC clients usually use these for input history. 2019-02-22Remove topic TODOJune McEnroe I played around with it and it doesn't look right unless there is only one channel listed in the status. 2019-02-22Add /znc commandJune McEnroe Only because ZNC tells you to use it and expects it to work. 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe It's actually in a good state now, I think. 2019-02-21Replace "view" with "window"June McEnroe I think originally I didn't want to use the same word as curses WINDOW but it's really much clearer for the user if they're just called windows. UI code probably needs yet another rewrite though. Still feels messy. 2019-02-21Remove ROT13June McEnroe It's just not convenient when it can only do the whole line... 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe Otherwise the "Traveling" message isn't visible while connecting. 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe