commit 62e0f7b6f493f49ccd40a6cd32d3d9544956f9e5
parent 2052090f8c4837f606901a4c7ffd689594c86c9c
Author: Andrew Kloet <andrew@kloet.net>
Date: Mon, 27 Apr 2026 13:13:29 -0400
add colornames patch
Diffstat:
1 file changed, 78 insertions(+), 0 deletions(-)
diff --git a/patches/colornames.diff b/patches/colornames.diff
@@ -0,0 +1,78 @@
+ cio.c | 30 ++++++++++++++++++++++++++----
+ 1 file changed, 26 insertions(+), 4 deletions(-)
+diff --git a/cio.c b/cio.c
+index fe90dc3..4470d43 100644
+--- a/cio.c
++++ b/cio.c
+@@ -46,8 +46,8 @@
+ #define SCROLL 15
+ #define INDENT 23
+ #define DATEFMT "%H:%M"
+-#define PFMT " %-12s < %s"
+-#define PFMTHIGH "> %-12s < %s"
++#define PFMT " \x03%-12s\x03 < %s"
++#define PFMTHIGH ">\x03 %-12s\x03 < %s"
+ #define SRV "irc.oftc.net"
+ #define PORT "6697"
+
+@@ -219,6 +219,14 @@ b64_enc(const unsigned char *in, size_t len)
+ return out;
+ }
+
++static int
++nickhash(const char *s)
++{
++ unsigned int h = 5381;
++ while (*s) h = ((h << 5) + h) + (*s++);
++ return (h % 6) + 2; /* Use pairs 2-7 */
++}
++
+ static void
+ sndf(const char *fmt, ...)
+ {
+@@ -422,6 +430,7 @@ pushl(char *p, char *e)
+ char *w;
+ Rune u[2];
+ cchar_t cc;
++ int color = 0;
+
+ u[1] = 0;
+ if ((w = memchr(p, '\n', e - p)))
+@@ -440,7 +449,14 @@ pushl(char *p, char *e)
+ if (p >= e || *p == ' ' || p - w + INDENT >= (ptrdiff_t)scr.x - 1) {
+ while (w < p) {
+ w += utf8decode(w, u, UtfSz);
+- if (wcwidth(*u) > 0 || *u == '\n') {
++ if (*u == '\x03') {
++ if (color) wattroff(scr.mw, COLOR_PAIR(color)), color = 0;
++ else {
++ char nb[16];
++ snprintf(nb, sizeof(nb), "%.*s", (int)(strchr(w, '\x03') - w), w);
++ wattron(scr.mw, COLOR_PAIR(color = nickhash(nb)));
++ }
++ } else if (wcwidth(*u) > 0 || *u == '\n') {
+ setcchar(&cc, u, 0, 0, 0);
+ wadd_wch(scr.mw, &cc);
+ }
+@@ -449,7 +465,7 @@ pushl(char *p, char *e)
+ }
+ p += utf8decode(p, u, UtfSz);
+ int cl = wcwidth(*u);
+- if (cl >= 0) x += cl;
++ if (cl >= 0 && *u != '\x03') x += cl;
+ }
+ }
+
+@@ -717,6 +733,12 @@ tinit(void)
+ start_color();
+ use_default_colors();
+ init_pair(1, COLOR_WHITE, COLOR_BLACK);
++ init_pair(2, COLOR_RED, -1);
++ init_pair(3, COLOR_GREEN, -1);
++ init_pair(4, COLOR_YELLOW, -1);
++ init_pair(5, COLOR_BLUE, -1);
++ init_pair(6, COLOR_MAGENTA, -1);
++ init_pair(7, COLOR_CYAN, -1);
+ wbkgd(scr.sw, COLOR_PAIR(1));
+ }
+ }