An easy way to write applications with Tomo.
Go to file
Sasha Koshka ddff2f9e47 Improve Notebook styling
...Once we get PageWrapper, that is
2024-09-12 15:50:09 -04:00
assets Initial commit 2024-04-29 00:47:50 -04:00
config Config impl watches for create *and* write 2024-08-28 00:56:40 -04:00
internal Improve Notebook styling 2024-09-12 15:50:09 -04:00
.editorconfig Add editorconfig 2024-04-29 16:24:04 -04:00
application.go NewApplicationWindow takes in a WindowKind 2024-09-12 02:46:35 -04:00
go.mod Update backend 2024-09-12 15:31:24 -04:00
go.sum Update backend 2024-09-12 15:31:24 -04:00
LICENSE Initial commit 2024-04-29 00:47:50 -04:00
manager.go Fix code relating to cookies 2024-09-12 02:42:55 -04:00
path_unix.go Add system dirs to path.go 2024-08-22 13:37:38 -04:00
path.go Improve doc comments for ApplicationSystem*Dirs 2024-08-23 02:27:49 -04:00
README.md Improve README.md 2024-08-23 02:23:04 -04:00

nasin

Go Reference

Nasin builds an application framework on top of Tomo to ease and encourage the development of consistent and stable application software. It has these wonderful features, and more:

  • Use the Application interface to create applications with relatively low boilerplate
  • CLI argument parsing and URI opening
  • Automatic setup/teardown of the backend
  • Advanced configuration system that can watch config files for changes
  • Default style and icon set, as well as a fully featured stylesheet language for creating custom styles, and support for XDG icon themes

Getting Started

Here is a basic "hello world" application, with explanations as comments:

package main

import "image"
import "git.tebibyte.media/tomo/nasin"
import "git.tebibyte.media/tomo/objects"
import "git.tebibyte.media/tomo/objects/layouts"

func main () {
	nasin.RunApplication(new(Application))
}

type Application struct { }

// Describe returns the application's name and ID, and optionally what type of
// application it is.
func (this *Application) Describe () nasin.ApplicationDescription {
	return nasin.ApplicationDescription {
		// This is the name of the application. New application windows
		// will have this as their title by default.
		Name: "Example",
		// This is a "well-known" name, which typically is a domain name
		// owned by the application author.
		ID: "com.example.Example",
	}
}

// Init performs initial setup of the application. Since this is a single-window
// application that doesn't open any files, we create the window here.
func (this *Application) Init () error {
	// Passing an empty rectangle when creating a new window will cause it
	// to auto-expand to fit the minimum size of its contents.
	window, err := nasin.NewApplicationWindow(this, image.Rectangle { })
	if err != nil { return err }
	// Here we create a new container with a basic vertical layout, place a
	// text label that says "Hello world!" in it, and set it as the root
	// object of the window.
	window.SetRoot(objects.NewOuterContainer (
		layouts.ContractVertical,
		objects.NewLabel("Hello world!")))
	window.SetVisible(true)
	// Nasin will not exit until all windows it is "waiting for" have
	// been closed.
	nasin.WaitFor(window)
	return nil
}

// Stop cleanly closes things like system resources or background tasks. We do
// not have any here, so nothing is done.
func (this *Application) Stop () { }

To learn more, take a look at the examples directory and the online documentation.

  • Tomo API: The API that all other parts of the toolkit agree on
  • Objects: A standard collection of re-usable objects and other GUI components
  • Backend: The software responsible for managing and rendering things behind the scenes