about summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-02 03:13:50 -0500
committerJune McEnroe <june@causal.agency>2020-02-02 03:13:50 -0500
commitec83332e15d31c1ffbb7112ff6743f2a5c815c71 (patch)
tree13c8812f90e5c3a830063144f47a8b3cb33e2719 /ui.c
parentPreserve copyright year in term.c (diff)
downloadcatgirl-ec83332e15d31c1ffbb7112ff6743f2a5c815c71.tar.gz
catgirl-ec83332e15d31c1ffbb7112ff6743f2a5c815c71.zip
Implement window switching and status line
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/ui.c b/ui.c
index 90ba726..3ae6592 100644
--- a/ui.c
+++ b/ui.c
@@ -262,6 +262,40 @@ static void styleAdd(WINDOW *win, const char *str) {
 	}
 }
 
+static void statusUpdate(void) {
+	wmove(status, 0, 0);
+	int num;
+	const struct Window *window;
+	for (num = 0, window = windows.head; window; ++num, window = window->next) {
+		if (!window->unread && window != windows.active) continue;
+		enum Color color = hash(idNames[window->id]); // FIXME: queries.
+		int unread;
+		char buf[256];
+		snprintf(
+			buf, sizeof(buf), C"%d%s %d %s %n("C"%02d%d"C"%d) ",
+			color, (window == windows.active ? V : ""),
+			num, idNames[window->id],
+			&unread, (window->heat > Warm ? White : color), window->unread,
+			color
+		);
+		if (!window->unread) buf[unread] = '\0';
+		styleAdd(status, buf);
+	}
+	wclrtoeol(status);
+}
+
+void uiShowID(size_t id) {
+	struct Window *window = windowFor(id);
+	window->heat = Cold;
+	window->unread = 0;
+	window->mark = false;
+	if (windows.active) windows.active->mark = true;
+	windows.other = windows.active;
+	windows.active = window;
+	touchwin(window->pad);
+	statusUpdate();
+}
+
 void uiWrite(size_t id, enum Heat heat, const struct tm *time, const char *str) {
 	(void)time;
 	struct Window *window = windowFor(id);