commit 34122cd

Hubert Hirtz  ·  2020-08-21 16:51:43 +0000 UTC
parent cdfae68
ui: Blacklist dark colors for nicks
1 files changed,  +8, -6
+8, -6
 1@@ -604,16 +604,18 @@ func printTime(screen tcell.Screen, x int, y int, st tcell.Style, t time.Time) {
 2 	screen.SetContent(x+4, y, mn1, nil, st)
 3 }
 4 
 5+// see <https://modern.ircdocs.horse/formatting.html>
 6+var identColorBlacklist = []int{1, 8, 16, 27, 28, 88, 89, 90, 91}
 7+
 8 func identColor(s string) (code int) {
 9 	h := fnv.New32()
10 	_, _ = h.Write([]byte(s))
11 
12-	code = int(h.Sum32()) % 96
13-	if 1 <= code {
14-		code++
15-	}
16-	if 8 <= code {
17-		code++
18+	code = int(h.Sum32()) % (99 - len(identColorBlacklist))
19+	for _, c := range identColorBlacklist {
20+		if c <= code {
21+			code++
22+		}
23 	}
24 
25 	return