From 7fae7f74c5315877e0d341ec60ceef2e87c0c1cc Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Wed, 21 Oct 2020 16:22:28 +0200 Subject: Vertical channel list --- ui/style.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ui/style.go') 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 +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 +} -- cgit v1.2.3