Class: HighLine::Terminal::NCurses

Inherits:
HighLine::Terminal show all
Defined in:
lib/highline/terminal/ncurses.rb

Overview

Note:

Code migrated UNTESTED from the old code base to the new

NCurses HighLine::Terminal terminal api.

Instance Attribute Summary

Attributes inherited from HighLine::Terminal

#input, #output

Instance Method Summary collapse

Methods inherited from HighLine::Terminal

#character_mode, #get_character, #get_line, #get_line_default, #get_line_with_readline, get_terminal, #initialize, #initialize_system_extensions, #jruby?, #raw_no_echo_mode_exec, #readline_read, #rubinius?, #windows?

Constructor Details

This class inherits a constructor from HighLine::Terminal

Instance Method Details

#raw_no_echo_modeObject

Enter Raw No Echo mode.



12
13
14
15
# File 'lib/highline/terminal/ncurses.rb', line 12

def raw_no_echo_mode
  FFI::NCurses.initscr
  FFI::NCurses.cbreak
end

#restore_modeObject

Restore terminal to its default mode



18
19
20
# File 'lib/highline/terminal/ncurses.rb', line 18

def restore_mode
  FFI::NCurses.endwin
end

#terminal_sizeArray<Integer, Integer>

A ncurses savvy method to fetch the console columns, and rows.

Returns:

  • (Array<Integer, Integer>)

    two value terminal size like [columns, lines]



26
27
28
29
30
31
32
33
34
35
# File 'lib/highline/terminal/ncurses.rb', line 26

def terminal_size
  size = [80, 40]
  FFI::NCurses.initscr
  begin
    size = FFI::NCurses.getmaxyx(FFI::NCurses.stdscr).reverse
  ensure
    FFI::NCurses.endwin
  end
  size
end