Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

126 Commits

Repository files navigation

ConsoleInteractive Nuget

A C# library that allows you to write and read from the console simultaneously

Usage

See ConsoleInteractiveDemo for a sample, but the gist of it is

// Create a CancellationToken so we can cancel the reader later.CancellationTokenSourcects=newCancellationTokenSource();// Create a new Thread that will print for us.ThreadPrintingThread=newThread(newThreadStart(()=>{ConsoleWriter.WriteLine("Hello World!");Thread.Sleep(5000);ConsoleWriter.WriteLine("Hello World after 5 seconds!");}));// Create a new Reader Thread. This thread will start listening for console inputConsoleReader.BeginReadThread(cts.Token);// Handle incoming messages from the user (Enter key pressed)ConsoleReader.MessageReceived+=(sender,s)=>{// We got a cancellation command! Let's cancel the CancellationTokenSource.if(s.Equals("cancel"))cts.Cancel();};// Start the printing thread.PrintingThread.Start();

For formatted output, use Minecraft's color and formatting code format.

ConsoleWriter.WriteLineFormatted("§aText §cwith §bMixed §1C§2o§3l§4o§5r§6s§a!");

will show up as the following: image

Note

It is important that you use the ConsoleInteractive.ConsoleWriter and ConsoleInteractive.ConsoleReader classes only.

Mixing and matching with System.Console is not supported nor recommended.

Demo

Check out an asciicast demo here! asciicast

About

a user input library for c#

Resources

Stars

9 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages