crolorama

Version, currently main branch1 version
  • main branchlatestMay 22, 2023

github.com/simplylu/crolorama

Crystal shard for colored text in the Terminal

3 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  crolorama:
    github: simplylu/crolorama
    branch: main

main is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
1.3.2
License
MIT
Author
simplylu @s1mplylu

Dependencies

This version declares no dependencies.

README

crolorama

Easy text coloring and styling in Crystal. Currently only support for systems with ANSI support.

Tested only on Linux.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      crolorama:
        github: simplylu/crolorama
  2. Run shards install

Usage

require "crolorama"
crol = Crolorama::Color.new

puts "This is #{crol.fg("red")}RED#{crol.reset}"

Available methods

  • Change foreground color: crol.fg
  • Change background color: crol.bg
  • Change text style: crol.style
  • Reset colors: crol.reset
  • Reset all (including styles): crol.reset_all

Experimental

  • Move cursor n lines up: crol.up n
  • Move cursor n lines down: crol.down n
  • Move cursor n lines forward: crol.forward n
  • Move cursor n lines back: crol.back n
  • Position cursor at x across, y down: crol.pos x, y

Example: crystal run src/example.cr

Available colors: crystal run src/colors.cr

Development

This shard is mainly oriented towards the colorama module of python. In case you wanna add new features, see Contributing.

Contributing

  1. Fork it (https://github.com/simplylu/crolorama/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors