add parsers

This commit is contained in:
probandula
2016-11-03 09:23:34 +01:00
parent 76dcd98705
commit 06b018b123
6 changed files with 152 additions and 28 deletions

View File

@@ -7,6 +7,8 @@ type RenderOptions struct {
FontName string
// Colors of the font
FontColor []Color
// Parser
Parser Parser
}
// NewRenderOptions creates new RenderOptions
@@ -14,6 +16,7 @@ type RenderOptions struct {
func NewRenderOptions() *RenderOptions {
return &RenderOptions{
FontName: defaultFont,
Parser: ParserTerminal,
}
}
@@ -83,15 +86,19 @@ func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error
// Result which will be returned
result := ""
result += opt.Parser.Prefix
// Foreach line of the font height
for curLine := 0; curLine < font.height; curLine++ {
// Add the current line of the char to the result
for i := range chars {
result += chars[i].GetLine(curLine)
result += chars[i].GetLine(curLine, opt.Parser)
}
// A new line at the end
result += "\n"
result += opt.Parser.NewLine
}
result += opt.Parser.Suffix
return result, nil
}