about 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);