summary refs log tree commit diff stats
path: root/widgets/spinner.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-14 21:37:00 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-14 21:37:00 -0400
commit0f8b7a1203309ebec0dc78baf3f195671eadac2d (patch)
treefce6d8148cdbfa5ecfb2030a902f5a0763bb3643 /widgets/spinner.go
parentb3896476a0e6978c0d7f6fedfb64588934a78f1e (diff)
downloadaerc-0f8b7a1203309ebec0dc78baf3f195671eadac2d.tar.gz
Lay out message list widget basic design
Diffstat (limited to 'widgets/spinner.go')
-rw-r--r--widgets/spinner.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/widgets/spinner.go b/widgets/spinner.go
index 2e7e367..812fb2c 100644
--- a/widgets/spinner.go
+++ b/widgets/spinner.go
@@ -36,6 +36,10 @@ func NewSpinner() *Spinner {
 }
 
 func (s *Spinner) Start() {
+	if s.IsRunning() {
+		return
+	}
+
 	s.frame = 0
 	go func() {
 		for {
@@ -54,6 +58,10 @@ func (s *Spinner) Start() {
 }
 
 func (s *Spinner) Stop() {
+	if !s.IsRunning() {
+		return
+	}
+
 	s.stop <- nil
 	s.frame = -1
 	s.Invalidate()
@@ -64,6 +72,10 @@ func (s *Spinner) IsRunning() bool {
 }
 
 func (s *Spinner) Draw(ctx *ui.Context) {
+	if !s.IsRunning() {
+		return
+	}
+
 	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
 	col := ctx.Width()/2 - len(frames[0])/2 + 1
 	ctx.Printf(col, 0, tcell.StyleDefault, "%s", frames[s.frame])