Module: TTY2::Reader::WinAPI
- Includes:
- Fiddle
- Defined in:
- lib/tty2/reader/win_api.rb
Constant Summary collapse
- CRT_HANDLE =
Fiddle::Handle.new("msvcrt") rescue Fiddle::Handle.new("crtdll")
Class Method Summary collapse
-
.getch ⇒ String
Get a character from the console without echo.
-
.getche ⇒ String
Gets a character from the console with echo.
-
.kbhit ⇒ Integer
Check the console for recent keystroke.
Class Method Details
.getch ⇒ String
Get a character from the console without echo.
18 19 20 21 |
# File 'lib/tty2/reader/win_api.rb', line 18 def getch @@getch ||= Fiddle::Function.new(CRT_HANDLE["_getch"], [], TYPE_INT) @@getch.call end |
.getche ⇒ String
Gets a character from the console with echo.
30 31 32 33 |
# File 'lib/tty2/reader/win_api.rb', line 30 def getche @@getche ||= Fiddle::Function.new(CRT_HANDLE["_getche"], [], TYPE_INT) @@getche.call end |
.kbhit ⇒ Integer
Check the console for recent keystroke. If the function returns a nonzero value, a keystroke is waiting in the buffer.
44 45 46 47 |
# File 'lib/tty2/reader/win_api.rb', line 44 def kbhit @@kbhit ||= Fiddle::Function.new(CRT_HANDLE["_kbhit"], [], TYPE_INT) @@kbhit.call end |