|
@@ -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()
|
|
|
+}
|