Git Product home page Git Product logo

mruby-ansi-colors's Introduction

# mruby-ansi-colors
Extends String class to use ANSI color escape codes.

# Returns an Hash with every color code pair.
"".color_codes
=> {:black=>30, :light_black=>90, :bg_black=>40, :bg_light_black=>100, :red=>31, :light_red=>91, :bg_red=>41, :bg_light_red=>101, :green=>32, :light_green=>92, :bg_green=>42, :bg_light_green=>102, :yellow=>33, :light_yellow=>93, :bg_yellow=>43, :bg_light_yellow=>103, :blue=>34, :light_blue=>94, :bg_blue=>44, :bg_light_blue=>104, :magenta=>35, :light_magenta=>95, :bg_magenta=>45, :bg_light_magenta=>105, :cyan=>36, :light_cyan=>96, :bg_cyan=>46, :bg_light_cyan=>106, :white=>37, :light_white=>97, :bg_white=>47, :bg_light_white=>107, :default=>39, :bg_default=>49}

# Returns and Array of Symbols representing every color.
"".colors
=> [:black, :light_black, :bg_black, :bg_light_black, :red, :light_red, :bg_red, :bg_light_red, :green, :light_green, :bg_green, :bg_light_green, :yellow, :light_yellow, :bg_yellow, :bg_light_yellow, :blue, :light_blue, :bg_blue, :bg_light_blue, :magenta, :light_magenta, :bg_magenta, :bg_light_magenta, :cyan, :light_cyan, :bg_cyan, :bg_light_cyan, :white, :light_white, :bg_white, :bg_light_white, :default, :bg_default]

# Returns a Hash of mode codes(different state the text can be displayed in).
"".mode_codes
=> {:default=>0, :bold=>1, :italic=>3, :underline=>4, :blink=>5, :swap=>7, :hide=>8}
default: 0, # Turn off all attributes
bold: 1, # Set bold mode
italic: 3, # Set italic mode
underline: 4, # Set underline mode
blink: 5, # Set blink mode
swap: 7, # Exchange foreground and background colors
hide: 8 # Hide text (foreground color would be the same as background)

# Returns and Array of modes.
"".modes
=> [:default, :bold, :italic, :underline, :blink, :swap, :hide]

# Sets the strings color, and mode.
String.set_color(fg_color, bg_color = :bg_default, mode = :default)
"".set_color(:red, :bg_blue, :bold)
alias color

# Example
Using this library is as easy as this: "My dog is red!".red

mruby-ansi-colors's People

Contributors

katzer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.