layout

package
v0.0.0-...-db1c41b Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultWidth  = 80
	DefaultHeight = 25
)

DefaultWidth and DefaultHeight define the default dimensions for a layout.

Functions

This section is empty.

Types

type Layout

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

Layout represents a layout container for UI components.

func New

func New(opts ...Option) *Layout

New creates a new Layout with optional configurations.

func (*Layout) AddItem

func (l *Layout) AddItem(i Placeable) *Layout

AddItem adds a Placeable item to the layout.

func (*Layout) CanGrow

func (l *Layout) CanGrow() bool

func (*Layout) GetHeight

func (l *Layout) GetHeight() int

func (*Layout) GetWidth

func (l *Layout) GetWidth() int

func (*Layout) Items

func (l *Layout) Items() []Placeable

Items returns the items currently in the layout.

func (*Layout) SetHeight

func (l *Layout) SetHeight(height int)

SetHeight sets the height of the UI component.

func (*Layout) SetSize

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

SetSize resizes the layout and its items.

func (*Layout) SetWidth

func (l *Layout) SetWidth(width int)

SetWidth sets the width of the UI component.

func (*Layout) View

func (l *Layout) View() string

View returns the string representation of the layout, rendered with its container styles.

type Option

type Option func(*Layout)

Option is a type for functions that modify a Layout.

func WithItem

func WithItem(i Placeable) Option

WithItem adds a Placeable item to the layout.

func WithStyles

func WithStyles(styles *Styles) Option

WithStyles sets the styles for the layout container.

type Placeable

type Placeable interface {
	Sizeable

	// View returns the string representation of the component.
	View() string
}

Placeable is an interface for components that can be placed within a layout. It extends the Sizeable interface, indicating that placeable items must be resizable.

type Sizeable

type Sizeable interface {
	SetSize(width int, height int)
	SetWidth(width int)
	SetHeight(height int)
	GetWidth() int
	GetHeight() int
	CanGrow() bool
}

Sizeable is an interface for components that can be resized.

type Styles

type Styles struct {
	Container lipgloss.Style
}

Styles defines the styles for the layout container.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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