tui: use ctx chroma highlighter
This commit is contained in:
parent
b803ea7a52
commit
3b71f08d19
@ -12,7 +12,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"
|
||||
@ -23,8 +22,6 @@ type model struct {
|
||||
ctx *lmcli.Context
|
||||
convShortname string
|
||||
|
||||
highlighter *tty.ChromaHighlighter
|
||||
|
||||
// application state
|
||||
conversation *models.Conversation
|
||||
messages []models.Message
|
||||
@ -154,12 +151,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()
|
||||
@ -294,7 +285,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")
|
||||
|
Loading…
Reference in New Issue
Block a user