Documentation
¶
Overview ¶
Package layout is pure geometry for one sampled terminal frame. Rendering, popup placement, modal scrolling, and selection coordinates all consume the same value so a resize cannot mix dimensions from different terminal-size reads.
Go port of Ruby's lib/tui/screen_layout.rb. It lives with the terminal primitives because both the frame renderer and the mouse hit map must agree on the same rectangles; nothing here knows about tasks or views.
Index ¶
- Constants
- Variables
- func MinimumEditTerminalHeight(footerRows int) int
- func MinimumEditTerminalWidth() int
- func VisibleRows[T any](l *Layout, rows []T) []T
- type Breakpoint
- type FooterLine
- type Layout
- func (l *Layout) BodyOrigin() (int, int)
- func (l *Layout) BodyRows() Span
- func (l *Layout) ContentBreakpoint() Breakpoint
- func (l *Layout) EditablePanel() bool
- func (l *Layout) Editing() bool
- func (l *Layout) FooterRows() Span
- func (l *Layout) FooterSize() int
- func (l *Layout) HasPanel() bool
- func (l *Layout) HeaderRow() int
- func (l *Layout) ListCols() Span
- func (l *Layout) ModalBoxSize(modal Modal) (width, height int)
- func (l *Layout) PanelCols() Span
- func (l *Layout) PanelDividerCol() int
- func (l *Layout) PlaceModal(modal Modal) Modal
- func (l *Layout) PlacePopup(popup Popup, preferredCol int) Popup
- type Modal
- type Options
- type PanelMode
- type Popup
- type Span
Constants ¶
const ( // FixedRows are the borders, header, and the two rules outside the body // and footer. FixedRows = 5 PanelRatio = 0.40 WidePanelRatio = 0.58 MinPanelWidth = 28 MinListWidth = 8 EditMinContentWidth = 32 InlineContentWidth = 48 // EditPanelChromeRows are the right panel's title and divider. EditPanelChromeRows = 2 // EditMinVisibleRows is the compact focused-field fallback. EditMinVisibleRows = 1 )
Variables ¶
var PanelModes = []PanelMode{PanelCompact, PanelStandard, PanelWide, PanelFocus}
PanelModes is the promotion ladder, narrowest first.
Functions ¶
func MinimumEditTerminalHeight ¶
MinimumEditTerminalHeight is the named zero-footer minimum. Every footer/help row consumes another terminal row before the panel title, divider, and focused fallback.
func MinimumEditTerminalWidth ¶
func MinimumEditTerminalWidth() int
MinimumEditTerminalWidth is the narrowest terminal that can host the editor.
func VisibleRows ¶
VisibleRows returns the slice of rows inside the viewport.
Types ¶
type Breakpoint ¶
type Breakpoint string
Breakpoint describes how much room the panel has for editable content.
const ( BelowMinimum Breakpoint = "below_minimum" Stacked Breakpoint = "stacked" Inline Breakpoint = "inline" )
type FooterLine ¶
type FooterLine struct {
}
FooterLine is one footer entry. A Rule line draws a divider instead of text.
type Layout ¶
type Layout struct {
Width, Height int
BodyHeight int
BodyWidth int
ListWidth int
PanelWidth int
PanelContentWidth int
ViewportOffset int
Selected *int
SelectedScreenRow *int
PanelMode PanelMode
RequestedPanelMode PanelMode
EditContentHeight int
PanelOffset int
// contains filtered or unexported fields
}
Layout is the resolved geometry. All fields are read-only after construction.
func (*Layout) BodyOrigin ¶
BodyOrigin is the (row, col) of the first body cell.
func (*Layout) ContentBreakpoint ¶
func (l *Layout) ContentBreakpoint() Breakpoint
ContentBreakpoint classifies the panel's editable content width.
func (*Layout) EditablePanel ¶
EditablePanel reports whether the panel has room for the task editor.
func (*Layout) FooterRows ¶
func (*Layout) FooterSize ¶
func (*Layout) ModalBoxSize ¶
ModalBoxSize is the drawn box size for a modal, shared by the renderer and the hit map so a click and a glyph never disagree.
func (*Layout) PanelDividerCol ¶
PanelDividerCol is the column of the "│" between list and panel, or -1 when no panel is drawn.
func (*Layout) PlaceModal ¶
PlaceModal supplies the modal's stable anchor. The frame still draws the box.
type Modal ¶
type Modal struct {
Title string
Lines []string
Width int
// Row and Col are meaningful only once Placed is true; PlaceModal sets all
// three. An unplaced modal is centered by the renderer.
Row, Col int
Placed bool
}
Modal is a centered box over the body. Width pins the box width; zero means "fit the content".
type Options ¶
type Options struct {
Width, Height int
// Selected is the absolute index of the selected row; nil means no
// selection.
Selected *int
Panel bool
PanelMode PanelMode
PanelOffset int
Editing bool
}
Options describes one sampled frame.