Documentation ¶
Overview ¶
Package gauge implements a widget that displays the progress of an operation.
Index ¶
- Constants
- type Gauge
- func (g *Gauge) Absolute(done, total int, opts ...Option) error
- func (g *Gauge) Draw(cvs *canvas.Canvas) error
- func (g *Gauge) Keyboard(k *terminalapi.Keyboard) error
- func (g *Gauge) Mouse(m *terminalapi.Mouse) error
- func (g *Gauge) Options() widgetapi.Options
- func (g *Gauge) Percent(p int, opts ...Option) error
- type Option
- func Border(ls draw.LineStyle, cOpts ...cell.Option) Option
- func BorderTitle(title string) Option
- func BorderTitleAlign(h align.Horizontal) Option
- func Char(ch rune) Option
- func Color(c cell.Color) Option
- func EmptyTextColor(c cell.Color) Option
- func FilledTextColor(c cell.Color) Option
- func Height(height int) Option
- func HideTextProgress() Option
- func HorizontalTextAlign(h align.Horizontal) Option
- func ShowTextProgress() Option
- func TextLabel(text string) Option
- func VerticalTextAlign(v align.Vertical) Option
Constants ¶
const DefaultChar = draw.DefaultRectChar
DefaultChar is the default value for the Char option.
const DefaultColor = cell.ColorGreen
DefaultColor is the default value for the Color option.
const DefaultEmptyTextColor = cell.ColorDefault
DefaultEmptyTextColor is the default value for the EmptyTextColor option.
const DefaultFilledTextColor = cell.ColorBlack
DefaultFilledTextColor is the default value for the FilledTextColor option.
const DefaultHorizontalTextAlign = align.HorizontalCenter
DefaultHorizontalTextAlign is the default value for the HorizontalTextAlign option.
const DefaultVerticalTextAlign = align.VerticalMiddle
DefaultVerticalTextAlign is the default value for the VerticalTextAlign option.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge displays the progress of an operation.
Draws a rectangle, a progress bar with optional display of percentage and / or text label.
Implements widgetapi.Widget. This object is thread-safe.
func (*Gauge) Absolute ¶
Absolute sets the progress in absolute numbers, i.e. 7 out of 10. The total amount must be a non-zero positive integer. The done amount must be a zero or a positive integer such that done <= total. Provided options override values set when New() was called.
func (*Gauge) Keyboard ¶
func (g *Gauge) Keyboard(k *terminalapi.Keyboard) error
Keyboard input isn't supported on the Gauge widget.
func (*Gauge) Mouse ¶
func (g *Gauge) Mouse(m *terminalapi.Mouse) error
Mouse input isn't supported on the Gauge widget.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
func BorderTitle ¶
BorderTitle sets a text title within the border.
func BorderTitleAlign ¶
func BorderTitleAlign(h align.Horizontal) Option
BorderTitleAlign sets the horizontal alignment for the border title. Defaults to alignment on the left.
func Char ¶
Char sets the rune that is used when drawing the rectangle representing the current progress.
func EmptyTextColor ¶
EmptyTextColor sets color of the text progress and text label for the portion of the text that falls outside the filled up part of the Gauge. I.e. text in the empty area the Gauge didn't fill yet.
func FilledTextColor ¶
FilledTextColor sets color of the text progress and text label for the portion of the text that falls within the filled up part of the Gauge. I.e. text on the Gauge.
func HideTextProgress ¶
func HideTextProgress() Option
HideTextProgress disables the display of a text enumerating the progress.
func HorizontalTextAlign ¶
func HorizontalTextAlign(h align.Horizontal) Option
HorizontalTextAlign sets the horizontal alignment of the text progress and text label.
func ShowTextProgress ¶
func ShowTextProgress() Option
ShowTextProgress configures the Gauge so that it also displays a text enumerating the progress. This is the default behavior. If the progress is set by a call to Percent(), the displayed text will show the percentage, e.g. "50%". If the progress is set by a call to Absolute(), the displayed text will whos the absolute numbers, e.g. "5/10".
func TextLabel ¶
TextLabel configures the Gauge to display the provided text. If the ShowTextProgress() option is also provided, this label is drawn right after the progress text.
func VerticalTextAlign ¶
VerticalTextAlign sets the vertical alignment of the text progress and text label.