diff --git a/application.go b/application.go index 0d40a9c..b8acbc4 100644 --- a/application.go +++ b/application.go @@ -18,13 +18,13 @@ func (application *Application) SetTitle (title string) { application.backend.SetTitle(title) } -// Run initializes the application, and then calls callback. Operations inside -// of callback are allowed to interact with the application. Depending on the -// backend used, this function may bind to the main thread. +// Run initializes the application, starts it, and then returns a channel that +// broadcasts events. If no suitable backend can be found, an error is returned. func (application *Application) Run ( callback func (application *Application), ) ( - err error, + channel chan(Event), + err error, ) { // default values for certain parameters width, height := application.Size() @@ -44,7 +44,7 @@ func (application *Application) Run ( application.backend, err = instantiateBackend(application) if err != nil { return } - application.backend.Run(callback) + channel = application.backend.Run() return } diff --git a/backend.go b/backend.go index 088aa01..336c1a0 100644 --- a/backend.go +++ b/backend.go @@ -1,11 +1,10 @@ package stone -import "time" import "image" import "errors" type Backend interface { - Run () (chan(Event)) + Run () (channel chan(Event)) SetTitle (title string) SetIcon (icons []image.Image) } diff --git a/event.go b/event.go index 3eba784..f60cff2 100644 --- a/event.go +++ b/event.go @@ -1,7 +1,8 @@ -package application +package stone type Event interface { } +type EventQuit struct { } type EventPress Button type EventRelease Button type EventResize struct { } diff --git a/examples/hello/main.go b/examples/hello/main.go index 0623cde..158116d 100644 --- a/examples/hello/main.go +++ b/examples/hello/main.go @@ -3,7 +3,7 @@ package main import "fmt" import "time" import "git.tebibyte.media/sashakoshka/stone" -import _ "git.tebibyte.media/sashakoshka/stone/backends/pixel" +// import _ "git.tebibyte.media/sashakoshka/stone/backends/x" func main () { application := stone.Application { }