Struct TextModeColorScheme
The resolved colors of one TextMode theme. This is the runtime value a view or a terminal draws with, produced from a palette by FromPalette(ColorPalette).
Implements
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public readonly struct TextModeColorScheme : IEquatable<TextModeColorScheme>
Remarks
Every color is always defined. An entry the source palette omits falls back to the corresponding color in Fallback, so a scheme is never partially populated and a caller never has to null-check a color.
The scheme keeps a reference to the palette it came from, because two things above it need the palette rather than the resolved colors: SetPalette(ColorPalette) wants the ANSI sixteen by index, and remapping existing content from one theme to another needs both palettes to build the mapping.
Constructors
TextModeColorScheme(ColorPalette, Color32, Color32, Color32, Color32, Color32, Color32, Color32, Color32, Color32, Color32, Color32, Color32, Color32)
Constructs a color scheme from explicit values. Most callers should use FromPalette(ColorPalette) instead.
Declaration
public TextModeColorScheme(ColorPalette sourcePalette, Color32 foreground, Color32 background, Color32 brightForeground, Color32 dimForeground, Color32 accent, Color32 border, Color32 selectionForeground, Color32 selectionBackground, Color32 cursor, Color32 errorForeground, Color32 warningForeground, Color32 infoForeground, Color32 successForeground)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorPalette | sourcePalette | The palette the colors came from, or null when there is none. |
| Color32 | foreground | Default text color. |
| Color32 | background | Default cell background. |
| Color32 | brightForeground | Emphasized text color. |
| Color32 | dimForeground | Secondary text color. |
| Color32 | accent | Highlight color. |
| Color32 | border | Frame and separator color. |
| Color32 | selectionForeground | Text color inside a selection. |
| Color32 | selectionBackground | Fill color behind a selection. |
| Color32 | cursor | Text cursor color. |
| Color32 | errorForeground | Error text color. |
| Color32 | warningForeground | Warning text color. |
| Color32 | infoForeground | Informational text color. |
| Color32 | successForeground | Success text color. |
Properties
Accent
Highlight color for headings, keys and anything meant to draw the eye.
Declaration
public Color32 Accent { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Background
Default cell background, and the color a cleared grid is filled with.
Declaration
public Color32 Background { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Border
Frames, rules and separators drawn with box characters.
Declaration
public Color32 Border { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightForeground
Emphasized text, one step brighter than Foreground.
Declaration
public Color32 BrightForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Cursor
The text cursor.
Declaration
public Color32 Cursor { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
DimForeground
Secondary text such as hints, disabled entries and inactive labels.
Declaration
public Color32 DimForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
ErrorForeground
Failures and error messages.
Declaration
public Color32 ErrorForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Foreground
Default text color, used for any cell written without an explicit color.
Declaration
public Color32 Foreground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
InfoForeground
Neutral notices.
Declaration
public Color32 InfoForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Name
Gets the name of the source palette, or an empty string when there is none.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
SelectionBackground
Fill color behind a selected region.
Declaration
public Color32 SelectionBackground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
SelectionForeground
Text color inside a selected region.
Declaration
public Color32 SelectionForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
SourcePalette
The palette this scheme was read from, or null when it was built from explicit colors.
Declaration
public ColorPalette SourcePalette { get; }
Property Value
| Type | Description |
|---|---|
| ColorPalette |
SuccessForeground
Confirmations and completed actions.
Declaration
public Color32 SuccessForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
WarningForeground
Cautions and non-fatal problems.
Declaration
public Color32 WarningForeground { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Methods
Equals(TextModeColorScheme)
Declaration
public bool Equals(TextModeColorScheme other)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeColorScheme | other |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
Two schemes are equal when they resolve to the same colors. The source palette is
deliberately left out of the comparison, because ColorPalette compares by name
only: two palettes named alike with different colors would otherwise report as equal
schemes, which is exactly the case a theme switch has to detect.
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
FromPalette(ColorPalette)
Reads the TextMode colors out of a theme palette.
Declaration
public static TextModeColorScheme FromPalette(ColorPalette palette)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorPalette | palette | The palette to read. Any entry the palette does not define falls back to the corresponding color in Fallback, so the result is always complete. Pass null to get the classic theme. |
Returns
| Type | Description |
|---|---|
| TextModeColorScheme | The resolved color scheme. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
Resolve(string)
Resolves a theme by name and reads its colors, in one step.
Declaration
public static TextModeColorScheme Resolve(string themeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | themeName | The theme name to resolve. Null or empty gives the classic theme. |
Returns
| Type | Description |
|---|---|
| TextModeColorScheme | The resolved color scheme. Never partially populated. |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Operators
operator ==(TextModeColorScheme, TextModeColorScheme)
Returns whether two schemes resolve to the same colors.
Declaration
public static bool operator ==(TextModeColorScheme left, TextModeColorScheme right)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeColorScheme | left | The first scheme. |
| TextModeColorScheme | right | The second scheme. |
Returns
| Type | Description |
|---|---|
| bool | True when every color matches. |
operator !=(TextModeColorScheme, TextModeColorScheme)
Returns whether two schemes resolve to different colors.
Declaration
public static bool operator !=(TextModeColorScheme left, TextModeColorScheme right)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeColorScheme | left | The first scheme. |
| TextModeColorScheme | right | The second scheme. |
Returns
| Type | Description |
|---|---|
| bool | True when any color differs. |