Module: Vedeu::EscapeSequences::Esc
- Extended by:
- Esc
- Includes:
- Common, Actions, Background, Borders, Colours, Foreground, Mouse
- Included in:
- Esc
- Defined in:
- lib/vedeu/esc/esc.rb
Overview
Provides escape sequence strings for setting the cursor position and various display related functions.
Instance Method Summary collapse
-
#border(&block) ⇒ String
Return the escape sequence to render a border character.
- #clear ⇒ String
- #clear_line ⇒ String
- #colour_reset ⇒ String
- #esc ⇒ Vedeu::EscapeSequences::Esc
-
#escape(stream = '') ⇒ String
Return the stream with the escape sequences escaped so that they can be printed to the terminal instead of being interpreted by the terminal which will render them.
- #last_character_position ⇒ String
- #normal ⇒ String
- #screen_colour_reset ⇒ String
- #screen_exit ⇒ String
- #screen_init ⇒ String
-
#string(value = '') ⇒ String
Return the escape sequence string from the list of recognised sequence ‘commands’, or an empty string when the ‘command’ cannot be found.
Methods included from Mouse
#disable_mouse, #enable_mouse, #mouse_off, #mouse_on, #mouse_x10_off, #mouse_x10_on
Methods included from Foreground
#black, #blue, #cyan, #dark_grey, #default, #foreground, #green, #light_blue, #light_cyan, #light_green, #light_grey, #light_magenta, #light_red, #light_yellow, #magenta, #red, #white, #yellow
Methods included from Colours
#background_codes, #background_colour, #colour, #foreground_codes, #valid_codes, #valid_name?
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Methods included from Borders
#border_off, #border_on, #bottom_left, #bottom_right, #horizontal, #horizontal_bottom, #horizontal_top, #top_left, #top_right, #vertical, #vertical_left, #vertical_right
Methods included from Background
#background, #on_black, #on_blue, #on_cyan, #on_dark_grey, #on_default, #on_green, #on_light_blue, #on_light_cyan, #on_light_green, #on_light_grey, #on_light_magenta, #on_light_red, #on_light_yellow, #on_magenta, #on_red, #on_white, #on_yellow
Methods included from Actions
#bg_reset, #blink, #blink_off, #bold, #bold_off, #cursor_position, #dim, #fg_reset, #hide_cursor, #negative, #positive, #reset, #show_cursor, #underline, #underline_off
Instance Method Details
#border(&block) ⇒ String
Return the escape sequence to render a border character.
62 63 64 65 66 |
# File 'lib/vedeu/esc/esc.rb', line 62 def border(&block) return '' unless block_given? border_on + yield + border_off end |
#clear ⇒ String
69 70 71 |
# File 'lib/vedeu/esc/esc.rb', line 69 def clear "#{colour_reset}\e[2J" end |
#clear_line ⇒ String
85 86 87 |
# File 'lib/vedeu/esc/esc.rb', line 85 def clear_line "#{colour_reset}\e[2K" end |
#colour_reset ⇒ String
90 91 92 |
# File 'lib/vedeu/esc/esc.rb', line 90 def colour_reset Vedeu::Colours::Colour.coerce(Vedeu.config.colour).to_s end |
#escape(stream = '') ⇒ String
Return the stream with the escape sequences escaped so that they can be printed to the terminal instead of being interpreted by the terminal which will render them. This way we can see what escape sequences are being sent along with the content.
36 37 38 39 40 |
# File 'lib/vedeu/esc/esc.rb', line 36 def escape(stream = '') return stream if absent?(stream) stream.gsub(/\e/, '\\e') end |
#last_character_position ⇒ String
105 106 107 |
# File 'lib/vedeu/esc/esc.rb', line 105 def last_character_position Vedeu::Geometries::Position.coerce([Vedeu.height, Vedeu.width]).to_s end |
#normal ⇒ String
95 96 97 |
# File 'lib/vedeu/esc/esc.rb', line 95 def normal "#{underline_off}#{bold_off}#{positive}" end |
#screen_colour_reset ⇒ String
100 101 102 |
# File 'lib/vedeu/esc/esc.rb', line 100 def screen_colour_reset "#{fg_reset}#{bg_reset}" end |
#screen_exit ⇒ String
79 80 81 82 |
# File 'lib/vedeu/esc/esc.rb', line 79 def screen_exit "#{disable_mouse}#{show_cursor}#{screen_colour_reset}#{reset}" \ "#{last_character_position}\n" end |
#screen_init ⇒ String
74 75 76 |
# File 'lib/vedeu/esc/esc.rb', line 74 def screen_init "#{reset}#{clear}#{hide_cursor}#{enable_mouse}" end |
#string(value = '') ⇒ String
Return the escape sequence string from the list of recognised sequence ‘commands’, or an empty string when the ‘command’ cannot be found.
48 49 50 51 52 53 54 |
# File 'lib/vedeu/esc/esc.rb', line 48 def string(value = '') return '' unless present?(value) send(value) rescue NoMethodError '' end |