layout

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeKeywordPane     = "pane"
	NodeKeywordBar      = "bar"
	NodeKeywordBorders  = "borders"
	NodeKeywordColorMap = "color-map"
	NodeKeywordMargins  = "margins"
	NodeKeywordSplit    = "split"
	NodeKeywordTabs     = "tabs"
)

Variables

View Source
var ErrChildNil = errors.New("child nodes cannot be nil")

Functions

func AddMargins

func AddMargins(ctx context.Context, screen mux.Screen) mux.Screen

func Attached

func Attached(layout Layout) *tree.NodeID

Attached returns the ID field of the attached pane in the layout.

func NewStatic

func NewStatic(
	ctx context.Context,
	shouldAnimate bool,
	message string,
) *taro.Program

func ValidateTree added in v0.6.0

func ValidateTree(tree Node) error

ValidateTree inspects a tree and ensures that it conforms to all relevant constraints, namely there should only be one PaneType with Attached=true.

Types

type Bar added in v1.6.0

type Bar struct {
	*Computable
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

func NewBar added in v1.6.0

func NewBar(
	ctx context.Context,
	screen mux.Screen,
) *Bar

func (*Bar) Apply added in v1.6.0

func (b *Bar) Apply(node Node) (bool, error)

func (*Bar) Kill added in v1.6.0

func (t *Bar) Kill()

func (*Bar) Resize added in v1.6.0

func (b *Bar) Resize(size geom.Size) error

func (*Bar) Send added in v1.6.0

func (b *Bar) Send(msg mux.Msg)

func (*Bar) State added in v1.6.0

func (b *Bar) State() *tty.State

type BarNode added in v1.6.0

type BarNode struct {
	Text   *prop.String
	Bottom bool
	Node   Node
}

func (*BarNode) Children added in v1.6.0

func (n *BarNode) Children() (nodes []Node)

func (*BarNode) Clone added in v1.6.0

func (n *BarNode) Clone() Node

func (*BarNode) IsAttached added in v1.6.0

func (n *BarNode) IsAttached() bool

func (*BarNode) MarshalJanet added in v1.6.0

func (n *BarNode) MarshalJanet() interface{}

func (*BarNode) Screen added in v1.6.0

func (n *BarNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*BarNode) SetChild added in v1.6.0

func (n *BarNode) SetChild(index int, node Node)

func (*BarNode) SetVisibleChild added in v1.6.0

func (n *BarNode) SetVisibleChild(index int, node Node)

func (*BarNode) Type added in v1.6.0

func (n *BarNode) Type() NodeType

func (*BarNode) UnmarshalJanet added in v1.6.0

func (n *BarNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*BarNode) Validate added in v1.6.0

func (n *BarNode) Validate() error

func (*BarNode) VisibleChildren added in v1.6.0

func (n *BarNode) VisibleChildren() (nodes []Node)

type Borders added in v0.5.0

type Borders struct {
	*Computable
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

func NewBorders added in v0.5.0

func NewBorders(ctx context.Context, screen mux.Screen) *Borders

func (*Borders) Apply added in v1.6.0

func (l *Borders) Apply(node Node) (bool, error)

func (*Borders) Kill added in v0.5.0

func (l *Borders) Kill()

func (*Borders) Resize added in v0.5.0

func (l *Borders) Resize(size geom.Size) error

func (*Borders) Send added in v0.5.0

func (l *Borders) Send(msg mux.Msg)

func (*Borders) Size added in v0.5.0

func (l *Borders) Size() geom.Size

func (*Borders) State added in v0.5.0

func (l *Borders) State() *tty.State

type BordersNode added in v1.6.0

type BordersNode struct {
	Title       *prop.String
	TitleBottom *prop.String
	Border      *prop.Border
	BorderFg    *prop.Color
	BorderBg    *prop.Color
	Node        Node
}

func (*BordersNode) Children added in v1.6.0

func (n *BordersNode) Children() (nodes []Node)

func (*BordersNode) Clone added in v1.6.0

func (n *BordersNode) Clone() Node

func (*BordersNode) IsAttached added in v1.6.0

func (n *BordersNode) IsAttached() bool

func (*BordersNode) MarshalJanet added in v1.6.0

func (n *BordersNode) MarshalJanet() interface{}

func (*BordersNode) Screen added in v1.6.0

func (n *BordersNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*BordersNode) SetChild added in v1.6.0

func (n *BordersNode) SetChild(index int, node Node)

func (*BordersNode) SetVisibleChild added in v1.6.0

func (n *BordersNode) SetVisibleChild(index int, node Node)

func (*BordersNode) Type added in v1.6.0

func (n *BordersNode) Type() NodeType

func (*BordersNode) UnmarshalJanet added in v1.6.0

func (n *BordersNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*BordersNode) Validate added in v1.6.0

func (n *BordersNode) Validate() error

func (*BordersNode) VisibleChildren added in v1.6.0

func (n *BordersNode) VisibleChildren() (nodes []Node)

type ColorMap added in v1.6.0

type ColorMap struct {
	*Computable
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

func NewColorMap added in v1.6.0

func NewColorMap(ctx context.Context, screen mux.Screen) *ColorMap

func (*ColorMap) Apply added in v1.6.0

func (l *ColorMap) Apply(node Node) (bool, error)

func (*ColorMap) Kill added in v1.6.0

func (l *ColorMap) Kill()

func (*ColorMap) Resize added in v1.6.0

func (l *ColorMap) Resize(size geom.Size) error

func (*ColorMap) Send added in v1.6.0

func (l *ColorMap) Send(msg mux.Msg)

func (*ColorMap) Size added in v1.6.0

func (l *ColorMap) Size() geom.Size

func (*ColorMap) State added in v1.6.0

func (l *ColorMap) State() *tty.State

type ColorMapNode added in v1.6.0

type ColorMapNode struct {
	Map  *prop.ColorMap
	Node Node
}

func (*ColorMapNode) Children added in v1.6.0

func (n *ColorMapNode) Children() (nodes []Node)

func (*ColorMapNode) Clone added in v1.6.0

func (n *ColorMapNode) Clone() Node

func (*ColorMapNode) IsAttached added in v1.6.0

func (n *ColorMapNode) IsAttached() bool

func (*ColorMapNode) MarshalJanet added in v1.6.0

func (n *ColorMapNode) MarshalJanet() interface{}

func (*ColorMapNode) Screen added in v1.6.0

func (n *ColorMapNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*ColorMapNode) SetChild added in v1.6.0

func (n *ColorMapNode) SetChild(index int, node Node)

func (*ColorMapNode) SetVisibleChild added in v1.6.0

func (n *ColorMapNode) SetVisibleChild(index int, node Node)

func (*ColorMapNode) Type added in v1.6.0

func (n *ColorMapNode) Type() NodeType

func (*ColorMapNode) UnmarshalJanet added in v1.6.0

func (n *ColorMapNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*ColorMapNode) Validate added in v1.6.0

func (n *ColorMapNode) Validate() error

func (*ColorMapNode) VisibleChildren added in v1.6.0

func (n *ColorMapNode) VisibleChildren() (nodes []Node)

type Computable added in v0.8.0

type Computable struct {
	util.Lifetime
	*Log
	*Context
}

func NewComputable added in v0.8.0

func NewComputable(ctx context.Context) *Computable

type Context added in v0.8.0

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) Context added in v0.8.0

func (c *Context) Context() interface{}

func (*Context) SetContext added in v0.8.0

func (c *Context) SetContext(context interface{})

type Contextable added in v0.8.0

type Contextable interface {
	SetContext(interface{})
}

Contextable is used for passing in an execution context that will be used when running Janet functions.

type Layout

type Layout struct {
	Root Node
}

func Default added in v1.5.0

func Default() Layout

Default returns the default layout.

func New

func New(node Node) Layout

func (*Layout) MarshalJanet

func (l *Layout) MarshalJanet() interface{}

func (*Layout) UnmarshalJanet

func (l *Layout) UnmarshalJanet(value *janet.Value) (err error)

type Log added in v0.8.0

type Log struct {
	zerolog.Logger
}

func NewLog added in v0.8.0

func NewLog() *Log

func (*Log) SetLogger added in v0.8.0

func (l *Log) SetLogger(log zerolog.Logger)

type Loggable added in v0.8.0

type Loggable interface {
	SetLogger(zerolog.Logger)
}

Loggable is used for passing a logger to the Screen when appropriate.

type Margins

type Margins struct {
	*Computable
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

Margins puts empty space around a Screen and centers it. In size mode, Margins attempts to keep the Screen at a fixed size (one or both dimensions fixed). In margin mode, the Screen is surrounded by fixed-size margins that do not change with the screen size.

func NewMargins

func NewMargins(ctx context.Context, screen mux.Screen) *Margins

func (*Margins) Apply added in v1.6.0

func (l *Margins) Apply(node Node) (bool, error)

func (*Margins) Kill

func (l *Margins) Kill()

func (*Margins) Resize

func (l *Margins) Resize(size geom.Size) error

func (*Margins) Send

func (l *Margins) Send(msg mux.Msg)

func (*Margins) Size

func (l *Margins) Size() geom.Size

func (*Margins) State

func (l *Margins) State() *tty.State

type MarginsNode added in v1.6.0

type MarginsNode struct {
	Cols     int
	Rows     int
	Frame    *string
	Border   *prop.Border
	BorderFg *prop.Color
	BorderBg *prop.Color
	Node     Node
}

func (*MarginsNode) Children added in v1.6.0

func (n *MarginsNode) Children() (nodes []Node)

func (*MarginsNode) Clone added in v1.6.0

func (n *MarginsNode) Clone() Node

func (*MarginsNode) IsAttached added in v1.6.0

func (n *MarginsNode) IsAttached() bool

func (*MarginsNode) MarshalJanet added in v1.6.0

func (n *MarginsNode) MarshalJanet() interface{}

func (*MarginsNode) Screen added in v1.6.0

func (n *MarginsNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*MarginsNode) SetChild added in v1.6.0

func (n *MarginsNode) SetChild(index int, node Node)

func (*MarginsNode) SetVisibleChild added in v1.6.0

func (n *MarginsNode) SetVisibleChild(index int, node Node)

func (*MarginsNode) Type added in v1.6.0

func (n *MarginsNode) Type() NodeType

func (*MarginsNode) UnmarshalJanet added in v1.6.0

func (n *MarginsNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*MarginsNode) Validate added in v1.6.0

func (n *MarginsNode) Validate() error

func (*MarginsNode) VisibleChildren added in v1.6.0

func (n *MarginsNode) VisibleChildren() (nodes []Node)

type Node added in v1.6.0

type Node interface {
	Type() NodeType
	IsAttached() bool
	Children() []Node
	SetChild(index int, node Node)
	VisibleChildren() []Node
	SetVisibleChild(index int, node Node)
	Clone() Node
	Validate() error
	MarshalJanet() interface{}
	UnmarshalJanet(*janet.Value) (Node, error)
	// Create a Screen from this Node.
	Screen(
		ctx context.Context,
		tree *tree.Tree,
		server *server.Server,
		params *params.Parameters,
		children []Reusable,
	) Reusable
}

func Attach

func Attach(node Node, id tree.NodeID) Node

Attach changes the currently attached tree node to the one specified by id.

func AttachFirst added in v0.6.0

func AttachFirst(node Node) Node

AttachFirst attaches to the first node it can find.

func Detach added in v0.6.0

func Detach(node Node) Node

Detach returns a copy of `node` with no attachment points.

func RemoveAttached added in v0.6.0

func RemoveAttached(node Node) Node

RemoveAttached removes the attached node by replacing its nearest parent that has more than one child with a parent with that child removed, or the other child if there are no other children.

type NodeChangeEvent added in v0.6.0

type NodeChangeEvent struct {
	Config Node
}

type NodeRemoveEvent added in v0.6.0

type NodeRemoveEvent struct{}

type NodeType

type NodeType int
const (
	NodeTypePane NodeType = iota
	NodeTypeSplit
	NodeTypeMargins
	NodeTypeBorders
	NodeTypeTabs
	NodeTypeBar
	NodeTypeColorMap
)

type Pane

type Pane struct {
	util.Lifetime
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

func NewPane

func NewPane(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
) *Pane

func (*Pane) Apply added in v1.6.0

func (p *Pane) Apply(node Node) (bool, error)

func (*Pane) Kill

func (p *Pane) Kill()

func (*Pane) Resize

func (p *Pane) Resize(size geom.Size) error

func (*Pane) Send

func (p *Pane) Send(msg mux.Msg)

func (*Pane) State

func (p *Pane) State() *tty.State

type PaneNode added in v1.6.0

type PaneNode struct {
	Attached     bool
	RemoveOnExit *bool
	ID           *tree.NodeID
}

func (*PaneNode) Children added in v1.6.0

func (p *PaneNode) Children() (nodes []Node)

func (*PaneNode) Clone added in v1.6.0

func (p *PaneNode) Clone() Node

func (*PaneNode) IsAttached added in v1.6.0

func (p *PaneNode) IsAttached() bool

func (*PaneNode) MarshalJanet added in v1.6.0

func (p *PaneNode) MarshalJanet() interface{}

func (*PaneNode) Screen added in v1.6.0

func (n *PaneNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*PaneNode) SetChild added in v1.6.0

func (p *PaneNode) SetChild(index int, node Node)

func (*PaneNode) SetVisibleChild added in v1.6.0

func (n *PaneNode) SetVisibleChild(index int, node Node)

func (*PaneNode) Type added in v1.6.0

func (p *PaneNode) Type() NodeType

func (*PaneNode) UnmarshalJanet added in v1.6.0

func (p *PaneNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*PaneNode) Validate added in v1.6.0

func (p *PaneNode) Validate() error

func (*PaneNode) VisibleChildren added in v1.6.0

func (n *PaneNode) VisibleChildren() (nodes []Node)

type Reusable added in v0.6.0

type Reusable interface {
	mux.Screen
	Apply(Node) (bool, error)
}

Reusable is used to describe a Screen that has a configuration that can change. Often a Screen does not actually need to be created from scratch when the corresponding layout node changes; it can just be updated. The reuse function checks whether the Screen can be updated to match the new configuration and updates it if possible.

type Split

type Split struct {
	*Computable
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

Split renders two screens side by side (or one above the other) at a fixed proportion of its full width or height (respectively.)

func NewSplit

func NewSplit(
	ctx context.Context,
	screenA, screenB mux.Screen,
	isVertical bool,
) *Split

func (*Split) Apply added in v1.6.0

func (s *Split) Apply(node Node) (bool, error)

func (*Split) Kill

func (s *Split) Kill()

func (*Split) Resize

func (s *Split) Resize(size geom.Size) error

func (*Split) Send

func (s *Split) Send(msg mux.Msg)

func (*Split) SetPercent

func (s *Split) SetPercent(percent int) error

func (*Split) State

func (s *Split) State() *tty.State

type SplitNode added in v1.6.0

type SplitNode struct {
	Vertical bool
	Percent  *int
	Cells    *int
	Border   *prop.Border
	BorderFg *prop.Color
	BorderBg *prop.Color
	A        Node
	B        Node
}

func (*SplitNode) Children added in v1.6.0

func (n *SplitNode) Children() (nodes []Node)

func (*SplitNode) Clone added in v1.6.0

func (n *SplitNode) Clone() Node

func (*SplitNode) IsAttached added in v1.6.0

func (n *SplitNode) IsAttached() bool

func (*SplitNode) MarshalJanet added in v1.6.0

func (n *SplitNode) MarshalJanet() interface{}

func (*SplitNode) Screen added in v1.6.0

func (n *SplitNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*SplitNode) SetChild added in v1.6.0

func (n *SplitNode) SetChild(index int, node Node)

func (*SplitNode) SetVisibleChild added in v1.6.0

func (n *SplitNode) SetVisibleChild(index int, node Node)

func (*SplitNode) Type added in v1.6.0

func (n *SplitNode) Type() NodeType

func (*SplitNode) UnmarshalJanet added in v1.6.0

func (n *SplitNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*SplitNode) Validate added in v1.6.0

func (n *SplitNode) Validate() error

func (*SplitNode) VisibleChildren added in v1.6.0

func (n *SplitNode) VisibleChildren() (nodes []Node)

type Static

type Static struct {
	util.Lifetime
	// contains filtered or unexported fields
}

func (*Static) Init

func (s *Static) Init() taro.Cmd

func (*Static) Update

func (s *Static) Update(msg tea.Msg) (taro.Model, tea.Cmd)

func (*Static) View

func (s *Static) View(state *tty.State)

type Tab added in v0.7.0

type Tab struct {
	Active bool
	Name   string
	Node   Node
}

type Tabs added in v1.6.0

type Tabs struct {
	*Computable
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

func NewTabs added in v1.6.0

func NewTabs(ctx context.Context, screen mux.Screen) *Tabs

func (*Tabs) Apply added in v1.6.0

func (t *Tabs) Apply(node Node) (bool, error)

func (*Tabs) Kill added in v1.6.0

func (t *Tabs) Kill()

func (*Tabs) Resize added in v1.6.0

func (t *Tabs) Resize(size geom.Size) error

func (*Tabs) Send added in v1.6.0

func (t *Tabs) Send(msg mux.Msg)

func (*Tabs) State added in v1.6.0

func (t *Tabs) State() *tty.State

type TabsNode added in v1.6.0

type TabsNode struct {
	ActiveFg, ActiveBg     *prop.Color
	InactiveFg, InactiveBg *prop.Color
	Bg                     *prop.Color
	Bottom                 bool
	Tabs                   []Tab
}

func (*TabsNode) Active added in v1.6.0

func (t *TabsNode) Active() (tab Tab)

Active returns the Tab config of the currently active tab.

func (*TabsNode) ActiveIndex added in v1.6.0

func (t *TabsNode) ActiveIndex() int

Active returns the index of the currently active tab.

func (*TabsNode) Children added in v1.6.0

func (n *TabsNode) Children() (nodes []Node)

func (*TabsNode) Clone added in v1.6.0

func (n *TabsNode) Clone() Node

func (*TabsNode) IsAttached added in v1.6.0

func (n *TabsNode) IsAttached() bool

func (*TabsNode) MarshalJanet added in v1.6.0

func (n *TabsNode) MarshalJanet() interface{}

func (*TabsNode) Screen added in v1.6.0

func (n *TabsNode) Screen(
	ctx context.Context,
	tree *tree.Tree,
	server *server.Server,
	params *params.Parameters,
	children []Reusable,
) Reusable

func (*TabsNode) SetChild added in v1.6.0

func (n *TabsNode) SetChild(index int, node Node)

func (*TabsNode) SetVisibleChild added in v1.6.0

func (n *TabsNode) SetVisibleChild(index int, node Node)

func (*TabsNode) Type added in v1.6.0

func (n *TabsNode) Type() NodeType

func (*TabsNode) UnmarshalJanet added in v1.6.0

func (n *TabsNode) UnmarshalJanet(value *janet.Value) (Node, error)

func (*TabsNode) Validate added in v1.6.0

func (n *TabsNode) Validate() error

func (*TabsNode) VisibleChildren added in v1.6.0

func (n *TabsNode) VisibleChildren() (nodes []Node)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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