Module: Vedeu::Esc
Overview
Provides escape sequence strings for setting the cursor position and various display related functions.
Class Method Summary
collapse
Instance Method Summary
collapse
#background_codes, #define_backgrounds!, #define_foregrounds!, #foreground_codes, #setup!
#border_off, #border_on, #characters, #define_borders!, #setup!
#characters, #define_actions!, #setup!
Class Method Details
.border ⇒ String
Return the escape sequence to render a border character.
49
50
51
52
53
|
# File 'lib/vedeu/esc/esc.rb', line 49
def border
return '' unless block_given?
"#{border_on}#{yield}#{border_off}"
end
|
.clear ⇒ String
58
59
60
|
# File 'lib/vedeu/esc/esc.rb', line 58
def clear
"#{colour_reset}\e[2J"
end
|
.clear_line ⇒ String
63
64
65
|
# File 'lib/vedeu/esc/esc.rb', line 63
def clear_line
"#{colour_reset}\e[2K"
end
|
.colour_reset ⇒ String
68
69
70
|
# File 'lib/vedeu/esc/esc.rb', line 68
def colour_reset
"#{fg_reset}#{bg_reset}"
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.
24
25
26
27
28
|
# File 'lib/vedeu/esc/esc.rb', line 24
def escape(stream = '')
return stream if stream.nil? || stream.empty?
stream.gsub(/\e/, '\\e')
end
|
.last_character_position ⇒ String
88
89
90
|
# File 'lib/vedeu/esc/esc.rb', line 88
def last_character_position
Vedeu::Geometry::Position[Vedeu.height, Vedeu.width].to_s
end
|
.normal ⇒ String
73
74
75
|
# File 'lib/vedeu/esc/esc.rb', line 73
def normal
"#{underline_off}#{bold_off}#{positive}"
end
|
.screen_exit ⇒ String
83
84
85
|
# File 'lib/vedeu/esc/esc.rb', line 83
def screen_exit
"#{show_cursor}#{colour_reset}#{reset}#{last_character_position}\n"
end
|
.screen_init ⇒ String
78
79
80
|
# File 'lib/vedeu/esc/esc.rb', line 78
def screen_init
"#{reset}#{clear}#{hide_cursor}"
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.
36
37
38
39
40
41
42
|
# File 'lib/vedeu/esc/esc.rb', line 36
def string(value = '')
return '' if value.empty?
send(value.to_sym)
rescue NoMethodError
''
end
|
Instance Method Details
#border ⇒ String
Return the escape sequence to render a border character.
49
50
51
52
53
|
# File 'lib/vedeu/esc/esc.rb', line 49
def border
return '' unless block_given?
"#{border_on}#{yield}#{border_off}"
end
|
#clear ⇒ String
58
59
60
|
# File 'lib/vedeu/esc/esc.rb', line 58
def clear
"#{colour_reset}\e[2J"
end
|
#clear_line ⇒ String
63
64
65
|
# File 'lib/vedeu/esc/esc.rb', line 63
def clear_line
"#{colour_reset}\e[2K"
end
|
#colour_reset ⇒ String
68
69
70
|
# File 'lib/vedeu/esc/esc.rb', line 68
def colour_reset
"#{fg_reset}#{bg_reset}"
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.
24
25
26
27
28
|
# File 'lib/vedeu/esc/esc.rb', line 24
def escape(stream = '')
return stream if stream.nil? || stream.empty?
stream.gsub(/\e/, '\\e')
end
|
#last_character_position ⇒ String
88
89
90
|
# File 'lib/vedeu/esc/esc.rb', line 88
def last_character_position
Vedeu::Geometry::Position[Vedeu.height, Vedeu.width].to_s
end
|
#normal ⇒ String
73
74
75
|
# File 'lib/vedeu/esc/esc.rb', line 73
def normal
"#{underline_off}#{bold_off}#{positive}"
end
|
#screen_exit ⇒ String
83
84
85
|
# File 'lib/vedeu/esc/esc.rb', line 83
def screen_exit
"#{show_cursor}#{colour_reset}#{reset}#{last_character_position}\n"
end
|
#screen_init ⇒ String
78
79
80
|
# File 'lib/vedeu/esc/esc.rb', line 78
def screen_init
"#{reset}#{clear}#{hide_cursor}"
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.
36
37
38
39
40
41
42
|
# File 'lib/vedeu/esc/esc.rb', line 36
def string(value = '')
return '' if value.empty?
send(value.to_sym)
rescue NoMethodError
''
end
|