layout

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package layout provides terminal layout management for memtui. It calculates pane sizes for the 2-pane layout (KeyList + Viewer).

Index

Constants

View Source
const (
	// MinKeyListWidth is the minimum width for the key list pane
	MinKeyListWidth = 10
	// MinViewerWidth is the minimum width for the viewer pane
	MinViewerWidth = 20
	// DefaultKeyListRatio is the default width ratio for the key list (30%)
	DefaultKeyListRatio = 0.30
	// HeaderLines is the number of lines used by the header
	HeaderLines = 2
	// StatusBarLines is the number of lines used by the status bar
	StatusBarLines = 1
	// BorderWidth is the width of the border between panes
	BorderWidth = 1
)

Constants for layout constraints

Variables

This section is empty.

Functions

This section is empty.

Types

type Bounds

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

Bounds represents a rectangular area in the terminal

func (Bounds) Bottom

func (b Bounds) Bottom() int

Bottom returns the bottom edge Y coordinate

func (Bounds) Contains

func (b Bounds) Contains(x, y int) bool

Contains checks if a point is within the bounds

func (Bounds) Right

func (b Bounds) Right() int

Right returns the right edge X coordinate

type Layout

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

Layout manages the terminal layout for memtui

func New

func New() *Layout

New creates a new Layout with default settings

func (*Layout) Calculate

func (l *Layout) Calculate()

Calculate computes all layout dimensions based on current terminal size

func (*Layout) ContentHeight

func (l *Layout) ContentHeight() int

ContentHeight returns the height of the content area

func (*Layout) ContentY

func (l *Layout) ContentY() int

ContentY returns the Y position of the content area (after header)

func (*Layout) HeaderBounds

func (l *Layout) HeaderBounds() Bounds

HeaderBounds returns the bounds of the header area

func (*Layout) HeaderHeight

func (l *Layout) HeaderHeight() int

HeaderHeight returns the height of the header

func (*Layout) Height

func (l *Layout) Height() int

Height returns the terminal height

func (*Layout) IsValid

func (l *Layout) IsValid() bool

IsValid returns true if the layout has been calculated and is valid

func (*Layout) KeyListBounds

func (l *Layout) KeyListBounds() Bounds

KeyListBounds returns the full bounds of the key list pane

func (*Layout) KeyListWidth

func (l *Layout) KeyListWidth() int

KeyListWidth returns the width of the key list pane

func (*Layout) KeyListX

func (l *Layout) KeyListX() int

KeyListX returns the X position of the key list pane

func (*Layout) SetKeyListRatio

func (l *Layout) SetKeyListRatio(ratio float64)

SetKeyListRatio sets the ratio of width for the key list pane Value should be between 0.1 and 0.9

func (*Layout) SetSize

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

SetSize sets the terminal dimensions

func (*Layout) StatusBarBounds

func (l *Layout) StatusBarBounds() Bounds

StatusBarBounds returns the bounds of the status bar

func (*Layout) StatusBarHeight

func (l *Layout) StatusBarHeight() int

StatusBarHeight returns the height of the status bar

func (*Layout) String

func (l *Layout) String() string

String returns a string representation of the layout for debugging

func (*Layout) ViewerBounds

func (l *Layout) ViewerBounds() Bounds

ViewerBounds returns the full bounds of the viewer pane

func (*Layout) ViewerWidth

func (l *Layout) ViewerWidth() int

ViewerWidth returns the width of the viewer pane

func (*Layout) ViewerX

func (l *Layout) ViewerX() int

ViewerX returns the X position of the viewer pane

func (*Layout) Width

func (l *Layout) Width() int

Width returns the terminal width

Jump to

Keyboard shortcuts

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