Module: Vedeu::Esc
Instance Method Summary collapse
- #background_colour(value = '#000000') ⇒ Object
- #foreground_colour(value = '#ffffff') ⇒ Object
- #set_position(y = 1, x = 1) ⇒ Object
- #string(value = '') ⇒ Object
Instance Method Details
#background_colour(value = '#000000') ⇒ Object
7 8 9 10 11 |
# File 'lib/vedeu/support/esc.rb', line 7 def background_colour(value = '#000000') return '' if value.empty? ["\e[48;5;", colour_translator(value), 'm'].join end |
#foreground_colour(value = '#ffffff') ⇒ Object
13 14 15 16 17 |
# File 'lib/vedeu/support/esc.rb', line 13 def foreground_colour(value = '#ffffff') return '' if value.empty? ["\e[38;5;", colour_translator(value), 'm'].join end |
#set_position(y = 1, x = 1) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/vedeu/support/esc.rb', line 19 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 |
#string(value = '') ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vedeu/support/esc.rb', line 26 def string(value = '') case value 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[2J" when 'colour_reset' then "\e[38;2;39m\e[48;2;49m" 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 |