Sha256: e4cd74e7a77d92b0031619bce0a18e3bef66aa85220f12d2b7a938472bd0c4e9
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# encoding: utf-8 require 'fiddle' module TTY class Prompt class Reader module WinAPI include Fiddle Handle = RUBY_VERSION >= "2.0.0" ? Fiddle::Handle : DL::Handle CRT_HANDLE = Handle.new("msvcrt") rescue Handle.new("crtdll") def getch @@getch ||= Fiddle::Function.new(CRT_HANDLE["_getch"], [], TYPE_INT) @@getch.call end module_function :getch def getche @@getche ||= Fiddle::Function.new(CRT_HANDLE["_getche"], [], TYPE_INT) @@getche.call end module_function :getche # 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 def kbhit @@kbhit ||= Fiddle::Function.new(CRT_HANDLE["_kbhit"], [], TYPE_INT) @@kbhit.call end module_function :kbhit end # WinAPI end # Reader end # Prompt end # TTY
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tty-prompt-0.13.0 | lib/tty/prompt/reader/win_api.rb |