chat/message/theme: Tweak default colorscheme v1.4
authorAndrey Petrov <andrey.petrov@shazow.net>
Fri, 12 Aug 2016 21:13:11 +0000 (17:13 -0400)
committerAndrey Petrov <andrey.petrov@shazow.net>
Fri, 12 Aug 2016 21:13:11 +0000 (17:13 -0400)
Fewer grey names, lighter grey for system messages.

chat/message/theme.go
chat/message/theme_test.go
chat/room_test.go
host_test.go

index b7488643d12fd8eb22d80c22f5c9cbdf6d5781b7..ca5ec34ff3aea453c7f5ddb8719ba74dda2e8cf4 100644 (file)
@@ -156,19 +156,17 @@ var Themes []Theme
 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
 }
@@ -207,8 +205,8 @@ func init() {
                {
                        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
                },
                {
@@ -237,7 +235,7 @@ func init() {
 }
 
 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()+" "))
        }
 }
index 2a1509ba82d98e18d95e7e92e0e654c05e612e54..7de7f935fcc2555e75b256e1eeec51584f98500c 100644 (file)
@@ -1,9 +1,6 @@
 package message
 
-import (
-       "fmt"
-       "testing"
-)
+import "testing"
 
 func TestThemePalette(t *testing.T) {
        var expected, actual string
@@ -15,21 +12,21 @@ func TestThemePalette(t *testing.T) {
        }
 
        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)
        }
 
 }
@@ -44,28 +41,28 @@ func TestTheme(t *testing.T) {
        }
 
        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)
        }
 }
index 078b80b9a0398a4ec29e1d7f07d83d167e3c9bb0..1ee841c8593daffe6fe383506e1aec898be7bda1 100644 (file)
@@ -144,6 +144,7 @@ func TestIgnore(t *testing.T) {
 
        // ensure ignorer has received the message
        if !ignorer.user.HasMessages() {
+               // FIXME: This is flaky :/
                t.Fatal("should have messages")
        }
        ignorer.user.HandleMsg(ignorer.user.ConsumeOne())
index 22a75e736f0fac8eddb714020caa54ed4fd18f28..31caf95a559fa48fff337d06617d8e549c3ed743 100644 (file)
@@ -37,7 +37,7 @@ func TestHostGetPrompt(t *testing.T) {
 
        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)
        }
@@ -70,7 +70,7 @@ func TestHostNameCollision(t *testing.T) {
                        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)
                        }