summaryrefslogtreecommitdiff
path: root/ui/style.go
diff options
context:
space:
mode:
Diffstat (limited to 'ui/style.go')
-rw-r--r--ui/style.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/ui/style.go b/ui/style.go
index 77dc515..acc1a41 100644
--- a/ui/style.go
+++ b/ui/style.go
@@ -1,6 +1,8 @@
package ui
import (
+ "hash/fnv"
+
"github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
)
@@ -223,3 +225,20 @@ func colorFromCode(code int) (color tcell.Color) {
}
return
}
+
+// see <https://modern.ircdocs.horse/formatting.html>
+var identColorBlacklist = []int{1, 8, 16, 27, 28, 88, 89, 90, 91}
+
+func IdentColor(s string) (code int) {
+ h := fnv.New32()
+ _, _ = h.Write([]byte(s))
+
+ code = int(h.Sum32()) % (99 - len(identColorBlacklist))
+ for _, c := range identColorBlacklist {
+ if c <= code {
+ code++
+ }
+ }
+
+ return
+}