46 lines
771 B
Go
46 lines
771 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
ui "github.com/gizak/termui/v3"
|
|
"github.com/gizak/termui/v3/widgets"
|
|
"morozovad.ddns.net/lnd212/go-roflcopter/roflcopter"
|
|
)
|
|
|
|
var (
|
|
count time.Duration = 15 * time.Second
|
|
str string = ""
|
|
p *widgets.Paragraph
|
|
)
|
|
|
|
const (
|
|
playSound = true
|
|
timer = 15 * time.Second
|
|
)
|
|
|
|
func prepareScreen() {
|
|
if err := ui.Init(); err != nil {
|
|
log.Fatalf("failed to initialize termui: %v", err)
|
|
}
|
|
//defer ui.Close()
|
|
p = widgets.NewParagraph()
|
|
p.Text = str
|
|
p.SetRect(0, 0, 25, 10)
|
|
ui.Render(p)
|
|
}
|
|
|
|
func updateScreen() {
|
|
p.Text = str
|
|
ui.Render(p)
|
|
}
|
|
|
|
func main() {
|
|
prepareScreen()
|
|
rofl := roflcopter.NewRoflcopter(timer, &str, playSound, updateScreen)
|
|
rofl.Start()
|
|
time.Sleep(timer + 500*time.Millisecond)
|
|
ui.Close()
|
|
}
|