Files

HighLine::SystemExtensions

Constants

CHARACTER_MODE

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.

JRUBY

Public Instance Methods

get_character( input = STDIN ) click to toggle source

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
raw_no_echo_mode() click to toggle source

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 = `stty -g`
  system "stty raw -echo -icanon isig"
end
restore_mode() click to toggle source

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
terminal_size() click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.