work correctly in JRuby manually installing the ffi-ncurses gem is the only way to get highline to operate correctly in JRuby. The ncurses library is only present on unix platforms so this is not a solution for using highline in JRuby on windows.
Windows savvy getc().
WARNING: This method ignores input
and reads
one character from STDIN
!
# File lib/highline/system_extensions.rb, line 37 def get_character( input = STDIN ) Win32API.new("msvcrt", "_getch", [ ], "L").Call rescue Exception Win32API.new("crtdll", "_getch", [ ], "L").Call end
Switched the input mode to raw and disables echo.
WARNING: This method requires the external “stty” program!
# File lib/highline/system_extensions.rb, line 137 def raw_no_echo_mode @state = %xstty -g` system "stty raw -echo -icanon isig" end
Restores a previously saved input mode.
WARNING: This method requires the external “stty” program!
# File lib/highline/system_extensions.rb, line 147 def restore_mode system "stty #{@state}" end
A Windows savvy method to fetch the console columns, and rows.
# File lib/highline/system_extensions.rb, line 44 def terminal_size m_GetStdHandle = Win32API.new( 'kernel32', 'GetStdHandle', ['L'], 'L' ) m_GetConsoleScreenBufferInfo = Win32API.new( 'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L' ) format = 'SSSSSssssSS' buf = ([0] * format.size).pack(format) stdout_handle = m_GetStdHandle.call(0xFFFFFFF5) m_GetConsoleScreenBufferInfo.call(stdout_handle, buf) bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy = buf.unpack(format) return right - left + 1, bottom - top + 1 end