Documentation
¶
Overview ¶
Package layout provides responsive layout calculations for the OpenCode TUI. This file contains box model definitions and styling helpers.
The Box model represents a rectangular region with styling, supporting:
- Dimension specification (width, height)
- Lipgloss styling (background, foreground, borders)
- Content rendering
- Functional options for configuration
Package layout provides layout components for the OpenCode TUI, including containers, splits, overlays, and other UI layout utilities.
Package layout provides responsive layout calculations for the OpenCode TUI. It offers utilities for dimension calculation, split panes, and container wrappers that automatically adapt to terminal window size changes.
The package provides:
- LayoutEngine: Responsive dimension calculator for all UI sections
- SplitPaneLayout: Horizontal/vertical split container layout
- Container: Wrapper with padding and borders
- Sizeable, Bindings, Focusable: Core interfaces for tea.Model components
Package layout provides responsive layout calculations for the OpenCode TUI.
Package layout provides responsive layout calculations for the OpenCode TUI.
Package layout provides responsive layout calculations for the OpenCode TUI. It offers utilities for dimension calculation, split panes, and container wrappers that automatically adapt to terminal window size changes.
The package provides:
- LayoutEngine: Responsive dimension calculator for all UI sections
- SplitPaneLayout: Horizontal/vertical split container layout
- Container: Wrapper with padding and borders
- Sizeable, Bindings, Focusable: Core interfaces for tea.Model components
Package layout provides responsive layout calculations for the OpenCode TUI. It offers a LayoutManager for calculating 3-pane layouts with header, sidebar, and footer sections, along with component implementations for each pane.
Package layout provides responsive layout calculations for the OpenCode TUI. This file contains overlay placement functions for rendering content on top of backgrounds.
The overlay functionality is borrowed and modified from the lipgloss library (https://github.com/charmbracelet/lipgloss/pull/102) to support:
- Placing foreground content over background content
- Optional shadow rendering
- Precise x, y coordinate placement
Package layout provides responsive layout calculations for the OpenCode TUI. This file contains helper functions for rendering with the layout engine.
Package layout provides responsive layout calculations for the OpenCode TUI.
Index ¶
- Constants
- func AdaptiveHeight(content string, padding int) int
- func AdaptiveWidth(content string, padding int) int
- func Clamp(value, min, max int) int
- func FlexJoinHorizontal(align lipgloss.Position, boxes ...*Box) string
- func FlexJoinVertical(align lipgloss.Position, boxes ...*Box) string
- func GetBorderColor(pane PaneType, focused PaneType) lipgloss.AdaptiveColor
- func GetBorderStyle(pane PaneType, focused PaneType) lipgloss.Border
- func GetPaneStyle(pane PaneType, focused PaneType) lipgloss.Style
- func Height(s string) int
- func JoinHorizontal(blocks ...string) string
- func JoinVertical(blocks ...string) string
- func KeyMapToSlice(t any) (bindings []key.Binding)
- func Max(a, b int) int
- func MeasureContent(content string) (width, height int)
- func Min(a, b int) int
- func PixelsToCells(pixelWidth, pixelHeight int) (cellsWidth, cellsHeight int)
- func PlaceContent(box *Box, content string, hAlign, vAlign lipgloss.Position) string
- func PlaceOverlay(x, y int, fg, bg string, shadow bool, opts ...WhitespaceOption) string
- func ResponsiveValue(terminalSize, threshold int, value, fallback int) int
- func ResponsiveWidth(terminalWidth int, thresholds []int, values []int) int
- func Width(s string) int
- type Bindings
- type Box
- type BoxOption
- func WithBoxBackground(color lipgloss.Color) BoxOption
- func WithBoxBorder(border lipgloss.Border) BoxOption
- func WithBoxBorderForeground(color lipgloss.Color) BoxOption
- func WithBoxContent(content string) BoxOption
- func WithBoxForeground(color lipgloss.Color) BoxOption
- func WithBoxMargin(margin int) BoxOption
- func WithBoxPadding(padding int) BoxOption
- func WithBoxPaddingXY(horizontal, vertical int) BoxOption
- func WithBoxStyle(style lipgloss.Style) BoxOption
- type Container
- type ContainerOption
- func WithBorder(top, right, bottom, left bool) ContainerOption
- func WithBorderAll() ContainerOption
- func WithBorderHorizontal() ContainerOption
- func WithBorderStyle(style lipgloss.Border) ContainerOption
- func WithBorderVertical() ContainerOption
- func WithDoubleBorder() ContainerOption
- func WithPadding(top, right, bottom, left int) ContainerOption
- func WithPaddingAll(padding int) ContainerOption
- func WithPaddingHorizontal(padding int) ContainerOption
- func WithPaddingVertical(padding int) ContainerOption
- func WithRoundedBorder() ContainerOption
- func WithThickBorder() ContainerOption
- type Dimensions
- type Focusable
- type Footer
- func (f *Footer) GetDimensions() Rect
- func (f *Footer) Render(content string) string
- func (f *Footer) RenderDefault() string
- func (f *Footer) SetDimensions(dims Rect) *Footer
- func (f *Footer) SetFocused(focused bool) *Footer
- func (f *Footer) SetHint(hint string) *Footer
- func (f *Footer) SetStatus(status string) *Footer
- type Header
- func (h *Header) GetDimensions() Rect
- func (h *Header) Render(content string) string
- func (h *Header) RenderDefault() string
- func (h *Header) SetDimensions(dims Rect) *Header
- func (h *Header) SetFocused(focused bool) *Header
- func (h *Header) SetMode(mode string) *Header
- func (h *Header) SetTitle(title string) *Header
- type LayoutConfig
- type LayoutEngine
- func (e *LayoutEngine) Calculate(width, height int) Dimensions
- func (e *LayoutEngine) CalculateFromPixels(pixelWidth, pixelHeight int) Dimensions
- func (e *LayoutEngine) GetChatStyle() lipgloss.Style
- func (e *LayoutEngine) GetDimensions() Dimensions
- func (e *LayoutEngine) GetInputStyle() lipgloss.Style
- func (e *LayoutEngine) GetPixelDimensions() (int, int)
- func (e *LayoutEngine) GetSidebarStyle() lipgloss.Style
- func (e *LayoutEngine) GetTerminalDimensions() (int, int)
- func (e *LayoutEngine) GetWorkspaceStyle() lipgloss.Style
- func (e *LayoutEngine) WithConfig(config LayoutConfig) *LayoutEngine
- type LayoutManager
- func (m *LayoutManager) Calculate(width, height int)
- func (m *LayoutManager) GetFocusedPane() PaneType
- func (m *LayoutManager) GetFooterDimensions() PaneDimensions
- func (m *LayoutManager) GetHeaderDimensions() PaneDimensions
- func (m *LayoutManager) GetHeight() int
- func (m *LayoutManager) GetMainDimensions() PaneDimensions
- func (m *LayoutManager) GetSidebarDimensions() PaneDimensions
- func (m *LayoutManager) GetWidth() int
- func (m *LayoutManager) Render(headerContent, sidebarContent, mainContent, footerContent string) string
- func (m *LayoutManager) SetFocusedPane(pane PaneType)
- type MainLayout
- type PaneDimensions
- type PaneType
- type Rect
- type Renderer
- func (r *Renderer) RenderBottomBar(content string) string
- func (r *Renderer) RenderChatArea(content string) string
- func (r *Renderer) RenderChatMessage(role, content, timestamp string) string
- func (r *Renderer) RenderDiffBlock(lines []string) string
- func (r *Renderer) RenderDiffLine(lineType, content string) string
- func (r *Renderer) RenderInputArea(content string) string
- func (r *Renderer) RenderMainLayout(...) string
- func (r *Renderer) RenderSidebar(content string) string
- func (r *Renderer) RenderStatusBar(segments []string, activeIndex int) string
- func (r *Renderer) RenderStatusSegment(text string, isActive bool) string
- func (r *Renderer) RenderToolBadge(toolName string) string
- func (r *Renderer) RenderTopBar(content string) string
- func (r *Renderer) RenderWarningBar(content string) string
- type Sidebar
- func (s *Sidebar) GetDimensions() PaneDimensions
- func (s *Sidebar) GetSelected() int
- func (s *Sidebar) Render(content string) string
- func (s *Sidebar) RenderDefault() string
- func (s *Sidebar) RenderItem(index int, itemContent string, isSelected bool) string
- func (s *Sidebar) SetDimensions(width, height int) *Sidebar
- func (s *Sidebar) SetFocused(focused bool) *Sidebar
- func (s *Sidebar) SetItems(items []string) *Sidebar
- func (s *Sidebar) SetSelected(index int) *Sidebar
- func (s *Sidebar) SetTitle(title string) *Sidebar
- type Sizeable
- type SplitPaneLayout
- type SplitPaneOption
- type WhitespaceOption
Constants ¶
const ( // CharacterCellWidth is the typical width of a character cell in pixels. // This is used to convert pixel dimensions to cell dimensions. CharacterCellWidth = 8 // CharacterCellHeight is the typical height of a character cell in pixels. // This is used to convert pixel dimensions to cell dimensions. CharacterCellHeight = 16 // DefaultTopBarHeight is the default height of the top bar. DefaultTopBarHeight = 1 // DefaultWarningBarHeight is the default height of the warning bar. DefaultWarningBarHeight = 1 // DefaultBottomBarHeight is the default height of the bottom bar. DefaultBottomBarHeight = 1 // DefaultSidebarMinWidth is the minimum width of the sidebar. DefaultSidebarMinWidth = 20 // DefaultSidebarMaxWidth is the maximum width of the sidebar. DefaultSidebarMaxWidth = 45 // DefaultSidebarRatio is the default ratio of sidebar width to terminal width (25%). DefaultSidebarRatio = 0.25 // DefaultInputMinHeight is the minimum height of the input area. DefaultInputMinHeight = 3 // DefaultInputMaxHeight is the maximum height of the input area. DefaultInputMaxHeight = 15 // DefaultMinTerminalWidth is the minimum terminal width supported. DefaultMinTerminalWidth = 60 // DefaultMinTerminalHeight is the minimum terminal height supported. DefaultMinTerminalHeight = 15 )
============================================================================ Layout Constants - Default dimensions based on HTML design ============================================================================ These are now in TERMINAL CELLS (Rows/Cols), not pixels!
Variables ¶
This section is empty.
Functions ¶
func AdaptiveHeight ¶ added in v1.10.0
AdaptiveHeight returns a height that fits content with optional padding.
func AdaptiveWidth ¶ added in v1.10.0
AdaptiveWidth returns a width that fits content with optional padding.
func Clamp ¶ added in v1.10.0
Clamp ensures value is within min/max bounds. If value is less than min, returns min. If value is greater than max, returns max. Otherwise returns value unchanged.
func FlexJoinHorizontal ¶ added in v1.10.0
FlexJoinHorizontal joins boxes horizontally with optional spacing.
func FlexJoinVertical ¶ added in v1.10.0
FlexJoinVertical joins boxes vertically with optional spacing.
func GetBorderColor ¶ added in v1.10.0
func GetBorderColor(pane PaneType, focused PaneType) lipgloss.AdaptiveColor
GetBorderColor returns the appropriate border color for a pane based on whether it is focused or unfocused.
func GetBorderStyle ¶ added in v1.10.0
GetBorderStyle returns the appropriate lipgloss.Border for a pane based on whether it is focused or unfocused.
func GetPaneStyle ¶ added in v1.10.0
GetPaneStyle returns a lipgloss.Style configured for a specific pane with appropriate borders and colors.
func JoinHorizontal ¶ added in v1.10.0
JoinHorizontal joins multiple content blocks horizontally with proper spacing.
func JoinVertical ¶ added in v1.10.0
JoinVertical joins multiple content blocks vertically with proper spacing.
func KeyMapToSlice ¶
KeyMapToSlice extracts key bindings from a struct into a slice. The struct fields must be of type key.Binding.
func MeasureContent ¶ added in v1.10.0
MeasureContent returns the width and height needed to render content.
func PixelsToCells ¶ added in v1.10.0
PixelsToCells converts pixel dimensions to terminal cell dimensions. This is necessary because tea.WindowSizeMsg provides pixel dimensions, but the layout engine works with terminal cell dimensions. Typical character cell size is 8x16 pixels (width x height).
Note: This function uses conservative estimates. For more accurate conversion, use LayoutEngine.CalculateFromPixels() which can determine actual cell size.
func PlaceContent ¶ added in v1.10.0
PlaceContent positions content within a box using lipgloss placement.
func PlaceOverlay ¶
func PlaceOverlay( x, y int, fg, bg string, shadow bool, opts ...WhitespaceOption, ) string
PlaceOverlay places fg (foreground) on top of bg (background) at position (x, y). The shadow parameter enables a drop shadow effect behind the foreground. Additional WhitespaceOption parameters can customize the placement behavior.
This function is useful for rendering dialogs, tooltips, or other overlay content on top of the main UI background.
func ResponsiveValue ¶ added in v1.10.0
ResponsiveValue returns value if terminal is large enough, otherwise returns fallback.
func ResponsiveWidth ¶ added in v1.10.0
ResponsiveWidth returns responsive width based on terminal width.
Types ¶
type Bindings ¶
type Bindings interface {
// BindingKeys returns the keyboard bindings for this component.
BindingKeys() []key.Binding
}
Bindings is an interface for components that have keyboard bindings. Implement this to expose keyboard shortcuts to the application.
type Box ¶ added in v1.10.0
Box represents a rectangular region with styling for the TUI. It combines dimension (Rect) with lipgloss styling and content.
func NewBox ¶ added in v1.10.0
NewBox creates a new Box with the given dimensions and options. Use functional options to configure the box with custom styling and content.
Example:
box := NewBox(80, 24,
WithBoxStyle(lipgloss.NewStyle().Background(lipgloss.Color("#222222"))),
WithBoxContent("Hello, World!"),
)
func SidebarBox ¶ added in v1.10.0
SidebarBox creates a sidebar-style box.
func WarningBox ¶ added in v1.10.0
WarningBox creates a warning bar box with orange background.
func (*Box) GetInnerDimensions ¶ added in v1.10.0
GetInnerDimensions returns the inner content dimensions accounting for borders/padding.
func (*Box) Render ¶ added in v1.10.0
Render renders the box content with its style. It properly accounts for borders and padding to prevent layout wrapping.
func (*Box) RenderWithFullDimensions ¶ added in v1.10.0
RenderWithFullDimensions renders content using the FULL allocated dimensions. Use this when you need the outer dimensions (including borders).
type BoxOption ¶ added in v1.10.0
type BoxOption func(*Box)
BoxOption configures a Box using the functional options pattern.
func WithBoxBackground ¶ added in v1.10.0
WithBoxBackground sets the background color.
func WithBoxBorder ¶ added in v1.10.0
WithBoxBorder sets border on all sides.
func WithBoxBorderForeground ¶ added in v1.10.0
WithBoxBorderForeground sets border color.
func WithBoxContent ¶ added in v1.10.0
WithBoxContent sets the content for the box.
func WithBoxForeground ¶ added in v1.10.0
WithBoxForeground sets the foreground (text) color.
func WithBoxMargin ¶ added in v1.10.0
WithBoxMargin sets margin on all sides.
func WithBoxPadding ¶ added in v1.10.0
WithBoxPadding sets padding on all sides.
func WithBoxPaddingXY ¶ added in v1.10.0
WithBoxPaddingXY sets horizontal and vertical padding.
func WithBoxStyle ¶ added in v1.10.0
WithBoxStyle sets the lipgloss style for the box.
type Container ¶
Container is a UI component that can contain other tea.Model components with optional padding and borders.
func NewContainer ¶
func NewContainer(content tea.Model, options ...ContainerOption) Container
NewContainer creates a new Container with the given content and options. It initializes the container with default values and applies any provided options.
type ContainerOption ¶
type ContainerOption func(*container)
ContainerOption is a function that configures a Container.
func WithBorder ¶
func WithBorder(top, right, bottom, left bool) ContainerOption
WithBorder allows you to set borders for each side of the container. You can specify different values for top, right, bottom, and left borders.
func WithBorderAll ¶
func WithBorderAll() ContainerOption
WithBorderAll sets borders on all sides of the container.
func WithBorderHorizontal ¶
func WithBorderHorizontal() ContainerOption
WithBorderHorizontal sets borders on the left and right sides of the container.
func WithBorderStyle ¶
func WithBorderStyle(style lipgloss.Border) ContainerOption
WithBorderStyle sets the style of the border.
func WithBorderVertical ¶
func WithBorderVertical() ContainerOption
WithBorderVertical sets borders on the top and bottom sides of the container.
func WithDoubleBorder ¶
func WithDoubleBorder() ContainerOption
WithDoubleBorder sets the style of the border to DoubleBorder.
func WithPadding ¶
func WithPadding(top, right, bottom, left int) ContainerOption
WithPadding allows you to set padding for each side of the container. You can specify different values for top, right, bottom, and left padding.
func WithPaddingAll ¶
func WithPaddingAll(padding int) ContainerOption
WithPaddingAll sets the same padding value for all sides of the container.
func WithPaddingHorizontal ¶
func WithPaddingHorizontal(padding int) ContainerOption
WithPaddingHorizontal sets the same padding value for the left and right sides of the container.
func WithPaddingVertical ¶
func WithPaddingVertical(padding int) ContainerOption
WithPaddingVertical sets the same padding value for the top and bottom sides of the container.
func WithRoundedBorder ¶
func WithRoundedBorder() ContainerOption
WithRoundedBorder sets the style of the border to RoundedBorder.
func WithThickBorder ¶
func WithThickBorder() ContainerOption
WithThickBorder sets the style of the border to ThickBorder.
type Dimensions ¶ added in v1.10.0
type Dimensions struct {
// Terminal
TerminalWidth int
TerminalHeight int
// Main sections
TopBar Rect
WarningBar Rect
BottomBar Rect
ContentArea Rect // Combined sidebar + workspace
// Content area splits
Sidebar Rect // Left panel (~320px or 25%)
Workspace Rect // Right panel (remaining space)
// Workspace splits
ChatArea Rect // Scrollable chat
InputArea Rect // Input box
}
Dimensions holds the calculated dimensions for all UI sections. Each field represents a rectangular region with position and size.
type Focusable ¶
type Focusable interface {
// Focus gives focus to the component.
Focus() tea.Cmd
// Blur removes focus from the component.
Blur() tea.Cmd
// IsFocused returns true if the component currently has focus.
IsFocused() bool
}
Focusable is an interface for components that can receive focus. Implement this interface to enable keyboard navigation support.
type Footer ¶ added in v1.10.0
type Footer struct {
// contains filtered or unexported fields
}
Footer represents the bottom bar of the TUI application. It displays status information, keyboard shortcuts, and contextual hints.
func NewFooter ¶ added in v1.10.0
func NewFooter() *Footer
NewFooter creates a new Footer component with default values.
func (*Footer) GetDimensions ¶ added in v1.10.0
GetDimensions returns the current dimensions of the footer.
func (*Footer) RenderDefault ¶ added in v1.10.0
RenderDefault renders the footer with default styling and content.
func (*Footer) SetDimensions ¶ added in v1.10.0
SetDimensions sets the dimensions for the footer.
func (*Footer) SetFocused ¶ added in v1.10.0
SetFocused sets the focused state of the footer.
type Header ¶ added in v1.10.0
type Header struct {
// contains filtered or unexported fields
}
Header represents the top bar of the TUI application. It displays application title, mode indicators, and status information.
func NewHeader ¶ added in v1.10.0
func NewHeader() *Header
NewHeader creates a new Header component with default values.
func (*Header) GetDimensions ¶ added in v1.10.0
GetDimensions returns the current dimensions of the header.
func (*Header) RenderDefault ¶ added in v1.10.0
RenderDefault renders the header with default styling and content.
func (*Header) SetDimensions ¶ added in v1.10.0
SetDimensions sets the dimensions for the header.
func (*Header) SetFocused ¶ added in v1.10.0
SetFocused sets the focused state of the header.
type LayoutConfig ¶ added in v1.10.0
type LayoutConfig struct {
// Sidebar configuration
SidebarWidth int // Fixed width, 0 = use ratio
SidebarRatio float64 // Percentage of total width (0.0-1.0)
SidebarMinWidth int // Minimum sidebar width
SidebarMaxWidth int // Maximum sidebar width
// Fixed heights (0 = auto-calculate)
TopBarHeight int
WarningBarHeight int
BottomBarHeight int
// Input configuration
InputMinHeight int
InputMaxHeight int
InputRatio float64 // Ratio of remaining space for input
// Padding
ContentPaddingHorizontal int
ContentPaddingVertical int
}
LayoutConfig contains configuration options for the layout engine. All values are used to customize the layout calculation.
func DefaultLayoutConfig ¶ added in v1.10.0
func DefaultLayoutConfig() LayoutConfig
DefaultLayoutConfig returns the default layout configuration. This configuration uses sensible defaults for a standard chat interface.
type LayoutEngine ¶ added in v1.10.0
type LayoutEngine struct {
// contains filtered or unexported fields
}
LayoutEngine calculates and manages responsive dimensions for all UI sections. It provides methods to compute layout based on terminal size and configuration.
func NewLayoutEngine ¶ added in v1.10.0
func NewLayoutEngine() *LayoutEngine
NewLayoutEngine creates a new layout engine with default configuration.
func (*LayoutEngine) Calculate ¶ added in v1.10.0
func (e *LayoutEngine) Calculate(width, height int) Dimensions
Calculate computes all layout dimensions based on terminal size (in cells). This should be called with cell dimensions from the terminal.
func (*LayoutEngine) CalculateFromPixels ¶ added in v1.10.0
func (e *LayoutEngine) CalculateFromPixels(pixelWidth, pixelHeight int) Dimensions
CalculateFromPixels computes layout from pixel dimensions. It stores the original pixel values and converts to cells using the stored cell size, or estimates it if not yet determined.
func (*LayoutEngine) GetChatStyle ¶ added in v1.10.0
func (e *LayoutEngine) GetChatStyle() lipgloss.Style
GetChatStyle returns a lipgloss style for the chat area with padding.
func (*LayoutEngine) GetDimensions ¶ added in v1.10.0
func (e *LayoutEngine) GetDimensions() Dimensions
GetDimensions returns the cached dimensions. Returns zero dimensions if Calculate() hasn't been called.
func (*LayoutEngine) GetInputStyle ¶ added in v1.10.0
func (e *LayoutEngine) GetInputStyle() lipgloss.Style
GetInputStyle returns a lipgloss style for the input area.
func (*LayoutEngine) GetPixelDimensions ¶ added in v1.10.0
func (e *LayoutEngine) GetPixelDimensions() (int, int)
GetPixelDimensions returns the original pixel dimensions. Returns (0, 0) if CalculateFromPixels() hasn't been called.
func (*LayoutEngine) GetSidebarStyle ¶ added in v1.10.0
func (e *LayoutEngine) GetSidebarStyle() lipgloss.Style
GetSidebarStyle returns a lipgloss style for the sidebar with proper dimensions.
func (*LayoutEngine) GetTerminalDimensions ¶ added in v1.10.0
func (e *LayoutEngine) GetTerminalDimensions() (int, int)
GetTerminalDimensions returns the terminal dimensions in cells.
func (*LayoutEngine) GetWorkspaceStyle ¶ added in v1.10.0
func (e *LayoutEngine) GetWorkspaceStyle() lipgloss.Style
GetWorkspaceStyle returns a lipgloss style for the workspace.
func (*LayoutEngine) WithConfig ¶ added in v1.10.0
func (e *LayoutEngine) WithConfig(config LayoutConfig) *LayoutEngine
WithConfig sets the layout configuration and returns the engine for chaining.
type LayoutManager ¶ added in v1.10.0
type LayoutManager struct {
// contains filtered or unexported fields
}
LayoutManager calculates and manages the dimensions of a 3-pane TUI layout. It divides the terminal window into:
- Header: fixed 3 lines at the top
- Footer: fixed 1 line at the bottom
- Sidebar: 20-25% of remaining width on the left
- Main: remaining space for the primary content
func NewLayoutManager ¶ added in v1.10.0
func NewLayoutManager(width, height int) *LayoutManager
NewLayoutManager creates a new LayoutManager with the given dimensions.
func (*LayoutManager) Calculate ¶ added in v1.10.0
func (m *LayoutManager) Calculate(width, height int)
Calculate recalculates all pane dimensions based on the given window size.
func (*LayoutManager) GetFocusedPane ¶ added in v1.10.0
func (m *LayoutManager) GetFocusedPane() PaneType
GetFocusedPane returns the currently focused pane.
func (*LayoutManager) GetFooterDimensions ¶ added in v1.10.0
func (m *LayoutManager) GetFooterDimensions() PaneDimensions
GetFooterDimensions returns the dimensions for the footer pane.
func (*LayoutManager) GetHeaderDimensions ¶ added in v1.10.0
func (m *LayoutManager) GetHeaderDimensions() PaneDimensions
GetHeaderDimensions returns the dimensions for the header pane.
func (*LayoutManager) GetHeight ¶ added in v1.10.0
func (m *LayoutManager) GetHeight() int
GetHeight returns the current total height.
func (*LayoutManager) GetMainDimensions ¶ added in v1.10.0
func (m *LayoutManager) GetMainDimensions() PaneDimensions
GetMainDimensions returns the dimensions for the main content pane.
func (*LayoutManager) GetSidebarDimensions ¶ added in v1.10.0
func (m *LayoutManager) GetSidebarDimensions() PaneDimensions
GetSidebarDimensions returns the dimensions for the sidebar pane.
func (*LayoutManager) GetWidth ¶ added in v1.10.0
func (m *LayoutManager) GetWidth() int
GetWidth returns the current total width.
func (*LayoutManager) Render ¶ added in v1.10.0
func (m *LayoutManager) Render(headerContent, sidebarContent, mainContent, footerContent string) string
Render assembles and renders the complete layout with all panes. It takes content strings for each pane and returns the complete UI. CRITICAL: This properly calculates inner dimensions accounting for borders to prevent layout wrapping issues.
func (*LayoutManager) SetFocusedPane ¶ added in v1.10.0
func (m *LayoutManager) SetFocusedPane(pane PaneType)
SetFocusedPane sets which pane currently has focus.
type MainLayout ¶ added in v1.10.0
type MainLayout struct {
TopBar lipgloss.Style
Sidebar lipgloss.Style
Content lipgloss.Style
Status lipgloss.Style
}
MainLayout holds the lipgloss styles for all main layout sections.
func BuildMainLayout ¶ added in v1.10.0
func BuildMainLayout(dims *Dimensions, theme theme.Theme) MainLayout
BuildMainLayout creates the complete main layout structure with all styles.
type PaneDimensions ¶ added in v1.10.0
PaneDimensions holds the width and height of a layout pane.
type PaneType ¶ added in v1.10.0
type PaneType int
PaneType represents the different panes in the layout.
type Rect ¶ added in v1.10.0
type Rect struct {
X int // Horizontal position (column)
Y int // Vertical position (row)
Width int // Width in characters
Height int // Height in rows
}
Rect represents a rectangular region with position and size.
type Renderer ¶ added in v1.10.0
type Renderer struct {
// contains filtered or unexported fields
}
Renderer combines layout calculations with theme-aware rendering.
func NewRenderer ¶ added in v1.10.0
func NewRenderer(engine *LayoutEngine) *Renderer
NewRenderer creates a new renderer with the given layout engine.
func NewRendererWithTheme ¶ added in v1.10.0
func NewRendererWithTheme(engine *LayoutEngine, t theme.Theme) *Renderer
NewRendererWithTheme creates a new renderer with custom theme.
func (*Renderer) RenderBottomBar ¶ added in v1.10.0
RenderBottomBar renders the bottom bar (status bar) section.
func (*Renderer) RenderChatArea ¶ added in v1.10.0
RenderChatArea renders the main chat area.
func (*Renderer) RenderChatMessage ¶ added in v1.10.0
RenderChatMessage renders a chat message with role and content.
func (*Renderer) RenderDiffBlock ¶ added in v1.10.0
RenderDiffBlock renders a complete diff block.
func (*Renderer) RenderDiffLine ¶ added in v1.10.0
RenderDiffLine renders a single diff line with appropriate styling.
func (*Renderer) RenderInputArea ¶ added in v1.10.0
RenderInputArea renders the input area.
func (*Renderer) RenderMainLayout ¶ added in v1.10.0
func (r *Renderer) RenderMainLayout( topBarContent, warningContent, sidebarContent, chatContent, inputContent, bottomBarContent string, ) string
RenderMainLayout renders the complete main layout with all sections.
func (*Renderer) RenderSidebar ¶ added in v1.10.0
RenderSidebar renders the sidebar section with proper borders.
func (*Renderer) RenderStatusBar ¶ added in v1.10.0
RenderStatusBar renders a complete status bar with segments.
func (*Renderer) RenderStatusSegment ¶ added in v1.10.0
RenderStatusSegment renders a single status segment with Powerline style.
func (*Renderer) RenderToolBadge ¶ added in v1.10.0
RenderToolBadge renders a tool name as a badge.
func (*Renderer) RenderTopBar ¶ added in v1.10.0
RenderTopBar renders the top bar section.
func (*Renderer) RenderWarningBar ¶ added in v1.10.0
RenderWarningBar renders the warning bar section.
type Sidebar ¶ added in v1.10.0
type Sidebar struct {
// contains filtered or unexported fields
}
Sidebar represents the left pane of the TUI application. It displays file tree, session list, or other navigation content.
func NewSidebar ¶ added in v1.10.0
func NewSidebar() *Sidebar
NewSidebar creates a new Sidebar component with default values.
func (*Sidebar) GetDimensions ¶ added in v1.10.0
func (s *Sidebar) GetDimensions() PaneDimensions
GetDimensions returns the current dimensions of the sidebar.
func (*Sidebar) GetSelected ¶ added in v1.10.0
GetSelected returns the currently selected item index.
func (*Sidebar) RenderDefault ¶ added in v1.10.0
RenderDefault renders the sidebar with default styling and content.
func (*Sidebar) RenderItem ¶ added in v1.10.0
RenderItem renders a single sidebar item with the given index and content.
func (*Sidebar) SetDimensions ¶ added in v1.10.0
SetDimensions sets the dimensions for the sidebar.
func (*Sidebar) SetFocused ¶ added in v1.10.0
SetFocused sets the focused state of the sidebar.
func (*Sidebar) SetSelected ¶ added in v1.10.0
SetSelected sets the selected item index.
type Sizeable ¶
type Sizeable interface {
// SetSize sets the dimensions of the component.
SetSize(width, height int) tea.Cmd
// GetSize returns the current dimensions of the component.
GetSize() (int, int)
}
Sizeable is an interface for components that can be sized. All visual components should implement this to support responsive layouts.
type SplitPaneLayout ¶
type SplitPaneLayout interface {
tea.Model
Sizeable
Bindings
// SetLeftPanel sets the left panel of the split pane.
SetLeftPanel(panel Container) tea.Cmd
// SetRightPanel sets the right panel of the split pane.
SetRightPanel(panel Container) tea.Cmd
// SetBottomPanel sets the bottom panel of the split pane.
SetBottomPanel(panel Container) tea.Cmd
// ClearLeftPanel removes the left panel.
ClearLeftPanel() tea.Cmd
// ClearRightPanel removes the right panel.
ClearRightPanel() tea.Cmd
// ClearBottomPanel removes the bottom panel.
ClearBottomPanel() tea.Cmd
}
SplitPaneLayout is an interface for a split pane layout that divides the terminal into left/right panels and optionally a bottom panel. It implements tea.Model, Sizeable, and Bindings interfaces.
func NewSplitPane ¶
func NewSplitPane(options ...SplitPaneOption) SplitPaneLayout
NewSplitPane creates a new SplitPaneLayout with optional configuration. The default horizontal ratio is 0.7 (70% left, 30% right) and vertical ratio is 0.9 (90% top, 10% bottom).
type SplitPaneOption ¶
type SplitPaneOption func(*splitPaneLayout)
SplitPaneOption is a functional option for configuring a SplitPaneLayout.
func WithBottomPanel ¶
func WithBottomPanel(panel Container) SplitPaneOption
WithBottomPanel sets the initial bottom panel for the split pane.
func WithLeftPanel ¶
func WithLeftPanel(panel Container) SplitPaneOption
WithLeftPanel sets the initial left panel for the split pane.
func WithRatio ¶
func WithRatio(ratio float64) SplitPaneOption
WithRatio sets the horizontal split ratio. A ratio of 0.7 means 70% for left panel, 30% for right.
func WithRightPanel ¶
func WithRightPanel(panel Container) SplitPaneOption
WithRightPanel sets the initial right panel for the split pane.
func WithVerticalRatio ¶
func WithVerticalRatio(ratio float64) SplitPaneOption
WithVerticalRatio sets the vertical split ratio. A ratio of 0.9 means 90% for top section, 10% for bottom panel.
type WhitespaceOption ¶
type WhitespaceOption func(*whitespace)
WhitespaceOption sets a styling rule for rendering whitespace.