Documentation
¶
Overview ¶
Package treeactions demonstrates marking and pkg/action on a tree: a cluster-shaped resource hierarchy where you mark nodes at any depth and run verbs over the selection.
Press x to mark a node, X to mark a range, A to mark everything visible, D to drop the selection. Then "a" or right-click for the menu.
The thing this screen exists to show ¶
A tree's mark key is its node **path** ("prod/api-server/pod-7f3a"), and marking a branch marks that branch alone — not its descendants. That is a deliberate choice (CLAUDE.md rule 32): it keeps Marks() equal to "what the user pressed x on", and it leaves the expansion question to the caller, because only the caller knows whether its verb is one that cascades.
Resolving a marked branch to the things a verb should actually touch is therefore the screen's job, and it is four lines — see expand() below. The paths are hierarchical strings, so "everything under this node" is a prefix test and nothing more. Restart cascades that way; Describe does not, because describing a namespace is not describing its pods.
Why the menu title matters more here than in a flat list ¶
Marks survive collapsing. Mark a pod, collapse its namespace, and the pod is still selected while nothing on screen says so — the same property that lets marks survive a filter, one level more surprising. Set.Target is the disclosure: the menu names what it is about to touch, counted after expand(), so "Restart 9 pods" is honest even when three of them are hidden inside a folded branch.
Index ¶
- func New(t theme.Theme) screen.Screen
- type Screen
- func (s *Screen) Actions() action.Set
- func (s *Screen) Help() []key.Binding
- func (s *Screen) HelpSections() []help.Section
- func (s *Screen) Init() tea.Cmd
- func (s *Screen) IsCapturingKeys() bool
- func (s *Screen) Layout() layout.Node
- func (s *Screen) OnEnter(any) tea.Cmd
- func (s *Screen) SetTheme(t theme.Theme)
- func (s *Screen) Title() string
- func (s *Screen) Update(msg tea.Msg) (screen.Screen, tea.Cmd)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Screen is a tree plus an Actions method. Nothing else about it is special.
func (*Screen) HelpSections ¶ added in v0.25.0
HelpSections passes the tree's own groups through — Navigate, Expand, Select, Search — and adds this screen's verbs under its own heading.