Removed the need for a quit handler
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user