just-ansi

Simple and fast ANSI control code processing.

MIT License

Downloads
425
Stars
0

JustAnsi version

Simple and fast ANSI control code processing.

Description

JustAnsi provides a rich set of methods to generate ANSI control codes for attributes, colors, cursor movement and much more. It supports most control codes, all attributes, 3/4bit-, 8bit- and 24bit-colors.

hello = JustAnsi.decorate('Hello World!', :bold, :red)
# => "\e[1;31mHello World!\e[m"

JustAnsi.undecorate(hello)
# => 'Hello World!'

JustAnsi.bbcode('[b]Hello [red]World[/fg]![/b]')
# => "\e[1mHello \e[31mWorld\e[39m!\e[22m"

Help

📕 See the online help and have a look at the examples directory.

Run Examples

You can execute the examples by

ruby ./examples/bbcode.rb

Installation

You can install the gem in your system with

gem install just-ansi

or you can use Bundler to add JustAnsi to your own project:

bundle add just-ansi

After that you only need one line of code to have everything together

require 'just-ansi'
Package Rankings