|
%!s(int64=2) %!d(string=hai) anos | |
---|---|---|
.devcontainer | %!s(int64=3) %!d(string=hai) anos | |
.github | %!s(int64=3) %!d(string=hai) anos | |
Example | %!s(int64=3) %!d(string=hai) anos | |
FSharpExample | %!s(int64=3) %!d(string=hai) anos | |
ReactiveExample | %!s(int64=3) %!d(string=hai) anos | |
StandaloneExample | %!s(int64=3) %!d(string=hai) anos | |
Terminal.Gui | %!s(int64=2) %!d(string=hai) anos | |
UICatalog | %!s(int64=2) %!d(string=hai) anos | |
UnitTests | %!s(int64=2) %!d(string=hai) anos | |
docfx | %!s(int64=2) %!d(string=hai) anos | |
docs | %!s(int64=2) %!d(string=hai) anos | |
.editorconfig | %!s(int64=5) %!d(string=hai) anos | |
.gitattributes | %!s(int64=5) %!d(string=hai) anos | |
.gitignore | %!s(int64=3) %!d(string=hai) anos | |
CODE_OF_CONDUCT.md | %!s(int64=5) %!d(string=hai) anos | |
CONTRIBUTING.md | %!s(int64=3) %!d(string=hai) anos | |
LICENSE | %!s(int64=7) %!d(string=hai) anos | |
README.md | %!s(int64=2) %!d(string=hai) anos | |
Terminal.sln | %!s(int64=3) %!d(string=hai) anos | |
global.json | %!s(int64=3) %!d(string=hai) anos | |
packages.config | %!s(int64=5) %!d(string=hai) anos | |
pull_request_template.md | %!s(int64=3) %!d(string=hai) anos |
A toolkit for building rich console apps for .NET, .NET Core, and Mono that works on Windows, the Mac, and Linux/Unix.
The Documentation matches the most recent Nuget release from the main
branch ()
Clipboard
class.View
class, and these in turn can contain an arbitrary number of sub-views.dotnet run --project UICatalog
to run the UI Catalog.System.Reactive
and ReactiveUI
with Terminal.Gui
. The app uses the MVVM architecture that may seem familiar to folks coming from WPF, Xamarin Forms, UWP, Avalonia, or Windows Forms. In this app, we implement the data bindings using ReactiveUI WhenAnyValue
syntax and Pharmacist — a tool that converts all events in a NuGet package into observable wrappers.demo.cs
) - Run dotnet run
in the Example
directory to run the simple demo.StandaloneExample
directory. Run dotnet run
in directory to test.Out-ConsoleGridView
- OCGV
sends the output from a command to an interactive table.See the Terminal.Gui/
README for an overview of how the library is structured. The Conceptual Documentation provides insight into core concepts.
(This code uses C# 9.0 Top-level statements.)
using Terminal.Gui;
using NStack;
Application.Init();
var top = Application.Top;
// Creates the top-level window to show
var win = new Window("MyApp")
{
X = 0,
Y = 1, // Leave one row for the toplevel menu
// By using Dim.Fill(), it will automatically resize without manual intervention
Width = Dim.Fill(),
Height = Dim.Fill()
};
top.Add(win);
// Creates a menubar, the item "New" has a help menu.
var menu = new MenuBar(new MenuBarItem[] {
new MenuBarItem ("_File", new MenuItem [] {
new MenuItem ("_New", "Creates new file", null),
new MenuItem ("_Close", "",null),
new MenuItem ("_Quit", "", () => { if (Quit ()) top.Running = false; })
}),
new MenuBarItem ("_Edit", new MenuItem [] {
new MenuItem ("_Copy", "", null),
new MenuItem ("C_ut", "", null),
new MenuItem ("_Paste", "", null)
})
});
top.Add(menu);
static bool Quit()
{
var n = MessageBox.Query(50, 7, "Quit Demo", "Are you sure you want to quit this demo?", "Yes", "No");
return n == 0;
}
var login = new Label("Login: ") { X = 3, Y = 2 };
var password = new Label("Password: ")
{
X = Pos.Left(login),
Y = Pos.Top(login) + 1
};
var loginText = new TextField("")
{
X = Pos.Right(password),
Y = Pos.Top(login),
Width = 40
};
var passText = new TextField("")
{
Secret = true,
X = Pos.Left(loginText),
Y = Pos.Top(password),
Width = Dim.Width(loginText)
};
// Add some controls,
win.Add(
// The ones with my favorite layout system, Computed
login, password, loginText, passText,
// The ones laid out like an australopithecus, with Absolute positions:
new CheckBox(3, 6, "Remember me"),
new RadioGroup(3, 8, new ustring[] { "_Personal", "_Company" }, 0),
new Button(3, 14, "Ok"),
new Button(10, 14, "Cancel"),
new Label(3, 18, "Press F9 or ESC plus 9 to activate the menubar")
);
Application.Run();
Application.Shutdown();
The example above shows adding views using both styles of layout supported by Terminal.Gui: Absolute layout and Computed layout.
Alternatively, you can encapsulate the app behavior in a new Window
-derived class, say App.cs
containing the code above, and simplify your Main
method to:
using Terminal.Gui;
class Demo {
static void Main ()
{
Application.Run<App> ();
Application.Shutdown ();
}
}
Use NuGet to install the Terminal.Gui
NuGet package: https://www.nuget.org/packages/Terminal.Gui
To install Terminal.Gui into a .NET Core project, use the dotnet
CLI tool with following command.
dotnet add package Terminal.Gui
See CONTRIBUTING.md for instructions for downloading and forking the source.
dotnet build
in the root directory). Run UICatalog
with dotnet run --project UICatalog
.Terminal.Gui.sln
with Visual Studio 2019.See CONTRIBUTING.md.
Debates on architecture and design can be found in Issues tagged with design.
This is an updated version of gui.cs that Miguel wrote for mono-curses in 2007.
The original gui.cs was a UI toolkit in a single file and tied to curses. This version tries to be console-agnostic and instead of having a container/widget model, only uses Views (which can contain subviews) and changes the rendering model to rely on damage regions instead of burdening each view with the details.
A presentation of this was part of the Retro.NET talk at .NET Conf 2018 Slides
The most recent release notes can be found in the Terminal.Gui.csproj file.