bubbleboxer

package module
v0.0.0-...-8ed04ff Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 5 Imported by: 0

README ΒΆ

bubbleboxer πŸ₯Š - compose bubbles into boxes πŸ“¦

A way to compose multiple bubbles into one layout.

To layout the bubbles with bubbleboxer, one would construct a layout-tree 🌲. Each node holds a arbitrary amount of children as well as the orientation (horizontal/vertical) and the spacing of them. Each leaf is linked (via an address) to one Model which satisfies the bubbletea Model-interface. With this address one can access this Models and change them independently from the layout-tree.

 1β•­>list of something β”‚ some    0 β”‚ a                       V
  β”‚ ----------------- β”‚ status  1 β”‚  text                  / \
 2β”œ which you may     β”‚ infor-  2 β”‚   logo                /   \
  β”‚ edit as you wish  β”‚ mation  4 β”‚    even!             H    l5
 3β”œ or just use it    β”‚           β”‚                     / \
 4β”œ to display        β”‚ l2        β”‚ l3                 /   \
 5β”œ and scroll        │──────────────────────         l1    V
                      β”‚ Maybe here is a                    / \
                      β”‚ note written to each              /   \
                      β”‚ list entry, in a                 H    l4
                      β”‚ bubbles viewport.               / \
                      β”‚                                /   \
 l1                   β”‚ l4                            l2   l3
─────────────────────────────────────────────
 maybe a progressbar or a command input? 100% 

 l5

// TODO write about the need for embedding boxer into a other model and about nobordernodes beeing non recursive

LICENSE

MIT

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	// 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 = "─"
)

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type Layout ΒΆ

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

Layout is a way to render multiple `tea.Modelβ€œs in a specific layout. The models are kept separate from the layout tree so that changing a Model does not require traversing the tree.

func NewLayout ΒΆ

func NewLayout(root Node, logger *slog.Logger) *Layout

New returns a new Layout.

func (*Layout) AddLeaf ΒΆ

func (b *Layout) AddLeaf(address string, model tea.Model) (Node, error)

AddLeaf adds a new leaf node to the tree.

func (*Layout) EditLeaf ΒΆ

func (b *Layout) EditLeaf(address string, editFunc func(tea.Model) (tea.Model, error)) error

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 (*Layout) Init ΒΆ

func (b *Layout) Init() tea.Cmd

Init satisfies the tea.Model interface

func (*Layout) Update ΒΆ

func (b *Layout) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles WindowSizeMsg and ctrl+c

func (*Layout) UpdateSize ΒΆ

func (b *Layout) UpdateSize(size tea.WindowSizeMsg) error

UpdateSize set the width and height of all Node's

func (*Layout) View ΒΆ

func (b *Layout) View() string

View renders the contained tea.Model's according to the LayoutTree

type Node ΒΆ

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

Node is a node in a layout tree.

func NewNode ΒΆ

func NewNode(o Orientation, withBorder bool) *Node

NewNode returns a new Node.

func (*Node) AddChild ΒΆ

func (n *Node) AddChild(child Node)

AddChild adds a new child to this node.

func (*Node) GetAddress ΒΆ

func (n *Node) GetAddress() string

GetAddress returns the Address of the Node The address of a Node is only settable through CreateLeaf

func (*Node) GetHeight ΒΆ

func (n *Node) GetHeight() int

GetHeight returns the current with of this node

func (*Node) GetWidth ΒΆ

func (n *Node) GetWidth() int

GetWidth returns the current with of this node

func (*Node) IsLeaf ΒΆ

func (n *Node) IsLeaf() bool

IsLeaf returns if the node is a leaf.

func (*Node) SetSizeFunc ΒΆ

func (n *Node) SetSizeFunc(sf SizeFunc)

SetSizeFunc sets the function that defines the dynamic width or height of children nodes.

type NotFoundError ΒΆ

type NotFoundError error

NotFoundError convey that the address was not found.

type Orientation ΒΆ

type Orientation uint8

Orientation specifies the rendering orientation.

const (
	Horizontal Orientation = iota + 1
	Vertical
)

type SizeError ΒΆ

type SizeError error

SizeError conveys that for at leased one node or leaf in the Layout-tree there was not enough space left

type SizeFunc ΒΆ

type SizeFunc func(n Node, widthOrHeight int) []int

SizeFunc is the function that defines the dynamic width or height of nodes.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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