Skip to content

Commit

Permalink
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
tig committed Feb 27, 2025
2 parents ebbcaff + b62e826 commit 9c3be44
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 71 deletions.
93 changes: 48 additions & 45 deletions Terminal.Gui/Drawing/LineCanvas/LineCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,39 +532,39 @@ private IntersectionRuneType GetRuneTypeForIntersects (ReadOnlySpan<Intersection

if (Has (
set,
IntersectionType.PassOverHorizontal,
IntersectionType.PassOverVertical
[IntersectionType.PassOverHorizontal,
IntersectionType.PassOverVertical]
))
{
return IntersectionRuneType.Cross;
}

if (Has (
set,
IntersectionType.PassOverVertical,
[IntersectionType.PassOverVertical,
IntersectionType.StartLeft,
IntersectionType.StartRight
IntersectionType.StartRight]
))
{
return IntersectionRuneType.Cross;
}

if (Has (
set,
IntersectionType.PassOverHorizontal,
[IntersectionType.PassOverHorizontal,
IntersectionType.StartUp,
IntersectionType.StartDown
IntersectionType.StartDown]
))
{
return IntersectionRuneType.Cross;
}

if (Has (
set,
IntersectionType.StartLeft,
[IntersectionType.StartLeft,
IntersectionType.StartRight,
IntersectionType.StartUp,
IntersectionType.StartDown
IntersectionType.StartDown]
))
{
return IntersectionRuneType.Cross;
Expand All @@ -574,38 +574,22 @@ private IntersectionRuneType GetRuneTypeForIntersects (ReadOnlySpan<Intersection

#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;
}
Expand All @@ -616,75 +600,75 @@ private IntersectionRuneType GetRuneTypeForIntersects (ReadOnlySpan<Intersection

if (Has (
set,
IntersectionType.PassOverHorizontal,
IntersectionType.StartDown
[IntersectionType.PassOverHorizontal,
IntersectionType.StartDown]
))
{
return IntersectionRuneType.TopTee;
}

if (Has (
set,
IntersectionType.StartRight,
[IntersectionType.StartRight,
IntersectionType.StartLeft,
IntersectionType.StartDown
IntersectionType.StartDown]
))
{
return IntersectionRuneType.TopTee;
}

if (Has (
set,
IntersectionType.PassOverHorizontal,
IntersectionType.StartUp
[IntersectionType.PassOverHorizontal,
IntersectionType.StartUp]
))
{
return IntersectionRuneType.BottomTee;
}

if (Has (
set,
IntersectionType.StartRight,
[IntersectionType.StartRight,
IntersectionType.StartLeft,
IntersectionType.StartUp
IntersectionType.StartUp]
))
{
return IntersectionRuneType.BottomTee;
}

if (Has (
set,
IntersectionType.PassOverVertical,
IntersectionType.StartRight
[IntersectionType.PassOverVertical,
IntersectionType.StartRight]
))
{
return IntersectionRuneType.LeftTee;
}

if (Has (
set,
IntersectionType.StartRight,
[IntersectionType.StartRight,
IntersectionType.StartDown,
IntersectionType.StartUp
IntersectionType.StartUp]
))
{
return IntersectionRuneType.LeftTee;
}

if (Has (
set,
IntersectionType.PassOverVertical,
IntersectionType.StartLeft
[IntersectionType.PassOverVertical,
IntersectionType.StartLeft]
))
{
return IntersectionRuneType.RightTee;
}

if (Has (
set,
IntersectionType.StartLeft,
[IntersectionType.StartLeft,
IntersectionType.StartDown,
IntersectionType.StartUp
IntersectionType.StartUp]
))
{
return IntersectionRuneType.RightTee;
Expand Down Expand Up @@ -712,7 +696,7 @@ private IntersectionRuneType GetRuneTypeForIntersects (ReadOnlySpan<Intersection
/// <param name="intersects"></param>
/// <param name="types"></param>
/// <returns></returns>
private bool Has (HashSet<IntersectionType> intersects, params IntersectionType [] types)
private bool Has (HashSet<IntersectionType> intersects, ReadOnlySpan<IntersectionType> types)
{
foreach (var type in types)
{
Expand All @@ -724,6 +708,25 @@ private bool Has (HashSet<IntersectionType> intersects, params IntersectionType
return true;
}


/// <summary>
/// Preallocated arrays for <see cref="GetRuneTypeForIntersects"/> calls to <see cref="Exactly"/>.
/// </summary>
/// <remarks>
/// 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 <see cref="Exactly"/> to take ReadOnlySpan instead of an array
/// but that would require replacing the HashSet.SetEquals call.
/// </remarks>
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 ()
Expand Down
Binary file modified docfx/aboutbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 13 additions & 8 deletions docfx/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)

Expand Down
36 changes: 20 additions & 16 deletions docfx/docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified docfx/images/sample.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docfx/images/sample.png
Binary file not shown.
Binary file modified docfx/images/wizard.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docfx/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docfx/toc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- name: Conceptual Docs
- name: Conceptual Docs & Deep Dives
href: docs/

- name: API
Expand Down

0 comments on commit 9c3be44

Please sign in to comment.