Davicro.ConsoleView 0.0.1-alpha

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

About

ConsoleView is a utility library created for personal use in my console applications.

Features:

  • Displaying colored text.
  • Hiding and showing text.
  • Grouping view elements into panels and switching between different panels.
  • Handling user prompts as part of a panel.
  • Menus with selectable options through number and letter keys.
  • Input handling with support for keybinds.

Limitations:

  • Text is static and cannot be modified beyond hiding/showing.
  • Text that has been pushed outside of the buffer (by the console scrolling down) cannot be hidden.
  • Window resizing is not handled.
  • No way to make specific layouts (such as text in the middle, top right, top left, etc.), everything is just printed top to bottom.
  • Menus can only display a set amount of options.

Installation

If you want to use this library in your project (for some reason), you can add it as a nuget dependency:

dotnet add package Davicro.ConsoleView

Basic usage

You can find a sample app here.

Basic text

ConsoleText text = new ConsoleText("Hello world!");
text.Show();

Basic panel

ConsolePanel panel = new ConsolePanel(
    new ConsoleText("Hello, world!"),
    new ConsoleText("Goodbye, world!")
);
panel.Show();

Stacking panels

ViewStack viewStack = new ViewStack();
ConsolePanel panel1 = new ConsolePanel(
    new ConsoleText("This is panel 1!"),
    new ConsoleText("Cool!")
);
ConsolePanel panel2 = new ConsolePanel(
    new ConsoleText("This is panel 2!"),
    new ConsoleText("Also cool?")
);
viewStack.Push(panel1); // Panel 1 is now visible
viewStack.Push(panel2); // Panel 2 is now visible
viewStack.Pop(); // Panel 1 is now visible

Panel with prompt

ConsolePanel panel = new ConsolePanel(
    new ConsoleText("Press enter to hide...")
);
ConsoleKeyPrompt prompt = ConsoleKeyPrompt.UntilKeyPressed(ConsoleKey.Enter, panel.Hide);
panel.AddElement(prompt);
panel.Show();
while(panel.CanHandleInput())
    panel.OnInput(Console.ReadKey());

Global input handling

Input is better handled globally in a dedicated loop rather than for every element individually.

ViewStack viewStack = new ViewStack();
// ...
while(viewStack.Count > 0)
{
    if(viewStack.CurrentView is IInputListener<ConsoleKeyInfo> listener 
    && listener.CanHandleInput())
    {
        listener.OnInput(Console.ReadKey());
    }
}

Basic Menu

ConsolePanel panel = new ConsolePanel();
ConsoleMenu<string> menu = new ConsoleMenu<string>(["yes!", "no"], (self, index, option) => {
    panel.RemoveElement(self);
    panel.AddElement(new ConsoleText("You picked:"+option));
});
panel.AddElement(menu);
panel.Show();
// [Input handling excluded]
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.
  • net8.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 Downloads Last Updated
0.0.1-alpha 70 8/10/2026