{"id":13819892,"url":"https://github.com/piotrmurach/tty-cursor","last_synced_at":"2025-06-12T13:09:22.606Z","repository":{"id":59158169,"uuid":"47037276","full_name":"piotrmurach/tty-cursor","owner":"piotrmurach","description":"Terminal cursor movement and manipulation of cursor properties such as visibility","archived":false,"fork":false,"pushed_at":"2025-04-25T19:58:45.000Z","size":100,"stargazers_count":75,"open_issues_count":0,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-22T18:15:20.655Z","etag":null,"topics":["cli","cursor-moves","cursor-position","ruby-gem","terminal","tty","tty-components"],"latest_commit_sha":null,"homepage":"https://ttytoolkit.org","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/piotrmurach.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null},"funding":{"github":"piotrmurach"}},"created_at":"2015-11-28T19:48:27.000Z","updated_at":"2025-04-25T19:58:49.000Z","dependencies_parsed_at":"2024-01-13T23:43:19.423Z","dependency_job_id":"50240c07-1f13-4d6f-8e24-f9f0198427ce","html_url":"https://github.com/piotrmurach/tty-cursor","commit_stats":{"total_commits":116,"total_committers":5,"mean_commits":23.2,"dds":0.06896551724137934,"last_synced_commit":"278d946ba134fbf4f3eb9fcc5c0c9f54bd267908"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty-cursor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty-cursor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty-cursor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty-cursor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piotrmurach","download_url":"https://codeload.github.com/piotrmurach/tty-cursor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrmurach%2Ftty-cursor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":257098001,"owners_count":22489576,"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":["cli","cursor-moves","cursor-position","ruby-gem","terminal","tty","tty-components"],"created_at":"2024-08-04T08:00:54.551Z","updated_at":"2025-06-12T13:09:22.579Z","avatar_url":"https://github.com/piotrmurach.png","language":"Ruby","funding_links":["https://github.com/sponsors/piotrmurach"],"categories":["Happy Exploring 🤘"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://ttytoolkit.org\"\u003e\u003cimg width=\"130\" src=\"https://github.com/piotrmurach/tty/raw/master/images/tty.png\" alt=\"TTY Toolkit logo\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n# TTY::Cursor\n\n[![Gem Version](https://badge.fury.io/rb/tty-cursor.svg)][gem]\n[![Actions CI](https://github.com/piotrmurach/tty-cursor/actions/workflows/ci.yml/badge.svg)][gh_actions_ci]\n[![Build status](https://ci.appveyor.com/api/projects/status/4k7cd69jscwg7fl7?svg=true)][appveyor]\n[![Maintainability](https://api.codeclimate.com/v1/badges/66b37f0f1a313bf0681a/maintainability)][codeclimate]\n[![Coverage Status](https://coveralls.io/repos/piotrmurach/tty-cursor/badge.svg)][coverage]\n\n[gem]: https://badge.fury.io/rb/tty-cursor\n[gh_actions_ci]: https://github.com/piotrmurach/tty-cursor/actions/workflows/ci.yml\n[appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-cursor\n[codeclimate]: https://codeclimate.com/github/piotrmurach/tty-cursor/maintainability\n[coverage]: https://coveralls.io/r/piotrmurach/tty-cursor\n\n\u003e Terminal cursor positioning, visibility and text manipulation.\n\nThe purpose of this library is to help move the terminal cursor around and manipulate text by using intuitive method calls.\n\n**TTY::Cursor** provides independent cursor movement component for [TTY](https://github.com/piotrmurach/tty) toolkit.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'tty-cursor'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install tty-cursor\n\n## Contents\n\n* [1. Usage](#1-usage)\n* [2. Interface](#2-interface)\n  * [2.1 Cursor Positioning](#21-cursor-positioning)\n    * [2.1.1 move_to(x, y)](#211-move_tox-y)\n    * [2.1.2 move(x, y)](#212-movex-y)\n    * [2.1.3 up(n)](#213-upn)\n    * [2.1.4 down(n)](#214-downn)\n    * [2.1.5 forward(n)](#215-forwardn)\n    * [2.1.6 backward(n)](#216-backwardn)\n    * [2.1.7 column(n)](#217-columnn)\n    * [2.1.8 row(n)](#218-rown)\n    * [2.1.9 next_line](#219-next_line)\n    * [2.1.10 prev_line](#2110-prev_line)\n    * [2.1.11 save](#2111-save)\n    * [2.1.12 restore](#2112-restore)\n    * [2.1.13 current](#2113-current)\n  * [2.2 Cursor Visibility](#22-cursor-visibility)\n    * [2.2.1 show](#221-show)\n    * [2.2.2 hide](#222-hide)\n    * [2.2.3 invisible(stream)](#223-invisiblestream)\n  * [2.3 Text Clearing](#23-text-clearing)\n    * [2.3.1 clear_char(n)](#231-clear_charn)\n    * [2.3.2 clear_line](#232-clear_line)\n    * [2.3.3 clear_line_before](#233-clear_line_before)\n    * [2.3.4 clear_line_after](#234-clear_line_after)\n    * [2.3.5 clear_lines(n, direction)](#235-clear_linesn-direction)\n    * [2.3.6 clear_screen_down](#236-clear_screen_down)\n    * [2.3.7 clear_screen_up](#237-clear_screen_up)\n    * [2.3.8 clear_screen](#238-clear_screen)\n  * [2.4 Scrolling](#24-scrolling)\n    * [2.4.1 scroll_down](#241-scroll_down)\n    * [2.4.2 scroll_up](#242-scroll_up)\n\n## 1. Usage\n\n**TTY::Cursor** is just a module hence you can reference it for later like so:\n\n```ruby\ncursor = TTY::Cursor\n```\n\nand to move the cursor current position by 5 rows up and 2 columns right do:\n\n```ruby\nprint cursor.up(5) + cursor.forward(2)\n```\n\nor call `move` to move cursor relative to current position:\n\n```ruby\nprint cursor.move(5, 2)\n```\n\nto remove text from the current line do:\n\n```ruby\nprint cursor.clear_line\n```\n\n## 2. Interface\n\n### 2.1 Cursor Positioning\n\nAll methods in this section allow to position the cursor around the terminal viewport.\n\nCursor movement will be bounded by the current viewport into the buffer. Scrolling (if available) will not occur.\n\n#### 2.1.1 move_to(x, y)\n\nSet the cursor absolute position to `x` and `y` coordinate, where `x` is the column of the `y` line.\n\nIf no row/column parameters are provided, the cursor will move to the home position, at the upper left of the screen:\n\n```ruby\ncursor.move_to\n```\n\n#### 2.1.2 move(x, y)\n\nMove cursor by x columns and y rows relative to its current position.\n\n#### 2.1.3 up(n)\n\nMove the cursor up by `n` rows; the default n is `1`.\n\n#### 2.1.4 down(n)\n\nMove the cursor down by `n` rows; the default n is `1`.\n\n#### 2.1.5 forward(n)\n\nMove the cursor forward by `n` columns; the default n is `1`.\n\n#### 2.1.6 backward(n)\n\nMove the cursor backward by `n` columns; the default n is `1`.\n\n#### 2.1.7 column(n)\n\nCursor moves to `\u003cn\u003e`th position horizontally in the current line.\n\n#### 2.1.8 row(n)\n\nCursor moves to the `\u003cn\u003e`th position vertically in the current column.\n\n#### 2.1.9 next_line\n\nMove the cursor down to the beginning of the next line.\n\n#### 2.1.10 prev_line\n\nMove the cursor up to the beginning of the previous line.\n\n#### 2.1.11 save\n\nSave current cursor position.\n\n#### 2.1.12 restore\n\nRestore cursor position after a save cursor was called.\n\n#### 2.1.13 current\n\nQuery current cursor position\n\n### 2.2 Cursor Visibility\n\nThe following methods control the visibility of the cursor.\n\n#### 2.2.1 show\n\nShow the cursor.\n\n#### 2.2.2 hide\n\nHide the cursor.\n\n#### 2.2.3 invisible(stream)\n\nTo hide the cursor for the duration of the block do:\n\n```ruby\ncursor.invisible { ... }\n```\n\nBy default standard output will be used but you can change that by passing a different stream that responds to `print` call:\n\n```ruby\ncursor.invisible($stderr) { .... }\n```\n\n### 2.3 Text Clearing\n\nAll methods in this section provide APIs to modify text buffer contents.\n\n#### 2.3.1 clear_char(n)\n\nErase `\u003cn\u003e` characters from the current cursor position by overwriting them with space character.\n\n#### 2.3.2 clear_line\n\nErase the entire current line and return cursor to beginning of the line.\n\n#### 2.3.3 clear_line_before\n\nErase from the beginning of the line up to and including the current position.\n\n#### 2.3.4 clear_line_after\n\nErase from the current position (inclusive) to the end of the line/display.\n\n#### 2.3.5 clear_lines(n, direction)\n\nErase `n` rows in given direction; the default direction is `:up`.\n\n```ruby\ncursor.clear_lines(5, :down)\n```\n\n#### 2.3.6 clear_screen\n\nErase the screen with the background colour and moves the cursor to home.\n\n#### 2.3.7 clear_screen_down\n\nErase the screen from the current line down to the bottom of the screen.\n\n#### 2.3.8 clear_screen_up\n\nErase the screen from the current line up to the top of the screen.\n\n### 2.4 Scrolling\n\n#### 2.4.1 scroll_down\n\nScroll display down one line.\n\n### 2.4.2 scroll_up\n\nScroll display up one line.\n\n\n## Contributing\n\n1. Fork it ( https://github.com/piotrmurach/tty-cursor/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## Code of Conduct\n\nEveryone interacting in the Strings::Inflection project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/tty-cursor/blob/master/CODE_OF_CONDUCT.md).\n\n## Copyright\n\nCopyright (c) 2015 Piotr Murach. See LICENSE for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrmurach%2Ftty-cursor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiotrmurach%2Ftty-cursor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrmurach%2Ftty-cursor/lists"}