fix(tui): layout issues

This commit is contained in:
adamdottv 2025-07-01 06:41:39 -05:00
parent aef81fce0b
commit 739a9f71c3
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
3 changed files with 29 additions and 41 deletions

View file

@ -21,9 +21,10 @@ import (
type EditorComponent interface {
tea.Model
tea.ViewModel
// tea.ViewModel
SetSize(width, height int) tea.Cmd
Content() string
View(width int, align lipgloss.Position) string
Content(width int, align lipgloss.Position) string
Lines() int
Value() string
Focused() bool
@ -105,7 +106,7 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...)
}
func (m *editorComponent) Content() string {
func (m *editorComponent) Content(width int, align lipgloss.Position) string {
t := theme.CurrentTheme()
base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render
muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render
@ -121,7 +122,7 @@ func (m *editorComponent) Content() string {
)
textarea = styles.NewStyle().
Background(t.BackgroundElement()).
Width(m.width).
Width(width).
PaddingTop(1).
PaddingBottom(1).
BorderStyle(lipgloss.ThickBorder()).
@ -156,19 +157,19 @@ func (m *editorComponent) Content() string {
return content
}
func (m *editorComponent) View() string {
func (m *editorComponent) View(width int, align lipgloss.Position) string {
if m.Lines() > 1 {
t := theme.CurrentTheme()
return lipgloss.Place(
m.width,
width,
m.height,
lipgloss.Center,
align,
lipgloss.Center,
"",
styles.WhitespaceStyle(t.Background()),
)
}
return m.Content()
return m.Content(width, align)
}
func (m *editorComponent) Focused() bool {
@ -343,7 +344,6 @@ func createTextArea(existing *textarea.Model) textarea.Model {
ta.SetHeight(existing.Height())
}
// ta.Focus()
return ta
}