statusbar

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package statusbar renders a one-line status strip with left/center/right slots, modeled on pug's footer.

The left and right slots are static (e.g. a "? help" hint, a version string). The center is a message region with three states — neutral (empty), info, and error — each with its own style preset. Call SetInfo / SetError to show a message; call ClearMessage (or forward tea messages through Update, which auto-clears on any KeyMsg) to wipe it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageKind

type MessageKind int

MessageKind is the state of the center slot.

const (
	MessageNone MessageKind = iota
	MessageInfo
	MessageError
)

type Model

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

Model is a one-line status bar.

func New

func New(opts Options) Model

New constructs a status bar with the given options, applying defaults for any unset field so you get a usable bar out of the box.

func (Model) BarBackground

func (m Model) BarBackground() lipgloss.TerminalColor

BarBackground returns the status bar's base background color. Useful when styling content you intend to embed in the bar (e.g. help key/desc styles) so the backgrounds line up.

func (Model) BarForeground

func (m Model) BarForeground() lipgloss.TerminalColor

BarForeground returns the status bar's base foreground color.

func (*Model) ClearMessage

func (m *Model) ClearMessage()

ClearMessage resets the center slot to its neutral state.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Message

func (m Model) Message() (string, MessageKind)

Message returns the current center-slot text and its kind. Useful when rebuilding the bar (e.g. on theme swap) and you want to carry an in-flight info/error message across the rebuild.

func (Model) MessageKind

func (m Model) MessageKind() MessageKind

MessageKind reports the current state of the center slot.

func (*Model) SetError

func (m *Model) SetError(s string)

SetError shows s in the center slot with the error style.

func (*Model) SetInfo

func (m *Model) SetInfo(s string)

SetInfo shows s in the center slot with the info style.

func (*Model) SetLeft

func (m *Model) SetLeft(s string)

func (*Model) SetRight

func (m *Model) SetRight(s string)

func (*Model) SetWidth

func (m *Model) SetWidth(w int)

func (Model) Update

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

Update auto-clears any info/error message on the next KeyMsg, matching pug's behavior. If you want persistent messages, skip Update and use ClearMessage explicitly.

func (Model) View

func (m Model) View() string

View renders the status bar as a single line, clipped to Width.

type Options

type Options struct {
	Width       int
	Left, Right string

	// BarBackground is the background color applied to left, right, and the
	// neutral middle slot. Defaults to "236" (dark grey).
	BarBackground lipgloss.TerminalColor
	// BarForeground is the foreground color for left, right, and neutral
	// middle. Defaults to "252".
	BarForeground lipgloss.TerminalColor

	LeftStyle, RightStyle               *lipgloss.Style
	NeutralStyle, InfoStyle, ErrorStyle *lipgloss.Style
}

Options configures a status bar. Zero-value fields fall back to defaults. Style fields are pointers so nil can mean "use default."

Use BarBackground / BarForeground to set a single color pair for the whole strip; the left, right, and neutral-middle styles all derive from them so the bar reads as one continuous band. Info and Error styles intentionally pop with different colors.

Jump to

Keyboard shortcuts

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