Documentation
¶
Overview ¶
Package deck is the bubbletea runtime for viewkit.
Invariant: tea lives ONLY in this package — viewkit core (glyph/theme/layout/panels/…) must not import bubbletea. Apps and plugins implement View and register via RegisterView; Model (alias Host) owns stack navigation + chrome.
Process-global singletons (install before Run):
- theme.Use / theme.Cur — active palette
- keys.Use / keys.Cur — active key scheme
- theme.Register / keys.Register / RegisterView — contribution registries
See INTERFACE.md for the Model + singleton contract.
Index ¶
- func ComponentIDs() []string
- func Confirm(title, message, yesLabel, noLabel string) (bool, error)
- func RegisterComponent(id string, ctor func() Component)
- func RegisterView(id string, ctor func() View)
- func Run(root View, opts ...Option) error
- func ViewIDs() []string
- type Chrome
- type Component
- type Content
- type ContentFunc
- type HomeShell
- func (h *HomeShell) Body(width, height int) string
- func (h *HomeShell) Context() [][2]string
- func (h *HomeShell) FocusSide() bool
- func (h *HomeShell) Hints() [][2]string
- func (h *HomeShell) Init() tea.Cmd
- func (h *HomeShell) Title() string
- func (h *HomeShell) Update(host *Model, msg tea.Msg) tea.Cmd
- type Host
- func (h *Host) Height() int
- func (h *Host) Init() tea.Cmd
- func (h *Host) Pop() tea.Cmd
- func (h *Host) Push(v View) tea.Cmd
- func (h *Host) RefreshStatus() tea.Cmd
- func (h *Host) SetStatus(info StatusInfo)
- func (h *Host) Top() View
- func (h *Host) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (h *Host) View() string
- func (h *Host) Width() int
- type ItemList
- type Job
- type KeyHook
- type Menu
- type MenuItem
- type Message
- type Model
- type MsgHook
- type Option
- type Scroll
- type ScrollContent
- type ServiceStatus
- type StatusFunc
- type StatusInfo
- type StatusLevel
- type Text
- type View
- type Work
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComponentIDs ¶
func ComponentIDs() []string
ComponentIDs returns registered component ids sorted.
func RegisterComponent ¶
RegisterComponent associates id with a component constructor.
func RegisterView ¶
RegisterView associates id with a view constructor.
Types ¶
type Chrome ¶
type Chrome struct {
Brand string // e.g. "MUNIN"
BrandGlyph string
Subtitle string // e.g. "ono-sendai deck"
ClockGlyph string
}
Chrome configures brand/header appearance. Apps inject product branding; viewkit/deck never hard-codes app names.
type Component ¶
Component is a reusable UI fragment registered by id. Components are not full Views — they paint a region when asked.
func LookupComponent ¶
LookupComponent returns a fresh Component for id.
type Content ¶
type Content interface {
// Render returns the painted body for the given width (may ignore width).
Render(width int) string
}
Content is domain-agnostic job/panel body text. Apps adapt their types (e.g. domain section trees) into Content before crossing into deck.
type ContentFunc ¶
ContentFunc adapts a function to Content.
func (ContentFunc) Render ¶
func (f ContentFunc) Render(width int) string
Render implements Content.
type HomeShell ¶
type HomeShell struct {
// BoxTitle is the menu TitledBox title. Empty (default) omits the title.
BoxTitle string
// SideLabel is shown above the side list when SideFetch is set.
SideLabel string
// SideHint is the tab-target label when menu-focused (default "side").
SideHint string
// SideFetch loads opaque side content once (nil disables the side pane).
SideFetch func() any
// SideBind maps fetched data → rows using current width.
SideBind func(width int, fetched any) []list.Item
// SideLoading shown while SideFetch has not completed.
SideLoading string
// IsAction maps a key string to a keys.Action, fully replacing the active
// scheme map (keys.Cur); map PageUp/PageDown and FocusNext to keep paging
// and pane switching.
IsAction func(string) (keys.Action, bool)
// OnOpen overrides browser.Open when a side item Key is confirmed.
OnOpen func(url string) error
// contains filtered or unexported fields
}
HomeShell is a dual-pane View: navigable menu + optional side Item list. SideFetch/SideBind keep domain types out of deck (caller maps → list.Item).
func NewHomeShell ¶
NewHomeShell builds a HomeShell. sideLabel empty + SideFetch nil → menu-only. BoxTitle defaults empty (no menu titled-box title); set after construction if desired.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is the tea model: stack navigation + chrome. Prefer the Model alias in new code; Host remains for compatibility.
func (*Host) RefreshStatus ¶ added in v0.1.3
RefreshStatus reloads the status strip via the installed StatusFunc. Same path as the periodic refresh ticker; no-op when WithStatus was not set.
func (*Host) SetStatus ¶
func (h *Host) SetStatus(info StatusInfo)
SetStatus applies chrome status immediately (tests / non-async hosts).
type ItemList ¶
type ItemList struct {
// Fetch loads opaque content once (optional if Bind alone is enough).
Fetch func() any
// Bind turns fetched data into list rows. Called on each refresh after load.
Bind func(width int, fetched any) []list.Item
// ChromeReserve is subtracted from window height for title/status chrome.
ChromeReserve int
// IsCancel reports whether a key string should pop the view.
IsCancel func(string) bool
// IsAction maps a key string to a keys.Action, fully replacing the active
// scheme map (keys.Cur); map PageUp/PageDown too to keep paging.
IsAction func(string) (keys.Action, bool)
// OnOpen overrides browser.Open when an item Key is confirmed.
OnOpen func(url string) error
// LoadingText shown before load completes.
LoadingText string
// contains filtered or unexported fields
}
ItemList is a lazy-loaded selectable list View. Fetch runs once on Init; Bind maps fetched data → rows using the current width so callers can width-wrap without importing domain types into deck.
type Job ¶ added in v0.1.5
Job is one unit of work. Do must be safe for concurrent execution; return Content (never domain types).
type KeyHook ¶
KeyHook handles a key before the top view. Return handled=true to skip view Update (and optionally a Cmd such as Push).
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
Menu is a simple navigable list View.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is a dismissible text View.
func NewMessage ¶
NewMessage builds a Message view.
type Model ¶
type Model = Host
Model is the stateful Bubble Tea program root for deck: navigable view stack, injectable chrome, and async status strip. It implements tea.Model (Init / Update / View).
Contract:
- One Model owns one tea.Program for a deck session.
- Views receive *Model in Update so they can Push/Pop and read size.
- Domain state lives in View implementations (or app kits), not in Model.
Host is a compatibility alias; prefer Model in new code and docs.
type MsgHook ¶ added in v0.1.4
MsgHook handles a non-key message before the top view. Return handled=true to skip view Update (e.g. debounced role-lifecycle settle).
type Option ¶
type Option func(*Model)
Option configures Model (Host alias).
func WithKeyHook ¶
WithKeyHook installs a global key interceptor (e.g. app hotkeys).
func WithKeyMapQuit ¶
func WithKeyMapQuit() Option
WithKeyMapQuit installs a quit matcher from keys.Cur() Quit binding. This is also the default; the option remains for explicit call sites.
func WithMsgHook ¶ added in v0.1.4
WithMsgHook installs a global message interceptor (e.g. debounce settle).
func WithQuitCheck ¶
WithQuitCheck overrides quit key matcher. An opaque matcher cannot be rendered, so pair it with WithQuitHint to keep the footer legend truthful.
func WithQuitHint ¶ added in v0.1.5
WithQuitHint overrides the quit glyph in the footer legend. Defaults to the active scheme's Quit binding.
func WithStatus ¶
func WithStatus(fn StatusFunc) Option
WithStatus installs an async status loader for the footer strip.
type Scroll ¶
type Scroll struct {
// ChromeReserve is subtracted from window height for title/status chrome.
ChromeReserve int
// IsCancel reports whether a key string should pop the view.
IsCancel func(string) bool
// contains filtered or unexported fields
}
Scroll is a lazy-loaded scrollable text view (bubbles viewport). Hosted only in the deck module so tea stays out of viewkit core.
type ScrollContent ¶
type ScrollContent struct {
// contains filtered or unexported fields
}
ScrollContent is a lazy-loaded scrollable text View.
func NewScrollContent ¶
func NewScrollContent(title string, ctx, hints [][2]string, load func() string) *ScrollContent
NewScrollContent builds a content view that loads asynchronously.
func (*ScrollContent) Body ¶
func (c *ScrollContent) Body(width, height int) string
func (*ScrollContent) Context ¶
func (c *ScrollContent) Context() [][2]string
func (*ScrollContent) Hints ¶
func (c *ScrollContent) Hints() [][2]string
func (*ScrollContent) Init ¶
func (c *ScrollContent) Init() tea.Cmd
func (*ScrollContent) Title ¶
func (c *ScrollContent) Title() string
type ServiceStatus ¶
type ServiceStatus struct {
Name string
Detail string
Level StatusLevel
Glyph string
Color lipgloss.TerminalColor
}
ServiceStatus is one right-strip status chip.
type StatusFunc ¶
type StatusFunc func(context.Context) StatusInfo
StatusFunc loads status asynchronously for the chrome strip.
type StatusInfo ¶
type StatusInfo struct {
Identity string // e.g. "@user ✓"
Services []ServiceStatus
}
StatusInfo is optional chrome identity + service chips.
type View ¶
type View interface {
Title() string
Init() tea.Cmd
Update(m *Model, msg tea.Msg) tea.Cmd
Body(width, height int) string
Hints() [][2]string
Context() [][2]string
}
View is a navigable screen hosted by Model. Apps implement domain views; the tea runtime lives only in this module (tea must not enter viewkit core).