mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-07-03 04:04:34 +02:00
Colorize Sys/Announce messages.
This commit is contained in:
parent
6c972e6e58
commit
c33f4284f9
@ -196,11 +196,14 @@ func NewSystemMsg(body string, to *User) *SystemMsg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *SystemMsg) Render(t *Theme) string {
|
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 {
|
func (m *SystemMsg) String() string {
|
||||||
return m.Render(nil)
|
return fmt.Sprintf("-> %s", m.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SystemMsg) To() *User {
|
func (m *SystemMsg) To() *User {
|
||||||
@ -223,11 +226,14 @@ func NewAnnounceMsg(body string) *AnnounceMsg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *AnnounceMsg) Render(t *Theme) string {
|
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 {
|
func (m *AnnounceMsg) String() string {
|
||||||
return m.Render(nil)
|
return fmt.Sprintf(" * %s", m.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandMsg struct {
|
type CommandMsg struct {
|
||||||
|
@ -186,5 +186,10 @@ func init() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug for printing colors:
|
||||||
|
//for _, color := range palette.colors {
|
||||||
|
// fmt.Print(color.Format(color.String() + " "))
|
||||||
|
//}
|
||||||
|
|
||||||
DefaultTheme = &Themes[0]
|
DefaultTheme = &Themes[0]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user