summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-03-17 13:48:55 -0400
committerJune McEnroe <june@causal.agency>2021-03-17 13:49:26 -0400
commit8d5631131498ce3952150beb79c777866ea14468 (patch)
tree315e1a8bc290484f7360264762d6c33ee85287a9
parentShow where too-long-messages will be automatically split (diff)
downloadcatgirl-8d5631131498ce3952150beb79c777866ea14468.tar.gz
catgirl-8d5631131498ce3952150beb79c777866ea14468.zip
Reset style after newline in input
Reflect what will actually be sent.
-rw-r--r--ui.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ui.c b/ui.c
index a78d5c8..ebae222 100644
--- a/ui.c
+++ b/ui.c
@@ -689,7 +689,7 @@ static void windowList(const struct Window *window) {
 	}
 }
 
-static void inputAdd(struct Style *style, const char *str) {
+static void inputAdd(struct Style reset, struct Style *style, const char *str) {
 	while (*str) {
 		const char *code = str;
 		size_t len = styleParse(style, &str);
@@ -705,6 +705,7 @@ static void inputAdd(struct Style *style, const char *str) {
 		}
 		if (str - code > 1) waddnstr(input, &code[1], str - &code[1]);
 		if (str[0] == '\n') {
+			*style = reset;
 			str++;
 			len--;
 		}
@@ -716,10 +717,13 @@ static void inputAdd(struct Style *style, const char *str) {
 	}
 }
 
-static char *inputStop(struct Style *style, const char *str, char *stop) {
+static char *inputStop(
+	struct Style reset, struct Style *style,
+	const char *str, char *stop
+) {
 	char ch = *stop;
 	*stop = '\0';
-	inputAdd(style, str);
+	inputAdd(reset, style, str);
 	*stop = ch;
 	return stop;
 }
@@ -777,18 +781,18 @@ static void inputUpdate(void) {
 	const char *ptr = skip;
 	struct Style style = styleInput;
 	if (split && split < pos) {
-		ptr = inputStop(&style, ptr, &buf[split]);
+		ptr = inputStop(styleInput, &style, ptr, &buf[split]);
 		style = styleInput;
 		style.bg = Red;
 	}
-	ptr = inputStop(&style, ptr, &buf[pos]);
+	ptr = inputStop(styleInput, &style, ptr, &buf[pos]);
 	getyx(input, y, x);
 	if (split && split >= pos) {
-		ptr = inputStop(&style, ptr, &buf[split]);
+		ptr = inputStop(styleInput, &style, ptr, &buf[split]);
 		style = styleInput;
 		style.bg = Red;
 	}
-	inputAdd(&style, ptr);
+	inputAdd(styleInput, &style, ptr);
 	wclrtoeol(input);
 	wmove(input, y, x);
 }
SD 9.3Štěpán Němec 2022-09-18Make copyrights and AUTHORS consistentJune McEnroe 2022-07-27Update to FreeBSD 13.1 2062.83June McEnroe 2022-07-27openbsd: Include man pages from baseXX.tgzKeith Whitney 2022-05-08Update to OpenBSD 7.1 2062.73June McEnroe 2021-10-15Update to OpenBSD 7.0 2062.63June McEnroe 2021-08-29Update to Linux man-pages 5.13 2062.53Štěpán Němec 2021-08-26Update to NetBSD 9.2 2062.52June McEnroe 2021-08-26Support DESTDIR in install/uninstallJune McEnroe 2021-08-26Add version number generatorJune McEnroe 2021-08-22Add ISC license headerJune McEnroe 2021-08-22Update to Linux man-pages 5.12Štěpán Němec 2021-06-21Add manuals for macOS 11.3June McEnroe 2021-05-08Update to OpenBSD 6.9June McEnroe 2021-04-26Update to Linux man-pages 5.11June McEnroe 2021-04-26Update to FreeBSD 13.0June McEnroe 2021-01-27Completely rewrite how manuals are fetched and installedJune McEnroe 2020-12-14Update to man-pages-posix 2017-aJune McEnroe 2020-12-14Update to OpenBSD 6.8June McEnroe 2020-12-14Update to NetBSD 9.1June McEnroe 2020-12-14Update to man-pages 5.09June McEnroe 2020-12-14Update to FreeBSD 12.2June McEnroe 2020-06-08Update to OpenBSD 6.7June McEnroe 2020-05-04Add hack for macOS to search extra man sectionsJune McEnroe 2020-05-04Don't clear MANSECTJune McEnroe