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.
Class Method Summary collapse
-
.absent?(variable) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
.background_codes ⇒ Hash<Symbol => Fixnum>
extended
from Colours
Produces the background named colour escape sequence hash from the foreground escape sequence hash.
- .background_colour(named_colour, &block) ⇒ String extended from Colours
-
.become(klass, attributes) ⇒ Class
extended
from Common
private
Converts one class into another.
- .bg_reset ⇒ String extended from Actions
- .black(&block) ⇒ String extended from Foreground
- .blink ⇒ String extended from Actions
- .blink_off ⇒ String extended from Actions
- .blue(&block) ⇒ String extended from Foreground
- .bold ⇒ String extended from Actions
- .bold_off ⇒ String extended from Actions
-
.boolean(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the value was a boolean.
-
.boolean?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Boolean.
-
.border(&block) ⇒ String
Return the escape sequence to render a border character.
- .border_off ⇒ String extended from Borders
- .border_on ⇒ String extended from Borders
-
.bottom_left ⇒ String
extended
from Borders
└ # u2514.
-
.bottom_right ⇒ String
extended
from Borders
Produces ‘┘’ (u2518).
- .clear ⇒ String
- .clear_line ⇒ String
- .colour(named_colour, &block) ⇒ String (also: #foreground_colour) extended from Colours
- .colour_reset ⇒ String
- .cursor_position ⇒ String extended from Actions
- .cyan(&block) ⇒ String extended from Foreground
- .dark_grey(&block) ⇒ String extended from Foreground
- .default(&block) ⇒ String extended from Foreground
- .dim ⇒ String extended from Actions
- .disable_mouse ⇒ String extended from Mouse
- .enable_mouse ⇒ String extended from Mouse
- .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.
-
.escape?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
.falsy?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value should be considered false.
- .fg_reset ⇒ String extended from Actions
-
.foreground_codes ⇒ Hash<Symbol => Fixnum>
extended
from Colours
Produces the foreground named colour escape sequence hash.
- .green(&block) ⇒ String extended from Foreground
-
.hash?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Hash.
- .hide_cursor ⇒ String extended from Actions
-
.horizontal ⇒ String
extended
from Borders
Produces ‘─’ (u2500).
-
.horizontal_bottom ⇒ String
extended
from Borders
Produces ‘┴’ (u2534).
-
.horizontal_top ⇒ String
extended
from Borders
Produces ‘┬’ (u252C).
- .last_character_position ⇒ String
- .light_blue(&block) ⇒ String extended from Foreground
- .light_cyan(&block) ⇒ String extended from Foreground
- .light_green(&block) ⇒ String extended from Foreground
- .light_grey(&block) ⇒ String extended from Foreground
- .light_magenta(&block) ⇒ String extended from Foreground
- .light_red(&block) ⇒ String extended from Foreground
- .light_yellow(&block) ⇒ String extended from Foreground
-
.line_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::Line.
- .magenta(&block) ⇒ String extended from Foreground
- .mouse_off ⇒ String extended from Mouse
- .mouse_on ⇒ String extended from Mouse
- .mouse_x10_off ⇒ String extended from Mouse
- .mouse_x10_on ⇒ String extended from Mouse
- .negative ⇒ String extended from Actions
- .normal ⇒ String
-
.numeric?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- .on_black(&block) ⇒ String extended from Background
- .on_blue(&block) ⇒ String extended from Background
- .on_cyan(&block) ⇒ String extended from Background
- .on_dark_grey(&block) ⇒ String extended from Background
- .on_default(&block) ⇒ String extended from Background
- .on_green(&block) ⇒ String extended from Background
- .on_light_blue(&block) ⇒ String extended from Background
- .on_light_cyan(&block) ⇒ String extended from Background
- .on_light_green(&block) ⇒ String extended from Background
- .on_light_grey(&block) ⇒ String extended from Background
- .on_light_magenta(&block) ⇒ String extended from Background
- .on_light_red(&block) ⇒ String extended from Background
- .on_light_yellow(&block) ⇒ String extended from Background
- .on_magenta(&block) ⇒ String extended from Background
- .on_red(&block) ⇒ String extended from Background
- .on_white(&block) ⇒ String extended from Background
- .on_yellow(&block) ⇒ String extended from Background
- .positive ⇒ String extended from Actions
-
.present?(variable) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether a variable has a useful value.
- .red(&block) ⇒ String extended from Foreground
- .reset ⇒ String extended from Actions
- .screen_colour_reset ⇒ String
- .screen_exit ⇒ String
- .screen_init ⇒ String
- .show_cursor ⇒ String extended from Actions
-
.snake_case(klass) ⇒ String
extended
from Common
private
Converts a class name to a lowercase snake case string.
-
.stream_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
.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.
-
.string?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
.top_left ⇒ String
extended
from Borders
Produces ‘┌’ (u250C).
-
.top_right ⇒ String
extended
from Borders
Produces ‘┐’ (u2510).
-
.truthy?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value should be considered true.
- .underline ⇒ String extended from Actions
- .underline_off ⇒ String extended from Actions
- .valid_codes ⇒ Array<Symbol> extended from Colours
-
.valid_name?(named_colour) ⇒ Boolean
extended
from Colours
Returns a boolean indicating whether the colour provided is a valid named colour.
-
.vertical ⇒ String
extended
from Borders
Produces ‘│’ (u2502).
-
.vertical_left ⇒ String
extended
from Borders
Produces ‘├’ (u251C).
-
.vertical_right ⇒ String
extended
from Borders
Produces ‘┤’ (u2524).
-
.view_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::View.
- .white(&block) ⇒ String extended from Foreground
- .yellow(&block) ⇒ String extended from Foreground
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#background_codes ⇒ Hash<Symbol => Fixnum>
included
from Colours
Produces the background named colour escape sequence hash from the foreground escape sequence hash.
- #background_colour(named_colour, &block) ⇒ String included from Colours
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
- #bg_reset ⇒ String included from Actions
- #black(&block) ⇒ String included from Foreground
- #blink ⇒ String included from Actions
- #blink_off ⇒ String included from Actions
- #blue(&block) ⇒ String included from Foreground
- #bold ⇒ String included from Actions
- #bold_off ⇒ String included from Actions
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
-
#border(&block) ⇒ String
Return the escape sequence to render a border character.
- #border_off ⇒ String included from Borders
- #border_on ⇒ String included from Borders
-
#bottom_left ⇒ String
included
from Borders
└ # u2514.
-
#bottom_right ⇒ String
included
from Borders
Produces ‘┘’ (u2518).
- #clear ⇒ String
- #clear_line ⇒ String
- #colour(named_colour, &block) ⇒ String (also: #foreground_colour) included from Colours
- #colour_reset ⇒ String
- #cursor_position ⇒ String included from Actions
- #cyan(&block) ⇒ String included from Foreground
- #dark_grey(&block) ⇒ String included from Foreground
- #default(&block) ⇒ String included from Foreground
- #dim ⇒ String included from Actions
- #disable_mouse ⇒ String included from Mouse
- #enable_mouse ⇒ String included from Mouse
- #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.
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
- #fg_reset ⇒ String included from Actions
-
#foreground_codes ⇒ Hash<Symbol => Fixnum>
included
from Colours
Produces the foreground named colour escape sequence hash.
- #green(&block) ⇒ String included from Foreground
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
- #hide_cursor ⇒ String included from Actions
-
#horizontal ⇒ String
included
from Borders
Produces ‘─’ (u2500).
-
#horizontal_bottom ⇒ String
included
from Borders
Produces ‘┴’ (u2534).
-
#horizontal_top ⇒ String
included
from Borders
Produces ‘┬’ (u252C).
- #last_character_position ⇒ String
- #light_blue(&block) ⇒ String included from Foreground
- #light_cyan(&block) ⇒ String included from Foreground
- #light_green(&block) ⇒ String included from Foreground
- #light_grey(&block) ⇒ String included from Foreground
- #light_magenta(&block) ⇒ String included from Foreground
- #light_red(&block) ⇒ String included from Foreground
- #light_yellow(&block) ⇒ String included from Foreground
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
- #magenta(&block) ⇒ String included from Foreground
- #mouse_off ⇒ String included from Mouse
- #mouse_on ⇒ String included from Mouse
- #mouse_x10_off ⇒ String included from Mouse
- #mouse_x10_on ⇒ String included from Mouse
- #negative ⇒ String included from Actions
- #normal ⇒ String
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- #on_black(&block) ⇒ String included from Background
- #on_blue(&block) ⇒ String included from Background
- #on_cyan(&block) ⇒ String included from Background
- #on_dark_grey(&block) ⇒ String included from Background
- #on_default(&block) ⇒ String included from Background
- #on_green(&block) ⇒ String included from Background
- #on_light_blue(&block) ⇒ String included from Background
- #on_light_cyan(&block) ⇒ String included from Background
- #on_light_green(&block) ⇒ String included from Background
- #on_light_grey(&block) ⇒ String included from Background
- #on_light_magenta(&block) ⇒ String included from Background
- #on_light_red(&block) ⇒ String included from Background
- #on_light_yellow(&block) ⇒ String included from Background
- #on_magenta(&block) ⇒ String included from Background
- #on_red(&block) ⇒ String included from Background
- #on_white(&block) ⇒ String included from Background
- #on_yellow(&block) ⇒ String included from Background
- #positive ⇒ String included from Actions
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
- #red(&block) ⇒ String included from Foreground
- #reset ⇒ String included from Actions
- #screen_colour_reset ⇒ String
- #screen_exit ⇒ String
- #screen_init ⇒ String
- #show_cursor ⇒ String included from Actions
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#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.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#top_left ⇒ String
included
from Borders
Produces ‘┌’ (u250C).
-
#top_right ⇒ String
included
from Borders
Produces ‘┐’ (u2510).
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
- #underline ⇒ String included from Actions
- #underline_off ⇒ String included from Actions
- #valid_codes ⇒ Array<Symbol> included from Colours
-
#valid_name?(named_colour) ⇒ Boolean
included
from Colours
Returns a boolean indicating whether the colour provided is a valid named colour.
-
#vertical ⇒ String
included
from Borders
Produces ‘│’ (u2502).
-
#vertical_left ⇒ String
included
from Borders
Produces ‘├’ (u251C).
-
#vertical_right ⇒ String
included
from Borders
Produces ‘┤’ (u2524).
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
- #white(&block) ⇒ String included from Foreground
- #yellow(&block) ⇒ String included from Foreground
Class Method Details
.absent?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
.background_codes ⇒ Hash<Symbol => Fixnum> Originally defined in module Colours
Produces the background named colour escape sequence hash from the foreground escape sequence hash.
.background_colour(named_colour, &block) ⇒ String Originally defined in module Colours
.become(klass, attributes) ⇒ Class Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts one class into another.
.bg_reset ⇒ String Originally defined in module Actions
.black(&block) ⇒ String Originally defined in module Foreground
.blink ⇒ String Originally defined in module Actions
.blink_off ⇒ String Originally defined in module Actions
.blue(&block) ⇒ String Originally defined in module Foreground
.bold ⇒ String Originally defined in module Actions
.bold_off ⇒ String Originally defined in module Actions
.boolean(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the value was a boolean.
.boolean?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Boolean.
.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 |
.border_off ⇒ String Originally defined in module Borders
.border_on ⇒ String Originally defined in module Borders
.bottom_left ⇒ String Originally defined in module Borders
└ # u2514
.bottom_right ⇒ String Originally defined in module Borders
Produces ‘┘’ (u2518)
.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(named_colour, &block) ⇒ String Also known as: foreground_colour Originally defined in module Colours
.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 |
.cursor_position ⇒ String Originally defined in module Actions
.cyan(&block) ⇒ String Originally defined in module Foreground
.dark_grey(&block) ⇒ String Originally defined in module Foreground
.default(&block) ⇒ String Originally defined in module Foreground
.dim ⇒ String Originally defined in module Actions
.disable_mouse ⇒ String Originally defined in module Mouse
.enable_mouse ⇒ String Originally defined in module Mouse
.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 |
.escape?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
.falsy?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered false.
.fg_reset ⇒ String Originally defined in module Actions
.foreground_codes ⇒ Hash<Symbol => Fixnum> Originally defined in module Colours
Produces the foreground named colour escape sequence hash. The background escape sequences are also generated from this by adding 10 to the values. This hash gives rise to methods you can call directly on ‘Esc` to produce the desired colours:
.green(&block) ⇒ String Originally defined in module Foreground
.hash?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Hash.
.hide_cursor ⇒ String Originally defined in module Actions
.horizontal ⇒ String Originally defined in module Borders
Produces ‘─’ (u2500)
.horizontal_bottom ⇒ String Originally defined in module Borders
Produces ‘┴’ (u2534)
.horizontal_top ⇒ String Originally defined in module Borders
Produces ‘┬’ (u252C)
.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 |
.light_blue(&block) ⇒ String Originally defined in module Foreground
.light_cyan(&block) ⇒ String Originally defined in module Foreground
.light_green(&block) ⇒ String Originally defined in module Foreground
.light_grey(&block) ⇒ String Originally defined in module Foreground
.light_magenta(&block) ⇒ String Originally defined in module Foreground
.light_red(&block) ⇒ String Originally defined in module Foreground
.light_yellow(&block) ⇒ String Originally defined in module Foreground
.line_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Line.
.magenta(&block) ⇒ String Originally defined in module Foreground
.mouse_off ⇒ String Originally defined in module Mouse
.mouse_on ⇒ String Originally defined in module Mouse
.mouse_x10_off ⇒ String Originally defined in module Mouse
.mouse_x10_on ⇒ String Originally defined in module Mouse
.negative ⇒ String Originally defined in module Actions
.normal ⇒ String
93 94 95 |
# File 'lib/vedeu/esc/esc.rb', line 93 def normal "#{underline_off}#{bold_off}#{positive}" end |
.numeric?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
.on_black(&block) ⇒ String Originally defined in module Background
.on_blue(&block) ⇒ String Originally defined in module Background
.on_cyan(&block) ⇒ String Originally defined in module Background
.on_dark_grey(&block) ⇒ String Originally defined in module Background
.on_default(&block) ⇒ String Originally defined in module Background
.on_green(&block) ⇒ String Originally defined in module Background
.on_light_blue(&block) ⇒ String Originally defined in module Background
.on_light_cyan(&block) ⇒ String Originally defined in module Background
.on_light_green(&block) ⇒ String Originally defined in module Background
.on_light_grey(&block) ⇒ String Originally defined in module Background
.on_light_magenta(&block) ⇒ String Originally defined in module Background
.on_light_red(&block) ⇒ String Originally defined in module Background
.on_light_yellow(&block) ⇒ String Originally defined in module Background
.on_magenta(&block) ⇒ String Originally defined in module Background
.on_red(&block) ⇒ String Originally defined in module Background
.on_white(&block) ⇒ String Originally defined in module Background
.on_yellow(&block) ⇒ String Originally defined in module Background
.positive ⇒ String Originally defined in module Actions
.present?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
.red(&block) ⇒ String Originally defined in module Foreground
.reset ⇒ String Originally defined in module Actions
.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 |
.show_cursor ⇒ String Originally defined in module Actions
.snake_case(klass) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
.stream_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Stream.
.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 |
.string?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
.top_left ⇒ String Originally defined in module Borders
Produces ‘┌’ (u250C)
.top_right ⇒ String Originally defined in module Borders
Produces ‘┐’ (u2510)
.truthy?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered true.
.underline ⇒ String Originally defined in module Actions
.underline_off ⇒ String Originally defined in module Actions
.valid_codes ⇒ Array<Symbol> Originally defined in module Colours
.valid_name?(named_colour) ⇒ Boolean Originally defined in module Colours
Returns a boolean indicating whether the colour provided is a valid named colour.
.vertical ⇒ String Originally defined in module Borders
Produces ‘│’ (u2502)
.vertical_left ⇒ String Originally defined in module Borders
Produces ‘├’ (u251C)
.vertical_right ⇒ String Originally defined in module Borders
Produces ‘┤’ (u2524)
.view_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::View.
.white(&block) ⇒ String Originally defined in module Foreground
.yellow(&block) ⇒ String Originally defined in module Foreground
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
#background_codes ⇒ Hash<Symbol => Fixnum> Originally defined in module Colours
Produces the background named colour escape sequence hash from the foreground escape sequence hash.
#background_colour(named_colour, &block) ⇒ String Originally defined in module Colours
#become(klass, attributes) ⇒ Class Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts one class into another.
#bg_reset ⇒ String Originally defined in module Actions
#black(&block) ⇒ String Originally defined in module Foreground
#blink ⇒ String Originally defined in module Actions
#blink_off ⇒ String Originally defined in module Actions
#blue(&block) ⇒ String Originally defined in module Foreground
#bold ⇒ String Originally defined in module Actions
#bold_off ⇒ String Originally defined in module Actions
#boolean(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the value was a boolean.
#boolean?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Boolean.
#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 |
#border_off ⇒ String Originally defined in module Borders
#border_on ⇒ String Originally defined in module Borders
#bottom_left ⇒ String Originally defined in module Borders
└ # u2514
#bottom_right ⇒ String Originally defined in module Borders
Produces ‘┘’ (u2518)
#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(named_colour, &block) ⇒ String Also known as: foreground_colour Originally defined in module Colours
#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 |
#cursor_position ⇒ String Originally defined in module Actions
#cyan(&block) ⇒ String Originally defined in module Foreground
#dark_grey(&block) ⇒ String Originally defined in module Foreground
#default(&block) ⇒ String Originally defined in module Foreground
#dim ⇒ String Originally defined in module Actions
#disable_mouse ⇒ String Originally defined in module Mouse
#enable_mouse ⇒ String Originally defined in module Mouse
#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 |
#escape?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
#falsy?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered false.
#fg_reset ⇒ String Originally defined in module Actions
#foreground_codes ⇒ Hash<Symbol => Fixnum> Originally defined in module Colours
Produces the foreground named colour escape sequence hash. The background escape sequences are also generated from this by adding 10 to the values. This hash gives rise to methods you can call directly on ‘Esc` to produce the desired colours:
#green(&block) ⇒ String Originally defined in module Foreground
#hash?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Hash.
#hide_cursor ⇒ String Originally defined in module Actions
#horizontal ⇒ String Originally defined in module Borders
Produces ‘─’ (u2500)
#horizontal_bottom ⇒ String Originally defined in module Borders
Produces ‘┴’ (u2534)
#horizontal_top ⇒ String Originally defined in module Borders
Produces ‘┬’ (u252C)
#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 |
#light_blue(&block) ⇒ String Originally defined in module Foreground
#light_cyan(&block) ⇒ String Originally defined in module Foreground
#light_green(&block) ⇒ String Originally defined in module Foreground
#light_grey(&block) ⇒ String Originally defined in module Foreground
#light_magenta(&block) ⇒ String Originally defined in module Foreground
#light_red(&block) ⇒ String Originally defined in module Foreground
#light_yellow(&block) ⇒ String Originally defined in module Foreground
#line_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Line.
#magenta(&block) ⇒ String Originally defined in module Foreground
#mouse_off ⇒ String Originally defined in module Mouse
#mouse_on ⇒ String Originally defined in module Mouse
#mouse_x10_off ⇒ String Originally defined in module Mouse
#mouse_x10_on ⇒ String Originally defined in module Mouse
#negative ⇒ String Originally defined in module Actions
#normal ⇒ String
93 94 95 |
# File 'lib/vedeu/esc/esc.rb', line 93 def normal "#{underline_off}#{bold_off}#{positive}" end |
#numeric?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
#on_black(&block) ⇒ String Originally defined in module Background
#on_blue(&block) ⇒ String Originally defined in module Background
#on_cyan(&block) ⇒ String Originally defined in module Background
#on_dark_grey(&block) ⇒ String Originally defined in module Background
#on_default(&block) ⇒ String Originally defined in module Background
#on_green(&block) ⇒ String Originally defined in module Background
#on_light_blue(&block) ⇒ String Originally defined in module Background
#on_light_cyan(&block) ⇒ String Originally defined in module Background
#on_light_green(&block) ⇒ String Originally defined in module Background
#on_light_grey(&block) ⇒ String Originally defined in module Background
#on_light_magenta(&block) ⇒ String Originally defined in module Background
#on_light_red(&block) ⇒ String Originally defined in module Background
#on_light_yellow(&block) ⇒ String Originally defined in module Background
#on_magenta(&block) ⇒ String Originally defined in module Background
#on_red(&block) ⇒ String Originally defined in module Background
#on_white(&block) ⇒ String Originally defined in module Background
#on_yellow(&block) ⇒ String Originally defined in module Background
#positive ⇒ String Originally defined in module Actions
#present?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
#red(&block) ⇒ String Originally defined in module Foreground
#reset ⇒ String Originally defined in module Actions
#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 |
#show_cursor ⇒ String Originally defined in module Actions
#snake_case(klass) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
#stream_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Stream.
#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 |
#string?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
#top_left ⇒ String Originally defined in module Borders
Produces ‘┌’ (u250C)
#top_right ⇒ String Originally defined in module Borders
Produces ‘┐’ (u2510)
#truthy?(value) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered true.
#underline ⇒ String Originally defined in module Actions
#underline_off ⇒ String Originally defined in module Actions
#valid_codes ⇒ Array<Symbol> Originally defined in module Colours
#valid_name?(named_colour) ⇒ Boolean Originally defined in module Colours
Returns a boolean indicating whether the colour provided is a valid named colour.
#vertical ⇒ String Originally defined in module Borders
Produces ‘│’ (u2502)
#vertical_left ⇒ String Originally defined in module Borders
Produces ‘├’ (u251C)
#vertical_right ⇒ String Originally defined in module Borders
Produces ‘┤’ (u2524)
#view_model? ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::View.