about summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-09-02 18:51:07 -0400
committerJune McEnroe <june@causal.agency>2020-09-02 18:51:07 -0400
commit96386adac3cf4e0ac48c5b8f39b719f194f8d2e6 (patch)
tree2e5c7bc0137d169dd803d64e5b6f48e44bb8e29d /ui.c
parentDon't call completeTouch for ignored messages (diff)
downloadcatgirl-96386adac3cf4e0ac48c5b8f39b719f194f8d2e6.tar.gz
catgirl-96386adac3cf4e0ac48c5b8f39b719f194f8d2e6.zip
Hide ignored messages at the soft -> hard buffer layer
This restores normal scrolling behaviour.
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/ui.c b/ui.c
index a6f78da..2177f10 100644
--- a/ui.c
+++ b/ui.c
@@ -462,8 +462,7 @@ static void windowUpdate(void) {
 	size_t bottom = BufferCap - 1 - window->scroll + !!window->scroll;
 	for (size_t i = bottom; i < BufferCap; --i) {
 		const struct Line *line = bufferHard(window->buffer, i);
-		if (!line) continue;
-		if (line->heat < Cold && window->ignore) continue;
+		if (!line) break;
 		mainAdd(y, line->str);
 		if (!y--) break;
 	}
@@ -477,8 +476,7 @@ static void windowUpdate(void) {
 	y = MAIN_LINES - 1;
 	for (size_t i = BufferCap - 1; i < BufferCap; --i) {
 		const struct Line *line = bufferHard(window->buffer, i);
-		if (!line) continue;
-		if (line->heat < Cold && window->ignore) continue;
+		if (!line) break;
 		mainAdd(y, line->str);
 		if (--y < MAIN_LINES - SplitLines) break;
 	}
@@ -537,21 +535,19 @@ static void notify(uint id, const char *str) {
 void uiWrite(uint id, enum Heat heat, const time_t *src, const char *str) {
 	struct Window *window = windows.ptrs[windowFor(id)];
 	time_t ts = (src ? *src : time(NULL));
-	if (heat < Cold && window->ignore) {
-		window->unreadHard += bufferPush(window->buffer, COLS, heat, ts, str);
-		return;
-	}
 
 	int lines = 0;
-	if (!window->unreadSoft++) window->unreadHard = 0;
+	if (heat > Ice || !window->ignore) {
+		if (!window->unreadSoft++) window->unreadHard = 0;
+	}
 	if (window->mark && heat > Cold) {
 		if (!window->unreadWarm++) {
-			lines += bufferPush(window->buffer, COLS, Cold, 0, "");
+			lines += bufferPush(window->buffer, COLS, false, Cold, 0, "");
 		}
 		if (heat > window->heat) window->heat = heat;
 		statusUpdate();
 	}
-	lines += bufferPush(window->buffer, COLS, heat, ts, str);
+	lines += bufferPush(window->buffer, COLS, window->ignore, heat, ts, str);
 	window->unreadHard += lines;
 	if (window->scroll) windowScroll(window, lines);
 	if (window == windows.ptrs[windows.show]) windowUpdate();
@@ -579,7 +575,8 @@ static void resize(void) {
 	wclear(main);
 	wresize(main, MAIN_LINES, COLS);
 	for (uint num = 0; num < windows.len; ++num) {
-		bufferReflow(windows.ptrs[num]->buffer, COLS);
+		struct Window *window = windows.ptrs[num];
+		bufferReflow(window->buffer, COLS, window->ignore);
 	}
 	windowUpdate();
 }
@@ -756,6 +753,7 @@ void uiCloseNum(uint num) {
 
 static void toggleIgnore(struct Window *window) {
 	window->ignore ^= true;
+	bufferReflow(window->buffer, COLS, window->ignore);
 	windowUpdate();
 	statusUpdate();
 }
@@ -789,7 +787,7 @@ static void showAuto(void) {
 }
 
 static void insertBlank(struct Window *window) {
-	int lines = bufferPush(window->buffer, COLS, Cold, 0, "");
+	int lines = bufferPush(window->buffer, COLS, false, Cold, 0, "");
 	window->unreadHard += lines;
 	if (window->scroll) {
 		windowScroll(window, lines);
@@ -1015,7 +1013,7 @@ void uiLoad(const char *name) {
 			if (!time) break;
 			enum Heat heat = (version > 2 ? readTime(file) : Cold);
 			readString(file, &buf, &cap);
-			bufferPush(window->buffer, COLS, heat, time, buf);
+			bufferPush(window->buffer, COLS, window->ignore, heat, time, buf);
 		}
 	}