Class: ANSI
Constant Summary collapse
- ESC =
27.chr
Class Method Summary collapse
- .clear ⇒ Object
- .clear_line ⇒ Object
- .color(fg, bg = :default) ⇒ Object
- .cursor_up(lines) ⇒ Object
- .escape(sequence) ⇒ Object
- .hide_cursor ⇒ Object
- .inverse ⇒ Object
- .reset ⇒ Object
- .show_cursor ⇒ Object
Class Method Details
.clear ⇒ Object
703 704 705 |
# File 'lib/selecta.rb', line 703 def clear escape "2J" end |
.clear_line ⇒ Object
719 720 721 |
# File 'lib/selecta.rb', line 719 def clear_line escape "2K" end |
.color(fg, bg = :default) ⇒ Object
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
# File 'lib/selecta.rb', line 723 def color(fg, bg=:default) fg_codes = { :black => 30, :red => 31, :green => 32, :yellow => 33, :blue => 34, :magenta => 35, :cyan => 36, :white => 37, :default => 39, } bg_codes = { :black => 40, :red => 41, :green => 42, :yellow => 43, :blue => 44, :magenta => 45, :cyan => 46, :white => 47, :default => 49, } fg_code = fg_codes.fetch(fg) bg_code = bg_codes.fetch(bg) escape "#{fg_code};#{bg_code}m" end |
.cursor_up(lines) ⇒ Object
715 716 717 |
# File 'lib/selecta.rb', line 715 def cursor_up(lines) escape "#{lines}A" end |
.escape(sequence) ⇒ Object
699 700 701 |
# File 'lib/selecta.rb', line 699 def escape(sequence) ESC + "[" + sequence end |
.hide_cursor ⇒ Object
707 708 709 |
# File 'lib/selecta.rb', line 707 def hide_cursor escape "?25l" end |
.inverse ⇒ Object
751 752 753 |
# File 'lib/selecta.rb', line 751 def inverse escape("7m") end |
.reset ⇒ Object
755 756 757 |
# File 'lib/selecta.rb', line 755 def reset escape("0m") end |
.show_cursor ⇒ Object
711 712 713 |
# File 'lib/selecta.rb', line 711 def show_cursor escape "?25h" end |