Removed the need for a quit handler

This commit is contained in:
2022-11-16 11:08:30 -05:00
parent e030f8632b
commit cab280a371
5 changed files with 25 additions and 47 deletions

View File

@@ -10,7 +10,7 @@ import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
var application = &stone.Application { }
func main () {
application.SetTitle("hellorld")
application.SetTitle("color demo")
application.SetSize(12, 7)
iconFile16, err := os.Open("assets/scaffold16.png")
@@ -26,21 +26,19 @@ func main () {
application.SetIcon([]image.Image { icon16, icon32 })
channel, err := application.Run()
if err != nil { panic(err) }
application.OnStart(onStart)
application.OnResize(onResize)
err = application.Run()
if err != nil { panic(err) }
}
func onStart () {
redraw()
}
for {
event := <- channel
switch event.(type) {
case stone.EventQuit:
os.Exit(0)
case stone.EventResize:
redraw()
}
}
func onResize () {
redraw()
}
func redraw () {
@@ -69,6 +67,4 @@ func redraw () {
application.SetRune(x, height - 1, '=')
application.SetColor(x, height - 1, stone.ColorRed)
}
application.Draw()
}