suggestion

package
v0.0.0-...-ea2a2fb Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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

Types

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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