summary refs log tree commit diff
path: root/buffer.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-09-02 21:29:03 -0400
committerJune McEnroe <june@causal.agency>2020-09-02 21:29:03 -0400
commit0968a8ac7c5342978fced88af6a897d9b5cdc6ab (patch)
tree857ccfd468b6b25d89f171f811060d4d0e1af4c0 /buffer.c
parentGive blank lines timestamps (diff)
downloadcatgirl-0968a8ac7c5342978fced88af6a897d9b5cdc6ab.tar.gz
catgirl-0968a8ac7c5342978fced88af6a897d9b5cdc6ab.zip
Recalculate unreadHard on reflow
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/buffer.c b/buffer.c
index 7ac5c10..ff21eb4 100644
--- a/buffer.c
+++ b/buffer.c
@@ -186,16 +186,19 @@ int bufferPush(
 	return flow(&buffer->hard, cols, soft);
 }
 
-void bufferReflow(struct Buffer *buffer, int cols, bool ignore) {
+int bufferReflow(struct Buffer *buffer, int cols, bool ignore, size_t tail) {
 	buffer->hard.len = 0;
 	for (size_t i = 0; i < BufferCap; ++i) {
 		free(buffer->hard.lines[i].str);
 		buffer->hard.lines[i].str = NULL;
 	}
+	int flowed = 0;
 	for (size_t i = 0; i < BufferCap; ++i) {
 		const struct Line *soft = bufferSoft(buffer, i);
 		if (!soft) continue;
 		if (soft->heat < Cold && ignore) continue;
-		flow(&buffer->hard, cols, soft);
+		int n = flow(&buffer->hard, cols, soft);
+		if (i >= BufferCap - tail) flowed += n;
 	}
+	return flowed;
 }