boxer

package
v0.0.0-...-e327841 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SPACE is used to fill up lines
	SPACE = " "
	//NEWLINE is the newline string
	NEWLINE = "\n" // TODO make windows compatible
)

Variables

This section is empty.

Functions

func NewNoChildrenError

func NewNoChildrenError() error

NewNoChildrenError returns a NoChildrenError

func NewNotABoxerError

func NewNotABoxerError(b Boxer) error

NewNotABoxerError returns a new NotABoxerError.

func NewProporationError

func NewProporationError(b Boxer) error

NewProporationError returns a uniform string for this error

func NewWrongSizeError

func NewWrongSizeError(isWidth, isHeight, shallWidth, shallHeight int) error

NewWrongSizeError returns a WrongSizeError if the is[Width/Height] is grater then the corresponding shall[Width/Height] other nil is returned.

func NewWrongTypeError

func NewWrongTypeError(got interface{}, want ...string) error

NewWrongTypeError returns a new WrongTypeError

Types

type BoxSize

type BoxSize struct {
	Box           Boxer
	Width, Height int
}

BoxSize holds a boxer value and the current size the box of this boxer should have

type Boxer

type Boxer interface {
	tea.Model
	InitAll() []tea.Cmd
	UpdateAll(tea.Msg) (Boxer, []tea.Cmd)
	Lines() ([]string, error)
}

Boxer is a interface to render multiple bubbles (within a tree) to the terminal screen.

type Leave

type Leave struct {
	Content     tea.Model
	Border      bool
	BorderStyle termenv.Style
	Width       int
	Heigth      int

	N, NW, W, SW, S, SO, O, NO string
	// contains filtered or unexported fields
}

Leave are the Boxers which holds the content Models

func NewLeave

func NewLeave() Leave

NewLeave returns a leave with border enabled and set

func (Leave) Init

func (l Leave) Init() tea.Cmd

Init is a proxy to the Content Init

func (Leave) InitAll

func (l Leave) InitAll() []tea.Cmd

InitAll calls the Init of the Content and returns the cmd embedded in a array to satisfiy the Boxer-interface

func (Leave) Lines

func (l Leave) Lines() ([]string, error)

Lines returns the fully rendert (maybe with borders) lines and fullfills the Boxer Interface. Error may be of type ProporationError.

func (Leave) Update

func (l Leave) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update takes care about the seting of the id of this leave and the changing of the WindowSizeMsg depending on the border and the focus style of the border.

func (Leave) UpdateAll

func (l Leave) UpdateAll(msg tea.Msg) (Boxer, []tea.Cmd)

UpdateAll calls the Update of the Content and returns the cmd embedded in a array to satisfiy the Boxer-interface

func (Leave) View

func (l Leave) View() string

View is used to satisfy the tea.Model interface and returnes either the joined lines or the Error string if err of lines is not nil.

type Model

type Model struct {
	Height, Width int
	Vertical      bool

	Sizer func(childLenght int, vertical bool, msg tea.WindowSizeMsg) ([]tea.WindowSizeMsg, error)
	// contains filtered or unexported fields
}

Model is a bubble to manage/bundle other bubbles into boxes on the screen

func (*Model) AddChildren

func (m *Model) AddChildren(cList ...BoxSize) error

AddChildren adds the given BoxerSize's as children If one provided BoxerSize.Box is 'nil' an NotABoxerError is returned and NO child is added!

func (Model) Init

func (m Model) Init() tea.Cmd

Init call the Init methods of the Children and returns the batched/collected returned Cmd's of them

func (Model) InitAll

func (m Model) InitAll() []tea.Cmd

InitAll call the Init methods of the Children and returns the batched/collected returned Cmd's of them

func (Model) Lines

func (m Model) Lines() ([]string, error)

Lines returns the joined lines of all the contained Boxers

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles the ratios between the different Boxers through the according fanning of the WindowSizeMsg's

func (Model) UpdateAll

func (m Model) UpdateAll(msg tea.Msg) (Boxer, []tea.Cmd)

UpdateAll handles the ratios between the different Boxers through the according fanning of the WindowSizeMsg's

func (Model) View

func (m Model) View() string

View is only used for the top (root) node since all other Models use the Lines function.

type MultipleErrors

type MultipleErrors []error

MultipleErrors is used to collect multiple errors from different sources

func (MultipleErrors) Error

func (me MultipleErrors) Error() string

type NoChildrenError

type NoChildrenError error

NoChildrenError is an error used to signal that a Boxer can not render itself when it has no Children to render.

type NodePos

type NodePos struct {
	Index       int
	Vertical    bool
	ChildAmount int
}

NodePos is used to hold the information about position of a child relative to its siblings within this layout-tree.

type NotABoxerError

type NotABoxerError error

NotABoxerError is used when something should satisfy the Boxer interface but does not (like 'nil').

type PathMsg

type PathMsg struct {
	Path []NodePos
	Msg  tea.Msg
}

PathMsg is used to transport the information about the position and the Msg to every leave-content.

type ProportionError

type ProportionError error

ProportionError is for signaling that the string return by the View or Lines function has wrong proportions(width/height)

type WrongSizeError

type WrongSizeError error

WrongSizeError shall be used to signal that a string exceeds the necessary Width or hight.

type WrongTypeError

type WrongTypeError error

WrongTypeError is used to show when the type provided does not match any of the acceptable types.

Jump to

Keyboard shortcuts

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