component.go

 1package common
 2
 3import (
 4	"charm.land/bubbles/v2/help"
 5	tea "charm.land/bubbletea/v2"
 6)
 7
 8// Model represents a simple UI model.
 9type Model interface {
10	Init() tea.Cmd
11	Update(tea.Msg) (Model, tea.Cmd)
12	View() string
13}
14
15// Component represents a Bubble Tea model that implements a SetSize function.
16type Component interface {
17	Model
18	help.KeyMap
19	SetSize(width, height int)
20}
21
22// TabComponenet represents a model that is mounted to a tab.
23// TODO: find a better name
24type TabComponent interface {
25	Component
26
27	// StatusBarValue returns the status bar value component.
28	StatusBarValue() string
29
30	// StatusBarInfo returns the status bar info component.
31	StatusBarInfo() string
32
33	// SpinnerID returns the ID of the spinner.
34	SpinnerID() int
35
36	// TabName returns the name of the tab.
37	TabName() string
38
39	// Path returns the hierarchical path of the tab.
40	Path() string
41}