2
0

2 Incheckningar 76565b3c07 ... 8eee3ee7d1

Upphovsman SHA1 Meddelande Datum
  blackwine 8eee3ee7d1 becoming a party pig 3 veckor sedan
  blackwine 76565b3c07 becoming a party pig 3 veckor sedan
1 ändrade filer med 31 tillägg och 31 borttagningar
  1. 31 31
      bar.go

+ 31 - 31
bar.go

@@ -1,10 +1,10 @@
 package main
 
 import (
-	"os"
-	"os/exec"
 	"fmt"
 	"log"
+	"os"
+	"os/exec"
 	"time"
 
 	// bar
@@ -23,17 +23,24 @@ type ScreenBar struct {
 	columns      int
 }
 
-// Ticker's gonna tick
-func (bar *ScreenBar) tick() {
-	bar.ticks += 1
-	bar.update()
-}
-
-// Ticker's gonna need to be reset sometimes
-func (bar *ScreenBar) reset(msg *osc.Message) {
+func NewScreenBar(title string) *ScreenBar {
+	bar := new(ScreenBar)
+	bar.title = title
 	bar.ticks = 0
-	bar.ticker.Reset(time.Second)
+	bar.tickerActive = true
+
+	bar.ticker = time.NewTicker(time.Second)
 	bar.update()
+
+	// Goroutine to handle ticker updates
+	go func() {
+		for range bar.ticker.C {
+			bar.ticks += 1
+			bar.update()
+		}
+	}()
+
+	return bar
 }
 
 // (Re)paint a screen by drawing bar
@@ -60,26 +67,6 @@ func (bar *ScreenBar) update() {
 	}
 }
 
-func NewScreenBar(title string) *ScreenBar {
-	bar := new(ScreenBar)
-	bar.title = title
-	bar.ticks = 0
-	bar.tickerActive = true
-
-	bar.ticker = time.NewTicker(time.Second)
-	bar.update()
-
-	// Goroutine to handle ticker updates
-	go func() {
-		for range bar.ticker.C {
-			bar.ticks += 1
-			bar.update()
-		}
-	}()
-
-	return bar
-}
-
 // Set title visible on the bar
 func (bar *ScreenBar) setTitle(msg *osc.Message) {
 	for _, arg := range msg.Arguments {
@@ -90,3 +77,16 @@ func (bar *ScreenBar) setTitle(msg *osc.Message) {
 		}
 	}
 }
+
+// Ticker's gonna tick
+func (bar *ScreenBar) tick() {
+	bar.ticks += 1
+	bar.update()
+}
+
+// Ticker's gonna need to be reset sometimes
+func (bar *ScreenBar) reset(msg *osc.Message) {
+	bar.ticks = 0
+	bar.ticker.Reset(time.Second)
+	bar.update()
+}