mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-15 00:20:37 +03:00
chat/message/theme: Tweak default colorscheme
Fewer grey names, lighter grey for system messages.
This commit is contained in:
parent
c69cefc873
commit
972bb86621
@ -156,19 +156,17 @@ var Themes []Theme
|
|||||||
var DefaultTheme *Theme
|
var DefaultTheme *Theme
|
||||||
|
|
||||||
func readableColors256() *Palette {
|
func readableColors256() *Palette {
|
||||||
size := 247
|
size := 225
|
||||||
p := Palette{
|
p := Palette{
|
||||||
colors: make([]Style, size),
|
colors: make([]Style, 0, size),
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
j := 0
|
|
||||||
for i := 0; i < 256; i++ {
|
for i := 0; i < 256; i++ {
|
||||||
if (16 <= i && i <= 18) || (232 <= i && i <= 237) {
|
if i == 0 || i == 7 || i == 8 || i == 15 || i == 16 || i == 17 || i > 230 {
|
||||||
// Remove the ones near black, this is kinda sadpanda.
|
// Skip 31 Shades of Grey, and one hyperintelligent shade of blue.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
p.colors[j] = Color256(i)
|
p.colors = append(p.colors, Color256(i))
|
||||||
j++
|
|
||||||
}
|
}
|
||||||
return &p
|
return &p
|
||||||
}
|
}
|
||||||
@ -207,8 +205,8 @@ func init() {
|
|||||||
{
|
{
|
||||||
id: "colors",
|
id: "colors",
|
||||||
names: palette,
|
names: palette,
|
||||||
sys: palette.Get(8), // Grey
|
sys: Color256(245), // Grey
|
||||||
pm: palette.Get(7), // White
|
pm: Color256(7), // White
|
||||||
highlight: style(Bold + "\033[48;5;11m\033[38;5;16m"), // Yellow highlight
|
highlight: style(Bold + "\033[48;5;11m\033[38;5;16m"), // Yellow highlight
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -237,7 +235,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printPalette(p *Palette) {
|
func printPalette(p *Palette) {
|
||||||
for _, color := range p.colors {
|
for i, color := range p.colors {
|
||||||
fmt.Print(color.Format(color.String() + " "))
|
fmt.Printf("%d\t%s\n", i, color.Format(color.String()+" "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
import (
|
import "testing"
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestThemePalette(t *testing.T) {
|
func TestThemePalette(t *testing.T) {
|
||||||
var expected, actual string
|
var expected, actual string
|
||||||
@ -15,21 +12,21 @@ func TestThemePalette(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actual = color.String()
|
actual = color.String()
|
||||||
expected = "38;05;5"
|
expected = "38;05;6"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
|
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
actual = color.Format("foo")
|
actual = color.Format("foo")
|
||||||
expected = "\033[38;05;5mfoo\033[0m"
|
expected = "\033[38;05;6mfoo\033[0m"
|
||||||
if actual != expected {
|
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()
|
actual = palette.Get(palette.Len() + 1).String()
|
||||||
expected = fmt.Sprintf("38;05;%d", 2)
|
expected = "38;05;3"
|
||||||
if actual != expected {
|
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")
|
actual = color.Format("foo")
|
||||||
expected = "\033[38;05;8mfoo\033[0m"
|
expected = "\033[38;05;245mfoo\033[0m"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
|
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
actual = colorTheme.ColorSys("foo")
|
actual = colorTheme.ColorSys("foo")
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
|
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
u := NewUser(SimpleId("foo"))
|
u := NewUser(SimpleId("foo"))
|
||||||
u.colorIdx = 4
|
u.colorIdx = 4
|
||||||
actual = colorTheme.ColorName(u)
|
actual = colorTheme.ColorName(u)
|
||||||
expected = "\033[38;05;4mfoo\033[0m"
|
expected = "\033[38;05;5mfoo\033[0m"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
|
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := NewPublicMsg("hello", u)
|
msg := NewPublicMsg("hello", u)
|
||||||
actual = msg.Render(&colorTheme)
|
actual = msg.Render(&colorTheme)
|
||||||
expected = "\033[38;05;4mfoo\033[0m: hello"
|
expected = "\033[38;05;5mfoo\033[0m: hello"
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
|
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ func TestIgnore(t *testing.T) {
|
|||||||
|
|
||||||
// ensure ignorer has received the message
|
// ensure ignorer has received the message
|
||||||
if !ignorer.user.HasMessages() {
|
if !ignorer.user.HasMessages() {
|
||||||
|
// FIXME: This is flaky :/
|
||||||
t.Fatal("should have messages")
|
t.Fatal("should have messages")
|
||||||
}
|
}
|
||||||
ignorer.user.HandleMsg(ignorer.user.ConsumeOne())
|
ignorer.user.HandleMsg(ignorer.user.ConsumeOne())
|
||||||
|
@ -37,7 +37,7 @@ func TestHostGetPrompt(t *testing.T) {
|
|||||||
|
|
||||||
u.Config.Theme = &message.Themes[0]
|
u.Config.Theme = &message.Themes[0]
|
||||||
actual = GetPrompt(u)
|
actual = GetPrompt(u)
|
||||||
expected = "[\033[38;05;2mfoo\033[0m] "
|
expected = "[\033[38;05;3mfoo\033[0m] "
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
t.Errorf("Got: %q; Expected: %q", actual, expected)
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ func TestHostNameCollision(t *testing.T) {
|
|||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
actual := scanner.Text()
|
actual := scanner.Text()
|
||||||
if !strings.HasPrefix(actual, "[foo] ") {
|
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)
|
t.Errorf("First client failed to get 'foo' name: %q", actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user