tui: slight function order change
This commit is contained in:
parent
ccf2353a0b
commit
a96eac91b3
@ -189,12 +189,50 @@ func (m model) View() string {
|
||||
return lipgloss.JoinVertical(
|
||||
lipgloss.Left,
|
||||
m.headerView(),
|
||||
m.content.View(),
|
||||
m.contentView(),
|
||||
m.inputView(),
|
||||
m.footerView(),
|
||||
)
|
||||
}
|
||||
|
||||
func (m *model) headerView() string {
|
||||
titleStyle := lipgloss.NewStyle().
|
||||
Bold(true)
|
||||
var title string
|
||||
if m.conversation != nil && m.conversation.Title != "" {
|
||||
title = m.conversation.Title
|
||||
} else {
|
||||
title = "Untitled"
|
||||
}
|
||||
part := titleStyle.Render(title)
|
||||
|
||||
return headerStyle.Width(m.content.Width).Render(part)
|
||||
}
|
||||
|
||||
func (m *model) contentView() string {
|
||||
return m.content.View()
|
||||
}
|
||||
|
||||
func (m *model) inputView() string {
|
||||
return m.input.View()
|
||||
}
|
||||
|
||||
func (m *model) footerView() string {
|
||||
left := m.status
|
||||
right := fmt.Sprintf("Model: %s", *m.ctx.Config.Defaults.Model)
|
||||
|
||||
totalWidth := lipgloss.Width(left + right)
|
||||
var padding string
|
||||
if m.content.Width-totalWidth > 0 {
|
||||
padding = strings.Repeat(" ", m.content.Width-totalWidth)
|
||||
} else {
|
||||
padding = ""
|
||||
}
|
||||
|
||||
footer := lipgloss.JoinHorizontal(lipgloss.Center, left, padding, right)
|
||||
return footerStyle.Width(m.content.Width).Render(footer)
|
||||
}
|
||||
|
||||
func initialModel(ctx *lmcli.Context, convShortname string) model {
|
||||
m := model{
|
||||
ctx: ctx,
|
||||
@ -405,40 +443,6 @@ func (m *model) updateContent() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *model) headerView() string {
|
||||
titleStyle := lipgloss.NewStyle().
|
||||
Bold(true)
|
||||
var title string
|
||||
if m.conversation != nil && m.conversation.Title != "" {
|
||||
title = m.conversation.Title
|
||||
} else {
|
||||
title = "Untitled"
|
||||
}
|
||||
part := titleStyle.Render(title)
|
||||
|
||||
return headerStyle.Width(m.content.Width).Render(part)
|
||||
}
|
||||
|
||||
func (m model) inputView() string {
|
||||
return m.input.View()
|
||||
}
|
||||
|
||||
func (m *model) footerView() string {
|
||||
left := m.status
|
||||
right := fmt.Sprintf("Model: %s", *m.ctx.Config.Defaults.Model)
|
||||
|
||||
totalWidth := lipgloss.Width(left + right)
|
||||
var padding string
|
||||
if m.content.Width-totalWidth > 0 {
|
||||
padding = strings.Repeat(" ", m.content.Width-totalWidth)
|
||||
} else {
|
||||
padding = ""
|
||||
}
|
||||
|
||||
footer := lipgloss.JoinHorizontal(lipgloss.Center, left, padding, right)
|
||||
return footerStyle.Width(m.content.Width).Render(footer)
|
||||
}
|
||||
|
||||
func Launch(ctx *lmcli.Context, convShortname string) error {
|
||||
p := tea.NewProgram(initialModel(ctx, convShortname), tea.WithAltScreen())
|
||||
if _, err := p.Run(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user