Sha256: b89d68bdce3ded6dcd8ffe3a18d289b11f1fe39339bc83b2624a7c1f3671aa96

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

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
      end # WinAPI
    end # Reader
  end # Prompt
end # TTY

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
austb-tty-prompt-0.13.0 lib/tty/prompt/reader/win_api.rb
tty-prompt-0.12.0 lib/tty/prompt/reader/win_api.rb
tty-prompt-0.11.0 lib/tty/prompt/reader/win_api.rb