From 16737d4edc73e3fdc9f6e8f3fc147a549cb5e563 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 2 Sep 2020 17:03:14 -0400 Subject: [PATCH] Preserve style after alignment This makes wrapping text with background colour look much better. --- buffer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buffer.c b/buffer.c index fd69cd3..711d5fd 100644 --- a/buffer.c +++ b/buffer.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "chat.h" @@ -160,10 +161,10 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) { if (!line->str) err(EX_OSERR, "malloc"); struct Cat cat = { line->str, cap, 0 }; + catf(&cat, "%*s%n", align, "", &width); styleCat(&cat, style); str = &line->str[cat.len]; - catf(&cat, "%*s%n%s", align, "", &width, &wrap[n]); - str += width; + catf(&cat, "%s", &wrap[n]); *wrap = '\0'; wrap = NULL;