progress

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {

	// Total width of the progress bar, including percentage, if set.
	Width int

	// "Filled" sections of the progress bar
	Full      rune
	FullColor string

	// "Empty" sections of progress bar
	Empty      rune
	EmptyColor string

	// Settings for rendering the numeric percentage
	ShowPercentage  bool
	PercentFormat   string // a fmt string for a float
	PercentageStyle *termenv.Style
	// contains filtered or unexported fields
}

Model stores values we'll use when rendering the progress bar.

func NewModel

func NewModel(opts ...Option) (*Model, error)

NewModel returns a model with default values.

func (Model) View

func (m Model) View(percent float64) string

View renders the progress bar as a given percentage.

type Option

type Option func(*Model) error

Option is used to set options in NewModel. For example:

    progress := NewModel(
	       WithRamp("#ff0000", "#0000ff"),
	       WithoutPercentage(),
    )

func WithDefaultGradient

func WithDefaultGradient() Option

WithDefaultGradient sets a gradient fill with default colors.

func WithDefaultScaledGradient

func WithDefaultScaledGradient() Option

WithDefaultScaledGradient sets a gradient with default colors, and scales the gradient to fit the filled portion of the ramp.

func WithGradient

func WithGradient(colorA, colorB string) Option

WithGradient sets a gradient fill blending between two colors.

func WithScaledGradient

func WithScaledGradient(colorA, colorB string) Option

WithScaledGradient scales the gradient to fit the width of the filled portion of the progress bar.

func WithSolidFill

func WithSolidFill(color string) Option

WithSolidFill sets the progress to use a solid fill with the given color.

func WithWidth

func WithWidth(w int) Option

WithWidth sets the initial width of the progress bar. Note that you can also set the width via the Width property, which can come in handy if you're waiting for a tea.WindowSizeMsg.

func WithoutPercentage

func WithoutPercentage() Option

WithoutPercentage hides the numeric percentage.

Jump to

Keyboard shortcuts

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