AnsiStyles 0.1.0-beta

This is a prerelease version of AnsiStyles.
There is a newer version of this package available.
See the version list below for details.
dotnet add package AnsiStyles --version 0.1.0-beta                
NuGet\Install-Package AnsiStyles -Version 0.1.0-beta                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnsiStyles" Version="0.1.0-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AnsiStyles --version 0.1.0-beta                
#r "nuget: AnsiStyles, 0.1.0-beta"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AnsiStyles as a Cake Addin
#addin nuget:?package=AnsiStyles&version=0.1.0-beta&prerelease

// Install AnsiStyles as a Cake Tool
#tool nuget:?package=AnsiStyles&version=0.1.0-beta&prerelease                

<div align="center"> <br> <img src=".github/banner.png" alt="[Banner image]" width=600 align="center"> </div>

<h2 align="center">AnsiStyles</h2> <p align="center">This lightweight, simple library provides a easy and intuitive way for adding color to your console applications, allowing you to add multiple different colors and styles to the same string variable.</p> <p align="center">[shields] [shields] [shields] [shields]</p>

<div align="center"> <img src=".github/example1.png" alt="[Example image]" width=1080 align="center"> <br> </div>

Usage

var rs = StringStyle.Reset;
var fc = StringStyle.Foreground;
var prpl = fc[129];

string text = $"This is {prpl}purple{rs} and this is {fc[196]}red{rs}";
Console.WriteLine(text); //Will print out 'text' with purple and red colored

//Can also use some ANSI code for styling 
var boBlue = fc[21].Bold().Outline();
Console.WriteLine(fc[70].Faint() + "some text" + $"{boBlue} bold outlined blue{rs}");

//You can also concat it with regular strings
var text2 = fc.Yellow + "This is yellow " + rs + prpl + "and this is purple";
Console.WriteLine(text2);
Console.WriteLine("Look, i'm still purple!");

Console.WriteLine(rs);                //Remember to always apply reset to the end of the strings
Console.WriteLine("i'm normal now!"); //Or you can just print the reset out, else the applied color/style
                                      //will keep bleading in subsequent prints until it finds a reset

//All of the above but for the background of the string
var bc = StringStyle.Background;
Console.WriteLine(bc.White + fc.Black + "Black text with White highlighting" + rs);
    
fc.ColorTest(); //prints out all the available colors codes
bc.ColorTest();

Installation

NuGet

The latest stable version is available on NuGet

dotnet add package AnsiStyles

From source

Alternatively, you can easily build from source if needed

git clone https://github.com/Haise777/AnsiStyles
cd AnsiStyles/AnsiStyles
dotnet build --configuration Release

# Here you can find the compiled assembly file 'AnsiStyles'
cd bin/Release/net6.0 

You can add the compiled assembly to your projects by adding a reference to the assembly file, you can follow this entry in a Microsoft article for more information.

Contributing

Feel free to contribute

  • Just fork and clone the repository
  • Then commit and pull request only for the dev branch.

Support

  • If you encouter a bug or would like to request a feature, please submit an issue.
  • For any other question that is not related to bugs or feature, feel free to contact me.

AnsiStyles is released under BSD 3-Clause license

Contact me
Email: gashimabucoro@proton.me  ·  Discord: @.haise_san

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 155 2/15/2024
1.0.0 117 2/15/2024
0.1.0-beta 113 2/13/2024

First release, product still in testing phase.

-Haise777