Gritty is a terminal emulator written in Go and Gio UI Framework, focusing on readability and documentation of the code.
You could use this emulator for normal work, but I created it as a reference implementation of vt100-ish terminal emulator. (I use kitty, and I'm happy with it. I only wanted to understand how terminals work.)
Ensure that Gio is installed on your system. Run with go run .
, test with go test .
. Gritty starts /bin/sh
.
graph LR;
subgraph Controller
E
C
I
end
C[Controller] --> B[Buffer]
C[Controller] --> E[EncodeKeys]
E --> PTY
PTY --> P[Parse input]
P --> I[Interpret control sequences]
I --> C
G[GUI] --"send keys"--> C
G --"read buffer"--> C
buffer
- Buffer is the model that contains a grid of characters, it also handles actions like "clear line" or "write rune".parser
- Parser is a control-sequence parser implemented based on the excellent state diagram by Paul Williams.controller
- Controller connects PTY and buffer.
main
- Main package contains the GUI code and starts the terminal emulator.c.handleOp
)gritty_debug=1 go run .
in the main
package. This also enables extended debug logging.man ascii