💻 TermColor User Manual
Public Member Functions | Properties | List of all members
TermColor.Terminal Class Reference
Inheritance diagram for TermColor.Terminal:
Inheritance graph
[legend]
Collaboration diagram for TermColor.Terminal:
Collaboration graph
[legend]

Public Member Functions

 Terminal ()
 
 Terminal (int width, int height)
 
 Terminal (int width, int height, ColorMode colorMode)
 
void SetCursorPosition (int left, int top)
 
void ResetColor ()
 
override void Write (char value)
 
override void Flush ()
 
void Flush (int x, int y)
 
void SetChar (int x, int y, char ch)
 
void SetForeground< TColorValue > (int x, int y, in TColorValue color)
 
void SetBackground< TColorValue > (int x, int y, in TColorValue color)
 
void Clear ()
 
void Clear< TColorValue > (char c, in TColorValue foreground, in TColorValue background)
 
void Flush (TextWriter output)
 
void Flush (TextWriter output, int offsetLeft, int offsetTop)
 
- Public Member Functions inherited from TermColor.ITerminalBuffer
void SetPoint< TColorValue > (int x, int y, char ch, in TColorValue foreground, in TColorValue background)
 

Properties

override Encoding Encoding [get]
 
int Width [get]
 
int Height [get]
 
int? CursorLeft [get, set]
 
DitherMapping DitherPreset = DitherMapping.Default [get, set]
 
int? CursorTop [get, set]
 
IColorForegroundColor [get, set]
 
IColorBackgroundColor [get, set]
 
ITerminalBuffer Buffer [get]
 
TextWriter Out = Console.Out [get, set]
 
ColorMode ColorMode [get, set]
 
- Properties inherited from TermColor.ITerminalBuffer
int Width [get]
 
int Height [get]
 

Detailed Description

Represents a colored text buffer. Not thread-safe.

Internally uses AnsiTermBuffer and Win32TermBuffer based on the current Terminal.ColorMode. On Windows, Win32TermBuffer is used in 16 color mode, otherwise AnsiTermBuffer is used.

Constructor & Destructor Documentation

◆ Terminal() [1/3]

TermColor.Terminal.Terminal ( )
inline

Create a new terminal buffer in 24-bit color mode with dimensions taken from (Console.WindowWidth, Console.WindowHeight).

◆ Terminal() [2/3]

TermColor.Terminal.Terminal ( int  width,
int  height 
)
inline

Create a new terminal buffer with given dimensions in 24-bit color mode.

Parameters
widthThe number of columns in the new buffer.
heightThe number of rows in the new buffer.

◆ Terminal() [3/3]

TermColor.Terminal.Terminal ( int  width,
int  height,
ColorMode  colorMode 
)
inline

Create a new terminal buffer with given dimensions and color mode.

Parameters
widthThe number of columns in the new buffer.
heightThe number of rows in the new buffer.
colorModeThe color mode of the new buffer.

Member Function Documentation

◆ Clear()

void TermColor.Terminal.Clear ( )
inline

Clears the buffer with BackgroundColor and sets the cursor to the top left corner.

Implements TermColor.ITerminalBuffer.

◆ Clear< TColorValue >()

void TermColor.Terminal.Clear< TColorValue > ( char  c,
in TColorValue  foreground,
in TColorValue  background 
)

Fill the buffer with given (char, IColor, IColor) tuple.

Template Parameters
TColorValueType of the color.
Parameters
cThe character to clear with.
foregroundForeground color.
backgroundBackground color.

Implements TermColor.ITerminalBuffer.

Type Constraints
TColorValue :IColor 
TColorValue :Buffer.Clear 
TColorValue :c 
TColorValue :foreground 
TColorValue :background 

◆ Flush() [1/4]

override void TermColor.Terminal.Flush ( )
inline

Forward the internal buffers out to Terminal.Out.

◆ Flush() [2/4]

void TermColor.Terminal.Flush ( int  x,
int  y 
)
inline

Forward the internal buffers out to Terminal.Out.

Parameters
xColumn position of the top left corner of the displayed output.
yRow position of the top left corner of the displayed output.

◆ Flush() [3/4]

void TermColor.Terminal.Flush ( TextWriter  output)
inline

Forward the contents of the buffer to an output device.

Parameters
outputThe output device.

Implements TermColor.ITerminalBuffer.

◆ Flush() [4/4]

void TermColor.Terminal.Flush ( TextWriter  output,
int  offsetLeft,
int  offsetTop 
)
inline

Forward the contents of the buffer to an output device at a specific offset.

Parameters
outputThe output device.

Implements TermColor.ITerminalBuffer.

◆ ResetColor()

void TermColor.Terminal.ResetColor ( )
inline

Sets the foreground and background colors to their defaults.

◆ SetBackground< TColorValue >()

void TermColor.Terminal.SetBackground< TColorValue > ( int  x,
int  y,
in TColorValue  color 
)

Write background color to one point in the buffer. Rows and columns are numbered from the top left starting at zero.

Parameters
xColumn number.
yRow number.
backgroundBackground color of the character.

Implements TermColor.ITerminalBuffer.

Type Constraints
TColorValue :IColor 
TColorValue :Buffer.SetBackground 
TColorValue :x 
TColorValue :y 
TColorValue :color 

◆ SetChar()

void TermColor.Terminal.SetChar ( int  x,
int  y,
char  ch 
)

Write a character to one point in the buffer. Rows and columns are numbered from the top left starting at zero.

Parameters
xColumn number.
yRow number.
chThe character to write.

Implements TermColor.ITerminalBuffer.

◆ SetCursorPosition()

void TermColor.Terminal.SetCursorPosition ( int  left,
int  top 
)
inline

Sets the position of the cursor.

Parameters
leftThe column position of the cursor. Columns are numbered from left to right starting at 0.
topThe row position of the cursor. Rows are numbered from top to bottom starting at 0.

◆ SetForeground< TColorValue >()

void TermColor.Terminal.SetForeground< TColorValue > ( int  x,
int  y,
in TColorValue  color 
)

Write foreground color to one point in the buffer. Rows and columns are numbered from the top left starting at zero.

Parameters
xColumn number.
yRow number.
foregroundForeground color of the character.

Implements TermColor.ITerminalBuffer.

Type Constraints
TColorValue :IColor 
TColorValue :Buffer.SetForeground 
TColorValue :x 
TColorValue :y 
TColorValue :color 

◆ Write()

override void TermColor.Terminal.Write ( char  value)
inline

Writes the specified Unicode character value to the buffer at the current cursor position and advances the cursor.

Parameters
valueThe character to write.

Property Documentation

◆ BackgroundColor

IColor? TermColor.Terminal.BackgroundColor
getset

Gets or sets the background color of the buffer.

◆ ColorMode

ColorMode TermColor.Terminal.ColorMode
getset

Gets or sets the color mode of the buffer.

◆ CursorLeft

int? TermColor.Terminal.CursorLeft
getset

Gets or sets the column position of the cursor within the buffer. Columns are numbered from left to right starting at 0.

◆ CursorTop

int? TermColor.Terminal.CursorTop
getset

Gets or sets the row position of the cursor within the buffer. Rows are numbered from top to bottom starting at 0.

◆ ForegroundColor

IColor? TermColor.Terminal.ForegroundColor
getset

Gets or sets the foreground color of the buffer.

◆ Height

int TermColor.Terminal.Height
get

Gets the height of the buffer.

◆ Out

TextWriter TermColor.Terminal.Out = Console.Out
getset

Gets or sets the output target. Calling Flush() forwards contents of this Terminal to Out.

◆ Width

int TermColor.Terminal.Width
get

Gets the width of the buffer.


The documentation for this class was generated from the following file: