summaryrefslogtreecommitdiffhomepage
path: root/internal/tui/layout
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-09 19:07:39 +0200
committerKujtim Hoxha <[email protected]>2025-04-09 19:07:39 +0200
commitd39d52d95d6aaab67fb3a17efb9ed62cc290e72f (patch)
tree940bad6f0c847ceb213e5fc684b6d87cbf9d6996 /internal/tui/layout
parent0d8d324ac6e640b95f4f2f62fd189399a959319a (diff)
downloadopencode-d39d52d95d6aaab67fb3a17efb9ed62cc290e72f.tar.gz
opencode-d39d52d95d6aaab67fb3a17efb9ed62cc290e72f.zip
finish logs page
Diffstat (limited to 'internal/tui/layout')
-rw-r--r--internal/tui/layout/bento.go55
1 files changed, 38 insertions, 17 deletions
diff --git a/internal/tui/layout/bento.go b/internal/tui/layout/bento.go
index 5225db192..c47c4e090 100644
--- a/internal/tui/layout/bento.go
+++ b/internal/tui/layout/bento.go
@@ -187,7 +187,6 @@ func (b *bentoLayout) SetSize(width int, height int) {
b.width = width
b.height = height
- // Check which panes are available
leftExists := false
rightTopExists := false
rightBottomExists := false
@@ -218,7 +217,6 @@ func (b *bentoLayout) SetSize(width int, height int) {
rightTopHeight = int(float64(height) * b.rightTopHeightRatio)
rightBottomHeight = height - rightTopHeight
- // Ensure minimum height for bottom pane
if rightBottomHeight < minRightBottomHeight && height >= minRightBottomHeight {
rightBottomHeight = minRightBottomHeight
rightTopHeight = height - rightBottomHeight
@@ -271,23 +269,47 @@ func (b *bentoLayout) HidePane(pane paneID) tea.Cmd {
}
func (b *bentoLayout) SwitchPane(back bool) tea.Cmd {
+ orderForward := []paneID{BentoLeftPane, BentoRightTopPane, BentoRightBottomPane}
+ orderBackward := []paneID{BentoLeftPane, BentoRightBottomPane, BentoRightTopPane}
+
+ order := orderForward
if back {
- switch b.currentPane {
- case BentoLeftPane:
- b.currentPane = BentoRightBottomPane
- case BentoRightTopPane:
- b.currentPane = BentoLeftPane
- case BentoRightBottomPane:
- b.currentPane = BentoRightTopPane
+ order = orderBackward
+ }
+
+ currentIdx := -1
+ for i, id := range order {
+ if id == b.currentPane {
+ currentIdx = i
+ break
+ }
+ }
+
+ if currentIdx == -1 {
+ for _, id := range order {
+ if _, exists := b.panes[id]; exists {
+ if _, hidden := b.hiddenPanes[id]; !hidden {
+ b.currentPane = id
+ break
+ }
+ }
}
} else {
- switch b.currentPane {
- case BentoLeftPane:
- b.currentPane = BentoRightTopPane
- case BentoRightTopPane:
- b.currentPane = BentoRightBottomPane
- case BentoRightBottomPane:
- b.currentPane = BentoLeftPane
+ startIdx := currentIdx
+ for {
+ currentIdx = (currentIdx + 1) % len(order)
+
+ nextID := order[currentIdx]
+ if _, exists := b.panes[nextID]; exists {
+ if _, hidden := b.hiddenPanes[nextID]; !hidden {
+ b.currentPane = nextID
+ break
+ }
+ }
+
+ if currentIdx == startIdx {
+ break
+ }
}
}
@@ -319,7 +341,6 @@ type BentoLayoutOption func(*bentoLayout)
func NewBentoLayout(panes BentoPanes, opts ...BentoLayoutOption) BentoLayout {
p := make(map[paneID]SinglePaneLayout, len(panes))
for id, pane := range panes {
- // Wrap any pane that is not a SinglePaneLayout in a SinglePaneLayout
if sp, ok := pane.(SinglePaneLayout); !ok {
p[id] = NewSinglePane(
pane,