Class ConsoleColoring
Console coloring extensions
Inheritance
Namespace: Terminaux.Base.Extensions
Assembly: Terminaux.dll
Syntax
public static class ConsoleColoring
Properties
| Edit this page View SourceAllowBackground
Whether applications are allowed to set the current background color or not
Declaration
public static bool AllowBackground { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
ConsoleSupportsTrueColor
If you are sure that the console supports true color, or if you want to change your terminal to a terminal that supports true color, change this value.
Declaration
public static bool ConsoleSupportsTrueColor { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
CurrentBackgroundColor
Current background color
Declaration
public static Color CurrentBackgroundColor { get; }
Property Value
| Type | Description |
|---|---|
| Color |
CurrentForegroundColor
Current foreground color
Declaration
public static Color CurrentForegroundColor { get; }
Property Value
| Type | Description |
|---|---|
| Color |
Methods
| Edit this page View SourceDetermineTrueColorFromUser()
Asks the user to decide whether the terminal supports true color
Declaration
public static void DetermineTrueColorFromUser()
GetGray(ColorContrastType)
Gets the gray color according to the brightness of the background color
Declaration
public static Color GetGray(ColorContrastType contrastType = ColorContrastType.Light)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorContrastType | contrastType | Contrast type |
Returns
| Type | Description |
|---|---|
| Color |
LoadBack()
Loads the background
Declaration
public static void LoadBack()
LoadBack(Color, bool)
Loads the background
Declaration
public static void LoadBack(Color ColorSequence, bool Force = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | Color sequence used to load background |
| bool | Force | Force set background even if background setting is disabled |
LoadBackDry()
Loads the background dryly
Declaration
public static void LoadBackDry()
LoadBackDry(Color, bool)
Loads the background dryly
Declaration
public static void LoadBackDry(Color ColorSequence, bool Force = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | Color sequence used to load background |
| bool | Force | Force set background even if background setting is disabled |
RenderResetBackground()
Gets a sequence that resets the background color without clearing screen
Declaration
public static string RenderResetBackground()
Returns
| Type | Description |
|---|---|
| string |
RenderResetColors()
Gets a sequence that resets the console colors without clearing screen
Declaration
public static string RenderResetColors()
Returns
| Type | Description |
|---|---|
| string |
RenderResetForeground()
Gets a sequence that resets the foreground color without clearing screen
Declaration
public static string RenderResetForeground()
Returns
| Type | Description |
|---|---|
| string |
RenderRevertBackground()
Gets a sequence that reverts the background color without clearing screen
Declaration
public static string RenderRevertBackground()
Returns
| Type | Description |
|---|---|
| string |
RenderRevertColors()
Gets a sequence that reverts the console colors without clearing screen
Declaration
public static string RenderRevertColors()
Returns
| Type | Description |
|---|---|
| string |
RenderRevertForeground()
Gets a sequence that reverts the foreground color without clearing screen
Declaration
public static string RenderRevertForeground()
Returns
| Type | Description |
|---|---|
| string |
RenderSetConsoleColor(Color)
Gets the console color setting sequence
Declaration
public static string RenderSetConsoleColor(Color ColorSequence)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
Returns
| Type | Description |
|---|---|
| string |
RenderSetConsoleColor(Color, bool)
Gets the console color setting sequence
Declaration
public static string RenderSetConsoleColor(Color ColorSequence, bool Background)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
Returns
| Type | Description |
|---|---|
| string |
RenderSetConsoleColor(Color, bool, bool, bool)
Gets the console color setting sequence
Declaration
public static string RenderSetConsoleColor(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
| bool | ForceSet | Force set background even if background setting is disabled or if the current background color doesn't match the provided color |
| bool | canSet | Can the console set this color? |
Returns
| Type | Description |
|---|---|
| string |
ResetBackground()
Resets the background color without clearing screen
Declaration
public static void ResetBackground()
ResetColors()
Resets the console colors without clearing screen
Declaration
public static void ResetColors()
ResetForeground()
Resets the foreground color without clearing screen
Declaration
public static void ResetForeground()
RevertBackground()
Reverts the background color without clearing screen
Declaration
public static void RevertBackground()
RevertColors()
Reverts the console colors without clearing screen
Declaration
public static void RevertColors()
RevertForeground()
Reverts the foreground color without clearing screen
Declaration
public static void RevertForeground()
SetConsoleColor(Color, bool)
Sets the console color
Declaration
public static void SetConsoleColor(Color ColorSequence, bool Background)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
SetConsoleColor(Color, bool, bool, bool)
Sets the console color
Declaration
public static void SetConsoleColor(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
| bool | ForceSet | Force set background even if background setting is disabled or if the current background color doesn't match the provided color |
| bool | canSet | Can the console set this color? |
SetConsoleColorDry(Color, bool)
Sets the console color dryly
Declaration
public static void SetConsoleColorDry(Color ColorSequence, bool Background)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
SetConsoleColorDry(Color, bool, bool, bool)
Sets the console color dryly
Declaration
public static void SetConsoleColorDry(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
| bool | ForceSet | Force set background even if background setting is disabled or if the current background color doesn't match the provided color |
| bool | canSet | Can the console set this color? |
TrySetConsoleColor(Color, bool, bool, bool)
Sets the console color
Declaration
public static bool TrySetConsoleColor(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
| bool | ForceSet | Force set background even if background setting is disabled or if the current background color doesn't match the provided color |
| bool | canSet | Can the console set this color? |
Returns
| Type | Description |
|---|---|
| bool | True if successful; False if unsuccessful |
TrySetConsoleColorDry(Color, bool, bool, bool)
Sets the console color dryly
Declaration
public static bool TrySetConsoleColorDry(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | ColorSequence | The color instance |
| bool | Background | Whether to set background or not |
| bool | ForceSet | Force set background even if background setting is disabled or if the current background color doesn't match the provided color |
| bool | canSet | Can the console set this color? |
Returns
| Type | Description |
|---|---|
| bool | True if successful; False if unsuccessful |