Return err from Application.Run
This commit is contained in:
parent
b773ba6fc6
commit
f6b8d9903b
@ -21,7 +21,11 @@ func (application *Application) SetTitle (title string) {
|
|||||||
application.backend.SetTitle(title)
|
application.backend.SetTitle(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) Run (callback func (application *Application)) {
|
func (application *Application) Run (
|
||||||
|
callback func (application *Application),
|
||||||
|
) (
|
||||||
|
err error,
|
||||||
|
) {
|
||||||
// default values for certain parameters
|
// default values for certain parameters
|
||||||
width, height := application.Size()
|
width, height := application.Size()
|
||||||
if width < 1 { width = 80 }
|
if width < 1 { width = 80 }
|
||||||
@ -38,11 +42,11 @@ func (application *Application) Run (callback func (application *Application)) {
|
|||||||
|
|
||||||
application.config.padding = 4
|
application.config.padding = 4
|
||||||
|
|
||||||
// TODO: instead, return the error
|
|
||||||
var err error
|
|
||||||
application.backend, err = instantiateBackend(application)
|
application.backend, err = instantiateBackend(application)
|
||||||
if err != nil { panic(err.Error()) }
|
if err != nil { return }
|
||||||
application.backend.Run(callback)
|
application.backend.Run(callback)
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) Await (timeout time.Duration) (keepRunning bool) {
|
func (application *Application) Await (timeout time.Duration) (keepRunning bool) {
|
||||||
@ -69,27 +73,3 @@ func (application *Application) Resized () (resized bool) {
|
|||||||
resized = application.backend.Resized()
|
resized = application.backend.Resized()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // updateWindowSize updates the window size according to the buffer size.
|
|
||||||
// func (application *Application) updateWindowSize () {
|
|
||||||
// if application.window == nil { return }
|
|
||||||
// application.window.SetBounds(application.calculateWindowSize())
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updateBufferSize updats the buffer size according to the window size.
|
|
||||||
// func (application *Application) updateBufferSize () {
|
|
||||||
// if application.window == nil {
|
|
||||||
// panic("call to application.updateBufferSize before window exists")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// windowBounds := application.window.Bounds().Max
|
|
||||||
//
|
|
||||||
// if windowBounds != application.previousBounds {
|
|
||||||
// application.previousBounds = windowBounds
|
|
||||||
// application.boundsDirty = true
|
|
||||||
// application.DamageBuffer.SetSize (
|
|
||||||
// int(windowBounds.X) / application.metrics.cellWidth,
|
|
||||||
// int(windowBounds.Y) / application.metrics.cellHeight)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
@ -7,7 +7,8 @@ import _ "git.tebibyte.media/sashakoshka/stone/backends/pixel"
|
|||||||
|
|
||||||
func main () {
|
func main () {
|
||||||
application := stone.Application { }
|
application := stone.Application { }
|
||||||
application.Run(run)
|
err := application.Run(run)
|
||||||
|
if err != nil { panic(err) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func run (application *stone.Application) {
|
func run (application *stone.Application) {
|
||||||
|
Loading…
Reference in New Issue
Block a user