summary refs log tree commit diff
path: root/buffer.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-09 17:28:42 -0500
committerJune McEnroe <june@causal.agency>2021-01-09 17:28:42 -0500
commitbf70fcbfedbe544a7e8dd1f444e8abe1bbd31da1 (patch)
tree3d4015a131f569b19b520f7c955bd231f649ecec /buffer.c
parentUse execl rather than execlp for shell (diff)
downloadcatgirl-bf70fcbfedbe544a7e8dd1f444e8abe1bbd31da1.tar.gz
catgirl-bf70fcbfedbe544a7e8dd1f444e8abe1bbd31da1.zip
Count width of 2 for invalid multibyte with high bit
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/buffer.c b/buffer.c
index 15d89f8..bdf9e3a 100644
--- a/buffer.c
+++ b/buffer.c
@@ -123,17 +123,18 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) {
 		int n = mbtowc(&wc, str, len);
 		if (n < 0) {
 			n = 1;
-			width++;
+			// ncurses will render these as "~A".
+			width += (*str & '\200' ? 2 : 1);
 		} else if (wc == ZWS || wc == ZWNJ) {
-			// XXX: ncurses likes to render these as spaces when they should be
+			// ncurses likes to render these as spaces when they should be
 			// zero-width, so just remove them entirely.
 			memmove(str, &str[n], strlen(&str[n]) + 1);
 			continue;
 		} else if (wc == L'\t') {
-			// XXX: Assuming TABSIZE = 8.
+			// Assuming TABSIZE = 8.
 			width += 8 - (width % 8);
 		} else if (wc < L' ' || wc == L'\177') {
-			// XXX: ncurses will render these as "^A".
+			// ncurses will render these as "^A".
 			width += 2;
 		} else if (wcwidth(wc) > 0) {
 			width += wcwidth(wc);
is only my third book of the year :( I need some more novellas to read, but the other books I have from the library currently are also thick. 2022-03-22Source ~/.profile.local if it existsJune McEnroe 2022-03-18Publish "Addendum 2021"June McEnroe 2022-03-16Remove wcwidth portJune McEnroe DYLD_FORCE_FLAT_NAMESPACE no longer exists in macOS 12 so this approach doesn't work anymore. Moved to <https://git.causal.agency/jorts/tree/wcwidth> and compiled into <https://git.causal.agency/jorts/tree/ncurses>. 2022-03-16Remove -j4 from ./PlanJune McEnroe Plan learned to set this automatically! 2022-03-15Rewrite Linux install.sh for DebianJune McEnroe 2022-03-15Remove dashJune McEnroe400'>2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe