package main import "os" import "fmt" import "time" import "image" import _ "image/png" import "git.tebibyte.media/sashakoshka/stone" import _ "git.tebibyte.media/sashakoshka/stone/backends/x" var application = &stone.Application { } var currentTime = time.Time { } var tickPing = make(chan(struct { })) func main () { application.SetTitle("hellorld") application.SetSize(12, 2) iconFile16, err := os.Open("assets/scaffold16.png") if err != nil { panic(err) } icon16, _, err := image.Decode(iconFile16) if err != nil { panic(err) } iconFile16.Close() iconFile32, err := os.Open("assets/scaffold32.png") if err != nil { panic(err) } icon32, _, err := image.Decode(iconFile32) if err != nil { panic(err) } iconFile16.Close() application.SetIcon([]image.Image { icon16, icon32 }) channel, err := application.Run() if err != nil { panic(err) } redraw() go tick() for { select { case <- tickPing: redraw() case event := <- channel: switch event.(type) { case stone.EventQuit: os.Exit(0) case stone.EventResize: redraw() } } } } func redraw () { currentTime = time.Now() application.SetDot(0, 0) fmt.Fprintln(application, "hellorld!") hour := currentTime.Hour() minute := currentTime.Minute() second := currentTime.Second() application.SetRune(0, 1, rune(hour / 10 + 48)) application.SetRune(1, 1, rune(hour % 10 + 48)) application.SetRune(2, 1, ':') application.SetRune(3, 1, rune(minute / 10 + 48)) application.SetRune(4, 1, rune(minute % 10 + 48)) application.SetRune(5, 1, ':') application.SetRune(6, 1, rune(second / 10 + 48)) application.SetRune(7, 1, rune(second % 10 + 48)) application.Draw() } func tick () { for { tickPing <- struct { } { } time.Sleep(time.Second) } }