Minimal terminal emulator for Bubbletea.
Go to file
2024-05-09 16:15:19 +01:00
.github Updated README.md. 2023-05-12 13:30:35 +02:00
bubbletea feat: update to new bubbletea mouse handling 2024-01-12 21:00:06 +01:00
examples Added glamour example. 2023-05-27 10:19:22 +02:00
fonts Initial version. 2023-05-12 09:53:45 +02:00
shader Added mutex to access of uniform. 2023-05-12 17:45:50 +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.go Remove test functions for WindowOption 2024-05-09 16:15:19 +01:00
csi_test.go Added visible cursor support. 2023-05-18 18:23:38 +02:00
csi.go Performance optimization. 2023-05-23 20:53:49 +02:00
dpi.go Added high dpi support. 2023-05-23 22:36:08 +02:00
font.go Fonts loadable from bytes. 2023-05-14 09:50:17 +02:00
go.mod chore: update bubbletea dep 2023-12-14 13:53:27 +01:00
go.sum chore: update bubbletea dep 2023-12-14 13:53:27 +01:00
kill_js.go Fix platform dependend syscall. 2023-05-15 16:09:44 +02:00
kill_windows.go Fix exit on windows. 2023-05-19 19:14:46 +02:00
kill.go Fix platform dependend syscall. 2023-05-15 16:09:44 +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 Update README.md 2023-05-27 14:19:33 +02:00
sgr_test.go Fix SGR passing edge case. 2023-05-19 19:57:17 +02:00
sgr.go Performance optimization. 2023-05-23 20:53:49 +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 a 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, called 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 which is a nice side effect.

Usage

go get github.com/BigJk/crt@latest
package main

import (
	"github.com/BigJk/crt"
	bubbleadapter "github.com/BigJk/crt/bubbletea"
	tea "github.com/charmbracelet/bubbletea"
	"github.com/charmbracelet/lipgloss"
	"image/color"
)

// Some tea.Model ...

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", crt.GetFontDPI(), 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)
	}
}

See more examples in the /examples folder!

Limitations

  • Only supports TrueColor at the moment (no 256 color support) so you need to use TrueColor colors in lipgloss (e.g. lipgloss.Color("#ff0000")) Now supported.
  • Not all CSI escape sequences are implemented but the ones that are used by bubbletea are implemented
  • Key handling is a bit quirky atm. Ebiten to bubbletea key mapping is not perfect and some keys are not handled correctly yet.
  • A lot of testing still needs to be done and there are probably edge cases that are not handled correctly yet

Credits