{"id":16737503,"url":"https://github.com/robotdana/tty_string","last_synced_at":"2025-04-10T12:51:41.373Z","repository":{"id":56217164,"uuid":"206820255","full_name":"robotdana/tty_string","owner":"robotdana","description":"render strings like a tty","archived":false,"fork":false,"pushed_at":"2025-01-25T09:55:14.000Z","size":104,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T11:38:23.216Z","etag":null,"topics":["ansi-colors","ansi-escape","ansi-escape-codes","ansi-escape-sequences","ansi-terminal","ruby","tty"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/robotdana.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2019-09-06T15:12:41.000Z","updated_at":"2025-01-25T09:54:20.000Z","dependencies_parsed_at":"2025-02-17T05:32:05.252Z","dependency_job_id":"6d239721-fe09-463e-8711-2d720a71dd19","html_url":"https://github.com/robotdana/tty_string","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdana%2Ftty_string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdana%2Ftty_string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdana%2Ftty_string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotdana%2Ftty_string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robotdana","download_url":"https://codeload.github.com/robotdana/tty_string/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247895283,"owners_count":21014268,"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":["ansi-colors","ansi-escape","ansi-escape-codes","ansi-escape-sequences","ansi-terminal","ruby","tty"],"created_at":"2024-10-13T00:26:44.520Z","updated_at":"2025-04-10T12:51:41.340Z","avatar_url":"https://github.com/robotdana.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TTYString\n\n[![Build Status](https://travis-ci.com/robotdana/tty_string.svg?branch=main)](https://travis-ci.com/robotdana/tty_string)\n[![Gem Version](https://badge.fury.io/rb/tty_string.svg)](https://rubygems.org/gems/tty_string)\n\nRender to a string like your terminal does by (narrowly) parsing ANSI TTY codes.\nIntended for use in tests of command line interfaces.\n\n## Features\n\n- supports ruby 2.4 - 3.0.0.preview1, and jruby\n- has no dependencies outside ruby stdlib\n\n## Supported codes\n\n| Code | Description | Default |\n|------|-------------|---------|\n| `\\a` | bell: suppressed | |\n| `\\b` | backspace: clear the character to the left of the cursor and move the cursor back one column | |\n| `\\n` | newline: move the cursor to the start of the next line | |\n| `\\r` | return: move the cursor to the start of the current line | |\n| `\\t` | tab: move the cursor to the next multiple-of-8 column | |\n| `\\e[nA` | move the cursor up _n_ lines | _n_=`1` |\n| `\\e[nB` | move the cursor down _n_ lines | _n_=`1` |\n| `\\e[nC` | move the cursor right _n_ columns | _n_=`1` |\n| `\\e[nD` | move the cursor left _n_ columns | _n_=`1` |\n| `\\e[nE` | move the cursor down _n_ lines, and to the start of the line | _n_=`1` |\n| `\\e[nF` | move the cursor up _n_ lines, and to the start of the line | _n_=`1` |\n| `\\e[nG` | move the cursor to column _n_. `1` is left-most column | _n_=`1` |\n| `\\e[n;mH` \u003cbr\u003e `\\e[n;mf` | move the cursor to row _n_, column _m_. `1;1` is top left corner | _n_=`1` _m_=`1` |\n| `\\e[nJ` | _n_=`0`: clear the screen from the cursor forward \u003cbr\u003e_n_=`1`: clear the screen from the cursor backward \u003cbr\u003e_n_=`2` or _n_=`3`: clear the screen | _n_=`0` |\n| `\\e[nK` | _n_=`0`: clear the line from the cursor forward \u003cbr\u003e_n_=`1`: clear the line from the cursor backward \u003cbr\u003e_n_=`2`: clear the line | _n_=`0` |\n| `\\e[nS` | scroll up _n_ rows | _n_=`1` |\n| `\\e[nT` | scroll down _n_ rows | _n_=`1` |\n| `\\e[m` | styling codes: dropped with `style: :drop` (default), rendered with `style: :render`. | |\n| `\\e[?5h` | reverse the screen: dropped | |\n| `\\e[?5l` | normal the screen: dropped | |\n| `\\e[?25h` | show the cursor: dropped | |\n| `\\e[?25l` | hide the cursor: dropped | |\n| `\\e[?1004h` | enable reporting focus: dropped | |\n| `\\e[?1004l` | disable reporting focus: dropped | |\n| `\\e[?1049h` | enable alternate screen buffer: dropped | |\n| `\\e[?1049l` | disable alternate screen buffer: dropped | |\n| `\\e[?2004h` | enable bracketed paste mode: dropped | |\n| `\\e[?2004l` | disable bracketed paste mode: dropped | |\n| `\\e[200~` | bracketed paste start: dropped | |\n| `\\e[201~` | bracketed paste end: dropped | |\n| `\\e[` | any other valid CSI code: dropped with `unknown: :drop` (default), raises TTYString::Error with `unknown: :raise`. | |\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'tty_string', '~\u003e 1.0'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install tty_string\n\n## Usage\n\n```ruby\nTTYString.parse(\"th\\ta string\\e[3Gis is\")\n=\u003e \"this is a string\"\n```\n\nStyling information is dropped by default:\n```ruby\nTTYString.parse(\"th\\ta \\e[31mstring\\e[0m\\e[3Gis is\")\n=\u003e \"this is a string\"\n```\nBut can be rendered:\n```ruby\nTTYString.parse(\"th\\ta \\e[31mstring\\e[0m\\e[3Gis is\", style: :render)\n=\u003e \"this is a \\e[31mstring\\e[0m\"\n```\n\n```ruby\nTTYString.parse(\"th\\ta \\e[31mstring\\e[0m\\e[3Gis is\", style: :render)\n=\u003e \"this is a \\e[31mstring\\e[0m\"\n```\n\nJust for fun TTYString.to_proc provides the `parse` method as a lambda, so:\n```ruby\n[\"th\\ta string\\e[3Gis is\"].each(\u0026TTYString)\n=\u003e [\"this is a string\"]\n```\n\n## Limitations\n\n- Various terminals are wildly variously permissive with what they accept,\n  so this doesn't even try to cover all possible cases\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests and linters. 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`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/robotdana/tty_string.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotdana%2Ftty_string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobotdana%2Ftty_string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotdana%2Ftty_string/lists"}