Skip to content

Commit

Permalink
imp - Improved separator rendering
Browse files Browse the repository at this point in the history
---

The separator rendering has been improved.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 1, 2025
1 parent e7eab91 commit d35ecb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

using Terminaux.Base;
using Terminaux.Writer.ConsoleWriters;
using Terminaux.Writer.FancyWriters;

namespace Terminaux.Console.Fixtures.Cases.Writer
Expand Down
8 changes: 4 additions & 4 deletions public/Terminaux/Writer/FancyWriters/SeparatorWriterColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,29 @@ internal static string RenderSeparator(string Text, Color ForegroundColor, Color
if (!string.IsNullOrWhiteSpace(Text))
{
// Render the text accordingly
Text = canPosition ? Text.Truncate(ConsoleWrapper.WindowWidth - 6) : Text;
Text = canPosition ? Text.Truncate(ConsoleWrapper.WindowWidth - 10) : Text;
if (useColor)
{
separator.Append(
ColorTools.RenderSetConsoleColor(ForegroundColor) +
ColorTools.RenderSetConsoleColor(BackgroundColor, true)
);
}
separator.Append($"──╢ {Text} ╟──");
separator.Append($"──╢ {Text} ");
}

// See how many times to repeat the closing minus sign. We could be running this in the wrap command.
int RepeatTimes = 0;
if (canPosition)
{
int width = ConsoleChar.EstimateCellWidth(separator.ToString());
RepeatTimes = ConsoleWrapper.WindowWidth - width - 4;
RepeatTimes = ConsoleWrapper.WindowWidth - width - 1;
}

// Write the closing minus sign.
if (RepeatTimes > 0)
{
separator.Append('╟');
if (useColor)
{
separator.Append(
Expand All @@ -187,7 +188,6 @@ internal static string RenderSeparator(string Text, Color ForegroundColor, Color
}
separator.Append(new string('─', RepeatTimes));
}
separator.Append('╢');

// Return the resulting separator
if (useColor)
Expand Down

0 comments on commit d35ecb2

Please sign in to comment.