Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e879defbd | |||
| aeea57a09c | |||
| 407049097d | |||
| 7c7d93d6d1 | |||
| 2eb82d9035 | |||
| ab0d84140f |
@@ -1,4 +1,6 @@
|
|||||||
# nasin
|
# nasin
|
||||||
|
|
||||||
|
[](https://pkg.go.dev/git.tebibyte.media/tomo/nasin)
|
||||||
|
|
||||||
Nasin provides an easy way to write applications with Tomo. Parts of Tomo that
|
Nasin provides an easy way to write applications with Tomo. Parts of Tomo that
|
||||||
aren't the GUI toolkit may be found here.
|
aren't the GUI toolkit may be found here.
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package nasin
|
package nasin
|
||||||
|
|
||||||
|
import "log"
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
|
import "git.tebibyte.media/tomo/nasin/internal/registry"
|
||||||
|
|
||||||
// Application represents an application object.
|
// Application represents an application object.
|
||||||
type Application interface {
|
type Application interface {
|
||||||
@@ -9,7 +11,7 @@ type Application interface {
|
|||||||
Describe () ApplicationDescription
|
Describe () ApplicationDescription
|
||||||
|
|
||||||
// Init performs the initial setup of the application.
|
// Init performs the initial setup of the application.
|
||||||
Init ()
|
Init () error
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplicationDescription describes the name and type of an application.
|
// ApplicationDescription describes the name and type of an application.
|
||||||
@@ -74,9 +76,16 @@ type ApplicationRole string; const (
|
|||||||
RoleChecklist ApplicationRole = "Checklist"
|
RoleChecklist ApplicationRole = "Checklist"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunApplication is like Run, but runs an application.
|
// RunApplication is like tomo.Run, but runs an application. If something fails
|
||||||
func RunApplication (application Application) error {
|
// to initialize, an error is written to the standard logger.
|
||||||
return tomo.Run(application.Init)
|
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
|
// 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/x"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
|
|
||||||
func init () {
|
func Init () error {
|
||||||
tomo.Register(1, x.NewBackend)
|
tomo.Register(1, x.NewBackend)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user