YonatanMankovich.SimpleColorConsole 1.0.1

dotnet add package YonatanMankovich.SimpleColorConsole --version 1.0.1
                    
NuGet\Install-Package YonatanMankovich.SimpleColorConsole -Version 1.0.1
                    
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="YonatanMankovich.SimpleColorConsole" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YonatanMankovich.SimpleColorConsole" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="YonatanMankovich.SimpleColorConsole" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YonatanMankovich.SimpleColorConsole --version 1.0.1
                    
#r "nuget: YonatanMankovich.SimpleColorConsole, 1.0.1"
                    
#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.
#:package YonatanMankovich.SimpleColorConsole@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YonatanMankovich.SimpleColorConsole&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=YonatanMankovich.SimpleColorConsole&version=1.0.1
                    
Install as a Cake Tool

Simple Color Console

An easier way to create, edit, and write colorful text to the console.

The NuGet package is available here.

All Colors

Getting Started Examples

Multiple ways to do the same thing:

using YonatanMankovich.SimpleColorConsole;

"Hello world!".TextBlack().BackYellow().WriteLine();
"Hello world!".Color(ConsoleColor.Black, ConsoleColor.Yellow).WriteLine();
"Hello world!".ColorText(ConsoleColor.Black).ColorBack(ConsoleColor.Yellow).WriteLine();
ColorConsole.WriteLine("Hello world!".TextBlack().BackYellow());
ColorConsole.WriteLine("Hello world!", ConsoleColor.Black, ConsoleColor.Yellow);
new ColorString("Hello world!", ConsoleColor.Black, ConsoleColor.Yellow).WriteLine();

See a list of available colors at the end.

ColorString Features

using YonatanMankovich.SimpleColorConsole;

ColorString cs = "Hello world!".TextBlack().BackYellow();

cs.Write(); // Write the ConsoleString to the console.
cs.WriteLine(); // Write the ConsoleString to the console and adds a new line.
cs.WriteAtPoint(new Point(6, 9)); // Write the ConsoleString to the console at the specified point.
ColorChar cc = cs[5]; // Get the ColorChar at an index.
cs[4].BackYellow(); // Set the ColorChar at an index.
cs.AddToEnd(new ConsoleChar('!', ConsoleColor.Blue, ConsoleColor.Green)); // Add a ConsoleChar to end.
cs.AddToEnd(' '); // Add a plain char to end.
cs.AddToEnd(new ConsoleString("Yo! ", ConsoleColor.Blue, ConsoleColor.Magenta)); // Add a ConsoleString to end.
cs.AddToEnd("Boom!"); // Add a plain string to end.
cs.AddToEnd("Very".BackBlue()).AddToEnd(' '.BackYellow()).AddToEnd("nice!"); // Chain calls.
ColorString concat1 = cs + " Cool!"; // Concatenate a plain string (or char).
ColorString concat2 = cs + " Cool!".TextYellow(); // Concatenate a ColorString string (or ColorChar).
foreach (ColorChar c in cs) c.Write(); // Enumerate the ColorChars of a ColorString.

ColorLines for Multi-Line ColorStrings

ColorLines is a collection of lines of type ColorString. It generally has the same features as ConsoleStrings. The following are the only additions:

using YonatanMankovich.SimpleColorConsole;

ColorLines cl = new ColorLines();

cl.AddLine("Hello!".TextGreen()); // Add a ColorString/string/ColorChar/char line.
cl.AddLine(); // Add a blank line.
cl.AddLine().AddLine("Hello!".TextCyan()); // Chain calls.
cl.AddToEndOfLastLine("OK".BackRed()); // Add a ColorString/string/ColorChar/char to the end of the last line.

Behavioral Notes

  • '/n', '/r', '/t' are not allowed. If a multi-line string is needed, use ColorLines.
  • If the background color is not specified, the current Console.BackgroundColor is used.
  • If the text color is not specified, the current Console.ForegroundColor is used.

Available Colors

  • Black
  • DarkBlue
  • DarkGreen
  • DarkCyan
  • DarkRed
  • DarkMagenta
  • DarkYellow
  • Gray
  • DarkGray
  • Blue
  • Green
  • Cyan
  • Red
  • Magenta
  • Yellow
  • White

(List from here)

My Other Projects That Use This Library

Console Diff Writer

Command Line Minesweeper

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (1)

Showing the top 1 NuGet packages that depend on YonatanMankovich.SimpleColorConsole:

Package Downloads
YonatanMankovich.ConsoleDiffWriter

A library that helps keep track of text written to the console and efficiently writes only the difference with the updated text instead of rewriting all of it.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 486 4/8/2023

Bug fix.