promptui: github.com/manifoldco/promptui/list Index | Files

package list

import "github.com/manifoldco/promptui/list"

Index

Package Files

list.go

Constants

const NotFound = -1

NotFound is an index returned when no item was selected. This could happen due to a search without results.

type List Uses

type List struct {
    Searcher Searcher
    // contains filtered or unexported fields
}

List holds a collection of items that can be displayed with an N number of visible items. The list can be moved up, down by one item of time or an entire page (ie: visible size). It keeps track of the current selected item.

func New Uses

func New(items interface{}, size int) (*List, error)

New creates and initializes a list of searchable items. The items attribute must be a slice type with a size greater than 0. Error will be returned if those two conditions are not met.

func (*List) CanPageDown Uses

func (l *List) CanPageDown() bool

CanPageDown returns whether a list can still PageDown().

func (*List) CanPageUp Uses

func (l *List) CanPageUp() bool

CanPageUp returns whether a list can still PageUp().

func (*List) CancelSearch Uses

func (l *List) CancelSearch()

CancelSearch stops the current search and returns the list to its original order.

func (*List) Index Uses

func (l *List) Index() int

Index returns the index of the item currently selected inside the searched list. If no item is selected, the NotFound (-1) index is returned.

func (*List) Items Uses

func (l *List) Items() ([]interface{}, int)

Items returns a slice equal to the size of the list with the current visible items and the index of the active item in this list.

func (*List) Next Uses

func (l *List) Next()

Next moves the visible list forward one item. If the selected item is out of view, the new select item becomes the first visible item. If the list is already at the bottom, nothing happens.

func (*List) PageDown Uses

func (l *List) PageDown()

PageDown moves the visible list forward by x items. Where x is the size of the visible items on the list. The selected item becomes the first visible item.

func (*List) PageUp Uses

func (l *List) PageUp()

PageUp moves the visible list backward by x items. Where x is the size of the visible items on the list. The selected item becomes the first visible item. If the list is already at the bottom, the selected item becomes the last visible item.

func (*List) Prev Uses

func (l *List) Prev()

Prev moves the visible list back one item. If the selected item is out of view, the new select item becomes the last visible item. If the list is already at the top, nothing happens.

func (*List) Search Uses

func (l *List) Search(term string)

Search allows the list to be filtered by a given term. The list must implement the searcher function signature for this functionality to work.

func (*List) SetCursor Uses

func (l *List) SetCursor(i int)

SetCursor sets the position of the cursor in the list. Values out of bounds will be clamped.

func (*List) SetStart Uses

func (l *List) SetStart(i int)

SetStart sets the current scroll position. Values out of bounds will be clamped.

func (*List) Start Uses

func (l *List) Start() int

Start returns the current render start position of the list.

type Searcher Uses

type Searcher func(input string, index int) bool

Searcher is a base function signature that is used inside select when activating the search mode. If defined, it is called on each items of the select and should return a boolean for whether or not the item fits the searched term.

Package list imports 3 packages (graph) and is imported by 3 packages. Updated 2019-02-06. Refresh now. Tools for package owners.