about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pls.c2
-rw-r--r--ui.c21
2 files changed, 21 insertions, 2 deletions
diff --git a/pls.c b/pls.c
index bd40dbd..c6071c7 100644
--- a/pls.c
+++ b/pls.c
@@ -26,7 +26,7 @@ wchar_t *wcssep(wchar_t **stringp, const wchar_t *delim) {
 	size_t i = wcscspn(orig, delim);
 	*stringp = NULL;
 	if (orig[i]) {
-		orig[i] = '\0';
+		orig[i] = L'\0';
 		*stringp = &orig[i + 1];
 	}
 	return orig;
diff --git a/ui.c b/ui.c
index 5f5efc3..9c77668 100644
--- a/ui.c
+++ b/ui.c
@@ -198,17 +198,36 @@ static const wchar_t *parseColor(short *pair, const wchar_t *str) {
 	return str;
 }
 
+static void wordWrap(WINDOW *win, const wchar_t *str) {
+	size_t len = wcscspn(str, L" ");
+	size_t width = 1;
+	for (size_t i = 0; i < len; ++i) {
+		if (iswprint(str[i])) width += wcwidth(str[i]);
+	}
+
+	int _, x, xMax;
+	getyx(win, _, x);
+	getmaxyx(win, _, xMax);
+
+	if (width >= (size_t)(xMax - x)) {
+		waddch(win, '\n');
+	} else {
+		waddch(win, ' ');
+	}
+}
+
 static void addIRC(WINDOW *win, const wchar_t *str) {
 	attr_t attr = A_NORMAL;
 	short pair = -1;
 	for (;;) {
-		size_t cc = wcscspn(str, L"\2\3\35\37");
+		size_t cc = wcscspn(str, L" \2\3\35\37");
 		wattr_set(win, attr | attr8(pair), 1 + pair8(pair), NULL);
 		waddnwstr(win, str, cc);
 		if (!str[cc]) break;
 
 		str = &str[cc];
 		switch (*str++) {
+			break; case L' ': wordWrap(win, str);
 			break; case L'\2': attr ^= A_BOLD;
 			break; case L'\3': str = parseColor(&pair, str);
 			break; case L'\35': attr ^= A_ITALIC;
14:15:41 -0400'>2020-08-30Sandbox pounce with unveil(2)June McEnroe 2020-08-28Refactor certificate loading and load all certs from config pathsJune McEnroe 2020-08-27Sandbox pounce with pledge(2)June McEnroe 2020-08-27Sandbox calico with pledge(2) and unveil(2)June McEnroe 2020-08-27Add support for OpenBSDJune McEnroe 2020-08-27Remove rc scriptsJune McEnroe 2020-08-27contrib/palaver: Fix documented database pathJune McEnroe 2020-08-27contrib/palaver: Remove rc scriptJune McEnroe 2020-08-27contrib/palaver: Fix database search and creationJune McEnroe 2020-08-27contrib/palaver: Use pounce's XDG directoryJune McEnroe 2020-08-27contrib/palaver: Only allow HTTPSJune McEnroe 2020-08-25Support the pounce_env rc variableJune McEnroe 2020-08-25Remove deprecated option namesJune McEnroe 2020-08-25Document configuration and data file searchJune McEnroe 2020-08-24Use dataOpen for save fileJune McEnroe 2020-08-24Use configOpen to load localCAJune McEnroe 2020-08-24Use configPath to load client cert/privJune McEnroe 2020-08-24Use configOpen in getopt_configJune McEnroe 2020-08-24Import xdg.c from catgirlJune McEnroe 2020-08-23Replace “RAND_bytes” by “getentropy”Issam E. Maghni 2020-08-16contrib/palaver: Add no message preview flagsJune McEnroe 2020-08-13contrib/palaver: Don't set channel for PMsJune McEnroe 2020-08-13Fix unintended interception of NICK after registrationJune McEnroe 2020-08-12Add Additional Components section to READMEJune McEnroe 2020-08-12Document -L / palaver optionJune McEnroe 2020-08-11contrib/palaver: Document service configurationJune McEnroe 2020-08-11contrib/palaver: Add install target and rc scriptJune McEnroe 2020-08-11contrib/palaver: Implement command and notificationsJune McEnroe