Module | Console::ANSICode
In: | lib/facets/more/ansicode.rb

# ANSICode

Module which makes it very easy to use ANSI codes. These are esspecially nice for beautifying shell output.

## Synopsis

      include Console::ANSICode

      p red, "Hello", blue, "World"
      => "\e[31mHello\e[34mWorld"

      p red { "Hello" } + blue { "World" }
      => "\e[31mHello\e[0m\e[34mWorld\e[0m"

## Supported ANSI Commands

        save
        restore
        clear_screen
        cls             # synonym for :clear_screen
        clear_line
        clr             # synonym for :clear_line
        move
        up
        down
        left
        right
        display

        clear
        reset           # synonym for :clear
        bold
        dark
        italic          # not widely implemented
        underline
        underscore      # synonym for :underline
        blink
        rapid_blink     # not widely implemented
        negative        # no reverse because of String#reverse
        concealed
        strikethrough   # not widely implemented

        black
        red
        green
        yellow
        blue
        magenta
        cyan
        white

        on_black
        on_red
        on_green
        on_yellow
        on_blue
        on_magenta
        on_cyan
        on_white

### Methods

clear_line clear_screen clr cls colors define_ansicolor_method display down left move restore right save uncolored up

### Constants

ColoredRegexp | = | /\e\[([34][0-7]|[0-9])m/

### Public Class methods

define_ansicolor_method(name,code)

Define color codes.

### Public Instance methods

clear_line()

Clear to the end of the current line.

clear_screen()

Clear the screen and move cursor to home.

clr()

Alias for clear_line

cls()

Alias for clear_screen

colors()
display( line, column=0, string=nil ) {|| ...}

Like `move` but returns to original positon after yielding block or adding string argument.

down( spaces=1 )

Move cursor down a specificed number of spaces.

left( spaces=1 )

Move cursor left a specificed number of spaces.

move( line, column=0 )

Move curose to line and column.

restore()

Restore saved cursor positon.

right( spaces=1 )

Move cursor right a specificed number of spaces.

save()

Save current cursor positon.

uncolored(string = nil) {|.gsub(ColoredRegexp, '')| ...}
up( spaces=1 )

Move cursor up a specificed number of spaces.

[Validate]