groupedlist

package
v0.0.0-...-a02a1e0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group[T any] struct {
	Name  string
	Items []T
}

type Model

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

func New

func New[T any](opts ...Option[T]) *Model[T]

func (*Model[T]) Blur

func (m *Model[T]) Blur() *Model[T]

func (*Model[T]) Focus

func (m *Model[T]) Focus() *Model[T]

func (Model[T]) Focused

func (m Model[T]) Focused() bool

func (*Model[T]) Height

func (m *Model[T]) Height(i int) *Model[T]

func (*Model[T]) MoveDown

func (m *Model[T]) MoveDown(n int)

func (*Model[T]) MoveUp

func (m *Model[T]) MoveUp(n int)

func (Model[T]) Selected

func (m Model[T]) Selected() *T

func (*Model[T]) SetGroups

func (m *Model[T]) SetGroups(groups []Group[T])

func (Model[T]) View

func (m Model[T]) View() string

func (*Model[T]) Width

func (m *Model[T]) Width(i int) *Model[T]

type Option

type Option[T any] func(*Model[T])

func WithRenderers

func WithRenderers[T any](renderers Renderers[T]) Option[T]

type Renderers

type Renderers[T any] struct {
	Header   func(string, int) string
	Footer   func(string, int) string
	Item     func(T, int) string
	Selected func(T, int) string
}

For each group in the list the following occurs:

  1. Header is rendered
  2. Each item is rendered with item or selected depending on if it is the cursor
  3. Footer is rendered

If you don't want a header or footer, leave the function nil. If there are no items in the group it is skipped entirely.

Jump to

Keyboard shortcuts

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