Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NEWLINE is used to separat the lines NEWLINE = "\n" // SPACE is used to fill up the lines, make sure it is only one column wide and a single character SPACE = " " // HorizontalSeparator is used to make a visible border between the horizontal arranged children // in the layout-tree, make sure it is only one column wide and a single character HorizontalSeparator = "│" // VerticalSeparator is used to make a visible border between the vertical arranged children // in the layout-tree, make sure it is only one column wide and a single character VerticalSeparator = "─" )
Functions ¶
func SetFocusMsg ¶
Types ¶
type Boxer ¶
type Boxer struct {
// HandleMsg controls if updates are propagated to the currently focused bubble.
// And if focus message should be sent.
HandleMsg bool
// LayoutTree holds the root node and thus the hole LayoutTree
// Change it as you like as long as every node without children was
// created with CreateLeaf (to make sure that every leave has a corresponding ModelMap entry)
// After deleting a Leaf delete the corresponding entry from ModelMap if you care about memory-leaks
LayoutTree Node
// ModelMap is a mapping between the Address of a Leaf and the according Model.
// A valid entry can only be created with CreateLeaf,
// because entries without a corresponding Node in the LayoutTree are meaningless.
ModelMap map[string]tea.Model
// contains filtered or unexported fields
}
Boxer is a way to render multiple tea.Model's in a specific layout according to a LayoutTree. The Model's are kept separate from the LayoutTree so that changing a Model does not require traversing the LayoutTree.
func (*Boxer) CreateLeaf ¶
CreateLeaf is the only way to create a Node which is treated as a Leaf in the layout-tree. CreateLeaf panics when either address is the empty string or the model is nil.
func (Boxer) CurrentlyFocused ¶
Returns the ID of the currently focused bubble
func (*Boxer) UpdateSize ¶
func (b *Boxer) UpdateSize(size tea.WindowSizeMsg) tea.Cmd
UpdateSize set the width and height of all Node's returns SizeErrorMsg if the area (width*height) is less or equal to zero for any node or leaf
panics if
a leaf has children
a leaf has a address without a model in the ModelMap (because it was deleted)
a Node (not a leaf) has no Children
the SizeFunc returned a slice with different length compared to the size of the Children
the combined space returned by the SizeFunc is greater than the provided size
type FocusError ¶
type FocusError setFocus
FocusError conveys that a SetFocusMsg had an incorrect ID given to it
type GainedFocus ¶
type GainedFocus struct{}
type Node ¶
type Node struct {
Children []Node
// VerticalStacked specifies the orientation of the Children to each other
VerticalStacked bool
// SizeFunc specifies the width or height (depending on the orientation) provided to each child.
// Here by should the sum of the returned int's be the same as the argument 'widthOrHeight'.
// The length of the returned slice should be the same as the amount of children of the node argument.
SizeFunc func(node Node, widthOrHeight int) []int
// contains filtered or unexported fields
}
Node is a node in a layout tree or when created with CreateLeaf its a valid leave of the LayoutTree
func CreateNoBorderNode ¶
func CreateNoBorderNode() Node
CreateNoBorderNode is a constructor for a Node which does not draw a Border around its children. The Border attribute is private, because the changing of the attribute has to be accompanied with a change of size of all its descendants and is not trivial to facilitate in a save manner.
func (*Node) GetAddress ¶
GetAddress returns the Address of the Node The address of a Node is only settable through CreateLeaf