summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-10 03:37:17 -0500
committerJune McEnroe <june@causal.agency>2020-02-10 03:37:17 -0500
commit2c9ff1717b00b9373240dad8200bb8a766ac05cb (patch)
treec17f6247e1d951a5287c6764f6ea9ec918c40c6f
parentOnly make windows hotter (diff)
downloadcatgirl-2c9ff1717b00b9373240dad8200bb8a766ac05cb.tar.gz
catgirl-2c9ff1717b00b9373240dad8200bb8a766ac05cb.zip
Recalculate unreadLines on reflow
-rw-r--r--ui.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ui.c b/ui.c
index 7f13e5b..666a93d 100644
--- a/ui.c
+++ b/ui.c
@@ -415,7 +415,7 @@ static void windowScroll(struct Window *window, int n) {
 
 static void windowScrollUnread(struct Window *window) {
 	window->scroll = 0;
-	windowScroll(window, window->unreadLines - PAGE_LINES);
+	windowScroll(window, window->unreadLines - PAGE_LINES + 1);
 }
 
 static int wordWidth(const char *str) {
@@ -516,13 +516,18 @@ void uiFormat(
 
 static void reflow(struct Window *window) {
 	werase(window->pad);
-	wmove(window->pad, BufferCap - 1, 0);
+	wmove(window->pad, WindowLines - 1, 0);
+	window->unreadLines = 0;
 	struct Buffer *buffer = &window->buffer;
 	for (size_t i = 0; i < BufferCap; ++i) {
 		char *line = buffer->lines[(buffer->len + i) % BufferCap];
 		if (!line) continue;
 		waddch(window->pad, '\n');
-		wordWrap(window->pad, line);
+		if (i >= (size_t)(BufferCap - window->unreadCount)) {
+			window->unreadLines += 1 + wordWrap(window->pad, line);
+		} else {
+			wordWrap(window->pad, line);
+		}
 	}
 }
 
464422d5a75fb3aa86cb170bddf04a57812f4&follow=1'>Ignore SIGPIPE in relayJune McEnroe 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe