diff --git a/echo/echo.go b/echo/echo.go index c9e4892..95b7ec8 100644 --- a/echo/echo.go +++ b/echo/echo.go @@ -31,6 +31,13 @@ func SetCurrentStyles(styles *style.Styles) { hasCurStyle = true } +func InitDefaultStyles() *style.Styles { + styles := style.NewStyles() + styles.LoadDefaultStyle() + SetCurrentStyles(styles) + return styles +} + func Title(title string, subtitle string) { Cstyle("").Echof("\n ") Cstyle("appSep").Echof(SYMB_TITLE_SEP) diff --git a/style/style.go b/style/style.go index ef3492c..bb07f3b 100644 --- a/style/style.go +++ b/style/style.go @@ -15,6 +15,33 @@ const KEY_STYLE_COLOR = 1 const KEY_STYLE_OPTION = 2 const COLOR_OFF = "\x1b[0m" +var ( + DEFAULT_STYLES []string = []string{ + "key 15874B 1", + "val FFDD60 1", + "appTitle FFFFFF,346488 1", + "appSep FFDD60,346488 1", + "appSubTitle FFBD99,346488 1", + "action 885E8E 1", + "actionSep FFBD43 3", + "param FFE07E 1", + "context FFFFFF,A92C58 1", + "sep A4A4A4", + "ok FFFFFF,06926D 1", + "ko FFFFFF,920623 1", + "usageApp FFFFFF 1", + "usageCmd FFA648 1", + "usageSection FFE772 1,3", + "usageArg 15874B 1", + "usageSep A678CF 1", + "usageCom CFA6DA 3", + "usageCmd F18847 1", + "progress 106573 1", + "progressTick FFC256 1", + "progressBg 1D5058 1", + } +) + var defStyle *Style = &Style{color: color.HEXStyle("#ffffff"), Name: "default"} type Style struct { @@ -89,6 +116,15 @@ func NewStyles() *Styles { return l } +func (s *Styles) LoadDefaultStyle() { + for _, rule := range DEFAULT_STYLES { + style := NewStyleByDef(rule) + if !s.HasStyle(style.Name) { + s.List[style.Name] = style + } + } +} + func (s *Styles) HasStyle(name string) bool { var done bool = false if s.List != nil {