gauge

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package gauge implements a widget that displays the progress of an operation.

Index

Constants

View Source
const DefaultChar = draw.DefaultRectChar

DefaultChar is the default value for the Char option.

View Source
const DefaultColor = cell.ColorGreen

DefaultColor is the default value for the Color option.

View Source
const DefaultEmptyTextColor = cell.ColorDefault

DefaultEmptyTextColor is the default value for the EmptyTextColor option.

View Source
const DefaultFilledTextColor = cell.ColorBlack

DefaultFilledTextColor is the default value for the FilledTextColor option.

View Source
const DefaultHorizontalTextAlign = align.HorizontalCenter

DefaultHorizontalTextAlign is the default value for the HorizontalTextAlign option.

View Source
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 New

func New(opts ...Option) (*Gauge, error)

New returns a new Gauge.

func (*Gauge) Absolute

func (g *Gauge) Absolute(done, total int, opts ...Option) error

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) Draw

func (g *Gauge) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error

Draw draws the Gauge widget onto the canvas. Implements widgetapi.Widget.Draw.

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.

func (*Gauge) Options

func (g *Gauge) Options() widgetapi.Options

Options implements widgetapi.Widget.Options.

func (*Gauge) Percent

func (g *Gauge) Percent(p int, opts ...Option) error

Percent sets the current progress in percentage. The provided value must be between 0 and 100. Provided options override values set when New() was called.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used to provide options.

func Border

func Border(ls linestyle.LineStyle, cOpts ...cell.Option) Option

Border configures the gauge to have a border of the specified style.

func BorderTitle

func BorderTitle(title string) Option

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

func Char(ch rune) Option

Char sets the rune that is used when drawing the rectangle representing the current progress.

func Color

func Color(c cell.Color) Option

Color sets the color of the gauge.

func EmptyTextColor

func EmptyTextColor(c cell.Color) Option

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

func FilledTextColor(c cell.Color) Option

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 Height

func Height(height int) Option

Height sets the height of the drawn Gauge. Must be a positive number. Defaults to zero which means the height of the container.

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

func TextLabel(text string) Option

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

func VerticalTextAlign(v align.Vertical) Option

VerticalTextAlign sets the vertical alignment of the text progress and text label.

Directories

Path Synopsis
Binary gaugedemo displays a couple of Gauge widgets.
Binary gaugedemo displays a couple of Gauge widgets.

Jump to

Keyboard shortcuts

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