module TTY::Reader::WinAPI

Constants

CRT_HANDLE

Public Class Methods

getch() click to toggle source

Get a character from the console without echo.

@return [String]

return the character read

@api public

# File lib/tty/reader/win_api.rb, line 18
def getch
  @@getch ||= Fiddle::Function.new(CRT_HANDLE["_getch"], [], TYPE_INT)
  @@getch.call
end
getche() click to toggle source

Gets a character from the console with echo.

@return [String]

return the character read

@api public

# File lib/tty/reader/win_api.rb, line 30
def getche
  @@getche ||= Fiddle::Function.new(CRT_HANDLE["_getche"], [], TYPE_INT)
  @@getche.call
end
kbhit() click to toggle source

Check the console for recent keystroke. If the function returns a nonzero value, a keystroke is waiting in the buffer.

@return [Integer]

return a nonzero value if a key has been pressed. Otherwirse,
it returns 0.

@api public

# File lib/tty/reader/win_api.rb, line 44
def kbhit
  @@kbhit ||= Fiddle::Function.new(CRT_HANDLE["_kbhit"], [], TYPE_INT)
  @@kbhit.call
end

Private Instance Methods

getch() click to toggle source

Get a character from the console without echo.

@return [String]

return the character read

@api public

# File lib/tty/reader/win_api.rb, line 18
def getch
  @@getch ||= Fiddle::Function.new(CRT_HANDLE["_getch"], [], TYPE_INT)
  @@getch.call
end
getche() click to toggle source

Gets a character from the console with echo.

@return [String]

return the character read

@api public

# File lib/tty/reader/win_api.rb, line 30
def getche
  @@getche ||= Fiddle::Function.new(CRT_HANDLE["_getche"], [], TYPE_INT)
  @@getche.call
end
kbhit() click to toggle source

Check the console for recent keystroke. If the function returns a nonzero value, a keystroke is waiting in the buffer.

@return [Integer]

return a nonzero value if a key has been pressed. Otherwirse,
it returns 0.

@api public

# File lib/tty/reader/win_api.rb, line 44
def kbhit
  @@kbhit ||= Fiddle::Function.new(CRT_HANDLE["_kbhit"], [], TYPE_INT)
  @@kbhit.call
end