selector

package
v0.0.0-...-cb7a572 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package selector is a terminal single-selection list library. selector library provides the functions of page up and down and key movement, and supports custom rendering methods.

Index

Constants

View Source
const (
	DefaultHeader   = "Use the arrow keys to navigate: ↓ ↑ → ←"
	DefaultFooter   = "Current page number details: %d/%d"
	DefaultCursor   = "»"
	DefaultFinished = "Current selected: %s\n"

	ColorHeader     = "15"
	ColorFooter     = "15"
	ColorCursor     = "2"
	ColorFinished   = "2"
	ColorSelected   = "14"
	ColorUnSelected = "8"
)

Variables

This section is empty.

Functions

func DefaultHeaderFuncWithAppend

func DefaultHeaderFuncWithAppend(append string) func(m Model, obj interface{}, gdIndex int) string

DefaultHeaderFuncWithAppend return the default HeaderFunc and append the given string to the next line of the default header

func DefaultSelectedFuncWithIndex

func DefaultSelectedFuncWithIndex(indexFormat string) func(m Model, obj interface{}, gdIndex int) string

DefaultSelectedFuncWithIndex return the default SelectedFunc and adds the serial number prefix of the given format

func DefaultUnSelectedFuncWithIndex

func DefaultUnSelectedFuncWithIndex(indexFormat string) func(m Model, obj interface{}, gdIndex int) string

DefaultUnSelectedFuncWithIndex return the default UnSelectedFunc and adds the serial number prefix of the given format

Types

type Model

type Model struct {
	// HeaderFunc Header rendering function
	HeaderFunc func(m Model, obj interface{}, gdIndex int) string
	// Cursor cursor rendering style
	Cursor string
	// CursorColor cursor rendering color
	CursorColor string
	// SelectedFunc selected data rendering function
	SelectedFunc func(m Model, obj interface{}, gdIndex int) string
	// UnSelectedFunc unselected data rendering function
	UnSelectedFunc func(m Model, obj interface{}, gdIndex int) string
	// FooterFunc footer rendering function
	FooterFunc func(m Model, obj interface{}, gdIndex int) string
	// FinishedFunc finished rendering function
	FinishedFunc func(selected interface{}) string
	// PerPage data count per page
	PerPage int
	// Data the data set to be rendered
	Data []interface{}
	// contains filtered or unexported fields
}

Model is a data container used to store TUI status information, the ui rendering success style is as follows:

Use the arrow keys to navigate: ↓ ↑ → ←
Select Commit Type:

» [1] feat (Introducing new features)
   2. fix (Bug fix)
   3. docs (Writing docs)
   4. style (Improving structure/format of the code)
   5. refactor (Refactoring code)

--------- Commit Type ----------
Type: feat
Description: 新功能(Introducing new features)

func (Model) Canceled

func (m Model) Canceled() bool

Canceled determine whether the operation is cancelled

func (Model) Index

func (m Model) Index() int

Index return the global real time index

func (Model) PageData

func (m Model) PageData() []interface{}

PageData return the current page data area slice

func (Model) PageIndex

func (m Model) PageIndex() int

PageIndex return the real time index of the page

func (Model) Selected

func (m Model) Selected() interface{}

Selected return the currently selected data

func (*Model) Update

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

Update method responds to various events and modifies the data model according to the corresponding events

func (Model) View

func (m Model) View() string

View reads the data state of the data model for rendering

Jump to

Keyboard shortcuts

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