donut

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 donut is a widget that displays the progress of an operation as a partial or full circle.

Index

Constants

View Source
const DefaultHolePercent = 35

DefaultHolePercent is the default value for the HolePercent option.

View Source
const DefaultLabelAlign = align.HorizontalCenter

DefaultLabelAlign is the default value for the LabelAlign option.

View Source
const DefaultStartAngle = 90

DefaultStartAngle is the default value for the StartAngle option.

Variables

This section is empty.

Functions

This section is empty.

Types

type Donut

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

Donut displays the progress of an operation by filling a partial circle and eventually by completing a full circle. The circle can have a "hole" in the middle, which is where the name comes from.

Implements widgetapi.Widget. This object is thread-safe.

func New

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

New returns a new Donut.

func (*Donut) Absolute

func (d *Donut) Absolute(done, total int, opts ...Option) error

Absolute sets the progress in absolute numbers, e.g. 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 (*Donut) Draw

func (d *Donut) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error

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

func (*Donut) Keyboard

func (*Donut) Keyboard(k *terminalapi.Keyboard) error

Keyboard input isn't supported on the Donut widget.

func (*Donut) Mouse

func (*Donut) Mouse(m *terminalapi.Mouse) error

Mouse input isn't supported on the Donut widget.

func (*Donut) Options

func (d *Donut) Options() widgetapi.Options

Options implements widgetapi.Widget.Options.

func (*Donut) Percent

func (d *Donut) 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 CellOpts

func CellOpts(cOpts ...cell.Option) Option

CellOpts sets cell options on cells that contain the donut.

func Clockwise

func Clockwise() Option

Clockwise sets the donut widget for a progression in the clockwise direction. This is the default option.

func CounterClockwise

func CounterClockwise() Option

CounterClockwise sets the donut widget for a progression in the counter-clockwise direction.

func HideTextProgress

func HideTextProgress() Option

HideTextProgress disables the display of a text enumerating the progress.

func HolePercent

func HolePercent(p int) Option

HolePercent sets the size of the "hole" inside the donut as a percentage of the donut's radius. Setting this to zero disables the hole so that the donut will become just a circle. Valid range is 0 <= p <= 100.

func Label added in v0.9.0

func Label(text string, cOpts ...cell.Option) Option

Label sets a text label to be displayed under the donut.

func LabelAlign added in v0.9.0

func LabelAlign(la align.Horizontal) Option

LabelAlign sets the alignment of the label under the donut.

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 those the absolute numbers, e.g. "5/10".

The progress is only displayed if there is enough space for it in the middle of the drawn donut.

Providing this option also sets HolePercent to its default value.

func StartAngle

func StartAngle(angle int) Option

StartAngle sets the starting angle in degrees, i.e. the point that will represent both 0% and 100% of progress. Valid values are in range 0 <= angle < 360. Angles start at the X axis and grow counter-clockwise.

func TextCellOpts

func TextCellOpts(cOpts ...cell.Option) Option

TextCellOpts sets cell options on cells that contain the displayed text progress.

Directories

Path Synopsis
Binary donutdemo displays a couple of Donut widgets.
Binary donutdemo displays a couple of Donut widgets.

Jump to

Keyboard shortcuts

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