Class: TTY::Prompt::Reader::WinConsole Private
- Inherits:
-
Object
- Object
- TTY::Prompt::Reader::WinConsole
- Defined in:
- lib/tty/prompt/reader/win_console.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- ESC =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\e".freeze
- NUL_HEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\x00".freeze
- EXT_HEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\xE0".freeze
Instance Attribute Summary collapse
-
#escape_codes ⇒ Array[Integer]
readonly
Escape codes.
-
#keys ⇒ Hash[Symbol]
readonly
Key codes.
Instance Method Summary collapse
-
#get_char(options) ⇒ String
private
Get a character from console with echo.
-
#initialize(input) ⇒ WinConsole
constructor
private
A new instance of WinConsole.
Constructor Details
#initialize(input) ⇒ WinConsole
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of WinConsole.
27 28 29 30 31 32 |
# File 'lib/tty/prompt/reader/win_console.rb', line 27 def initialize(input) require_relative 'win_api' @input = input @keys = Codes.win_keys @escape_codes = [[NUL_HEX.ord], [ESC.ord], EXT_HEX.bytes.to_a] end |
Instance Attribute Details
#escape_codes ⇒ Array[Integer] (readonly)
Escape codes
25 26 27 |
# File 'lib/tty/prompt/reader/win_console.rb', line 25 def escape_codes @escape_codes end |
#keys ⇒ Hash[Symbol] (readonly)
Key codes
18 19 20 |
# File 'lib/tty/prompt/reader/win_console.rb', line 18 def keys @keys end |
Instance Method Details
#get_char(options) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a character from console with echo
43 44 45 46 47 48 49 |
# File 'lib/tty/prompt/reader/win_console.rb', line 43 def get_char() if [:raw] WinAPI.getch.chr else [:echo] ? @input.getc : WinAPI.getch.chr end end |