Documentation
¶
Index ¶
- func IsSpace(child any) bool
- func RenderString(width, height int, child any) string
- func RenderView(view *tea.View, width, height int, child any)
- type Cell
- func (c *Cell) CalculateSize(totalSize int, usedPercent float64, zeroPercentCount int) int
- func (c *Cell) CalculatedPercent(calculatedSize int, totalSize int) float64
- func (c *Cell) HidePercent(percent float64) *Cell
- func (c *Cell) HideSize(hideSize int) *Cell
- func (c *Cell) Percent(percent float64) *Cell
- func (c *Cell) ShouldHide(calculatedSize int, calculatedPerc float64) bool
- func (c *Cell) Size(size int) *Cell
- type LayerMouseMsg
- type Layout
- func BottomPadding(amount int, child any) Layout
- func Center(child any) Layout
- func Columns(cells ...*Cell) Layout
- func Frame(style lipgloss.Style, child any) Layout
- func Horizontal(children ...any) Layout
- func LeftPadding(amount int, child any) Layout
- func RightPadding(amount int, child any) Layout
- func Rows(cells ...*Cell) Layout
- func Space() Layout
- func Stack(children ...any) Layout
- func TopPadding(amount int, child any) Layout
- func Vertical(children ...any) Layout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderString ¶
RenderString renders the provided child/layout/etc into a string.
func RenderView ¶
RenderView renders the provided child/layout/etc onto an existing tea.View, including applying a callback to the view to handle mouse events, which will send a downstream LayerMouseMsg to the model.
Types ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell represents a cell in a Rows or Columns layout with percentage-based or exact sizing.
func NewCell ¶
NewCell creates a new Cell with the specified percentage and child. The percentage is converted from int to float64 for convenience.
func (*Cell) CalculateSize ¶
CalculateSize calculates the actual size this cell should occupy based on: - totalSize: the total available size (width for columns, height for rows) - usedPercent: the sum of percentages from all cells with Percent > 0 - zeroPercentCount: the number of cells with Percent == 0
If this cell has Percent > 0, it uses that percentage. If this cell has Percent == 0, it gets an equal share of remaining space.
func (*Cell) CalculatedPercent ¶
CalculatedPercent calculates the actual percentage this cell occupies after size calculation.
func (*Cell) HidePercent ¶
HidePercent sets the minimum calculated percentage threshold. If the calculated percentage is less than this value, the cell will be hidden.
func (*Cell) HideSize ¶
HideSize sets the minimum calculated size threshold. If the calculated width or height is less than this value, the cell will be hidden.
func (*Cell) Percent ¶
Percent sets the percentage of available space this cell should occupy (0-1). If 0, the cell will receive an equal share of remaining space after percentage-based and exact-size cells. Setting a percentage unsets any exact size.
func (*Cell) ShouldHide ¶
ShouldHide determines if this cell should be hidden based on HidePerc and HideSize thresholds. It checks both the calculated percentage and calculated size against the thresholds.
type LayerMouseMsg ¶
type Layout ¶
type Layout interface {
// Render renders the layout into a [lipgloss.Layer]. The child can use the provided
// availableWidth and availableHeight to calculate the size of the layout it can
// consume.
Render(availableWidth, availableHeight int) *lipgloss.Layer
}
Layout is a generic layout interface. All layouts must implement this interface.
func BottomPadding ¶
BottomPadding creates a new layout that pads the provided child with the given amount of space on the bottom.
func Columns ¶
Columns creates a new horizontal layout with the provided cells, where each cell is sized based on its percentage of available width. Cells are arranged left to right.
func Frame ¶
Frame creates a new layout which contains the provided child within it, with the free space left over after the style has been applied. Use this for wrapping children in borders, padding, etc.
func Horizontal ¶
Horizontal creates a new horizontal layout with the provided children.
func LeftPadding ¶
LeftPadding creates a new layout that pads the provided child with the given amount of space on the left.
func RightPadding ¶
RightPadding creates a new layout that pads the provided child with the given amount of space on the right.
func Rows ¶
Rows creates a new vertical layout with the provided cells, where each cell is sized based on its percentage of available height. Cells are arranged top to bottom.
func Space ¶
func Space() Layout
Space creates a new space layout, which will consume all free space that is available.
func Stack ¶
Stack creates a new stacked layout with the provided children, where each child (left to right) is stacked on top of the previous one, with an increasing Z-index.
func TopPadding ¶
TopPadding creates a new layout that pads the provided child with the given amount of space on the top.