YonatanMankovich.ConsoleDiffWriter 1.0.2

dotnet add package YonatanMankovich.ConsoleDiffWriter --version 1.0.2
                    
NuGet\Install-Package YonatanMankovich.ConsoleDiffWriter -Version 1.0.2
                    
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.ConsoleDiffWriter" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YonatanMankovich.ConsoleDiffWriter" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="YonatanMankovich.ConsoleDiffWriter" />
                    
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.ConsoleDiffWriter --version 1.0.2
                    
#r "nuget: YonatanMankovich.ConsoleDiffWriter, 1.0.2"
                    
#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.ConsoleDiffWriter@1.0.2
                    
#: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.ConsoleDiffWriter&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=YonatanMankovich.ConsoleDiffWriter&version=1.0.2
                    
Install as a Cake Tool

Console Diff Writer

.NuGet Publish NuGet

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.

Getting Started Examples

Note that if a Point is not specified in the Diff constructor, the diff will be tracked starting the current Console cursor position.

Plain

String (or Char)
using YonatanMankovich.ConsoleDiffWriter;

StringDiff diff = new StringDiff(); // Or use 'CharDiff' if needed.

diff.WriteDiff("0123456789"); // Write the initial string.
diff.WriteDiff("01234X6789"); // Only the 'X' will be written.
diff.WriteDiff("01234X678"); // The '9' will be overwritten with a space char.

// If writing to a specific point is desired:
StringDiff diffAtPoint = new StringDiff(new Point (6, 9));
String Lines
using YonatanMankovich.ConsoleDiffWriter;

LinesDiff diff = new LinesDiff();

diff.WriteDiff(new List<string>()
{
    "----------",
    "----##----",
    "----++----"
}); // Write the initial lines.

diff.WriteDiff(new List<string>()
{
    "----------",
    "----XX----",
    "----++----"
}); // Only '##' will be overwritten with 'XX'.

diff.WriteDiff(new List<string>()
{
    "----------",
    "----XX----"
}); // The last line will be overwritten with spaces.

// If writing to a specific point is desired:
LinesDiff diffAtPoint = new LinesDiff(new Point (6, 9));

Colorful

Everything is the same as before but now in color. See SimpleColorConsole for methods for working with colored characters, strings, and lines.

ColorString (or ColorChar) and ColorLines
using YonatanMankovich.ConsoleDiffWriter.Color;
using YonatanMankovich.SimpleColorConsole;

 // Or use 'ColorCharDiff' or 'ColorLinesDiff' if needed.
ColorStringDiff diff = new ColorStringDiff();

diff.WriteDiff("0123456789".TextYellow()); // Write the initial string.
diff.WriteDiff("01234X6789".TextYellow()); // Only the 'X' will be written.

 // The '9' will be overwritten with a blue character.
diff.WriteDiff("01234X678".TextYellow() + new ColorChar('9').BackBlue());

// If writing to a specific point is desired:
ColorStringDiff diffAtPoint = new ColorStringDiff(new Point (6, 9));

Behavioral Note

'/n', '/r', '/t' characters will not work. If a multi-line string is needed, use string lists or ColorLines.

My Other Projects That Use This Library

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.

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.2 488 4/8/2023