ansi-escapes
Version, currently 1.0.01 version
- 1.0.0latestMar 30, 2021
github.com/gtramontina/ansi-escapes.cr
ANSI escape codes for manipulating the terminal
7 stars
4 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
ansi-escapes:
github: gtramontina/ansi-escapes.cr
version: ~> 1.0.0Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- Guilherme J. Tramontina
Dependencies
This version declares no dependencies.
README
ansi-escapes.cr 
ANSI escape codes for manipulating the terminal.
A copycat of ansi-escapes for javascript by @sindresorhus. Thank you!
Installation
Add this to your application's shard.yml:
dependencies:
ansi-escapes:
github: gtramontina/ansi-escapes.cr
Usage
require "ansi-escapes"
# move the cursor two rows up and to the left
puts "#{AnsiEscapes::Cursor.up(2)}#{AnsiEscapes::Cursor::LEFT}HI!" # => "\u001b[2A\u001b[1000DHI!"
You might want to include AnsiEscapes so your code reads a little better:
require "ansi-escapes"
include AnsiEscapes
# move the cursor two rows up and to the left
puts "#{Cursor.up(2)}#{Cursor::LEFT}HI!" # => "\u001b[2A\u001b[1000DHI!"
API
AnsiEscapes::ESC: The escape string.AnsiEscapes::BEEP: Output a beeping sound.AnsiEscapes::Cursor::LEFT: Move cursor to the left side.AnsiEscapes::Cursor::SAVE_POSITION: Save cursor position.AnsiEscapes::Cursor::RESTORE_POSITION: Restore saved cursor position.AnsiEscapes::Cursor::GET_POSITION: Get cursor position.AnsiEscapes::Cursor::NEXT_LINE: Move cursor to the next line.AnsiEscapes::Cursor::PREVIOUS_LINE: Move cursor to the previous line.AnsiEscapes::Cursor::HIDE: Hide cursor.AnsiEscapes::Cursor::SHOW: Show cursor.AnsiEscapes::Cursor.home: Move the cursor to the home position at the upper-left corner of the screen (x0y0).AnsiEscapes::Cursor.to(x : Int32): Absolutely set cursor column.AnsiEscapes::Cursor.to(x : Int32, y : Int32): Absolutely set cursor column and row.AnsiEscapes::Cursor.up(count = 1): Move cursor up a specific amount of rows.AnsiEscapes::Cursor.down(count = 1): Move cursor down a specific amount of rows.AnsiEscapes::Cursor.forward(count = 1): Move cursor forward a specific amount of columns.AnsiEscapes::Cursor.backward(count = 1): Move cursor backward a specific amount of columns.AnsiEscapes::Cursor.move(x : Int32, y : Int32): Set the position of the cursor relative to its current position.AnsiEscapes::Erase::END_LINE: Erase from the current cursor position to the end of the current line.AnsiEscapes::Erase::START_LINE: Erase from the current cursor position to the start of the current line.AnsiEscapes::Erase::LINE: Erase the entire current line.AnsiEscapes::Erase::DOWN: Erase the screen from the current line down to the bottom of the screen.AnsiEscapes::Erase::UP: Erase the screen from the current line up to the top of the screen.AnsiEscapes::Erase.lines(count : Int32): Erase from the current cursor position up the specified amount of rows.AnsiEscapes::Erase::SCREEN: Erase the screen and move the cursor home.AnsiEscapes::Screen::UP: Scroll display up one line.AnsiEscapes::Screen::DOWN: Scroll display down one line.
Contributing
- Fork it ( https://github.com/gtramontina/ansi-escapes.cr/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
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.0- Tagged
- Mar 30, 2021
- Commit
5e2ed92accdf- Indexed
- yes
Dependents
Repository
github.com/gtramontina/ansi-escapes.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 1, 2026
- Synced
- Aug 31, 2026
- Versions
- 1