Class: Termplot::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/termplot/shell.rb

Constant Summary collapse

CURSOR_HIDE =
"\e[?25l"
CURSOR_SHOW =
"\e[?25h"
CLEAR_SCREEN =
"\e[2J"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.termios_settingsObject (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

.get_dimensionsObject

Leave a 1 char buffer on the right/bottom



24
25
26
# File 'lib/termplot/shell.rb', line 24

def get_dimensions
  STDOUT.winsize.map { |d| d - 1 }
end

.init(clear: false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/termplot/shell.rb', line 12

def init(clear: false)
  print CLEAR_SCREEN if clear

  # Disable echo on stdout tty, prevents printing chars if you type in
  STDOUT.echo = false

  print CURSOR_HIDE
  at_exit { reset }
  Signal.trap("INT") { exit(0) }
end

.resetObject



28
29
30
31
32
# File 'lib/termplot/shell.rb', line 28

def reset
  STDOUT.echo = true

  print CURSOR_SHOW
end