Sha256: 56679acaa0b657a429e164b49fef606fe8395ce985dd745bad9cdd742f6416eb

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Vedeu
  module Esc
    extend self

    def set_position(y = 1, x = 1)
      row    = (y == 0 || y == nil) ? 1 : y
      column = (x == 0 || x == nil) ? 1 : x

      ["\e[", row, ';', column, 'H'].join
    end

    def string(value = '')
      case value
      when 'bg_reset'      then "\e[48;2;49m"
      when 'blink'         then "\e[5m"
      when 'blink_off'     then "\e[25m"
      when 'bold'          then "\e[1m"
      when 'bold_off'      then "\e[21m"
      when 'clear'         then "\e[38;2;39m\e[48;2;49m\e[2J"
      when 'colour_reset'  then "\e[38;2;39m\e[48;2;49m"
      when 'fg_reset'      then "\e[38;2;39m"
      when 'hide_cursor'   then "\e[?25l"
      when 'negative'      then "\e[7m"
      when 'positive'      then "\e[27m"
      when 'reset'         then "\e[0m"
      when 'normal'        then "\e[24m\e[21m\e[27m"
      when 'dim'           then "\e[2m"
      when 'show_cursor'   then "\e[?25h"
      when 'underline'     then "\e[4m"
      when 'underline_off' then "\e[24m"
      else
        ''
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.7 lib/vedeu/support/esc.rb