Class ANSISGRAttributes
Maps the style parameters of an ANSI SGR (Select Graphic Rendition) sequence onto CellAttributes flags.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public static class ANSISGRAttributes
Remarks
SGR carries both style and color. This class covers the style half only, so that the terminal emulator and the scrollback formatter share one table rather than each keeping a copy. Color parameters are left to the caller, which is the only side that knows what the current default colors are.
The sequences a caller is most likely to care about are ESC[7m to invert a
passage and ESC[27m to stop inverting it, with ESC[0m clearing everything
at once.
Fields
SGR_INVERSE
The SGR parameter that turns on inverse video, swapping foreground and background.
Declaration
public const int SGR_INVERSE = 7
Field Value
| Type | Description |
|---|---|
| int |
SGR_INVERSE_OFF
The SGR parameter that turns inverse video back off.
Declaration
public const int SGR_INVERSE_OFF = 27
Field Value
| Type | Description |
|---|---|
| int |
SGR_RESET
The SGR parameter that clears every style attribute and resets the colors.
Declaration
public const int SGR_RESET = 0
Field Value
| Type | Description |
|---|---|
| int |
Methods
Apply(CellAttributes, int)
Applies one SGR parameter to a set of cell attributes and returns the result.
Declaration
public static CellAttributes Apply(CellAttributes current, int parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| CellAttributes | current | The attributes in effect before this parameter. |
| int | parameter | The numeric SGR parameter, for example |
Returns
| Type | Description |
|---|---|
| CellAttributes | The updated attributes. Parameters this class does not recognize, including every
color parameter, leave |
Remarks
Parameter 0 clears all style attributes. It does not reset colors, because
this class does not deal with colors at all; a caller that also tracks colors has
to reset those itself.
IsAttributeParameter(int)
Determines whether an SGR parameter affects style attributes rather than colors.
Declaration
public static bool IsAttributeParameter(int parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parameter | The numeric SGR parameter to test. |
Returns
| Type | Description |
|---|---|
| bool |
|