Class BaseConsoleWrapper
Base console wrapper class for the System.Console class to ensure safety against dumb consoles and Windows-only features.
Inheritance
Namespace: Terminaux.Base.Wrappers
Assembly: Terminaux.dll
Syntax
public class BaseConsoleWrapper
Fields
| Edit this page View Source_moved
Checks to see if the console has moved. Only set this to true if the console has really moved, for example, each call to setting cursor position, key reading, writing text, etc.
Declaration
protected bool _moved
Field Value
| Type | Description |
|---|---|
| bool |
Properties
| Edit this page View SourceBufferHeight
The console buffer height (rows)
Declaration
public virtual int BufferHeight { get; }
Property Value
| Type | Description |
|---|---|
| int |
BufferWidth
The console buffer width (columns)
Declaration
public virtual int BufferWidth { get; }
Property Value
| Type | Description |
|---|---|
| int |
CursorLeft
The cursor left position
Declaration
public virtual int CursorLeft { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
CursorTop
The cursor top position
Declaration
public virtual int CursorTop { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
CursorVisible
The cursor visibility mode
Declaration
public virtual bool CursorVisible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
GetCursorPosition
The cursor top position
Declaration
public virtual Coordinate GetCursorPosition { get; }
Property Value
| Type | Description |
|---|---|
| Coordinate |
IsDumb
Checks to see if the console is dumb
Declaration
public virtual bool IsDumb { get; }
Property Value
| Type | Description |
|---|---|
| bool |
KeyAvailable
Whether a key is pressed
Declaration
public virtual bool KeyAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MovementDetected
Has the console moved? Should be set by Write*, Set*, and all console functions that have to do with moving the console.
Declaration
public virtual bool MovementDetected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
TreatCtrlCAsInput
Whether to treat Ctrl + C as input or not
Declaration
public virtual bool TreatCtrlCAsInput { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
WindowHeight
The console window height (rows)
Declaration
public virtual int WindowHeight { get; }
Property Value
| Type | Description |
|---|---|
| int |
WindowWidth
The console window width (columns)
Declaration
public virtual int WindowWidth { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceBeep()
Beeps the console
Declaration
public virtual void Beep()
BeepCustom(int, int)
Beeps the console
Declaration
public virtual void BeepCustom(int freq, int ms)
Parameters
| Type | Name | Description |
|---|---|---|
| int | freq | Frequency in hertz |
| int | ms | Duration in milliseconds |
BeepSeq()
Beeps the console (VT Sequence method)
Declaration
public virtual void BeepSeq()
Clear()
Clears the console screen.
Declaration
public virtual void Clear()
ClearLoadBack()
Clears the console screen while loading the background.
Declaration
public virtual void ClearLoadBack()
ReadKey(bool)
Reads a key
Declaration
public virtual ConsoleKeyInfo ReadKey(bool intercept = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | intercept | Whether to intercept |
Returns
| Type | Description |
|---|---|
| ConsoleKeyInfo |
SetBufferDimensions(int, int)
Sets the buffer dimensions
Declaration
public virtual void SetBufferDimensions(int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The buffer width to be set (from 0) |
| int | height | The buffer height to be set (from 0) |
SetBufferHeight(int)
Sets the buffer height
Declaration
public virtual void SetBufferHeight(int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | height | The buffer height to be set (from 0) |
SetBufferWidth(int)
Sets the buffer width
Declaration
public virtual void SetBufferWidth(int width)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The buffer width to be set (from 0) |
SetCursorLeft(int)
Sets the cursor left
Declaration
public virtual void SetCursorLeft(int left)
Parameters
| Type | Name | Description |
|---|---|---|
| int | left | The left to be set (from 0) |
SetCursorPosition(int, int)
Sets the cursor position
Declaration
public virtual void SetCursorPosition(int left, int top)
Parameters
| Type | Name | Description |
|---|---|---|
| int | left | The left to be set (from 0) |
| int | top | The top to be set (from 0) |
SetCursorTop(int)
Sets the cursor top
Declaration
public virtual void SetCursorTop(int top)
Parameters
| Type | Name | Description |
|---|---|---|
| int | top | The top to be set (from 0) |
SetWindowDimensions(int, int)
Sets the window dimensions
Declaration
public virtual void SetWindowDimensions(int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The window width to be set (from 0) |
| int | height | The window height to be set (from 0) |
SetWindowHeight(int)
Sets the window height
Declaration
public virtual void SetWindowHeight(int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | height | The window height to be set (from 0) |
SetWindowWidth(int)
Sets the window width
Declaration
public virtual void SetWindowWidth(int width)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The window width to be set (from 0) |
Write(char)
Writes a character to console (stdout)
Declaration
public virtual void Write(char value)
Parameters
| Type | Name | Description |
|---|---|---|
| char | value | A character |
Write(string)
Writes text to console (stdout)
Declaration
public virtual void Write(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
Write(string, params object[])
Writes text to console (stdout)
Declaration
public virtual void Write(string text, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
| object[] | args | The arguments to evaluate |
WriteError(char)
Writes a character to console (stderr)
Declaration
public virtual void WriteError(char value)
Parameters
| Type | Name | Description |
|---|---|---|
| char | value | A character |
WriteError(string)
Writes text to console (stderr)
Declaration
public virtual void WriteError(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
WriteError(string, params object[])
Writes text to console (stderr)
Declaration
public virtual void WriteError(string text, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
| object[] | args | The arguments to evaluate |
WriteErrorLine()
Writes new line to console (stderr)
Declaration
public virtual void WriteErrorLine()
WriteErrorLine(string)
Writes text to console (stderr) with line terminator
Declaration
public virtual void WriteErrorLine(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
WriteErrorLine(string, params object[])
Writes text to console (stderr) with line terminator
Declaration
public virtual void WriteErrorLine(string text, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
| object[] | args | The arguments to evaluate |
WriteLine()
Writes new line to console (stdout)
Declaration
public virtual void WriteLine()
WriteLine(string)
Writes text to console (stdout) with line terminator
Declaration
public virtual void WriteLine(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
WriteLine(string, params object[])
Writes text to console (stdout) with line terminator
Declaration
public virtual void WriteLine(string text, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to write |
| object[] | args | The arguments to evaluate |