Skip to content

Commit

Permalink
add - Added option whether to write a new line or not
Browse files Browse the repository at this point in the history
---

We've added an option whether to print the new line after separator or not.

---

Type: add
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Mar 8, 2024
1 parent 8ee4117 commit 177ace9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Terminaux.Console/Fixtures/Cases/Writer/PrintSep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class PrintSep : IFixture
public string FixtureID => "PrintSep";
public void RunFixture()
{
SeparatorWriterColor.WriteSeparator("Hello world!", true);
SeparatorWriterColor.WriteSeparator("Hello world!", true, true);
}
}
}
46 changes: 30 additions & 16 deletions Terminaux/Writer/FancyWriters/SeparatorWriterColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,25 @@ public static class SeparatorWriterColor
/// Draw a separator with text plainly
/// </summary>
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparatorPlain(string Text, params object[] Vars) =>
WriteSeparatorPlain(Text, true, Vars);
public static void WriteSeparatorPlain(string Text, bool line = true, params object[] Vars) =>
WriteSeparatorPlain(Text, true, line, Vars);

/// <summary>
/// Draw a separator with text plainly
/// </summary>
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="PrintSuffix">Whether or not to print the leading suffix. Only use if you don't have suffix on your text.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparatorPlain(string Text, bool PrintSuffix, params object[] Vars)
public static void WriteSeparatorPlain(string Text, bool PrintSuffix, bool line = true, params object[] Vars)
{
try
{
TextWriterRaw.WritePlain(RenderSeparator(Text, PrintSuffix, Vars) + '\n');
TextWriterRaw.WriteRaw(RenderSeparator(Text, PrintSuffix, Vars));
if (line)
TextWriterRaw.WritePlain("\n");
}
catch (Exception ex)
{
Expand All @@ -65,40 +69,46 @@ public static void WriteSeparatorPlain(string Text, bool PrintSuffix, params obj
/// Draw a separator with text
/// </summary>
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparator(string Text, params object[] Vars) =>
WriteSeparator(Text, true, Vars);
public static void WriteSeparator(string Text, bool line = true, params object[] Vars) =>
WriteSeparator(Text, true, line, Vars);

/// <summary>
/// Draw a separator with text
/// </summary>
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="Color">A color that will be changed to.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparatorColor(string Text, Color Color, params object[] Vars) =>
WriteSeparatorColorBack(Text, true, Color, ColorTools.currentBackgroundColor, Vars);
public static void WriteSeparatorColor(string Text, Color Color, bool line = true, params object[] Vars) =>
WriteSeparatorColorBack(Text, true, Color, ColorTools.currentBackgroundColor, line, Vars);

/// <summary>
/// Draw a separator with text
/// </summary>
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="ForegroundColor">A foreground color that will be changed to.</param>
/// <param name="BackgroundColor">A background color that will be changed to.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparatorColorBack(string Text, Color ForegroundColor, Color BackgroundColor, params object[] Vars) =>
WriteSeparatorColorBack(Text, true, ForegroundColor, BackgroundColor, Vars);
public static void WriteSeparatorColorBack(string Text, Color ForegroundColor, Color BackgroundColor, bool line = true, params object[] Vars) =>
WriteSeparatorColorBack(Text, true, ForegroundColor, BackgroundColor, line, Vars);

/// <summary>
/// Draw a separator with text
/// </summary>
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="PrintSuffix">Whether or not to print the leading suffix. Only use if you don't have suffix on your text.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparator(string Text, bool PrintSuffix, params object[] Vars)
public static void WriteSeparator(string Text, bool PrintSuffix, bool line = true, params object[] Vars)
{
try
{
TextWriterRaw.WritePlain(RenderSeparator(Text, PrintSuffix, Vars) + '\n');
TextWriterRaw.WriteRaw(RenderSeparator(Text, PrintSuffix, Vars));
if (line)
TextWriterRaw.WritePlain("\n");
}
catch (Exception ex)
{
Expand All @@ -113,9 +123,10 @@ public static void WriteSeparator(string Text, bool PrintSuffix, params object[]
/// <param name="Text">Text to be written. If nothing, the entire line is filled with the separator.</param>
/// <param name="PrintSuffix">Whether or not to print the leading suffix. Only use if you have suffix on your text.</param>
/// <param name="Color">A color that will be changed to.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparatorColor(string Text, bool PrintSuffix, Color Color, params object[] Vars) =>
WriteSeparatorColorBack(Text, PrintSuffix, Color, ColorTools.currentBackgroundColor, Vars);
public static void WriteSeparatorColor(string Text, bool PrintSuffix, Color Color, bool line = true, params object[] Vars) =>
WriteSeparatorColorBack(Text, PrintSuffix, Color, ColorTools.currentBackgroundColor, line, Vars);

/// <summary>
/// Draw a separator with text
Expand All @@ -124,12 +135,15 @@ public static void WriteSeparatorColor(string Text, bool PrintSuffix, Color Colo
/// <param name="PrintSuffix">Whether or not to print the leading suffix. Only use if you have suffix on your text.</param>
/// <param name="ForegroundColor">A foreground color that will be changed to.</param>
/// <param name="BackgroundColor">A background color that will be changed to.</param>
/// <param name="line">Whether to write a new line or not</param>
/// <param name="Vars">Variables to format the message before it's written.</param>
public static void WriteSeparatorColorBack(string Text, bool PrintSuffix, Color ForegroundColor, Color BackgroundColor, params object[] Vars)
public static void WriteSeparatorColorBack(string Text, bool PrintSuffix, Color ForegroundColor, Color BackgroundColor, bool line = true, params object[] Vars)
{
try
{
TextWriterRaw.WritePlain(RenderSeparator(Text, PrintSuffix, ForegroundColor, BackgroundColor, Vars) + '\n');
TextWriterRaw.WriteRaw(RenderSeparator(Text, PrintSuffix, ForegroundColor, BackgroundColor, Vars));
if (line)
TextWriterRaw.WritePlain("\n");
}
catch (Exception ex)
{
Expand Down

0 comments on commit 177ace9

Please sign in to comment.