{"id":38327561,"url":"https://github.com/viktomas/gritty","last_synced_at":"2026-01-17T02:46:54.601Z","repository":{"id":195143259,"uuid":"692341710","full_name":"viktomas/gritty","owner":"viktomas","description":"Terminal emulator written in Go and Gio","archived":false,"fork":false,"pushed_at":"2023-10-08T10:18:44.000Z","size":2234,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-21T17:55:12.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/viktomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-16T07:21:40.000Z","updated_at":"2024-05-07T21:58:15.000Z","dependencies_parsed_at":"2024-06-21T16:30:56.177Z","dependency_job_id":"e50b3420-d59a-4237-b13f-a7c6112acfc0","html_url":"https://github.com/viktomas/gritty","commit_stats":null,"previous_names":["viktomas/gritty"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/viktomas/gritty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktomas%2Fgritty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktomas%2Fgritty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktomas%2Fgritty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktomas%2Fgritty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viktomas","download_url":"https://codeload.github.com/viktomas/gritty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktomas%2Fgritty/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T02:46:54.455Z","updated_at":"2026-01-17T02:46:54.536Z","avatar_url":"https://github.com/viktomas.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gritty\n\nGritty is a terminal emulator written in Go and Gio UI Framework, focusing on readability and documentation of the code.\n\nYou could use this emulator for normal work, but I created it as a reference implementation of vt100-ish terminal emulator. (I use [kitty](https://sw.kovidgoyal.net/kitty/), and I'm happy with it. I only wanted to understand how terminals work.)\n\n![Gritty GIF](https://github.com/viktomas/gritty/blob/391dd1ea57866de05d118fdd08204f514087c157/doc/gritty-color-2.gif?raw=true)\n\n## Using Gritty\n\nEnsure that [Gio is installed on your system](https://gioui.org/doc/install). Run with `go run .`, test with `go test .`. Gritty starts `/bin/sh`.\n\n## Architecture\n\n```mermaid\ngraph LR;\nsubgraph Controller\nE\nC\nI\nend\nC[Controller] --\u003e B[Buffer]\nC[Controller] --\u003e E[EncodeKeys]\nE --\u003e PTY\nPTY --\u003e P[Parse input]\nP --\u003e I[Interpret control sequences]\nI --\u003e C\nG[GUI] --\"send keys\"--\u003e C\nG --\"read buffer\"--\u003e C\n```\n\n### Packages\n\n- `buffer` - Buffer is the model that contains a grid of characters, it also handles actions like \"clear line\" or \"write rune\".\n- `parser` - Parser is a control-sequence parser implemented based on the [excellent state diagram by Paul Williams](https://www.vt100.net/emu/dec_ansi_parser).\n- `controller` - Controller connects PTY and buffer.\n  - It gives GUI the grid of runes to render and signal when to re-render.\n  - It receives key events from GUI.\n- `main` - Main package contains the GUI code and starts the terminal emulator.\n\n### Code walkthrough\n\n1. Start by understanding the [controller.Start method](https://github.com/viktomas/gritty/blob/6e545ec8c234bccabcd47d09fe3af0ee70138ebc/controller/controller.go#L31).\n  - it starts the shell command and starts processing the parsed PTY operations (`c.handleOp`)\n1. run the code with `gritty_debug=1 go run .` in the `main` package. This also enables extended debug logging.\n1. watch the log output when you interact with the terminal and find the log statements using a full-text search.\n\n## Resources\n\n- [VT510 user manual - Contents](https://vt100.net/docs/vt510-rm/contents.html)\n- [ANSI Control Functions Summary](https://vt100.net/docs/vt510-rm/chapter4.html#S4.1)\n- [Digital VT100 User Guide: Programmer Information - chapter 3](https://vt100.net/docs/vt100-ug/chapter3.html)\n- [asciinema/avt](https://github.com/asciinema/avt/blob/main/src/vt.rs) - extremely clear implementation of vt100-ish terminal emulator in rust\n- [ANSI escape code - Wikipedia](https://en.wikipedia.org/wiki/ANSI_escape_code)\n- [ASCII - Wikipedia](https://en.wikipedia.org/wiki/ASCII)\n- `man ascii`\n- [XtermJS - Supported Terminal Sequences](http://xtermjs.org/docs/api/vtfeatures/) - helpful overview of escape sequences\n- [XTerm Control Sequences](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviktomas%2Fgritty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviktomas%2Fgritty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviktomas%2Fgritty/lists"}