about summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/ui.c b/ui.c
index 81917a4..d6f79c2 100644
--- a/ui.c
+++ b/ui.c
@@ -493,7 +493,7 @@ static void windowScrollUnread(struct Window *window) {
 }
 
 static int wordWidth(const char *str) {
-	size_t len = strcspn(str, " ");
+	size_t len = strcspn(str, " \t");
 	int width = 0;
 	while (len) {
 		wchar_t wc;
@@ -515,18 +515,10 @@ static int wordWrap(WINDOW *win, const char *str) {
 	int align = 0;
 	struct Style style = Reset;
 	while (*str) {
-		if (*str == '\t') {
-			if (align) {
-				waddch(win, '\t');
-				str++;
-			} else {
-				waddch(win, ' ');
-				getyx(win, y, align);
-				str++;
-			}
-		} else if (*str == ' ') {
+		char ch = *str;
+		if (ch == ' ' || ch == '\t') {
 			getyx(win, y, x);
-			const char *word = &str[strspn(str, " ")];
+			const char *word = &str[strspn(str, " \t")];
 			if (width - x - 1 <= wordWidth(word)) {
 				lines += 1 + (align + wordWidth(word)) / width;
 				waddch(win, '\n');
@@ -534,13 +526,16 @@ static int wordWrap(WINDOW *win, const char *str) {
 				wmove(win, y, align);
 				str = word;
 			} else {
-				waddch(win, ' ');
+				waddch(win, (align ? ch : ' '));
 				str++;
 			}
 		}
+		if (ch == '\t' && !align) {
+			getyx(win, y, align);
+		}
 
 		size_t len = styleParse(&style, &str);
-		size_t ws = strcspn(str, "\t ");
+		size_t ws = strcspn(str, " \t");
 		if (ws < len) len = ws;
 
 		wattr_set(
cJune McEnroe 2018-09-13Fix len for format->split at end of stringJune McEnroe 2018-09-13Avoid uninitialized x in uiReadJune McEnroe 2018-09-13Add IRCDefault to colors enumJune McEnroe 2018-09-13Return a format->split even at the end of the stringJune McEnroe 2018-09-13Fix weird tab-complete after commaJune McEnroe 2018-09-13Rewrite UI againJune McEnroe 2018-09-12Add note about C-oJune McEnroe 2018-09-12Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe