selection

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = KeyMap{
	SelectionUp: key.NewBinding(
		key.WithKeys("k", tea.KeyUp.String()),
		key.WithHelp("↑/k", "move up"),
	),
	SelectionDown: key.NewBinding(
		key.WithKeys("j", tea.KeyDown.String()),
		key.WithHelp("↓/j", "move down"),
	),
	PagePrev: key.NewBinding(
		key.WithKeys("h", tea.KeyLeft.String()),
		key.WithHelp("←/h", "prev page"),
	),
	PageNext: key.NewBinding(
		key.WithKeys("l", tea.KeyRight.String()),
		key.WithHelp("→/l", "next page"),
	),
	Quit: key.NewBinding(
		key.WithKeys("q", tea.KeyEsc.String(), tea.KeyCtrlC.String()),
		key.WithHelp("q", "quit"),
	),
	Select: key.NewBinding(
		key.WithKeys(tea.KeySpace.String()),
		key.WithHelp("space", "select"),
	),
	Enter: key.NewBinding(key.WithKeys(tea.KeyEnter.String())),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "toggle help"),
	),
}

Functions

This section is empty.

Types

type KeyMap

type KeyMap struct {
	SelectionUp   key.Binding
	SelectionDown key.Binding
	PageNext      key.Binding
	PagePrev      key.Binding
	Quit          key.Binding
	Select        key.Binding
	Help          key.Binding
	Enter         key.Binding
}

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view. It's part of the key.Map interface.

type Model

type Model struct {
	PromptPrefix      string
	Prompt            string
	SelectedIndicator rune
	ChooserIndicator  rune
	Styles            Styles
	Choices           []string
	KeyMap            KeyMap
	MaxSelections     int
	HideHelp          bool
	PerPage           int
	// contains filtered or unexported fields
}

Model represents the bubble tea model for the selection

func New

func New() Model

New creates a new model with default settings.

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) SelectedIndexes

func (m *Model) SelectedIndexes() []int

func (*Model) SelectedValues

func (m *Model) SelectedValues() []string

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Model) View

func (m *Model) View() string

type Styles

type Styles struct {
	PromptPrefix      lipgloss.Style
	Prompt            lipgloss.Style
	Text              lipgloss.Style
	SelectedIndicator lipgloss.Style
	ChooserIndicator  lipgloss.Style
}

Styles holds relevant styles used for rendering

Jump to

Keyboard shortcuts

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