From 5458ca37ba3740d35b186dfba27fe3eaa46130de Mon Sep 17 00:00:00 2001 From: mahdi Date: Sun, 5 Nov 2023 13:49:27 +0100 Subject: [PATCH] amend NewStyleByDef --- style/style.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/style/style.go b/style/style.go index 96b1ecb..5aa2f13 100644 --- a/style/style.go +++ b/style/style.go @@ -50,11 +50,16 @@ func (s *Style) Ln() { func NewStyleByDef(def string) *Style { var o []string = []string{} + var c []string = []string{"FFFFFF"} d := strings.Fields(def) - c := strings.Split(d[KEY_STYLE_COLOR], ",") - if len(d) > KEY_STYLE_OPTION { - o = strings.Split(d[KEY_STYLE_OPTION], ",") + + if len(d) > KEY_STYLE_COLOR { + c = strings.Split(d[KEY_STYLE_COLOR], ",") + if len(d) > KEY_STYLE_OPTION { + o = strings.Split(d[KEY_STYLE_OPTION], ",") + } } + util.PrependToSliceStr(&c, "#") var s *color.RGBStyle switch len(c) {