help

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 4 Imported by: 390

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewModel = New

NewModel creates a new help view with some useful defaults.

Deprecated: use New instead.

Functions

This section is empty.

Types

type KeyMap

type KeyMap interface {

	// ShortHelp returns a slice of bindings to be displayed in the short
	// version of the help. The help bubble will render help in the order in
	// which the help items are returned here.
	ShortHelp() []key.Binding

	// FullHelp returns an extended group of help items, grouped by columns.
	// The help bubble will render the help in the order in which the help
	// items are returned here.
	FullHelp() [][]key.Binding
}

KeyMap is a map of keybindings used to generate help. Since it's an interface it can be any type, though struct or a map[string][]key.Binding are likely candidates.

Note that if a key is disabled (via key.Binding.SetEnabled) it will not be rendered in the help view, so in theory generated help should self-manage.

type Model

type Model struct {
	Width   int
	ShowAll bool // if true, render the "full" help menu

	ShortSeparator string
	FullSeparator  string

	// The symbol we use in the short help when help items have been truncated
	// due to width. Periods of ellipsis by default.
	Ellipsis string

	Styles Styles
}

Model contains the state of the help view.

func New added in v0.10.0

func New() Model

New creates a new help view with some useful defaults.

func (Model) FullHelpView

func (m Model) FullHelpView(groups [][]key.Binding) string

FullHelpView renders help columns from a slice of key binding slices. Each top level slice entry renders into a column.

func (Model) ShortHelpView

func (m Model) ShortHelpView(bindings []key.Binding) string

ShortHelpView renders a single line help view from a slice of keybindings. If the line is longer than the maximum width it will be gracefully truncated, showing only as many help items as possible.

func (Model) Update

func (m Model) Update(_ tea.Msg) (Model, tea.Cmd)

Update helps satisfy the Bubble Tea Model interface. It's a no-op.

func (Model) View

func (m Model) View(k KeyMap) string

View renders the help view's current state.

type Styles

type Styles struct {
	Ellipsis lipgloss.Style

	// Styling for the short help
	ShortKey       lipgloss.Style
	ShortDesc      lipgloss.Style
	ShortSeparator lipgloss.Style

	// Styling for the full help
	FullKey       lipgloss.Style
	FullDesc      lipgloss.Style
	FullSeparator lipgloss.Style
}

Styles is a set of available style definitions for the Help bubble.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL