gritty

command module
v0.0.0-...-e77d027 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 23 Imported by: 0

README

gritty

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.)

Gritty GIF

Using Gritty

Ensure that Gio is installed on your system. Run with go run ., test with go test .. Gritty starts /bin/sh.

Architecture

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
Packages
  • 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.
    • It gives GUI the grid of runes to render and signal when to re-render.
    • It receives key events from GUI.
  • main - Main package contains the GUI code and starts the terminal emulator.
Code walkthrough
  1. Start by understanding the controller.Start method.
  • it starts the shell command and starts processing the parsed PTY operations (c.handleOp)
  1. run the code with gritty_debug=1 go run . in the main package. This also enables extended debug logging.
  2. watch the log output when you interact with the terminal and find the log statements using a full-text search.

Resources

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL