blob: dda193aeaa0fbf0d9180d45f29ff0dbd4dad566a (
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
38
|
# 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'
CHARACTER_MODE = "ncurses" # For Debugging purposes only.
# (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
|