Module: Cuboid::Support::Mixins::Terminal
Overview
Terminal manipulation methods.
Instance Method Summary collapse
-
#clear_screen ⇒ Object
Clear the bottom of the screen.
- #empty_screen ⇒ Object
-
#flush ⇒ Object
Flushes the STDOUT buffer.
-
#move_to_home ⇒ Object
Moves cursor top left to its home.
-
#reprint(str = '') ⇒ Object
Clears the line before printing.
-
#reputs(str = '') ⇒ Object
Clears the line before printing using ‘puts`.
- #restr(str = '') ⇒ Object
Instance Method Details
#clear_screen ⇒ Object
Clear the bottom of the screen
31 32 33 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 31 def clear_screen print "\e[2J" end |
#empty_screen ⇒ Object
[View source]
35 36 37 38 39 40 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 35 def empty_screen move_to_home rows, cols = $stdin.winsize (rows - 1).times{ puts ' ' * cols } move_to_home end |
#flush ⇒ Object
Flushes the STDOUT buffer
48 49 50 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 48 def flush $stdout.flush end |
#move_to_home ⇒ Object
Moves cursor top left to its home
43 44 45 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 43 def move_to_home print "\e[H" end |
#reprint(str = '') ⇒ Object
Clears the line before printing.
22 23 24 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 22 def reprint( str = '' ) print restr( str ) end |
#reputs(str = '') ⇒ Object
Clears the line before printing using ‘puts`.
14 15 16 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 14 def reputs( str = '' ) reprint str + "\n" end |
#restr(str = '') ⇒ Object
[View source]
26 27 28 |
# File 'lib/cuboid/support/mixins/terminal.rb', line 26 def restr( str = '' ) "\e[0K" + str end |