Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e879defbd | |||
| aeea57a09c | |||
| 407049097d | |||
| 7c7d93d6d1 | |||
| 2eb82d9035 | |||
| ab0d84140f |
@@ -1,4 +1,6 @@
|
||||
# nasin
|
||||
|
||||
[](https://pkg.go.dev/git.tebibyte.media/tomo/nasin)
|
||||
|
||||
Nasin provides an easy way to write applications with Tomo. Parts of Tomo that
|
||||
aren't the GUI toolkit may be found here.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package nasin
|
||||
|
||||
import "log"
|
||||
import "image"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/registry"
|
||||
|
||||
// Application represents an application object.
|
||||
type Application interface {
|
||||
@@ -9,7 +11,7 @@ type Application interface {
|
||||
Describe () ApplicationDescription
|
||||
|
||||
// Init performs the initial setup of the application.
|
||||
Init ()
|
||||
Init () error
|
||||
}
|
||||
|
||||
// ApplicationDescription describes the name and type of an application.
|
||||
@@ -74,9 +76,16 @@ type ApplicationRole string; const (
|
||||
RoleChecklist ApplicationRole = "Checklist"
|
||||
)
|
||||
|
||||
// RunApplication is like Run, but runs an application.
|
||||
func RunApplication (application Application) error {
|
||||
return tomo.Run(application.Init)
|
||||
// RunApplication is like tomo.Run, but runs an application. If something fails
|
||||
// to initialize, an error is written to the standard logger.
|
||||
func RunApplication (application Application) {
|
||||
err := registry.Init()
|
||||
if err != nil { log.Fatal("nasin: could not init registry:", err) }
|
||||
err = tomo.Run(func () {
|
||||
err := application.Init()
|
||||
if err != nil { log.Fatal("nasin: could not run application:", err) }
|
||||
})
|
||||
if err != nil { log.Fatal("nasin: could not run application:", err) }
|
||||
}
|
||||
|
||||
// NewApplicationWindow creates a window for an application. It will
|
||||
|
||||
2
internal/registry/doc.go
Normal file
2
internal/registry/doc.go
Normal file
@@ -0,0 +1,2 @@
|
||||
// Package registry provides platform-dependent components at compile time.
|
||||
package registry
|
||||
@@ -1,8 +1,10 @@
|
||||
package nasin
|
||||
//go:build unix && (!darwin)
|
||||
package registry
|
||||
|
||||
import "git.tebibyte.media/tomo/x"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
|
||||
func init () {
|
||||
func Init () error {
|
||||
tomo.Register(1, x.NewBackend)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user