about summary refs log tree commit diff
path: root/input.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-07-07 14:40:44 -0400
committerJune McEnroe <june@causal.agency>2023-07-07 14:40:44 -0400
commitdc132b4350d207d147bb79d997c3f8b511c4ac30 (patch)
tree564e83a1a55b85b22ac67e3ae536aa578af3dd58 /input.c
parentFix what went wrong, part 3 (diff)
downloadcatgirl-dc132b4350d207d147bb79d997c3f8b511c4ac30.tar.gz
catgirl-dc132b4350d207d147bb79d997c3f8b511c4ac30.zip
Work-in-progress showing prefixes
Diffstat (limited to '')
-rw-r--r--input.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/input.c b/input.c
index 6b33b93..b4f5b5e 100644
--- a/input.c
+++ b/input.c
@@ -174,37 +174,45 @@ void inputUpdate(void) {
 	const char *ptr = editString(&edits[id], &buf, &cap, &pos);
 	if (!ptr) err(EX_OSERR, "editString");
 
-	const char *prefix = "";
+	const char *head = "";
+	char prefix[2] = "";
 	const char *prompt = self.nick;
-	const char *suffix = "";
+	const char *tail = "";
 	const char *skip = buf;
 	struct Style stylePrompt = { .fg = self.color, .bg = Default };
 	struct Style styleInput = StyleDefault;
+	if (self.showPrefix) {
+		uint *bits = completeBits(id, self.nick);
+		if (bits) prefix[0] = bitPrefix(*bits);
+	}
 
 	size_t split = commandWillSplit(id, buf);
 	const char *privmsg = commandIsPrivmsg(id, buf);
 	const char *notice = commandIsNotice(id, buf);
 	const char *action = commandIsAction(id, buf);
 	if (privmsg) {
-		prefix = "<"; suffix = "> ";
+		head = "<"; tail = "> ";
 		skip = privmsg;
 	} else if (notice) {
-		prefix = "-"; suffix = "- ";
+		head = "-"; tail = "- ";
 		styleInput.fg = LightGray;
 		skip = notice;
 	} else if (action) {
-		prefix = "* "; suffix = " ";
+		head = "* "; tail = " ";
 		stylePrompt.attr |= Italic;
 		styleInput.attr |= Italic;
 		skip = action;
 	} else if (id == Debug && buf[0] != '/') {
+		prefix[0] = '\0';
 		prompt = "<< ";
 		stylePrompt.fg = Gray;
 	} else {
+		prefix[0] = '\0';
 		prompt = "";
 	}
 	if (skip > &buf[pos]) {
-		prefix = prompt = suffix = "";
+		prefix[0] = '\0';
+		head = prompt = tail = "";
 		skip = buf;
 	}
 
@@ -215,9 +223,10 @@ void inputUpdate(void) {
 		wmove(uiInput, 0, windowTime.width);
 	}
 	wattr_set(uiInput, uiAttr(stylePrompt), uiPair(stylePrompt), NULL);
+	waddstr(uiInput, head);
 	waddstr(uiInput, prefix);
 	waddstr(uiInput, prompt);
-	waddstr(uiInput, suffix);
+	waddstr(uiInput, tail);
 	getyx(uiInput, y, x);
 
 	int posx;