Skip to content

Cursor Class

A cursor that is attached to a Console used for printing.

C#
[DataContract]
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class Cursor : IComponent, IDisposable

Inheritance object

Implements IComponent, IDisposable

Creates a new instance of the cursor as a component.

C#
public Cursor()

Creates a new instance of the cursor that works with the specified surface.

C#
public Cursor(ICellSurface surface)

surface ICellSurface

The default glyph used for a new cursor. Value 219.

C#
public static readonly int DefaultCursorGlyph

Cell used to render the cursor on the screen.

C#
[DataMember(Order = 0)]
public ColoredGlyphBase CursorRenderCell { get; set; }

Used in rendering. The cell after the effect has been applied.

C#
public ColoredGlyphBase CursorRenderCellActiveState { get; }

Appearance used when printing text. PrintOnlyCharacterData must be set to false for this to apply.

C#
[DataMember]
public ColoredGlyphBase PrintAppearance { get; set; }

When true, printing will use the host’s DefaultForeground and DefaultBackground color properties.

C#
[DataMember]
public bool PrintAppearanceMatchesHost { get; set; }

This effect is applied to each cell printed by the cursor.

C#
[DataMember]
public ICellEffect? PrintEffect { get; set; }

This is the cursor visible effect, like blinking.

C#
[DataMember]
public ICellEffect? CursorRenderEffect { get; set; }

Sets the glyph used in rendering. A shortcut to CursorRenderCell.

C#
public int CursorGlyph { get; set; }

When true, indicates that the cursor, when printing, should not use the PrintAppearance property in determining the color/effect of the cell, but keep the cell the same as it was.

C#
[DataMember]
public bool PrintOnlyCharacterData { get; set; }

When true, left-clicking on the host surface will reposition the cursor to the clicked position.

C#
[DataMember]
public bool MouseClickReposition { get; set; }

When true, returns a handled status from the mouse processor when the MouseClickReposition is enabled. This prevents further left-mouse processing on the host.

C#
[DataMember]
public bool MouseClickRepositionHandlesMouse { get; set; }

Shows or hides the cursor. This does not affect how the cursor operates.

C#
[DataMember]
public bool IsVisible { get; set; }

When false, prevents the cursor from running on the host.

C#
[DataMember]
public bool IsEnabled { get; set; }

When false, prevents the CursorRenderEffect from being applied.

C#
public bool ApplyCursorEffect { get; set; }

When true, applies the PrintEffect to the cursor when it prints.

C#
[DataMember]
public bool UsePrintEffect { get; set; }

Gets or sets the location of the cursor on the console.

C#
[DataMember]
public Point Position { get; set; }

When true, prevents any print method from breaking words up by spaces when wrapping lines.

C#
[DataMember]
public bool DisableWordBreak { get; set; }

When true, printing characters to the end of a line won’t wrap to the next line. Defaults to false, which moves the cursor to the next line if printing goes past the end of the line.

C#
public bool DisablePrintAutomaticLineFeed { get; set; }

Enables Linux-like string parsing where a \n behaves like a \r\n.

C#
[DataMember]
public bool UseLinuxLineEndings { get; set; }

Indicates this cursor should process te string through the Parse(ReadOnlySpan<char>, int, ICellSurface, ParseCommandStacks) method from Parser to create a colored string when using Print(string) or Print(string, ColoredGlyphBase, ICellEffect).

C#
[DataMember]
public bool UseStringParser { get; set; }

Gets or sets the row of the cursor position.

C#
public int Row { get; set; }

Gets or sets the column of the cursor position.

C#
public int Column { get; set; }

Indicates that when the cursor goes past the last cell of the console, that the rows should be shifted up when the cursor is automatically reset to the next line.

C#
[DataMember]
public bool AutomaticallyShiftRowsUp { get; set; }

Sets the sort order of this component within the host.

C#
[DataMember]
public uint SortOrder { get; set; }

Resets the CursorRenderEffect back to the default.

C#
public Cursor ApplyDefaultCursorEffect()

Cursor

Clones and reassigns CursorRenderEffect to restart it.

C#
public Cursor RestartCursorEffect()

Cursor

Sets the cursor appearance to the console’s default foreground and background.

C#
public Cursor SetPrintAppearanceToHost()

Cursor
This cursor object.

Exception
Thrown when the cursor is not attached to any surface.

Sets PrintAppearance.

C#
public Cursor SetPrintAppearance(ColoredGlyphBase appearance)

appearance ColoredGlyphBase
The appearance to set.

Cursor
This cursor object.

Sets PrintAppearance.

C#
public Cursor SetPrintAppearance(Color foreground, Color background)

foreground SadRogue.Primitives.Color
The foreground color.

background SadRogue.Primitives.Color
The background color

Cursor
This cursor object.

Sets PrintAppearance, only changing the foreground color.

C#
public Cursor SetPrintAppearance(Color foreground)

foreground SadRogue.Primitives.Color
The foreground color.

Cursor
This cursor object.

Prints text to the console using the default print appearance.

C#
public Cursor Print(string text)

text string
The text to print.

Cursor
Returns this cursor object.

Print(string, ColoredGlyphBase, ICellEffect?)

Section titled “Print(string, ColoredGlyphBase, ICellEffect?)”

Prints text on the console.

C#
public Cursor Print(string text, ColoredGlyphBase template, ICellEffect? templateEffect)

text string
The text to print.

template ColoredGlyphBase
The way the text will look when it is printed.

templateEffect ICellEffect
Effect to apply to the text as its printed. Can be null.

Cursor
Returns this cursor object.

Prints text to the console using the appearance of the colored string, but with coroutine.

C#
public IEnumerator<Wait> PrintCoroutine(ColoredString text)

text ColoredString
The text to print.

IEnumerator<Wait>
An enumerator that returns at each character printed.

Prints text to the console using the appearance of the colored string.

C#
public Cursor Print(ColoredString text)

text ColoredString
The text to print.

Cursor
Returns this cursor object.

Returns the cursor to the start of the current line.

C#
public Cursor CarriageReturn()

Cursor
The current cursor object.

Moves the cursor down a line.

C#
public Cursor LineFeed()

Cursor
The current cursor object.

Calls the CarriageReturn() and LineFeed() methods in a single call.

C#
public Cursor NewLine()

Cursor
The current cursor object.

Moves the cursor to the specified position.

C#
public Cursor Move(Point position)

position SadRogue.Primitives.Point
The destination of the cursor.

Cursor
This cursor object.

Moves the cursor to the specified position.

C#
public Cursor Move(int x, int y)

x int
The x (horizontal) of the position.

y int
The x (vertical) of the position.

Cursor

Moves the cursor up by the specified amount of lines.

C#
public Cursor Up(int amount)

amount int
The amount of lines to move the cursor

Cursor
This cursor object.

Moves the cursor down by the specified amount of lines.

C#
public Cursor Down(int amount)

amount int
The amount of lines to move the cursor

Cursor
This cursor object.

Moves the cursor left by the specified amount of columns.

C#
public Cursor Left(int amount)

amount int
The amount of columns to move the cursor

Cursor
This cursor object.

Moves the cursor left by the specified amount of columns, wrapping the cursor if needed.

C#
public Cursor LeftWrap(int amount)

amount int
The amount of columns to move the cursor

Cursor
This cursor object.

Moves the cursor right by the specified amount of columns.

C#
public Cursor Right(int amount)

amount int
The amount of columns to move the cursor

Cursor
This cursor object.

Moves the cursor right by the specified amount of columns, wrapping the cursor if needed.

C#
public Cursor RightWrap(int amount)

amount int
The amount of columns to move the cursor

Cursor
This cursor object.

Clears the cell at the position of the cursor.

C#
public Cursor Erase(int glyph = 0)

glyph int
The glyph to set on the erased cell. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

Clears the cells in the same column as the cursor.

C#
public Cursor EraseColumn(int glyph = 0)

glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

Clears the cells in the same row as the cursor.

C#
public Cursor EraseRow(int glyph = 0)

glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

Clears the cells above the cursor.

C#
public Cursor EraseUp(int glyph = 0)

glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

Clears the cells below the cursor.

C#
public Cursor EraseDown(int glyph = 0)

glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

Clears the cells to the left of the cursor.

C#
public Cursor EraseLeft(int glyph = 0)

glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

Clears the cells to the right of the cursor.

C#
public Cursor EraseRight(int glyph = 0)

glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.

Cursor
The cursor object.

Exception
Thrown when a host isn’t attached to the cursor.

C#
protected virtual void Dispose(bool disposing)

disposing bool

C#
protected ~Cursor()
C#
public void Dispose()

Raised when the keyboard is processing keys. Each key is sent to this event and can be cancelled

C#
public event EventHandler<KeyboardHandledKeyEventArgs>? KeyboardPreview

EventHandler<KeyboardHandledKeyEventArgs>