Ansi 1.0.0

Simple StringBuilder extensions for adding ansi escape sequences

There is a newer version of this package available.
See the version list below for details.
Install-Package Ansi -Version 1.0.0
dotnet add package Ansi --version 1.0.0
<PackageReference Include="Ansi" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ansi --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Example


/*** NOTE: To use esapce sequences on your Windows 
  Console, you need to enable virtual terminal 
  processing. This is easy; */
WindowsConsole.TryEnableVirtualTerminalProcessing();
/* TryEnableVirtualTerminalProcessing shouldn't fail 
   and only really does something on Windows Platforms
*/
Console.Write( new StringBuilder()
	.SetTitle("Hello World")
	.HideCursor()
	.SaveState() /* save state so we can restore it top of next loop*/
);

for( var i = 0;; i++ ) {
	/* What, ain't monochrome good enough for ya? */
	var color = new Rgb(
		(byte)(128 + Math.Sin( i / 200d ) * 127),
		(byte)(128 + Math.Sin( i / 100d ) * 127),
		(byte)(128 + Math.Sin( i / 130d ) * 80) );

	Console.Write( new StringBuilder()
		.RestoreState()
		.SaveState()
		.SetMode( Mode.Reset )
		.Append( "HELLO" )
		.SetMode( Mode.Bold )
		.SetForegroundColor( color )
		.Append( "WORLD" )
	);
	Thread.Sleep( 25 );
}

Example


/*** NOTE: To use esapce sequences on your Windows 
  Console, you need to enable virtual terminal 
  processing. This is easy; */
WindowsConsole.TryEnableVirtualTerminalProcessing();
/* TryEnableVirtualTerminalProcessing shouldn't fail 
   and only really does something on Windows Platforms
*/
Console.Write( new StringBuilder()
	.SetTitle("Hello World")
	.HideCursor()
	.SaveState() /* save state so we can restore it top of next loop*/
);

for( var i = 0;; i++ ) {
	/* What, ain't monochrome good enough for ya? */
	var color = new Rgb(
		(byte)(128 + Math.Sin( i / 200d ) * 127),
		(byte)(128 + Math.Sin( i / 100d ) * 127),
		(byte)(128 + Math.Sin( i / 130d ) * 80) );

	Console.Write( new StringBuilder()
		.RestoreState()
		.SaveState()
		.SetMode( Mode.Reset )
		.Append( "HELLO" )
		.SetMode( Mode.Bold )
		.SetForegroundColor( color )
		.Append( "WORLD" )
	);
	Thread.Sleep( 25 );
}

  • .NETStandard 2.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 History

Version Downloads Last updated
1.0.3 970 11/27/2018
1.0.2 1,349 11/3/2017
1.0.1 790 10/19/2017
1.0.0 819 10/11/2017