GithubHelp home page GithubHelp logo

mterminal.wpf's Introduction

Nuget Version .NET Version 6.0

MTerminal provides a "console" for the WPF apps.

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.

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.

mterminal.wpf's People

Contributors

mortuusars avatar

Watchers

 avatar

mterminal.wpf's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.