class Windows::Console

Provides advanced console input / output functionality for Windows based systems.

Global Functions

int CreateWindow ()Creates and opens a console window for the application.
string GetTitle ()Returns the current title of the console window.
Window GetWindow ()Returns the console window as a Window object.
SmallSize GetWindowSize ()Returns the current window size.
SetActive (const Console)Causes the console window to display the specified console's text buffer.
SetTitle (const string)Sets the title of the console window.
SetWindowSize (const SmallSize)Changes the window size, if the specified size is permitted by the system.
int StdOut (const string)Writes a string to the standard text buffer, rather than to an instance's text buffer.

Constructors

Console (const string)Initializes a new instance and specifies a title.
Console (const string, const SmallSize)Initializes a new instance and specifies a title and custom text buffer size.

Methods

Clear ()Clears the text buffer, filling it with spaces and the current color.
int FillArea (const SmallRect, const int)Fills an area in the text buffer with a character and color.
int FillArea (const SmallRect, const CharColor, const int)Fills an area in the text buffer with the specified character and color.
FlushInput ()Removes all events from the console's input event queue.
CharArea GetArea (const SmallRect)Copies a rectangular area of character and color information and returns it as a CharArea object.
SmallSize GetBufferSize ()Returns the size of the current text buffer.
Location GetCursorPosition ()Returns the current cursor location.
int GetCursorSize ()Returns the height of the cursor in percent.
int GetCursorVisible ()Returns true if the cursor is currently enabled, false if it is disabled.
InputEvent[] PeekInput (const int)Returns the specified number (at most) of input events from the console's event queue without removing them.
int Print (const string)Writes a string to the current text buffer without appending a line feed.
int PrintAt (const Location, const int, const string)Writes 'length' characters from 's' to the specified location.
int PrintAt (const Location, const string)Writes the entire string to the specified location.
int PrintLine (const string)Writes a string to the current text buffer and appends a line feed.
PutArea (const CharArea, const Location)Copies the contents of the specified CharArea to the specified location of the console buffer.
InputEvent[] ReadInput (const int)Returns the specified number (at most) of input events from the console's event queue and removes them.
string ReadString (const int)Performs a simple console input function, allowing the user to enter a string.
string ReadString (ReadStringOptions)Performs a complex console input function as described by the specified ReadStringOptions object.
int ScrollArea (const SmallRect, const Location)Scrolls an area in the text buffer by copying the contents of the source rectangle to the destination location.
int ScrollArea (const SmallRect, const SmallRect, const Location, const int)Scrolls an area in the text buffer by copying the contents of the source rectangle to the destination location.
SetBufferSize (const SmallSize)Changes the text buffer size.
SetCursorPosition (const Location)Sets the cursor to a new location in zero-based character coordinates.
SetCursorStyle (const int, const int)Sets the cursor height, enables or disables it.

Properties

CharColor CurrentColor ()Returns the current character color information.
CurrentColor (const CharColor)Sets the current character color.
int InputEventCount ()Returns the number of events currently waiting in the console's input event queue.

Type Declaration

native class Windows::Console
{
    ["Provides advanced console input / output functionality for Windows based systems."]
    alias SmallRect Rectangle;
    method Console (const string title); ["Initializes a new instance and specifies a title. The console will use the default text buffer size. All Console instances share the same window, but each instance will use it's own text buffer."]
    method Console (const string title, const SmallSize s); ["Initializes a new instance and specifies a title and custom text buffer size."]
    method Clear (); ["Clears the text buffer, filling it with spaces and the current color. The cursor will be set to the HOME position (0,0)."]
    method SetBufferSize (const SmallSize s); ["Changes the text buffer size."]
    method SmallSize GetBufferSize (); ["Returns the size of the current text buffer."]
    method SetCursorPosition (const Location c); ["Sets the cursor to a new location in zero-based character coordinates."]
    method Location GetCursorPosition (); ["Returns the current cursor location."]
    method SetCursorStyle (const int size, const int enable); ["Sets the cursor height, enables or disables it. The size specifies the percentage of the cursor block to draw."]
    method int GetCursorSize (); ["Returns the height of the cursor in percent."]
    method int GetCursorVisible (); ["Returns true if the cursor is currently enabled, false if it is disabled."]
    method int Print (const string s); ["Writes a string to the current text buffer without appending a line feed."]
    method int PrintLine (const string s); ["Writes a string to the current text buffer and appends a line feed."]
    method int PrintAt (const Location c, const int length, const string s); ["Writes 'length' characters from 's' to the specified location. The text will be written without applying any colors. Use FillArea() to fill an area with specific colors before printing into that area."]
    method int PrintAt (const Location c, const string s); ["Writes the entire string to the specified location. The text will be written without applying any colors. Use FillArea() to fill an area with specific colors before printing into that area."]
    method int FillArea (const SmallRect rect, const int fillChar); ["Fills an area in the text buffer with a character and color. The currently active color settings will be used."]
    method int FillArea (const SmallRect rect, const CharColor color, const int fillChar); ["Fills an area in the text buffer with the specified character and color."]
    method int ScrollArea (const SmallRect source, const Location dest); ["Scrolls an area in the text buffer by copying the contents of the source rectangle to the destination location. No clipping rectangle will be used."]
    method int ScrollArea (const SmallRect clip, const SmallRect source, const Location dest, const int fillChar); ["Scrolls an area in the text buffer by copying the contents of the source rectangle to the destination location. The clipping rectangle specifies the area in the text buffer that can be affected by the copy operation, meaning characters outside of this area will not be affected."]
    method CharArea GetArea (const SmallRect rect); ["Copies a rectangular area of character and color information and returns it as a CharArea object. This can be used to save and restore portions of the console buffer, or to copy characters between console buffers."]
    method PutArea (const CharArea area, const Location pos); ["Copies the contents of the specified CharArea to the specified location of the console buffer. This can be used to save and restore portions of the console buffer, or to copy characters between console buffers."]
    method InputEvent[] PeekInput (const int length); ["Returns the specified number (at most) of input events from the console's event queue without removing them. If there are fewer events in the queue, the returned array will be shorter than specified by 'length'."]
    method InputEvent[] ReadInput (const int length); ["Returns the specified number (at most) of input events from the console's event queue and removes them. If there are fewer events in the queue, the returned array will be shorter than specified by 'length'."]
    method string ReadString (const int length); ["Performs a simple console input function, allowing the user to enter a string. The function will not return until the user has pressed return. The string returned will contain at most 'length' characters."]
    method string ReadString (ReadStringOptions options); ["Performs a complex console input function as described by the specified ReadStringOptions object. See this class for more information."]
    method FlushInput (); ["Removes all events from the console's input event queue."]
    accessor CharColor CurrentColor (); ["Returns the current character color information."]
    accessor CurrentColor (const CharColor color); ["Sets the current character color."]
    accessor int InputEventCount (); ["Returns the number of events currently waiting in the console's input event queue."]
    function SetActive(const Console c); ["Causes the console window to display the specified console's text buffer. To switch to the system's standard text buffer, pass null. This will only affect which text buffer is displayed. All text output will be written to the console's own text buffer."]
    function int CreateWindow(); ["Creates and opens a console window for the application. This can be used by Windows GUI applications to open a console window. The function will fail when called by a command line application. An application can only have one console window."]
    function int StdOut (const string s); ["Writes a string to the standard text buffer, rather than to an instance's text buffer. A line feed is appended to the string."]
    function SetWindowSize (const SmallSize s); ["Changes the window size, if the specified size is permitted by the system. Sizes are specified in characters, not pixels."]
    function SmallSize GetWindowSize (); ["Returns the current window size."]
    function string GetTitle (); ["Returns the current title of the console window."]
    function SetTitle (const string); ["Sets the title of the console window."]
    function Windows::Window GetWindow (); ["Returns the console window as a Window object."]
    const int KeyEventType = 1;
    const int MouseEventType = 2;
    const int WindowBufferSizeEventType = 4;
    const int MenuEventType = 8;
    const int FocusEventType = 16;
}

Reference

function int CreateWindow ()

Creates and opens a console window for the application.

This can be used by Windows GUI applications to open a console window. The function will fail when called by a command line application. An application can only have one console window.


function string GetTitle ()

Returns the current title of the console window.


function Window GetWindow ()

Returns the console window as a Window object.


function SmallSize GetWindowSize ()

Returns the current window size.


function SetActive (const Console c)

Causes the console window to display the specified console's text buffer.

To switch to the system's standard text buffer, pass null. This will only affect which text buffer is displayed. All text output will be written to the console's own text buffer.


function SetTitle (const string)

Sets the title of the console window.


function SetWindowSize (const SmallSize s)

Changes the window size, if the specified size is permitted by the system.

Sizes are specified in characters, not pixels.


function int StdOut (const string s)

Writes a string to the standard text buffer, rather than to an instance's text buffer.

A line feed is appended to the string.


method Console (const string title)

Initializes a new instance and specifies a title.

The console will use the default text buffer size. All Console instances share the same window, but each instance will use it's own text buffer.


method Console (const string title, const SmallSize s)

Initializes a new instance and specifies a title and custom text buffer size.


method Clear ()

Clears the text buffer, filling it with spaces and the current color.

The cursor will be set to the HOME position (0,0).


method int FillArea (const SmallRect rect, const int fillChar)

Fills an area in the text buffer with a character and color.

The currently active color settings will be used.


method int FillArea (const SmallRect rect, const CharColor color, const int fillChar)

Fills an area in the text buffer with the specified character and color.


method FlushInput ()

Removes all events from the console's input event queue.


method CharArea GetArea (const SmallRect rect)

Copies a rectangular area of character and color information and returns it as a CharArea object.

This can be used to save and restore portions of the console buffer, or to copy characters between console buffers.


method SmallSize GetBufferSize ()

Returns the size of the current text buffer.


method Location GetCursorPosition ()

Returns the current cursor location.


method int GetCursorSize ()

Returns the height of the cursor in percent.


method int GetCursorVisible ()

Returns true if the cursor is currently enabled, false if it is disabled.


method InputEvent[] PeekInput (const int length)

Returns the specified number (at most) of input events from the console's event queue without removing them.

If there are fewer events in the queue, the returned array will be shorter than specified by 'length'.


method int Print (const string s)

Writes a string to the current text buffer without appending a line feed.


method int PrintAt (const Location c, const int length, const string s)

Writes 'length' characters from 's' to the specified location.

The text will be written without applying any colors. Use FillArea() to fill an area with specific colors before printing into that area.


method int PrintAt (const Location c, const string s)

Writes the entire string to the specified location.

The text will be written without applying any colors. Use FillArea() to fill an area with specific colors before printing into that area.


method int PrintLine (const string s)

Writes a string to the current text buffer and appends a line feed.


method PutArea (const CharArea area, const Location pos)

Copies the contents of the specified CharArea to the specified location of the console buffer.

This can be used to save and restore portions of the console buffer, or to copy characters between console buffers.


method InputEvent[] ReadInput (const int length)

Returns the specified number (at most) of input events from the console's event queue and removes them.

If there are fewer events in the queue, the returned array will be shorter than specified by 'length'.


method string ReadString (const int length)

Performs a simple console input function, allowing the user to enter a string.

The function will not return until the user has pressed return. The string returned will contain at most 'length' characters.


method string ReadString (ReadStringOptions options)

Performs a complex console input function as described by the specified ReadStringOptions object.

See this class for more information.


method int ScrollArea (const SmallRect source, const Location dest)

Scrolls an area in the text buffer by copying the contents of the source rectangle to the destination location.

No clipping rectangle will be used.


method int ScrollArea (const SmallRect clip, const SmallRect source, const Location dest, const int fillChar)

Scrolls an area in the text buffer by copying the contents of the source rectangle to the destination location.

The clipping rectangle specifies the area in the text buffer that can be affected by the copy operation, meaning characters outside of this area will not be affected.


method SetBufferSize (const SmallSize s)

Changes the text buffer size.


method SetCursorPosition (const Location c)

Sets the cursor to a new location in zero-based character coordinates.


method SetCursorStyle (const int size, const int enable)

Sets the cursor height, enables or disables it.

The size specifies the percentage of the cursor block to draw.


accessor CharColor CurrentColor ()

Returns the current character color information.


accessor CurrentColor (const CharColor color)

Sets the current character color.


accessor int InputEventCount ()

Returns the number of events currently waiting in the console's input event queue.