Documentation
¶
Overview ¶
Package bubblehelp is a manager to help render, contextualize and manage keybinds for bubbletea.
Index ¶
- Variables
- func Init()
- func IsKeybindVisible(keybind key.Binding) bool
- func RegisterContext(context KeymapContext, keymap *Keymap)
- func SetDefaultStyle(style Style)
- func SetKeybindVisible(keybind key.Binding, visible bool)
- func SwitchContext(context KeymapContext)
- func SwitchToPreviousContext()
- func UpdateKeybindHelpDesc(keybind key.Binding, desc string)
- func View(width int) string
- func ViewAll(keymap *Keymap, width int) string
- func ViewEssential(keymap *Keymap, width int) string
- type Key
- type Keymap
- type KeymapContext
- type Style
Constants ¶
This section is empty.
Variables ¶
var ( // CurrentContext holds the current context identifier. CurrentContext KeymapContext // Contexts map of single every registered contexts. Contexts map[KeymapContext]*Keymap // ShowAll is the flag to define whether it's the full or short help that will be rendered. ShowAll bool )
Functions ¶
func IsKeybindVisible ¶
IsKeybindVisible returns the current visibility of a Keybind. If the Keybind do not exist in the current context, returns false.
func RegisterContext ¶
func RegisterContext(context KeymapContext, keymap *Keymap)
RegisterContext allows to register a new Keymap context and link it with the given identifier.
func SetDefaultStyle ¶ added in v1.0.2
func SetDefaultStyle(style Style)
func SetKeybindVisible ¶
SetKeybindVisible allows to set keybinds visibility in the current Keymap context.
func SwitchContext ¶
func SwitchContext(context KeymapContext)
SwitchContext take care of properly changing context. Resets the current context before switching.
func SwitchToPreviousContext ¶ added in v1.0.1
func SwitchToPreviousContext()
func UpdateKeybindHelpDesc ¶
UpdateKeybindHelpDesc allows to temporary change the help description for a keybind in the current Keymap context.
func View ¶
View is the main render function of bubblehelp. Take the ShowAll flag into account to render full or short help.
func ViewEssential ¶
ViewEssential is the short help render function, can be called directly
Types ¶
type Key ¶
Key describes a single keybind in bubblehelp.
func (*Key) GetHelpDesc ¶
GetHelpDesc returns the current help description for the Key. Returns the temporary CustomHelpDesc first.
type Keymap ¶
Keymap describes a keymap context inside bubblehelp. Each context can have its own Style definition
func GetCurrentContextKeymap ¶
func GetCurrentContextKeymap() *Keymap
GetCurrentContextKeymap returns a pointer on the current Keymap context.
func NewKeymap ¶
NewKeymap helps initialize a new context with default style and given column count for full help rendering. showAllColCount parameters allows definition of the columns of the full help rendering.
func (*Keymap) AllBindings ¶
AllBindings returns every single binding of the Keymap context.
func (*Keymap) EssentialBindings ¶
EssentialBindings returns the slice of all essential binding of the Keymap context.
func (*Keymap) NewKeyBinding ¶
NewKeyBinding registers a new key.Binding to the Keymap context. essential parameter allows to define if the key should appear on the short help or only in full help.
type KeymapContext ¶
type KeymapContext string
KeymapContext is a special type used inside bubblehelp to serve as a unique identifier for different contexts.
type Style ¶
type Style struct {
EssentialKey lipgloss.Style
EssentialKeyDescription lipgloss.Style
EssentialKeySeparator lipgloss.Style
EssentialKeySeparatorValue string
EssentialColSeparator lipgloss.Style
EssentialColSeparatorValue string
FullKey lipgloss.Style
FullKeyDescription lipgloss.Style
FullKeySeparator lipgloss.Style
FullKeySeparatorValue string
FullColSeparator lipgloss.Style
FullColSeparatorValue string
}
Style describes every rendering aspect of bubblehelp.