summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui.c104
1 files changed, 53 insertions, 51 deletions
diff --git a/ui.c b/ui.c
index 3b0c2d9..01dcbab 100644
--- a/ui.c
+++ b/ui.c
@@ -68,11 +68,22 @@ void uiInit(void) {
 
 	start_color();
 	use_default_colors();
-	for (short pair = 0; pair < 077; ++pair) {
-		if (pair < 010) {
-			init_pair(1 + pair, pair, -1);
-		} else {
-			init_pair(1 + pair, pair & 007, (pair & 070) >> 3);
+
+	if (COLORS >= 16) {
+		for (short pair = 0; pair < 0xFF; ++pair) {
+			if (pair < 0x10) {
+				init_pair(1 + pair, pair, -1);
+			} else {
+				init_pair(1 + pair, pair & 0x0F, (pair & 0xF0) >> 4);
+			}
+		}
+	} else {
+		for (short pair = 0; pair < 077; ++pair) {
+			if (pair < 010) {
+				init_pair(1 + pair, pair, -1);
+			} else {
+				init_pair(1 + pair, pair & 007, (pair & 070) >> 3);
+			}
 		}
 	}
 
@@ -128,79 +139,70 @@ void uiDraw(void) {
 	doupdate();
 }
 
-static const struct AttrColor {
-	attr_t attr;
-	short pair;
-} MIRC_COLORS[16] = {
-	{ A_BOLD,   COLOR_WHITE },   // white
-	{ A_NORMAL, COLOR_BLACK },   // black
-	{ A_NORMAL, COLOR_BLUE },    // blue
-	{ A_NORMAL, COLOR_GREEN },   // green
-	{ A_BOLD,   COLOR_RED },     // red
-	{ A_NORMAL, COLOR_RED },     // "brown"
-	{ A_NORMAL, COLOR_MAGENTA }, // magenta
-	{ A_NORMAL, COLOR_YELLOW },  // "orange"
-	{ A_BOLD,   COLOR_YELLOW },  // yellow
-	{ A_BOLD,   COLOR_GREEN },   // light green
-	{ A_NORMAL, COLOR_CYAN },    // cyan
-	{ A_BOLD,   COLOR_CYAN },    // light cyan
-	{ A_BOLD,   COLOR_BLUE },    // light blue
-	{ A_BOLD,   COLOR_MAGENTA }, // "pink"
-	{ A_BOLD,   COLOR_BLACK },   // grey
-	{ A_NORMAL, COLOR_WHITE },   // light grey
+static const short MIRC_COLORS[16] = {
+	8 + COLOR_WHITE,   // white
+	0 + COLOR_BLACK,   // black
+	0 + COLOR_BLUE,    // blue
+	0 + COLOR_GREEN,   // green
+	8 + COLOR_RED,     // red
+	0 + COLOR_RED,     // brown
+	0 + COLOR_MAGENTA, // magenta
+	0 + COLOR_YELLOW,  // orange
+	8 + COLOR_YELLOW,  // yellow
+	8 + COLOR_GREEN,   // light green
+	0 + COLOR_CYAN,    // cyan
+	8 + COLOR_CYAN,    // light cyan
+	8 + COLOR_BLUE,    // light blue
+	8 + COLOR_MAGENTA, // pink
+	8 + COLOR_BLACK,   // gray
+	0 + COLOR_WHITE,   // light gray
 };
 
-static const char *parseColor(struct AttrColor *color, const char *str) {
+static const char *parseColor(short *pair, const char *str) {
 	short fg = 0;
 	size_t fgLen = MIN(strspn(str, "0123456789"), 2);
-	if (!fgLen) {
-		color->attr = A_NORMAL;
-		color->pair = -1;
-		return str;
-	}
+	if (!fgLen) { *pair = -1; return str; }
 	for (size_t i = 0June McEnroe
2020-02-02
* Add extremely basid handlePrivmsgJune McEnroe2020-02-02
* Remove style string macrosJune McEnroe2020-02-02
* Add idColorsJune McEnroe2020-02-02
* Implement window switching and status lineJune McEnroe2020-02-02
* Preserve copyright year in term.cJune McEnroe2020-02-02
* Add color hashing functionJune McEnroe2020-02-02
* Handle nickname errorsJune McEnroe2020-02-02
* Call reset_shell_mode on errJune McEnroe2020-02-02
* Wrap before the very edge of the screenJune McEnroe2020-02-02
* Parse time tagJune McEnroe2020-02-02
* Implement wordWidthJune McEnroe2020-02-02
* Implement word wrapJune McEnroe2020-02-01
* Parse IRC styling in UIJune McEnroe2020-02-01
* Generate tags fileJune McEnroe2020-02-01
* Implement the beginnings of UIJune McEnroe2020-02-01
* Add term stuffJune McEnroe2020-02-01
* Add IDs and namesJune McEnroe2020-02-01
* Add -v flagJune McEnroe2020-02-01
* Fix CapNames array indicesJune McEnroe2020-02-01
* Blindly implement login flowJune McEnroe2020-02-01
* Add more login options to the manual pageJune McEnroe2020-02-01
* Add simple manual pageJune McEnroe2020-01-31