Skip to content

Commit

Permalink
fix - Fixed infoboxes not rendering properly
Browse files Browse the repository at this point in the history
---

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
  • Loading branch information
AptiviCEO committed May 22, 2024
1 parent dff4069 commit be381be
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
4 changes: 0 additions & 4 deletions Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -474,7 +471,6 @@ internal static int WriteInfoBoxButtonsColorBack(string title, InputChoiceInfo[]
ColorTools.RenderSetConsoleColor(ColorTools.CurrentBackgroundColor, true)
);
}
ColorTools.AllowForeground = false;
return boxBuffer.ToString();
});

Expand Down
2 changes: 1 addition & 1 deletion Terminaux/Inputs/Styles/Infobox/InfoBoxColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
);
Expand Down
3 changes: 0 additions & 3 deletions Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -409,7 +407,6 @@ internal static int WriteInfoBoxSelectionColorBack(string title, InputChoiceInfo
);
// Return the buffer
ColorTools.AllowForeground = false;
return boxBuffer.ToString();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -413,7 +411,6 @@ internal static int[] WriteInfoBoxSelectionMultipleColorBack(string title, Input
);
// Return the buffer
ColorTools.AllowForeground = false;
return boxBuffer.ToString();
});

Expand Down
6 changes: 5 additions & 1 deletion Terminaux/Inputs/Styles/Selection/SelectionInputTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be381be

Please sign in to comment.