Cursor Class
Definition
Section titled “Definition”A cursor that is attached to a Console used for printing.
[DataContract][JsonObject(MemberSerialization = MemberSerialization.OptIn)]public class Cursor : IComponent, IDisposableInheritance object
Implements IComponent, IDisposable
Constructors
Section titled “Constructors”Cursor()
Section titled “Cursor()”Creates a new instance of the cursor as a component.
public Cursor()Cursor(ICellSurface)
Section titled “Cursor(ICellSurface)”Creates a new instance of the cursor that works with the specified surface.
public Cursor(ICellSurface surface)Parameters
Section titled “Parameters”surface ICellSurface
Fields
Section titled “Fields”DefaultCursorGlyph
Section titled “DefaultCursorGlyph”The default glyph used for a new cursor. Value 219.
public static readonly int DefaultCursorGlyphProperties
Section titled “Properties”CursorRenderCell
Section titled “CursorRenderCell”Cell used to render the cursor on the screen.
[DataMember(Order = 0)]public ColoredGlyphBase CursorRenderCell { get; set; }CursorRenderCellActiveState
Section titled “CursorRenderCellActiveState”Used in rendering. The cell after the effect has been applied.
public ColoredGlyphBase CursorRenderCellActiveState { get; }PrintAppearance
Section titled “PrintAppearance”Appearance used when printing text. PrintOnlyCharacterData must be set to false for this to apply.
[DataMember]public ColoredGlyphBase PrintAppearance { get; set; }PrintAppearanceMatchesHost
Section titled “PrintAppearanceMatchesHost”When true, printing will use the host’s DefaultForeground and DefaultBackground color properties.
[DataMember]public bool PrintAppearanceMatchesHost { get; set; }PrintEffect
Section titled “PrintEffect”This effect is applied to each cell printed by the cursor.
[DataMember]public ICellEffect? PrintEffect { get; set; }CursorRenderEffect
Section titled “CursorRenderEffect”This is the cursor visible effect, like blinking.
[DataMember]public ICellEffect? CursorRenderEffect { get; set; }CursorGlyph
Section titled “CursorGlyph”Sets the glyph used in rendering. A shortcut to CursorRenderCell.
public int CursorGlyph { get; set; }PrintOnlyCharacterData
Section titled “PrintOnlyCharacterData”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.
[DataMember]public bool PrintOnlyCharacterData { get; set; }MouseClickReposition
Section titled “MouseClickReposition”When true, left-clicking on the host surface will reposition the cursor to the clicked position.
[DataMember]public bool MouseClickReposition { get; set; }MouseClickRepositionHandlesMouse
Section titled “MouseClickRepositionHandlesMouse”When true, returns a handled status from the mouse processor when the MouseClickReposition is enabled. This prevents further left-mouse processing on the host.
[DataMember]public bool MouseClickRepositionHandlesMouse { get; set; }IsVisible
Section titled “IsVisible”Shows or hides the cursor. This does not affect how the cursor operates.
[DataMember]public bool IsVisible { get; set; }IsEnabled
Section titled “IsEnabled”When false, prevents the cursor from running on the host.
[DataMember]public bool IsEnabled { get; set; }ApplyCursorEffect
Section titled “ApplyCursorEffect”When false, prevents the CursorRenderEffect from being applied.
public bool ApplyCursorEffect { get; set; }UsePrintEffect
Section titled “UsePrintEffect”When true, applies the PrintEffect to the cursor when it prints.
[DataMember]public bool UsePrintEffect { get; set; }Position
Section titled “Position”Gets or sets the location of the cursor on the console.
[DataMember]public Point Position { get; set; }DisableWordBreak
Section titled “DisableWordBreak”When true, prevents any print method from breaking words up by spaces when wrapping lines.
[DataMember]public bool DisableWordBreak { get; set; }DisablePrintAutomaticLineFeed
Section titled “DisablePrintAutomaticLineFeed”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.
public bool DisablePrintAutomaticLineFeed { get; set; }UseLinuxLineEndings
Section titled “UseLinuxLineEndings”Enables Linux-like string parsing where a \n behaves like a \r\n.
[DataMember]public bool UseLinuxLineEndings { get; set; }UseStringParser
Section titled “UseStringParser”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).
[DataMember]public bool UseStringParser { get; set; }Gets or sets the row of the cursor position.
public int Row { get; set; }Column
Section titled “Column”Gets or sets the column of the cursor position.
public int Column { get; set; }AutomaticallyShiftRowsUp
Section titled “AutomaticallyShiftRowsUp”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.
[DataMember]public bool AutomaticallyShiftRowsUp { get; set; }SortOrder
Section titled “SortOrder”Sets the sort order of this component within the host.
[DataMember]public uint SortOrder { get; set; }Methods
Section titled “Methods”ApplyDefaultCursorEffect()
Section titled “ApplyDefaultCursorEffect()”Resets the CursorRenderEffect back to the default.
public Cursor ApplyDefaultCursorEffect()Returns
Section titled “Returns”RestartCursorEffect()
Section titled “RestartCursorEffect()”Clones and reassigns CursorRenderEffect to restart it.
public Cursor RestartCursorEffect()Returns
Section titled “Returns”SetPrintAppearanceToHost()
Section titled “SetPrintAppearanceToHost()”Sets the cursor appearance to the console’s default foreground and background.
public Cursor SetPrintAppearanceToHost()Returns
Section titled “Returns”Cursor
This cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when the cursor is not attached to any surface.
SetPrintAppearance(ColoredGlyphBase)
Section titled “SetPrintAppearance(ColoredGlyphBase)”Sets PrintAppearance.
public Cursor SetPrintAppearance(ColoredGlyphBase appearance)Parameters
Section titled “Parameters”appearance ColoredGlyphBase
The appearance to set.
Returns
Section titled “Returns”Cursor
This cursor object.
SetPrintAppearance(Color, Color)
Section titled “SetPrintAppearance(Color, Color)”Sets PrintAppearance.
public Cursor SetPrintAppearance(Color foreground, Color background)Parameters
Section titled “Parameters”foreground SadRogue.Primitives.Color
The foreground color.
background SadRogue.Primitives.Color
The background color
Returns
Section titled “Returns”Cursor
This cursor object.
SetPrintAppearance(Color)
Section titled “SetPrintAppearance(Color)”Sets PrintAppearance, only changing the foreground color.
public Cursor SetPrintAppearance(Color foreground)Parameters
Section titled “Parameters”foreground SadRogue.Primitives.Color
The foreground color.
Returns
Section titled “Returns”Cursor
This cursor object.
Print(string)
Section titled “Print(string)”Prints text to the console using the default print appearance.
public Cursor Print(string text)Parameters
Section titled “Parameters”text string
The text to print.
Returns
Section titled “Returns”Cursor
Returns this cursor object.
Print(string, ColoredGlyphBase, ICellEffect?)
Section titled “Print(string, ColoredGlyphBase, ICellEffect?)”Prints text on the console.
public Cursor Print(string text, ColoredGlyphBase template, ICellEffect? templateEffect)Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”Cursor
Returns this cursor object.
PrintCoroutine(ColoredString)
Section titled “PrintCoroutine(ColoredString)”Prints text to the console using the appearance of the colored string, but with coroutine.
public IEnumerator<Wait> PrintCoroutine(ColoredString text)Parameters
Section titled “Parameters”text ColoredString
The text to print.
Returns
Section titled “Returns”IEnumerator<Wait>
An enumerator that returns at each character printed.
Print(ColoredString)
Section titled “Print(ColoredString)”Prints text to the console using the appearance of the colored string.
public Cursor Print(ColoredString text)Parameters
Section titled “Parameters”text ColoredString
The text to print.
Returns
Section titled “Returns”Cursor
Returns this cursor object.
CarriageReturn()
Section titled “CarriageReturn()”Returns the cursor to the start of the current line.
public Cursor CarriageReturn()Returns
Section titled “Returns”Cursor
The current cursor object.
LineFeed()
Section titled “LineFeed()”Moves the cursor down a line.
public Cursor LineFeed()Returns
Section titled “Returns”Cursor
The current cursor object.
NewLine()
Section titled “NewLine()”Calls the CarriageReturn() and LineFeed() methods in a single call.
public Cursor NewLine()Returns
Section titled “Returns”Cursor
The current cursor object.
Move(Point)
Section titled “Move(Point)”Moves the cursor to the specified position.
public Cursor Move(Point position)Parameters
Section titled “Parameters”position SadRogue.Primitives.Point
The destination of the cursor.
Returns
Section titled “Returns”Cursor
This cursor object.
Move(int, int)
Section titled “Move(int, int)”Moves the cursor to the specified position.
public Cursor Move(int x, int y)Parameters
Section titled “Parameters”x int
The x (horizontal) of the position.
y int
The x (vertical) of the position.
Returns
Section titled “Returns”Up(int)
Section titled “Up(int)”Moves the cursor up by the specified amount of lines.
public Cursor Up(int amount)Parameters
Section titled “Parameters”amount int
The amount of lines to move the cursor
Returns
Section titled “Returns”Cursor
This cursor object.
Down(int)
Section titled “Down(int)”Moves the cursor down by the specified amount of lines.
public Cursor Down(int amount)Parameters
Section titled “Parameters”amount int
The amount of lines to move the cursor
Returns
Section titled “Returns”Cursor
This cursor object.
Left(int)
Section titled “Left(int)”Moves the cursor left by the specified amount of columns.
public Cursor Left(int amount)Parameters
Section titled “Parameters”amount int
The amount of columns to move the cursor
Returns
Section titled “Returns”Cursor
This cursor object.
LeftWrap(int)
Section titled “LeftWrap(int)”Moves the cursor left by the specified amount of columns, wrapping the cursor if needed.
public Cursor LeftWrap(int amount)Parameters
Section titled “Parameters”amount int
The amount of columns to move the cursor
Returns
Section titled “Returns”Cursor
This cursor object.
Right(int)
Section titled “Right(int)”Moves the cursor right by the specified amount of columns.
public Cursor Right(int amount)Parameters
Section titled “Parameters”amount int
The amount of columns to move the cursor
Returns
Section titled “Returns”Cursor
This cursor object.
RightWrap(int)
Section titled “RightWrap(int)”Moves the cursor right by the specified amount of columns, wrapping the cursor if needed.
public Cursor RightWrap(int amount)Parameters
Section titled “Parameters”amount int
The amount of columns to move the cursor
Returns
Section titled “Returns”Cursor
This cursor object.
Erase(int)
Section titled “Erase(int)”Clears the cell at the position of the cursor.
public Cursor Erase(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cell. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
EraseColumn(int)
Section titled “EraseColumn(int)”Clears the cells in the same column as the cursor.
public Cursor EraseColumn(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
EraseRow(int)
Section titled “EraseRow(int)”Clears the cells in the same row as the cursor.
public Cursor EraseRow(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
EraseUp(int)
Section titled “EraseUp(int)”Clears the cells above the cursor.
public Cursor EraseUp(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
EraseDown(int)
Section titled “EraseDown(int)”Clears the cells below the cursor.
public Cursor EraseDown(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
EraseLeft(int)
Section titled “EraseLeft(int)”Clears the cells to the left of the cursor.
public Cursor EraseLeft(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
EraseRight(int)
Section titled “EraseRight(int)”Clears the cells to the right of the cursor.
public Cursor EraseRight(int glyph = 0)Parameters
Section titled “Parameters”glyph int
The glyph to set on the erased cells. Defaults to glyph index 0.
Returns
Section titled “Returns”Cursor
The cursor object.
Exceptions
Section titled “Exceptions”Exception
Thrown when a host isn’t attached to the cursor.
Dispose(bool)
Section titled “Dispose(bool)”protected virtual void Dispose(bool disposing)Parameters
Section titled “Parameters”disposing bool
~Cursor()
Section titled “~Cursor()”protected ~Cursor()Dispose()
Section titled “Dispose()”public void Dispose()Events
Section titled “Events”KeyboardPreview
Section titled “KeyboardPreview”Raised when the keyboard is processing keys. Each key is sent to this event and can be cancelled
public event EventHandler<KeyboardHandledKeyEventArgs>? KeyboardPreview