summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-12 17:12:41 -0400
committerPietro Gagliardi <[email protected]>2014-03-12 17:12:41 -0400
commitbf093d534c0bc64fa7da38708c05e5a632964ae7 (patch)
treea53fa06ebf67d1d7e6599f9ae8f269a250b8e78b
parent6be3c2835f00c1f072aea02d4d4ad94132e36ef0 (diff)
Added indeterminate ProgressBars to the portable frontend and fixed up ProgressBar's documentation.
-rw-r--r--progressbar.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/progressbar.go b/progressbar.go
index e80ff3c..4d16874 100644
--- a/progressbar.go
+++ b/progressbar.go
@@ -6,7 +6,9 @@ import (
)
// A ProgressBar is a horizontal rectangle that fills up from left to right to indicate the progress of a long-running task.
-// This progress is typically a percentage, so within the range [0,100].
+// This progress is represented by an integer within the range [0,100], representing a percentage.
+// Alternatively, a progressbar can show an animation indicating that progress is being made but how much is indeterminate.
+// Newly-created ProgressBars default to showing 0% progress.
type ProgressBar struct {
lock sync.Mutex
created bool
@@ -21,13 +23,16 @@ func NewProgressBar() *ProgressBar {
}
}
-// SetProgress sets the currently indicated progress amount on the ProgressBar. If this amount is outside the range [0,100] (ideally -1), the function will panic (TODO make it indeterminate).
+// SetProgress sets the currently indicated progress amount on the ProgressBar.
+// If percent is in the range [0,100], the progressBar shows that much percent complete.
+// If percent is -1, the ProgressBar is made indeterminate.
+// Otherwise, SetProgress panics.
func (p *ProgressBar) SetProgress(percent int) {
p.lock.Lock()
defer p.lock.Unlock()
- if percent < 0 || percent > 100 {
- panic("invalid percent") // TODO
+ if percent < -1 || percent > 100 {
+ panic("percent value out of range")
}
if p.created {
p.sysData.setProgress(percent)