Documentation
¶
Index ¶
- Variables
- type Entry
- type KeyMap
- type Model
- func (m *Model) Blur()
- func (m *Model) Debug() string
- func (m *Model) Focus()
- func (m *Model) FullHelp() [][]key.Binding
- func (m *Model) GetHeight() int
- func (m *Model) GetMaxHeight() int
- func (m *Model) Init() tea.Cmd
- func (m *Model) MatchesKey(msg tea.KeyPressMsg) bool
- func (m *Model) SetHeight(height int)
- func (m *Model) SetValues(values Values)
- func (m *Model) SetWidth(width int)
- func (m *Model) ShortHelp() []key.Binding
- func (m *Model) Update(imsg tea.Msg) (*Model, tea.Cmd)
- func (m *Model) View() string
- type Styles
- type Values
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyMap = KeyMap{ KeyMap: list.KeyMap{ CursorUp: key.NewBinding(key.WithKeys("up", "ctrl+p", "shift+tab"), key.WithHelp("C-p/↑", "prev entry")), CursorDown: key.NewBinding(key.WithKeys("down", "ctrl+n", "tab"), key.WithHelp("C-n/↓", "next entry")), NextPage: key.NewBinding(key.WithKeys("pgdown"), key.WithHelp("pgdown", "prev page/column")), PrevPage: key.NewBinding(key.WithKeys("pgup"), key.WithHelp("pgup", "next page/column")), GoToStart: key.NewBinding(key.WithKeys("ctrl+a", "home"), key.WithHelp("C-a/home", "start of column")), GoToEnd: key.NewBinding(key.WithKeys("ctrl+e", "end"), key.WithHelp("C-e/end", "end of column")), Filter: key.NewBinding(key.WithKeys("/", ""), key.WithHelp("/", "filter")), ClearFilter: key.NewBinding(key.WithKeys("ctrl+g"), key.WithHelp("C-g", "clear/cancel")), CancelWhileFiltering: key.NewBinding(key.WithKeys("ctrl+g"), key.WithHelp("C-g", "clear/cancel")), AcceptWhileFiltering: key.NewBinding(key.WithKeys("enter", "ctrl+j"), key.WithHelp("C-j/enter", "accept filter")), ShowFullHelp: key.NewBinding(key.WithKeys("alt+?"), key.WithHelp("M-?", "toggle key help")), CloseFullHelp: key.NewBinding(key.WithKeys("alt+?"), key.WithHelp("M-?", "toggle key help")), }, NextCompletions: key.NewBinding(key.WithKeys("right", "alt+n"), key.WithHelp("→/M-n", "next column")), PrevCompletions: key.NewBinding(key.WithKeys("left", "alt+p"), key.WithHelp("←/M-p", "prev column")), AcceptCompletion: key.NewBinding(key.WithKeys("enter", "ctrl+j"), key.WithHelp("C-j/enter/tab", "accept")), Abort: key.NewBinding(key.WithKeys("ctrl+c", "esc"), key.WithHelp("C-c/esc", "close/cancel")), }
DefaultKeyMap is the default set of key bindings.
var DefaultStyles = func() (c Styles) { ls := list.DefaultStyles(true) subtle := lipgloss.Color("#D9DCCF") c.Item = lipgloss.NewStyle().PaddingLeft(1) c.SelectedItem = lipgloss.NewStyle().PaddingLeft(1).Foreground(lipgloss.Color("170")) c.FocusedTitleBar = lipgloss.NewStyle() c.BlurredTitleBar = lipgloss.NewStyle() c.FocusedTitle = lipgloss.NewStyle().Background(lipgloss.Color("62")).Foreground(lipgloss.Color("230")) c.BlurredTitle = c.FocusedTitle.Foreground(subtle) c.Spinner = ls.Spinner c.FilterPrompt = lipgloss.NewStyle() c.FilterCursor = lipgloss.NewStyle() c.PaginationStyle = lipgloss.NewStyle() c.DefaultFilterCharacterMatch = ls.DefaultFilterCharacterMatch c.ActivePaginationDot = ls.ActivePaginationDot c.InactivePaginationDot = ls.InactivePaginationDot c.ArabicPagination = ls.ArabicPagination c.DividerDot = ls.DividerDot c.Description = lipgloss.NewStyle().Bold(true) c.PlaceholderDescription = lipgloss.NewStyle().Foreground(lipgloss.Color("240")) return c }()
DefaultStyles returns a set of default style definitions for the completions component.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry interface {
// Title is the main displayed text.
Title() string
// Description is the explanation for the entry.
Description() string
// SidePanel returns optional content to display in a side panel.
// If empty, no side panel is shown.
SidePanel() string
}
Entry is the interface to one completion candidate.
func StringEntry ¶
StringEntry adds the Entry interface to a simple string. Its description part is empty.
type KeyMap ¶
type KeyMap struct {
list.KeyMap
NextCompletions key.Binding
PrevCompletions key.Binding
AcceptCompletion key.Binding
Abort key.Binding
}
KeyMap defines keybindings for navigating the completions.
type Model ¶
type Model struct {
Err error
// KeyMap is the key bindings for navigating the completions.
KeyMap KeyMap
// Styles is the styles to use for display.
Styles Styles
// AcceptedValue is the result of the selection.
AcceptedValue Entry
// contains filtered or unexported fields
}
Model is the model that implements the completion selector widget.
func (*Model) GetMaxHeight ¶
GetHeight retrieves the maximum height.
func (*Model) MatchesKey ¶
func (m *Model) MatchesKey(msg tea.KeyPressMsg) bool
MatchesKeys returns true when the completion editor can use the given key message.
type Styles ¶
type Styles struct {
FocusedTitleBar lipgloss.Style
FocusedTitle lipgloss.Style
BlurredTitleBar lipgloss.Style
BlurredTitle lipgloss.Style
Item lipgloss.Style
SelectedItem lipgloss.Style
Spinner lipgloss.Style
FilterPrompt lipgloss.Style
FilterCursor lipgloss.Style
PaginationStyle lipgloss.Style
DefaultFilterCharacterMatch lipgloss.Style
ActivePaginationDot lipgloss.Style
InactivePaginationDot lipgloss.Style
ArabicPagination lipgloss.Style
DividerDot lipgloss.Style
PlaceholderDescription lipgloss.Style
Description lipgloss.Style
SidePanel lipgloss.Style
SidePanelTitle lipgloss.Style
}
Styles contain style definitions for the completions component.
type Values ¶
type Values interface {
// NumCategories returns the number of categories to display.
NumCategories() int
// CategoryTitle returns the title of a category.
CategoryTitle(catIdx int) string
// NumEntries returns the number of entries in a given category.
NumEntries(catIdx int) int
// Entry returns the entry in a category.
Entry(catIdx, entryIdx int) Entry
}
Values is the interface to the values displayed by the completion bubble.
func MapValues ¶
MapValues adds the Values interface to a map of entries.
In go 1.18, this function would be:
func MapValues[T Entry](values map[string][]T, categories []string)
Each of the map values should be a slice of objects implementing the Entry interface.
The categories string slice, if provided, selects a specific order for the categories. If nil is specified, the map keys are used in sorted order.
func StringValues ¶
StringValues adds the Values interface to a simple string slice. There is just one category.