style - reset style on apply

This commit is contained in:
Mahdi Abu Yasmine 2023-11-05 14:01:24 +01:00
parent ba8baf7457
commit bcf4abb26c

View File

@ -12,6 +12,7 @@ import (
const KEY_STYLE_NAME = 0 const KEY_STYLE_NAME = 0
const KEY_STYLE_COLOR = 1 const KEY_STYLE_COLOR = 1
const KEY_STYLE_OPTION = 2 const KEY_STYLE_OPTION = 2
const COLOR_OFF = "\\033[m"
var defStyle *Style = &Style{color: color.HEXStyle("#ffffff"), Name: "default"} var defStyle *Style = &Style{color: color.HEXStyle("#ffffff"), Name: "default"}
@ -29,11 +30,11 @@ type Styles struct {
} }
func (s *Style) Echof(format string, a ...any) { func (s *Style) Echof(format string, a ...any) {
s.color.Printf(format, a...) s.color.Printf(format+COLOR_OFF, a...)
} }
func (s *Style) Applyf(format string, a ...any) string { func (s *Style) Applyf(format string, a ...any) string {
return s.color.Sprintf(format, a...) return s.color.Sprintf(format+COLOR_OFF, a...)
} }
func (s *Style) Echo(data string) { func (s *Style) Echo(data string) {