Documentation ¶
Overview ¶
Package donut is a widget that displays the progress of an operation as a partial or full circle.
Index ¶
- Constants
- type Donut
- func (d *Donut) Absolute(done, total int, opts ...Option) error
- func (d *Donut) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (*Donut) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (*Donut) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (d *Donut) Options() widgetapi.Options
- func (d *Donut) Percent(p int, opts ...Option) error
- type Option
- func CellOpts(cOpts ...cell.Option) Option
- func Clockwise() Option
- func CounterClockwise() Option
- func HideTextProgress() Option
- func HolePercent(p int) Option
- func Label(text string, cOpts ...cell.Option) Option
- func LabelAlign(la align.Horizontal) Option
- func ShowTextProgress() Option
- func StartAngle(angle int) Option
- func TextCellOpts(cOpts ...cell.Option) Option
Constants ¶
const DefaultHolePercent = 35
DefaultHolePercent is the default value for the HolePercent option.
const DefaultLabelAlign = align.HorizontalCenter
DefaultLabelAlign is the default value for the LabelAlign option.
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 (*Donut) Absolute ¶
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.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
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 ¶
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 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 ¶
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 ¶
TextCellOpts sets cell options on cells that contain the displayed text progress.