Bny.Console 1.0.0.1

dotnet add package Bny.Console --version 1.0.0.1
NuGet\Install-Package Bny.Console -Version 1.0.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="Bny.Console" Version="1.0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bny.Console --version 1.0.0.1
#r "nuget: Bny.Console, 1.0.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.
// Install Bny.Console as a Cake Addin
#addin nuget:?package=Bny.Console&version=1.0.0.1

// Install Bny.Console as a Cake Tool
#tool nuget:?package=Bny.Console&version=1.0.0.1

Bny.Console

Improves working with console using ANSI escape codes

Examples

Printing

This example shows printing colorful ascii art text into console.

Code
// import
using Bny.Console;

// prepare text to print
string[] str = new string[] {
    @"  ______   ______     ______     ______  ",
    @" /\__  _\ /\  ___\   /\  ___\   /\__  _\ ",
    @" \/_/\ \/ \ \  __\   \ \___  \  \/_/\ \/ ",
    @"    \ \_\  \ \_____\  \/\_____\    \ \_\ ",
    @"     \/_/   \/_____/   \/_____/     \/_/ ",
};

// print the text at coordinates [40, 12]
// the color for each line is created using the index of the line with the Term.Prepare static method
Term.FormAt(str.AsSpan(), 40, 12, i => Term.Prepare(Term.fg, 230 - i * 7, 55, 150 + i * 15));
// hide the cursor
Term.Form(Term.hideCursor);
// wait for enter
Console.ReadLine();
// reset font style and cursor visibility
Term.ResetAll();
Output

image Output is shown in windows terminal before the enter was pressed

Reading

This example shows how to read secret text from console limited by length

Code
using Bny.Console;

// Read from console
// map maps the printed characters,
// if you don't want to print any characters, you can use 'intercept: true'
// min and max speicies the minimal and maximal length of readed input
// pressing enter before the given limit won't do anything
// characters after the 64 are ignored and not printed, but you can still edit what you entered
string s = Term.Read(map: _ => '*', min: 8, max: 64);
// this will write newline before the given string
// Term.Read doesn't jump to the next line
Term.LineWrite(s);
Output
****************************************************************
if this was shorter than 8 characters, pressing enter wouldn't w
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.0.1 419 8/10/2022
1.0.0 413 5/14/2022