Skip to content
ConsoleMonster
Class

Region

ConsoleMonster.Canvas

Namespace
ConsoleMonster.Canvas
Assembly
ConsoleMonster
Modifiers
sealed

The rectangle a widget renders into: a clipped view onto a CellBuffer with local coordinates. Writes outside the region are discarded, so a widget can never draw over its neighbours.

Inheritance

  • object
  • Region

Usage

Explore 114 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 1

Accepted by parameters 113

Constructors

Region 2 overloads
public Region(CellBuffer buffer, Rect bounds) #

Creates a region covering part of a buffer.

Parameters

buffer ConsoleMonster.Canvas.CellBuffer required
The buffer.
bounds ConsoleMonster.Canvas.Rect required
The absolute rectangle (clipped to the buffer).
public Region(CellBuffer buffer) #

Creates a region covering a whole buffer.

Parameters

buffer ConsoleMonster.Canvas.CellBuffer required
The buffer.

Methods

Fill 2 overloads
public void Fill(int x, int y, int width, int height, string glyph, Style style) #

Fills a local rectangle with a glyph.

Parameters

x int required
Local column.
y int required
Local row.
width int required
Width.
height int required
Height.
glyph string required
The glyph.
style ConsoleMonster.Styling.Style required
The style.
public void Fill(Style style) #

Fills the whole region with blanks in a style (for example a header bar background).

Parameters

style ConsoleMonster.Styling.Style required
The style.
public Cell Get(int x, int y) #

Reads a cell at a local position.

Parameters

x int required
Local column.
y int required
Local row.

Returns

Cell The cell (blank when outside).
public void HorizontalLine(int x, int y, int count, string glyph, Style style) #

Repeats a glyph horizontally.

Parameters

x int required
Local column.
y int required
Local row.
count int required
Number of cells.
glyph string required
The glyph.
style ConsoleMonster.Styling.Style required
The style.
public void Put(int x, int y, string glyph, Style style, int width = 1) #

Places one grapheme at a local position.

Parameters

x int required
Local column.
y int required
Local row.
glyph string required
The grapheme.
style ConsoleMonster.Styling.Style required
The style.
width int = 1 optional
Grapheme width (1 or 2), or 0 to measure.
public void SetStyle(int x, int y, Style style) #

Changes the style of a cell, keeping its glyph.

Parameters

x int required
Local column.
y int required
Local row.
style ConsoleMonster.Styling.Style required
The style.
public Region Sub(int x, int y, int width, int height) #

Returns a child region in local coordinates, clipped to this region.

Parameters

x int required
Local left column.
y int required
Local top row.
width int required
Width.
height int required
Height.

Returns

Region The child region.
public void VerticalLine(int x, int y, int count, string glyph, Style style) #

Repeats a glyph vertically.

Parameters

x int required
Local column.
y int required
Local row.
count int required
Number of cells.
glyph string required
The glyph.
style ConsoleMonster.Styling.Style required
The style.
Write 2 overloads
public int Write(int x, int y, string text, Style style, int maxWidth = -1) #

Writes single-line text at a local position, clipped to the region (and to maxWidth).

Parameters

x int required
Local column.
y int required
Local row.
text string required
The text.
style ConsoleMonster.Styling.Style required
The style.
maxWidth int = -1 optional
Maximum cells to use, or -1 for the rest of the row.

Returns

int The local column after the text.
public int Write(int x, int y, StyledLine line, int maxWidth = -1, Style baseStyle = default) #

Writes a styled line at a local position, clipped to the region.

Parameters

x int required
Local column.
y int required
Local row.
line ConsoleMonster.Text.StyledLine required
The line.
maxWidth int = -1 optional
Maximum cells to use, or -1 for the rest of the row.
baseStyle ConsoleMonster.Styling.Style = default optional
A style layered underneath every span.

Returns

int The local column after the text.

Properties

public CellBuffer Buffer { get; } #

The underlying buffer.

public Rect Bounds { get; } #

The absolute rectangle within the buffer.

public int Width { get; } #

Width in cells.

public int Height { get; } #

Height in cells.