Documentation
¶
Index ¶
- Variables
- func CalculateDimensions(dimensions []Dimension, total int) []int
- func DebugPrintf(format string, a ...any)
- func GetHandlingForMessageWithRoutePath(msg IMessageWithRoutePath) func(msg Msg) Msg
- func GetStylingSize(s lipgloss.Style) (int, int, int, int)
- func HandleBatchCmds(msg Msg) []tea.Cmd
- func IsSamePath(path1, path2 []int) bool
- func MakeAutoRoutedCmd(cmd tea.Cmd, path []int) tea.Cmd
- func MapKeyMsg(msg KeyMsg) (tea.KeyMsg, bool)
- func Run(model IRootModel, screen tcell.Screen)
- func TcellDrawHelper(j string, s tcellviews.View, preserveViews []*tcellviews.ViewPort)
- type AutoRoutedCmd
- type AutoRoutedMsg
- type BroadcastMsg
- type BroadcastMsgType
- type ConsiderForGlobalShortcutMsg
- type ConsiderForLocalShortcutMsg
- type ContextualHelpTextMsg
- type Dimension
- type FastKeyMapChecker
- type FocusGrantMsg
- type FocusPropagatedMsgType
- type FocusRequestMsg
- type FocusRevokeMsg
- type HasView
- type ILeafModel
- type ILeafModelWithDraw
- type ILeafModelWithView
- type IMessageWithRoutePath
- type IMovementNode
- type IPanel
- type IRootModel
- type KeyBinding
- type KeyBindingOption
- func WithEnabled(enabled bool) KeyBindingOption
- func WithFunc(fn func() tea.Cmd) KeyBindingOption
- func WithKeyDef(keyDef KeyDef) KeyBindingOption
- func WithKeyDefs(keyDefs []KeyDef) KeyBindingOption
- func WithLongHelp(longHelp string) KeyBindingOption
- func WithShortHelp(shortHelp string) KeyBindingOption
- type KeyDef
- type KeyMsg
- type Layout
- type ListPanel
- func (l ListPanel) AreDimensionsValid(printErrors bool) bool
- func (p *ListPanel) Draw(force bool) bool
- func (m *ListPanel) GetFocusIndex() int
- func (m ListPanel) GetLayout() Layout
- func (m *ListPanel) GetLeafPanelCenters() []PanelCenter
- func (m *ListPanel) GetMsgForParent() tea.Msg
- func (m *ListPanel) GetName() string
- func (m *ListPanel) GetPath() []int
- func (m *ListPanel) GetSelected() IPanel
- func (m *ListPanel) GetSelectedIndex() int
- func (m *ListPanel) HandleFocusRequestMsg(msg FocusRequestMsg) *FocusGrantMsg
- func (m *ListPanel) HandleMessage(msg Msg)
- func (m *ListPanel) HandleSizeMsg(msg ResizeMsg)
- func (m *ListPanel) HandleZStackedMsg(msg tea.Msg)
- func (m *ListPanel) HandleZStackedSizeMsg(msg ResizeMsg)
- func (m *ListPanel) Init(cmds chan tea.Cmd)
- func (m *ListPanel) IsFocused() bool
- func (m *ListPanel) IsInHiddenTab() 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 (m *ListPanel) SetTabHidden(hidden bool)
- func (p *ListPanel) SetView(view *tcellviews.ViewPort)
- func (m *ListPanel) TabNext() tea.Cmd
- func (m *ListPanel) TabPrev() tea.Cmd
- type Msg
- type Orientation
- type PanelCenter
- type PanelSequence
- func (m *PanelSequence) CreateKeyBindings(root IMovementNode, kb *KeyBinding, rev_kb *KeyBinding)
- func (m *PanelSequence) First() *ShortCutPanel
- func (m *PanelSequence) IsListOfPanels() bool
- func (m *PanelSequence) IsSelector() bool
- func (m *PanelSequence) Last() *ShortCutPanel
- func (m *PanelSequence) Next(panel *ShortCutPanel) *ShortCutPanel
- func (m *PanelSequence) Previous(panel *ShortCutPanel) *ShortCutPanel
- type PanelStyle
- type Relation
- type RequestMsgType
- type ResizeMsg
- type RoutePath
- type RoutedMsgType
- type SelectTabIndexMsg
- type SelectedTabIndexMsg
- type SelectorNode
- func (m *SelectorNode) CreateKeyBindings(root IMovementNode, kb *KeyBinding, rev_kb *KeyBinding)
- func (m *SelectorNode) First() *ShortCutPanel
- func (m *SelectorNode) IsListOfPanels() bool
- func (m *SelectorNode) IsSelector() bool
- func (m *SelectorNode) Last() *ShortCutPanel
- func (m *SelectorNode) Next(panel *ShortCutPanel) *ShortCutPanel
- func (m *SelectorNode) Previous(panel *ShortCutPanel) *ShortCutPanel
- type ShortCutPanel
- func (p *ShortCutPanel) AddKeyBinding(kb KeyBinding)
- func (p *ShortCutPanel) Draw(force bool) bool
- func (p *ShortCutPanel) DrawModelWithDraw(m ILeafModelWithDraw, force bool) bool
- func (p *ShortCutPanel) DrawModelWithView(m ILeafModelWithView, force bool) bool
- func (p *ShortCutPanel) FocusRequestCmd(direction Relation) tea.Cmd
- func (p *ShortCutPanel) GetLeafPanelCenters() []PanelCenter
- func (p *ShortCutPanel) GetName() string
- func (p *ShortCutPanel) GetPath() []int
- func (p *ShortCutPanel) HandleMessage(msg Msg)
- func (p *ShortCutPanel) HandleMessageFromChild(msg Msg) tea.Cmd
- func (p *ShortCutPanel) HandleSizeMsg(msg ResizeMsg) tea.Cmd
- func (p *ShortCutPanel) Init(cmds chan tea.Cmd)
- func (p *ShortCutPanel) IsFocused() bool
- func (p *ShortCutPanel) IsInHiddenTab() bool
- func (p *ShortCutPanel) RoutedCmd(cmd tea.Cmd) tea.Cmd
- func (p *ShortCutPanel) SetPath(path []int)
- func (p *ShortCutPanel) SetTabHidden(hidden bool)
- func (p *ShortCutPanel) SetView(view *tcellviews.ViewPort)
- type ShortCutPanelConfig
- type ShortCutPanelOption
- func WithConfig(config ShortCutPanelConfig) ShortCutPanelOption
- func WithContextualHelp(help string) ShortCutPanelOption
- func WithKeyBindingMaker(keyBindingMaker func(*ShortCutPanel) KeyBinding) ShortCutPanelOption
- func WithName(name string) ShortCutPanelOption
- func WithPanelStyle(style PanelStyle) ShortCutPanelOption
- func WithTitle(title string) ShortCutPanelOption
- func WithTitleStyle(style lipgloss.Style) ShortCutPanelOption
- type TabBar
- type TabBarOption
- type TabStyles
- type TcellKeyToTeaMsgResult
- type TeaCmdMsgEvent
- type TopLevelListPanel
- type UntypedMsgType
Constants ¶
This section is empty.
Variables ¶
var ( Debug = false DebugChan = make(chan string, 100) )
var KeyShiftTabBinding = SingleKeyBinding(tcell.KeyBacktab)
var KeyTabBinding = SingleKeyBinding(tcell.KeyTAB)
Functions ¶
func CalculateDimensions ¶
Here we assume that the layout is valid
func DebugPrintf ¶
func GetHandlingForMessageWithRoutePath ¶
func GetHandlingForMessageWithRoutePath(msg IMessageWithRoutePath) func(msg Msg) Msg
func HandleBatchCmds ¶
func IsSamePath ¶
func Run ¶
func Run(model IRootModel, screen tcell.Screen)
func TcellDrawHelper ¶
func TcellDrawHelper(j string, s tcellviews.View, preserveViews []*tcellviews.ViewPort)
Types ¶
type AutoRoutedCmd ¶
func (AutoRoutedCmd) AsRouteTypedMsg ¶
func (msg AutoRoutedCmd) AsRouteTypedMsg() Msg
type AutoRoutedMsg ¶
type BroadcastMsg ¶
type BroadcastMsg struct {
Msg
}
type BroadcastMsgType ¶
type BroadcastMsgType struct {
Msg Msg
}
type ConsiderForGlobalShortcutMsg ¶
type ConsiderForGlobalShortcutMsg struct {
KeyMsg
}
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 ¶
func (Dimension) IsPureFixed ¶
func (Dimension) IsPureRatio ¶
func (Dimension) IsUnspecified ¶
type FastKeyMapChecker ¶
type FastKeyMapChecker struct {
Keys map[string]struct{}
}
func MakeFastKeyMapChecker ¶
func MakeFastKeyMapChecker(keymap interface{}) FastKeyMapChecker
type FocusGrantMsg ¶
type FocusPropagatedMsgType ¶
type FocusPropagatedMsgType struct {
Msg Msg
}
type FocusRequestMsg ¶
type FocusRevokeMsg ¶
type FocusRevokeMsg struct{}
type ILeafModelWithDraw ¶
type ILeafModelWithDraw interface {
Draw(force bool, view *tcellviews.ViewPort) bool
}
type ILeafModelWithView ¶
type IMessageWithRoutePath ¶
type IMessageWithRoutePath interface {
GetRoutePath() *RoutePath
}
type IMovementNode ¶ added in v0.0.2
type IMovementNode interface { IsListOfPanels() bool IsSelector() bool Next(*ShortCutPanel) *ShortCutPanel Previous(*ShortCutPanel) *ShortCutPanel CreateKeyBindings(IMovementNode, *KeyBinding, *KeyBinding) First() *ShortCutPanel Last() *ShortCutPanel // contains filtered or unexported methods }
type IPanel ¶
type IPanel interface { IsFocused() bool GetPath() []int SetPath(path []int) HandleMessage(msg Msg) SetView(view *tcellviews.ViewPort) Draw(force bool) bool Init(cmds chan tea.Cmd) GetLeafPanelCenters() []PanelCenter GetName() string SetTabHidden(hidden bool) IsInHiddenTab() bool }
IPanel is an interface that allows a tea model to be focused. It is used to handle focus passing in the UI.
type IRootModel ¶
type KeyBinding ¶
type KeyBinding struct { KeyDefs []KeyDef ShortHelp string LongHelp string Enabled bool Func func() tea.Cmd }
func NewKeyBinding ¶
func NewKeyBinding(opts ...KeyBindingOption) *KeyBinding
func ShiftTabBinding ¶ added in v0.0.2
func ShiftTabBinding() KeyBinding
func SingleKeyBinding ¶
func SingleKeyBinding(key tcell.Key) KeyBinding
func SingleRuneBinding ¶
func SingleRuneBinding(rune rune) KeyBinding
func (*KeyBinding) IsEnabled ¶
func (keybinding *KeyBinding) IsEnabled() bool
func (*KeyBinding) IsMatch ¶
func (keybinding *KeyBinding) IsMatch(eventKey *tcell.EventKey) bool
type KeyBindingOption ¶
type KeyBindingOption func(*KeyBinding)
func WithEnabled ¶
func WithEnabled(enabled bool) KeyBindingOption
func WithFunc ¶
func WithFunc(fn func() tea.Cmd) KeyBindingOption
func WithKeyDef ¶
func WithKeyDef(keyDef KeyDef) KeyBindingOption
func WithKeyDefs ¶
func WithKeyDefs(keyDefs []KeyDef) KeyBindingOption
func WithLongHelp ¶
func WithLongHelp(longHelp string) KeyBindingOption
func WithShortHelp ¶
func WithShortHelp(shortHelp string) KeyBindingOption
type Layout ¶
type Layout struct { Orientation Orientation Dimensions []Dimension }
Layout is a struct that describes the layout of a panel
func (Layout) AreDimensionsValid ¶
func (Layout) CalculateDims ¶
Preconditions: The layout is Vertical or Horizontal Total > 0
func (Layout) IsLayoutValid ¶
type ListPanel ¶
type ListPanel struct { Panels []IPanel MsgForParent tea.Msg Layout Layout Selected int // Index of the selected panel, only used if the orientation is ZStacked 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 ¶
func (*ListPanel) GetFocusIndex ¶
func (*ListPanel) GetLeafPanelCenters ¶
func (m *ListPanel) GetLeafPanelCenters() []PanelCenter
func (*ListPanel) GetMsgForParent ¶
func (*ListPanel) GetSelected ¶
func (*ListPanel) GetSelectedIndex ¶
func (*ListPanel) HandleFocusRequestMsg ¶
func (m *ListPanel) HandleFocusRequestMsg(msg FocusRequestMsg) *FocusGrantMsg
func (*ListPanel) HandleMessage ¶
func (*ListPanel) HandleSizeMsg ¶
func (*ListPanel) HandleZStackedMsg ¶
func (*ListPanel) HandleZStackedSizeMsg ¶
func (*ListPanel) IsInHiddenTab ¶ added in v0.0.2
func (ListPanel) IsLayoutValid ¶
func (*ListPanel) SetMsgForParent ¶
func (*ListPanel) SetTabHidden ¶ added in v0.0.2
func (*ListPanel) SetView ¶
func (p *ListPanel) SetView(view *tcellviews.ViewPort)
type PanelCenter ¶
type PanelSequence ¶ added in v0.0.2
type PanelSequence struct {
// contains filtered or unexported fields
}
func NewPanelSequence ¶ added in v0.0.2
func NewPanelSequence(panels ...*ShortCutPanel) *PanelSequence
func (*PanelSequence) CreateKeyBindings ¶ added in v0.0.2
func (m *PanelSequence) CreateKeyBindings(root IMovementNode, kb *KeyBinding, rev_kb *KeyBinding)
Panel list can only create keybindings to go back and forth between the panels in the list It will leave out the entry/exit keybindings
func (*PanelSequence) First ¶ added in v0.0.2
func (m *PanelSequence) First() *ShortCutPanel
func (*PanelSequence) IsListOfPanels ¶ added in v0.0.2
func (m *PanelSequence) IsListOfPanels() bool
func (*PanelSequence) IsSelector ¶ added in v0.0.2
func (m *PanelSequence) IsSelector() bool
func (*PanelSequence) Last ¶ added in v0.0.2
func (m *PanelSequence) Last() *ShortCutPanel
func (*PanelSequence) Next ¶ added in v0.0.2
func (m *PanelSequence) Next(panel *ShortCutPanel) *ShortCutPanel
func (*PanelSequence) Previous ¶ added in v0.0.2
func (m *PanelSequence) Previous(panel *ShortCutPanel) *ShortCutPanel
type PanelStyle ¶
type RequestMsgType ¶
type RequestMsgType struct {
Msg Msg
}
type RoutedMsgType ¶
type SelectTabIndexMsg ¶
type SelectedTabIndexMsg ¶
type SelectorNode ¶ added in v0.0.2
type SelectorNode struct {
// contains filtered or unexported fields
}
func NewLoopAroundTabMap ¶ added in v0.0.2
func NewLoopAroundTabMap(chains ...IMovementNode) *SelectorNode
func NewVisibleSelectorNode ¶ added in v0.0.2
func NewVisibleSelectorNode(chains ...IMovementNode) *SelectorNode
func (*SelectorNode) CreateKeyBindings ¶ added in v0.0.2
func (m *SelectorNode) CreateKeyBindings(root IMovementNode, kb *KeyBinding, rev_kb *KeyBinding)
func (*SelectorNode) First ¶ added in v0.0.2
func (m *SelectorNode) First() *ShortCutPanel
func (*SelectorNode) IsListOfPanels ¶ added in v0.0.2
func (m *SelectorNode) IsListOfPanels() bool
func (*SelectorNode) IsSelector ¶ added in v0.0.2
func (m *SelectorNode) IsSelector() bool
func (*SelectorNode) Last ¶ added in v0.0.2
func (m *SelectorNode) Last() *ShortCutPanel
func (*SelectorNode) Next ¶ added in v0.0.2
func (m *SelectorNode) Next(panel *ShortCutPanel) *ShortCutPanel
func (*SelectorNode) Previous ¶ added in v0.0.2
func (m *SelectorNode) Previous(panel *ShortCutPanel) *ShortCutPanel
type ShortCutPanel ¶
type ShortCutPanel struct { ShortCutPanelConfig Model ILeafModel Name string MarkMessageNotUsed func(msg *KeyMsg) // contains filtered or unexported fields }
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 NewShortCutPanel ¶
func NewShortCutPanel(model ILeafModel, opts ...ShortCutPanelOption) *ShortCutPanel
func (*ShortCutPanel) AddKeyBinding ¶ added in v0.0.2
func (p *ShortCutPanel) AddKeyBinding(kb KeyBinding)
func (*ShortCutPanel) Draw ¶
func (p *ShortCutPanel) Draw(force bool) bool
func (*ShortCutPanel) DrawModelWithDraw ¶
func (p *ShortCutPanel) DrawModelWithDraw(m ILeafModelWithDraw, force bool) bool
func (*ShortCutPanel) DrawModelWithView ¶
func (p *ShortCutPanel) DrawModelWithView(m ILeafModelWithView, force bool) bool
func (*ShortCutPanel) FocusRequestCmd ¶
func (p *ShortCutPanel) FocusRequestCmd(direction Relation) tea.Cmd
func (*ShortCutPanel) GetLeafPanelCenters ¶
func (p *ShortCutPanel) GetLeafPanelCenters() []PanelCenter
func (*ShortCutPanel) GetName ¶ added in v0.0.2
func (p *ShortCutPanel) GetName() string
func (*ShortCutPanel) GetPath ¶
func (p *ShortCutPanel) GetPath() []int
func (*ShortCutPanel) HandleMessage ¶
func (p *ShortCutPanel) HandleMessage(msg Msg)
func (*ShortCutPanel) HandleMessageFromChild ¶
func (p *ShortCutPanel) HandleMessageFromChild(msg Msg) tea.Cmd
func (*ShortCutPanel) HandleSizeMsg ¶
func (p *ShortCutPanel) HandleSizeMsg(msg ResizeMsg) tea.Cmd
func (*ShortCutPanel) Init ¶
func (p *ShortCutPanel) Init(cmds chan tea.Cmd)
func (*ShortCutPanel) IsFocused ¶
func (p *ShortCutPanel) IsFocused() bool
func (*ShortCutPanel) IsInHiddenTab ¶ added in v0.0.2
func (p *ShortCutPanel) IsInHiddenTab() bool
func (*ShortCutPanel) SetPath ¶
func (p *ShortCutPanel) SetPath(path []int)
func (*ShortCutPanel) SetTabHidden ¶ added in v0.0.2
func (p *ShortCutPanel) SetTabHidden(hidden bool)
func (*ShortCutPanel) SetView ¶
func (p *ShortCutPanel) SetView(view *tcellviews.ViewPort)
type ShortCutPanelConfig ¶
type ShortCutPanelConfig struct { ContextualHelp string Title string TitleStyle lipgloss.Style PanelStyle PanelStyle KeyBindings []KeyBinding }
type ShortCutPanelOption ¶
type ShortCutPanelOption func(*ShortCutPanel)
func WithConfig ¶
func WithConfig(config ShortCutPanelConfig) ShortCutPanelOption
func WithContextualHelp ¶
func WithContextualHelp(help string) ShortCutPanelOption
func WithKeyBindingMaker ¶
func WithKeyBindingMaker(keyBindingMaker func(*ShortCutPanel) KeyBinding) ShortCutPanelOption
func WithName ¶
func WithName(name string) ShortCutPanelOption
func WithPanelStyle ¶
func WithPanelStyle(style PanelStyle) ShortCutPanelOption
func WithTitle ¶
func WithTitle(title string) ShortCutPanelOption
func WithTitleStyle ¶
func WithTitleStyle(style lipgloss.Style) ShortCutPanelOption
type TabBar ¶
type TabBar struct { ListPanel *ListPanel TabNext KeyBinding TabPrev KeyBinding TabStyles // contains filtered or unexported fields }
func NewTabBar ¶ added in v0.0.2
func NewTabBar(listPanel *ListPanel, opts ...TabBarOption) *TabBar
func (*TabBar) NeedsRedraw ¶ added in v0.0.2
type TabBarOption ¶ added in v0.0.2
type TabBarOption func(*TabBar)
func WithTabNext ¶ added in v0.0.2
func WithTabNext(tabNext KeyBinding) TabBarOption
func WithTabPrev ¶ added in v0.0.2
func WithTabPrev(tabPrev KeyBinding) TabBarOption
func WithTabStyles ¶ added in v0.0.2
func WithTabStyles(tabStyles TabStyles) TabBarOption
type TcellKeyToTeaMsgResult ¶
func MapTCellKeyToTeaMsg ¶
func MapTCellKeyToTeaMsg(ev tcell.EventKey) TcellKeyToTeaMsgResult
type TeaCmdMsgEvent ¶
func (*TeaCmdMsgEvent) When ¶
func (t *TeaCmdMsgEvent) When() time.Time
type TopLevelListPanel ¶
type TopLevelListPanel struct { *ListPanel // contains filtered or unexported fields }
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) FigureOutFocusGrant ¶
func (m *TopLevelListPanel) FigureOutFocusGrant(msg FocusRequestMsg) *FocusGrantMsg
func (*TopLevelListPanel) HandleMessage ¶
func (m *TopLevelListPanel) HandleMessage(msg Msg)
func (*TopLevelListPanel) Init ¶
func (m *TopLevelListPanel) Init(cmds chan tea.Cmd)
type UntypedMsgType ¶
type UntypedMsgType struct {
Msg Msg
}