var DefaultTheme *Theme
func readableColors256() *Palette {
- size := 247
+ size := 225
p := Palette{
- colors: make([]Style, size),
+ colors: make([]Style, 0, size),
size: size,
}
- j := 0
for i := 0; i < 256; i++ {
- if (16 <= i && i <= 18) || (232 <= i && i <= 237) {
- // Remove the ones near black, this is kinda sadpanda.
+ if i == 0 || i == 7 || i == 8 || i == 15 || i == 16 || i == 17 || i > 230 {
+ // Skip 31 Shades of Grey, and one hyperintelligent shade of blue.
continue
}
- p.colors[j] = Color256(i)
- j++
+ p.colors = append(p.colors, Color256(i))
}
return &p
}
{
id: "colors",
names: palette,
- sys: palette.Get(8), // Grey
- pm: palette.Get(7), // White
+ sys: Color256(245), // Grey
+ pm: Color256(7), // White
highlight: style(Bold + "\033[48;5;11m\033[38;5;16m"), // Yellow highlight
},
{
}
func printPalette(p *Palette) {
- for _, color := range p.colors {
- fmt.Print(color.Format(color.String() + " "))
+ for i, color := range p.colors {
+ fmt.Printf("%d\t%s\n", i, color.Format(color.String()+" "))
}
}
package message
-import (
- "fmt"
- "testing"
-)
+import "testing"
func TestThemePalette(t *testing.T) {
var expected, actual string
}
actual = color.String()
- expected = "38;05;5"
+ expected = "38;05;6"
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
actual = color.Format("foo")
- expected = "\033[38;05;5mfoo\033[0m"
+ expected = "\033[38;05;6mfoo\033[0m"
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
actual = palette.Get(palette.Len() + 1).String()
- expected = fmt.Sprintf("38;05;%d", 2)
+ expected = "38;05;3"
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
}
}
actual = color.Format("foo")
- expected = "\033[38;05;8mfoo\033[0m"
+ expected = "\033[38;05;245mfoo\033[0m"
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
actual = colorTheme.ColorSys("foo")
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
u := NewUser(SimpleId("foo"))
u.colorIdx = 4
actual = colorTheme.ColorName(u)
- expected = "\033[38;05;4mfoo\033[0m"
+ expected = "\033[38;05;5mfoo\033[0m"
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
msg := NewPublicMsg("hello", u)
actual = msg.Render(&colorTheme)
- expected = "\033[38;05;4mfoo\033[0m: hello"
+ expected = "\033[38;05;5mfoo\033[0m: hello"
if actual != expected {
- t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
+ t.Errorf("Got: %q; Expected: %q", actual, expected)
}
}
u.Config.Theme = &message.Themes[0]
actual = GetPrompt(u)
- expected = "[\033[38;05;2mfoo\033[0m] "
+ expected = "[\033[38;05;3mfoo\033[0m] "
if actual != expected {
t.Errorf("Got: %q; Expected: %q", actual, expected)
}
scanner.Scan()
actual := scanner.Text()
if !strings.HasPrefix(actual, "[foo] ") {
- // FIXME: Technically this is flakey. :/
+ // FIXME: This is flaky. :/
t.Errorf("First client failed to get 'foo' name: %q", actual)
}