GithubHelp home page GithubHelp logo

socolin.ansiterminalcolor's Introduction

ANSITerminalColor

Nuget License:MIT

Helpers to generate ANSI escape codes

License

MIT

Disable color

You can disable coloring with AnsiColor.NoColor = true

Examples

Colorize a text before printing it to the console

Console.WriteLine(AnsiColor.ColorizeText("Colored Text", AnsiColor.Bold))
Console.WriteLine(AnsiColor.ColorizeText("Colored Text", AnsiColor.Foreground(Terminal256ColorCodes.Aquamarine1C86)))

Composite multiple modifiers

Composite

Console.WriteLine(AnsiColor.ColorizeText(
    "some-text",
    AnsiColor.Composite(
        AnsiColor.Bold,
        AnsiColor.Underline,
        AnsiColor.Foreground(Terminal256ColorCodes.Gold3C178)
    )));

Using RGB Colors

Console.WriteLine(AnsiColor.ColorizeText(
    "some-text",
    AnsiColor.Foreground(255, 16, 240)
);

Using Colorize()

Console.WriteLine(AnsiColor.Foreground(45, 150, 240).Colorize("Text"));

Use multiple code on the same text

Superposed

var boldBlue = AnsiColor.Composite(
    AnsiColor.Foreground(Terminal256ColorCodes.CadetBlueC73),
    AnsiColor.Bold
);
var orangeBackgroundUnderline = AnsiColor.Composite(
    AnsiColor.Background(Terminal256ColorCodes.Orange4C58),
    AnsiColor.Underline
);
Console.WriteLine(boldBlue.Colorize("Bold Blue " + orangeBackgroundUnderline.Colorize("Orange Underlined") + " Bold Blue"));
Console.WriteLine(orangeBackgroundUnderline.Colorize("Orange Underlined " + boldBlue.Colorize("Bold Blue") + " Orange Underlined"));

More escape sequence can be used when using new AnsiColor(...)

socolin.ansiterminalcolor's People

Contributors

socolin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.