selector

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Selector

type Selector[T any] struct {
	// contains filtered or unexported fields
}

Selector is a helper type for selecting items.

func NewSelector

func NewSelector[T any](items []T) *Selector[T]

NewSelector creates a new item selector.

func (*Selector[T]) Append

func (s *Selector[T]) Append(item T)

Append adds an item to the selector.

func (*Selector[T]) Get

func (s *Selector[T]) Get(i int) T

Get returns the item at the given index.

func (*Selector[T]) Index

func (s *Selector[T]) Index() int

Index returns the index of the current selected item.

func (*Selector[T]) Next

func (s *Selector[T]) Next()

Next moves the selector to the next item.

func (*Selector[T]) OnFirst

func (s *Selector[T]) OnFirst() bool

OnFirst returns true if the selector is on the first item.

func (*Selector[T]) OnLast

func (s *Selector[T]) OnLast() bool

OnLast returns true if the selector is on the last item.

func (*Selector[T]) Prev

func (s *Selector[T]) Prev()

Prev moves the selector to the previous item.

func (*Selector[T]) Range

func (s *Selector[T]) Range(f func(i int, item T) bool)

Range iterates over the items. The callback function should return true to continue the iteration.

func (*Selector[T]) ReverseRange

func (s *Selector[T]) ReverseRange(f func(i int, item T) bool)

ReverseRange iterates over the items in reverse. The callback function should return true to continue the iteration.

func (*Selector[T]) Selected

func (s *Selector[T]) Selected() T

Selected returns the index of the current selected item.

func (*Selector[T]) Set

func (s *Selector[T]) Set(i int, item T)

Set sets the item at the given index.

func (*Selector[T]) SetIndex

func (s *Selector[T]) SetIndex(i int)

SetIndex sets the selected item.

func (*Selector[T]) Total

func (s *Selector[T]) Total() int

Totoal returns the total number of items.

Jump to

Keyboard shortcuts

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