layout

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layout

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

func NewLayout

func NewLayout(rows ...Row) *Layout

func (*Layout) GetActive

func (l *Layout) GetActive() *PositionalElement

func (*Layout) Init

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

func (*Layout) NavigateDown

func (l *Layout) NavigateDown()

func (*Layout) NavigateLeft

func (l *Layout) NavigateLeft()

func (*Layout) NavigateRight

func (l *Layout) NavigateRight()

func (*Layout) NavigateUp

func (l *Layout) NavigateUp()

func (*Layout) Resize

func (l *Layout) Resize(width, height int)

func (*Layout) SetActive

func (l *Layout) SetActive(x, y int)

Set active element

func (*Layout) UpdateActive

func (l *Layout) UpdateActive(msg tea.Msg) tea.Cmd

func (*Layout) UpdateAll

func (l *Layout) UpdateAll(msg tea.Msg) tea.Cmd

func (*Layout) View

func (l *Layout) View() string

type LayoutModel

type LayoutModel interface {
	Init() tea.Cmd
	Update(tea.Msg) (tea.Model, tea.Cmd)
	View() string

	IsActive() bool
	SetActive() LayoutModel
	UnsetActive() LayoutModel

	OnAvailWidthChange(width int) LayoutModel
}

Extends the normal tea.Model

type Position

type Position int
const (
	Left   Position = iota
	Center Position = iota
	Right  Position = iota
)

type PositionalElement

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

func Empty

func Empty() PositionalElement

Empty element. Fill empty space in Layout.

func Fill

func Fill(model *LayoutModel, position Position, width float64) PositionalElement

Fill width dynamically. position: left | center | right width: fraction of how much space to take, e.g. 0.5 for 50%

func FillAuto

func FillAuto(model *LayoutModel, position Position) PositionalElement

Fill width dynamically. Split space equally among fill-auto elements position: left | center | right

func Fixed

func Fixed(model *LayoutModel, position Position, width int) PositionalElement

Fixed width.

func (*PositionalElement) IsSelectable

func (p *PositionalElement) IsSelectable() bool

func (PositionalElement) NotSelectable

func (p PositionalElement) NotSelectable() PositionalElement

Element cannot be selected by user

type Row

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

func NewRow

func NewRow(elements ...PositionalElement) Row

func (*Row) All

func (r *Row) All() iter.Seq[PositionalElement]

func (*Row) GetLength

func (r *Row) GetLength() int

func (*Row) NotNil

func (r *Row) NotNil() iter.Seq[PositionalElement]

func (*Row) View

func (r *Row) View() string

Jump to

Keyboard shortcuts

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