tui

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMultiSelectKeyMap = MultiSelectKeyMap{
	Prev: key.NewBinding(
		key.WithKeys("up", "k"),
		key.WithHelp("↑/k", "move up"),
	),
	Next: key.NewBinding(
		key.WithKeys("down", "j", "tab"),
		key.WithHelp("↓/j/tab", "move down"),
	),
	Select: key.NewBinding(
		key.WithKeys(" "),
		key.WithHelp("space", "select"),
	),
	Confirm: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "confirm"),
	),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "toggle help"),
	),
	Quit: key.NewBinding(
		key.WithKeys("q", "esc", "ctrl+c"),
		key.WithHelp("q", "quit"),
	),
}
View Source
var DefaultSingleSelectKeyMap = SingleSelectKeyMap{
	Prev: key.NewBinding(
		key.WithKeys("up", "k"),
		key.WithHelp("↑/k", "move up"),
	),
	Next: key.NewBinding(
		key.WithKeys("down", "j", "tab"),
		key.WithHelp("↓/j/tab", "move down"),
	),
	Confirm: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "confirm"),
	),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "toggle help"),
	),
	Quit: key.NewBinding(
		key.WithKeys("q", "esc", "ctrl+c"),
		key.WithHelp("q", "quit"),
	),
}
View Source
var (
	ErrQuit = errors.New("user exited prompt")
)

Functions

func ListBranches

func ListBranches(branches []*git.Branch) error

Types

type Item added in v0.4.0

type Item struct {
	Name     string
	Note     string
	Selected bool
}

func ItemsFromBranches added in v0.4.0

func ItemsFromBranches(branches []*git.Branch) ([]*Item, error)

func NewItemFromBranch added in v0.4.0

func NewItemFromBranch(branch *git.Branch) (*Item, error)

func RunMultiSelect added in v0.4.0

func RunMultiSelect(items []*Item) ([]*Item, error)

func RunSingleSelect added in v0.4.0

func RunSingleSelect(items []*Item) (*Item, error)

type MultiSelectKeyMap

type MultiSelectKeyMap struct {
	Prev    key.Binding
	Next    key.Binding
	Select  key.Binding
	Confirm key.Binding
	Help    key.Binding
	Quit    key.Binding
}

func (MultiSelectKeyMap) FullHelp

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

func (MultiSelectKeyMap) ShortHelp

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

type MultiSelectModel added in v0.4.0

type MultiSelectModel struct {
	// contains filtered or unexported fields
}

func NewMultiSelectModel added in v0.4.0

func NewMultiSelectModel(items []*Item) *MultiSelectModel

func (*MultiSelectModel) Error added in v0.4.0

func (m *MultiSelectModel) Error() error

func (*MultiSelectModel) Init added in v0.4.0

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

func (*MultiSelectModel) SelectedItems added in v0.4.0

func (m *MultiSelectModel) SelectedItems() []*Item

func (*MultiSelectModel) Update added in v0.4.0

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

func (*MultiSelectModel) View added in v0.4.0

func (m *MultiSelectModel) View() string

type RenderItemFunc added in v0.4.0

type RenderItemFunc func(item *Item, hovered bool) string

type SelectModel added in v0.4.0

type SelectModel struct {
	// contains filtered or unexported fields
}

func NewSingleSelectModel added in v0.4.0

func NewSingleSelectModel(items []*Item) *SelectModel

func (*SelectModel) Error added in v0.4.0

func (m *SelectModel) Error() error

func (*SelectModel) Init added in v0.4.0

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

func (*SelectModel) SelectedItem added in v0.4.0

func (m *SelectModel) SelectedItem() *Item

func (*SelectModel) Update added in v0.4.0

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

func (*SelectModel) View added in v0.4.0

func (m *SelectModel) View() string

type SingleSelectKeyMap

type SingleSelectKeyMap struct {
	Prev    key.Binding
	Next    key.Binding
	Confirm key.Binding
	Help    key.Binding
	Quit    key.Binding
}

func (SingleSelectKeyMap) FullHelp

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

func (SingleSelectKeyMap) ShortHelp

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

Jump to

Keyboard shortcuts

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