blob: 3f399e0cddd0523700926451ed7f4bb4f7771d42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# coding: utf-8
class HighLine
class Terminal
# NCurses HighLine::Terminal
# @note Code migrated +UNTESTED+ from the old code base to the new terminal api.
class NCurses < Terminal
require 'ffi-ncurses'
# (see Terminal#raw_no_echo_mode)
def raw_no_echo_mode
FFI::NCurses.initscr
FFI::NCurses.cbreak
end
# (see Terminal#restore_mode)
def restore_mode
FFI::NCurses.endwin
end
#
# (see Terminal#terminal_size)
# A ncurses savvy method to fetch the console columns, and rows.
#
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
end
end
end
|