Show / Hide Table of Contents

# Class ConsoleDriver

ConsoleDriver is an abstract class that defines the requirements for a console driver. There are currently three implementations: Terminal.Gui.CursesDriver (for Unix and Mac), Terminal.Gui.WindowsDriver, and Terminal.Gui.NetDriver that uses the .NET Console API.

##### Inheritance

System.Object
ConsoleDriver
FakeDriver

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public abstract class ConsoleDriver

### Fields

#### BottomTee

The bottom tee.

##### Declaration

    public Rune BottomTee

##### Field Value

Type | Description
--- | ---
System.Rune |

#### Checked

Checkmark.

##### Declaration

    public Rune Checked

##### Field Value

Type | Description
--- | ---
System.Rune |

#### Diamond

Diamond character

##### Declaration

    public Rune Diamond

##### Field Value

Type | Description
--- | ---
System.Rune |

#### DownArrow

Down Arrow.

##### Declaration

    public Rune DownArrow

##### Field Value

Type | Description
--- | ---
System.Rune |

#### HLine

Horizontal line character.

##### Declaration

    public Rune HLine

##### Field Value

Type | Description
--- | ---
System.Rune |

#### LeftArrow

Left Arrow.

##### Declaration

    public Rune LeftArrow

##### Field Value

Type | Description
--- | ---
System.Rune |

#### LeftBracket

Left frame/bracket (e.g. '[' for Button).

##### Declaration

    public Rune LeftBracket

##### Field Value

Type | Description
--- | ---
System.Rune |

#### LeftDefaultIndicator

Left indicator for default action (e.g. for Button).

##### Declaration

    public Rune LeftDefaultIndicator

##### Field Value

Type | Description
--- | ---
System.Rune |

#### LeftTee

Left tee

##### Declaration

    public Rune LeftTee

##### Field Value

Type | Description
--- | ---
System.Rune |

#### LLCorner

Lower left corner

##### Declaration

    public Rune LLCorner

##### Field Value

Type | Description
--- | ---
System.Rune |

#### LRCorner

Lower right corner

##### Declaration

    public Rune LRCorner

##### Field Value

Type | Description
--- | ---
System.Rune |

#### OffMeterSegement

Off Segment indicator for meter views (e.g. ProgressBar.

##### Declaration

    public Rune OffMeterSegement

##### Field Value

Type | Description
--- | ---
System.Rune |

#### OnMeterSegment

On Segment indicator for meter views (e.g. ProgressBar.

##### Declaration

    public Rune OnMeterSegment

##### Field Value

Type | Description
--- | ---
System.Rune |

#### RightArrow

Right Arrow.

##### Declaration

    public Rune RightArrow

##### Field Value

Type | Description
--- | ---
System.Rune |

#### RightBracket

Right frame/bracket (e.g. ']' for Button).

##### Declaration

    public Rune RightBracket

##### Field Value

Type | Description
--- | ---
System.Rune |

#### RightDefaultIndicator

Right indicator for default action (e.g. for Button).

##### Declaration

    public Rune RightDefaultIndicator

##### Field Value

Type | Description
--- | ---
System.Rune |

#### RightTee

Right tee

##### Declaration

    public Rune RightTee

##### Field Value

Type | Description
--- | ---
System.Rune |

#### Selected

Selected mark.

##### Declaration

    public Rune Selected

##### Field Value

Type | Description
--- | ---
System.Rune |

#### Stipple

Stipple pattern

##### Declaration

    public Rune Stipple

##### Field Value

Type | Description
--- | ---
System.Rune |

#### TerminalResized

The handler fired when the terminal is resized.

##### Declaration

    protected Action TerminalResized

##### Field Value

Type | Description
--- | ---
System.Action |

#### TopTee

Top tee

##### Declaration

    public Rune TopTee

##### Field Value

Type | Description
--- | ---
System.Rune |

#### ULCorner

Upper left corner

##### Declaration

    public Rune ULCorner

##### Field Value

Type | Description
--- | ---
System.Rune |

#### UnChecked

Un-checked checkmark.

##### Declaration

    public Rune UnChecked

##### Field Value

Type | Description
--- | ---
System.Rune |

#### UnSelected

Un-selected selected mark.

##### Declaration

    public Rune UnSelected

##### Field Value

Type | Description
--- | ---
System.Rune |

#### UpArrow

Up Arrow.

##### Declaration

    public Rune UpArrow

##### Field Value

Type | Description
--- | ---
System.Rune |

#### URCorner

Upper right corner

##### Declaration

    public Rune URCorner

##### Field Value

Type | Description
--- | ---
System.Rune |

#### VLine

Vertical line character.

##### Declaration

    public Rune VLine

##### Field Value

Type | Description
--- | ---
System.Rune |

### Properties

#### Clip

Controls the current clipping region that AddRune/AddStr is subject to.

##### Declaration

    public Rect Clip { get; set; }

##### Property Value

Type | Description
--- | ---
Rect | The clip.

#### Cols

The current number of columns in the terminal.

##### Declaration

    public abstract int Cols { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

#### Diagnostics

Set flags to enable/disable ConsoleDriver diagnostics.

##### Declaration

    public static ConsoleDriver.DiagnosticFlags Diagnostics { get; set; }

##### Property Value

Type | Description
--- | ---
ConsoleDriver.DiagnosticFlags |

#### Rows

The current number of rows in the terminal.

##### Declaration

    public abstract int Rows { get; }

##### Property Value

Type | Description
--- | ---
System.Int32 |

### Methods

#### AddRune(Rune)

Adds the specified rune to the display at the current cursor position

##### Declaration

    public abstract void AddRune(Rune rune)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Rune | rune | Rune to add.

#### AddStr(ustring)

Adds the specified

##### Declaration

    public abstract void AddStr(ustring str)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | str | String.

#### CookMouse()

Enables the cooked event processing from the mouse driver

##### Declaration

    public abstract void CookMouse()

#### DrawFrame(Rect, Int32, Boolean)

Draws a frame on the specified region with the specified padding around the frame.

##### Declaration

    public virtual void DrawFrame(Rect region, int padding, bool fill)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region | Screen relative region where the frame will be drawn.
System.Int32 | padding | Padding to add on the sides.
System.Boolean | fill | If set to `true` it will clear the contents with the current color, otherwise the contents will be left untouched.

##### Remarks

This API has been superceded by DrawWindowFrame(Rect, Int32, Int32, Int32, Int32, Boolean, Boolean).

#### DrawWindowFrame(Rect, Int32, Int32, Int32, Int32, Boolean, Boolean)

Draws a frame for a window with padding and an optional visible border inside the padding.

##### Declaration

    public virtual void DrawWindowFrame(Rect region, int paddingLeft = 0, int paddingTop = 0, int paddingRight = 0, int paddingBottom = 0, bool border = true, bool fill = false)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region | Screen relative region where the frame will be drawn.
System.Int32 | paddingLeft | Number of columns to pad on the left (if 0 the border will not appear on the left).
System.Int32 | paddingTop | Number of rows to pad on the top (if 0 the border and title will not appear on the top).
System.Int32 | paddingRight | Number of columns to pad on the right (if 0 the border will not appear on the right).
System.Int32 | paddingBottom | Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).
System.Boolean | border | If set to `true` and any padding dimension is > 0 the border will be drawn.
System.Boolean | fill | If set to `true` it will clear the content area (the area inside the padding) with the current color, otherwise the content area will be left untouched.

#### DrawWindowTitle(Rect, ustring, Int32, Int32, Int32, Int32, TextAlignment)

Draws the title for a Window-style view incorporating padding.

##### Declaration

    public virtual void DrawWindowTitle(Rect region, ustring title, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, TextAlignment textAlignment = TextAlignment.Left)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region | Screen relative region where the frame will be drawn.
NStack.ustring | title | The title for the window. The title will only be drawn if `title` is not null or empty and paddingTop is greater than 0.
System.Int32 | paddingLeft | Number of columns to pad on the left (if 0 the border will not appear on the left).
System.Int32 | paddingTop | Number of rows to pad on the top (if 0 the border and title will not appear on the top).
System.Int32 | paddingRight | Number of columns to pad on the right (if 0 the border will not appear on the right).
System.Int32 | paddingBottom | Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).
TextAlignment | textAlignment | Not yet immplemented.

#### End()

Ends the execution of the console driver.

##### Declaration

    public abstract void End()

#### Init(Action)

Initializes the driver

##### Declaration

    public abstract void Init(Action terminalResized)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action | terminalResized | Method to invoke when the terminal is resized.

#### MakeAttribute(Color, Color)

Make the attribute for the foreground and background colors.

##### Declaration

    public abstract Attribute MakeAttribute(Color fore, Color back)

##### Parameters

Type | Name | Description
--- | --- | ---
Color | fore | Foreground.
Color | back | Background.

##### Returns

Type | Description
--- | ---
Attribute |

#### MakePrintable(Rune)

Ensures a Rune is not a control character and can be displayed by translating characters below 0x20 to equivalent, printable, Unicode chars.

##### Declaration

    public static Rune MakePrintable(Rune c)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Rune | c | Rune to translate

##### Returns

Type | Description
--- | ---
System.Rune |

#### Move(Int32, Int32)

Moves the cursor to the specified column and row.

##### Declaration

    public abstract void Move(int col, int row)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | col | Column to move the cursor to.
System.Int32 | row | Row to move the cursor to.

#### PrepareToRun(MainLoop, Action<KeyEvent>, Action<KeyEvent>, Action<KeyEvent>, Action<MouseEvent>)

Prepare the driver and set the key and mouse events handlers.

##### Declaration

    public abstract void PrepareToRun(MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)

##### Parameters

Type | Name | Description
--- | --- | ---
MainLoop | mainLoop | The main loop.
System.Action<KeyEvent> | keyHandler | The handler for ProcessKey
System.Action<KeyEvent> | keyDownHandler | The handler for key down events
System.Action<KeyEvent> | keyUpHandler | The handler for key up events
System.Action<MouseEvent> | mouseHandler | The handler for mouse events

#### Refresh()

Updates the screen to reflect all the changes that have been done to the display buffer

##### Declaration

    public abstract void Refresh()

#### SetAttribute(Attribute)

Selects the specified attribute as the attribute to use for future calls to AddRune, AddString.

##### Declaration

    public abstract void SetAttribute(Attribute c)

##### Parameters

Type | Name | Description
--- | --- | ---
Attribute | c | C.

#### SetColors(ConsoleColor, ConsoleColor)

Set Colors from limit sets of colors.

##### Declaration

    public abstract void SetColors(ConsoleColor foreground, ConsoleColor background)

##### Parameters

Type | Name | Description
--- | --- | ---
System.ConsoleColor | foreground | Foreground.
System.ConsoleColor | background | Background.

#### SetColors(Int16, Int16)

Advanced uses - set colors to any pre-set pairs, you would need to init_color that independently with the R, G, B values.

##### Declaration

    public abstract void SetColors(short foregroundColorId, short backgroundColorId)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int16 | foregroundColorId | Foreground color identifier.
System.Int16 | backgroundColorId | Background color identifier.

#### SetTerminalResized(Action)

Set the handler when the terminal is resized.

##### Declaration

    public void SetTerminalResized(Action terminalResized)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action | terminalResized |

#### StartReportingMouseMoves()

Start of mouse moves.

##### Declaration

    public abstract void StartReportingMouseMoves()

#### StopReportingMouseMoves()

Stop reporting mouses moves.

##### Declaration

    public abstract void StopReportingMouseMoves()

#### Suspend()

Suspend the application, typically needs to save the state, suspend the app and upon return, reset the console driver.

##### Declaration

    public abstract void Suspend()

#### UncookMouse()

Disables the cooked event processing from the mouse driver. At startup, it is assumed mouse events are cooked.

##### Declaration

    public abstract void UncookMouse()

#### UpdateCursor()

Updates the location of the cursor position

##### Declaration

    public abstract void UpdateCursor()

#### UpdateScreen()

Redraws the physical screen with the contents that have been queued up via any of the printing commands.

##### Declaration

    public abstract void UpdateScreen()