From 92d821387b3dd777e0f24ed02ce595452d7aa4f0 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Thu, 11 Aug 2016 15:09:13 -0400 Subject: [PATCH] chat/message/theme: Apply PM colors, add new themes to /help, cleanup. Fixes #191. --- chat/command.go | 2 +- chat/message/message.go | 6 +++++- chat/message/theme.go | 32 ++++++++++++++++++-------------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/chat/command.go b/chat/command.go index dea601b..81abf61 100644 --- a/chat/command.go +++ b/chat/command.go @@ -180,7 +180,7 @@ func InitCommands(c *Commands) { c.Add(Command{ Prefix: "/theme", PrefixHelp: "[mono|colors]", - Help: "Set your color theme.", + Help: "Set your color theme. (More themes: solarized, hacker)", Handler: func(room *Room, msg message.CommandMsg) error { user := msg.From() args := msg.Args() diff --git a/chat/message/message.go b/chat/message/message.go index a928c45..5b4f76a 100644 --- a/chat/message/message.go +++ b/chat/message/message.go @@ -176,7 +176,11 @@ func (m PrivateMsg) To() *User { } func (m PrivateMsg) Render(t *Theme) string { - return fmt.Sprintf("[PM from %s] %s", m.from.Name(), m.body) + s := fmt.Sprintf("[PM from %s] %s", m.from.Name(), m.body) + if t == nil { + return s + } + return t.ColorPM(s) } func (m PrivateMsg) String() string { diff --git a/chat/message/theme.go b/chat/message/theme.go index 2d9a3bb..b748864 100644 --- a/chat/message/theme.go +++ b/chat/message/theme.go @@ -200,8 +200,8 @@ func hackerColors() *Palette { func init() { palette := readableColors256() - solar := solarizedColors() - hacker := hackerColors() + solarized := solarizedColors() + hacker := hackerColors() Themes = []Theme{ { @@ -213,27 +213,31 @@ func init() { }, { id: "solarized", - names: solar, - sys: Color256(11), - pm: Color256(15), - highlight: style(Bold + "\033[48;5;202m\033[38;5;256m"), // orange highlight + names: solarized, + sys: Color256(11), // Yellow + pm: Color256(15), // White + highlight: style(Bold + "\033[48;5;202m\033[38;5;256m"), // Orange highlight }, { id: "hacker", names: hacker, - sys: Color256(22), - pm: Color256(22), - highlight: style(Bold + "\033[48;5;22m\033[38;5;256m"), // green bg black fg + sys: Color256(22), // Green + pm: Color256(28), // More green, slightly lighter + highlight: style(Bold + "\033[48;5;22m\033[38;5;256m"), // Green on black }, { id: "mono", }, } - // Debug for printing colors: - //for _, color := range palette.colors { - // fmt.Print(color.Format(color.String() + " ")) - //} - DefaultTheme = &Themes[0] + + // Debug for printing colors: + //printPalette(palette) +} + +func printPalette(p *Palette) { + for _, color := range p.colors { + fmt.Print(color.Format(color.String() + " ")) + } }