linearcontainer

package
v0.0.0-...-997d7fb Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HORIZONTAL int = iota
	VERTICAL
	STACK
)
View Source
const (
	FOCUS_FORWARD  = "tab"
	FOCUS_BACKWARD = "shift+tab"
)

Variables

View Source
var BORDER_STYLE = lipgloss.NewStyle().BorderStyle(
	lipgloss.RoundedBorder(),
).BorderForeground(lipgloss.Color("#AAAAAA"))
View Source
var FOCUSED_BORDER_STYLE = lipgloss.NewStyle().BorderStyle(
	lipgloss.RoundedBorder(),
).BorderForeground(lipgloss.Color("69"))
View Source
var NO_BORDER_STYLE = lipgloss.NewStyle().BorderStyle(
	lipgloss.Border{
		Top:          "",
		Bottom:       "",
		Left:         "",
		Right:        "",
		TopLeft:      "",
		TopRight:     "",
		BottomLeft:   "",
		BottomRight:  "",
		MiddleLeft:   "",
		MiddleRight:  "",
		Middle:       "",
		MiddleTop:    "",
		MiddleBottom: "",
	},
)

Functions

func NewLinearFocusHandler

func NewLinearFocusHandler() linearFocusHandler

Types

type ChildComponent

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

func ChildComponentFromModel

func ChildComponentFromModel(model tea.Model) *ChildComponent

func GetFocusableComponents

func GetFocusableComponents(components []*ChildComponent) (output []*ChildComponent)

Returns a slice of the components' (including their child components, if they have any) that are capable of receiving focus

func (ChildComponent) GetBorderStyle

func (m ChildComponent) GetBorderStyle() lipgloss.Style

func (ChildComponent) GetFocusBorderStyle

func (m ChildComponent) GetFocusBorderStyle() lipgloss.Style

func (ChildComponent) GetMaximumHeight

func (m ChildComponent) GetMaximumHeight() int

func (ChildComponent) GetMaximumWidth

func (m ChildComponent) GetMaximumWidth() int

func (ChildComponent) GetMinimumHeight

func (m ChildComponent) GetMinimumHeight() int

func (ChildComponent) GetMinimumWidth

func (m ChildComponent) GetMinimumWidth() int

func (ChildComponent) GetModel

func (m ChildComponent) GetModel() tea.Model

func (ChildComponent) GetPriority

func (m ChildComponent) GetPriority() int

func (ChildComponent) IsFocusable

func (m ChildComponent) IsFocusable() bool

func (*ChildComponent) SetBorderStyle

func (m *ChildComponent) SetBorderStyle(style lipgloss.Style) *ChildComponent

func (*ChildComponent) SetFocusBorderStyle

func (m *ChildComponent) SetFocusBorderStyle(style lipgloss.Style) *ChildComponent

func (*ChildComponent) SetFocusable

func (m *ChildComponent) SetFocusable(focusable bool) *ChildComponent

func (*ChildComponent) SetMaximumHeight

func (m *ChildComponent) SetMaximumHeight(height int) *ChildComponent

func (*ChildComponent) SetMaximumWidth

func (m *ChildComponent) SetMaximumWidth(width int) *ChildComponent

func (*ChildComponent) SetMinimumHeight

func (m *ChildComponent) SetMinimumHeight(height int) *ChildComponent

func (*ChildComponent) SetMinimumWidth

func (m *ChildComponent) SetMinimumWidth(width int) *ChildComponent

func (*ChildComponent) SetModel

func (m *ChildComponent) SetModel(model tea.Model) *ChildComponent

func (*ChildComponent) SetPriority

func (m *ChildComponent) SetPriority(priority int) *ChildComponent

func (*ChildComponent) Update

func (m *ChildComponent) Update(message tea.Msg) (tea.Model, tea.Cmd)

This function calls ChildComponent.Model.Update function and returns the result. If the given message is a tea.WindowSizeMsg, it will call the ChildComponent's setSize function to record the change int the model's size

type Container

type Container interface {
	GetChildren() []*ChildComponent
}

type FocusHandler

type FocusHandler interface {
	/*
		Checks if a given string represents a key combination
		that the focus handler uses to change focus
	*/
	IsFocusKey(string) bool
	/*
		Updates which child component has focus based on the
		given key combination
	*/
	HandleFocusKey(string) FocusHandler
	/*
		Returns the component that currently has focus
	*/
	GetFocusedComponent() *ChildComponent
	/*
		Returns the focus handler with a given container as its
		subject. The subject being the UI element whose focus
		the focus manager is managing
	*/
	SetSubjectContainer(Container) FocusHandler
	/*
		Returns the focus handler with a given ChildComponent pointer
		as its currently focused component
	*/
	SetFocusedComponent(*ChildComponent) FocusHandler
	/*
		Returns the focus handler after having updated its focused child
	*/
	UpdateFocusedChild() FocusHandler
}

FocusHandler keeps track of which child component has focus and determines how focus behaves

type LinearContainerModel

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

func NewLinearContainer

func NewLinearContainer() *LinearContainerModel

func NewLinearContainerFromComponents

func NewLinearContainerFromComponents(components []*ChildComponent) *LinearContainerModel

func (LinearContainerModel) GetChild

func (m LinearContainerModel) GetChild(idx int) *ChildComponent

func (LinearContainerModel) GetChildStyle

func (m LinearContainerModel) GetChildStyle(child *ChildComponent) lipgloss.Style

Returns the current border style of the given child component

func (LinearContainerModel) GetChildStyleByIndex

func (m LinearContainerModel) GetChildStyleByIndex(childIdx int) lipgloss.Style

func (LinearContainerModel) GetChildren

func (m LinearContainerModel) GetChildren() []*ChildComponent

func (LinearContainerModel) GetFocusHandler

func (m LinearContainerModel) GetFocusHandler() FocusHandler

func (LinearContainerModel) GetSizeAlongMainAxis

func (m LinearContainerModel) GetSizeAlongMainAxis(msg tea.WindowSizeMsg) int

func (LinearContainerModel) Init

func (m LinearContainerModel) Init() tea.Cmd

func (LinearContainerModel) IsHorizontal

func (m LinearContainerModel) IsHorizontal() bool

func (LinearContainerModel) IsVertical

func (m LinearContainerModel) IsVertical() bool

func (*LinearContainerModel) SetDirection

func (m *LinearContainerModel) SetDirection(direction int) *LinearContainerModel

func (*LinearContainerModel) SetFocusHandler

func (m *LinearContainerModel) SetFocusHandler(handler FocusHandler)

func (LinearContainerModel) Update

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

func (LinearContainerModel) View

func (m LinearContainerModel) View() (s string)

Jump to

Keyboard shortcuts

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