Project

just-ansi

0.0
The project is in a healthy, maintained state
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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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'