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, #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
#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.
60 61 62 63 64 |
# File 'lib/vedeu/esc/esc.rb', line 60 def border(&block) return '' unless block_given? border_on + yield + border_off end |
#clear ⇒ String
67 68 69 |
# File 'lib/vedeu/esc/esc.rb', line 67 def clear "#{colour_reset}\e[2J" end |
#clear_line ⇒ String
83 84 85 |
# File 'lib/vedeu/esc/esc.rb', line 83 def clear_line "#{colour_reset}\e[2K" end |
#colour_reset ⇒ String
88 89 90 |
# File 'lib/vedeu/esc/esc.rb', line 88 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.
34 35 36 37 38 |
# File 'lib/vedeu/esc/esc.rb', line 34 def escape(stream = '') return stream if absent?(stream) stream.gsub(/\e/, '\\e') end |
#last_character_position ⇒ String
103 104 105 |
# File 'lib/vedeu/esc/esc.rb', line 103 def last_character_position Vedeu::Geometries::Position.coerce([Vedeu.height, Vedeu.width]).to_s end |
#normal ⇒ String
93 94 95 |
# File 'lib/vedeu/esc/esc.rb', line 93 def normal "#{underline_off}#{bold_off}#{positive}" end |
#screen_colour_reset ⇒ String
98 99 100 |
# File 'lib/vedeu/esc/esc.rb', line 98 def screen_colour_reset "#{fg_reset}#{bg_reset}" end |
#screen_exit ⇒ String
77 78 79 80 |
# File 'lib/vedeu/esc/esc.rb', line 77 def screen_exit "#{disable_mouse}#{show_cursor}#{screen_colour_reset}#{reset}" \ "#{last_character_position}\n" end |
#screen_init ⇒ String
72 73 74 |
# File 'lib/vedeu/esc/esc.rb', line 72 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.
46 47 48 49 50 51 52 |
# File 'lib/vedeu/esc/esc.rb', line 46 def string(value = '') return '' unless present?(value) send(value) rescue NoMethodError '' end |