summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-14 05:00:26 -0500
committerJune McEnroe <june@causal.agency>2020-02-14 05:19:33 -0500
commitfbdfb360851d9926a739f7d02d0f4a3cd9cfc217 (patch)
tree1078eec7e53d86bcf5fc1cf3b745d60aaef2628c
parentDon't copy into cut buffer during tab complete (diff)
downloadcatgirl-fbdfb360851d9926a739f7d02d0f4a3cd9cfc217.tar.gz
catgirl-fbdfb360851d9926a739f7d02d0f4a3cd9cfc217.zip
Track unreadTotal and unreadWarm separately
Otherwise reflow's calculation of unreadLines is always going to be
wrong if there were Cold lines interspersed.
-rw-r--r--ui.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/ui.c b/ui.c
index f44a78b..f5c4936 100644
--- a/ui.c
+++ b/ui.c
@@ -84,7 +84,8 @@ struct Window {
 	int scroll;
 	bool mark;
 	enum Heat heat;
-	int unreadCount;
+	int unreadTotal;
+	int unreadWarm;
 	int unreadLines;
 };
 
@@ -406,7 +407,7 @@ static void statusUpdate(void) {
 		const struct Window *window = windows.ptrs[num];
 		if (!window->heat && num != windows.show) continue;
 		if (num != windows.show) {
-			otherUnread += window->unreadCount;
+			otherUnread += window->unreadWarm;
 			if (window->heat > otherHeat) otherHeat = window->heat;
 		}
 		int trunc;
@@ -416,20 +417,20 @@ static void statusUpdate(void) {
 			idColors[window->id], (num == windows.show ? "\26" : ""),
 			num, idNames[window->id],
 			&trunc, (window->heat > Warm ? White : idColors[window->id]),
-			window->unreadCount,
+			window->unreadWarm,
 			idColors[window->id]
 		);
-		if (!window->mark || !window->unreadCount) buf[trunc] = '\0';
+		if (!window->mark || !window->unreadWarm) buf[trunc] = '\0';
 		statusAdd(buf);
 	}
 	wclrtoeol(status);
 
 	const struct Window *window = windows.ptrs[windows.show];
 	snprintf(title, sizeof(title), "%s %s", self.network, idNames[window->id]);
-	if (window->mark && window->unreadCount) {
+	if (window->mark && window->unreadWarm) {
 		snprintf(
 			&title[strlen(title)], sizeof(title) - strlen(title),
-			" (%d%s)", window->unreadCount, (window->heat > Warm ? "!" : "")
+			" (%d%s)", window->unreadWarm, (window->heat > Warm ? "!" : "")
 		);
 	}
 	if (otherUnread) {
@@ -443,7 +444,8 @@ static void statusUpdate(void) {
 static void mark(struct Window *window) {
 	if (window->scroll) return;
 	window->mark = true;
-	window->unreadCount = 0;
+	window->unreadTotal = 0;
+	window->unreadWarm = 0;
 	window->unreadLines = 0;
 }
 
@@ -588,12 +590,13 @@ void uiWrite(size_t id, enum Heat heat, const time_t *src, const char *str) {
 
 	int lines = 1;
 	waddch(window->pad, '\n');
+	window->unreadTotal++;
 	if (window->mark && heat > Cold) {
-		if (!window->unreadCount++) {
-			lines++;
+		if (window->heat < heat) window->heat = heat;
+		if (!window->unreadWarm++) {
 			waddch(window->pad, '\n');
+			lines++;
 		}
-		if (window->heat < heat) window->heat = heat;
 		statusUpdate();
 	}
 	lines += wordWrap(window->pad, str);
@@ -625,7 +628,7 @@ static void reflow(struct Window *window) {
 		const char *line = bufferLine(&window->buffer, i);
 		if (!line) continue;
 		waddch(window->pad, '\n');
-		if (i >= (size_t)(BufferCap - window->unreadCount)) {
+		if (i >= (size_t)(BufferCap - window->unreadTotal)) {
 			window->unreadLines += 1 + wordWrap(window->pad, line);
 		} else {
 			wordWrap(window->pad, line);
span>Adjust brightness by smaller incrementsJune McEnroe 2021-02-07Fix cwm window cycling, move big by defaultJune McEnroe 2021-02-07Use class names for Foreground, Background, BorderColorJune McEnroe I'm not really sure what difference this makes, but it seems like the right thing to do to be generic? 2021-02-07Add simple battery status and clock to xsessionJune McEnroe I love how simple this is. 2021-02-07Set cursor theme and sizeJune McEnroe 2021-02-07Use scrot for up -s if no screencaptureJune McEnroe Still missing putting the URL in an X selection. 2021-02-07Enable mouse acceleration in XJune McEnroe 2021-02-07Set colours for Xt and cwmJune McEnroe And increase XTerm internalBorder. 2021-02-07Set urgency on bell in xtermJune McEnroe 2021-02-07Add bindings for brightness controlJune McEnroe Weirdly the Fn key doesn't change how the F row registers... I wonder if I can do something about that. 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 11 is what I use on macOS, but I feel like my eyes are working harder here. 2021-02-07Fully configure and rebind cwmJune McEnroe This is sort of a mix of trying to emulate macOS somewhat for my muscle memory and just rebinding some of the cwm defaults to use 4- rather than M-. 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe cwm still needs a lot more rebinding, and I need to actually look at its other options. xterm definitely still needs some configuration, but I at least managed to get it to use a decent looking font. Very happy that OpenBSD includes Luxi Mono, which is what my usual font, Go Mono, is based on anyway. Still missing is xmodmap and such. 2021-02-06Add xterm output to schemeJune McEnroe