Documentation
¶
Index ¶
- Variables
- type Boxer
- func (b *Boxer) CreateLeaf(address string, model tea.Model) (Node, error)
- func (b *Boxer) EditLeaf(address string, editFunc func(tea.Model) (tea.Model, error)) error
- func (b Boxer) Init() tea.Cmd
- func (b Boxer) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (b *Boxer) UpdateSize(size tea.WindowSizeMsg) error
- func (b Boxer) View() string
- type Node
- type NotFoundError
- type SizeError
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 ¶
This section is empty.
Types ¶
type Boxer ¶
type Boxer struct {
// 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
}
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.
func (*Boxer) EditLeaf ¶ added in v0.2.0
EditLeaf is a saver way to interact with the Leafs, since it can not be forgotten to save back the Model after changing. If the editFunc returns an error the Model is not saved.
func (*Boxer) UpdateSize ¶
func (b *Boxer) UpdateSize(size tea.WindowSizeMsg) error
UpdateSize set the width and height of all Node's
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. Be aware that this is not recursiv, so all contained children may still have borderes. 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
type NotFoundError ¶ added in v0.2.0
type NotFoundError error
NotFoundError convey that the address was not found.