Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar interface {
UpdateDisplay(newDisplay *DisplayProps)
}
Bar controls how a bar is displayed, for both single bar or multi bar item.
type DisplayProps ¶
type DisplayProps struct { Prefix string Suffix string // If `Mode == Done / Error`, Suffix is not printed Mode Mode }
DisplayProps controls the display of the progress bar.
type MultiBar ¶
type MultiBar struct {
// contains filtered or unexported fields
}
MultiBar renders multiple progress bars.
func (*MultiBar) AddBar ¶
func (b *MultiBar) AddBar(prefix string) *MultiBarItem
AddBar adds a new bar item. This function is not thread safe. Must be called before render loop is started.
func (*MultiBar) StartRenderLoop ¶
func (b *MultiBar) StartRenderLoop()
StartRenderLoop starts the render loop. This function is thread safe.
func (*MultiBar) StopRenderLoop ¶
func (b *MultiBar) StopRenderLoop()
StopRenderLoop stops the render loop. This function is thread safe.
type MultiBarItem ¶
type MultiBarItem struct {
// contains filtered or unexported fields
}
MultiBarItem controls a bar item inside MultiBar.
func (*MultiBarItem) UpdateDisplay ¶
func (i *MultiBarItem) UpdateDisplay(newDisplay *DisplayProps)
UpdateDisplay updates the display property of this bar item. This function is thread safe.
type SingleBar ¶
type SingleBar struct {
// contains filtered or unexported fields
}
SingleBar renders single progress bar.
Example ¶
package main import ( "strconv" "time" "github.com/luyomo/OhMyTiUP/pkg/tui/progress" ) func main() { b := progress.NewSingleBar("Prefix") b.UpdateDisplay(&progress.DisplayProps{ Prefix: "Prefix", Suffix: "Suffix", }) n := 3 go func() { time.Sleep(time.Second) for i := 0; i < n; i++ { b.UpdateDisplay(&progress.DisplayProps{ Prefix: "Prefix" + strconv.Itoa(i), Suffix: "Suffix" + strconv.Itoa(i), }) time.Sleep(time.Second) } }() b.StartRenderLoop() time.Sleep(time.Second * time.Duration(n+1)) b.UpdateDisplay(&progress.DisplayProps{ Mode: progress.ModeDone, // Mode: progress.ModeError, Prefix: "Prefix", }) b.StopRenderLoop() }
Output:
func NewSingleBar ¶
NewSingleBar creates a new SingleBar.
func (*SingleBar) StartRenderLoop ¶
func (b *SingleBar) StartRenderLoop()
StartRenderLoop starts the render loop. This function is thread safe.
func (*SingleBar) StopRenderLoop ¶
func (b *SingleBar) StopRenderLoop()
StopRenderLoop stops the render loop. This function is thread safe.
func (*SingleBar) UpdateDisplay ¶
func (b *SingleBar) UpdateDisplay(newDisplay *DisplayProps)
UpdateDisplay updates the display property of this single bar. This function is thread safe.