cio

a simple irc client
Download | Log | Files | Refs | README | LICENSE

commit 80d83c49eb377fc86c53960fffb74745cf66bdb1
parent 575f1cc2d0c4b9e1b78a4c321f782404a6278684
Author: Andrew Kloet <andrew@kloet.net>
Date:   Fri,  1 May 2026 15:32:23 -0400

update colornames patch

Diffstat:
Mpatches/colornames.diff | 73+++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 35 insertions(+), 38 deletions(-)

diff --git a/patches/colornames.diff b/patches/colornames.diff @@ -1,23 +1,23 @@ - cio.c | 30 ++++++++++++++++++++++++++---- - 1 file changed, 26 insertions(+), 4 deletions(-) + cio.c | 34 ++++++++++++++++++++++++++++++++-- + 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cio.c b/cio.c -index f346646..2d3b2b8 100644 +index d1a70aa..7d0f00b 100644 --- a/cio.c +++ b/cio.c -@@ -47,8 +47,8 @@ - #define SCROLL 15 +@@ -51,8 +51,8 @@ #define INDENT 23 + #define TABSTOP 8 #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 PFMTHIGH "> \x03%-12s\x03 < %s" #define SRV "irc.oftc.net" #define PORT "6697" -@@ -221,6 +221,14 @@ b64_enc(const unsigned char *in, size_t len) - return out; +@@ -153,6 +153,14 @@ empty(const char *str) { + return (str == NULL || str[0] == '\0'); } +static int @@ -31,40 +31,37 @@ index f346646..2d3b2b8 100644 static void sndf(const char *fmt, ...) { -@@ -414,6 +422,7 @@ pushl(char *p, char *e) - char *w; - Rune u[2]; +@@ -340,6 +348,7 @@ pushl(char *p, char *e) + wchar_t wc; + int n, cl; cchar_t cc; + int color = 0; + char *eol = memchr(p, '\n', e - p); - u[1] = 0; - if ((w = memchr(p, '\n', e - p))) -@@ -432,7 +441,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); - } -@@ -441,7 +457,7 @@ pushl(char *p, char *e) + if (!eol) eol = e; +@@ -349,6 +358,21 @@ pushl(char *p, char *e) + mbtowc(NULL, NULL, 0); + wc = L'?'; n = 1; } - p += utf8decode(p, u, UtfSz); - int cl = wcwidth(*u); -- if (cl >= 0) x += cl; -+ if (cl >= 0 && *u != '\x03') x += cl; - } - } - -@@ -711,6 +727,12 @@ tinit(void) ++ if (wc == L'\x03') { ++ p += n; ++ if (color) { ++ wattroff(scr.mw, COLOR_PAIR(color)); ++ color = 0; ++ continue; ++ } ++ char nb[64]; ++ char *found = memccpy(nb, p, '\x03', sizeof(nb) - 1); ++ if (found) { ++ *(found - 1) = '\0'; ++ wattron(scr.mw, COLOR_PAIR(color = nickhash(nb))); ++ } ++ continue; ++ } + if (iswcntrl(wc)) { + p += n; + continue; +@@ -648,6 +672,12 @@ tinit(void) start_color(); use_default_colors(); init_pair(1, COLOR_WHITE, COLOR_BLACK);