Table of Contents

Getting Started

Paste these commands into your favorite terminal on Windows, Mac, or Linux. This will install the Terminal.Gui.Templates, create a new "Hello World" TUI app, and run it.

(Press Esc to exit the app)

dotnet new install Terminal.Gui.Templates@2.0.*
dotnet new tui-simple -n myproj
cd myproj
dotnet run

Adding Terminal.Gui to a Project

To install Terminal.Gui from Nuget into a .NET Core project, use the dotnet CLI tool with this command.

dotnet add package Terminal.Gui

Using the Templates

Use the Terminal.Gui.Templates:

dotnet new install Terminal.Gui.Templates@2.0.*

Sample Usage in C#

The following example shows a basic Terminal.Gui application using the modern instance-based model:

using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;

using IApplication app = Application.Create ();
app.Init ();

using Window window = new () { Title = "Hello World (Esc to quit)" };
Label label = new ()
{
    Text = "Hello, Terminal.Gui v2!",
    X = Pos.Center (),
    Y = Pos.Center ()
};
window.Add (label);

app.Run (window);

Key aspects of the modern model:

  • Use Application.Create() to create an IApplication instance
  • The application initializes automatically when you call Run<T>()
  • Use app.Run<ExampleWindow>() to run a window that implements IRunnable
  • Call app.Dispose() to clean up resources and restore the terminal
  • Event handling uses Accepting event instead of legacy Accept event
  • Set e.Handled = true in event handlers to prevent further processing

When run the application looks as follows:

Simple Usage app

Building the Library and Running the Examples

  • Windows, Mac, and Linux - Build and run using the .NET SDK command line tools (dotnet build in the root directory). Run UICatalog with dotnet run --project UICatalog.
  • Additional examples are available in gui-cs/Examples.
  • Windows - Open Terminal.slnx with Visual Studio 2022 (17.10+).