Class: Termplot::Shell
- Inherits:
-
Object
- Object
- Termplot::Shell
- Defined in:
- lib/termplot/shell.rb
Constant Summary collapse
- CURSOR_HIDE =
"\e[?25l"
- CURSOR_SHOW =
"\e[?25h"
Class Attribute Summary collapse
-
.termios_settings ⇒ Object
readonly
Returns the value of attribute termios_settings.
Class Method Summary collapse
Class Attribute Details
.termios_settings ⇒ Object (readonly)
Returns the value of attribute termios_settings.
6 7 8 |
# File 'lib/termplot/shell.rb', line 6 def termios_settings @termios_settings end |
Class Method Details
.init ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/termplot/shell.rb', line 10 def init # Disable echo on stdout tty, prevents printing chars if you type in # between rendering @termios_settings = Termios.tcgetattr($stdout) new_termios_settings = termios_settings.dup new_termios_settings.c_lflag &= ~(Termios::ECHO) Termios.tcsetattr($stdout, Termios::TCSAFLUSH, new_termios_settings) print CURSOR_HIDE at_exit { reset } Signal.trap("INT") { exit(0) } end |
.reset ⇒ Object
23 24 25 26 27 28 |
# File 'lib/termplot/shell.rb', line 23 def reset # Reset stdout tty to original settings Termios.tcsetattr($stdout, Termios::TCSAFLUSH, termios_settings) print CURSOR_SHOW end |