Documentation
¶
Index ¶
- Constants
- Variables
- func AddMargins(ctx context.Context, screen mux.Screen) mux.Screen
- func Attached(layout Layout) *tree.NodeID
- func NewStatic(ctx context.Context, shouldAnimate bool, message string) *taro.Program
- func ValidateTree(tree Node) error
- type Bar
- type BarNode
- func (n *BarNode) Children() (nodes []Node)
- func (n *BarNode) Clone() Node
- func (n *BarNode) IsAttached() bool
- func (n *BarNode) MarshalJanet() interface{}
- func (n *BarNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (n *BarNode) SetChild(index int, node Node)
- func (n *BarNode) SetVisibleChild(index int, node Node)
- func (n *BarNode) Type() NodeType
- func (n *BarNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (n *BarNode) Validate() error
- func (n *BarNode) VisibleChildren() (nodes []Node)
- type Borders
- type BordersNode
- func (n *BordersNode) Children() (nodes []Node)
- func (n *BordersNode) Clone() Node
- func (n *BordersNode) IsAttached() bool
- func (n *BordersNode) MarshalJanet() interface{}
- func (n *BordersNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (n *BordersNode) SetChild(index int, node Node)
- func (n *BordersNode) SetVisibleChild(index int, node Node)
- func (n *BordersNode) Type() NodeType
- func (n *BordersNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (n *BordersNode) Validate() error
- func (n *BordersNode) VisibleChildren() (nodes []Node)
- type ColorMap
- type ColorMapNode
- func (n *ColorMapNode) Children() (nodes []Node)
- func (n *ColorMapNode) Clone() Node
- func (n *ColorMapNode) IsAttached() bool
- func (n *ColorMapNode) MarshalJanet() interface{}
- func (n *ColorMapNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (n *ColorMapNode) SetChild(index int, node Node)
- func (n *ColorMapNode) SetVisibleChild(index int, node Node)
- func (n *ColorMapNode) Type() NodeType
- func (n *ColorMapNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (n *ColorMapNode) Validate() error
- func (n *ColorMapNode) VisibleChildren() (nodes []Node)
- type Computable
- type Context
- type Contextable
- type Layout
- type Log
- type Loggable
- type Margins
- type MarginsNode
- func (n *MarginsNode) Children() (nodes []Node)
- func (n *MarginsNode) Clone() Node
- func (n *MarginsNode) IsAttached() bool
- func (n *MarginsNode) MarshalJanet() interface{}
- func (n *MarginsNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (n *MarginsNode) SetChild(index int, node Node)
- func (n *MarginsNode) SetVisibleChild(index int, node Node)
- func (n *MarginsNode) Type() NodeType
- func (n *MarginsNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (n *MarginsNode) Validate() error
- func (n *MarginsNode) VisibleChildren() (nodes []Node)
- type Node
- type NodeChangeEvent
- type NodeRemoveEvent
- type NodeType
- type Pane
- type PaneNode
- func (p *PaneNode) Children() (nodes []Node)
- func (p *PaneNode) Clone() Node
- func (p *PaneNode) IsAttached() bool
- func (p *PaneNode) MarshalJanet() interface{}
- func (n *PaneNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (p *PaneNode) SetChild(index int, node Node)
- func (n *PaneNode) SetVisibleChild(index int, node Node)
- func (p *PaneNode) Type() NodeType
- func (p *PaneNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (p *PaneNode) Validate() error
- func (n *PaneNode) VisibleChildren() (nodes []Node)
- type Reusable
- type Split
- type SplitNode
- func (n *SplitNode) Children() (nodes []Node)
- func (n *SplitNode) Clone() Node
- func (n *SplitNode) IsAttached() bool
- func (n *SplitNode) MarshalJanet() interface{}
- func (n *SplitNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (n *SplitNode) SetChild(index int, node Node)
- func (n *SplitNode) SetVisibleChild(index int, node Node)
- func (n *SplitNode) Type() NodeType
- func (n *SplitNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (n *SplitNode) Validate() error
- func (n *SplitNode) VisibleChildren() (nodes []Node)
- type Static
- type Tab
- type Tabs
- type TabsNode
- func (t *TabsNode) Active() (tab Tab)
- func (t *TabsNode) ActiveIndex() int
- func (n *TabsNode) Children() (nodes []Node)
- func (n *TabsNode) Clone() Node
- func (n *TabsNode) IsAttached() bool
- func (n *TabsNode) MarshalJanet() interface{}
- func (n *TabsNode) Screen(ctx context.Context, tree *tree.Tree, server *server.Server, ...) Reusable
- func (n *TabsNode) SetChild(index int, node Node)
- func (n *TabsNode) SetVisibleChild(index int, node Node)
- func (n *TabsNode) Type() NodeType
- func (n *TabsNode) UnmarshalJanet(value *janet.Value) (Node, error)
- func (n *TabsNode) Validate() error
- func (n *TabsNode) VisibleChildren() (nodes []Node)
Constants ¶
const ( NodeKeywordPane = "pane" NodeKeywordBar = "bar" NodeKeywordBorders = "borders" NodeKeywordColorMap = "color-map" NodeKeywordMargins = "margins" NodeKeywordSplit = "split" NodeKeywordTabs = "tabs" )
Variables ¶
var ErrChildNil = errors.New("child nodes cannot be nil")
Functions ¶
func ValidateTree ¶ added in v0.6.0
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
}
type BarNode ¶ added in v1.6.0
func (*BarNode) IsAttached ¶ added in v1.6.0
func (*BarNode) MarshalJanet ¶ added in v1.6.0
func (n *BarNode) MarshalJanet() interface{}
func (*BarNode) SetVisibleChild ¶ added in v1.6.0
func (*BarNode) UnmarshalJanet ¶ added in v1.6.0
func (*BarNode) VisibleChildren ¶ added in v1.6.0
type Borders ¶ added in v0.5.0
type Borders struct {
*Computable
deadlock.RWMutex
*mux.UpdatePublisher
// contains filtered or unexported fields
}
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) 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
type ColorMapNode ¶ added in v1.6.0
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) 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
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) 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 (*Layout) MarshalJanet ¶
func (l *Layout) MarshalJanet() interface{}
type Loggable ¶ added in v0.8.0
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.
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) 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 AttachFirst ¶ added in v0.6.0
AttachFirst attaches to the first node it can find.
func RemoveAttached ¶ added in v0.6.0
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 Pane ¶
type Pane struct {
util.Lifetime
deadlock.RWMutex
*mux.UpdatePublisher
// contains filtered or unexported fields
}
type PaneNode ¶ added in v1.6.0
func (*PaneNode) IsAttached ¶ added in v1.6.0
func (*PaneNode) MarshalJanet ¶ added in v1.6.0
func (p *PaneNode) MarshalJanet() interface{}
func (*PaneNode) SetVisibleChild ¶ added in v1.6.0
func (*PaneNode) UnmarshalJanet ¶ added in v1.6.0
func (*PaneNode) VisibleChildren ¶ added in v1.6.0
type Reusable ¶ added in v0.6.0
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 (*Split) SetPercent ¶
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) IsAttached ¶ added in v1.6.0
func (*SplitNode) MarshalJanet ¶ added in v1.6.0
func (n *SplitNode) MarshalJanet() interface{}
func (*SplitNode) SetVisibleChild ¶ added in v1.6.0
func (*SplitNode) UnmarshalJanet ¶ added in v1.6.0
func (*SplitNode) VisibleChildren ¶ added in v1.6.0
type Tabs ¶ added in v1.6.0
type Tabs struct {
*Computable
deadlock.RWMutex
*mux.UpdatePublisher
// contains filtered or unexported fields
}
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
Active returns the Tab config of the currently active tab.
func (*TabsNode) ActiveIndex ¶ added in v1.6.0
Active returns the index of the currently active tab.
func (*TabsNode) IsAttached ¶ added in v1.6.0
func (*TabsNode) MarshalJanet ¶ added in v1.6.0
func (n *TabsNode) MarshalJanet() interface{}