From be381be3b835f88b493e8a8fef9fb881ad4eb0b2 Mon Sep 17 00:00:00 2001 From: Aptivi Date: Wed, 22 May 2024 11:44:19 +0300 Subject: [PATCH] fix - Fixed infoboxes not rendering properly --- We've fixed infoboxes not rendering properly caused by arbitrary setting of ColorTools.AllowForeground to true. --- Type: fix Breaking: False Doc Required: False Part: 1/1 --- Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs | 4 ---- Terminaux/Inputs/Styles/Infobox/InfoBoxColor.cs | 2 +- Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs | 3 --- .../Inputs/Styles/Infobox/InfoBoxSelectionMultipleColor.cs | 3 --- Terminaux/Inputs/Styles/Selection/SelectionInputTools.cs | 6 +++++- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs b/Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs index a46d5fa59..1ae5c1059 100644 --- a/Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs +++ b/Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs @@ -411,15 +411,12 @@ internal static int WriteInfoBoxButtonsColorBack(string title, InputChoiceInfo[] ScreenTools.CurrentScreen?.AddBufferedPart(nameof(InfoBoxButtonsColor), infoBoxScreenPart); try { - bool initialForeground = ColorTools.AllowForeground; int currIdx = 0; int increment = 0; bool exiting = false; bool delay = false; infoBoxScreenPart.AddDynamicText(() => { - ColorTools.AllowForeground = true; - // Deal with the lines to actually fit text in the infobox string[] splitFinalLines = InfoBoxColor.GetFinalLines(text, vars); var (maxWidth, maxHeight, _, borderX, borderY) = InfoBoxColor.GetDimensionsInput(splitFinalLines); @@ -474,7 +471,6 @@ internal static int WriteInfoBoxButtonsColorBack(string title, InputChoiceInfo[] ColorTools.RenderSetConsoleColor(ColorTools.CurrentBackgroundColor, true) ); } - ColorTools.AllowForeground = false; return boxBuffer.ToString(); }); diff --git a/Terminaux/Inputs/Styles/Infobox/InfoBoxColor.cs b/Terminaux/Inputs/Styles/Infobox/InfoBoxColor.cs index 725b888d8..ca4b72006 100644 --- a/Terminaux/Inputs/Styles/Infobox/InfoBoxColor.cs +++ b/Terminaux/Inputs/Styles/Infobox/InfoBoxColor.cs @@ -935,7 +935,7 @@ internal static string RenderText( BorderColor.RenderBorderPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) : BorderColor.RenderBorderPlain(borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar); boxBuffer.Append( - $"{(useColor ? ColorTools.RenderSetConsoleColor(InfoBoxColor) : "")}" + + $"{(useColor ? InfoBoxColor.VTSequenceForeground : "")}" + $"{(useColor ? ColorTools.RenderSetConsoleColor(BackgroundColor, true) : "")}" + $"{border}" ); diff --git a/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs b/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs index b2b5fc7d1..608f76291 100644 --- a/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs +++ b/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs @@ -388,8 +388,6 @@ internal static int WriteInfoBoxSelectionColorBack(string title, InputChoiceInfo bool delay = false; infoBoxScreenPart.AddDynamicText(() => { - ColorTools.AllowForeground = true; - // Deal with the lines to actually fit text in the infobox string[] splitFinalLines = InfoBoxColor.GetFinalLines(text, vars); var (maxWidth, maxHeight, _, borderX, borderY, selectionBoxPosX, selectionBoxPosY, _, maxSelectionWidth, _, _) = InfoBoxColor.GetDimensionsSelection(selections, splitFinalLines); @@ -409,7 +407,6 @@ internal static int WriteInfoBoxSelectionColorBack(string title, InputChoiceInfo ); // Return the buffer - ColorTools.AllowForeground = false; return boxBuffer.ToString(); }); diff --git a/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionMultipleColor.cs b/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionMultipleColor.cs index a36ab725a..86e6245df 100644 --- a/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionMultipleColor.cs +++ b/Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionMultipleColor.cs @@ -392,8 +392,6 @@ internal static int[] WriteInfoBoxSelectionMultipleColorBack(string title, Input bool delay = false; infoBoxScreenPart.AddDynamicText(() => { - ColorTools.AllowForeground = true; - // Deal with the lines to actually fit text in the infobox string[] splitFinalLines = InfoBoxColor.GetFinalLines(text, vars); var (maxWidth, maxHeight, _, borderX, borderY, selectionBoxPosX, selectionBoxPosY, _, maxSelectionWidth, _, _) = InfoBoxColor.GetDimensionsSelection(selections, splitFinalLines); @@ -413,7 +411,6 @@ internal static int[] WriteInfoBoxSelectionMultipleColorBack(string title, Input ); // Return the buffer - ColorTools.AllowForeground = false; return boxBuffer.ToString(); }); diff --git a/Terminaux/Inputs/Styles/Selection/SelectionInputTools.cs b/Terminaux/Inputs/Styles/Selection/SelectionInputTools.cs index e240fc715..cb10cfa70 100644 --- a/Terminaux/Inputs/Styles/Selection/SelectionInputTools.cs +++ b/Terminaux/Inputs/Styles/Selection/SelectionInputTools.cs @@ -210,7 +210,11 @@ altSelectedForegroundColor is not null || altSelectedBackgroundColor is not null if (useColor) { buffer.Append( - TextWriterWhereColor.RenderWhereColorBack(AnswerOption + new string(' ', width - AnswerOption.Length), leftPos, optionTop, finalForeColor, finalBackColor) + finalForeColor.VTSequenceForeground + + finalBackColor.VTSequenceBackground + + TextWriterWhereColor.RenderWhere(AnswerOption + new string(' ', width - AnswerOption.Length), leftPos, optionTop, finalForeColor, finalBackColor) + + ColorTools.RenderSetConsoleColor(ColorTools.CurrentForegroundColor) + + ColorTools.RenderSetConsoleColor(ColorTools.CurrentBackgroundColor, true) ); } else