Class TextModeConsole
High-level text operations API for a CellGrid. Provides convenient methods for printing text, drawing boxes, and filling regions with support for text wrapping, alignment, and background blending.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public class TextModeConsole
Constructors
TextModeConsole(CellGrid, GlyphAtlasCache)
Creates a new TextModeConsole wrapping the specified grid and glyph cache.
Declaration
public TextModeConsole(CellGrid grid, GlyphAtlasCache glyphCache)
Parameters
| Type | Name | Description |
|---|---|---|
| CellGrid | grid | The cell grid to operate on. |
| GlyphAtlasCache | glyphCache | The glyph atlas cache for stamping cells. |
Properties
Columns
Gets the number of columns in the grid.
Declaration
public int Columns { get; }
Property Value
| Type | Description |
|---|---|
| int |
Grid
Gets the underlying cell grid.
Declaration
public CellGrid Grid { get; }
Property Value
| Type | Description |
|---|---|
| CellGrid |
Rows
Gets the number of rows in the grid.
Declaration
public int Rows { get; }
Property Value
| Type | Description |
|---|---|
| int |
WrapMode
Gets or sets the line wrap mode used by PrintWrapped(int, int, int, string, Color32, Color32, CellAttributes) and PrintWrappedHeight(int, string, int). By default the value is read live from the active module configuration, so changes made to the configuration (including in Play Mode) apply to subsequent draws without recreating the console. Assigning a value pins it as an explicit override for this console, after which the configuration is ignored.
Declaration
public TextWrapMode WrapMode { get; set; }
Property Value
| Type | Description |
|---|---|
| TextWrapMode |
Methods
Blit(CellGrid, int, int, int, int, int, int, float, float)
Blits (copies) a region from one cell grid to another with optional alpha blending.
Declaration
public void Blit(CellGrid src, int srcX, int srcY, int w, int h, int dstX, int dstY, float fgAlpha = 1, float bgAlpha = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| CellGrid | src | Source cell grid. |
| int | srcX | Source starting column. |
| int | srcY | Source starting row. |
| int | w | Width to copy. |
| int | h | Height to copy. |
| int | dstX | Destination starting column. |
| int | dstY | Destination starting row. |
| float | fgAlpha | Foreground alpha multiplier (0-1). |
| float | bgAlpha | Background alpha multiplier (0-1). |
Clear()
Clears the entire grid to default colors.
Declaration
public void Clear()
ClearRegion(int, int, int, int)
Clears a rectangular region.
Declaration
public void ClearRegion(int x, int y, int w, int h)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Starting column. |
| int | y | Starting row. |
| int | w | Width in columns. |
| int | h | Height in rows. |
DrawBox(int, int, int, int, BoxStyle, Color32, Color32)
Draws a box using the specified box drawing style.
Declaration
public void DrawBox(int x, int y, int w, int h, BoxStyle style, Color32 fg, Color32 bg)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Starting column. |
| int | y | Starting row. |
| int | w | Width in columns (including border). |
| int | h | Height in rows (including border). |
| BoxStyle | style | Box drawing character style. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
DrawHLine(int, int, int, uint, Color32, Color32)
Draws a horizontal line of characters.
Declaration
public void DrawHLine(int x, int y, int length, uint codepoint, Color32 fg, Color32 bg)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Starting column. |
| int | y | Row position. |
| int | length | Length in columns. |
| uint | codepoint | Character codepoint for the line. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
DrawVLine(int, int, int, uint, Color32, Color32)
Draws a vertical line of characters.
Declaration
public void DrawVLine(int x, int y, int length, uint codepoint, Color32 fg, Color32 bg)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Column position. |
| int | y | Starting row. |
| int | length | Length in rows. |
| uint | codepoint | Character codepoint for the line. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
Fill(int, int, int, int, uint, Color32, Color32, CellAttributes)
Fills a rectangular region with a character and colors.
Declaration
public void Fill(int x, int y, int w, int h, uint codepoint, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Starting column. |
| int | y | Starting row. |
| int | w | Width in columns. |
| int | h | Height in rows. |
| uint | codepoint | Unicode codepoint to fill with. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Cell attributes. |
Print(int, int, string, Color32, Color32, BackgroundBlendMode, CellAttributes)
Prints a string at the specified position. Characters that extend beyond the grid boundary are clipped.
Declaration
public void Print(int x, int y, string text, Color32 fg, Color32 bg, BackgroundBlendMode blend = BackgroundBlendMode.Set, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Column position (0-based). |
| int | y | Row position (0-based). |
| string | text | Text to print. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| BackgroundBlendMode | blend | Background blend mode. |
| CellAttributes | attributes | Text style attributes. |
PrintAligned(int, string, TextAlignment, Color32, Color32, CellAttributes)
Prints a string aligned horizontally within the full grid width.
Declaration
public void PrintAligned(int y, string text, TextAlignment align, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | y | Row position (0-based). |
| string | text | Text to print. |
| TextAlignment | align | Horizontal alignment. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Text style attributes. |
PrintWrapped(int, int, int, string, Color32, Color32, CellAttributes)
Prints a string with word wrapping within a specified width.
Declaration
public int PrintWrapped(int x, int y, int width, string text, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Starting column position. |
| int | y | Starting row position. |
| int | width | Maximum width in columns. |
| string | text | Text to print. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Text style attributes. |
Returns
| Type | Description |
|---|---|
| int | Number of rows used. |
PrintWrappedHeight(int, string, int)
Calculates the number of rows that would be used by wrapped text without printing. The returned count reflects the active WrapMode and matches the row count PrintWrapped(int, int, int, string, Color32, Color32, CellAttributes) would use for the same text, width, and start column.
Declaration
public int PrintWrappedHeight(int width, string text, int x = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | Maximum width in columns. |
| string | text | Text to measure. |
| int | x | Starting column position, used to clamp the effective width to the grid. |
Returns
| Type | Description |
|---|---|
| int | Number of rows required. |
PutChar(int, int, uint, Color32, Color32, CellAttributes)
Puts a single character at the specified position.
Declaration
public void PutChar(int x, int y, uint codepoint, Color32 fg, Color32 bg, CellAttributes attributes = CellAttributes.None)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | Column position. |
| int | y | Row position. |
| uint | codepoint | Unicode codepoint. |
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
| CellAttributes | attributes | Cell attributes. |