Minimal terminal emulator for Bubbletea.
Go to file
2023-05-12 13:32:53 +02:00
.github Updated README.md. 2023-05-12 13:30:35 +02:00
bubbletea Initial version. 2023-05-12 09:53:45 +02:00
examples Initial version. 2023-05-12 09:53:45 +02:00
fonts Initial version. 2023-05-12 09:53:45 +02:00
.gitignore Initial version. 2023-05-12 09:53:45 +02:00
adapter_empty.go Initial version. 2023-05-12 09:53:45 +02:00
adapter.go Initial version. 2023-05-12 09:53:45 +02:00
cell.go Initial version. 2023-05-12 09:53:45 +02:00
crt_shader.go Initial version. 2023-05-12 09:53:45 +02:00
crt.go Initial version. 2023-05-12 09:53:45 +02:00
csi_test.go Initial version. 2023-05-12 09:53:45 +02:00
csi.go Initial version. 2023-05-12 09:53:45 +02:00
font.go Initial version. 2023-05-12 09:53:45 +02:00
go.mod Initial version. 2023-05-12 09:53:45 +02:00
go.sum Initial version. 2023-05-12 09:53:45 +02:00
LICENSE Initial commit 2023-05-12 08:41:42 +02:00
read_writer.go Updated README.md and some comments. 2023-05-12 13:32:53 +02:00
README.md Updated README.md and some comments. 2023-05-12 13:32:53 +02:00
sgr_test.go Initial version. 2023-05-12 09:53:45 +02:00
sgr.go Initial version. 2023-05-12 09:53:45 +02:00

crt — cathode-ray tube

Screenshot

About

CRT is a library to provide a simple terminal emulator that can be attached to a tea.Program. It uses ebitengine to render the terminal. It supports TrueColor, Mouse and Keyboard input. It interprets the CSI escape sequences coming from bubbletea and renders them to the terminal.

This started as a simple proof of concept for the game I'm writing with the help of bubbletea, aclled End Of Eden. I wanted to give people who have no clue about the terminal a simple option to play the game without interacting with the terminal directly. It's also possible to apply shaders to the terminal to give it a more retro look.

Usage

go get github.com/BigJk/crt@latest
func main() {
	// Load fonts for normal, bold and italic text styles.
	fonts, err := crt.LoadFaces("./fonts/SomeFont-Regular.ttf", "./fonts/SomeFont-Bold.ttf", "./fonts/SomeFont-Italic.ttf", 72.0, 16.0)
	if err != nil {
		panic(err)
	}

	// Just pass your tea.Model to the bubbleadapter, and it will render it to the terminal.
	win, err := bubbleadapter.Window(1000, 600, fonts, someModel{}, color.Black, tea.WithAltScreen())
	if err != nil {
		panic(err)
	}

	// Star the terminal with the given title.
	if err := win.Run("Simple"); err != nil {
		panic(err)
	}
}

Limitations

  • Only supports TrueColor at the moment (no 256 color support) so you need to use TrueColor collors in lipgloss (e.g. lipgloss.Color("#ff0000"))