Documentation
¶
Index ¶
- Variables
- func BatchCmdHandler(msg tea.BatchMsg) []tea.Msg
- func CalculateDimensions(dimensions []Dimension, total int) []int
- func DebugPrintf(format string, a ...any)
- func GetMessageHandlingType(msg tea.Msg) tea.Msg
- func GetStylingSize(s lipgloss.Style) (int, int)
- func HandleAutoRoutedBatchMsg(msg tea.BatchMsg, path []int) tea.Cmd
- func IsSamePath(path1, path2 []int) bool
- func MakeAutoRoutedCmd(cmd tea.Cmd, path []int) tea.Cmd
- func MsgUsedCmd() tea.Cmd
- type AutoRoutedCmd
- type AutoRoutedMsg
- type BroadcastMsg
- type BroadcastMsgType
- type CanSendMsgToParent
- type ConsiderForGlobalShortcutMsg
- type ConsiderForLocalShortcutMsg
- type ContextualHelpTextMsg
- type Dimension
- type Direction
- type FastKeyMapChecker
- type FocusGrantMsg
- type FocusPropagatedMsgType
- type FocusRequestMsg
- type FocusRevokeMsg
- type Focusable
- type GeometricFocusRequestMsg
- type HandlesFocusRevoke
- type HandlesRecvFocus
- type HandlesSizeMsg
- type HasView
- type ImplementsAsRouteTypedMsg
- type Initiable
- type Layout
- type ListPanel
- func (l ListPanel) AreDimensionsValid(printErrors bool) bool
- func (p *ListPanel) Draw(force bool) bool
- func (m ListPanel) GetLayout() Layout
- func (m *ListPanel) GetMsgForParent() tea.Msg
- func (m *ListPanel) GetPath() []int
- func (m *ListPanel) GetSelected() tea.Model
- func (m *ListPanel) GetSelectedIndex() int
- func (m *ListPanel) HandleMessageFromChild(msg tea.Msg) tea.Cmd
- func (m *ListPanel) HandleRoutedMessage(msg tea.Msg) tea.Cmd
- func (m *ListPanel) HandleSizeMsg(msg ResizeMsg) tea.Cmd
- func (m *ListPanel) HandleZStackedMsg(msg tea.Msg) (tea.Cmd, bool)
- func (m *ListPanel) HandleZStackedSizeMsg(msg ResizeMsg) tea.Cmd
- func (m *ListPanel) Init() tea.Cmd
- func (m *ListPanel) IsFocused() bool
- func (l ListPanel) IsLayoutValid() bool
- func (m *ListPanel) ListView() string
- func (m *ListPanel) SetMsgForParent(msg tea.Msg)
- func (m *ListPanel) SetPath(path []int)
- func (m *ListPanel) SetSelected(i int) tea.Cmd
- func (p *ListPanel) SetView(view *tcellviews.ViewPort)
- func (m *ListPanel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *ListPanel) UpdateInner(msg tea.Msg) tea.Cmd
- func (m *ListPanel) View() string
- type MsgUsed
- type Orientation
- type Panel
- func (p *Panel) Draw(force bool) bool
- func (p *Panel) GetMsgForParent() tea.Msg
- func (p *Panel) GetPath() []int
- func (p *Panel) HandleFocus(msg tea.Msg) tea.Cmd
- func (p *Panel) HandleFocusGranted(msg FocusGrantMsg) tea.Cmd
- func (p *Panel) HandleFocusRevoke() tea.Cmd
- func (p *Panel) HandleMessage(msg tea.Msg) tea.Cmd
- func (p *Panel) HandleSizeMsg(msg ResizeMsg) tea.Cmd
- func (p *Panel) Init() tea.Cmd
- func (p *Panel) IsFocused() bool
- func (p *Panel) RoutedCmd(cmd tea.Cmd) tea.Cmd
- func (p *Panel) SetMsgForParent(msg tea.Msg)
- func (p *Panel) SetPath(path []int)
- func (p *Panel) SetView(view *tcellviews.ViewPort)
- func (p *Panel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (p *Panel) View() string
- type PanelStyle
- type PropagateKeyMsg
- type Relation
- type RequestMsgType
- type ResizeMsg
- type RoutePath
- type RoutedMsgType
- type SelectTabIndexMsg
- type SelectedTabIndexMsg
- type ShortCutPanel
- func (p *ShortCutPanel) Draw(force bool) bool
- func (p *ShortCutPanel) GetMsgForParent() tea.Msg
- func (p *ShortCutPanel) HandleMessageFromChild(msg tea.Msg) tea.Cmd
- func (p *ShortCutPanel) HandleShortcuts(msg tea.Msg) tea.Cmd
- func (p *ShortCutPanel) HandleSizeMsg(msg ResizeMsg) tea.Cmd
- func (p ShortCutPanel) Init() tea.Cmd
- func (p *ShortCutPanel) SetMsgForParent(msg tea.Msg)
- func (p *ShortCutPanel) SetPath(path []int)
- func (p *ShortCutPanel) SetView(view *tcellviews.ViewPort)
- func (p *ShortCutPanel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (p *ShortCutPanel) View() string
- type ShortCutPanelConfig
- type TabBar
- type TabStyles
- type TopLevelListPanel
- type UntypedMsgType
- type WorkFlow
- type WorkflowHandler
- type WorkflowHandlerInterface
Constants ¶
This section is empty.
Variables ¶
var ( Debug = false DebugChan = make(chan string, 100) )
Functions ¶
func CalculateDimensions ¶ added in v0.1.0
Here we assume that the layout is valid
func DebugPrintf ¶
func HandleAutoRoutedBatchMsg ¶
For any tea.Model that uses auto-routed messages, the top-level model should use this function to handle auto-routed batch messages. Auto-routed batch messages need to be converted to auto-routed cmds and then added to the batch to be executed.
func IsSamePath ¶
func MakeAutoRoutedCmd ¶
When a bunch of tea-bubbles are put together in multiple panels, this function embeds the cmd in an auto-routed cmd, so that when the cmd is executed, the message is auto-routed to the generator of the cmd
func MsgUsedCmd ¶
Types ¶
type AutoRoutedCmd ¶
func (AutoRoutedCmd) AsRouteTypedMsg ¶
func (msg AutoRoutedCmd) AsRouteTypedMsg() tea.Msg
type AutoRoutedMsg ¶
func (AutoRoutedMsg) AsRouteTypedMsg ¶
func (msg AutoRoutedMsg) AsRouteTypedMsg() tea.Msg
type BroadcastMsg ¶
func (BroadcastMsg) AsRouteTypedMsg ¶
func (msg BroadcastMsg) AsRouteTypedMsg() tea.Msg
type BroadcastMsgType ¶
type CanSendMsgToParent ¶
This interfaces allows a tea model to directly pass a message to its parent panel. This mechanism is used to handle focus passing for example - when the down arrow key is pressed on the last item of a list, focus is passed to the next panel in the hierarchy.
type ConsiderForGlobalShortcutMsg ¶
func (ConsiderForGlobalShortcutMsg) AsRouteTypedMsg ¶
func (msg ConsiderForGlobalShortcutMsg) AsRouteTypedMsg() tea.Msg
type ConsiderForLocalShortcutMsg ¶
func (ConsiderForLocalShortcutMsg) AsRouteTypedMsg ¶
func (msg ConsiderForLocalShortcutMsg) AsRouteTypedMsg() tea.Msg
type ContextualHelpTextMsg ¶
type Dimension ¶
type Dimension struct { Min int //valid if > 0, assumed unspecified otherwise Max int //valid if > 0, assumed unspecified otherwise Fixed int //valid if > 0, assumed unspecified otherwise Ratio float64 //valid if > 0, assumed unspecified otherwise }
If all fields are 0, it is assumed that the panel should take up the remaining space
func (Dimension) IsConstrained ¶ added in v0.1.0
func (Dimension) IsPureFixed ¶ added in v0.1.0
func (Dimension) IsPureRatio ¶ added in v0.1.0
func (Dimension) IsUnspecified ¶ added in v0.1.0
type FastKeyMapChecker ¶ added in v0.1.0
type FastKeyMapChecker struct {
Keys map[string]struct{}
}
func MakeFastKeyMapChecker ¶ added in v0.1.0
func MakeFastKeyMapChecker(keymap interface{}) FastKeyMapChecker
type FocusGrantMsg ¶
func (FocusGrantMsg) AsRouteTypedMsg ¶
func (msg FocusGrantMsg) AsRouteTypedMsg() tea.Msg
type FocusPropagatedMsgType ¶
type FocusRequestMsg ¶
type FocusRequestMsg struct { RequestedPath []int // Path to identify the focus request, e.g., [0, 2] means first panel's second child Relation Relation WorkflowName string }
func (FocusRequestMsg) AsRouteTypedMsg ¶
func (msg FocusRequestMsg) AsRouteTypedMsg() tea.Msg
type FocusRevokeMsg ¶
type FocusRevokeMsg struct{}
func (FocusRevokeMsg) AsRouteTypedMsg ¶
func (msg FocusRevokeMsg) AsRouteTypedMsg() tea.Msg
type Focusable ¶
type Focusable interface { IsFocused() bool GetPath() []int SetPath(path []int) Draw(force bool) bool SetView(view *tcellviews.ViewPort) tea.Model }
Focusable is an interface that allows a tea model to be focused. It is used to handle focus passing in the UI.
type GeometricFocusRequestMsg ¶ added in v0.1.0
type GeometricFocusRequestMsg struct {
Direction Direction
}
type HandlesFocusRevoke ¶
A Tea Model that can handle focus revokes can implement this interface The parent panel will call this method when it receives a focus revoke
type HandlesRecvFocus ¶
A Tea Model that can handle focus grants can implement this interface The parent panel will call this method when it receives a focus grant
type HandlesSizeMsg ¶
type Initiable ¶
Initiable is an interface that allows calling Init() on things that implement the Init() method but might not be a tea.Model
type Layout ¶
type Layout struct { Orientation Orientation Dimensions []Dimension }
Layout is a struct that describes the layout of a panel
func (Layout) AreDimensionsValid ¶ added in v0.1.0
func (Layout) CalculateDims ¶ added in v0.1.0
Preconditions: The layout is Vertical or Horizontal Total > 0
func (Layout) IsLayoutValid ¶ added in v0.1.0
type ListPanel ¶
type ListPanel struct { Panels []Focusable MsgForParent tea.Msg Layout Layout Selected int // Index of the selected panel, only used if the orientation is Vertical Name string // contains filtered or unexported fields }
ListPanel can house a list of panels that can be displayed in a horizontal, vertical, or stacked layout List panels also support handling focus propagation
func NewListPanel ¶
func (ListPanel) AreDimensionsValid ¶ added in v0.1.0
func (*ListPanel) GetMsgForParent ¶ added in v0.1.0
func (*ListPanel) GetSelected ¶
func (*ListPanel) GetSelectedIndex ¶
func (*ListPanel) HandleMessageFromChild ¶ added in v0.1.0
func (*ListPanel) HandleRoutedMessage ¶ added in v0.1.0
func (*ListPanel) HandleZStackedMsg ¶
func (*ListPanel) HandleZStackedSizeMsg ¶
func (ListPanel) IsLayoutValid ¶ added in v0.1.0
func (*ListPanel) SetMsgForParent ¶ added in v0.1.0
func (*ListPanel) SetView ¶ added in v1.2.0
func (p *ListPanel) SetView(view *tcellviews.ViewPort)
func (*ListPanel) UpdateInner ¶ added in v1.2.0
type Panel ¶
type Panel struct { Model tea.Model Name string Workflow WorkflowHandlerInterface MsgForParent tea.Msg // contains filtered or unexported fields }
func (*Panel) GetMsgForParent ¶
func (*Panel) HandleFocusGranted ¶
func (p *Panel) HandleFocusGranted(msg FocusGrantMsg) tea.Cmd
func (*Panel) HandleFocusRevoke ¶
func (*Panel) SetMsgForParent ¶
func (*Panel) SetView ¶ added in v1.2.0
func (p *Panel) SetView(view *tcellviews.ViewPort)
type PanelStyle ¶
type PropagateKeyMsg ¶
func (PropagateKeyMsg) AsRouteTypedMsg ¶
func (msg PropagateKeyMsg) AsRouteTypedMsg() tea.Msg
type Relation ¶
type Relation int
There are 4 types of messages: 1. Request messages: messages that are sent to the top level panel These are messages like FocusRequestMsg, FocusRevokeMsg, ContextualHelpTextMsg, that are responded to by the top level panel 2. Focus Propagated messages: messages that are sent along the current focus path 3. Routed messages: messages that are sent to a specific panel identified by path 4. Broadcast messages: messages that are sent to all panels Relation is an enum that describes the relation of a panel to its requested focus panel
type RequestMsgType ¶
type RoutedMsgType ¶
func (RoutedMsgType) GetRoutePath ¶
func (routedMsg RoutedMsgType) GetRoutePath() []int
type SelectTabIndexMsg ¶
type SelectedTabIndexMsg ¶
type ShortCutPanel ¶
type ShortCutPanel struct { ShortCutPanelConfig *Panel }
ShortCutPanel is an extension of Panel that can handle -- global and local shortcuts -- focus movement on key strokes -- up, down, backspace and enter For focus movement to work, the child panel must send the key-strokes to this panel via GetMsgForParent() It listens for ConsiderForGlobalShortcutMsg and ConsiderForLocalShortcutMsg for local and global shortcuts respectively When focused, it sends a ContextualHelpTextMsg to the parent to set ContextualHelp. The parent can decide to display it or not
func (*ShortCutPanel) Draw ¶ added in v1.2.0
func (p *ShortCutPanel) Draw(force bool) bool
func (*ShortCutPanel) GetMsgForParent ¶ added in v0.1.0
func (p *ShortCutPanel) GetMsgForParent() tea.Msg
func (*ShortCutPanel) HandleMessageFromChild ¶
func (p *ShortCutPanel) HandleMessageFromChild(msg tea.Msg) tea.Cmd
func (*ShortCutPanel) HandleShortcuts ¶
func (p *ShortCutPanel) HandleShortcuts(msg tea.Msg) tea.Cmd
func (*ShortCutPanel) HandleSizeMsg ¶
func (p *ShortCutPanel) HandleSizeMsg(msg ResizeMsg) tea.Cmd
func (ShortCutPanel) Init ¶
func (p ShortCutPanel) Init() tea.Cmd
func (*ShortCutPanel) SetMsgForParent ¶ added in v0.1.0
func (p *ShortCutPanel) SetMsgForParent(msg tea.Msg)
func (*ShortCutPanel) SetPath ¶
func (p *ShortCutPanel) SetPath(path []int)
func (*ShortCutPanel) SetView ¶ added in v1.2.0
func (p *ShortCutPanel) SetView(view *tcellviews.ViewPort)
func (*ShortCutPanel) View ¶
func (p *ShortCutPanel) View() string
type ShortCutPanelConfig ¶
type TabBar ¶
type TopLevelListPanel ¶
type TopLevelListPanel struct {
*ListPanel
}
TopLevelListPanel is a special case of ListPanel that is the topmost panel in the hierarchy It handles responding to focus-request messages with focus-grant messages It also initializes the path of all its children And gives all children panels a chance to request focus for key-strokes by passing them a ConsiderForGlobalShortcutMsg before passing a key-stroke as a regular key-stroke message
func (*TopLevelListPanel) Init ¶
func (m *TopLevelListPanel) Init() tea.Cmd
type UntypedMsgType ¶
type WorkFlow ¶
type WorkFlow[S any] struct { // contains filtered or unexported fields }
WorkFlow is a struct that describes a workflow It contains the name of the workflow And the current state of the workflow
func NewWorkflow ¶
func (*WorkFlow[S]) AddHandler ¶
func (w *WorkFlow[S]) AddHandler(handler *WorkflowHandler[S])
type WorkflowHandler ¶
type WorkflowHandler[S any] struct { Workflow *WorkFlow[S] Handler func(model tea.Model, state S) (tea.Model, S, tea.Cmd) // contains filtered or unexported fields }
WorkflowHandler is a struct that describes a step in a workflow It references the workflow it belongs to And the handler function that implements the logic for this step
func (WorkflowHandler[S]) GetNumber ¶
func (w WorkflowHandler[S]) GetNumber() int
func (WorkflowHandler[S]) GetWorkflowName ¶
func (w WorkflowHandler[S]) GetWorkflowName() string
func (WorkflowHandler[S]) HandleFocusGrant ¶
func (w WorkflowHandler[S]) HandleFocusGrant(model tea.Model, msg FocusGrantMsg) (tea.Model, tea.Cmd)
For panels that are a part of a workflow, the workflow handles checking if the focus-grant message is relevant to this step
func (WorkflowHandler[S]) IsFirst ¶
func (w WorkflowHandler[S]) IsFirst() bool
func (WorkflowHandler[S]) IsLast ¶
func (w WorkflowHandler[S]) IsLast() bool
type WorkflowHandlerInterface ¶
type WorkflowHandlerInterface interface { HandleFocusGrant(model tea.Model, msg FocusGrantMsg) (tea.Model, tea.Cmd) GetNumber() int GetWorkflowName() string IsFirst() bool IsLast() bool }
WorkflowHandlerInterface is an interface that allows a tea model to be a workflow handler. A workflow handler is a panel that is part of a workflow.