6 Commits

Author SHA1 Message Date
7e879defbd Fix RunApplication 2024-05-03 13:27:32 -04:00
aeea57a09c What egven 2024-05-03 13:26:33 -04:00
407049097d Applications can return init errors 2024-05-03 12:46:53 -04:00
7c7d93d6d1 Backend registering is platform-dependent 2024-05-03 12:46:27 -04:00
2eb82d9035 Add application FS fuctionality 2024-05-03 12:30:52 -04:00
ab0d84140f Add godoc badge to README.md 2024-04-30 04:31:02 +00:00
4 changed files with 21 additions and 6 deletions

View File

@@ -1,4 +1,6 @@
# nasin # nasin
[![Go Reference](https://pkg.go.dev/badge/git.tebibyte.media/tomo/nasin.svg)](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.

View File

@@ -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
View File

@@ -0,0 +1,2 @@
// Package registry provides platform-dependent components at compile time.
package registry

View File

@@ -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
} }