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 ¶
- type MessageKind
- type Model
- func (m Model) BarBackground() lipgloss.TerminalColor
- func (m Model) BarForeground() lipgloss.TerminalColor
- func (m *Model) ClearMessage()
- func (m Model) Init() tea.Cmd
- func (m Model) Message() (string, MessageKind)
- func (m Model) MessageKind() MessageKind
- func (m *Model) SetError(s string)
- func (m *Model) SetInfo(s string)
- func (m *Model) SetLeft(s string)
- func (m *Model) SetRight(s string)
- func (m *Model) SetWidth(w int)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- type Options
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 ¶
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) 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.
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.