ConsoleTextFormat 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package ConsoleTextFormat --version 1.0.3                
NuGet\Install-Package ConsoleTextFormat -Version 1.0.3                
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="ConsoleTextFormat" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConsoleTextFormat --version 1.0.3                
#r "nuget: ConsoleTextFormat, 1.0.3"                
#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 ConsoleTextFormat as a Cake Addin
#addin nuget:?package=ConsoleTextFormat&version=1.0.3

// Install ConsoleTextFormat as a Cake Tool
#tool nuget:?package=ConsoleTextFormat&version=1.0.3                

ConsoleTextFormat

About

A simple static class libray facilitating .NET Console app text formatting in Console.Write() and Console.WriteLine() statements without explicitly using escape codes.

Console Virtual Terminal Sequences: MS Learn Ref

About

Whilst there are same Console class methods for setting text and background colors, there are no methods for setting text attributes such as bold, underline, etc. This library provides a simple way to do this. This library enables inline code (that is, with in a string) to change text format when writing to the console using Console.Write() and Console.WriteLine() methods.

The class entities have been made a cryptic as possible whilst maintaining interpretation upon inspection. The strings so used are not escaped, but are interpreted by the library.

String Interpolation is used to embed the format strings in the text to be written to the console.

The format strings are at 2 levels.

  • Quite explicit e.g. {Fmt.fg(Fmt.Col.yellow)}
  • Cryptic e.g. {F.fgYel}

Both of the code segments above will produce the same result. The cryptic version requires the using statements as in the following code to alias the class names.


## Example Console Code

```cs
using B = ConsoleTextFormat.Fmt.Bold;
using F = ConsoleTextFormat.Fmt;
namespace ConsoleApp9
{
    using System;
    using ConsoleTextFormat;

    internal class Program
    {

        static void Main(string[] args)
        {
            Fmt.Heading("Hello, World!",Fmt.Col.yellow, Fmt.Col.blue);
            Fmt.RainbowHeading("Hello, World!", Fmt.Col.yellow);
            Fmt.Info("This is a topic:", "Information");            Console.WriteLine($"{Fmt.bg(Fmt.Col.white)}Hello, {Fmt.b}World!{Fmt._b}{Fmt.clear}");
            Console.WriteLine($"{Fmt.fg(Fmt.Col.yellow)}Hello, {Fmt.b}World!{Fmt._b}{Fmt.clear}");
            Console.WriteLine($"{Fmt.fg(Fmt.Col.blue)}Hello, {Fmt.clear}World!");
            Console.WriteLine($"{B.fgRed}{B.bgCya}Hello, {Fmt.clear}World!");
            Console.WriteLine($"{F.fgRed}{F.bgCya}Hello, {Fmt.clear}World!");
        }
    }
}

Consoleformat Image of running app
Console app output

Updates

  • 2021-09-07: Added Fmt.Heading() and Fmt.RainbowHeading() methods to format text as headings.
  • 2021-09-07: Added Fmt.Info(topic,info) added.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.
  • net8.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.3.0 69 12/22/2024
1.2.9 61 12/22/2024
1.2.8 62 12/22/2024
1.2.7 69 12/22/2024
1.2.6 79 12/16/2024
1.2.5 68 12/16/2024
1.2.4 72 12/15/2024
1.2.3 85 11/7/2024
1.2.1 82 11/7/2024
1.1.7 79 11/6/2024
1.1.0 83 10/17/2024
1.0.5 81 11/6/2024
1.0.4 96 10/13/2024
1.0.3.8 89 10/13/2024
1.0.3.7 101 10/13/2024
1.0.3.6 92 10/13/2024
1.0.3.5 98 10/13/2024
1.0.3.4 86 10/13/2024
1.0.3.2 93 10/11/2024
1.0.3 92 10/11/2024
1.0.2 103 10/10/2024
1.0.1 92 10/10/2024
1.0.0 88 10/10/2024

Update of ReadMe only