https://github.com/piotrmurach/tty-cursor
Terminal cursor movement and manipulation of cursor properties such as visibility
https://github.com/piotrmurach/tty-cursor
Keywords
cli cursor-moves cursor-position ruby-gem terminal tty tty-components
Keywords from Contributors
spinner
Last synced: about 6 hours ago
JSON representation
Repository metadata
Terminal cursor movement and manipulation of cursor properties such as visibility
- Host: GitHub
- URL: https://github.com/piotrmurach/tty-cursor
- Owner: piotrmurach
- License: mit
- Created: 2015-11-28T19:48:27.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-25T19:58:45.000Z (8 months ago)
- Last Synced: 2025-12-01T13:41:54.189Z (10 days ago)
- Topics: cli, cursor-moves, cursor-position, ruby-gem, terminal, tty, tty-components
- Language: Ruby
- Homepage: https://ttytoolkit.org
- Size: 97.7 KB
- Stars: 77
- Watchers: 4
- Forks: 11
- Open Issues: 0
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
README.md
TTY::Cursor
Terminal cursor positioning, visibility and text manipulation.
The purpose of this library is to help move the terminal cursor around and manipulate text by using intuitive method calls.
TTY::Cursor provides independent cursor movement component for TTY toolkit.
Installation
Add this line to your application's Gemfile:
gem 'tty-cursor'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tty-cursor
Contents
1. Usage
TTY::Cursor is just a module hence you can reference it for later like so:
cursor = TTY::Cursor
and to move the cursor current position by 5 rows up and 2 columns right do:
print cursor.up(5) + cursor.forward(2)
or call move to move cursor relative to current position:
print cursor.move(5, 2)
to remove text from the current line do:
print cursor.clear_line
2. Interface
2.1 Cursor Positioning
All methods in this section allow to position the cursor around the terminal viewport.
Cursor movement will be bounded by the current viewport into the buffer. Scrolling (if available) will not occur.
2.1.1 move_to(x, y)
Set the cursor absolute position to x and y coordinate, where x is the column of the y line.
If no row/column parameters are provided, the cursor will move to the home position, at the upper left of the screen:
cursor.move_to
2.1.2 move(x, y)
Move cursor by x columns and y rows relative to its current position.
2.1.3 up(n)
Move the cursor up by n rows; the default n is 1.
2.1.4 down(n)
Move the cursor down by n rows; the default n is 1.
2.1.5 forward(n)
Move the cursor forward by n columns; the default n is 1.
2.1.6 backward(n)
Move the cursor backward by n columns; the default n is 1.
2.1.7 column(n)
Cursor moves to <n>th position horizontally in the current line.
2.1.8 row(n)
Cursor moves to the <n>th position vertically in the current column.
2.1.9 next_line
Move the cursor down to the beginning of the next line.
2.1.10 prev_line
Move the cursor up to the beginning of the previous line.
2.1.11 save
Save current cursor position.
2.1.12 restore
Restore cursor position after a save cursor was called.
2.1.13 current
Query current cursor position
2.2 Cursor Visibility
The following methods control the visibility of the cursor.
2.2.1 show
Show the cursor.
2.2.2 hide
Hide the cursor.
2.2.3 invisible(stream)
To hide the cursor for the duration of the block do:
cursor.invisible { ... }
By default standard output will be used but you can change that by passing a different stream that responds to print call:
cursor.invisible($stderr) { .... }
2.3 Text Clearing
All methods in this section provide APIs to modify text buffer contents.
2.3.1 clear_char(n)
Erase <n> characters from the current cursor position by overwriting them with space character.
2.3.2 clear_line
Erase the entire current line and return cursor to beginning of the line.
2.3.3 clear_line_before
Erase from the beginning of the line up to and including the current position.
2.3.4 clear_line_after
Erase from the current position (inclusive) to the end of the line/display.
2.3.5 clear_lines(n, direction)
Erase n rows in given direction; the default direction is :up.
cursor.clear_lines(5, :down)
2.3.6 clear_screen
Erase the screen with the background colour and moves the cursor to home.
2.3.7 clear_screen_down
Erase the screen from the current line down to the bottom of the screen.
2.3.8 clear_screen_up
Erase the screen from the current line up to the top of the screen.
2.4 Scrolling
2.4.1 scroll_down
Scroll display down one line.
2.4.2 scroll_up
Scroll display up one line.
Contributing
- Fork it ( https://github.com/piotrmurach/tty-cursor/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Code of Conduct
Everyone interacting in the Strings::Inflection project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Copyright
Copyright (c) 2015 Piotr Murach. See LICENSE for further details.
Owner metadata
- Name: Piotr Murach
- Login: piotrmurach
- Email:
- Kind: user
- Description: Tender loving command line.
- Website: https://piotrmurach.com
- Location: Sheffield / Olsztyn
- Twitter: piotr_murach
- Company:
- Icon url: https://avatars.githubusercontent.com/u/444312?v=4
- Repositories: 89
- Last ynced at: 2025-11-23T03:03:05.684Z
- Profile URL: https://github.com/piotrmurach
GitHub Events
Total
- Watch event: 7
- Issue comment event: 2
- Push event: 5
- Pull request event: 2
- Fork event: 1
Last Year
- Watch event: 6
- Issue comment event: 2
- Push event: 5
- Pull request event: 2
- Fork event: 1
Committers metadata
Last synced: 7 days ago
Total Commits: 131
Total Committers: 5
Avg Commits per committer: 26.2
Development Distribution Score (DDS): 0.061
Commits in past year: 5
Committers in past year: 1
Avg Commits per committer in past year: 5.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Piotr Murach | p****h@g****m | 123 |
| Austin Blatt | a****t@g****m | 3 |
| moe | m****e@b****t | 2 |
| Xinyue Lu | i@7****n | 2 |
| Aaron Lasseigne | a****e@g****m | 1 |
Committer domains:
- 7086.in: 1
- busyloop.net: 1
Issue and Pull Request metadata
Last synced: 2 months ago
Total issues: 5
Total pull requests: 8
Average time to close issues: 14 days
Average time to close pull requests: 6 days
Total issue authors: 4
Total pull request authors: 5
Average comments per issue: 2.2
Average comments per pull request: 3.13
Merged pull request: 6
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 2
Past year average time to close issues: N/A
Past year average time to close pull requests: 23 days
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 2.0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- austb (2)
- jitlogan (1)
- ghost (1)
- weshatheleopard (1)
Top Pull Request Authors
- austb (3)
- aaronmallen (2)
- AaronLasseigne (1)
- m-o-e (1)
- msg7086 (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 4
-
Total downloads:
- rubygems: 373,675,840 total
- Total docker downloads: 1,004,253,824
- Total dependent packages: 68 (may contain duplicates)
- Total dependent repositories: 23,253 (may contain duplicates)
- Total versions: 29
- Total maintainers: 1
gem.coop: tty-cursor
The purpose of this library is to help move the terminal cursor around and manipulate text by using intuitive method calls.
- Homepage: https://ttytoolkit.org
- Documentation: http://www.rubydoc.info/gems/tty-cursor/
- Licenses: MIT
- Latest release: 0.7.1 (published almost 6 years ago)
- Last Synced: 2025-12-10T09:41:48.354Z (1 day ago)
- Versions: 9
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 186,895,164 Total
- Docker Downloads: 502,126,912
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.082%
- Downloads: 0.133%
- Docker downloads count: 0.197%
- Maintainers (1)
rubygems.org: tty-cursor
The purpose of this library is to help move the terminal cursor around and manipulate text by using intuitive method calls.
- Homepage: https://ttytoolkit.org
- Documentation: http://www.rubydoc.info/gems/tty-cursor/
- Licenses: MIT
- Latest release: 0.7.1 (published almost 6 years ago)
- Last Synced: 2025-12-09T19:03:48.837Z (2 days ago)
- Versions: 9
- Dependent Packages: 67
- Dependent Repositories: 23,253
- Downloads: 186,780,676 Total
- Docker Downloads: 502,126,912
-
Rankings:
- Downloads: 0.169%
- Dependent repos count: 0.233%
- Docker downloads count: 0.246%
- Dependent packages count: 0.432%
- Average: 2.602%
- Stargazers count: 6.531%
- Forks count: 7.999%
- Maintainers (1)
proxy.golang.org: github.com/piotrmurach/tty-cursor
- Homepage:
- Documentation: https://pkg.go.dev/github.com/piotrmurach/tty-cursor#section-documentation
- Licenses: mit
- Latest release: v0.7.1 (published almost 6 years ago)
- Last Synced: 2025-12-09T19:03:49.794Z (2 days ago)
- Versions: 9
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 5.169%
- Forks count: 5.952%
- Average: 7.875%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
conda-forge.org: rb-tty-cursor
- Homepage: https://rubygems.org/gems/tty-cursor
- Licenses: MIT
- Latest release: 0.7.1 (published about 4 years ago)
- Last Synced: 2025-12-01T10:04:13.091Z (11 days ago)
- Versions: 2
- Dependent Packages: 1
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 28.82%
- Dependent repos count: 34.025%
- Average: 34.077%
- Stargazers count: 34.46%
- Forks count: 39.002%
Dependencies
- coveralls_reborn ~> 0.21.0 development
- simplecov ~> 0.21.0 development
- yardstick ~> 0.9.9 development
- bundler >= 1.6 development
- rake >= 0 development
- rspec ~> 3.1 development
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
Score: 26.997109189429906