libghostty-vaxis

April 10, 2026 ยท View on GitHub

libghostty-vaxis provides a libghostty-backed terminal model for vaxis with an API intentionally close to vaxis/widgets/term.

Status

The initial surface is in place:

  • New
  • Attach / Detach
  • Start / StartWithSize
  • Update
  • Draw
  • Resize
  • Focus / Blur
  • Close

It also exposes ScrollViewportTop, ScrollViewportBottom, and ScrollViewportDelta so callers can take advantage of libghostty scrollback support.

Example

Run the example app with:

go run ./examples/shell

To run a specific command instead of your default shell:

go run ./examples/shell -- htop
package main

import (
	"os"
	"os/exec"

	"git.sr.ht/~rockorager/vaxis"
	term "github.com/rockorager/libghostty-vaxis"
)

func main() {
	vx, err := vaxis.New(vaxis.Options{})
	if err != nil {
		panic(err)
	}
	defer vx.Close()

	vt := term.New()
	vt.Attach(vx.PostEvent)
	vt.Focus()

	if err := vt.Start(exec.Command(os.Getenv("SHELL"))); err != nil {
		panic(err)
	}
	defer vt.Close()

	for ev := range vx.Events() {
		switch ev := ev.(type) {
		case vaxis.Key:
			if ev.MatchString("Ctrl+c") {
				return
			}
		case term.EventClosed:
			return
		case vaxis.Redraw:
			vx.HideCursor()
			vt.Draw(vx.Window())
			vx.Render()
			continue
		}

		vt.Update(ev)
	}
}

Native Dependency

This package depends on github.com/mitchellh/go-libghostty, which links against libghostty-vt.

By default the upstream binding expects libghostty-vt-static to be available through pkg-config. If you build go-libghostty from source, point PKG_CONFIG_PATH at the generated share/pkgconfig directory before running go build or go test.