MTerminal.WPF 0.1.3

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

// Install MTerminal.WPF as a Cake Tool
#tool nuget:?package=MTerminal.WPF&version=0.1.3

<div align="center">

.NET Version 6.0

</div>

<div align="center"> <h2>MTerminal provides a "console" for the WPF apps.</h2>

Terminal is a simple WPF window that can display text and has an input box for commands. Can be used as more user-friendly Command-Line Interface for simple apps or as a convenient debug tool for your WPF app. </div>

Features:

  • Similar to the System.Console
  • Can be used as target output of a Console
  • Supports colored text
  • Autocomplete for the commands
  • Customizable style of the window
  • Has two built-in commands:
    • help: shows information about available commands
    • clear: clears the screen

Basic usage:

// Show the Terminal window:
Terminal.Show();

//Write a colored message to the Terminal:
Terminal.WriteLine("Hello World!", Colors.LightBlue);

Commands overview:

Basic working command consists of two elements:

  • Command name/ID (this is what typed to invoke it)
  • Action<string[]> - code that will be executed when command is invoked.

Command also has some additional properties but they are not essential.

Arguments

When command is invoked - all text that was typed after a command id will be passed to the command as an argument. Args work as the regular app args do:

  • It's a array of strings separated by spaces
  • Text encased in quotes counts as 1 argument

Adding a command:

Terminal.Commands.Add(new TerminalCommand("exit", "Exits the app", (args) => App.Shutdown()));

Read functionality:

Terminal supports Read, ReadLine and ReadKey. They work as expected:

  • Read returns next char that is typed in by user;
  • ReadLine waits for the return key, after which it returns text that was inputed;
  • ReadKey returns a key that was pressed;

But - they are implemented as Tasks, which means to use it properly they should be awaited.

Warning: if called from the UI thread with waiting (such as GetAwaiter().GetResult()) they will hang the app in a deadlock, as the UI thread is waiting and cannot process user input.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows 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.

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
0.1.3 509 1/29/2022
0.1.2 417 1/29/2022
0.1.1 426 1/29/2022
0.1.0 433 1/28/2022

0.1.3 - Fixed getting style properties from different thread.
0.1.2 - Fixed version number. Small fix in 'help' command.
Added Color extension method to change opacity.
0.1.1 - Fixed Show after window was closed.
0.1.0 - Initial release.