progressbar

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DownloadingStatus = "Downloading"
	DownloadingColor  = "#FF6600"

	MergingStatus = "Merging"
	MergingColor  = "#FFCC66"

	CompleteStatus = "Complete"
	CompleteColor  = "#00FF00"

	ErrStatus = "Error"
	ErrColor  = "#CC0000"

	RetryStatus = "Retry"
	RetryColor  = "#CC66CC"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Mux sync.Mutex // protect fields below
	Pbs map[string]*ProgressBar
	// contains filtered or unexported fields
}

func (*Model) AddPb added in v0.3.0

func (m *Model) AddPb(pb *ProgressBar)

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Model) View

func (m *Model) View() string

type ProgressBar

type ProgressBar struct {
	Pw       *ProgressWriter
	Pc       *ProgressCounter
	Progress progress.Model
	FileName string
	Status   string
}

type ProgressCompleteMsg added in v0.3.1

type ProgressCompleteMsg struct{}

type ProgressCounter added in v0.3.0

type ProgressCounter struct {
	Total      int64
	Downloaded atomic.Int64
	FileName   string
	Onprogress func(string, float64)
}

func (*ProgressCounter) Increase added in v0.3.0

func (pc *ProgressCounter) Increase()

type ProgressErrMsg

type ProgressErrMsg struct{ Err error }

type ProgressMsg

type ProgressMsg struct {
	FileName string
	Ratio    float64
	Speed    int64
	DLTime   float64
}

type ProgressStatusMsg added in v0.3.0

type ProgressStatusMsg struct {
	FileName string
	Status   string
}

type ProgressWriter

type ProgressWriter struct {
	Total      int64
	Downloaded int64
	File       *os.File
	Reader     io.Reader
	FileName   string
	StartTime  time.Time
	Speed      int64
	DLTime     float64
	OnProgress func(string, float64, float64, int64)
}

func (*ProgressWriter) Start

func (pw *ProgressWriter) Start(p *tea.Program) (int64, error)

func (*ProgressWriter) Write

func (pw *ProgressWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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