From a47c1a76b4781287270b00548794aae42c4f7603 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Tue, 12 Mar 2024 08:12:12 +0000 Subject: [PATCH] tui: use ctx chroma highlighter --- pkg/tui/tui.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/tui/tui.go b/pkg/tui/tui.go index 92b2c5a..aa545f3 100644 --- a/pkg/tui/tui.go +++ b/pkg/tui/tui.go @@ -13,7 +13,6 @@ import ( "git.mlow.ca/mlow/lmcli/pkg/lmcli" models "git.mlow.ca/mlow/lmcli/pkg/lmcli/model" "git.mlow.ca/mlow/lmcli/pkg/lmcli/tools" - "git.mlow.ca/mlow/lmcli/pkg/util/tty" "github.com/charmbracelet/bubbles/textarea" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" @@ -24,8 +23,6 @@ type model struct { ctx *lmcli.Context convShortname string - highlighter *tty.ChromaHighlighter - // application state conversation *models.Conversation messages []models.Message @@ -155,12 +152,6 @@ func initialModel(ctx *lmcli.Context, convShortname string) model { confirmPrompt: false, } - m.highlighter = tty.NewChromaHighlighter( - "markdown", // we're highlighting markdown - *ctx.Config.Chroma.Formatter, - *ctx.Config.Chroma.Style, - ) - m.content = viewport.New(0, 0) m.input = textarea.New() @@ -295,7 +286,7 @@ func (m *model) updateContent() { sb.WriteString(fmt.Sprintf("%s:\n\n", style.Render(string(message.Role)))) - highlighted, _ := m.highlighter.HighlightS(message.Content) + highlighted, _ := m.ctx.Chroma.HighlightS(message.Content) sb.WriteString(contentStyle.Width(m.content.Width - 5).Render(highlighted)) if i < msgCnt-1 { sb.WriteString("\n\n")