2022-10-31 13:51:28 -06:00
|
|
|
package main
|
|
|
|
|
2022-11-09 13:52:49 -07:00
|
|
|
import "os"
|
2022-11-06 12:17:43 -07:00
|
|
|
import "fmt"
|
|
|
|
import "time"
|
2022-10-31 13:51:28 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/stone"
|
2022-11-08 23:18:56 -07:00
|
|
|
// import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
2022-10-31 13:51:28 -06:00
|
|
|
|
|
|
|
func main () {
|
2022-11-09 13:52:49 -07:00
|
|
|
application := &stone.Application { }
|
|
|
|
channel, err := application.Run()
|
2022-11-06 12:47:37 -07:00
|
|
|
if err != nil { panic(err) }
|
2022-11-06 12:17:43 -07:00
|
|
|
|
2022-11-09 13:52:49 -07:00
|
|
|
currentTime := time.Time { }
|
|
|
|
|
2022-11-05 16:43:57 -06:00
|
|
|
for {
|
2022-11-09 13:52:49 -07:00
|
|
|
event := <- channel
|
|
|
|
switch event.(type) {
|
|
|
|
case stone.EventQuit:
|
|
|
|
os.Exit(0)
|
|
|
|
|
|
|
|
case stone.EventResize:
|
2022-11-06 12:17:43 -07:00
|
|
|
currentTime = time.Now()
|
|
|
|
|
|
|
|
application.ResetDot()
|
|
|
|
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))
|
2022-11-06 13:59:06 -07:00
|
|
|
}
|
2022-10-31 13:51:28 -06:00
|
|
|
}
|
|
|
|
}
|
2022-11-09 13:52:49 -07:00
|
|
|
|
|
|
|
// func run (application *stone.Application) {
|
|
|
|
// currentTime := time.Time { }
|
|
|
|
// frameDelay := time.Second / 2
|
|
|
|
// textBuffer := ""
|
|
|
|
//
|
|
|
|
// for {
|
|
|
|
// typed := application.Typed()
|
|
|
|
// textBuffer += typed
|
|
|
|
//
|
|
|
|
// shouldRender :=
|
|
|
|
// application.Resized() ||
|
|
|
|
// time.Since(currentTime) > frameDelay ||
|
|
|
|
// len(typed) > 0
|
|
|
|
//
|
|
|
|
// if shouldRender {
|
|
|
|
// currentTime = time.Now()
|
|
|
|
//
|
|
|
|
// application.ResetDot()
|
|
|
|
// 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.Dot.X = 0
|
|
|
|
// application.Dot.Y = 2
|
|
|
|
// fmt.Fprintln(application, textBuffer)
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if application.Pressed(stone.MouseButtonLeft) {
|
|
|
|
// x, y := application.MousePosition()
|
|
|
|
// application.SetRune(x, y, '#')
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if !application.Await(frameDelay) { break }
|
|
|
|
// }
|
|
|
|
// }
|