From 5499788460ca87f4f58902a475356c96440dbe93 Mon Sep 17 00:00:00 2001 From: "diamondburned (Forefront)" Date: Sun, 28 Jun 2020 16:02:28 -0700 Subject: [PATCH] Removed dead code --- go.mod | 2 +- internal/ui/rich/parser/hl/hl.go | 49 -------------------------------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/go.mod b/go.mod index 2319abf..2850520 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 replace github.com/gotk3/gotk3 => github.com/diamondburned/gotk3 v0.0.0-20200619213419-0533bcce0dd6 -// replace github.com/diamondburned/cchat-discord => ../cchat-discord/ +replace github.com/diamondburned/cchat-discord => ../cchat-discord/ require ( github.com/Xuanwo/go-locale v0.2.0 diff --git a/internal/ui/rich/parser/hl/hl.go b/internal/ui/rich/parser/hl/hl.go index 02c4ce9..b875209 100644 --- a/internal/ui/rich/parser/hl/hl.go +++ b/internal/ui/rich/parser/hl/hl.go @@ -3,8 +3,6 @@ package hl import ( "errors" "fmt" - "html" - "io" "strings" "github.com/alecthomas/chroma" @@ -42,21 +40,6 @@ func Tokenize(language, source string) chroma.Iterator { return i } -func Render(w io.Writer, language, source string) { - if i := Tokenize(language, source); i != nil { - fmtter.Format(w, i) - } else { - // Fallback. - w.Write([]byte(source)) - } -} - -func RenderString(language, source string) string { - var buf strings.Builder - Render(&buf, language, source) - return buf.String() -} - func Segments(appendmap *attrmap.AppendMap, src string, seg text.Codeblocker) { var start, end = seg.Bounds() appendmap.Span(start, end, `font_family="monospace"`) @@ -120,38 +103,6 @@ func (f *formatter) segments(appendmap *attrmap.AppendMap, offset int, iter chro } } -func (f *formatter) Format(w io.Writer, iterator chroma.Iterator) { - f.reset() - - for _, token := range iterator.Tokens() { - var code = strings.Replace(html.EscapeString(token.String()), "\t", " ", -1) - if attr := f.styleAttr(token.Type); attr != "" { - code = fmt.Sprintf(`%s`, attr, code) - } - - w.Write([]byte(code)) - } -} - -func (f *formatter) shouldHighlight(highlightIndex, line int) (bool, bool) { - var next = false - - for highlightIndex < len(f.highlightRanges) && line > f.highlightRanges[highlightIndex][1] { - highlightIndex++ - next = true - } - - if highlightIndex < len(f.highlightRanges) { - hrange := f.highlightRanges[highlightIndex] - - if line >= hrange[0] && line <= hrange[1] { - return true, next - } - } - - return false, next -} - func (f *formatter) styleAttr(tt chroma.TokenType) string { if _, ok := css[tt]; !ok { tt = tt.SubCategory()