wip: refactoring tui

This commit is contained in:
adamdottv
2025-06-13 11:18:46 -05:00
parent 62b9a30a9c
commit 61396b93ed
4 changed files with 70 additions and 22 deletions

View File

@@ -18,11 +18,14 @@ type Container interface {
Blur()
MaxWidth() int
Alignment() lipgloss.Position
GetPosition() (x, y int)
}
type container struct {
width int
height int
x int
y int
content ModelWithView
@@ -140,7 +143,7 @@ func (c *container) SetSize(width, height int) tea.Cmd {
}
func (c *container) GetSize() (int, int) {
return c.width, c.height
return min(c.width, c.maxWidth), c.height
}
func (c *container) MaxWidth() int {
@@ -169,6 +172,11 @@ func (c *container) Blur() {
}
}
// GetPosition returns the x, y coordinates of the container
func (c *container) GetPosition() (x, y int) {
return c.x, c.y
}
type ContainerOption func(*container)
func NewContainer(content ModelWithView, options ...ContainerOption) Container {