diff --git a/Terminal.Gui/Drawing/LineCanvas/LineCanvas.cs b/Terminal.Gui/Drawing/LineCanvas/LineCanvas.cs index 8018e16b5..47f08c4ae 100644 --- a/Terminal.Gui/Drawing/LineCanvas/LineCanvas.cs +++ b/Terminal.Gui/Drawing/LineCanvas/LineCanvas.cs @@ -532,8 +532,8 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverHorizontal, - IntersectionType.PassOverVertical + [IntersectionType.PassOverHorizontal, + IntersectionType.PassOverVertical] )) { return IntersectionRuneType.Cross; @@ -541,9 +541,9 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverVertical, + [IntersectionType.PassOverVertical, IntersectionType.StartLeft, - IntersectionType.StartRight + IntersectionType.StartRight] )) { return IntersectionRuneType.Cross; @@ -551,9 +551,9 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverHorizontal, + [IntersectionType.PassOverHorizontal, IntersectionType.StartUp, - IntersectionType.StartDown + IntersectionType.StartDown] )) { return IntersectionRuneType.Cross; @@ -561,10 +561,10 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.StartLeft, + [IntersectionType.StartLeft, IntersectionType.StartRight, IntersectionType.StartUp, - IntersectionType.StartDown + IntersectionType.StartDown] )) { return IntersectionRuneType.Cross; @@ -574,38 +574,22 @@ public class LineCanvas : IDisposable #region Corner Conditions - if (Exactly ( - set, - IntersectionType.StartRight, - IntersectionType.StartDown - )) + if (Exactly (set, CornerIntersections.UpperLeft)) { return IntersectionRuneType.ULCorner; } - if (Exactly ( - set, - IntersectionType.StartLeft, - IntersectionType.StartDown - )) + if (Exactly (set, CornerIntersections.UpperRight)) { return IntersectionRuneType.URCorner; } - if (Exactly ( - set, - IntersectionType.StartUp, - IntersectionType.StartLeft - )) + if (Exactly (set, CornerIntersections.LowerRight)) { return IntersectionRuneType.LRCorner; } - if (Exactly ( - set, - IntersectionType.StartUp, - IntersectionType.StartRight - )) + if (Exactly (set, CornerIntersections.LowerLeft)) { return IntersectionRuneType.LLCorner; } @@ -616,8 +600,8 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverHorizontal, - IntersectionType.StartDown + [IntersectionType.PassOverHorizontal, + IntersectionType.StartDown] )) { return IntersectionRuneType.TopTee; @@ -625,9 +609,9 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.StartRight, + [IntersectionType.StartRight, IntersectionType.StartLeft, - IntersectionType.StartDown + IntersectionType.StartDown] )) { return IntersectionRuneType.TopTee; @@ -635,8 +619,8 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverHorizontal, - IntersectionType.StartUp + [IntersectionType.PassOverHorizontal, + IntersectionType.StartUp] )) { return IntersectionRuneType.BottomTee; @@ -644,9 +628,9 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.StartRight, + [IntersectionType.StartRight, IntersectionType.StartLeft, - IntersectionType.StartUp + IntersectionType.StartUp] )) { return IntersectionRuneType.BottomTee; @@ -654,8 +638,8 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverVertical, - IntersectionType.StartRight + [IntersectionType.PassOverVertical, + IntersectionType.StartRight] )) { return IntersectionRuneType.LeftTee; @@ -663,9 +647,9 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.StartRight, + [IntersectionType.StartRight, IntersectionType.StartDown, - IntersectionType.StartUp + IntersectionType.StartUp] )) { return IntersectionRuneType.LeftTee; @@ -673,8 +657,8 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.PassOverVertical, - IntersectionType.StartLeft + [IntersectionType.PassOverVertical, + IntersectionType.StartLeft] )) { return IntersectionRuneType.RightTee; @@ -682,9 +666,9 @@ public class LineCanvas : IDisposable if (Has ( set, - IntersectionType.StartLeft, + [IntersectionType.StartLeft, IntersectionType.StartDown, - IntersectionType.StartUp + IntersectionType.StartUp] )) { return IntersectionRuneType.RightTee; @@ -712,7 +696,7 @@ public class LineCanvas : IDisposable /// /// /// - private bool Has (HashSet intersects, params IntersectionType [] types) + private bool Has (HashSet intersects, ReadOnlySpan types) { foreach (var type in types) { @@ -724,6 +708,25 @@ public class LineCanvas : IDisposable return true; } + + /// + /// Preallocated arrays for calls to . + /// + /// + /// Optimization to avoid array allocation for each call from array params. Please do not edit the arrays at runtime. :) + /// + /// More ideal solution would be to change to take ReadOnlySpan instead of an array + /// but that would require replacing the HashSet.SetEquals call. + /// + private static class CornerIntersections + { + // Names matching #region "Corner Conditions" IntersectionRuneType + internal static readonly IntersectionType[] UpperLeft = [IntersectionType.StartRight, IntersectionType.StartDown]; + internal static readonly IntersectionType[] UpperRight = [IntersectionType.StartLeft, IntersectionType.StartDown]; + internal static readonly IntersectionType[] LowerRight = [IntersectionType.StartUp, IntersectionType.StartLeft]; + internal static readonly IntersectionType[] LowerLeft = [IntersectionType.StartUp, IntersectionType.StartRight]; + } + private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver { public override void SetGlyphs () diff --git a/docfx/aboutbox.png b/docfx/aboutbox.png index 32404418d..1fbf892c4 100644 Binary files a/docfx/aboutbox.png and b/docfx/aboutbox.png differ diff --git a/docfx/docs/index.md b/docfx/docs/index.md index 2d0386271..11c12d12d 100644 --- a/docfx/docs/index.md +++ b/docfx/docs/index.md @@ -11,7 +11,7 @@ * **[Extensible UI](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.View.html)** - All visible UI elements are subclasses of the `View` class, and these in turn can contain an arbitrary number of sub-views. Dozens of [Built-in Views](views.md) are provided. * **[Keyboard](keyboard.md) and [Mouse](mouse.md) Input** - The library handles all the details of input processing and provides a simple event-based API for applications to consume. * **[Powerful Layout Engine](layout.md)** - The layout engine makes it easy to lay out controls relative to each other and enables dynamic terminal UIs. -* **[Machine, User, and App-Level Configuration](config.md)** - Persistent configuration settings, including overriding default look & feel with Themes, keyboard bindings, and more via the [`ConfigurationManager`](~/api/Terminal.Gui.ConfigurationManager.yml) class. +* **[Machine, User, and App-Level Configuration](config.md)** - Persistent configuration settings, including overriding default look & feel with Themes, keyboard bindings, and more via the [ConfigurationManager](~/api/Terminal.Gui.ConfigurationManager.yml) class. * **[Clipboard support](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.Clipboard.html)** - Cut, Copy, and Paste is provided through the [`Clipboard`] class. * **Multi-tasking** - The [Mainloop](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.MainLoop.html) supports processing events, idle handlers, and timers. Most classes are safe for threading. * **[Reactive Extensions](https://github.com/dotnet/reactive)** - Use reactive extensions and benefit from increased code readability, and the ability to apply the MVVM pattern and [ReactiveUI](https://www.reactiveui.net/) data bindings. See the [source code](https://github.com/gui-cs/Terminal.GuiV2Docs/tree/master/ReactiveExample) of a sample app. @@ -20,17 +20,22 @@ See [What's New in V2 For more](newinv2.md). ## Conceptual Documentation -* [Guide to Migrating from Terminal.Gui v1](migratingfromv1.md) -* [List of Views](views.md) -* [Layout Engine](layout.md) -* [Navigation](navigation.md) -* [Keyboard API](keyboard.md) -* [Mouse API](mouse.md) * [Arrangement API](arrangement.md) * [Configuration and Theme Manager](config.md) -* [Multi-tasking and the Application Main Loop](mainloop.md) +* [Cursor Deep Dive](cursor.md) * [Cross-platform Driver Model](drivers.md) * [Dim.Auto Deep Dive](dimauto.md) +* [Drawing](drawing.md) +* [Events Deep Dive](events.md) +* [Keyboard API](keyboard.md) +* [Layout Engine](layout.md) +* [Migrating from Terminal.Gui v1](migratingfromv1.md) +* [Mouse API](mouse.md) +* [Multi-tasking and the Application Main Loop](mainloop.md) +* [Navigation](navigation.md) +* [View Deep Dive](View.md) +* [Views](views.md) +* [Scrolling Deep Dive](scrolling.md) * [TableView Deep Dive](tableview.md) * [TreeView Deep Dive](treeview.md) diff --git a/docfx/docs/toc.yml b/docfx/docs/toc.yml index 2e80dda9b..6304b7e7d 100644 --- a/docfx/docs/toc.yml +++ b/docfx/docs/toc.yml @@ -6,32 +6,36 @@ href: newinv2.md - name: v1 To v2 Migration href: migratingfromv1.md -- name: View Deep Dive - href: View.md -- name: List of Views - href: views.md -- name: Layout Engine - href: layout.md - name: Arrangement href: arrangement.md -- name: Navigation - href: navigation.md -- name: Scrolling - href: scrolling.md -- name: Keyboard - href: keyboard.md -- name: Mouse - href: mouse.md - name: Configuration href: config.md +- name: Cursor + href: cursor.md +- name: Dim.Auto Deep Dive + href: dimauto.md - name: Drawing href: drawing.md - name: Drivers href: drivers.md +- name: Events Deep Dive + href: events.md +- name: Keyboard + href: keyboard.md +- name: Layout Engine + href: layout.md +- name: Mouse + href: mouse.md - name: Multi-Tasking href: mainloop.md -- name: Dim.Auto Deep Dive - href: dimauto.md +- name: Navigation + href: navigation.md +- name: View Deep Dive + href: View.md +- name: View List + href: views.md +- name: Scrolling + href: scrolling.md - name: TableView Deep Dive href: tableview.md - name: TreeView Deep Dive diff --git a/docfx/images/sample.gif b/docfx/images/sample.gif index 22368dcec..ea82d9096 100644 Binary files a/docfx/images/sample.gif and b/docfx/images/sample.gif differ diff --git a/docfx/images/sample.png b/docfx/images/sample.png deleted file mode 100644 index 27cfe5c81..000000000 Binary files a/docfx/images/sample.png and /dev/null differ diff --git a/docfx/images/wizard.gif b/docfx/images/wizard.gif index 53eb279cf..9e63129bc 100644 Binary files a/docfx/images/wizard.gif and b/docfx/images/wizard.gif differ diff --git a/docfx/index.md b/docfx/index.md index f1a19defe..0333b5457 100644 --- a/docfx/index.md +++ b/docfx/index.md @@ -8,7 +8,7 @@ A toolkit for building rich console apps for .NET that run on Windows, the Mac, ## Terminal.Gui API Documentation -* [Conceptual Documentation](docs/index.md) +* [Conceptual Docs & Deep Dives](docs/index.md) * [API Reference](~/api/Terminal.Gui.yml) ## UI Catalog diff --git a/docfx/toc.yml b/docfx/toc.yml index 01e26dbc8..94ab08013 100644 --- a/docfx/toc.yml +++ b/docfx/toc.yml @@ -1,4 +1,4 @@ -- name: Conceptual Docs +- name: Conceptual Docs & Deep Dives href: docs/ - name: API