summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ui/colors.go98
-rw-r--r--ui/ui.go3
2 files changed, 64 insertions, 37 deletions
diff --git a/ui/colors.go b/ui/colors.go
index 7f0ec3a..f9b4f3f 100644
--- a/ui/colors.go
+++ b/ui/colors.go
@@ -6,48 +6,74 @@ import (
"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°
+type ColorScheme int
+
+const (
+ ColorSchemeBase ColorScheme = iota
+ ColorSchemeExtended
+)
+
+var colors = map[ColorScheme][]tcell.Color{
+ // base 16 colors, excluding grayscale colors.
+ ColorSchemeBase: {
+ tcell.ColorMaroon,
+ tcell.ColorGreen,
+ tcell.ColorOlive,
+ tcell.ColorNavy,
+ tcell.ColorPurple,
+ tcell.ColorTeal,
+ tcell.ColorSilver,
+ tcell.ColorRed,
+ tcell.ColorLime,
+ tcell.ColorYellow,
+ tcell.ColorBlue,
+ tcell.ColorFuchsia,
+ tcell.ColorAqua,
+ },
+ // all XTerm extended colors with HSL saturation=1, light=0.5
+ ColorSchemeExtended: {
+ 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 {
+func IdentColor(scheme ColorScheme, ident string) tcell.Color {
h := fnv.New32()
_, _ = h.Write([]byte(ident))
- return identColors[int(h.Sum32()%uint32(len(identColors)))]
+ c := colors[scheme]
+ return c[int(h.Sum32()%uint32(len(c)))]
}
-func IdentString(ident string) StyledString {
- color := IdentColor(ident)
+func IdentString(scheme ColorScheme, ident string) StyledString {
+ color := IdentColor(scheme, ident)
style := tcell.StyleDefault.Foreground(color)
return Styled(ident, style)
}
diff --git a/ui/ui.go b/ui/ui.go
index 3627939..45c3472 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -25,6 +25,7 @@ type Config struct {
type ConfigColors struct {
Unread tcell.Color
+ Nicks ColorScheme
}
type UI struct {
@@ -552,7 +553,7 @@ 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 {
- color := IdentColor(m.Name.Name)
+ color := IdentColor(ui.config.Colors.Nicks, m.Name.Name)
name = Styled(nameText, tcell.StyleDefault.Foreground(color).Reverse(reverse))
}