Help us shape the future of Go! Take the 2026 Go Developer Survey

tui

package
v0.0.0-...-09a8bdb Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tui is the dashboard shell: it owns layout, focus, global keys and the frame around each widget. It must not import a concrete widget package.

Index

Constants

View Source
const (
	FrameOverheadX = 4
	FrameOverheadY = 2
)

FrameOverhead is the number of cells the frame consumes on each axis: a border and one column of padding on each side horizontally, and a border row top and bottom vertically.

Variables

This section is empty.

Functions

func Frame

func Frame(t theme.Theme, title string, state FrameState, w, h int, content string) string

Frame draws a titled box of exactly w by h cells around content.

lipgloss has no border-title support, so the top border is assembled by hand. content is expected to already fit the inner area; anything longer is truncated ANSI-safely rather than allowed to break the layout.

func Layout

func Layout(rows [][]string, w, h int) [][]Box

Layout computes the outer box for every widget on a dashboard.

Rows split the available height; widgets within a row split that row's width. Remainders go to the earlier rows and earlier columns, so a 3-column layout in an 80-cell terminal gives 27/27/26 rather than losing two cells.

func MoveDown

func MoveDown(rows [][]string, name string) [][]string

MoveDown moves a widget into the row below, creating one at the bottom when there is none.

func MoveLeft

func MoveLeft(rows [][]string, name string) [][]string

MoveLeft swaps a widget with its left neighbour in the same row.

func MoveRight

func MoveRight(rows [][]string, name string) [][]string

MoveRight swaps a widget with its right neighbour in the same row.

func MoveUp

func MoveUp(rows [][]string, name string) [][]string

MoveUp moves a widget into the row above, keeping roughly its column. From the top row it creates a new row above, so a widget can always be promoted.

func SplitOut

func SplitOut(rows [][]string, name string) [][]string

SplitOut gives a widget a new row of its own, directly below its current one. A widget already alone in its row stays put.

Types

type Box

type Box struct {
	W, H int
}

Box is a widget's outer rectangle, including its frame.

func (Box) Inner

func (b Box) Inner() (w, h int)

Inner converts an outer box to the content area a widget may draw in.

type FrameState

type FrameState int

FrameState selects how a widget's border is drawn.

const (
	// FrameIdle is an unfocused widget.
	FrameIdle FrameState = iota
	// FrameFocused is the widget receiving keys.
	FrameFocused
	// FrameMoving is the widget being repositioned in layout mode.
	FrameMoving
)

type Model

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

Model is the root bubbletea model.

func New

func New(cfg *config.Config, dash *config.Dashboard) (*Model, error)

New builds every widget on the dashboard and returns the root model.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init starts every widget.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update routes messages. Key messages go only to the focused widget, a widget's own results (widget.Addressed) go only to the widget that asked for them, and anything else — resize, and messages from outside any widget — is broadcast.

func (*Model) View

func (m *Model) View() string

View renders the whole dashboard.

Jump to

Keyboard shortcuts

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