From d982cd287128fb1be692df15fa22e0776c56bf58 Mon Sep 17 00:00:00 2001 From: Aptivi CEO Date: Thu, 26 Dec 2024 15:38:35 +0300 Subject: [PATCH] rem - brk|doc - Removed fancy console writers --- To follow Terminaux's deprecation of the old method-based writers, we've decided to remove fancy console writers, except those that are really important. --- Type: rem Breaking: True Doc Required: True Backport Required: False Part: 1/1 --- Directory.Build.props | 2 +- .../Commands/Element.cs | 35 +- .../Git/Commands/Diff.cs | 5 +- .../templates/KSMod/ModName.cs | 2 +- .../ConsoleBase/Writers/TextDynamicWriters.cs | 272 ---- .../ConsoleBase/Writers/TextFancyWriters.cs | 1201 ----------------- .../ConsoleBase/Writers/TextMiscWriters.cs | 275 ---- .../ConsoleBase/Writers/TextWriters.cs | 113 +- .../Debugging/Testing/Facades/PrintFiglet.cs | 41 - .../Testing/Facades/PrintFigletCentered.cs | 41 - .../Testing/Facades/PrintFigletCenteredF.cs | 41 - .../Facades/PrintFigletCenteredPositional.cs | 41 - .../Facades/PrintFigletCenteredPositionalF.cs | 41 - .../Debugging/Testing/Facades/PrintFigletF.cs | 41 - .../Testing/Facades/PrintSepColor.cs | 37 - .../Testing/Facades/PrintSepColorF.cs | 37 - .../Debugging/Testing/TestInteractive.cs | 8 - .../Kernel/Starting/KernelInitializers.cs | 3 +- .../Kernel/Starting/KernelStageTools.cs | 3 +- .../Kernel/Starting/WelcomeMessage.cs | 5 +- .../ShellBase/Commands/CommandExecutor.cs | 2 +- .../Shell/ShellBase/Scripting/UESHParse.cs | 21 +- .../Shell/Shells/Admin/Commands/UserInfo.cs | 7 +- .../Shell/Shells/UESH/Commands/DriverMan.cs | 3 +- .../Shells/UESH/Commands/GetAllExtHandlers.cs | 3 +- .../Shells/UESH/Commands/GetConfigValue.cs | 9 +- .../UESH/Commands/GetDefaultExtHandlers.cs | 3 +- .../Shells/UESH/Commands/GetExtHandlers.cs | 3 +- .../Shells/UESH/Commands/LsConfigValues.cs | 9 +- .../Shells/UESH/Commands/LsExtHandlers.cs | 3 +- .../Shells/UESH/Commands/SetConfigValue.cs | 11 +- .../Shell/Shells/UESH/Commands/SysInfo.cs | 11 +- 32 files changed, 156 insertions(+), 2173 deletions(-) delete mode 100644 public/Nitrocid/ConsoleBase/Writers/TextDynamicWriters.cs delete mode 100644 public/Nitrocid/ConsoleBase/Writers/TextFancyWriters.cs delete mode 100644 public/Nitrocid/ConsoleBase/Writers/TextMiscWriters.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFiglet.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCentered.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredF.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositional.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositionalF.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletF.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColor.cs delete mode 100644 public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColorF.cs diff --git a/Directory.Build.props b/Directory.Build.props index c578c7253..02a93a93c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,7 +23,7 @@ changes! --> 3.0.27 - 17 + 18 $(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset) diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.Chemistry/Commands/Element.cs b/public/Nitrocid.Addons/Nitrocid.Extras.Chemistry/Commands/Element.cs index c425600bb..3cb69ea7c 100644 --- a/public/Nitrocid.Addons/Nitrocid.Extras.Chemistry/Commands/Element.cs +++ b/public/Nitrocid.Addons/Nitrocid.Extras.Chemistry/Commands/Element.cs @@ -23,6 +23,8 @@ using Nitrocid.ConsoleBase.Writers; using Nitrocid.Languages; using Nitrocid.Shell.ShellBase.Commands; +using Terminaux.Writer.ConsoleWriters; +using Terminaux.Writer.CyclicWriters; namespace Nitrocid.Extras.Chemistry.Commands { @@ -54,19 +56,30 @@ public override int Execute(CommandParameters parameters, ref string variableVal } // Print information - TextWriters.WriteListEntry(Translate.DoTranslation("Name"), substance.Name, KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Atomic number"), $"{substance.AtomicNumber}", KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Atomic mass"), $"{substance.AtomicMass}", KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Symbol"), substance.Symbol, KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Summary"), substance.Summary, KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Phase"), $"{substance.Phase}", KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Position in the periodic table"), $"{substance.Period}, {substance.Group}", KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Position in coordinates"), $"{substance.PosX} (w: {substance.WPosX}), {substance.PosY} (w: {substance.WPosY})", KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Discoverer"), substance.Discoverer, KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Named by"), substance.NamedBy, KernelColorType.ListEntry, KernelColorType.ListValue); - TextWriters.WriteListEntry(Translate.DoTranslation("Electron configuration"), substance.ElectronConfiguration, KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Name"), substance.Name, KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Atomic number"), $"{substance.AtomicNumber}", KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Atomic mass"), $"{substance.AtomicMass}", KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Symbol"), substance.Symbol, KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Summary"), substance.Summary, KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Phase"), $"{substance.Phase}", KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Position in the periodic table"), $"{substance.Period}, {substance.Group}", KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Position in coordinates"), $"{substance.PosX} (w: {substance.WPosX}), {substance.PosY} (w: {substance.WPosY})", KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Discoverer"), substance.Discoverer, KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Named by"), substance.NamedBy, KernelColorType.ListEntry, KernelColorType.ListValue); + WriteListEntry(Translate.DoTranslation("Electron configuration"), substance.ElectronConfiguration, KernelColorType.ListEntry, KernelColorType.ListValue); return 0; } + private void WriteListEntry(string entry, string value, KernelColorType entryColor, KernelColorType valueColor) + { + var listEntry = new ListEntry() + { + Entry = entry, + Value = value, + KeyColor = KernelColorTools.GetColor(entryColor), + ValueColor = KernelColorTools.GetColor(valueColor), + }; + TextWriterRaw.WritePlain(listEntry.Render()); + } } } diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.GitShell/Git/Commands/Diff.cs b/public/Nitrocid.Addons/Nitrocid.Extras.GitShell/Git/Commands/Diff.cs index 6e06c15ba..767ddf6ba 100644 --- a/public/Nitrocid.Addons/Nitrocid.Extras.GitShell/Git/Commands/Diff.cs +++ b/public/Nitrocid.Addons/Nitrocid.Extras.GitShell/Git/Commands/Diff.cs @@ -24,6 +24,7 @@ using Nitrocid.ConsoleBase.Colors; using Nitrocid.Languages; using Terminaux.Writer.ConsoleWriters; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Extras.GitShell.Git.Commands { @@ -66,7 +67,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal var renamed = tree.Renamed; // List the general changes - TextFancyWriters.WriteSeparator(Translate.DoTranslation("General changes in") + $" {GitShellCommon.RepoName}:", KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("General changes in") + $" {GitShellCommon.RepoName}:", KernelColorTools.GetColor(KernelColorType.ListTitle)); foreach (var change in modified) TextWriters.Write($"[M] * {change.Path}", KernelColorType.ListEntry); foreach (var change in added) @@ -82,7 +83,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (doPatch) { - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Content changes in") + $" {GitShellCommon.RepoName}:", KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Content changes in") + $" {GitShellCommon.RepoName}:", KernelColorTools.GetColor(KernelColorType.ListTitle)); TextWriterColor.Write(patch.Content); } diff --git a/public/Nitrocid.Templates/templates/KSMod/ModName.cs b/public/Nitrocid.Templates/templates/KSMod/ModName.cs index f0fbe5e08..645c8a403 100644 --- a/public/Nitrocid.Templates/templates/KSMod/ModName.cs +++ b/public/Nitrocid.Templates/templates/KSMod/ModName.cs @@ -10,7 +10,7 @@ public class ModName : IMod public string Name { get; set; } = "My Mod"; public string Version { get; set; } = "1.0.0"; - public Version MinimumSupportedApiVersion => new(3, 0, 27, 17); + public Version MinimumSupportedApiVersion => new(3, 0, 27, 18); public ReadOnlyDictionary PubliclyAvailableFunctions => null; diff --git a/public/Nitrocid/ConsoleBase/Writers/TextDynamicWriters.cs b/public/Nitrocid/ConsoleBase/Writers/TextDynamicWriters.cs deleted file mode 100644 index fe21f07a2..000000000 --- a/public/Nitrocid/ConsoleBase/Writers/TextDynamicWriters.cs +++ /dev/null @@ -1,272 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.Drivers; -using Nitrocid.Drivers.Console; -using Nitrocid.Kernel.Debugging; -using Nitrocid.Languages; -using System; -using System.Threading; -using Terminaux.Writer.ConsoleWriters; - -namespace Nitrocid.ConsoleBase.Writers -{ - /// - /// Dynamic writers with kernel color support - /// - public static class TextDynamicWriters - { - /// - /// Outputs the text into the terminal prompt slowly with color support. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Time in milliseconds to delay writing - /// A type of colors that will be changed. - /// Variables to format the message before it's written. - public static void WriteSlowly(string msg, bool Line, double MsEachLetter, KernelColorType colorType, params object[] vars) - { - lock (BaseConsoleDriver.WriteLock) - { - try - { - // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. - KernelColorTools.SetConsoleColorDry(colorType); - - // Write text slowly - TextWriterSlowColor.WriteSlowlyPlain(msg, Line, MsEachLetter, vars); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - } - - /// - /// Outputs the text into the terminal prompt slowly with color support. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Time in milliseconds to delay writing - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Variables to format the message before it's written. - public static void WriteSlowly(string msg, bool Line, double MsEachLetter, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] vars) - { - lock (BaseConsoleDriver.WriteLock) - { - try - { - // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. - KernelColorTools.SetConsoleColorDry(colorTypeForeground); - KernelColorTools.SetConsoleColorDry(colorTypeBackground, true); - - // Write text slowly - TextWriterSlowColor.WriteSlowlyPlain(msg, Line, MsEachLetter, vars); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - } - - /// - /// Outputs the text into the terminal prompt with location support, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Column number in console - /// Row number in console - /// Time in milliseconds to delay writing - /// A type of colors that will be changed. - /// Variables to format the message before it's written. - public static void WriteWhereSlowly(string msg, bool Line, int Left, int Top, double MsEachLetter, KernelColorType colorType, params object[] vars) => - WriteWhereSlowly(msg, Line, Left, Top, MsEachLetter, false, 0, colorType, vars); - - /// - /// Outputs the text into the terminal prompt with location support, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Column number in console - /// Row number in console - /// Time in milliseconds to delay writing - /// Whether or not to return to old position - /// A type of colors that will be changed. - /// Variables to format the message before it's written. - public static void WriteWhereSlowly(string msg, bool Line, int Left, int Top, double MsEachLetter, bool Return, KernelColorType colorType, params object[] vars) => - WriteWhereSlowly(msg, Line, Left, Top, MsEachLetter, Return, 0, colorType, vars); - - /// - /// Outputs the text into the terminal prompt with location support, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Column number in console - /// Row number in console - /// Time in milliseconds to delay writing - /// Whether or not to return to old position - /// The right margin - /// A type of colors that will be changed. - /// Variables to format the message before it's written. - public static void WriteWhereSlowly(string msg, bool Line, int Left, int Top, double MsEachLetter, bool Return, int RightMargin, KernelColorType colorType, params object[] vars) - { - lock (BaseConsoleDriver.WriteLock) - { - try - { - // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. - KernelColorTools.SetConsoleColorDry(colorType); - - // Write text in another place slowly - TextWriterWhereSlowColor.WriteWhereSlowly(msg, Line, Left, Top, MsEachLetter, Return, RightMargin, vars); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - } - - /// - /// Outputs the text into the terminal prompt with location support, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Column number in console - /// Row number in console - /// Time in milliseconds to delay writing - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Variables to format the message before it's written. - public static void WriteWhereSlowly(string msg, bool Line, int Left, int Top, double MsEachLetter, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] vars) => - WriteWhereSlowly(msg, Line, Left, Top, MsEachLetter, false, 0, colorTypeForeground, colorTypeBackground, vars); - - /// - /// Outputs the text into the terminal prompt with location support, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Column number in console - /// Row number in console - /// Time in milliseconds to delay writing - /// Whether or not to return to old position - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Variables to format the message before it's written. - public static void WriteWhereSlowly(string msg, bool Line, int Left, int Top, double MsEachLetter, bool Return, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] vars) => - WriteWhereSlowly(msg, Line, Left, Top, MsEachLetter, Return, 0, colorTypeForeground, colorTypeBackground, vars); - - /// - /// Outputs the text into the terminal prompt with location support, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// Column number in console - /// Row number in console - /// Time in milliseconds to delay writing - /// Whether or not to return to old position - /// The right margin - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Variables to format the message before it's written. - public static void WriteWhereSlowly(string msg, bool Line, int Left, int Top, double MsEachLetter, bool Return, int RightMargin, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] vars) - { - lock (BaseConsoleDriver.WriteLock) - { - try - { - // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. - KernelColorTools.SetConsoleColorDry(colorTypeForeground); - KernelColorTools.SetConsoleColorDry(colorTypeBackground, true); - - // Write text in another place slowly - TextWriterWhereSlowColor.WriteWhereSlowlyPlain(msg, Line, Left, Top, MsEachLetter, Return, RightMargin, vars); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - } - - /// - /// Outputs the text into the terminal prompt, wraps the long terminal output if needed, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// A type of colors that will be changed. - /// Variables to format the message before it's written. - public static void WriteWrapped(string Text, bool Line, KernelColorType colorType, params object[] vars) - { - lock (BaseConsoleDriver.WriteLock) - { - try - { - // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. - KernelColorTools.SetConsoleColorDry(colorType); - - // Write wrapped output - DriverHandler.CurrentConsoleDriverLocal.WriteWrappedPlain(Text, Line, vars); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - } - - /// - /// Outputs the text into the terminal prompt, wraps the long terminal output if needed, and sets colors as needed. - /// - /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... - /// Whether to print a new line or not - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Variables to format the message before it's written. - public static void WriteWrapped(string Text, bool Line, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] vars) - { - lock (BaseConsoleDriver.WriteLock) - { - try - { - // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. - KernelColorTools.SetConsoleColorDry(colorTypeForeground); - KernelColorTools.SetConsoleColorDry(colorTypeBackground, true); - - // Write wrapped output - DriverHandler.CurrentConsoleDriverLocal.WriteWrappedPlain(Text, Line, vars); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - } - } -} diff --git a/public/Nitrocid/ConsoleBase/Writers/TextFancyWriters.cs b/public/Nitrocid/ConsoleBase/Writers/TextFancyWriters.cs deleted file mode 100644 index 1bf1607eb..000000000 --- a/public/Nitrocid/ConsoleBase/Writers/TextFancyWriters.cs +++ /dev/null @@ -1,1201 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet.Utilities.Lines; -using Nitrocid.ConsoleBase.Colors; -using Terminaux.Writer.ConsoleWriters; -using Terminaux.Writer.FancyWriters; -using Terminaux.Writer.CyclicWriters.Renderer.Tools; -using Nitrocid.Kernel.Debugging; -using Nitrocid.Languages; -using System; -using System.Collections.Generic; -using System.Threading; -using Terminaux.Base; -using Terminaux.Writer.CyclicWriters; -using Textify.General; -using Terminaux.Writer.CyclicWriters.Renderer; -using Terminaux.Colors.Transformation; - -namespace Nitrocid.ConsoleBase.Writers -{ - /// - /// Fancy text writer wrapper for writing with () - /// - public static class TextFancyWriters - { - /// - /// Writes the border plainly - /// - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border color from Nitrocid KS's - public static void WriteBorder(int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxBorderColor) => - WriteBorder(Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxBorderColor, KernelColorType.Background); - - /// - /// Writes the border plainly - /// - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border color from Nitrocid KS's - /// Border background color from Nitrocid KS's - public static void WriteBorder(int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxBorderColor, KernelColorType BackgroundColor) => - WriteBorder(Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxBorderColor, BackgroundColor); - - /// - /// Writes the border plainly - /// - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// Border color from Nitrocid KS's - public static void WriteBorder(int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType BoxBorderColor) => - WriteBorder(Left, Top, InteriorWidth, InteriorHeight, settings, BoxBorderColor, KernelColorType.Background); - - /// - /// Writes the border plainly - /// - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// Border color from Nitrocid KS's - /// Border background color from Nitrocid KS's - public static void WriteBorder(int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType BoxBorderColor, KernelColorType BackgroundColor) - { - try - { - var border = new Border() - { - Left = Left, - Top = Top, - InteriorWidth = InteriorWidth, - InteriorHeight = InteriorHeight, - Settings = settings, - Color = KernelColorTools.GetColor(BoxBorderColor), - BackgroundColor = KernelColorTools.GetColor(BackgroundColor) - }; - TextWriterRaw.WriteRaw(border.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the border plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border color from Nitrocid KS's - public static void WriteBorderText(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxBorderColor, params object[] vars) => - WriteBorderText(text, Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxBorderColor, KernelColorType.Background, vars); - - /// - /// Writes the border plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border color from Nitrocid KS's - /// Border background color from Nitrocid KS's - public static void WriteBorderText(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxBorderColor, KernelColorType BackgroundColor, params object[] vars) => - WriteBorderText(text, Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxBorderColor, BackgroundColor, vars); - - /// - /// Writes the border plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// Border color from Nitrocid KS's - public static void WriteBorderText(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType BoxBorderColor, params object[] vars) => - WriteBorderText(text, Left, Top, InteriorWidth, InteriorHeight, settings, BoxBorderColor, KernelColorType.Background, vars); - - /// - /// Writes the border plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the border horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the border vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// Border color from Nitrocid KS's - /// Border background color from Nitrocid KS's - public static void WriteBorderText(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType BoxBorderColor, KernelColorType BackgroundColor, params object[] vars) - { - try - { - var border = new Border() - { - Text = text.FormatString(vars), - Left = Left, - Top = Top, - InteriorWidth = InteriorWidth, - InteriorHeight = InteriorHeight, - Settings = settings, - Color = KernelColorTools.GetColor(BoxBorderColor), - TextColor = KernelColorTools.GetColor(BoxBorderColor), - BackgroundColor = KernelColorTools.GetColor(BackgroundColor) - }; - TextWriterRaw.WriteRaw(border.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the box plainly - /// - /// Where to place the box horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Box color from Nitrocid KS's - public static void WriteBox(int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxColorType) - { - try - { - var box = new Box() - { - Left = Left, - Top = Top, - InteriorWidth = InteriorWidth, - InteriorHeight = InteriorHeight, - Color = KernelColorTools.GetColor(BoxColorType), - }; - TextWriterRaw.WriteRaw(box.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the box frame plainly - /// - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// BoxFrame color from Nitrocid KS's - public static void WriteBoxFrame(int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxFrameColor) => - WriteBoxFrame(Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxFrameColor, KernelColorType.Background); - - /// - /// Writes the box frame plainly - /// - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// BoxFrame color from Nitrocid KS's - /// BoxFrame background color from Nitrocid KS's - public static void WriteBoxFrame(int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxFrameColor, KernelColorType BackgroundColor) => - WriteBoxFrame(Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxFrameColor, BackgroundColor); - - /// - /// Writes the box frame plainly - /// - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// BoxFrame color from Nitrocid KS's - public static void WriteBoxFrame(int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType BoxFrameColor) => - WriteBoxFrame(Left, Top, InteriorWidth, InteriorHeight, settings, BoxFrameColor, KernelColorType.Background); - - /// - /// Writes the box frame plainly - /// - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// BoxFrame color from Nitrocid KS's - /// BoxFrame background color from Nitrocid KS's - public static void WriteBoxFrame(int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType FrameColor, KernelColorType BackgroundColor) - { - try - { - var boxFrame = new BoxFrame() - { - Left = Left, - Top = Top, - InteriorWidth = InteriorWidth, - InteriorHeight = InteriorHeight, - Settings = settings, - FrameColor = KernelColorTools.GetColor(FrameColor), - BackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(boxFrame.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the box frame plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// BoxFrame color from Nitrocid KS's - public static void WriteBoxFrame(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxFrameColor, params object[] vars) => - WriteBoxFrame(text, Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxFrameColor, KernelColorType.Background, vars); - - /// - /// Writes the box frame plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// BoxFrame color from Nitrocid KS's - /// BoxFrame background color from Nitrocid KS's - public static void WriteBoxFrame(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, KernelColorType BoxFrameColor, KernelColorType BackgroundColor, params object[] vars) => - WriteBoxFrame(text, Left, Top, InteriorWidth, InteriorHeight, BorderSettings.GlobalSettings, BoxFrameColor, BackgroundColor, vars); - - /// - /// Writes the box frame plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// BoxFrame color from Nitrocid KS's - public static void WriteBoxFrame(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType BoxFrameColor, params object[] vars) => - WriteBoxFrame(text, Left, Top, InteriorWidth, InteriorHeight, settings, BoxFrameColor, KernelColorType.Background, vars); - - /// - /// Writes the box frame plainly - /// - /// Text to be written. - /// Variables to format the message before it's written. - /// Where to place the box frame horizontally? Please note that this value comes from the upper left corner, which is an exterior position. - /// Where to place the box frame vertically? Please note that this value comes from the upper left corner, which is an exterior position. - /// The width of the interior window, excluding the two console columns for left and right frames - /// The height of the interior window, excluding the two console columns for upper and lower frames - /// Border settings - /// BoxFrame color from Nitrocid KS's - /// BoxFrame background color from Nitrocid KS's - public static void WriteBoxFrame(string text, int Left, int Top, int InteriorWidth, int InteriorHeight, BorderSettings settings, KernelColorType FrameColor, KernelColorType BackgroundColor, params object[] vars) - { - try - { - var boxFrame = new BoxFrame() - { - Text = text.FormatString(vars), - Left = Left, - Top = Top, - InteriorWidth = InteriorWidth, - InteriorHeight = InteriorHeight, - Settings = settings, - FrameColor = KernelColorTools.GetColor(FrameColor), - TitleColor = KernelColorTools.GetColor(FrameColor), - BackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(boxFrame.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Draw a centered figlet with text - /// - /// Top position to write centered figlet text to - /// Figlet font to use in the text. - /// Text to be written. If nothing, the entire line is filled with the centered figlet. - /// A type of colors that will be changed. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteCenteredFiglet(int top, FigletFont FigletFont, string Text, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var figlet = new AlignedFigletText(FigletFont) - { - Top = top, - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(figlet.Render()); - } - - /// - /// Draw a centered figlet with text - /// - /// Top position to write centered figlet text to - /// Figlet font to use in the text. - /// Text to be written. If nothing, the entire line is filled with the centered figlet. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteCenteredFiglet(int top, FigletFont FigletFont, string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var figlet = new AlignedFigletText(FigletFont) - { - Top = top, - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(figlet.Render()); - } - - /// - /// Draw a centered figlet with text - /// - /// Figlet font to use in the text. - /// Text to be written. If nothing, the entire line is filled with the centered figlet. - /// A type of colors that will be changed. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteCenteredFiglet(FigletFont FigletFont, string Text, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var figlet = new AlignedFigletText(FigletFont) - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(figlet.Render()); - } - - /// - /// Draw a centered figlet with text - /// - /// Figlet font to use in the text. - /// Text to be written. If nothing, the entire line is filled with the centered figlet. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteCenteredFiglet(FigletFont FigletFont, string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var figlet = new AlignedFigletText(FigletFont) - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(figlet.Render()); - } - - /// - /// Draws a centered text - /// - /// Top position to write centered text to - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCentered(int top, string Text, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Top = top, - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text - /// - /// Top position to write centered text to - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCentered(int top, string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Top = top, - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text - /// - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCentered(string Text, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text - /// - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCentered(string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text (just the first line) - /// - /// Top position to write centered text to - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCenteredOneLine(int top, string Text, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Top = top, - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - OneLine = true, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text (just the first line) - /// - /// Top position to write centered text to - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCenteredOneLine(int top, string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Top = top, - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - OneLine = true, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text (just the first line) - /// - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCenteredOneLine(string Text, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - OneLine = true, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Draws a centered text (just the first line) - /// - /// Text to be written. If nothing, the entire line is filled with the centered. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// The left margin - /// The right margin - /// Variables to format the message before it's written. - public static void WriteCenteredOneLine(string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - var text = new AlignedText() - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - OneLine = true, - }; - TextWriterRaw.WriteRaw(text.Render()); - } - - /// - /// Writes the figlet text - /// - /// Text to be written. If nothing, the entire line is filled with the separator. - /// Figlet font to use in the text. - /// A type of colors that will be changed. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteFiglet(string Text, FigletFont FigletFont, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - try - { - var figlet = new FigletText(FigletFont) - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(figlet.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the figlet text - /// - /// Text to be written. If nothing, the entire line is filled with the separator. - /// Figlet font to use in the text. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteFiglet(string Text, FigletFont FigletFont, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - try - { - var figlet = new FigletText(FigletFont) - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(figlet.Render()); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the figlet text with position support - /// - /// Text to be written. If nothing, the entire line is filled with the separator. - /// Column number in console - /// Row number in console - /// Figlet font to use in the text. - /// A type of colors that will be changed. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteFigletWhere(string Text, int Left, int Top, FigletFont FigletFont, KernelColorType ColTypes, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - try - { - var figlet = new FigletText(FigletFont) - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(ColTypes), - BackgroundColor = KernelColorTools.GetColor(KernelColorType.Background), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(figlet, new(Left, Top))); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the figlet text with position support - /// - /// Text to be written. If nothing, the entire line is filled with the separator. - /// Column number in console - /// Row number in console - /// Figlet font to use in the text. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Left margin - /// Right margin - /// Variables to format the message before it's written. - public static void WriteFigletWhere(string Text, int Left, int Top, FigletFont FigletFont, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, int leftMargin = 0, int rightMargin = 0, params object[] Vars) - { - try - { - var figlet = new FigletText(FigletFont) - { - Text = Text.FormatString(Vars), - ForegroundColor = KernelColorTools.GetColor(colorTypeForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - LeftMargin = leftMargin, - RightMargin = rightMargin, - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(figlet, new(Left, Top))); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the PowerLine text - /// - /// List of PowerLine segments - /// A type of colors that will be changed at the end of the transition - /// Write new line after writing the segments - public static void WritePowerLine(List Segments, KernelColorType EndingColor, bool Line = false) - { - var powerLine = new PowerLine() - { - EndingColor = KernelColorTools.GetColor(EndingColor), - Segments = Segments - }; - TextWriterRaw.WriteRaw(powerLine.Render()); - if (Line) - TextWriterRaw.Write(); - } - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - public static void WriteProgress(double Progress, int Left, int Top, KernelColorType ProgressColor) => - WriteProgress(Progress, Left, Top, ConsoleWrapper.WindowWidth - 10, ProgressColor, KernelColorType.Background); - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - /// Progress bar width - public static void WriteProgress(double Progress, int Left, int Top, int width, KernelColorType ProgressColor) => - WriteProgress(Progress, Left, Top, width, ProgressColor, KernelColorType.Background); - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - /// The progress bar background color - public static void WriteProgress(double Progress, int Left, int Top, KernelColorType ProgressColor, KernelColorType BackgroundColor) => - WriteProgress(Progress, Left, Top, ConsoleWrapper.WindowWidth - 10, ProgressColor, BackgroundColor); - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - /// The progress bar background color - /// Progress bar width - public static void WriteProgress(double Progress, int Left, int Top, int width, KernelColorType ProgressColor, KernelColorType BackgroundColor) - { - try - { - var progress = new ProgressBarNoText((int)Progress, 100) - { - LeftMargin = ConsoleWrapper.WindowWidth - width, - ProgressActiveForegroundColor = KernelColorTools.GetColor(ProgressColor), - ProgressForegroundColor = TransformationTools.GetDarkBackground(KernelColorTools.GetColor(ProgressColor)), - ProgressBackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(progress, new(Left, Top))); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - public static void WriteVerticalProgress(double Progress, int Left, int Top, KernelColorType ProgressColor) => - WriteVerticalProgress(Progress, Left, Top, ConsoleWrapper.WindowHeight - 2, ProgressColor, KernelColorType.Background); - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - /// Progress bar height - public static void WriteVerticalProgress(double Progress, int Left, int Top, int height, KernelColorType ProgressColor) => - WriteVerticalProgress(Progress, Left, Top, height, ProgressColor, KernelColorType.Background); - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - /// The progress bar background color - public static void WriteVerticalProgress(double Progress, int Left, int Top, KernelColorType ProgressColor, KernelColorType BackgroundColor) => - WriteVerticalProgress(Progress, Left, Top, ConsoleWrapper.WindowHeight - 2, ProgressColor, BackgroundColor); - - /// - /// Writes the progress bar - /// - /// The progress percentage - /// The progress position from the upper left corner - /// The progress position from the top - /// The progress bar color - /// The progress bar background color - /// Progress bar height - public static void WriteVerticalProgress(double Progress, int Left, int Top, int height, KernelColorType ProgressColor, KernelColorType BackgroundColor) - { - try - { - var progress = new SimpleProgress((int)Progress, 100) - { - Vertical = true, - Height = height, - ProgressActiveForegroundColor = KernelColorTools.GetColor(ProgressColor), - ProgressForegroundColor = TransformationTools.GetDarkBackground(KernelColorTools.GetColor(ProgressColor)), - ProgressBackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(progress, new(Left, Top))); - } - catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) - { - DebugWriter.WriteDebugStackTrace(ex); - DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); - } - } - - /// - /// Draw a separator with text - /// - /// Text to be written. If nothing, the entire line is filled with the separator. - /// A type of colors that will be changed. - /// Variables to format the message before it's written. - public static void WriteSeparator(string Text, KernelColorType ColTypes, params object[] Vars) => - SeparatorWriterColor.WriteSeparatorColorBack(Text, KernelColorTools.GetColor(ColTypes), KernelColorTools.GetColor(KernelColorType.Background), true, Vars); - - /// - /// Draw a separator with text - /// - /// Text to be written. If nothing, the entire line is filled with the separator. - /// A type of colors that will be changed for the foreground color. - /// A type of colors that will be changed for the background color. - /// Variables to format the message before it's written. - public static void WriteSeparator(string Text, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] Vars) => - SeparatorWriterColor.WriteSeparatorColorBack(Text, KernelColorTools.GetColor(colorTypeForeground), KernelColorTools.GetColor(colorTypeBackground), true, Vars); - - /// - /// Draw a table with text - /// - /// Rows to insert to the table. - /// Left position of the upper-left corner - /// Top position of the upper-left corner - /// Table interior width - /// Table interior height - /// Whether to enable the header or no - /// Specifies the table border settings - /// Specifies the cell options - /// A type of colors that will be changed for the separator foreground color. - /// A type of colors that will be changed for the header foreground color. - /// A type of colors that will be changed for the value foreground color. - /// A type of colors that will be changed for the background color. - public static void WriteTable(string[,] Rows, int left, int top, int width, int height, bool enableHeader, KernelColorType colorTypeSeparatorForeground, KernelColorType colorTypeHeaderForeground, KernelColorType colorTypeValueForeground, KernelColorType colorTypeBackground, List? CellOptions = null, BorderSettings? borderSettings = null) - { - var table = new Table() - { - Rows = Rows, - Left = left, - Top = top, - InteriorWidth = width, - InteriorHeight = height, - Header = enableHeader, - SeparatorColor = KernelColorTools.GetColor(colorTypeSeparatorForeground), - HeaderColor = KernelColorTools.GetColor(colorTypeHeaderForeground), - ValueColor = KernelColorTools.GetColor(colorTypeValueForeground), - BackgroundColor = KernelColorTools.GetColor(colorTypeBackground), - Settings = CellOptions ?? [], - BorderSettings = borderSettings ?? new(), - }; - TextWriterRaw.WriteRaw(table.Render()); - } - - /// - /// Writes the slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - public static void WriteSliderAbsolute(int currPos, int maxPos, int Left, int Top, KernelColorType sliderColor, int minPos = 0) => - WriteSliderAbsolute(currPos, maxPos, Left, Top, ConsoleWrapper.WindowWidth - 10, sliderColor, KernelColorType.Separator, minPos); - - /// - /// Writes the slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// Slider width - public static void WriteSliderAbsolute(int currPos, int maxPos, int Left, int Top, int width, KernelColorType sliderColor, int minPos = 0) => - WriteSliderAbsolute(currPos, maxPos, Left, Top, width, sliderColor, KernelColorType.Separator, minPos); - - /// - /// Writes the slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - public static void WriteSliderAbsolute(int currPos, int maxPos, int Left, int Top, KernelColorType sliderColor, KernelColorType BackgroundColor, int minPos = 0) => - WriteSliderAbsolute(currPos, maxPos, Left, Top, ConsoleWrapper.WindowWidth - 10, sliderColor, BackgroundColor, minPos); - - /// - /// Writes the slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - /// Slider width - public static void WriteSliderAbsolute(int currPos, int maxPos, int Left, int Top, int width, KernelColorType sliderColor, KernelColorType BackgroundColor, int minPos = 0) - { - var slider = new Slider(width * ((currPos - minPos) / (maxPos - minPos)), minPos, width + 1) - { - Width = width, - SliderActiveForegroundColor = KernelColorTools.GetColor(sliderColor), - SliderForegroundColor = TransformationTools.GetDarkBackground(KernelColorTools.GetColor(sliderColor)), - SliderBackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(slider, new(Left, Top))); - } - - /// - /// Writes the slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - public static void WriteSlider(int currPos, int maxPos, int Left, int Top, KernelColorType sliderColor) => - WriteSlider(currPos, maxPos, Left, Top, ConsoleWrapper.WindowWidth - 10, sliderColor, KernelColorType.Separator); - - /// - /// Writes the slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// Slider width - public static void WriteSlider(int currPos, int maxPos, int Left, int Top, int width, KernelColorType sliderColor) => - WriteSlider(currPos, maxPos, Left, Top, width, sliderColor, KernelColorType.Separator); - - /// - /// Writes the slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - public static void WriteSlider(int currPos, int maxPos, int Left, int Top, KernelColorType sliderColor, KernelColorType BackgroundColor) => - WriteSlider(currPos, maxPos, Left, Top, ConsoleWrapper.WindowWidth - 10, sliderColor, BackgroundColor); - - /// - /// Writes the slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - /// Slider width - public static void WriteSlider(int currPos, int maxPos, int Left, int Top, int width, KernelColorType sliderColor, KernelColorType BackgroundColor) - { - var slider = new Slider(currPos, 0, maxPos) - { - Width = width, - SliderActiveForegroundColor = KernelColorTools.GetColor(sliderColor), - SliderForegroundColor = TransformationTools.GetDarkBackground(KernelColorTools.GetColor(sliderColor)), - SliderBackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(slider, new(Left, Top))); - } - - /// - /// Writes the vertical slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - public static void WriteVerticalSliderAbsolute(int currPos, int maxPos, int Left, int Top, KernelColorType SliderColor, int minPos = 0) => - WriteVerticalSliderAbsolute(currPos, maxPos, Left, Top, ConsoleWrapper.WindowHeight - 2, SliderColor, KernelColorType.Separator, minPos); - - /// - /// Writes the vertical slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// Slider height - public static void WriteVerticalSliderAbsolute(int currPos, int maxPos, int Left, int Top, int height, KernelColorType SliderColor, int minPos = 0) => - WriteVerticalSliderAbsolute(currPos, maxPos, Left, Top, height, SliderColor, KernelColorType.Separator, minPos); - - /// - /// Writes the vertical slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - public static void WriteVerticalSliderAbsolute(int currPos, int maxPos, int Left, int Top, KernelColorType SliderColor, KernelColorType BackgroundColor, int minPos = 0) => - WriteVerticalSliderAbsolute(currPos, maxPos, Left, Top, ConsoleWrapper.WindowHeight - 2, SliderColor, BackgroundColor, minPos); - - /// - /// Writes the vertical slider (absolute) - /// - /// Current position out of maximum position - /// Minimum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - /// Slider height - public static void WriteVerticalSliderAbsolute(int currPos, int maxPos, int Left, int Top, int height, KernelColorType SliderColor, KernelColorType BackgroundColor, int minPos = 0) - { - var slider = new Slider(height * ((currPos - minPos) / (maxPos - minPos)), minPos, height + 1) - { - Vertical = true, - Height = height, - SliderActiveForegroundColor = KernelColorTools.GetColor(SliderColor), - SliderForegroundColor = TransformationTools.GetDarkBackground(KernelColorTools.GetColor(SliderColor)), - SliderBackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(slider, new(Left, Top))); - } - - /// - /// Writes the vertical slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - public static void WriteVerticalSlider(int currPos, int maxPos, int Left, int Top, KernelColorType SliderColor) => - WriteVerticalSlider(currPos, maxPos, Left, Top, ConsoleWrapper.WindowHeight - 2, SliderColor, KernelColorType.Separator); - - /// - /// Writes the vertical slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// Slider height - public static void WriteVerticalSlider(int currPos, int maxPos, int Left, int Top, int height, KernelColorType SliderColor) => - WriteVerticalSlider(currPos, maxPos, Left, Top, height, SliderColor, KernelColorType.Separator); - - /// - /// Writes the vertical slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - public static void WriteVerticalSlider(int currPos, int maxPos, int Left, int Top, KernelColorType SliderColor, KernelColorType BackgroundColor) => - WriteVerticalSlider(currPos, maxPos, Left, Top, ConsoleWrapper.WindowHeight - 2, SliderColor, BackgroundColor); - - /// - /// Writes the vertical slider - /// - /// Current position out of maximum position - /// Maximum position - /// The slider position from the upper left corner - /// The slider position from the top - /// The slider color - /// The slider background color - /// Slider height - public static void WriteVerticalSlider(int currPos, int maxPos, int Left, int Top, int height, KernelColorType SliderColor, KernelColorType BackgroundColor) - { - var slider = new Slider(currPos, 0, maxPos) - { - Vertical = true, - Height = height, - SliderActiveForegroundColor = KernelColorTools.GetColor(SliderColor), - SliderForegroundColor = TransformationTools.GetDarkBackground(KernelColorTools.GetColor(SliderColor)), - SliderBackgroundColor = KernelColorTools.GetColor(BackgroundColor), - }; - TextWriterRaw.WriteRaw(ContainerTools.RenderRenderable(slider, new(Left, Top))); - } - } -} diff --git a/public/Nitrocid/ConsoleBase/Writers/TextMiscWriters.cs b/public/Nitrocid/ConsoleBase/Writers/TextMiscWriters.cs deleted file mode 100644 index c305fa512..000000000 --- a/public/Nitrocid/ConsoleBase/Writers/TextMiscWriters.cs +++ /dev/null @@ -1,275 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Nitrocid.ConsoleBase.Colors; -using Terminaux.Writer.ConsoleWriters; -using Terminaux.Writer.CyclicWriters; - -namespace Nitrocid.ConsoleBase.Writers -{ - /// - /// Miscellaneous text writer wrapper for writing with () - /// - public static class TextMiscWriters - { - /// - /// Prints the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static void PrintLineWithHandleConditional(bool Condition, string Filename, int LineNumber, int startPos, int endPos, KernelColorType ColorType) - { - if (!Condition) - return; - PrintLineWithHandle(Filename, LineNumber, startPos, endPos, ColorType); - } - - /// - /// Prints the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static void PrintLineWithHandleConditional(bool Condition, string[] Array, int LineNumber, int startPos, int endPos, KernelColorType ColorType) - { - if (!Condition) - return; - PrintLineWithHandle(Array, LineNumber, startPos, endPos, ColorType); - } - - /// - /// Prints the line of a text file with the specified line number and the column number - /// - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static void PrintLineWithHandle(string Filename, int LineNumber, int startPos, int endPos, KernelColorType ColorType) => - TextWriterRaw.WriteRaw(RenderLineWithHandle(Filename, LineNumber, startPos, endPos, ColorType)); - - /// - /// Prints the line of a text file with the specified line number and the column number - /// - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static void PrintLineWithHandle(string[] Array, int LineNumber, int startPos, int endPos, KernelColorType ColorType) => - TextWriterRaw.WriteRaw(RenderLineWithHandle(Array, LineNumber, startPos, endPos, ColorType)); - - /// - /// Renders the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static string RenderLineWithHandleConditional(bool Condition, string Filename, int LineNumber, int startPos, int endPos, KernelColorType ColorType) - { - if (Condition) - return RenderLineWithHandle(Filename, LineNumber, startPos, endPos, ColorType); - return ""; - } - - /// - /// Renders the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static string RenderLineWithHandleConditional(bool Condition, string[] Array, int LineNumber, int startPos, int endPos, KernelColorType ColorType) - { - if (Condition) - return RenderLineWithHandle(Array, LineNumber, startPos, endPos, ColorType); - return ""; - } - - /// - /// Renders the line of a text file with the specified line number and the column number - /// - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static string RenderLineWithHandle(string Filename, int LineNumber, int startPos, int endPos, KernelColorType ColorType) - { - var lineHandle = new LineHandle(Filename) - { - Position = LineNumber, - SourcePosition = startPos, - TargetPosition = endPos, - Ranged = true, - Color = KernelColorTools.GetColor(ColorType), - }; - return lineHandle.Render(); - } - - /// - /// Renders the line of a text file with the specified line number and the column number - /// - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// Column number (not index). This tells the handle where to place itself as the end. Should be bigger than the start position. - /// The type of color - public static string RenderLineWithHandle(string[] Array, int LineNumber, int startPos, int endPos, KernelColorType ColorType) - { - var lineHandle = new LineHandle(Array) - { - Position = LineNumber, - SourcePosition = startPos, - TargetPosition = endPos, - Ranged = true, - Color = KernelColorTools.GetColor(ColorType), - }; - return lineHandle.Render(); - } - - /// - /// Prints the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static void PrintLineWithHandleConditional(bool Condition, string Filename, int LineNumber, int ColumnNumber, KernelColorType ColorType) - { - if (!Condition) - return; - PrintLineWithHandle(Filename, LineNumber, ColumnNumber, ColorType); - } - - /// - /// Prints the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static void PrintLineWithHandleConditional(bool Condition, string[] Array, int LineNumber, int ColumnNumber, KernelColorType ColorType) - { - if (!Condition) - return; - PrintLineWithHandle(Array, LineNumber, ColumnNumber, ColorType); - } - - /// - /// Prints the line of a text file with the specified line number and the column number - /// - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static void PrintLineWithHandle(string Filename, int LineNumber, int ColumnNumber, KernelColorType ColorType) => - TextWriterRaw.WriteRaw(RenderLineWithHandle(Filename, LineNumber, ColumnNumber, ColorType)); - - /// - /// Prints the line of a text file with the specified line number and the column number - /// - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static void PrintLineWithHandle(string[] Array, int LineNumber, int ColumnNumber, KernelColorType ColorType) => - TextWriterRaw.WriteRaw(RenderLineWithHandle(Array, LineNumber, ColumnNumber, ColorType)); - - /// - /// Renders the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static string RenderLineWithHandleConditional(bool Condition, string Filename, int LineNumber, int ColumnNumber, KernelColorType ColorType) - { - if (Condition) - return RenderLineWithHandle(Filename, LineNumber, ColumnNumber, ColorType); - return ""; - } - - /// - /// Renders the line of a text file with the specified line number and the column number if the specified condition is satisfied - /// - /// The condition to satisfy - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static string RenderLineWithHandleConditional(bool Condition, string[] Array, int LineNumber, int ColumnNumber, KernelColorType ColorType) - { - if (Condition) - return RenderLineWithHandle(Array, LineNumber, ColumnNumber, ColorType); - return ""; - } - - /// - /// Renders the line of a text file with the specified line number and the column number - /// - /// Path to text file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static string RenderLineWithHandle(string Filename, int LineNumber, int ColumnNumber, KernelColorType ColorType) - { - var lineHandle = new LineHandle(Filename) - { - Position = LineNumber, - SourcePosition = ColumnNumber, - Color = KernelColorTools.GetColor(ColorType), - }; - return lineHandle.Render(); - } - - /// - /// Renders the line of a text file with the specified line number and the column number - /// - /// A string array containing the contents of the file - /// Line number (not index) - /// Column number (not index). This tells the handle where to place itself - /// The type of color - public static string RenderLineWithHandle(string[] Array, int LineNumber, int ColumnNumber, KernelColorType ColorType) - { - var lineHandle = new LineHandle(Array) - { - Position = LineNumber, - SourcePosition = ColumnNumber, - Color = KernelColorTools.GetColor(ColorType), - }; - return lineHandle.Render(); - } - } -} diff --git a/public/Nitrocid/ConsoleBase/Writers/TextWriters.cs b/public/Nitrocid/ConsoleBase/Writers/TextWriters.cs index 1de677cb2..938952584 100644 --- a/public/Nitrocid/ConsoleBase/Writers/TextWriters.cs +++ b/public/Nitrocid/ConsoleBase/Writers/TextWriters.cs @@ -27,6 +27,7 @@ using Nitrocid.Drivers.Console; using Terminaux.Base; using Terminaux.Writer.CyclicWriters; +using Nitrocid.Drivers; namespace Nitrocid.ConsoleBase.Writers { @@ -35,62 +36,6 @@ namespace Nitrocid.ConsoleBase.Writers /// public static class TextWriters { - /// - /// Outputs a list entry and value into the terminal prompt. - /// - /// A list entry that will be listed to the terminal prompt. - /// A list value that will be listed to the terminal prompt. - /// Indentation level - /// A key color. - /// A value color. - public static void WriteListEntry(string entry, string value, KernelColorType ListKeyColor, KernelColorType ListValueColor, int indent = 0) - { - var listing = new ListEntry() - { - Entry = entry, - Value = value, - KeyColor = KernelColorTools.GetColor(ListKeyColor), - ValueColor = KernelColorTools.GetColor(ListValueColor), - Indentation = indent, - }; - TextWriterRaw.WriteRaw(listing.Render()); - } - - /// - /// Outputs the text into the terminal prompt with custom color support. - /// - /// A dictionary that will be listed to the terminal prompt. - /// A key color. - /// A value color. - public static void WriteList(Dictionary List, KernelColorType ListKeyColor, KernelColorType ListValueColor) - where TKey : notnull - { - var listing = new Listing() - { - Objects = List, - KeyColor = KernelColorTools.GetColor(ListKeyColor), - ValueColor = KernelColorTools.GetColor(ListValueColor), - }; - TextWriterRaw.WriteRaw(listing.Render()); - } - - /// - /// Outputs the text into the terminal prompt with custom color support. - /// - /// A dictionary that will be listed to the terminal prompt. - /// A key color. - /// A value color. - public static void WriteList(IEnumerable List, KernelColorType ListKeyColor, KernelColorType ListValueColor) - { - var listing = new Listing() - { - Objects = List, - KeyColor = KernelColorTools.GetColor(ListKeyColor), - ValueColor = KernelColorTools.GetColor(ListValueColor), - }; - TextWriterRaw.WriteRaw(listing.Render()); - } - /// /// Outputs the text into the terminal prompt, and sets colors as needed. /// @@ -312,5 +257,61 @@ public static void WriteWhere(string msg, int Left, int Top, bool Return, int Ri } } } + + /// + /// Outputs the text into the terminal prompt, wraps the long terminal output if needed, and sets colors as needed. + /// + /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... + /// Whether to print a new line or not + /// A type of colors that will be changed. + /// Variables to format the message before it's written. + public static void WriteWrapped(string Text, bool Line, KernelColorType colorType, params object[] vars) + { + lock (BaseConsoleDriver.WriteLock) + { + try + { + // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. + KernelColorTools.SetConsoleColorDry(colorType); + + // Write wrapped output + DriverHandler.CurrentConsoleDriverLocal.WriteWrappedPlain(Text, Line, vars); + } + catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) + { + DebugWriter.WriteDebugStackTrace(ex); + DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); + } + } + } + + /// + /// Outputs the text into the terminal prompt, wraps the long terminal output if needed, and sets colors as needed. + /// + /// A sentence that will be written to the terminal prompt. Supports {0}, {1}, ... + /// Whether to print a new line or not + /// A type of colors that will be changed for the foreground color. + /// A type of colors that will be changed for the background color. + /// Variables to format the message before it's written. + public static void WriteWrapped(string Text, bool Line, KernelColorType colorTypeForeground, KernelColorType colorTypeBackground, params object[] vars) + { + lock (BaseConsoleDriver.WriteLock) + { + try + { + // Check if default console output equals the new console output text writer. If it does, write in color, else, suppress the colors. + KernelColorTools.SetConsoleColorDry(colorTypeForeground); + KernelColorTools.SetConsoleColorDry(colorTypeBackground, true); + + // Write wrapped output + DriverHandler.CurrentConsoleDriverLocal.WriteWrappedPlain(Text, Line, vars); + } + catch (Exception ex) when (ex.GetType().Name != nameof(ThreadInterruptedException)) + { + DebugWriter.WriteDebugStackTrace(ex); + DebugWriter.WriteDebug(DebugLevel.E, Translate.DoTranslation("There is a serious error when printing text.") + " {0}", ex.Message); + } + } + } } } diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFiglet.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFiglet.cs deleted file mode 100644 index f2fcce187..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFiglet.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet; -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; -using Nitrocid.Kernel.Exceptions; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintFiglet : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a figlet string to console"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hello world!"; - var figletFont = FigletFonts.TryGetByName("small") ?? - throw new KernelException(KernelExceptionType.Console, Translate.DoTranslation("Failed to get figlet font")); - TextFancyWriters.WriteFiglet(rendered, figletFont, KernelColorType.Success); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCentered.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCentered.cs deleted file mode 100644 index 7fa81c828..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCentered.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet; -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; -using Nitrocid.Kernel.Exceptions; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintFigletCentered : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a figlet string to console (centered)"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hello world!"; - var figletFont = FigletFonts.TryGetByName("speed") ?? - throw new KernelException(KernelExceptionType.Console, Translate.DoTranslation("Failed to get figlet font")); - TextFancyWriters.WriteCenteredFiglet(figletFont, rendered, KernelColorType.Success); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredF.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredF.cs deleted file mode 100644 index 90d9de0f8..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredF.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet; -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; -using Nitrocid.Kernel.Exceptions; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintFigletCenteredF : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a figlet string to console with formatting (centered)"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hi, {0}!"; - var figletFont = FigletFonts.TryGetByName("speed") ?? - throw new KernelException(KernelExceptionType.Console, Translate.DoTranslation("Failed to get figlet font")); - TextFancyWriters.WriteCenteredFiglet(figletFont, rendered, KernelColorType.Success, 0, 0, "Nitrocid KS"); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositional.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositional.cs deleted file mode 100644 index ddc6842c8..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositional.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet; -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; -using Nitrocid.Kernel.Exceptions; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintFigletCenteredPositional : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a figlet string to console (centered, positional)"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hello world!"; - var figletFont = FigletFonts.TryGetByName("speed") ?? - throw new KernelException(KernelExceptionType.Console, Translate.DoTranslation("Failed to get figlet font")); - TextFancyWriters.WriteCenteredFiglet(5, figletFont, rendered, KernelColorType.Success); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositionalF.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositionalF.cs deleted file mode 100644 index de7fe9101..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletCenteredPositionalF.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet; -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; -using Nitrocid.Kernel.Exceptions; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintFigletCenteredPositionalF : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a figlet string to console with formatting (centered, positional)"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hi, {0}!"; - var figletFont = FigletFonts.TryGetByName("speed") ?? - throw new KernelException(KernelExceptionType.Console, Translate.DoTranslation("Failed to get figlet font")); - TextFancyWriters.WriteCenteredFiglet(5, figletFont, rendered, KernelColorType.Success, 20, 10, "Nitrocid KS"); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletF.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletF.cs deleted file mode 100644 index ad7f07b5a..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintFigletF.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Textify.Data.Figlet; -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; -using Nitrocid.Kernel.Exceptions; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintFigletF : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a figlet string to console with formatting"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hi, {0}!"; - var figletFont = FigletFonts.TryGetByName("speed") ?? - throw new KernelException(KernelExceptionType.Console, Translate.DoTranslation("Failed to get figlet font")); - TextFancyWriters.WriteFiglet(rendered, figletFont, KernelColorType.Success, 0, 0, "Nitrocid KS"); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColor.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColor.cs deleted file mode 100644 index 6cf7056e7..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColor.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintSepColor : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a separator to console with color"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hello world!"; - TextFancyWriters.WriteSeparator(rendered, KernelColorType.Success); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColorF.cs b/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColorF.cs deleted file mode 100644 index 597e40f85..000000000 --- a/public/Nitrocid/Kernel/Debugging/Testing/Facades/PrintSepColorF.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2025 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using Nitrocid.ConsoleBase.Colors; -using Nitrocid.ConsoleBase.Writers; -using Nitrocid.Languages; - -namespace Nitrocid.Kernel.Debugging.Testing.Facades -{ - internal class PrintSepColorF : TestFacade - { - public override string TestName => Translate.DoTranslation("Print a separator to console with formatting and color"); - public override TestSection TestSection => TestSection.ConsoleBase; - public override int TestOptionalParameters => 1; - public override void Run(params string[] args) - { - string rendered = args.Length > 0 ? args[0] : "Hi, {0}!"; - TextFancyWriters.WriteSeparator(rendered, KernelColorType.Success, "Nitrocid KS"); - } - } -} diff --git a/public/Nitrocid/Kernel/Debugging/Testing/TestInteractive.cs b/public/Nitrocid/Kernel/Debugging/Testing/TestInteractive.cs index e2a3ce914..8a1908505 100644 --- a/public/Nitrocid/Kernel/Debugging/Testing/TestInteractive.cs +++ b/public/Nitrocid/Kernel/Debugging/Testing/TestInteractive.cs @@ -40,14 +40,6 @@ internal static class TestInteractive { "PrintDF", new PrintDF() }, { "PrintSep", new PrintSep() }, { "PrintSepF", new PrintSepF() }, - { "PrintSepColor", new PrintSepColor() }, - { "PrintSepColorF", new PrintSepColorF() }, - { "PrintFiglet", new PrintFiglet() }, - { "PrintFigletF", new PrintFigletF() }, - { "PrintFigletCentered", new PrintFigletCentered() }, - { "PrintFigletCenteredF", new PrintFigletCenteredF() }, - { "PrintFigletCenteredPositional", new PrintFigletCenteredPositional() }, - { "PrintFigletCenteredPositionalF", new PrintFigletCenteredPositionalF() }, { "PrintPlaces", new PrintPlaces() }, { "PrintWithNewLines", new PrintWithNewLines() }, { "PrintWithNulls", new PrintWithNulls() }, diff --git a/public/Nitrocid/Kernel/Starting/KernelInitializers.cs b/public/Nitrocid/Kernel/Starting/KernelInitializers.cs index b52f0f11b..39037818c 100644 --- a/public/Nitrocid/Kernel/Starting/KernelInitializers.cs +++ b/public/Nitrocid/Kernel/Starting/KernelInitializers.cs @@ -61,6 +61,7 @@ using System.Collections.Generic; using System.Text; using Nitrocid.Kernel.Exceptions; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Kernel.Starting { @@ -310,7 +311,7 @@ internal static void InitializeWelcomeMessages() // Some information if (Config.MainConfig.ShowAppInfoOnBoot & !Config.MainConfig.EnableSplash) { - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Kernel environment information"), KernelColorType.Stage); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Kernel environment information"), KernelColorTools.GetColor(KernelColorType.Stage)); TextWriterColor.Write("OS: " + Translate.DoTranslation("Running on {0}"), System.Environment.OSVersion.ToString()); TextWriterColor.Write("KSAPI: " + $"v{KernelMain.ApiVersion}"); } diff --git a/public/Nitrocid/Kernel/Starting/KernelStageTools.cs b/public/Nitrocid/Kernel/Starting/KernelStageTools.cs index 98e99b343..9d5e8a448 100644 --- a/public/Nitrocid/Kernel/Starting/KernelStageTools.cs +++ b/public/Nitrocid/Kernel/Starting/KernelStageTools.cs @@ -26,6 +26,7 @@ using Nitrocid.Languages; using Nitrocid.ConsoleBase.Colors; using Terminaux.Writer.ConsoleWriters; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Kernel.Starting { @@ -99,7 +100,7 @@ internal static void ReportNewStage(int StageNumber, string StageText) if (!Config.MainConfig.EnableSplash & !KernelEntry.QuietKernel) { TextWriterRaw.Write(); - TextFancyWriters.WriteSeparator(StageText, KernelColorType.Stage); + SeparatorWriterColor.WriteSeparatorColor(StageText, KernelColorTools.GetColor(KernelColorType.Stage)); } DebugWriter.WriteDebug(DebugLevel.I, $"- Kernel stage {StageNumber} | Text: {StageText}"); } diff --git a/public/Nitrocid/Kernel/Starting/WelcomeMessage.cs b/public/Nitrocid/Kernel/Starting/WelcomeMessage.cs index 50641a209..9fcfe0ddd 100644 --- a/public/Nitrocid/Kernel/Starting/WelcomeMessage.cs +++ b/public/Nitrocid/Kernel/Starting/WelcomeMessage.cs @@ -31,6 +31,7 @@ using System; using Terminaux.Inputs.Styles; using Nitrocid.ConsoleBase.Writers; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Kernel.Starting { @@ -65,7 +66,7 @@ internal static void WriteMessage() // Finally, write the message if (Config.MainConfig.StartScroll) - TextDynamicWriters.WriteSlowly(MessageWrite, true, 10d, KernelColorType.Banner, KernelMain.VersionFullStr); + TextWriterSlowColor.WriteSlowlyColor(MessageWrite, true, 10d, KernelColorTools.GetColor(KernelColorType.Banner), KernelMain.VersionFullStr); else TextWriters.Write(MessageWrite, true, KernelColorType.Banner, KernelMain.VersionFullStr); @@ -77,7 +78,7 @@ internal static void WriteMessage() internal static void WriteLicense() { - TextFancyWriters.WriteSeparator(Translate.DoTranslation("License information"), KernelColorType.Stage); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("License information"), KernelColorTools.GetColor(KernelColorType.Stage)); TextWriters.Write(GetLicenseString(), true, KernelColorType.License); } diff --git a/public/Nitrocid/Shell/ShellBase/Commands/CommandExecutor.cs b/public/Nitrocid/Shell/ShellBase/Commands/CommandExecutor.cs index b29ac6de8..c8956d0a1 100644 --- a/public/Nitrocid/Shell/ShellBase/Commands/CommandExecutor.cs +++ b/public/Nitrocid/Shell/ShellBase/Commands/CommandExecutor.cs @@ -396,7 +396,7 @@ public static void ExecuteCommandWrapped(string Command) // Now, print the output DebugWriter.WriteDebug(DebugLevel.I, "Printing..."); - TextDynamicWriters.WriteWrapped(wrapOutput, false, KernelColorType.NeutralText); + TextWriters.WriteWrapped(wrapOutput, false, KernelColorType.NeutralText); } catch (Exception ex) { diff --git a/public/Nitrocid/Shell/ShellBase/Scripting/UESHParse.cs b/public/Nitrocid/Shell/ShellBase/Scripting/UESHParse.cs index 9c56d7a1b..bd17ad6d6 100644 --- a/public/Nitrocid/Shell/ShellBase/Scripting/UESHParse.cs +++ b/public/Nitrocid/Shell/ShellBase/Scripting/UESHParse.cs @@ -30,6 +30,8 @@ using Textify.General; using Nitrocid.ConsoleBase.Writers; using Nitrocid.ConsoleBase.Colors; +using Terminaux.Writer.ConsoleWriters; +using Terminaux.Writer.CyclicWriters; namespace Nitrocid.Shell.ShellBase.Scripting { @@ -38,7 +40,6 @@ namespace Nitrocid.Shell.ShellBase.Scripting /// public static class UESHParse { - /// /// Executes the UESH script /// @@ -104,10 +105,10 @@ public static void Execute(string ScriptPath, string ScriptArguments, bool justL // If it still starts with the new stack indicator, throw an error if (Line.StartsWith('|')) - throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("You can't declare the new block before you place expressions that support the creation, like conditions or loops. The stack number is {0}.") + " {1}:{2}\n{3}", commandStackNum, ScriptPath, LineNo, TextMiscWriters.RenderLineWithHandle(ScriptPath, LineNo, commandStackNum, KernelColorType.Error)); + throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("You can't declare the new block before you place expressions that support the creation, like conditions or loops. The stack number is {0}.") + " {1}:{2}\n{3}", commandStackNum, ScriptPath, LineNo, GetLineHandle(ScriptPath, LineNo, commandStackNum, KernelColorType.Error)); } else if (!Line.StartsWith(stackIndicator) && newCommandStackRequired) - throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("When starting a new block, make sure that you've indented the stack correctly. The stack number is {0}.") + " {1}:{2}\n{3}", commandStackNum, ScriptPath, LineNo, TextMiscWriters.RenderLineWithHandle(ScriptPath, LineNo, commandStackNum, KernelColorType.Error)); + throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("When starting a new block, make sure that you've indented the stack correctly. The stack number is {0}.") + " {1}:{2}\n{3}", commandStackNum, ScriptPath, LineNo, GetLineHandle(ScriptPath, LineNo, commandStackNum, KernelColorType.Error)); else { if (retryLoopCondition && !justLint) @@ -234,16 +235,26 @@ public static void Execute(string ScriptPath, string ScriptArguments, bool justL EventsManager.FireEvent(EventType.UESHError, ScriptPath, ScriptArguments, ex); DebugWriter.WriteDebug(DebugLevel.E, "Error trying to execute script {0} with arguments {1}: {2}", ScriptPath, ScriptArguments, ex.Message); DebugWriter.WriteDebugStackTrace(ex); - throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("The script is malformed. Check the script and resolve any errors.") + "\n{0}", ex, TextMiscWriters.RenderLineWithHandle(ScriptPath, LineNo, 0, KernelColorType.Error)); + throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("The script is malformed. Check the script and resolve any errors.") + "\n{0}", ex, GetLineHandle(ScriptPath, LineNo, 0, KernelColorType.Error)); } catch (Exception ex) { EventsManager.FireEvent(EventType.UESHError, ScriptPath, ScriptArguments, ex); DebugWriter.WriteDebug(DebugLevel.E, "Error trying to execute script {0} with arguments {1}: {2}", ScriptPath, ScriptArguments, ex.Message); DebugWriter.WriteDebugStackTrace(ex); - throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("The script is malformed. Check the script and resolve any errors: {0}") + "\n{1}", ex, ex.Message, TextMiscWriters.RenderLineWithHandle(ScriptPath, LineNo, 0, KernelColorType.Error)); + throw new KernelException(KernelExceptionType.UESHScript, Translate.DoTranslation("The script is malformed. Check the script and resolve any errors: {0}") + "\n{1}", ex, ex.Message, GetLineHandle(ScriptPath, LineNo, 0, KernelColorType.Error)); } } + internal static LineHandle GetLineHandle(string path, int line, int column, KernelColorType colorType) + { + var lineHandle = new LineHandle(path) + { + Position = line, + SourcePosition = column, + Color = KernelColorTools.GetColor(colorType), + }; + return lineHandle; + } } } diff --git a/public/Nitrocid/Shell/Shells/Admin/Commands/UserInfo.cs b/public/Nitrocid/Shell/Shells/Admin/Commands/UserInfo.cs index 3a989c698..16150f157 100644 --- a/public/Nitrocid/Shell/Shells/Admin/Commands/UserInfo.cs +++ b/public/Nitrocid/Shell/Shells/Admin/Commands/UserInfo.cs @@ -23,6 +23,7 @@ using Nitrocid.Languages; using Nitrocid.ConsoleBase.Colors; using Terminaux.Writer.ConsoleWriters; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.Admin.Commands { @@ -45,7 +46,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (user is not null) { // First off, basic user information - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Basic user info"), KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Basic user info"), KernelColorTools.GetColor(KernelColorType.ListTitle)); TextWriters.Write(Translate.DoTranslation("Username") + ": ", false, KernelColorType.ListEntry); TextWriters.Write(user.Username, true, KernelColorType.ListValue); TextWriters.Write(Translate.DoTranslation("Full name") + ": ", false, KernelColorType.ListEntry); @@ -59,13 +60,13 @@ public override int Execute(CommandParameters parameters, ref string variableVal TextWriterRaw.Write(); // Now, the permissions. - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Permissions"), KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Permissions"), KernelColorTools.GetColor(KernelColorType.ListTitle)); foreach (string perm in user.Permissions) TextWriters.Write($" - {perm}", true, KernelColorType.ListValue); TextWriterRaw.Write(); // Now, the groups. - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Groups"), KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Groups"), KernelColorTools.GetColor(KernelColorType.ListTitle)); foreach (string group in user.Groups) TextWriters.Write($" - {group}", true, KernelColorType.ListValue); } diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/DriverMan.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/DriverMan.cs index 5e13c2999..2cf83c0ad 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/DriverMan.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/DriverMan.cs @@ -27,6 +27,7 @@ using Nitrocid.ConsoleBase.Colors; using Nitrocid.Drivers; using System; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -85,7 +86,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal } case "list": { - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Drivers for") + $" {typeTerm}", KernelColorType.Separator); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Drivers for") + $" {typeTerm}", KernelColorTools.GetColor(KernelColorType.Separator)); foreach (var driver in DriverHandler.GetDrivers(typeTerm)) { if (!driver.DriverInternal) diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/GetAllExtHandlers.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/GetAllExtHandlers.cs index 4282e34c1..33ca6e162 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/GetAllExtHandlers.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/GetAllExtHandlers.cs @@ -23,6 +23,7 @@ using Nitrocid.Languages; using Nitrocid.Shell.ShellBase.Commands; using System.Linq; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -41,7 +42,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal for (int i = 0; i < handlers.Length; i++) { ExtensionHandler handler = handlers[i]; - TextFancyWriters.WriteSeparator($"{i + 1}/{handlers.Length}", KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor($"{i + 1}/{handlers.Length}", KernelColorTools.GetColor(KernelColorType.ListTitle)); TextWriters.Write("- " + Translate.DoTranslation("Extension") + ": ", false, KernelColorType.ListEntry); TextWriters.Write(handler.Extension, KernelColorType.ListValue); TextWriters.Write("- " + Translate.DoTranslation("Extension handler") + ": ", false, KernelColorType.ListEntry); diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/GetConfigValue.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/GetConfigValue.cs index 466644e71..c20698fe9 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/GetConfigValue.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/GetConfigValue.cs @@ -95,7 +95,14 @@ public override int Execute(CommandParameters parameters, ref string variableVal public override void HelpHelper() { var names = Config.GetKernelConfigs().Select((bkc) => bkc.GetType().Name).ToArray(); - TextWriters.WriteListEntry(Translate.DoTranslation("Available configuration types"), string.Join(", ", names), KernelColorType.ListEntry, KernelColorType.ListValue); + var listEntry = new ListEntry() + { + Entry = Translate.DoTranslation("Available configuration types"), + Value = string.Join(", ", names), + KeyColor = KernelColorTools.GetColor(KernelColorType.ListEntry), + ValueColor = KernelColorTools.GetColor(KernelColorType.ListValue), + }; + TextWriterRaw.WriteRaw(listEntry.Render()); } } diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/GetDefaultExtHandlers.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/GetDefaultExtHandlers.cs index 1a67b9581..923d95e8f 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/GetDefaultExtHandlers.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/GetDefaultExtHandlers.cs @@ -23,6 +23,7 @@ using Nitrocid.Languages; using Nitrocid.Shell.ShellBase.Commands; using System.Linq; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -43,7 +44,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal ExtensionHandler? handler = ExtensionHandlerTools.GetExtensionHandler(handlers.ElementAt(i).Key, handlers.ElementAt(i).Value); if (handler is null) continue; - TextFancyWriters.WriteSeparator($"{i + 1}/{handlers.Count}", KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor($"{i + 1}/{handlers.Count}", KernelColorTools.GetColor(KernelColorType.ListTitle)); TextWriters.Write("- " + Translate.DoTranslation("Extension") + ": ", false, KernelColorType.ListEntry); TextWriters.Write(handler.Extension, KernelColorType.ListValue); TextWriters.Write("- " + Translate.DoTranslation("Default extension handler") + ": ", false, KernelColorType.ListEntry); diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/GetExtHandlers.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/GetExtHandlers.cs index ae40b1c54..a93193467 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/GetExtHandlers.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/GetExtHandlers.cs @@ -23,6 +23,7 @@ using Nitrocid.Languages; using Nitrocid.Shell.ShellBase.Commands; using System.Linq; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -46,7 +47,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal for (int i = 0; i < handlers.Length; i++) { ExtensionHandler handler = handlers[i]; - TextFancyWriters.WriteSeparator($"{i + 1}/{handlers.Length}", KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor($"{i + 1}/{handlers.Length}", KernelColorTools.GetColor(KernelColorType.ListTitle)); TextWriters.Write("- " + Translate.DoTranslation("Extension") + ": ", false, KernelColorType.ListEntry); TextWriters.Write(handler.Extension, KernelColorType.ListValue); TextWriters.Write("- " + Translate.DoTranslation("Extension handler") + ": ", false, KernelColorType.ListEntry); diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/LsConfigValues.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/LsConfigValues.cs index 2d860e1aa..13a9b1abf 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/LsConfigValues.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/LsConfigValues.cs @@ -96,7 +96,14 @@ public override int Execute(CommandParameters parameters, ref string variableVal public override void HelpHelper() { var names = Config.GetKernelConfigs().Select((bkc) => bkc.GetType().Name).ToArray(); - TextWriters.WriteListEntry(Translate.DoTranslation("Available configuration types"), string.Join(", ", names), KernelColorType.ListEntry, KernelColorType.ListValue); + var listEntry = new ListEntry() + { + Entry = Translate.DoTranslation("Available configuration types"), + Value = string.Join(", ", names), + KeyColor = KernelColorTools.GetColor(KernelColorType.ListEntry), + ValueColor = KernelColorTools.GetColor(KernelColorType.ListValue), + }; + TextWriterRaw.WriteRaw(listEntry.Render()); } } diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/LsExtHandlers.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/LsExtHandlers.cs index af1d9aecd..f17a08a20 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/LsExtHandlers.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/LsExtHandlers.cs @@ -22,6 +22,7 @@ using Nitrocid.Files.Extensions; using Nitrocid.Languages; using Nitrocid.Shell.ShellBase.Commands; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -39,7 +40,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal var handlers = ExtensionHandlerTools.GetExtensionHandlers(); foreach (var handler in handlers) { - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Extension handler information for") + $" {handler.Extension}", KernelColorType.ListTitle); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Extension handler information for") + $" {handler.Extension}", KernelColorTools.GetColor(KernelColorType.ListTitle)); TextWriters.Write("- " + Translate.DoTranslation("Handler implementer") + $": ", false, KernelColorType.ListEntry); TextWriters.Write(handler.Implementer, true, KernelColorType.ListValue); TextWriters.Write("- " + Translate.DoTranslation("Handler metadata") + $": ", false, KernelColorType.ListEntry); diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/SetConfigValue.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/SetConfigValue.cs index a1ce81095..8bcb69da1 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/SetConfigValue.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/SetConfigValue.cs @@ -24,6 +24,8 @@ using Nitrocid.Languages; using Nitrocid.Shell.ShellBase.Commands; using System.Linq; +using Terminaux.Writer.ConsoleWriters; +using Terminaux.Writer.CyclicWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -68,7 +70,14 @@ public override int Execute(CommandParameters parameters, ref string variableVal public override void HelpHelper() { var names = Config.GetKernelConfigs().Select((bkc) => bkc.GetType().Name).ToArray(); - TextWriters.WriteListEntry(Translate.DoTranslation("Available configuration types"), string.Join(", ", names), KernelColorType.ListEntry, KernelColorType.ListValue); + var listEntry = new ListEntry() + { + Entry = Translate.DoTranslation("Available configuration types"), + Value = string.Join(", ", names), + KeyColor = KernelColorTools.GetColor(KernelColorType.ListEntry), + ValueColor = KernelColorTools.GetColor(KernelColorType.ListValue), + }; + TextWriterRaw.WriteRaw(listEntry.Render()); } } diff --git a/public/Nitrocid/Shell/Shells/UESH/Commands/SysInfo.cs b/public/Nitrocid/Shell/Shells/UESH/Commands/SysInfo.cs index 9aa095c98..632854484 100644 --- a/public/Nitrocid/Shell/Shells/UESH/Commands/SysInfo.cs +++ b/public/Nitrocid/Shell/Shells/UESH/Commands/SysInfo.cs @@ -30,6 +30,7 @@ using Nitrocid.Users.Login.Motd; using Nitrocid.Users.Windows; using Nitrocid.Kernel.Configuration; +using Terminaux.Writer.FancyWriters; namespace Nitrocid.Shell.Shells.UESH.Commands { @@ -68,7 +69,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (ShowSystemInfo) { // Kernel section - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Kernel settings"), KernelColorType.Separator); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Kernel settings"), KernelColorTools.GetColor(KernelColorType.Separator)); TextWriters.Write(Translate.DoTranslation("Kernel Version:") + " ", false, KernelColorType.ListEntry); TextWriters.Write(KernelMain.Version?.ToString() ?? "0.0.0.0", true, KernelColorType.ListValue); TextWriters.Write(Translate.DoTranslation("Debug Mode:") + " ", false, KernelColorType.ListEntry); @@ -83,7 +84,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (ShowHardwareInfo) { // Hardware section - TextFancyWriters.WriteSeparator(Translate.DoTranslation("Hardware settings"), KernelColorType.Separator); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("Hardware settings"), KernelColorTools.GetColor(KernelColorType.Separator)); HardwareList.ListHardware(); if (!WindowsUserTools.IsAdministrator()) @@ -96,7 +97,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (ShowUserInfo) { // User section - TextFancyWriters.WriteSeparator(Translate.DoTranslation("User settings"), KernelColorType.Separator); + SeparatorWriterColor.WriteSeparatorColor(Translate.DoTranslation("User settings"), KernelColorTools.GetColor(KernelColorType.Separator)); TextWriters.Write(Translate.DoTranslation("Current user name:") + " ", false, KernelColorType.ListEntry); TextWriters.Write(UserManagement.CurrentUser.Username, true, KernelColorType.ListValue); TextWriters.Write(Translate.DoTranslation("Current host name:") + " ", false, KernelColorType.ListEntry); @@ -109,7 +110,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (ShowMessageOfTheDay) { // Show MOTD - TextFancyWriters.WriteSeparator("MOTD", KernelColorType.Separator); + SeparatorWriterColor.WriteSeparatorColor("MOTD", KernelColorTools.GetColor(KernelColorType.Separator)); TextWriters.Write(PlaceParse.ProbePlaces(MotdParse.MotdMessage), true, KernelColorType.NeutralText); TextWriterRaw.Write(); } @@ -117,7 +118,7 @@ public override int Execute(CommandParameters parameters, ref string variableVal if (ShowMal) { // Show MAL - TextFancyWriters.WriteSeparator("MAL", KernelColorType.Separator); + SeparatorWriterColor.WriteSeparatorColor("MAL", KernelColorTools.GetColor(KernelColorType.Separator)); TextWriters.Write(PlaceParse.ProbePlaces(MalParse.MalMessage), true, KernelColorType.NeutralText); } return 0;