This repo contains types, interfaces, and utilities for building terminal user interfaces in Go. It's an opinionated framework that uses charm TUI components and packages for rendering and handling terminal events.
First, install the package:
go get -u github.com/jahvon/tuikit@latest
You can then use the package in your Go code:
package main
import (
"context"
"github.com/jahvon/tuikit"
"github.com/jahvon/tuikit/views"
)
func main() {
ctx := context.Background()
// Define your application metadata
app := &tuikit.Application{Name: "MyApp"}
// Create and start the container
container, err := tuikit.NewContainer(ctx, app)
if err != nil {
panic(err)
}
if err := container.Start(); err != nil {
panic(err)
}
// Create and set your view - the example below used the Markdown view type.
// There are other view types available in the views package.
view := views.NewMarkdownView(container.RenderState(), "# Hello, world!")
if err := container.SetView(view); err != nil {
panic(err)
}
// Wait for the container to exit. Before getting here, you can handle events, update the view, etc.
container.WaitForExit()
}
Also see the sample app for examples of how different views can be used.