Class: TTY::Prompt::Reader::WinConsole Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/prompt/reader/win_console.rb

Overview

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.

API:

  • private

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.

API:

  • private

"\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.

API:

  • private

"\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.

API:

  • private

"\xE0".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

API:

  • private



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_codesArray[Integer] (readonly)

Escape codes

Returns:

API:

  • public



25
26
27
# File 'lib/tty/prompt/reader/win_console.rb', line 25

def escape_codes
  @escape_codes
end

#keysHash[Symbol] (readonly)

Key codes

Returns:

API:

  • public



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

Parameters:

Options Hash (options):

  • :echo (Symbol)

    the echo toggle

Returns:

API:

  • private



43
44
45
46
47
48
49
# File 'lib/tty/prompt/reader/win_console.rb', line 43

def get_char(options)
  if options[:raw]
    WinAPI.getch.chr
  else
    options[:echo] ? @input.getc : WinAPI.getch.chr
  end
end