cransi
Version, currently 0.1.01 version
- 0.1.0latestSep 30, 2019
github.com/daviscodesbugs/cransi
ANSI escape codes for terminal manipulation
0 stars
0 dependents
License: GPL
Installation
# Add this to your shard.yml
dependencies:
cransi:
github: daviscodesbugs/cransi
version: ~> 0.1.0Then run:
shards installshard.yml
- Crystal
0.30.1- License
- GPL
- Author
- daviscodsbugs
Dependencies
This version declares no dependencies.
README
cransi
ANSI escape codes for terminal manipulation
Installation
- Add the dependency to your
shard.yml:
dependencies:
cransi:
github: daviscodesbugs/cransi
- Run
shards install
Usage
require "cransi"
puts "Hello world!\nThanks for checking out cransi!"
print Cransi.cursor_save
wait
print Cransi.cursor_prev_line 2
wait
print Cransi.cursor_col 6
wait
print Cransi.insert_char 7
wait
print " there,"
wait
print Cransi.cursor_restore
wait
puts "Try this example with SLOW = true"
wait
SLOW = false
def wait
sleep 1.second if SLOW
end
Final output
Hello there, world!
Thanks for checking out cransi!
Try this example with SLOW = true
API
Additional documentation can be found here
Cursor Movement
cursor_upMove the cursor upcursor_downMove the cursor downcursor_forwardMove the cursor forwardcursor_backwardMove the cursor backwardcursor_next_lineMove the cursor to the beginning of the next linecursor_prev_lineMove the cursor to the beginning of the previous linecursor_colMove the cursor to a specific columncursor_toMove the cursor to a specific row & columncursor_saveSave the current position of the cursor to latercursor_restoretocursor_restoreRestore the cursor to the position whencursor_savewas last calledcursor_showShow the cursorcursor_hideHide the cursorcursor_get_posGet the current position of the cursorcursor_homeReturn the cursor to row 0, column 0
Erase
For the following, a cell that is "erased" can also be thought of as blank
erase_charsMark cells from cursor as erasederase_endMark cells from the cursor the end of the line as erasederase_homeMark cells from the beginning of the line to the cursor as erasederase_lineMark the entire line as erasederase_downMark cells from the cursor the the bottom of the display as erasederase_upMark cells from the top of the display to the cursor as erasederase_screenMark the entire display as erasederase_terminalMark the entire display and the scroll-back buffer as erased
Insert
insert_charInsert cells, shifting the rest of the line forwardinsert_lineInsert lines, shifting the current line downward
Delete
delete_charDelete cells, shifting the rest of the line backwarddelete_lineDelete lines, shifting following lines upward
Misc
repeatRepeat the last printable characterscroll_upShift all lines upward, generating new linesscroll_downShift all lines downward
Contributing
- Fork it (https://github.com/daviscodesbugs/cransi/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
Contributors
- daviscodsbugs - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Sep 30, 2019
- Commit
0aaf2aa3a037- Crystal
0.30.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/daviscodesbugs/cransi
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 17, 2026
- Synced
- Aug 17, 2026
- Versions
- 1