summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-07 11:06:29 -0400
committerJune McEnroe <june@causal.agency>2020-04-07 11:06:29 -0400
commit83a2fb0d345c1e38069a5ec243cbea2a65c43731 (patch)
treee3bdc01e0fc5e696c14ae98eaada8fd7f980a6bb
parentAdd M-q to collapse whitespace (diff)
downloadcatgirl-83a2fb0d345c1e38069a5ec243cbea2a65c43731.tar.gz
catgirl-83a2fb0d345c1e38069a5ec243cbea2a65c43731.zip
Reset unreadSoft only on first unreadHard
Also rename unread{,Lines} to be maybe more clear and disambiguate with
buffer lines.
-rw-r--r--ui.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/ui.c b/ui.c
index da6cd18..ffaff45 100644
--- a/ui.c
+++ b/ui.c
@@ -90,9 +90,9 @@ struct Window {
 	bool mark;
 	bool ignore;
 	enum Heat heat;
-	uint unread;
+	uint unreadHard;
+	uint unreadSoft;
 	uint unreadWarm;
-	uint unreadLines;
 	struct Buffer buffer;
 };
 
@@ -469,9 +469,8 @@ static void statusUpdate(void) {
 static void mark(struct Window *window) {
 	if (window->scroll) return;
 	window->mark = true;
-	window->unread = 0;
+	window->unreadHard = 0;
 	window->unreadWarm = 0;
-	window->unreadLines = 0;
 }
 
 static void unmark(struct Window *window) {
@@ -513,7 +512,7 @@ static void windowScroll(struct Window *window, int n) {
 
 static void windowScrollUnread(struct Window *window) {
 	window->scroll = 0;
-	windowScroll(window, window->unreadLines - PAGE_LINES + 1);
+	windowScroll(window, window->unreadSoft - PAGE_LINES + 1);
 }
 
 static int wordWidth(const char *str) {
@@ -608,7 +607,7 @@ void uiWrite(uint id, enum Heat heat, const time_t *src, const char *str) {
 	if (heat < Cold && window->ignore) return;
 
 	int lines = 0;
-	window->unread++;
+	if (!window->unreadHard++) window->unreadSoft = 0;
 	if (window->mark && heat > Cold) {
 		if (!window->unreadWarm++) {
 			lines++;
@@ -619,7 +618,7 @@ void uiWrite(uint id, enum Heat heat, const time_t *src, const char *str) {
 	}
 
 	lines += wordWrap(window->pad, str);
-	window->unreadLines += lines;
+	window->unreadSoft += lines;
 	if (window->scroll) windowScroll(window, lines);
 
 	if (window->mark && heat > Warm) {
@@ -645,19 +644,19 @@ static void reflow(struct Window *window) {
 	wmove(window->pad, 0, 0);
 
 	int flowed = 0;
-	window->unreadLines = 0;
+	window->unreadSoft = 0;
 	for (size_t i = 0; i < BufferCap; ++i) {
 		struct Line line = bufferLine(&window->buffer, i);
 		if (!line.str) continue;
 		if (line.heat < Cold && window->ignore) continue;
 		int lines = 0;
-		if (i == (size_t)(BufferCap - window->unread)) {
+		if (i == (size_t)(BufferCap - window->unreadHard)) {
 			waddch(window->pad, '\n');
 			lines++;
 		}
 		lines += wordWrap(window->pad, line.str);
-		if (i >= (size_t)(BufferCap - window->unread)) {
-			window->unreadLines += lines;
+		if (i >= (size_t)(BufferCap - window->unreadHard)) {
+			window->unreadSoft += lines;
 		}
 		flowed += lines;
 	}
@@ -1038,7 +1037,7 @@ int uiSave(const char *name) {
 		const struct Window *window = windows.ptrs[num];
 		if (writeString(file, idNames[window->id])) return -1;
 		if (writeTime(file, window->heat)) return -1;
-		if (writeTime(file, window->unread)) return -1;
+		if (writeTime(file, window->unreadHard)) return -1;
 		if (writeTime(file, window->unreadWarm)) return -1;
 		for (size_t i = 0; i < BufferCap; ++i) {
 			struct Line line = bufferLine(&window->buffer, i);
@@ -1094,7 +1093,7 @@ void uiLoad(const char *name) {
 		struct Window *window = windows.ptrs[windowFor(idFor(buf))];
 		if (version > 0) {
 			window->heat = readTime(file);
-			window->unread = readTime(file);
+			window->unreadHard = readTime(file);
 			window->unreadWarm = readTime(file);
 		}
 		for (;;) {
/tr> 2020-02-26Add Fierce Femmes and Notorious LiarsJune McEnroe 2020-02-23Add This Is How You Lose the Time WarJune McEnroe 2020-02-22Add See Ya LaterJune McEnroe 2020-02-20Remove wiki scriptJune McEnroe Wikipedia seems to have removed the one-sentence extracts from the opensearch results. Too bad. It's not a wiki script, what we need is a command that fetches single-sentence summaries of articles on Wikipedia. 2020-02-19Add The Obelisk GateJune McEnroe 2020-02-17Add Four Tet — HandsJune McEnroe One from the cafe that caught my attention. 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe Apparently sometimes it didn't like receiving its own internal storage to parse again. Understandable. 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe Wow. One of the best I've read. 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe Broke out LDLIBS for each bin, and made everything more uniform. 2020-01-28Change scout sensitivity to 1.4June McEnroe idk it seems to work. 2020-01-28Import shows.txtJune McEnroe