about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-02 19:38:37 -0500
committerJune McEnroe <june@causal.agency>2020-02-02 19:38:37 -0500
commit5398a6ac9d31916ec1a399813032797988e308d2 (patch)
treee29c5374801e7576f38e7c86169b14d452448c72
parentRemove term.c in favor of more curses APIs (diff)
downloadcatgirl-5398a6ac9d31916ec1a399813032797988e308d2.tar.gz
catgirl-5398a6ac9d31916ec1a399813032797988e308d2.zip
Rearrange some UI code
Diffstat (limited to '')
-rw-r--r--ui.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/ui.c b/ui.c
index 5d626ce..8bc3eae 100644
--- a/ui.c
+++ b/ui.c
@@ -41,32 +41,6 @@
 #define RIGHT (COLS - 1)
 #define WINDOW_LINES (LINES - 2)
 
-static short colorPairs;
-
-static void colorInit(void) {
-	start_color();
-	use_default_colors();
-	for (short pair = 0; pair < 16; ++pair) {
-		init_pair(1 + pair, pair % COLORS, -1);
-	}
-	colorPairs = 17;
-}
-
-static attr_t colorAttr(short fg) {
-	return (fg >= COLORS ? A_BOLD : A_NORMAL);
-}
-
-static short colorPair(short fg, short bg) {
-	if (bg == -1) return 1 + fg;
-	for (short pair = 17; pair < colorPairs; ++pair) {
-		short f, b;
-		pair_content(pair, &f, &b);
-		if (f == fg && b == bg) return pair;
-	}
-	init_pair(colorPairs, fg % COLORS, bg % COLORS);
-	return colorPairs++;
-}
-
 enum {
 	InputCols = 512,
 	PadLines = 512,
@@ -115,18 +89,46 @@ static struct Window *windowFor(size_t id) {
 	}
 	window = malloc(sizeof(*window));
 	if (!window) err(EX_OSERR, "malloc");
+
 	window->id = id;
 	window->pad = newpad(PadLines, COLS);
-	scrollok(window->pad, true);
-	wmove(window->pad, PadLines - 1, 0);
 	window->heat = Cold;
 	window->unread = 0;
 	window->scroll = PadLines;
 	window->mark = true;
+	scrollok(window->pad, true);
+	wmove(window->pad, PadLines - 1, 0);
+
 	windowAdd(window);
 	return window;
 }
 
+static short colorPairs;
+
+static void colorInit(void) {
+	start_color();
+	use_default_colors();
+	for (short pair = 0; pair < 16; ++pair) {
+		init_pair(1 + pair, pair % COLORS, -1);
+	}
+	colorPairs = 17;
+}
+
+static attr_t colorAttr(short fg) {
+	return (fg >= COLORS ? A_BOLD : A_NORMAL);
+}
+
+static short colorPair(short fg, short bg) {
+	if (bg == -1) return 1 + fg;
+	for (short pair = 17; pair < colorPairs; ++pair) {
+		short f, b;
+		pair_content(pair, &f, &b);
+		if (f == fg && b == bg) return pair;
+	}
+	init_pair(colorPairs, fg % COLORS, bg % COLORS);
+	return colorPairs++;
+}
+
 enum {
 	KeyFocusIn = KEY_MAX + 1,
 	KeyFocusOut,