Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Fresh

Fresh is a dotnet library that makes it easy to customize console output utilizing common ANSI Escape Sequences (colors, bold, underline, etc). It also allows you to wrap text with borders (round, square, or double lined).

Tutorial

Start by creating a new Style object:

var myStyle = new Style();

Here are the available methods on the Style object:

public Style Foreground(RGBColor color)         // Set the text foreground color
public Style Background(RGBColor color)         // Set the text background color
public Style Border(BorderStyle style)          // Choose a border for the text
public Style BorderForeground(RGBColor color)   // Set the border foreground color
public Style BorderBackground(RGBColor color)   // Set the border background color
public Style Bold(bool enabled)                 // Enable or disable bold text
public Style Faint(bool enabled)                // Enable or disable faint/dim text
public Style Italic(bool enabled)               // Enable or disable italic text
public Style Underline(bool enabled)            // Enable or disable underlined text
public Style Blink(bool enabled)                // Enable or disable blinking text
public Style Reverse(bool enabled)              // Enable or disable reverse text (foreground/background colors)
public Style Strikethrough(bool enabled)        // Enable or disable Strikethrough text
public Style Render(string text)                // Render the provided text string with this style

RGBColor is a struct containing ushort values for Red, Green, and Blue:

var red = new RGBColor(255, 0, 0);

BorderStyle is an enumeration to choose a border style:

public enum BorderStyle
{
    SquareBorder,
    RoundBorder,
    DoubleBorder,
}

The Style class supports a fluent API with method-chaining:

var myStyle = new Style()
    .Foreground(red)
    .Border(BorderStyle.RoundBorder)
    .BorderForeground(red)
    .Bold(true);

Finally, use the Style.Render(string) method to apply the style to the provided text and return the result as a new string:

Console.WriteLine(myStyle.Render("This is my fresh Style!"));

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages