- Wrapped all table operations in a new foreground job context, which mediates foreground tasks. - Added cancellation support and partial results for table read operations. - Added the "mark" command, which can mark, unmark & toggle marked items - Added support for alias arguments. - Removed the "unmark" command, and replaced it as an alias to the "marked" command - Fixed seg faults raised when there is no table shown in the result set.
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package layout
|
|
|
|
import (
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/lmika/audax/internal/dynamo-browse/ui/teamodels/utils"
|
|
)
|
|
|
|
type ZStack struct {
|
|
visibleModel tea.Model
|
|
focusedModel tea.Model
|
|
otherModels []tea.Model
|
|
}
|
|
|
|
func NewZStack(visibleModel tea.Model, focusedModel tea.Model, otherModels ...tea.Model) ZStack {
|
|
return ZStack{
|
|
visibleModel: visibleModel,
|
|
focusedModel: focusedModel,
|
|
otherModels: otherModels,
|
|
}
|
|
}
|
|
|
|
func (vb ZStack) Init() tea.Cmd {
|
|
var cc utils.CmdCollector
|
|
cc.Collect(vb.visibleModel, vb.visibleModel.Init())
|
|
cc.Collect(vb.focusedModel, vb.focusedModel.Init())
|
|
for _, c := range vb.otherModels {
|
|
cc.Collect(c, c.Init())
|
|
}
|
|
return cc.Cmd()
|
|
}
|
|
|
|
func (vb ZStack) Update(msg tea.Msg) (m tea.Model, cmd tea.Cmd) {
|
|
switch msg.(type) {
|
|
case tea.KeyMsg:
|
|
// Only the focused model gets keyboard events
|
|
vb.focusedModel, cmd = vb.focusedModel.Update(msg)
|
|
return vb, cmd
|
|
}
|
|
|
|
// All other messages go to each model
|
|
var cc utils.CmdCollector
|
|
vb.visibleModel = cc.Collect(vb.visibleModel.Update(msg)).(tea.Model)
|
|
vb.focusedModel = cc.Collect(vb.focusedModel.Update(msg)).(tea.Model)
|
|
for i, c := range vb.otherModels {
|
|
vb.otherModels[i] = cc.Collect(c.Update(msg)).(tea.Model)
|
|
}
|
|
return vb, cc.Cmd()
|
|
}
|
|
|
|
func (vb ZStack) View() string {
|
|
return vb.visibleModel.View()
|
|
}
|
|
|
|
func (vb ZStack) Resize(w, h int) ResizingModel {
|
|
vb.visibleModel = Resize(vb.visibleModel, w, h)
|
|
vb.focusedModel = Resize(vb.focusedModel, w, h)
|
|
for i := range vb.otherModels {
|
|
vb.otherModels[i] = Resize(vb.otherModels[i], w, h)
|
|
}
|
|
return vb
|
|
}
|