Module: Zashoku::Util::Term

Defined in:
lib/core/util/term.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.colsObject



32
33
34
# File 'lib/core/util/term.rb', line 32

def self.cols
  HighLine::SystemExtensions.terminal_size[0]
end

.echo_offObject



22
23
24
25
# File 'lib/core/util/term.rb', line 22

def self.echo_off
  `stty -echo`
  self
end

.echo_onObject



27
28
29
30
# File 'lib/core/util/term.rb', line 27

def self.echo_on
  `stty echo`
  self
end

.iniObject



56
57
58
# File 'lib/core/util/term.rb', line 56

def self.ini
  save.hide_cursor.echo_off
end

.resetObject



52
53
54
# File 'lib/core/util/term.rb', line 52

def self.reset
  restore.show_cursor.echo_on
end

.rowsObject



36
37
38
# File 'lib/core/util/term.rb', line 36

def self.rows
  HighLine::SystemExtensions.terminal_size[1]
end

Instance Method Details

#get_keyObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/core/util/term.rb', line 40

def get_key
  STDIN.getch
       .gsub("\r", 'enter')
       .gsub(' ',  'space')
       .gsub('A',  'up')
       .gsub('B',  'down')
       .gsub('C',  'right')
       .gsub('D',  'left')
       .gsub("\e", 'skip')
       .gsub('[',  'skip')
end