term

package
v3.0.0-...-606b3c3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Build = 1
	Major = 0
	Minor = 5
)

Variables

View Source
var (
	// DefaultInteractiveMultiselect is the default InteractiveMultiselect printer.
	DefaultInteractiveMultiselect = InteractiveMultiselectPrinter{
		TextStyle:      &pterm.ThemeDefault.PrimaryStyle,
		DefaultText:    "Please select your options",
		Options:        []string{},
		OptionStyle:    &pterm.ThemeDefault.DefaultText,
		DefaultOptions: []string{},
		MaxHeight:      5,
		Selector:       ">",
		SelectorStyle:  &pterm.ThemeDefault.SecondaryStyle,
		Filter:         true,
		KeySelect:      keys.Space,
		KeyConfirm:     keys.Enter,
		Up:             'w',
		Down:           's',
		Left:           'a',
		Right:          'd',
		Checkmark:      &pterm.ThemeDefault.Checkmark,
	}
)
View Source
var (
	// DefaultInteractiveSelect is the default InteractiveSelect printer.
	DefaultInteractiveSelect = InteractiveSelectPrinter{
		TextStyle:     &pterm.ThemeDefault.PrimaryStyle,
		DefaultText:   "Please select an option",
		Options:       []string{},
		OptionStyle:   &pterm.ThemeDefault.DefaultText,
		DefaultOption: "",
		MaxHeight:     5,
		Selector:      ">",
		SelectorStyle: &pterm.ThemeDefault.SecondaryStyle,
		Filter:        true,
		Up:            'w',
		Down:          's',
	}
)
View Source
var IsWindows10 = true
View Source
var Logger *pterm.Logger
View Source
var TermOut = new(Termout)

Functions

func BoxPrintln

func BoxPrintln(a ...interface{})

func GoENERGY

func GoENERGY()

func NewCancelationSignal

func NewCancelationSignal(interruptFunc func()) (func(), func())

NewCancelationSignal for keeping track of a cancelation

func Println

func Println(a ...interface{})

func TextInputWith

func TextInputWith(text, delimiter string) string

func WithBoolean

func WithBoolean(b []bool) bool

WithBoolean helps an option setter (WithXXX(b ...bool) to return true, if no boolean is set, but false if it's explicitly set to false.

Types

type InteractiveMultiselectPrinter

type InteractiveMultiselectPrinter struct {
	DefaultText     string
	TextStyle       *pterm.Style
	Options         []string
	OptionStyle     *pterm.Style
	DefaultOptions  []string
	MaxHeight       int
	Selector        string
	SelectorStyle   *pterm.Style
	Filter          bool
	Checkmark       *pterm.Checkmark
	OnInterruptFunc func()

	// KeySelect is the select key. It cannot be keys.Space when Filter is enabled.
	KeySelect keys.KeyCode

	// KeyConfirm is the confirm key. It cannot be keys.Space when Filter is enabled.
	KeyConfirm keys.KeyCode

	// 自定义上下左右选择键
	Up    keys.KeyCode
	Down  keys.KeyCode
	Left  keys.KeyCode
	Right keys.KeyCode
	// contains filtered or unexported fields
}

InteractiveMultiselectPrinter is a printer for interactive multiselect menus.

func (*InteractiveMultiselectPrinter) CheckmarkANSI

func (p *InteractiveMultiselectPrinter) CheckmarkANSI()

func (*InteractiveMultiselectPrinter) Show

func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)

Show shows the interactive multiselect menu and returns the selected entry.

func (InteractiveMultiselectPrinter) WithCheckmark

WithCheckmark sets the checkmark

func (InteractiveMultiselectPrinter) WithDefaultOptions

func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter

WithDefaultOptions sets the default options.

func (InteractiveMultiselectPrinter) WithDefaultText

WithDefaultText sets the default text.

func (InteractiveMultiselectPrinter) WithFilter

WithFilter sets the Filter option

func (InteractiveMultiselectPrinter) WithKeyConfirm

WithKeyConfirm sets the confirm key It cannot be keys.Space when Filter is enabled.

func (InteractiveMultiselectPrinter) WithKeySelect

WithKeySelect sets the confirm key It cannot be keys.Space when Filter is enabled.

func (InteractiveMultiselectPrinter) WithMaxHeight

WithMaxHeight sets the maximum height of the select menu.

func (InteractiveMultiselectPrinter) WithOnInterruptFunc

func (p InteractiveMultiselectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveMultiselectPrinter

OnInterrupt sets the function to execute on exit of the input reader

func (InteractiveMultiselectPrinter) WithOptions

WithOptions sets the options.

type InteractiveSelectPrinter

type InteractiveSelectPrinter struct {
	TextStyle       *pterm.Style
	DefaultText     string
	Options         []string
	OptionStyle     *pterm.Style
	DefaultOption   string
	MaxHeight       int
	Selector        string
	SelectorStyle   *pterm.Style
	OnInterruptFunc func()
	Filter          bool

	// 自定义上下选择键
	Up   keys.KeyCode
	Down keys.KeyCode
	// contains filtered or unexported fields
}

InteractiveSelectPrinter is a printer for interactive select menus.

func (*InteractiveSelectPrinter) CheckmarkANSI

func (p *InteractiveSelectPrinter) CheckmarkANSI()

func (*InteractiveSelectPrinter) Show

func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)

Show shows the interactive select menu and returns the selected entry.

func (InteractiveSelectPrinter) WithDefaultOption

func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter

WithDefaultOption sets the default options.

func (InteractiveSelectPrinter) WithDefaultText

func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter

WithDefaultText sets the default text.

func (InteractiveSelectPrinter) WithFilter

WithFilter sets the Filter option

func (InteractiveSelectPrinter) WithMaxHeight

func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter

WithMaxHeight sets the maximum height of the select menu.

func (InteractiveSelectPrinter) WithOnInterruptFunc

func (p InteractiveSelectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveSelectPrinter

OnInterrupt sets the function to execute on exit of the input reader

func (InteractiveSelectPrinter) WithOptions

func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter

WithOptions sets the options.

type Termout

type Termout struct {
}

func (*Termout) Write

func (m *Termout) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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