Module: Console::Windows
- Extended by:
- FFI::Library
- Defined in:
- lib/console/platform/windows.rb
Overview
Implements Windows-specific platform functionality
Defined Under Namespace
Classes: BufferInfo, Coord
Constant Summary collapse
- STD_OUTPUT_HANDLE =
Constants representing STDIN, STDOUT, and STDERR
0xFFFFFFF5
- STD_INPUT_HANDLE =
0xFFFFFFF6
- STD_ERROR_HANDLE =
0xFFFFFFF7
Class Method Summary collapse
-
.buffer_info ⇒ Object
Retrieve a BufferInfo object.
-
.get_buffer_info ⇒ BufferInfo
Populate a BufferInfo structure with details about the current buffer state.
-
.set_color(color) ⇒ Object
Sets the console foreground and background colors.
-
.set_cursor_position(x, y) ⇒ Object
Sets the cursor position to the specified
xandylocations in the console output buffer. -
.stdout ⇒ Object
Retrieve a handle to STDOUT.
Class Method Details
.buffer_info ⇒ Object
Retrieve a BufferInfo object
66 67 68 |
# File 'lib/console/platform/windows.rb', line 66 def buffer_info @buffer_info ||= BufferInfo.new end |
.get_buffer_info ⇒ BufferInfo
Populate a BufferInfo structure with details about the current buffer state.
78 79 80 81 82 83 |
# File 'lib/console/platform/windows.rb', line 78 def get_buffer_info if stdout self.get_console_screen_buffer_info(stdout, buffer_info) @buffer_info end end |
.set_color(color) ⇒ Object
Sets the console foreground and background colors.
88 89 90 91 92 |
# File 'lib/console/platform/windows.rb', line 88 def set_color(color) if stdout && color self.set_console_text_attribute(stdout, color) end end |
.set_cursor_position(x, y) ⇒ Object
Sets the cursor position to the specified x and y locations in the console output buffer. If y is nil, the cursor is positioned at x on the current line.
99 100 101 102 103 104 |
# File 'lib/console/platform/windows.rb', line 99 def set_cursor_position(x, y) if stdout && x && y coord = Coord.new(x, y) self.set_console_cursor_position(stdout, coord) end end |
.stdout ⇒ Object
Retrieve a handle to STDOUT
58 59 60 |
# File 'lib/console/platform/windows.rb', line 58 def stdout @stdout ||= self.get_std_handle(STD_OUTPUT_HANDLE) end |