gui-cs / TerminalGuiDesigner

Forms Designer for Terminal.Gui (aka gui.cs)
MIT License
423 stars 28 forks source link
csharp curses designer dotnet editor gui terminal toolkit ui

Terminal Gui Designer

example workflow NuGet Badge Code Coverage

Cross platform designer for Terminal.Gui applications.

Built with CodeDom and Roslyn, TerminalGuiDesigner lets you create complicated Views with drag and drop just like the WinForms designer you know and love (or hate).

V1

Install the tool from NuGet or follow the Hello World Tutorial:

dotnet tool install --global TerminalGuiDesigner

Update to the latest version using

dotnet tool update --global TerminalGuiDesigner

This project is in alpha. See the feature list for progress.

V2

If you are targetting Terminal.Gui version 2 (currently pre-alpha) then you will want to install version 2 of the designer

dotnet tool install --global TerminalGuiDesigner --prerelease

Ensure that you match the Terminal.Gui library version you reference to the designer version.

Demo

long-demo

Building


Build using the dotnet 6.0 sdk

cd src
dotnet run

Usage


Install the dotnet sdk and create a new console application with references to Terminal.Gui. Install the TerminalGuiDesigner and create a new dialog:

dotnet new console -n hello
cd hello
dotnet add package Terminal.Gui
dotnet tool install --global TerminalGuiDesigner
TerminalGuiDesigner MyDialog.cs

Enter a namespace then add a Button to the view. Save with Ctrl+S. Exit the designer with Ctrl+Q.

Enter the following into Program.cs

using Terminal.Gui;

Application.Init();

Application.Run(new YourNamespace.MyDialog());

Application.Shutdown();

Run your program with dotnet run

You can add new code to MyDialog.cs but avoid making any changes to MyDialog.Designer.cs as this will be rewritten when saving.

For example in MyDialog.cs after InitializeComponent() add the following:

button1.Accept += ()=>MessageBox.Query("Hello","Hello World","Ok");

Now when run clicking the button will trigger a message box.

msgbox

You can re-open the designer by running it from the command line with the file you want to edit/create.

TerminalGuiDesigner MyDialog.cs

You can remove the tool using the following:

dotnet tool uninstall --global TerminalGuiDesigner

Troubleshooting

If when running the tool you have issues seeing the colors add the --usc flag:

TerminalGuiDesigner --usc

The designer is built to be robust and has top level catch blocks but if you are still able to crash it you may find your console blocking input. If this happens you should be able to fix your console by typing reset<enter> but also :heart: please report it :heart:

Keybindings & Controls


You can change keybindings by copying Keys.yaml into your current directory.

To edit MenuBar items use the following controls

Key Action
Shift Up/Down Move selected menu item up/down
Shift Right Move selected menu item to a submenu of the one above
Shift Left Move selected sub menu item up a level
Del Remove selected menu item
Enter Add a new menu item
Typing Edit the Title of the selected item
Ctrl + T Set Shortcut
Ctrl + R Set menu field name

New root level menus can be added by right clicking the MenuBar and selecting 'Add Menu'.

You can create a menu separator by typing ---

Features


The following feature list shows the current capabilities and the roadmap. Features in italics are experimental and require passing the -e flag when starting application.

Class Diagram


Terminal.Gui Class Diagram