Skip to content

Commit

Permalink
add - Added allow/disallow background colors
Browse files Browse the repository at this point in the history
---

We've added a new config entry that controls whether foreground and background colors are allowed to be set.

---

Type: add
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 20, 2024
1 parent f151cf5 commit 40a78b1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions public/Nitrocid/ConsoleBase/Colors/KernelColorTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public static class KernelColorTools
internal static Color accentForegroundColor = GetColor(KernelColorType.Warning);
internal static Color accentBackgroundColor = GetColor(KernelColorType.Background);

// Variables to allow/disallow background/foreground color
internal static bool allowForeground = true;
internal static bool allowBackground = true;

/// <summary>
/// Enables color blindness
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions public/Nitrocid/Kernel/Configuration/Instances/KernelMainConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,30 @@ public bool UseConsoleColorPalette
set => ColorTools.GlobalSettings.UseTerminalPalette = value;
}
/// <summary>
/// Whether to allow foreground color
/// </summary>
public bool AllowForegroundColor
{
get => KernelColorTools.allowForeground;
set
{
KernelColorTools.allowForeground = value;
ColorTools.AllowForeground = KernelColorTools.allowForeground;
}
}
/// <summary>
/// Whether to allow background color
/// </summary>
public bool AllowBackgroundColor
{
get => KernelColorTools.allowBackground;
set
{
KernelColorTools.allowBackground = value;
ColorTools.AllowBackground = KernelColorTools.allowBackground;
}
}
/// <summary>
/// User Name Shell Color
/// </summary>
public string UserNameShellColor
Expand Down
4 changes: 4 additions & 0 deletions public/Nitrocid/Kernel/Starting/KernelInitializers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ internal static void InitializeCritical()
// Check for terminal
ConsoleChecker.CheckConsole();

// Allow fore/background colors
ColorTools.AllowForeground = true;
ColorTools.AllowBackground = true;

// Initialize crucial things
if (!KernelPlatform.IsOnUnix())
{
Expand Down
2 changes: 1 addition & 1 deletion public/Nitrocid/Nitrocid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<NitrocidModAPIVersionMajor>3.0.25</NitrocidModAPIVersionMajor>

<!-- Increment NitrocidModAPIVersionChangeset every time there is a breaking change or an API addition in the N-KS API. -->
<NitrocidModAPIVersionChangeset>431</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>432</NitrocidModAPIVersionChangeset>

<!-- To be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
12 changes: 12 additions & 0 deletions public/Nitrocid/Resources/Settings/SettingsEntries.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@
"Variable": "UseConsoleColorPalette",
"Description": "When this is set to true, the color palette defined by the terminal is used."
},
{
"Name": "Allow foreground color",
"Type": "SBoolean",
"Variable": "AllowForegroundColor",
"Description": "When this is set to true, the current foreground color is honored. Else, it uses your terminal's default colors."
},
{
"Name": "Allow background color",
"Type": "SBoolean",
"Variable": "AllowBackgroundColor",
"Description": "When this is set to true, the current background color is honored. Else, it uses your terminal's default colors."
},
{
"Name": "User Name Shell Color",
"Type": "SColor",
Expand Down

0 comments on commit 40a78b1

Please sign in to comment.