Skip to content

Commit

Permalink
ref - brk|doc - Refactored the border and box frame color
Browse files Browse the repository at this point in the history
---

This is a breaking refactor to reduce the maintenance burden.

---

Type: ref
Breaking: True
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Dec 20, 2023
1 parent 7b6f1ee commit cce2727
Show file tree
Hide file tree
Showing 11 changed files with 840 additions and 979 deletions.
12 changes: 6 additions & 6 deletions Terminaux/Colors/Selector/ColorSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static string RenderColorSelector(Color selectedColor, ColorType type)
hueRamp.Append($"{new Color($"hsl:{hue};100;50").VTSequenceBackgroundTrueColor} {initialBackground}");
}
selector.Append(
BoxFrameTextColor.RenderBoxFrame($"Hue: {(type == ColorType.TrueColor ? trueColorHue : HslConversionTools.ConvertFrom(selectedColor.RGB).HueWhole)}/360", hueBarX, hueBarY, boxWidth, boxHeight) +
BoxFrameColor.RenderBoxFrame($"Hue: {(type == ColorType.TrueColor ? trueColorHue : HslConversionTools.ConvertFrom(selectedColor.RGB).HueWhole)}/360", hueBarX, hueBarY, boxWidth, boxHeight) +
CsiSequences.GenerateCsiCursorPosition(hueBarX + 2, hueBarY + 2) +
hueRamp.ToString()
);
Expand All @@ -208,7 +208,7 @@ private static string RenderColorSelector(Color selectedColor, ColorType type)
satRamp.Append($"{new Color($"hsl:{(type == ColorType.TrueColor ? trueColorHue : HslConversionTools.ConvertFrom(selectedColor.RGB).HueWhole)};{sat};50").VTSequenceBackgroundTrueColor} {initialBackground}");
}
selector.Append(
BoxFrameTextColor.RenderBoxFrame($"Saturation: {(type == ColorType.TrueColor ? trueColorSaturation : HslConversionTools.ConvertFrom(selectedColor.RGB).SaturationWhole)}/100", hueBarX, saturationBarY, boxWidth, boxHeight) +
BoxFrameColor.RenderBoxFrame($"Saturation: {(type == ColorType.TrueColor ? trueColorSaturation : HslConversionTools.ConvertFrom(selectedColor.RGB).SaturationWhole)}/100", hueBarX, saturationBarY, boxWidth, boxHeight) +
CsiSequences.GenerateCsiCursorPosition(hueBarX + 2, saturationBarY + 2) +
satRamp.ToString()
);
Expand All @@ -222,7 +222,7 @@ private static string RenderColorSelector(Color selectedColor, ColorType type)
ligRamp.Append($"{new Color($"hsl:{(type == ColorType.TrueColor ? trueColorHue : HslConversionTools.ConvertFrom(selectedColor.RGB).HueWhole)};100;{lig}").VTSequenceBackgroundTrueColor} {initialBackground}");
}
selector.Append(
BoxFrameTextColor.RenderBoxFrame($"Lightness: {(type == ColorType.TrueColor ? trueColorLightness : HslConversionTools.ConvertFrom(selectedColor.RGB).LightnessWhole)}/100", hueBarX, lightnessBarY, boxWidth, boxHeight) +
BoxFrameColor.RenderBoxFrame($"Lightness: {(type == ColorType.TrueColor ? trueColorLightness : HslConversionTools.ConvertFrom(selectedColor.RGB).LightnessWhole)}/100", hueBarX, lightnessBarY, boxWidth, boxHeight) +
CsiSequences.GenerateCsiCursorPosition(hueBarX + 2, lightnessBarY + 2) +
ligRamp.ToString()
);
Expand All @@ -237,7 +237,7 @@ private static string RenderColorSelector(Color selectedColor, ColorType type)
grayRamp.Append($"{new Color($"{gray};{gray};{gray}").VTSequenceBackgroundTrueColor} {initialBackground}");
}
selector.Append(
BoxFrameTextColor.RenderBoxFrame($"Gray: {mono.R}/255", hueBarX, grayRampBarY, boxWidth, boxHeight) +
BoxFrameColor.RenderBoxFrame($"Gray: {mono.R}/255", hueBarX, grayRampBarY, boxWidth, boxHeight) +
CsiSequences.GenerateCsiCursorPosition(hueBarX + 2, grayRampBarY + 2) +
grayRamp.ToString()
);
Expand All @@ -257,7 +257,7 @@ private static string RenderColorSelector(Color selectedColor, ColorType type)
blueRamp.Append($"{new Color($"0;0;{blue}").VTSequenceBackgroundTrueColor} {initialBackground}");
}
selector.Append(
BoxFrameTextColor.RenderBoxFrame($"Red, Green, and Blue: {selectedColor.R};{selectedColor.G};{selectedColor.B}", hueBarX, rgbRampBarY, boxWidth, boxHeight + 2) +
BoxFrameColor.RenderBoxFrame($"Red, Green, and Blue: {selectedColor.R};{selectedColor.G};{selectedColor.B}", hueBarX, rgbRampBarY, boxWidth, boxHeight + 2) +
CsiSequences.GenerateCsiCursorPosition(hueBarX + 2, rgbRampBarY + 2) +
redRamp.ToString() +
CsiSequences.GenerateCsiCursorPosition(hueBarX + 2, rgbRampBarY + 3) +
Expand Down Expand Up @@ -495,7 +495,7 @@ private static string RenderPreviewBox(Color selectedColor, ColorType type)
int boxHeight = ConsoleWrapper.WindowHeight - 6;

// First, draw the border
builder.Append(BoxFrameTextColor.RenderBoxFrame($"{selectedColor.PlainSequence} [{selectedColor.PlainSequenceTrueColor}{(type != ColorType.TrueColor ? $" | {(type == ColorType._16Color ? colorValue16 : colorValue255)}" : "")}]", boxX, boxY, boxWidth, boxHeight));
builder.Append(BoxFrameColor.RenderBoxFrame($"{selectedColor.PlainSequence} [{selectedColor.PlainSequenceTrueColor}{(type != ColorType.TrueColor ? $" | {(type == ColorType._16Color ? colorValue16 : colorValue255)}" : "")}]", boxX, boxY, boxWidth, boxHeight));

// then, the box
builder.Append(
Expand Down
4 changes: 2 additions & 2 deletions Terminaux/Inputs/Styles/Infobox/InfoBoxButtonsColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ internal static int WriteInfoBoxButtonsColorBack(string title, string[] buttons,
var boxBuffer = new StringBuilder();
string border =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
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 ? InfoBoxTitledButtonsColor.VTSequenceForeground : "")}" +
Expand Down Expand Up @@ -665,7 +665,7 @@ internal static int WriteInfoBoxButtonsColorBack(string title, string[] buttons,
if (useColor)
{
boxBuffer.Append(
BorderTextColor.RenderBorderText(title, buttonX, buttonPanelPosY, maxButtonWidth - 3, 1, buttonForegroundColor, buttonBackgroundColor) +
BorderColor.RenderBorder(title, buttonX, buttonPanelPosY, maxButtonWidth - 3, 1, buttonForegroundColor, buttonBackgroundColor) +
TextWriterWhereColor.RenderWhere(buttonText, buttonTextX, buttonPanelPosY + 1, buttonForegroundColor, buttonBackgroundColor)
);
}
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 @@ -980,7 +980,7 @@ string[] GetFinalLines()
var boxBuffer = new StringBuilder();
string border =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
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 ? InfoBoxTitledColor.VTSequenceForeground : "")}" +
Expand Down
2 changes: 1 addition & 1 deletion Terminaux/Inputs/Styles/Infobox/InfoBoxInputColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ internal static string WriteInfoBoxInputColorBack(string title, string text,
var boxBuffer = new StringBuilder();
string border =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
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 ? InfoBoxTitledColor.VTSequenceForeground : "")}" +
Expand Down
2 changes: 1 addition & 1 deletion Terminaux/Inputs/Styles/Infobox/InfoBoxProgressColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ internal static void WriteInfoBoxProgressColorBack(string title, double progress
var boxBuffer = new StringBuilder();
string border =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
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 ? InfoBoxTitledProgressColor.VTSequenceForeground : "")}" +
Expand Down
4 changes: 2 additions & 2 deletions Terminaux/Inputs/Styles/Infobox/InfoBoxSelectionColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,11 @@ internal static int WriteInfoBoxSelectionColorBack(string title, InputChoiceInfo
var boxBuffer = new StringBuilder();
string border =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
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);
string borderSelection =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, selectionBoxPosX, selectionBoxPosY - 1, maxSelectionWidth, selectionChoices, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
BorderColor.RenderBorderPlain(title, selectionBoxPosX, selectionBoxPosY - 1, maxSelectionWidth, selectionChoices, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
BorderColor.RenderBorderPlain(selectionBoxPosX, selectionBoxPosY - 1, maxSelectionWidth, selectionChoices, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar);
boxBuffer.Append(
$"{(useColor ? InfoBoxTitledSelectionColor.VTSequenceForeground : "")}" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,11 @@ internal static int[] WriteInfoBoxSelectionMultipleColorBack(string title, Input
var boxBuffer = new StringBuilder();
string border =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, borderX, borderY, maxWidth, maxHeight, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
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);
string borderSelection =
!string.IsNullOrEmpty(title) ?
BorderTextColor.RenderBorderTextPlain(title, selectionBoxPosX, selectionBoxPosY - 1, maxSelectionWidth, selectionChoices, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
BorderColor.RenderBorderPlain(title, selectionBoxPosX, selectionBoxPosY - 1, maxSelectionWidth, selectionChoices, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar) :
BorderColor.RenderBorderPlain(selectionBoxPosX, selectionBoxPosY - 1, maxSelectionWidth, selectionChoices, UpperLeftCornerChar, LowerLeftCornerChar, UpperRightCornerChar, LowerRightCornerChar, UpperFrameChar, LowerFrameChar, LeftFrameChar, RightFrameChar);
boxBuffer.Append(
$"{(useColor ? InfoBoxTitledSelectionMultipleColor.VTSequenceForeground : "")}" +
Expand Down
Loading

0 comments on commit cce2727

Please sign in to comment.