Every workspace split into real panes: 19 panes across 7 workspaces, one program per panel
This commit is contained in:
25
tui/frame.go
25
tui/frame.go
@@ -289,3 +289,28 @@ func helpOverlay(title string, entries [][2]string, w, h int) string {
|
||||
p := panel{title: title, width: boxW, height: boxH, focused: true}
|
||||
return lipgloss.Place(w, h, lipgloss.Center, lipgloss.Center, p.render(lines))
|
||||
}
|
||||
|
||||
// singlePanel draws one panel filling the whole pane: a title, optional tabs,
|
||||
// a scrolling body, and one line of keys. It is what a pane shows when a
|
||||
// workspace has been split into real panes instead of one program drawing
|
||||
// several panels inside itself.
|
||||
func singlePanel(title string, tabs []string, active int, body []string, w, h int, footer string, scroll int) string {
|
||||
if w < 12 || h < 4 {
|
||||
return fmt.Sprintf("this pane is %d × %d; it needs 12 × 4", w, h)
|
||||
}
|
||||
p := panel{title: title, tabs: tabs, active: active, width: w, height: h - 1, focused: true}
|
||||
visible := p.bodyHeight()
|
||||
maxScroll := max(0, len(body)-visible)
|
||||
if scroll > maxScroll {
|
||||
scroll = maxScroll
|
||||
}
|
||||
if scroll < 0 {
|
||||
scroll = 0
|
||||
}
|
||||
from := scroll
|
||||
to := min(len(body), from+visible)
|
||||
if to < from {
|
||||
to = from
|
||||
}
|
||||
return p.render(body[from:to]) + "\n" + truncateVisible(footer, w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user