tui better

This commit is contained in:
2026-08-27 17:57:23 +01:00
parent 71961f68da
commit 73c2009139
5 changed files with 230 additions and 123 deletions
+21 -5
View File
@@ -6,6 +6,7 @@ import (
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
type State int
@@ -42,8 +43,8 @@ type Model struct {
func New() Model {
return Model{
state: StateForm,
form: NewForm(),
state: StateForm,
form: NewForm(),
isDark: true,
}
}
@@ -139,7 +140,12 @@ func (m Model) renderGenerating() string {
b.WriteString(fmt.Sprintf(" %s Generating...\n", m.spinner.View()))
b.WriteString("\n")
b.WriteString(footerStyle.Render("Please wait."))
return appBorder.Render(b.String())
content := appBorder.Render(b.String())
if m.width > 0 && m.height > 0 {
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, content)
}
return content
}
func (m Model) renderDone() string {
@@ -156,7 +162,12 @@ func (m Model) renderDone() string {
}
b.WriteString("\n\n")
b.WriteString(footerStyle.Render("Press any key to exit."))
return appBorder.Render(b.String())
content := appBorder.Render(b.String())
if m.width > 0 && m.height > 0 {
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, content)
}
return content
}
func (m Model) renderError() string {
@@ -168,5 +179,10 @@ func (m Model) renderError() string {
b.WriteString(fmt.Sprintf(" %s\n", m.result.Error.Error()))
b.WriteString("\n")
b.WriteString(footerStyle.Render("Press any key to exit."))
return appBorder.Render(b.String())
content := appBorder.Render(b.String())
if m.width > 0 && m.height > 0 {
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, content)
}
return content
}