Expand description
Cleanroom Rust port of upstream Go source file: progress/progress.go
Upstream Target Tag / Version: v2.1.0
A simple progress bar for Bubble Tea applications.
The spring-based animation is an inline port of
github.com/charmbracelet/harmonica (a simplified damped harmonic
oscillator), which the upstream progress component uses for animated
transitions.
Structs§
- Frame
Msg - FrameMsg indicates that an animation step should occur.
- Model
- Model stores values we’ll use when rendering the progress bar.
Constants§
- DEFAULT_
EMPTY_ CHAR_ BLOCK - DefaultEmptyCharBlock is the default character used to fill the empty portion of the progress bar.
- DEFAULT_
FULL_ CHAR_ FULL_ BLOCK - DefaultFullCharFullBlock can also be used as a fill character for the
progress bar. Use this to disable the higher resolution blending which is
enabled when using
DEFAULT_FULL_CHAR_HALF_BLOCK. - DEFAULT_
FULL_ CHAR_ HALF_ BLOCK - DefaultFullCharHalfBlock is the default character used to fill the progress bar. It is a half block, which allows more granular color blending control, by having a different foreground and background color, doubling blending resolution.
Functions§
- default_
blend_ end - defaultBlendEnd is the end of the default color blend (neon pink).
- default_
blend_ start - defaultBlendStart is the start of the default color blend (purple haze).
- default_
empty_ color - defaultEmptyColor is the default “empty” color (slate gray).
- default_
full_ color - defaultFullColor is the default “filled” color (blueberry).
- new
- New returns a model with default values.
- with_
color_ func - WithColorFunc sets a function that can be used to dynamically fill the progress bar based on the current percentage. total is the total filled percentage, and current is the current percentage that is actively being filled with a color. When specified, this overrides any other defined colors and scaling.
- with_
colors - WithColors sets the colors to use to fill the progress bar. Depending on the number of colors passed in, will determine whether to use a solid fill or a blend of colors.
- with_
default_ blend - WithDefaultBlend sets a default blend of colors, which is a blend of purple haze to neon pink.
- with_
fill_ characters - WithFillCharacters sets the characters used to construct the full and empty components of the progress bar.
- with_
scaled - WithScaled sets whether to scale the blend/gradient to fit the width of only the filled portion of the progress bar. The default is false, which means the percentage must be 100% to see the full color blend/gradient.
- with_
spring_ options - WithSpringOptions sets the initial frequency and damping options for the progress bar’s built-in spring-based animation. Frequency corresponds to speed, and damping to bounciness.
- with_
width - WithWidth sets the initial width of the progress bar. Note that you can
also set the width via the
widthproperty, which can come in handy if you’re waiting for atea.WindowSizeMsg. - without_
percentage - WithoutPercentage hides the numeric percentage.