From da716cd0f76505f81225f8b32abd0b6888c8b7b7 Mon Sep 17 00:00:00 2001 From: Yieldone Date: Wed, 3 Jul 2024 19:08:19 +0800 Subject: [PATCH] style: rm border/parameter.go, move to handler --- service/border/{processor.go => handler.go} | 18 +++- service/border/parameter.go | 99 --------------------- 2 files changed, 16 insertions(+), 101 deletions(-) rename service/border/{processor.go => handler.go} (88%) delete mode 100644 service/border/parameter.go diff --git a/service/border/processor.go b/service/border/handler.go similarity index 88% rename from service/border/processor.go rename to service/border/handler.go index dee4cdf..530046f 100644 --- a/service/border/processor.go +++ b/service/border/handler.go @@ -13,12 +13,26 @@ import ( "strings" ) +type Style string + +const ( + StyleSimple Style = "simple" + StyleTextBottom Style = "text_bottom" +) + +type Parameterizable interface { + Input() string + SetInput(input string) + Output() string + SetOutput(output string) +} + type StyleProcessor struct { style Style - params Parameter + params Parameterizable } -func NewStyleProcessor(style Style, params Parameter) *StyleProcessor { +func NewStyleProcessor(style Style, params Parameterizable) *StyleProcessor { return &StyleProcessor{ style: style, params: params, diff --git a/service/border/parameter.go b/service/border/parameter.go deleted file mode 100644 index 830df26..0000000 --- a/service/border/parameter.go +++ /dev/null @@ -1,99 +0,0 @@ -package border - -import ( - "github.com/sincerefly/capybara/utils" - "image/color" - "path/filepath" -) - -type Style string - -const ( - StyleSimple Style = "simple" - StyleTextBottom Style = "text_bottom" -) - -type GeneralParameter struct { - style Style - input string - output string - borderWidth int - borderColor color.Color -} - -func NewGeneralParameter() GeneralParameter { - return GeneralParameter{} -} - -func (p *GeneralParameter) SetStyle(style Style) *GeneralParameter { - p.style = style - return p -} - -func (p *GeneralParameter) SetDefaultStyle() *GeneralParameter { - p.style = StyleSimple - return p -} - -func (p *GeneralParameter) GetStyle() Style { - return p.style -} - -func (p *GeneralParameter) SetInput(inputDir string) *GeneralParameter { - p.input = inputDir - return p -} - -func (p *GeneralParameter) SetDefaultInput() *GeneralParameter { - dir, err := utils.ExecutableDir() - if err != nil { - return nil - } - p.input = filepath.Join(dir, "input") - return p -} - -func (p *GeneralParameter) Input() string { - return p.input -} - -func (p *GeneralParameter) SetOutput(outputDir string) *GeneralParameter { - p.output = outputDir - return p -} - -func (p *GeneralParameter) SetDefaultOutput() *GeneralParameter { - dir, err := utils.ExecutableDir() - if err != nil { - return nil - } - p.output = filepath.Join(dir, "output") - return p -} - -func (p *GeneralParameter) Output() string { - return p.output -} - -func (p *GeneralParameter) SetBorderWidth(borderWidth int) *GeneralParameter { - p.borderWidth = borderWidth - return p -} - -func (p *GeneralParameter) GetBorderWidth() int { - return p.borderWidth -} - -func (p *GeneralParameter) SetBorderColor(color color.Color) *GeneralParameter { - p.borderColor = color - return p -} - -func (p *GeneralParameter) GetBorderColor() color.Color { - return p.borderColor -} - -type Parameter interface { - Input() string - Output() string -}