summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h5
-rw-r--r--format.c12
-rw-r--r--ui.c6
3 files changed, 12 insertions, 11 deletions
diff --git a/chat.h b/chat.h
index f9ffff3..b72e664 100644
--- a/chat.h
+++ b/chat.h
@@ -56,7 +56,7 @@ const struct Tag TagVerbose;
 struct Tag tagFind(const char *name);
 struct Tag tagFor(const char *name);
 
-enum {
+enum IRCColor {
 	IRCWhite,
 	IRCBlack,
 	IRCBlue,
@@ -73,6 +73,7 @@ enum {
 	IRCPink,
 	IRCGray,
 	IRCLightGray,
+	IRCDefault = 99,
 };
 enum {
 	IRCBold      = 002,
@@ -88,7 +89,7 @@ struct Format {
 	size_t len;
 	bool split;
 	bool bold, italic, underline, reverse;
-	int fg, bg;
+	enum IRCColor fg, bg;
 };
 void formatReset(struct Format *format);
 bool formatParse(struct Format *format, const wchar_t *split);
diff --git a/format.c b/format.c
index b9cd8b1..cb9cb15 100644
--- a/format.c
+++ b/format.c
@@ -25,15 +25,15 @@ void formatReset(struct Format *format) {
 	format->italic = false;
 	format->underline = false;
 	format->reverse = false;
-	format->fg = -1;
-	format->bg = -1;
+	format->fg = IRCDefault;
+	format->bg = IRCDefault;
 }
 
 static void parseColor(struct Format *format) {
 	size_t len = MIN(wcsspn(format->str, L"0123456789"), 2);
 	if (!len) {
-		format->fg = -1;
-		format->bg = -1;
+		format->fg = IRCDefault;
+		format->bg = IRCDefault;
 		return;
 	}
 	format->fg = 0;
@@ -41,7 +41,7 @@ static void parseColor(struct Format *format) {
 		format->fg *= 10;
 		format->fg += format->str[i] - L'0';
 	}
-	if (format->fg > IRCLightGray) format->fg = -1;
+	if (format->fg > IRCLightGray) format->fg = IRCDefault;
 	format->str = &format->str[len];
 
 	len = 0;
@@ -54,7 +54,7 @@ static void parseColor(struct Format *format) {
 		format->bg *= 10;
 		format->bg += format->str[1 + i] - L'0';
 	}
-	if (format->bg > IRCLightGray) format->bg = -1;
+	if (format->bg > IRCLightGray) format->bg = IRCDefault;
 	format->str = &format->str[1 + len];
 }
 
diff --git a/ui.c b/ui.c
index c9210c6..54f0492 100644
--- a/ui.c
+++ b/ui.c
@@ -160,7 +160,7 @@ void uiDraw(void) {
 	doupdate();
 }
 
-static const short IRCColors[] = {
+static const short Colors[] = {
 	[IRCWhite]      = 8 + COLOR_WHITE,
 	[IRCBlack]      = 0 + COLOR_BLACK,
 	[IRCBlue]       = 0 + COLOR_BLUE,
@@ -187,8 +187,8 @@ static void addFormat(WINDOW *win, const struct Format *format) {
 	if (format->reverse)   attr |= A_REVERSE;
 
 	short pair = -1;
-	if (format->fg >= 0) pair = IRCColors[format->fg];
-	if (format->bg >= 0) pair |= IRCColors[format->bg] << 4;
+	if (format->fg != IRCDefault) pair = Colors[format->fg];
+	if (format->bg != IRCDefault) pair |= Colors[format->bg] << 4;
 
 	wattr_set(win, attr | attr8(pair), 1 + pair8(pair), NULL);
 	waddnwstr(win, format->str, format->len);
ss='logmsg'> 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe It's actually in a good state now, I think. 2019-02-21Replace "view" with "window"June McEnroe I think originally I didn't want to use the same word as curses WINDOW but it's really much clearer for the user if they're just called windows. UI code probably needs yet another rewrite though. Still feels messy. 2019-02-21Remove ROT13June McEnroe It's just not convenient when it can only do the whole line... 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe Otherwise the "Traveling" message isn't visible while connecting. 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe