layout

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package layout provides centralized layout management for the Kafui UI. It handles responsive breakpoints, component sizing, and layout calculations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Breakpoints

type Breakpoints struct {
	// CompactWidth triggers compact mode when terminal width is below this value
	CompactWidth int

	// MinimalWidth triggers minimal mode when terminal width is below this value
	MinimalWidth int

	// CompactHeight triggers compact mode when terminal height is below this value
	CompactHeight int

	// MinimalHeight triggers minimal mode when terminal height is below this value
	MinimalHeight int
}

Breakpoints defines responsive breakpoints for different screen sizes

func DefaultBreakpoints

func DefaultBreakpoints() Breakpoints

DefaultBreakpoints returns the default responsive breakpoints

type Layout

type Layout struct {
	// Total dimensions
	Width  int
	Height int

	// Component rectangles
	Header    Rectangle
	Sidebar   Rectangle
	Main      Rectangle
	Footer    Rectangle
	Search    Rectangle
	StatusBar Rectangle

	// Layout mode
	Mode LayoutMode

	// Responsive state
	CompactMode bool
	SmallScreen bool
}

Layout represents the complete layout configuration for the application

func CalculateLayout

func CalculateLayout(width, height int, config *LayoutConfig) *Layout

CalculateLayout computes the complete layout based on available space and configuration

func (*Layout) GetAvailableHeight

func (l *Layout) GetAvailableHeight() int

GetAvailableHeight returns the available height for content in the main area

func (*Layout) GetAvailableWidth

func (l *Layout) GetAvailableWidth() int

GetAvailableWidth returns the available width for content in the main area

func (*Layout) GetContentArea

func (l *Layout) GetContentArea(padding int) Rectangle

GetContentArea returns the available content area (main area minus padding)

func (*Layout) IsFooterVisible

func (l *Layout) IsFooterVisible() bool

IsFooterVisible returns true if the footer should be visible

func (*Layout) IsHeaderVisible

func (l *Layout) IsHeaderVisible() bool

IsHeaderVisible returns true if the header should be visible

func (*Layout) IsSidebarVisible

func (l *Layout) IsSidebarVisible() bool

IsSidebarVisible returns true if the sidebar should be visible

type LayoutCalculator

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

LayoutCalculator provides methods for calculating layout-related values

func NewLayoutCalculator

func NewLayoutCalculator(config *LayoutConfig) *LayoutCalculator

NewLayoutCalculator creates a new layout calculator with the given configuration

func (*LayoutCalculator) CalculateTableHeight

func (lc *LayoutCalculator) CalculateTableHeight(layout *Layout, reservedLines int) int

CalculateTableHeight calculates the appropriate table height for the main content area

func (*LayoutCalculator) CalculateTableWidth

func (lc *LayoutCalculator) CalculateTableWidth(layout *Layout, reservedColumns int) int

CalculateTableWidth calculates the appropriate table width for the main content area

func (*LayoutCalculator) GetResponsiveBreakpoint

func (lc *LayoutCalculator) GetResponsiveBreakpoint(layout *Layout) string

GetResponsiveBreakpoint returns the breakpoint that matches the current layout mode

func (*LayoutCalculator) ShouldShowComponent

func (lc *LayoutCalculator) ShouldShowComponent(layout *Layout, component string) bool

ShouldShowComponent determines if a component should be shown based on layout mode

type LayoutConfig

type LayoutConfig struct {
	// ShowSidebar indicates whether sidebar should be shown
	ShowSidebar bool

	// ShowHeader indicates whether header should be shown
	ShowHeader bool

	// ShowFooter indicates whether footer should be shown
	ShowFooter bool

	// ShowStatusBar indicates whether status bar should be shown
	ShowStatusBar bool

	// SidebarWidth is the fixed width of the sidebar when visible
	SidebarWidth int

	// HeaderHeight is the fixed height of the header when visible
	HeaderHeight int

	// FooterHeight is the fixed height of the footer when visible
	FooterHeight int

	// SearchHeight is the height of the search bar when active
	SearchHeight int

	// StatusBarHeight is the height of the status bar
	StatusBarHeight int

	// Breakpoints for responsive design
	Breakpoints Breakpoints
}

LayoutConfig contains configuration for layout calculations

func DefaultLayoutConfig

func DefaultLayoutConfig() *LayoutConfig

DefaultLayoutConfig returns the default layout configuration

type LayoutMode

type LayoutMode uint8

LayoutMode represents the current layout mode

const (
	// LayoutNormal is the standard layout with all components visible
	LayoutNormal LayoutMode = iota

	// LayoutCompact is a space-optimized layout for small terminals
	LayoutCompact

	// LayoutMinimal is an ultra-minimal layout for very small terminals
	LayoutMinimal
)

type Rectangle

type Rectangle struct {
	X      int
	Y      int
	Width  int
	Height int
}

Rectangle represents a rectangular area in the layout

Jump to

Keyboard shortcuts

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