Colorize Sys/Announce messages.

This commit is contained in:
Andrey Petrov 2015-01-18 19:27:49 -08:00
parent 6c972e6e58
commit c33f4284f9
2 changed files with 15 additions and 4 deletions

View File

@ -196,11 +196,14 @@ func NewSystemMsg(body string, to *User) *SystemMsg {
}
func (m *SystemMsg) Render(t *Theme) string {
return fmt.Sprintf("-> %s", m.body)
if t == nil {
return m.String()
}
return t.ColorSys(m.String())
}
func (m *SystemMsg) String() string {
return m.Render(nil)
return fmt.Sprintf("-> %s", m.body)
}
func (m *SystemMsg) To() *User {
@ -223,11 +226,14 @@ func NewAnnounceMsg(body string) *AnnounceMsg {
}
func (m *AnnounceMsg) Render(t *Theme) string {
return fmt.Sprintf(" * %s", m.body)
if t == nil {
return m.String()
}
return t.ColorSys(m.String())
}
func (m *AnnounceMsg) String() string {
return m.Render(nil)
return fmt.Sprintf(" * %s", m.body)
}
type CommandMsg struct {

View File

@ -186,5 +186,10 @@ func init() {
},
}
// Debug for printing colors:
//for _, color := range palette.colors {
// fmt.Print(color.Format(color.String() + " "))
//}
DefaultTheme = &Themes[0]
}