aboutsummaryrefslogtreecommitdiff
path: root/ui/widget
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-04-16 19:27:35 +0300
committerTulir Asokan <tulir@maunium.net>2020-04-19 15:01:16 +0300
commit815190be147e575f12211c468f8121e5c60e6337 (patch)
tree8abd9b3d3952dbf767ca369ddad400db8a6f2d45 /ui/widget
parentff20c2c44f86b40f9214f1dc3d339584e48374f1 (diff)
Update stuff and move pushrules to mautrix-go
Diffstat (limited to 'ui/widget')
-rw-r--r--ui/widget/color.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/ui/widget/color.go b/ui/widget/color.go
index edb966c..5a8d001 100644
--- a/ui/widget/color.go
+++ b/ui/widget/color.go
@@ -21,6 +21,8 @@ import (
"hash/fnv"
"maunium.net/go/tcell"
+
+ "maunium.net/go/mautrix/id"
)
var colorNames = []string{
@@ -201,8 +203,17 @@ func GetHashColorName(s string) string {
// GetHashColor gets the tcell Color value for the given string.
//
// GetHashColor calls GetHashColorName() and gets the Color value from the tcell.ColorNames map.
-func GetHashColor(s string) tcell.Color {
- return tcell.ColorNames[GetHashColorName(s)]
+func GetHashColor(val interface{}) tcell.Color {
+ switch str := val.(type) {
+ case string:
+ return tcell.ColorNames[GetHashColorName(str)]
+ case *string:
+ return tcell.ColorNames[GetHashColorName(*str)]
+ case id.UserID:
+ return tcell.ColorNames[GetHashColorName(string(str))]
+ default:
+ return tcell.ColorNames["red"]
+ }
}
// AddColor adds tview color tags to the given string.