From 5a37db7c18394ff9b1a3a5830b038748e7934814 Mon Sep 17 00:00:00 2001 From: tznind Date: Fri, 10 Feb 2023 08:23:58 +0000 Subject: [PATCH 1/5] Start refactoring LineCanvas for mixing line style support (e.g. double into single) --- Terminal.Gui/Core/Graphs/LineCanvas.cs | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Terminal.Gui/Core/Graphs/LineCanvas.cs b/Terminal.Gui/Core/Graphs/LineCanvas.cs index 04583518e..5e51cb164 100644 --- a/Terminal.Gui/Core/Graphs/LineCanvas.cs +++ b/Terminal.Gui/Core/Graphs/LineCanvas.cs @@ -14,6 +14,11 @@ namespace Terminal.Gui.Graphs { private List lines = new List (); + Dictionary runeResolvers = new Dictionary { + {IntersectionRuneType.ULCorner,new ULIntersectionRuneResolver()}, + // TODO: Add other resolvers + }; + /// /// Add a new line to the canvas starting at . /// Use positive for Right and negative for Left @@ -84,22 +89,51 @@ namespace Terminal.Gui.Graphs { } } + private abstract class IntersectionRuneResolver + { + public Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects) + { + var useDouble = intersects.Any (i => i.Line.Style == BorderStyle.Double && i.Line.Length != 0); + var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0); + + return GetRuneForIntersects (driver, intersects, useDouble, useRounded); + } + + protected abstract Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded); + } + + private class ULIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? driver.ULDCorner : useRounded ? driver.ULRCorner : driver.ULCorner; + } + } + private Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects) { if (!intersects.Any ()) return null; var runeType = GetRuneTypeForIntersects (intersects); + + if(runeResolvers.ContainsKey (runeType)) { + return runeResolvers [runeType].GetRuneForIntersects (driver, intersects); + } + + // TODO: Remove these two once we have all of the below ported to IntersectionRuneResolvers var useDouble = intersects.Any (i => i.Line.Style == BorderStyle.Double && i.Line.Length != 0); var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0); + // TODO: Turn all these into classes switch (runeType) { case IntersectionRuneType.None: return null; case IntersectionRuneType.Dot: return (Rune)'.'; case IntersectionRuneType.ULCorner: - return useDouble ? driver.ULDCorner : useRounded ? driver.ULRCorner : driver.ULCorner; case IntersectionRuneType.URCorner: return useDouble ? driver.URDCorner : useRounded ? driver.URRCorner : driver.URCorner; case IntersectionRuneType.LLCorner: From 5af44d2c537767032a29ac054db2710b9a0a7466 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 10 Feb 2023 17:10:00 +0000 Subject: [PATCH 2/5] Add remaining resolvers --- Terminal.Gui/Core/Graphs/LineCanvas.cs | 106 ++++++++++++++++++++----- 1 file changed, 86 insertions(+), 20 deletions(-) diff --git a/Terminal.Gui/Core/Graphs/LineCanvas.cs b/Terminal.Gui/Core/Graphs/LineCanvas.cs index 5e51cb164..a5406bb31 100644 --- a/Terminal.Gui/Core/Graphs/LineCanvas.cs +++ b/Terminal.Gui/Core/Graphs/LineCanvas.cs @@ -16,6 +16,17 @@ namespace Terminal.Gui.Graphs { Dictionary runeResolvers = new Dictionary { {IntersectionRuneType.ULCorner,new ULIntersectionRuneResolver()}, + {IntersectionRuneType.URCorner,new URIntersectionRuneResolver()}, + {IntersectionRuneType.LLCorner,new LLIntersectionRuneResolver()}, + {IntersectionRuneType.LRCorner,new LRIntersectionRuneResolver()}, + + {IntersectionRuneType.TopTee,new TopTeeIntersectionRuneResolver()}, + {IntersectionRuneType.LeftTee,new LeftTeeIntersectionRuneResolver()}, + {IntersectionRuneType.RightTee,new RightTeeIntersectionRuneResolver()}, + {IntersectionRuneType.BottomTee,new BottomTeeIntersectionRuneResolver()}, + + + {IntersectionRuneType.Crosshair,new CrosshairIntersectionRuneResolver()}, // TODO: Add other resolvers }; @@ -111,6 +122,78 @@ namespace Terminal.Gui.Graphs { return useDouble ? driver.ULDCorner : useRounded ? driver.ULRCorner : driver.ULCorner; } } + private class URIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? driver.URDCorner : useRounded ? driver.URRCorner : driver.URCorner; + } + } + private class LLIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? driver.LLDCorner : useRounded ? driver.LLRCorner : driver.LLCorner; + } + } + private class LRIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? driver.LRDCorner : useRounded ? driver.LRRCorner : driver.LRCorner; + } + } + private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? '╦' : driver.TopTee; + } + } + private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? '╠' : driver.LeftTee; + } + } + private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? '╣' : driver.RightTee; + } + } + private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? '╩' : driver.BottomTee; + } + } + private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + { + // TODO: Handle all relevant permutations of double lines into single lines + // to make F type borders instead. + return useDouble ? '╬' : '┼'; + } + } private Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects) { @@ -127,36 +210,19 @@ namespace Terminal.Gui.Graphs { var useDouble = intersects.Any (i => i.Line.Style == BorderStyle.Double && i.Line.Length != 0); var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0); - // TODO: Turn all these into classes + // TODO: maybe make these resolvers to for simplicity? + // or for dotted lines later on or that kind of thing? switch (runeType) { case IntersectionRuneType.None: return null; case IntersectionRuneType.Dot: return (Rune)'.'; - case IntersectionRuneType.ULCorner: - case IntersectionRuneType.URCorner: - return useDouble ? driver.URDCorner : useRounded ? driver.URRCorner : driver.URCorner; - case IntersectionRuneType.LLCorner: - return useDouble ? driver.LLDCorner : useRounded ? driver.LLRCorner : driver.LLCorner; - case IntersectionRuneType.LRCorner: - return useDouble ? driver.LRDCorner : useRounded ? driver.LRRCorner : driver.LRCorner; - case IntersectionRuneType.TopTee: - return useDouble ? '╦' : driver.TopTee; - case IntersectionRuneType.BottomTee: - return useDouble ? '╩' : driver.BottomTee; - case IntersectionRuneType.RightTee: - return useDouble ? '╣' : driver.RightTee; - case IntersectionRuneType.LeftTee: - return useDouble ? '╠' : driver.LeftTee; - case IntersectionRuneType.Crosshair: - return useDouble ? '╬' : '┼'; case IntersectionRuneType.HLine: return useDouble ? driver.HDLine : driver.HLine; case IntersectionRuneType.VLine: return useDouble ? driver.VDLine : driver.VLine; - default: throw new ArgumentOutOfRangeException (nameof (runeType)); + default: throw new Exception ("Could not find resolver or switch case for " + nameof (runeType) + ":" + runeType); } - } From f716dbe596c7086754278aba54e36d3a63b199b4 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 10 Feb 2023 23:29:07 +0000 Subject: [PATCH 3/5] Implement corner border style mixing in LineCanvas --- Terminal.Gui/Core/Graphs/LineCanvas.cs | 85 ++++++++++++++++++++------ UnitTests/LineCanvasTests.cs | 63 +++++++++++++++++++ 2 files changed, 128 insertions(+), 20 deletions(-) diff --git a/Terminal.Gui/Core/Graphs/LineCanvas.cs b/Terminal.Gui/Core/Graphs/LineCanvas.cs index a5406bb31..356b87493 100644 --- a/Terminal.Gui/Core/Graphs/LineCanvas.cs +++ b/Terminal.Gui/Core/Graphs/LineCanvas.cs @@ -113,40 +113,85 @@ namespace Terminal.Gui.Graphs { protected abstract Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded); } - private class ULIntersectionRuneResolver : IntersectionRuneResolver - { + private abstract class CornerIntersectionRuneResolver : IntersectionRuneResolver { protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? driver.ULDCorner : useRounded ? driver.ULRCorner : driver.ULCorner; + + bool doubleHorizontal = intersects.Any(l=>l.Line.Orientation == Orientation.Horizontal && l.Line.Style == BorderStyle.Double); + bool doubleVertical = intersects.Any(l=>l.Line.Orientation == Orientation.Vertical && l.Line.Style == BorderStyle.Double); + + return GetRuneForIntersects(driver,useRounded,doubleHorizontal,doubleVertical); + } + + protected abstract Rune? GetRuneForIntersects(ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical); + } + + private class ULIntersectionRuneResolver : CornerIntersectionRuneResolver + { + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) + { + if(doubleHorizontal) + { + return doubleVertical ? driver.ULDCorner : '╒'; + } + + if(doubleVertical) + { + return '╓'; + } + + return useRounded ? driver.ULRCorner : driver.ULCorner; } } - private class URIntersectionRuneResolver : IntersectionRuneResolver + private class URIntersectionRuneResolver : CornerIntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? driver.URDCorner : useRounded ? driver.URRCorner : driver.URCorner; + if(doubleHorizontal) + { + return doubleVertical ? driver.URDCorner : '╕'; + } + + if(doubleVertical) + { + return '╖'; + } + + return useRounded ? driver.URRCorner : driver.URCorner; } } - private class LLIntersectionRuneResolver : IntersectionRuneResolver + private class LLIntersectionRuneResolver : CornerIntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? driver.LLDCorner : useRounded ? driver.LLRCorner : driver.LLCorner; + if(doubleHorizontal) + { + return doubleVertical ? driver.LLDCorner : '╘'; + } + + if(doubleVertical) + { + return '╙'; + } + + return useRounded ? driver.LLRCorner : driver.LLCorner; } } - private class LRIntersectionRuneResolver : IntersectionRuneResolver + private class LRIntersectionRuneResolver : CornerIntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? driver.LRDCorner : useRounded ? driver.LRRCorner : driver.LRCorner; + if(doubleHorizontal) + { + return doubleVertical ? driver.LRDCorner : '╛'; + } + + if(doubleVertical) + { + return '╜'; + } + + return useRounded ? driver.LRRCorner : driver.LRCorner; } } private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver diff --git a/UnitTests/LineCanvasTests.cs b/UnitTests/LineCanvasTests.cs index 35c657361..2a5644bb4 100644 --- a/UnitTests/LineCanvasTests.cs +++ b/UnitTests/LineCanvasTests.cs @@ -218,6 +218,69 @@ namespace Terminal.Gui.Core { TestHelpers.AssertDriverContentsAre (looksLike, output); } + + [Theory, AutoInitShutdown] + [InlineData(BorderStyle.Single)] + [InlineData(BorderStyle.Rounded)] + public void TestLineCanvas_Window_DoubleTop_SingleSides (BorderStyle thinStyle) + { + var v = GetCanvas (out var canvas); + + // outer box + canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Double); + canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, thinStyle); + canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, BorderStyle.Double); + canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, thinStyle); + + + canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Double); + canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Double); + + v.Redraw (v.Bounds); + +// TODO: Fix those Ts! + string looksLike = +@" +╒════╦═══╕ +│ ║ │ +╠════╬═══╣ +│ ║ │ +╘════╩═══╛ +"; + TestHelpers.AssertDriverContentsAre (looksLike, output); + } + + [Theory, AutoInitShutdown] + [InlineData(BorderStyle.Single)] + [InlineData(BorderStyle.Rounded)] + public void TestLineCanvas_Window_SingleTop_DoubleSides (BorderStyle thinStyle) + { + var v = GetCanvas (out var canvas); + + // outer box + canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, thinStyle); + canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Double); + canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal,thinStyle); + canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, BorderStyle.Double); + + + canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Double); + canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Double); + + v.Redraw (v.Bounds); + +// TODO: Fix those Ts! + string looksLike = +@" +╓────╦───╖ +║ ║ ║ +╠════╬═══╣ +║ ║ ║ +╙────╩───╜ +"; + TestHelpers.AssertDriverContentsAre (looksLike, output); + } + private View GetCanvas (out LineCanvas canvas) { var v = new View { From a443ec7986cb19cedc4696090ce53e0b0e082567 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 11 Feb 2023 00:03:37 +0000 Subject: [PATCH 4/5] Refactor and simplify resolvers --- Terminal.Gui/Core/Graphs/LineCanvas.cs | 166 ++++++++++--------------- UnitTests/LineCanvasTests.cs | 23 ++-- 2 files changed, 79 insertions(+), 110 deletions(-) diff --git a/Terminal.Gui/Core/Graphs/LineCanvas.cs b/Terminal.Gui/Core/Graphs/LineCanvas.cs index 356b87493..ab45c0264 100644 --- a/Terminal.Gui/Core/Graphs/LineCanvas.cs +++ b/Terminal.Gui/Core/Graphs/LineCanvas.cs @@ -102,142 +102,112 @@ namespace Terminal.Gui.Graphs { private abstract class IntersectionRuneResolver { - public Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects) - { - var useDouble = intersects.Any (i => i.Line.Style == BorderStyle.Double && i.Line.Length != 0); - var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0); + readonly Rune round; + readonly Rune doubleH; + readonly Rune doubleV; + readonly Rune doubleBoth; + readonly Rune normal; - return GetRuneForIntersects (driver, intersects, useDouble, useRounded); + public IntersectionRuneResolver(Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune normal) + { + this.round = round; + this.doubleH = doubleH; + this.doubleV = doubleV; + this.doubleBoth = doubleBoth; + this.normal = normal; } - protected abstract Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded); - } - - private abstract class CornerIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) + public Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects) { - + var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0); + bool doubleHorizontal = intersects.Any(l=>l.Line.Orientation == Orientation.Horizontal && l.Line.Style == BorderStyle.Double); bool doubleVertical = intersects.Any(l=>l.Line.Orientation == Orientation.Vertical && l.Line.Style == BorderStyle.Double); - return GetRuneForIntersects(driver,useRounded,doubleHorizontal,doubleVertical); - } - protected abstract Rune? GetRuneForIntersects(ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical); - } - - private class ULIntersectionRuneResolver : CornerIntersectionRuneResolver - { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) - { if(doubleHorizontal) { - return doubleVertical ? driver.ULDCorner : '╒'; + return doubleVertical ? doubleBoth : doubleH; } if(doubleVertical) { - return '╓'; + return doubleV; } - return useRounded ? driver.ULRCorner : driver.ULCorner; + return useRounded ? round : normal; } } - private class URIntersectionRuneResolver : CornerIntersectionRuneResolver - { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) - { - if(doubleHorizontal) - { - return doubleVertical ? driver.URDCorner : '╕'; - } - - if(doubleVertical) - { - return '╖'; - } - - return useRounded ? driver.URRCorner : driver.URCorner; - } - } - private class LLIntersectionRuneResolver : CornerIntersectionRuneResolver - { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) - { - if(doubleHorizontal) - { - return doubleVertical ? driver.LLDCorner : '╘'; - } - - if(doubleVertical) - { - return '╙'; - } - return useRounded ? driver.LLRCorner : driver.LLCorner; - } - } - private class LRIntersectionRuneResolver : CornerIntersectionRuneResolver + private class ULIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, bool useRounded, bool doubleHorizontal, bool doubleVertical) + public ULIntersectionRuneResolver() : + base('╭','╒','╓','╔','┌') { - if(doubleHorizontal) - { - return doubleVertical ? driver.LRDCorner : '╛'; - } - if(doubleVertical) - { - return '╜'; - } - - return useRounded ? driver.LRRCorner : driver.LRCorner; } } + private class URIntersectionRuneResolver : IntersectionRuneResolver + { + + public URIntersectionRuneResolver() : + base('╮','╕','╖','╗','┐') + { + + } + } + private class LLIntersectionRuneResolver : IntersectionRuneResolver + { + + public LLIntersectionRuneResolver() : + base('╰','╘','╙','╚','└') + { + + } + } + private class LRIntersectionRuneResolver : IntersectionRuneResolver + { + public LRIntersectionRuneResolver() : + base('╯','╛','╜','╝','┘') + { + + } + } + private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) - { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? '╦' : driver.TopTee; - } + public TopTeeIntersectionRuneResolver(): + base('┬','╤','╥','╦','┬'){ + + } } private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) - { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? '╠' : driver.LeftTee; - } + public LeftTeeIntersectionRuneResolver(): + base('├','╞','╟','╠','├'){ + + } } private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) - { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? '╣' : driver.RightTee; - } + public RightTeeIntersectionRuneResolver(): + base('┤','╡','╢','╣','┤'){ + + } } private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) - { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? '╩' : driver.BottomTee; - } + public BottomTeeIntersectionRuneResolver(): + base('┴','╧','╨','╩','┴'){ + + } } private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver { - protected override Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects, bool useDouble, bool useRounded) - { - // TODO: Handle all relevant permutations of double lines into single lines - // to make F type borders instead. - return useDouble ? '╬' : '┼'; - } + public CrosshairIntersectionRuneResolver(): + base('┼','╪','╫','╬','┼'){ + + } } private Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects) diff --git a/UnitTests/LineCanvasTests.cs b/UnitTests/LineCanvasTests.cs index 2a5644bb4..13282cb77 100644 --- a/UnitTests/LineCanvasTests.cs +++ b/UnitTests/LineCanvasTests.cs @@ -233,19 +233,18 @@ namespace Terminal.Gui.Core { canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, thinStyle); - canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Double); + canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical,thinStyle); canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Double); v.Redraw (v.Bounds); -// TODO: Fix those Ts! string looksLike = @" -╒════╦═══╕ -│ ║ │ -╠════╬═══╣ -│ ║ │ -╘════╩═══╛ +╒════╤═══╕ +│ │ │ +╞════╪═══╡ +│ │ │ +╘════╧═══╛ "; TestHelpers.AssertDriverContentsAre (looksLike, output); } @@ -265,18 +264,18 @@ namespace Terminal.Gui.Core { canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Double); - canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Double); + canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, thinStyle); v.Redraw (v.Bounds); -// TODO: Fix those Ts! string looksLike = @" -╓────╦───╖ +╓────╥───╖ ║ ║ ║ -╠════╬═══╣ +╟────╫───╢ ║ ║ ║ -╙────╩───╜ +╙────╨───╜ + "; TestHelpers.AssertDriverContentsAre (looksLike, output); } From 985df1d3c2751ea2dbd8eab63e1437db1d394663 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 11 Feb 2023 08:17:35 +0000 Subject: [PATCH 5/5] Move tests to Core folder and namespace to Terminal.Gui.CoreTests --- UnitTests/{ => Core}/LineCanvasTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename UnitTests/{ => Core}/LineCanvasTests.cs (99%) diff --git a/UnitTests/LineCanvasTests.cs b/UnitTests/Core/LineCanvasTests.cs similarity index 99% rename from UnitTests/LineCanvasTests.cs rename to UnitTests/Core/LineCanvasTests.cs index 13282cb77..7e988b0de 100644 --- a/UnitTests/LineCanvasTests.cs +++ b/UnitTests/Core/LineCanvasTests.cs @@ -2,7 +2,7 @@ using Xunit; using Xunit.Abstractions; -namespace Terminal.Gui.Core { +namespace Terminal.Gui.CoreTests { public class LineCanvasTests { readonly ITestOutputHelper output;