summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-08-10 13:58:18 +0200
committerdelthas <delthas@dille.cc>2022-08-10 13:59:00 +0200
commit0621fe2d0f304726b3f4be225aec22c8469cbd20 (patch)
tree2ee837691fd0be42dde55cbc883b9f43980de4cd /ui
parentAdd support for soju.im/bouncer-networks-notify (diff)
Color nicks in the member list the same as in the timeline
Also, change the color scheme to use more colors. Now 30 instead of 15, and with the consistent color codes offered by the extended XTerm 256 color scheme. Fixes: https://todo.sr.ht/~taiite/senpai/90
Diffstat (limited to 'ui')
-rw-r--r--ui/colors.go53
-rw-r--r--ui/ui.go3
2 files changed, 55 insertions, 1 deletions
diff --git a/ui/colors.go b/ui/colors.go
new file mode 100644
index 0000000..7f0ec3a
--- /dev/null
+++ b/ui/colors.go
@@ -0,0 +1,53 @@
+package ui
+
+import (
+ "hash/fnv"
+
+ "github.com/gdamore/tcell/v2"
+)
+
+// all XTerm extended colors with HSL saturation=1, light=0.5
+var identColors = []tcell.Color{
+ tcell.Color196, // HSL hue: 0°
+ tcell.Color202, // HSL hue: 22°
+ tcell.Color208, // HSL hue: 32°
+ tcell.Color214, // HSL hue: 41°
+ tcell.Color220, // HSL hue: 51°
+ tcell.Color226, // HSL hue: 60°
+ tcell.Color190, // HSL hue: 69°
+ tcell.Color154, // HSL hue: 79°
+ tcell.Color118, // HSL hue: 88°
+ tcell.Color82, // HSL hue: 98°
+ tcell.Color46, // HSL hue: 120°
+ tcell.Color47, // HSL hue: 142°
+ tcell.Color48, // HSL hue: 152°
+ tcell.Color49, // HSL hue: 161°
+ tcell.Color50, // HSL hue: 171°
+ tcell.Color51, // HSL hue: 180°
+ tcell.Color45, // HSL hue: 189°
+ tcell.Color39, // HSL hue: 199°
+ tcell.Color33, // HSL hue: 208°
+ tcell.Color27, // HSL hue: 218°
+ tcell.Color21, // HSL hue: 240°
+ tcell.Color57, // HSL hue: 262°
+ tcell.Color93, // HSL hue: 272°
+ tcell.Color129, // HSL hue: 281°
+ tcell.Color165, // HSL hue: 291°
+ tcell.Color201, // HSL hue: 300°
+ tcell.Color200, // HSL hue: 309°
+ tcell.Color199, // HSL hue: 319°
+ tcell.Color198, // HSL hue: 328°
+ tcell.Color197, // HSL hue: 338°
+}
+
+func IdentColor(ident string) tcell.Color {
+ h := fnv.New32()
+ _, _ = h.Write([]byte(ident))
+ return identColors[int(h.Sum32()%uint32(len(identColors)))]
+}
+
+func IdentString(ident string) StyledString {
+ color := IdentColor(ident)
+ style := tcell.StyleDefault.Foreground(color)
+ return Styled(ident, style)
+}
diff --git a/ui/ui.go b/ui/ui.go
index 0a380a7..3627939 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -552,7 +552,8 @@ func (ui *UI) drawVerticalMemberList(screen tcell.Screen, x0, y0, width, height
if m.Away {
name = Styled(nameText, tcell.StyleDefault.Foreground(tcell.ColorGray).Reverse(reverse))
} else {
- name = Styled(nameText, tcell.StyleDefault.Reverse(reverse))
+ color := IdentColor(m.Name.Name)
+ name = Styled(nameText, tcell.StyleDefault.Foreground(color).Reverse(reverse))
}
printString(screen, &x, y, name)