tui: use ctx chroma highlighter
This commit is contained in:
parent
e92a0ff50d
commit
9d83013f52
@ -12,7 +12,6 @@ import (
|
|||||||
"git.mlow.ca/mlow/lmcli/pkg/lmcli"
|
"git.mlow.ca/mlow/lmcli/pkg/lmcli"
|
||||||
models "git.mlow.ca/mlow/lmcli/pkg/lmcli/model"
|
models "git.mlow.ca/mlow/lmcli/pkg/lmcli/model"
|
||||||
"git.mlow.ca/mlow/lmcli/pkg/lmcli/tools"
|
"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/textarea"
|
||||||
"github.com/charmbracelet/bubbles/viewport"
|
"github.com/charmbracelet/bubbles/viewport"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
@ -23,8 +22,6 @@ type model struct {
|
|||||||
ctx *lmcli.Context
|
ctx *lmcli.Context
|
||||||
convShortname string
|
convShortname string
|
||||||
|
|
||||||
highlighter *tty.ChromaHighlighter
|
|
||||||
|
|
||||||
// application state
|
// application state
|
||||||
conversation *models.Conversation
|
conversation *models.Conversation
|
||||||
messages []models.Message
|
messages []models.Message
|
||||||
@ -154,12 +151,6 @@ func initialModel(ctx *lmcli.Context, convShortname string) model {
|
|||||||
confirmPrompt: false,
|
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.content = viewport.New(0, 0)
|
||||||
|
|
||||||
m.input = textarea.New()
|
m.input = textarea.New()
|
||||||
@ -294,7 +285,7 @@ func (m *model) updateContent() {
|
|||||||
|
|
||||||
sb.WriteString(fmt.Sprintf("%s:\n\n", style.Render(string(message.Role))))
|
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))
|
sb.WriteString(contentStyle.Width(m.content.Width - 5).Render(highlighted))
|
||||||
if i < msgCnt-1 {
|
if i < msgCnt-1 {
|
||||||
sb.WriteString("\n\n")
|
sb.WriteString("\n\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user