Skip to content

Commit 972bb86

Browse files
committed
chat/message/theme: Tweak default colorscheme
Fewer grey names, lighter grey for system messages.
1 parent c69cefc commit 972bb86

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

chat/message/theme.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,17 @@ var Themes []Theme
156156
var DefaultTheme *Theme
157157

158158
func readableColors256() *Palette {
159-
size := 247
159+
size := 225
160160
p := Palette{
161-
colors: make([]Style, size),
161+
colors: make([]Style, 0, size),
162162
size: size,
163163
}
164-
j := 0
165164
for i := 0; i < 256; i++ {
166-
if (16 <= i && i <= 18) || (232 <= i && i <= 237) {
167-
// Remove the ones near black, this is kinda sadpanda.
165+
if i == 0 || i == 7 || i == 8 || i == 15 || i == 16 || i == 17 || i > 230 {
166+
// Skip 31 Shades of Grey, and one hyperintelligent shade of blue.
168167
continue
169168
}
170-
p.colors[j] = Color256(i)
171-
j++
169+
p.colors = append(p.colors, Color256(i))
172170
}
173171
return &p
174172
}
@@ -207,8 +205,8 @@ func init() {
207205
{
208206
id: "colors",
209207
names: palette,
210-
sys: palette.Get(8), // Grey
211-
pm: palette.Get(7), // White
208+
sys: Color256(245), // Grey
209+
pm: Color256(7), // White
212210
highlight: style(Bold + "\033[48;5;11m\033[38;5;16m"), // Yellow highlight
213211
},
214212
{
@@ -237,7 +235,7 @@ func init() {
237235
}
238236

239237
func printPalette(p *Palette) {
240-
for _, color := range p.colors {
241-
fmt.Print(color.Format(color.String() + " "))
238+
for i, color := range p.colors {
239+
fmt.Printf("%d\t%s\n", i, color.Format(color.String()+" "))
242240
}
243241
}

chat/message/theme_test.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package message
22

3-
import (
4-
"fmt"
5-
"testing"
6-
)
3+
import "testing"
74

85
func TestThemePalette(t *testing.T) {
96
var expected, actual string
@@ -15,21 +12,21 @@ func TestThemePalette(t *testing.T) {
1512
}
1613

1714
actual = color.String()
18-
expected = "38;05;5"
15+
expected = "38;05;6"
1916
if actual != expected {
20-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
17+
t.Errorf("Got: %q; Expected: %q", actual, expected)
2118
}
2219

2320
actual = color.Format("foo")
24-
expected = "\033[38;05;5mfoo\033[0m"
21+
expected = "\033[38;05;6mfoo\033[0m"
2522
if actual != expected {
26-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
23+
t.Errorf("Got: %q; Expected: %q", actual, expected)
2724
}
2825

2926
actual = palette.Get(palette.Len() + 1).String()
30-
expected = fmt.Sprintf("38;05;%d", 2)
27+
expected = "38;05;3"
3128
if actual != expected {
32-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
29+
t.Errorf("Got: %q; Expected: %q", actual, expected)
3330
}
3431

3532
}
@@ -44,28 +41,28 @@ func TestTheme(t *testing.T) {
4441
}
4542

4643
actual = color.Format("foo")
47-
expected = "\033[38;05;8mfoo\033[0m"
44+
expected = "\033[38;05;245mfoo\033[0m"
4845
if actual != expected {
49-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
46+
t.Errorf("Got: %q; Expected: %q", actual, expected)
5047
}
5148

5249
actual = colorTheme.ColorSys("foo")
5350
if actual != expected {
54-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
51+
t.Errorf("Got: %q; Expected: %q", actual, expected)
5552
}
5653

5754
u := NewUser(SimpleId("foo"))
5855
u.colorIdx = 4
5956
actual = colorTheme.ColorName(u)
60-
expected = "\033[38;05;4mfoo\033[0m"
57+
expected = "\033[38;05;5mfoo\033[0m"
6158
if actual != expected {
62-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
59+
t.Errorf("Got: %q; Expected: %q", actual, expected)
6360
}
6461

6562
msg := NewPublicMsg("hello", u)
6663
actual = msg.Render(&colorTheme)
67-
expected = "\033[38;05;4mfoo\033[0m: hello"
64+
expected = "\033[38;05;5mfoo\033[0m: hello"
6865
if actual != expected {
69-
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
66+
t.Errorf("Got: %q; Expected: %q", actual, expected)
7067
}
7168
}

chat/room_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func TestIgnore(t *testing.T) {
144144

145145
// ensure ignorer has received the message
146146
if !ignorer.user.HasMessages() {
147+
// FIXME: This is flaky :/
147148
t.Fatal("should have messages")
148149
}
149150
ignorer.user.HandleMsg(ignorer.user.ConsumeOne())

host_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestHostGetPrompt(t *testing.T) {
3737

3838
u.Config.Theme = &message.Themes[0]
3939
actual = GetPrompt(u)
40-
expected = "[\033[38;05;2mfoo\033[0m] "
40+
expected = "[\033[38;05;3mfoo\033[0m] "
4141
if actual != expected {
4242
t.Errorf("Got: %q; Expected: %q", actual, expected)
4343
}
@@ -70,7 +70,7 @@ func TestHostNameCollision(t *testing.T) {
7070
scanner.Scan()
7171
actual := scanner.Text()
7272
if !strings.HasPrefix(actual, "[foo] ") {
73-
// FIXME: Technically this is flakey. :/
73+
// FIXME: This is flaky. :/
7474
t.Errorf("First client failed to get 'foo' name: %q", actual)
7575
}
7676

0 commit comments

Comments
 (0)