summaryrefslogtreecommitdiff
path: root/ui/style.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2020-10-21 16:22:28 +0200
committerHubert Hirtz <hubert@hirtz.pm>2020-10-26 08:45:07 +0100
commit7fae7f74c5315877e0d341ec60ceef2e87c0c1cc (patch)
treeafdea6e39840dfbd3db4e864bf914fe137009298 /ui/style.go
parentCollapse bufferlist in one block (diff)
Vertical channel list
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
+}