summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--buffer.c7
-rw-r--r--chat.h2
-rw-r--r--ui.c12
3 files changed, 16 insertions, 5 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;
 }
diff --git a/chat.h b/chat.h
index 6f2ba15..6cf34b3 100644
--- a/chat.h
+++ b/chat.h
@@ -291,7 +291,7 @@ int bufferPush(
 	struct Buffer *buffer, int cols, bool ignore,
 	enum Heat heat, time_t time, const char *str
 );
-void bufferReflow(struct Buffer *buffer, int cols, bool ignore);
+int bufferReflow(struct Buffer *buffer, int cols, bool ignore, size_t tail);
 
 enum Edit {
 	EditHead,
diff --git a/ui.c b/ui.c
index ab557d3..333ef53 100644
--- a/ui.c
+++ b/ui.c
@@ -542,6 +542,7 @@ void uiWrite(uint id, enum Heat heat, const time_t *src, const char *str) {
 	}
 	if (window->mark && heat > Cold) {
 		if (!window->unreadWarm++) {
+			window->unreadSoft++;
 			lines += bufferPush(window->buffer, COLS, false, Cold, ts, "");
 		}
 		if (heat > window->heat) window->heat = heat;
@@ -576,7 +577,9 @@ static void resize(void) {
 	wresize(main, MAIN_LINES, COLS);
 	for (uint num = 0; num < windows.len; ++num) {
 		struct Window *window = windows.ptrs[num];
-		bufferReflow(window->buffer, COLS, window->ignore);
+		window->unreadHard = bufferReflow(
+			window->buffer, COLS, window->ignore, window->unreadSoft
+		);
 	}
 	windowUpdate();
 }
@@ -753,7 +756,9 @@ void uiCloseNum(uint num) {
 
 static void toggleIgnore(struct Window *window) {
 	window->ignore ^= true;
-	bufferReflow(window->buffer, COLS, window->ignore);
+	window->unreadHard = bufferReflow(
+		window->buffer, COLS, window->ignore, window->unreadSoft
+	);
 	windowUpdate();
 	statusUpdate();
 }
@@ -1015,6 +1020,9 @@ void uiLoad(const char *name) {
 			readString(file, &buf, &cap);
 			bufferPush(window->buffer, COLS, window->ignore, heat, time, buf);
 		}
+		window->unreadHard = bufferReflow(
+			window->buffer, COLS, window->ignore, window->unreadSoft
+		);
 	}
 
 	free(buf);
d colspan='3' class='logmsg'> 2017-08-19Move nethack options to envJune McEnroe 2017-08-17Remove scala syntax fileJune McEnroe 2017-08-06Add wakeJune McEnroe That payload can appear anywhere within an ethernet frame. Wake-on-LAN is funny. 2017-08-04Use $() in install.shJune McEnroe Something gave me the impression that sh did not like this, but it's specified by POSIX. 2017-08-02Create Code Tarmak 3 layoutJune McEnroe 2017-07-31Add tupJune McEnroe 2017-07-31Use designated initializer for hnel tableJune McEnroe I did not know this syntax worked! 2017-07-30Add juneJune McEnroe 2017-07-30Play nethack as ValkyrieJune McEnroe 2017-07-28Add toggle to hnelJune McEnroe 2017-07-28Install slJune McEnroe 2017-07-25Add up, supJune McEnroe 2017-07-24Autopickup ringsJune McEnroe 2017-07-24Name dogJune McEnroe 2017-07-23Add nethackrcJune McEnroe 2017-07-23Remove useless setuid in briJune McEnroe Don't you think it would be better if the setuid bit only gave you permission to do it and didn't do it for you? 2017-07-23Clean up hnel a tiny bitJune McEnroe 2017-07-21Set window size in hnelJune McEnroe 2017-07-21Add hnelJune McEnroe 2017-07-19chmod 600 in dtchJune McEnroe