Skip to main content

API

suggestion

import "github.com/aschey/bubbleprompt/suggestion"

Index

Variables

var (
DefaultNameForeground = "243"
DefaultNameBackground = "7"
DefaultSelectedNameForeground = "8"
DefaultSelectedNameBackground = "14"
)
var (
DefaultDescriptionForeground = "255"
DefaultDescriptionBackground = "245"
DefaultSelectedDescriptionForeground = "0"
DefaultSelectedDescriptionBackground = "6"
DefaultErrorTextBackground = "1"
)
var (
DefaultScrollbarColor = "251"
DefaultScrollbarThumbColor = "255"
)
var DefaultIndicatorForeground = "8"

func Complete

func Complete() tea.Msg

func OneShotCompleter

func OneShotCompleter(nextTrigger time.Duration) tea.Cmd

func PeriodicCompleter

func PeriodicCompleter(nextTrigger time.Duration) tea.Cmd

func RefreshSuggestions

func RefreshSuggestions[T any](init func() []Suggestion[T]) tea.Cmd

type CompleteMsg

type CompleteMsg struct{}

type Formatters

type Formatters struct {
Name SuggestionText
Description SuggestionText
ErrorText lipgloss.Style
SelectedIndicator lipgloss.Style
Scrollbar lipgloss.Style
ScrollbarThumb lipgloss.Style
Suggestions lipgloss.Style
}

func DefaultFormatters

func DefaultFormatters() Formatters

func (Formatters) Minimal

func (f Formatters) Minimal() Formatters

type Manager

type Manager[T any] interface {
Init() tea.Cmd
Update(msg tea.Msg) tea.Cmd
SetMaxSuggestions(maxSuggestions int)
MaxSuggestions() int
SetSelectionIndicator(selectionIndicator string)
SelectionIndicator() string
EnableScrollbar()
DisableScrollbar()
SelectedSuggestion() *Suggestion[T]
SelectedIndex() int
Suggestions() []Suggestion[T]
VisibleSuggestions() []Suggestion[T]
MaxSuggestionWidth() (int, int)
SelectSuggestion(suggestion Suggestion[T])
UnselectSuggestion()
IsSuggestionSelected() bool
PreviousSuggestion()
NextSuggestion()
UpdateSuggestions() tea.Cmd
ResetSuggestions() tea.Cmd
ClearSuggestions()
Error() error
ScrollbarBounds() (int, int)
ScrollPosition() int
Scrollbar() string
ScrollbarThumb() string
Render(paddingSize int) string
ShouldChangeListPosition(msg tea.Msg) bool
Formatters() Formatters
SetFormatters(formatters Formatters)
SetShowSuggestions(showSuggestions bool)
}

type OneShotCompleterMsg

type OneShotCompleterMsg struct{}

type PeriodicCompleterMsg

type PeriodicCompleterMsg struct {
NextTrigger time.Duration
}

type RefreshSuggestionsMessage

type RefreshSuggestionsMessage[T any] []Suggestion[T]

type Suggestion

type Suggestion[T any] struct {
Text string
SuggestionText string
Description string
Metadata T
CursorOffset int
}

func (Suggestion[T]) GetSuggestionText

func (s Suggestion[T]) GetSuggestionText() string

func (Suggestion[T]) Key

func (s Suggestion[T]) Key() *string

func (Suggestion[T]) Render

func (s Suggestion[T]) Render(selected bool, maxNameLen int, maxDescLen int, formatters Formatters, scrollbar string, indicator string) string

type SuggestionMsg

type SuggestionMsg[T any] struct {
Suggestions []Suggestion[T]
SequenceNumber int
Err error
}

type SuggestionText

type SuggestionText struct {
Style lipgloss.Style
SelectedStyle lipgloss.Style
}

func (SuggestionText) Format

func (t SuggestionText) Format(text string, maxLen int, selected bool) string

func (SuggestionText) HasBackground

func (t SuggestionText) HasBackground() bool

Generated by gomarkdoc