tui: add header with title
This commit is contained in:
parent
dfafc573e5
commit
5afc9667c7
@ -70,11 +70,14 @@ type (
|
||||
|
||||
// styles
|
||||
var (
|
||||
inputStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff0000"))
|
||||
contentStyle = lipgloss.NewStyle().PaddingLeft(2)
|
||||
userStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("10"))
|
||||
assistantStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12"))
|
||||
footerStyle = lipgloss.NewStyle().
|
||||
headerStyle = lipgloss.NewStyle().
|
||||
PaddingLeft(1).
|
||||
Background(lipgloss.Color("0"))
|
||||
footerStyle = lipgloss.NewStyle().
|
||||
Faint(true).
|
||||
BorderTop(true).
|
||||
BorderStyle(lipgloss.NormalBorder())
|
||||
)
|
||||
@ -118,7 +121,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
case tea.WindowSizeMsg:
|
||||
m.content.Width = msg.Width
|
||||
m.content.Height = msg.Height - m.input.Height() - lipgloss.Height(m.footerView())
|
||||
m.content.Height = msg.Height - m.input.Height() - lipgloss.Height(m.footerView()) - lipgloss.Height(m.headerView())
|
||||
m.input.SetWidth(msg.Width - 1)
|
||||
m.updateContent()
|
||||
case msgConversationLoaded:
|
||||
@ -180,6 +183,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
func (m model) View() string {
|
||||
return lipgloss.JoinVertical(
|
||||
lipgloss.Left,
|
||||
m.headerView(),
|
||||
m.content.View(),
|
||||
m.inputView(),
|
||||
m.footerView(),
|
||||
@ -349,17 +353,25 @@ func (m *model) updateContent() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m model) inputView() string {
|
||||
var inputView string
|
||||
if m.waitingForReply {
|
||||
inputView = inputStyle.Faint(true).Render(m.input.View())
|
||||
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 {
|
||||
inputView = inputStyle.Render(m.input.View())
|
||||
title = "Untitled"
|
||||
}
|
||||
return inputView
|
||||
part := titleStyle.Render(title)
|
||||
|
||||
return headerStyle.Width(m.content.Width).Render(part)
|
||||
}
|
||||
|
||||
func (m model) footerView() string {
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user