treeactions

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t theme.Theme) screen.Screen

New returns the tree-actions demo screen.

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) Actions

func (s *Screen) Actions() action.Set

Actions satisfies action.Provider.

func (*Screen) Help

func (s *Screen) Help() []key.Binding

func (*Screen) HelpSections added in v0.25.0

func (s *Screen) HelpSections() []help.Section

HelpSections passes the tree's own groups through — Navigate, Expand, Select, Search — and adds this screen's verbs under its own heading.

func (*Screen) Init

func (s *Screen) Init() tea.Cmd

func (*Screen) IsCapturingKeys

func (s *Screen) IsCapturingKeys() bool

func (*Screen) Layout

func (s *Screen) Layout() layout.Node

func (*Screen) OnEnter

func (s *Screen) OnEnter(any) tea.Cmd

func (*Screen) SetTheme

func (s *Screen) SetTheme(t theme.Theme)

func (*Screen) Title

func (s *Screen) Title() string

func (*Screen) Update

func (s *Screen) Update(msg tea.Msg) (screen.Screen, tea.Cmd)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL