tui

package
v0.0.0-...-27d5cd9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInteractive = errors.New("not interactive session")

ErrNotInteractive is returned when the user is not in an interactive session.

Functions

This section is empty.

Types

type BubbleProgress

type BubbleProgress struct {
	output.InputOutput
	Message
	TotalSize  int
	FinalPause time.Duration
	// contains filtered or unexported fields
}

func (*BubbleProgress) Error

func (b *BubbleProgress) Error(err error)

func (*BubbleProgress) Init

func (b *BubbleProgress) Init() tea.Cmd

func (*BubbleProgress) Update

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

func (*BubbleProgress) View

func (b *BubbleProgress) View() string

func (*BubbleProgress) With

func (b *BubbleProgress) With(fn func(ProgressControl) error) error

func (*BubbleProgress) Write

func (b *BubbleProgress) Write(bytes []byte) (int, error)

type BubbleSpinner

type BubbleSpinner struct {
	output.InputOutput
	Message
	// contains filtered or unexported fields
}

func (*BubbleSpinner) Init

func (b *BubbleSpinner) Init() tea.Cmd

func (*BubbleSpinner) Update

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

func (*BubbleSpinner) View

func (b *BubbleSpinner) View() string

func (*BubbleSpinner) With

func (b *BubbleSpinner) With(fn func(Spinner) error) error

type Chooser

type Chooser[T any] interface {
	Choose(options []T, format string, a ...any) T
}

func NewChooser

func NewChooser[T any](iw *InteractiveWidgets) Chooser[T]

NewChooser returns a new Chooser.

type InteractiveWidgets

type InteractiveWidgets struct {
	// contains filtered or unexported fields
}

func NewInteractiveWidgets

func NewInteractiveWidgets(ctx context.Context) (*InteractiveWidgets, error)

NewInteractiveWidgets returns a set of interactive widgets if the user is in an interactive session. If the user is not in an interactive session, ErrNotInteractive error is returned.

type Message

type Message struct {
	Text        string
	PaddingSize int
}

func (Message) BoundingBoxSize

func (m Message) BoundingBoxSize() int

func (Message) TextSize

func (m Message) TextSize() int

type Progress

type Progress interface {
	Runnable[ProgressControl]
}

type ProgressControl

type ProgressControl interface {
	io.Writer
	Error(err error)
}

type Runnable

type Runnable[T any] interface {
	With(fn func(T) error) error
}

type Spinner

type Spinner interface {
	Runnable[Spinner]
}

type Widgets

type Widgets interface {
	// Printf prints a formatted string to the output.
	Printf(format string, a ...any)
	// NewSpinner returns a new spinner with the given message. The spinner will
	// be started when the With method is called and stopped when the function
	// returns.
	NewSpinner(message string) Spinner
	// NewProgress returns a new progress bar with the given total size and
	// message. The progress bar will be started when the With method is called
	// and stopped when the function returns. The progress bar can be updated
	// with the Write method.
	NewProgress(totalSize int, message Message) Progress
}

Widgets is a set of widgets that can be used to display progress, spinners, and other interactive elements.

func NewWidgets

func NewWidgets(ctx context.Context) Widgets

Jump to

Keyboard shortcuts

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