{"id":18732336,"url":"https://github.com/coezbek/vtparser","last_synced_at":"2025-10-26T09:05:56.989Z","repository":{"id":257806259,"uuid":"866220126","full_name":"coezbek/vtparser","owner":"coezbek","description":"VT100 parser in pure ruby","archived":false,"fork":false,"pushed_at":"2024-10-05T14:34:44.000Z","size":42,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T21:06:26.775Z","etag":null,"topics":["escape-sequences","ruby","ruby-gem","terminal-ui","tui","vt100"],"latest_commit_sha":null,"homepage":"https://github.com/coezbek/vtparser","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coezbek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2024-10-01T21:18:55.000Z","updated_at":"2024-10-05T14:34:46.000Z","dependencies_parsed_at":"2024-10-01T21:38:52.005Z","dependency_job_id":"6c1e0642-ce29-4289-b2f4-56b6dfd86c2a","html_url":"https://github.com/coezbek/vtparser","commit_stats":null,"previous_names":["coezbek/vtparser"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coezbek%2Fvtparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coezbek%2Fvtparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coezbek%2Fvtparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coezbek%2Fvtparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coezbek","download_url":"https://codeload.github.com/coezbek/vtparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248613271,"owners_count":21133480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["escape-sequences","ruby","ruby-gem","terminal-ui","tui","vt100"],"created_at":"2024-11-07T15:05:27.627Z","updated_at":"2025-10-26T09:05:51.936Z","avatar_url":"https://github.com/coezbek.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VT 100 Parser Gem\n\nThis gem is a parser for VT100 terminal escape sequences. It is based on the C code from https://github.com/haberman/vtparse/ and implements the statemachine from https://www.vt100.net/emu/dec_ansi_parser.\n\nThe purpose of this Gem is to have a relatively easy way to filter/modify the output of child/sub-processes (for instance launched via `PTY::spawn`) which use animation or colors. \n\nUses keyboard mapping logic from https://github.com/vidarh/keyboard_map/\n\n## Background on VT100 Escape Sequences\n\nSee https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```bash\nbundle add vtparser\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```bash\ngem install vtparser\n```\n\n## Basic Usage\n\nSee the minimal example below:\n\n```ruby\nrequire_relative '../lib/vtparser'\n\n# Instantiate the parser with a block to handle actions\nparser = VTParser.new do |action|\n\n  # For this minimal example, we'll just turn everything back strings to print\n  print action.to_ansi\n\nend\n\n# Sample input containing ANSI escape sequences (red text, bold text)\ninput = \"\\e[31mHello, \\e[1mWorld!\\e[0m\\n\"\n\n# Parse the input\nparser.parse(input)\n```\n\nFurther samples in the [`examples directory`](https://github.com/coezbek/vtparser/tree/main/examples):\n\n- [`echo_keys.rb`](https://github.com/coezbek/vtparser/tree/main/examples/echo_keys.rb): Echoes the keys pressed by the user\n- [`indent_cli.rb`](https://github.com/coezbek/vtparser/tree/main/examples/indent_cli.rb): Indents the output of simple command line tools\n- [`colorswap.rb`](https://github.com/coezbek/vtparser/tree/main/examples/colorswap.rb): Swaps the colors red / green in the input program\n- [`analyze.rb`](https://github.com/coezbek/vtparser/tree/main/examples/analyze.rb): Output all VT100 escape sequences written by the subprocess.\n- [`roundtrip.rb`](https://github.com/coezbek/vtparser/tree/main/examples/roundtrip.rb): Runs the given command and compares characters written by the command to the output of running the characters through the parser and serializing the actions back `to_ansi`. If the parser works correctly the output should be the same.\n\n## Limitations\n\n- The parser is based on the implementation https://github.com/haberman/vtparse/ and based on a state machine which precedes Unicode. As such it does not have state transitions for Unicode characters. Rather, it will output them as `:ignore` actions. In case unicode characters are used inside escape sequences, the parser will likely not be able to handle them correctly.\n\n- The state machine does not expose all input characters to the implementation in relationship to the `DSC` (Device Control String) sequences. In particular the \"Final Character\" is swallowed by the statemachine from https://www.vt100.net/emu/dec_ansi_parser. To circumvent this limitation, I have modified the parser to expose the final character as intermediate_chars to the `:hook` action.\n\n- The parser only outputs full `actions`. So triggering an event for the `ESC` key doesn't work (as expected).\n\n- The parser does not emit actions for commands which are 'interrupted' by another command.\"\n\n- The parser does not explain any of the actions.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/coezbek/vtparser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoezbek%2Fvtparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoezbek%2Fvtparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoezbek%2Fvtparser/lists"}