Class TextModeThemeChangedEvent
Event published when the active TextMode color theme changes. Views and terminals subscribe to this to re-adopt the theme's colors and, where a color map is supplied, to recolor the content they already hold.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public sealed class TextModeThemeChangedEvent : ScyllaEvent
Remarks
An event is used here rather than the direct calls the Console module makes, because TextMode has no single owner to call through. A scene can hold any number of views, and a TextModeTerminal is a plain object that no registry knows about.
Constructors
TextModeThemeChangedEvent(in TextModeColorScheme, in TextModeColorScheme, IReadOnlyDictionary<uint, uint>, bool, IReadOnlyDictionary<uint, uint>)
Creates a new theme-changed event.
Declaration
public TextModeThemeChangedEvent(in TextModeColorScheme previousScheme, in TextModeColorScheme scheme, IReadOnlyDictionary<uint, uint> colorMap, bool inverted = false, IReadOnlyDictionary<uint, uint> backgroundColorMap = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeColorScheme | previousScheme | The theme that was active before the change. |
| TextModeColorScheme | scheme | The theme that is active now. |
| IReadOnlyDictionary<uint, uint> | colorMap | The color translation table, or null to leave existing content alone. |
| bool | inverted | Whether every color is shown inverted after the change. |
| IReadOnlyDictionary<uint, uint> | backgroundColorMap | The translation table for cell backgrounds, or null to use |
Properties
BackgroundColorMap
The packed-color translation table for cell backgrounds, or null when ColorMap is null.
Declaration
public IReadOnlyDictionary<uint, uint> BackgroundColorMap { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<uint, uint> |
Remarks
Built by BuildBackgroundMap(ColorPalette, ColorPalette, Dictionary<uint, uint>), where the outgoing theme's background wins over ANSI black when the two share a color, so blank cells take the incoming theme's background. Pass it with ColorMap to Remap(CellGrid, IReadOnlyDictionary<uint, uint>, IReadOnlyDictionary<uint, uint>). The same rule as for ColorMap applies: read it synchronously and do not keep the reference.
ColorMap
Packed-color translation table from the previous theme to the current one, or null when existing content should be left alone.
Declaration
public IReadOnlyDictionary<uint, uint> ColorMap { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<uint, uint> |
Remarks
The map is built once and shared by every subscriber, because building it runs a nearest-color search per palette entry and there is no reason for each view to pay that separately. Pass it to Remap(CellGrid, IReadOnlyDictionary<uint, uint>, IReadOnlyDictionary<uint, uint>) together with BackgroundColorMap, or to RemapColors(IReadOnlyDictionary<uint, uint>).
Read it synchronously, and do not keep the reference. The dictionary behind this property is one table the theme system reuses for every switch: it is cleared and refilled by the next theme change, which can happen before a handler that stashed the reference ever looks at it again. Consume the map inside the event handler and let it go.
Inverted
Whether TextMode shows every color inverted after this change. Inverting is a display setting that changes neither Scheme nor any stored color; code that draws theme colors outside a TextMode view passes them through DisplayColor(Color).
Declaration
public bool Inverted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
PreviousScheme
The theme that was active before the change.
Declaration
public TextModeColorScheme PreviousScheme { get; }
Property Value
| Type | Description |
|---|---|
| TextModeColorScheme |
Scheme
The theme that is active now.
Declaration
public TextModeColorScheme Scheme { get; }
Property Value
| Type | Description |
|---|---|
| TextModeColorScheme |