This document provides an overview of the new features and improvements in Terminal.Gui v2.
For information on how to port code from v1 to v2, see the v1 To v2 Migration Guide.
Apps built with Terminal.Gui now feel modern thanks to these improvements:
Border
, Margin
, and Padding
property on all views. This simplifies View development and enables a sophisticated look and feel. See Adornments for details.LineCanvas
provides auto join, a smart TUI drawing system that automatically selects the correct line/box drawing glyphs for intersections making drawing complex shapes easy. See Line Canvas for details.The entire library has been reviewed and simplified. As a result, the API is more consistent and uses modern .NET API standards (e.g. for events). This refactoring resulted in the removal of thousands of lines of code, better unit tests, and higher performance than v1. See Simplified API for details.
View
ImprovementsView
was derived from Responder
which supported IDisposable
. In v2, Responder
has been removed and View
is the base-class supporting IDisposable
.Application.Init
no longer automatically creates a toplevel or sets Applicaton.Top
; app developers must explicitly create the toplevel view and pass it to Appliation.Run
(or use Application.Run<myTopLevel>
). Developers are responsible for calling Dispose
on any toplevel they create before exiting.Viewport
: Margin
, Border
, and Padding
.ScrollView
, or managing the complexity of ScrollBarView
directly. In v2, the base-View class supports scrolling inherently. The area of a view visible to the user at a given moment was previously a rectangle called Bounds
. Bounds.Location
was always Point.Empty
. In v2 the visible area is a rectangle called Viewport
which is a protal into the Views content, which can be bigger (or smaller) than the area visible to the user. Causing a view to scroll is as simple as changing View.Viewport.Location
. The View's content described by View.ContentSize
. See Layout for details.Dim.Auto
- Automatically sizes the view to fitthe view's Text, SubViews, or ContentArea.Pos.AnchorEnd ()
- New to v2 is Pos.AnchorEnd ()
(with no parameters) which allows a view to be anchored to the right or bottom of the Superview.Pos.Align ()
- Aligns a set of views horizontally or vertically (left, rigth, center, etc...).Bar
Bar
Bar
TreeView
`. See FileDialog for details.Terminal.Gui now supports a configuration manager enabling library and app settings to be persisted and loaded from the file system. See Configuration Manager for details.
The API for handling keyboard input is significantly improved. See Keyboard API.
Key
class replaces the KeyEvent
struct and provides a platform-independent abstraction for common keyboard operations. It is used for processing keyboard input and raising keyboard events. This class provides a high-level abstraction with helper methods and properties for common keyboard operations. Use this class instead of the low-level KeyCode
enum when possible. See Key for more details.View.AddCommand()
. Use the View.Keybindings
to configure the key bindings.The API for mouse input is now internally consistent and easiser to use.
MouseEvent
class replaces MouseEventEventArgs
.View.Highlight
event to have the view be visibly highlighted on various mouse events.View.WantContinousButtonPresses = true
to ahve their Command.Accept
command be invoked repeatedly as the user holds a mouse button down on the view.