Method: Reline::Windows#initialize

Defined in:
lib/reline/io/windows.rb

#initializeWindows

Returns a new instance of Windows.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/reline/io/windows.rb', line 4

def initialize
  @input_buf = []
  @output_buf = []

  @output = STDOUT
  @hsg = nil
  @getwch = Win32API.new('msvcrt', '_getwch', [], 'I')
  @kbhit = Win32API.new('msvcrt', '_kbhit', [], 'I')
  @GetKeyState = Win32API.new('user32', 'GetKeyState', ['L'], 'L')
  @GetConsoleScreenBufferInfo = Win32API.new('kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L')
  @SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', ['L', 'L'], 'L')
  @GetStdHandle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
  @FillConsoleOutputCharacter = Win32API.new('kernel32', 'FillConsoleOutputCharacter', ['L', 'L', 'L', 'L', 'P'], 'L')
  @ScrollConsoleScreenBuffer = Win32API.new('kernel32', 'ScrollConsoleScreenBuffer', ['L', 'P', 'P', 'L', 'P'], 'L')
  @hConsoleHandle = @GetStdHandle.call(STD_OUTPUT_HANDLE)
  @hConsoleInputHandle = @GetStdHandle.call(STD_INPUT_HANDLE)
  @GetNumberOfConsoleInputEvents = Win32API.new('kernel32', 'GetNumberOfConsoleInputEvents', ['L', 'P'], 'L')
  @ReadConsoleInputW = Win32API.new('kernel32', 'ReadConsoleInputW', ['L', 'P', 'L', 'P'], 'L')
  @GetFileType = Win32API.new('kernel32', 'GetFileType', ['L'], 'L')
  @GetFileInformationByHandleEx = Win32API.new('kernel32', 'GetFileInformationByHandleEx', ['L', 'I', 'P', 'L'], 'I')
  @FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', ['L', 'L', 'L', 'L', 'P'], 'L')
  @SetConsoleCursorInfo = Win32API.new('kernel32', 'SetConsoleCursorInfo', ['L', 'P'], 'L')

  @GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'L')
  @SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'L')
  @WaitForSingleObject = Win32API.new('kernel32', 'WaitForSingleObject', ['L', 'L'], 'L')

  @legacy_console = getconsolemode & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0
end