Method: HighLine::Terminal::NCurses#terminal_size

Defined in:
lib/highline/terminal/ncurses.rb

#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