Closed valentin-ok closed 3 years ago
I hadn't head about fatih/color
- thanks for turning me onto it. I'll definitely be looking into it.
The current color scheme definitely does make an assumption that the user is using a black background and I'm sure ticker looks pretty wonky with a light or non-block color background. I think this is worth addressing - whether it be with fatih/color
or some other library
I just found out that termenv can do the basic ANSI colors 0 to 15 as well. It's just not documented.
https://github.com/muesli/termenv/blob/701b1fc7232bc1fe4d2f4030c5f0803d9bac63db/examples/color-chart/main.go#L10 https://github.com/muesli/termenv/blob/701b1fc7232bc1fe4d2f4030c5f0803d9bac63db/ansicolors.go#L3
Edit: Yes, this works:
diff --git a/internal/ui/ui.go b/internal/ui/ui.go
index 310c6e6..e9267e3 100644
--- a/internal/ui/ui.go
+++ b/internal/ui/ui.go
@@ -19,8 +19,8 @@ import (
)
var (
- styleLogo = NewStyle("#ffc27d", "#f37329", true)
- styleHelp = NewStyle("#4e4e4e", "", true)
+ styleLogo = NewStyleANSI(0, 3, true)
+ styleHelp = NewStyleANSI(8, 256, true)
)
const (
diff --git a/internal/ui/util/style.go b/internal/ui/util/style.go
index 813d84f..3ecb219 100644
--- a/internal/ui/util/style.go
+++ b/internal/ui/util/style.go
@@ -12,12 +12,12 @@ const (
)
var (
- StyleNeutral = NewStyle("#d4d4d4", "", false)
- StyleNeutralBold = NewStyle("#d4d4d4", "", true)
- StyleNeutralFaded = NewStyle("#616161", "", false)
- StyleLine = NewStyle("#3a3a3a", "", false)
- StyleTag = NewStyle("#d4d4d4", "#3a3a3a", false)
- StyleTagEnd = NewStyle("#3a3a3a", "#3a3a3a", false)
+ StyleNeutral = NewStyleANSI(te.ANSIWhite, 256, false)
+ StyleNeutralBold = NewStyleANSI(te.ANSIWhite, 256, true)
+ StyleNeutralFaded = NewStyleANSI(te.ANSIBrightBlack, 256, false)
+ StyleLine = NewStyleANSI(te.ANSIBlack, 256, false)
+ StyleTag = NewStyleANSI(te.ANSIWhite, te.ANSIBlack, false)
+ StyleTagEnd = NewStyleANSI(te.ANSIWhite, te.ANSIBlack, false)
StylePricePositive = NewStyleFromGradient("#C6FF40", "#779929")
StylePriceNegative = NewStyleFromGradient("#FF7940", "#994926")
)
@@ -30,6 +30,14 @@ func NewStyle(fg string, bg string, bold bool) func(string) string {
return s.Styled
}
+func NewStyleANSI(fg te.ANSIColor, bg te.ANSIColor, bold bool) func(string) string {
+ s := te.Style{}.Foreground(fg).Background(bg)
+ if bold {
+ s = s.Bold()
+ }
+ return s.Styled
+}
+
I misunderstood your original request - I think the color scheme as-is is good. Changing it to use ANSI 16 would constitute a rather significant change in user experience in my opinion.
In the recent version, I've simplified the colors scheme to ANSI 256 where it made sense. I hope this at least somewhat addresses this problem for you. Perhaps another improvement could be to allow user configuration of color scheme - feel free to open that as a separate issue if you'd like.
The Dark Grey is barely readable on dark terminals when there's sunlight in the room.
Best regards
Edit: This is a tricky one. ticker isn't using ANSI colors but termenv, which doesn't respect color schemes.
I patched it with fatih/color to use ANSI for most Text and it improved readability for me a lot.
I guess this is a fundamental decision everyone has to decide for themselves. I have no problem with maintaining a patch so I am fine.