pbar

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 9 Imported by: 0

README

pbar - Custom terminal progress bar

Go Report Card GoDoc GitHub license

demo

This is a customizable terminal progress bar that also provides several default styles
You can achieve a completely different effect by simply modifying the configuration

Usage

API Documentation
Example

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar interface {
	BarFormat(info *Info, offset, length, total int) string
}

Bar Mark progress is a bar

type BarMark

type BarMark struct {
	Width          int
	PaddingBarForm Bar
	MidMarkForm    Mark
	PendingBarForm Bar
}

BarMark basic implementation progress bar mark

func (*BarMark) MarkFormat

func (p *BarMark) MarkFormat(info *Info) string

MarkFormat returns mark string

type BaseBar

type BaseBar struct {
	Filler string
	Left   Mark
	Mid    Mark
	Right  Mark
}

BaseBar basic implementation bar

func (*BaseBar) BarFormat

func (b *BaseBar) BarFormat(info *Info, offset, length, total int) string

BarFormat returns bar string

type Info

type Info struct {
	Total     uint64
	Current   uint64
	Refresh   int
	StartTime time.Time
}

Info Current information about the progress bar

func (*Info) AddCurrent

func (i *Info) AddCurrent(val uint64)

AddCurrent adds current

func (*Info) Info

func (i *Info) Info() *Info

Info returns into

func (*Info) IsComplete

func (i *Info) IsComplete() bool

IsComplete returns completed

func (*Info) SetCurrent

func (i *Info) SetCurrent(current uint64)

SetCurrent sets current

func (*Info) SetTotal

func (i *Info) SetTotal(total uint64)

SetTotal sets total

type Mark

type Mark interface {
	MarkFormat(info *Info) string
}

Mark Marking progress can be any text that represents progress

func NewAddedStyle

func NewAddedStyle(content string) Mark

NewAddedStyle added style

func NewBreakStyle

func NewBreakStyle(content string) Mark

NewBreakStyle break style

func NewFillRedStyle

func NewFillRedStyle(content string) Mark

NewFillRedStyle fill red style

func NewFillStyle

func NewFillStyle(content string) Mark

NewFillStyle fill style

func NewNormalStyle

func NewNormalStyle(content string) Mark

NewNormalStyle normal style

func NewTTYShowStyle

func NewTTYShowStyle(content string) Mark

NewTTYShowStyle TTY show style

type MarkAfter

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

MarkAfter Show the after time

func (*MarkAfter) MarkFormat

func (b *MarkAfter) MarkFormat(info *Info) string

MarkFormat returns mark string

type MarkPercent

type MarkPercent struct{}

MarkPercent Show progress in a percent

func (*MarkPercent) MarkFormat

func (b *MarkPercent) MarkFormat(info *Info) string

MarkFormat returns mark string

type MarkRatio

type MarkRatio struct{}

MarkRatio Show progress in a ratio

func (*MarkRatio) MarkFormat

func (b *MarkRatio) MarkFormat(info *Info) string

MarkFormat returns mark string

type MarkRoll

type MarkRoll struct {
	Over string
	Roll []string
}

MarkRoll Indicates that no response has been lost

func (*MarkRoll) MarkFormat

func (b *MarkRoll) MarkFormat(info *Info) string

MarkFormat returns mark string

type MarkText

type MarkText struct {
	Text   string
	Width  int
	Roll   int
	Filler string
}

MarkText Show text

func (*MarkText) MarkFormat

func (b *MarkText) MarkFormat(info *Info) string

MarkFormat returns mark string

type Marks

type Marks struct {
	Split string
	Slice []Mark
}

Marks is a combination of multiple Marks

func (*Marks) MarkFormat

func (m *Marks) MarkFormat(info *Info) string

MarkFormat returns mark string

type Renderer

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

Renderer is render progress bar

func NewRenderer

func NewRenderer() *Renderer

NewRenderer creating a new progress bar renderer must have only one working renderer

func (*Renderer) Add

func (r *Renderer) Add(pb Mark) *Info

Add adds a new progress bar

func (*Renderer) Clear

func (r *Renderer) Clear()

Clear clear all progress bars

func (*Renderer) New

func (r *Renderer) New(name string) *Info

New adds a new default progress bar

func (*Renderer) Print

func (r *Renderer) Print()

Print renderer

func (*Renderer) SetHZ

func (r *Renderer) SetHZ(hz uint8)

SetHZ sets refresh frequency HZ

func (*Renderer) Wait

func (r *Renderer) Wait()

Wait until complete

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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