mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-14 16:17:17 +03:00
chat/message/theme: Apply PM colors, add new themes to /help, cleanup.
Fixes #191.
This commit is contained in:
parent
f870c5761d
commit
92d821387b
@ -180,7 +180,7 @@ func InitCommands(c *Commands) {
|
|||||||
c.Add(Command{
|
c.Add(Command{
|
||||||
Prefix: "/theme",
|
Prefix: "/theme",
|
||||||
PrefixHelp: "[mono|colors]",
|
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 {
|
Handler: func(room *Room, msg message.CommandMsg) error {
|
||||||
user := msg.From()
|
user := msg.From()
|
||||||
args := msg.Args()
|
args := msg.Args()
|
||||||
|
@ -176,7 +176,11 @@ func (m PrivateMsg) To() *User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m PrivateMsg) Render(t *Theme) string {
|
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 {
|
func (m PrivateMsg) String() string {
|
||||||
|
@ -200,8 +200,8 @@ func hackerColors() *Palette {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
palette := readableColors256()
|
palette := readableColors256()
|
||||||
solar := solarizedColors()
|
solarized := solarizedColors()
|
||||||
hacker := hackerColors()
|
hacker := hackerColors()
|
||||||
|
|
||||||
Themes = []Theme{
|
Themes = []Theme{
|
||||||
{
|
{
|
||||||
@ -213,27 +213,31 @@ func init() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "solarized",
|
id: "solarized",
|
||||||
names: solar,
|
names: solarized,
|
||||||
sys: Color256(11),
|
sys: Color256(11), // Yellow
|
||||||
pm: Color256(15),
|
pm: Color256(15), // White
|
||||||
highlight: style(Bold + "\033[48;5;202m\033[38;5;256m"), // orange highlight
|
highlight: style(Bold + "\033[48;5;202m\033[38;5;256m"), // Orange highlight
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "hacker",
|
id: "hacker",
|
||||||
names: hacker,
|
names: hacker,
|
||||||
sys: Color256(22),
|
sys: Color256(22), // Green
|
||||||
pm: Color256(22),
|
pm: Color256(28), // More green, slightly lighter
|
||||||
highlight: style(Bold + "\033[48;5;22m\033[38;5;256m"), // green bg black fg
|
highlight: style(Bold + "\033[48;5;22m\033[38;5;256m"), // Green on black
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "mono",
|
id: "mono",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug for printing colors:
|
|
||||||
//for _, color := range palette.colors {
|
|
||||||
// fmt.Print(color.Format(color.String() + " "))
|
|
||||||
//}
|
|
||||||
|
|
||||||
DefaultTheme = &Themes[0]
|
DefaultTheme = &Themes[0]
|
||||||
|
|
||||||
|
// Debug for printing colors:
|
||||||
|
//printPalette(palette)
|
||||||
|
}
|
||||||
|
|
||||||
|
func printPalette(p *Palette) {
|
||||||
|
for _, color := range p.colors {
|
||||||
|
fmt.Print(color.Format(color.String() + " "))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user