summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/layout
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-06-12 05:35:40 -0500
committeradamdottv <[email protected]>2025-06-12 16:00:24 -0500
commitcce2e4ad754479917fc8f6f24c1421cf19c04573 (patch)
tree62c0ec32358932a468af73b44fd28e7de7859bbe /packages/tui/internal/layout
parenta1ce35c208bf9ebca37f722e845035bd7fd5e801 (diff)
downloadopencode-cce2e4ad754479917fc8f6f24c1421cf19c04573.tar.gz
opencode-cce2e4ad754479917fc8f6f24c1421cf19c04573.zip
wip: refactoring tui
Diffstat (limited to 'packages/tui/internal/layout')
-rw-r--r--packages/tui/internal/layout/container.go19
-rw-r--r--packages/tui/internal/layout/flex.go14
-rw-r--r--packages/tui/internal/layout/layout.go4
-rw-r--r--packages/tui/internal/layout/overlay.go4
4 files changed, 20 insertions, 21 deletions
diff --git a/packages/tui/internal/layout/container.go b/packages/tui/internal/layout/container.go
index 1c12ef6a1..2bed6708f 100644
--- a/packages/tui/internal/layout/container.go
+++ b/packages/tui/internal/layout/container.go
@@ -1,14 +1,19 @@
package layout
import (
- "github.com/charmbracelet/bubbles/key"
- tea "github.com/charmbracelet/bubbletea"
- "github.com/charmbracelet/lipgloss"
+ "github.com/charmbracelet/bubbles/v2/key"
+ tea "github.com/charmbracelet/bubbletea/v2"
+ "github.com/charmbracelet/lipgloss/v2"
"github.com/sst/opencode/internal/theme"
)
-type Container interface {
+type ModelWithView interface {
tea.Model
+ tea.ViewModel
+}
+
+type Container interface {
+ ModelWithView
Sizeable
Bindings
Focus()
@@ -21,7 +26,7 @@ type container struct {
width int
height int
- content tea.Model
+ content ModelWithView
paddingTop int
paddingRight int
@@ -46,7 +51,7 @@ func (c *container) Init() tea.Cmd {
func (c *container) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
u, cmd := c.content.Update(msg)
- c.content = u
+ c.content = u.(ModelWithView)
return c, cmd
}
@@ -175,7 +180,7 @@ func (c *container) Blur() {
type ContainerOption func(*container)
-func NewContainer(content tea.Model, options ...ContainerOption) Container {
+func NewContainer(content ModelWithView, options ...ContainerOption) Container {
c := &container{
content: content,
borderStyle: lipgloss.NormalBorder(),
diff --git a/packages/tui/internal/layout/flex.go b/packages/tui/internal/layout/flex.go
index a0882196e..292cfcb0f 100644
--- a/packages/tui/internal/layout/flex.go
+++ b/packages/tui/internal/layout/flex.go
@@ -1,10 +1,9 @@
package layout
import (
- "github.com/charmbracelet/bubbles/key"
- tea "github.com/charmbracelet/bubbletea"
- "github.com/charmbracelet/lipgloss"
- "github.com/sst/opencode/internal/theme"
+ "github.com/charmbracelet/bubbles/v2/key"
+ tea "github.com/charmbracelet/bubbletea/v2"
+ "github.com/charmbracelet/lipgloss/v2"
)
type FlexDirection int
@@ -26,7 +25,7 @@ func FlexPaneSizeFixed(size int) FlexPaneSize {
}
type FlexLayout interface {
- tea.Model
+ ModelWithView
Sizeable
Bindings
SetPanes(panes []Container) tea.Cmd
@@ -75,8 +74,6 @@ func (f *flexLayout) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (f *flexLayout) View() string {
- t := theme.CurrentTheme()
-
if len(f.panes) == 0 {
return ""
}
@@ -94,7 +91,6 @@ func (f *flexLayout) View() string {
paneWidth,
pane.Alignment(),
pane.View(),
- lipgloss.WithWhitespaceBackground(t.Background()),
)
views = append(views, view)
} else {
@@ -105,7 +101,6 @@ func (f *flexLayout) View() string {
lipgloss.Center,
pane.Alignment(),
pane.View(),
- lipgloss.WithWhitespaceBackground(t.Background()),
)
views = append(views, view)
}
@@ -245,4 +240,3 @@ func WithPaneSizes(sizes ...FlexPaneSize) FlexLayoutOption {
f.sizes = sizes
}
}
-
diff --git a/packages/tui/internal/layout/layout.go b/packages/tui/internal/layout/layout.go
index 05f07f1a2..9a7fefcad 100644
--- a/packages/tui/internal/layout/layout.go
+++ b/packages/tui/internal/layout/layout.go
@@ -3,8 +3,8 @@ package layout
import (
"reflect"
- "github.com/charmbracelet/bubbles/key"
- tea "github.com/charmbracelet/bubbletea"
+ "github.com/charmbracelet/bubbles/v2/key"
+ tea "github.com/charmbracelet/bubbletea/v2"
)
var Current *LayoutInfo
diff --git a/packages/tui/internal/layout/overlay.go b/packages/tui/internal/layout/overlay.go
index bc349096a..c2cd54b1a 100644
--- a/packages/tui/internal/layout/overlay.go
+++ b/packages/tui/internal/layout/overlay.go
@@ -3,7 +3,7 @@ package layout
import (
"strings"
- "github.com/charmbracelet/lipgloss"
+ "github.com/charmbracelet/lipgloss/v2"
chAnsi "github.com/charmbracelet/x/ansi"
"github.com/muesli/ansi"
"github.com/muesli/reflow/truncate"
@@ -14,7 +14,7 @@ import (
)
// Most of this code is borrowed from
-// https://github.com/charmbracelet/lipgloss/pull/102
+// https://github.com/charmbracelet/lipgloss/v2/pull/102
// as well as the lipgloss library, with some modification for what I needed.
// Split a string into lines, additionally returning the size of the widest line.