Browse Source

whitespace formatting fixes

tznind 2 years ago
parent
commit
fd989430bc
2 changed files with 84 additions and 91 deletions
  1. 62 69
      Terminal.Gui/Core/Graphs/LineCanvas.cs
  2. 22 22
      UnitTests/Core/LineCanvasTests.cs

+ 62 - 69
Terminal.Gui/Core/Graphs/LineCanvas.cs

@@ -11,10 +11,10 @@ namespace Terminal.Gui.Graphs {
 	/// </summary>
 	public class LineCanvas {
 
-		
+
 		private List<StraightLine> lines = new List<StraightLine> ();
 
-		Dictionary<IntersectionRuneType, IntersectionRuneResolver> runeResolvers = new Dictionary<IntersectionRuneType, IntersectionRuneResolver> { 
+		Dictionary<IntersectionRuneType, IntersectionRuneResolver> runeResolvers = new Dictionary<IntersectionRuneType, IntersectionRuneResolver> {
 			{IntersectionRuneType.ULCorner,new ULIntersectionRuneResolver()},
 			{IntersectionRuneType.URCorner,new URIntersectionRuneResolver()},
 			{IntersectionRuneType.LLCorner,new LLIntersectionRuneResolver()},
@@ -100,15 +100,14 @@ namespace Terminal.Gui.Graphs {
 			}
 		}
 
-		private abstract class IntersectionRuneResolver
-		{
+		private abstract class IntersectionRuneResolver {
 			readonly Rune round;
 			readonly Rune doubleH;
 			readonly Rune doubleV;
 			readonly Rune doubleBoth;
 			readonly Rune normal;
 
-			public IntersectionRuneResolver(Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune normal)
+			public IntersectionRuneResolver (Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune normal)
 			{
 				this.round = round;
 				this.doubleH = doubleH;
@@ -121,17 +120,15 @@ namespace Terminal.Gui.Graphs {
 			{
 				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);
+				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);
 
 
-				if(doubleHorizontal)
-				{
-						return doubleVertical ? doubleBoth : doubleH;
+				if (doubleHorizontal) {
+					return doubleVertical ? doubleBoth : doubleH;
 				}
-				
-				if(doubleVertical)
-				{
+
+				if (doubleVertical) {
 					return doubleV;
 				}
 
@@ -139,75 +136,71 @@ namespace Terminal.Gui.Graphs {
 			}
 		}
 
-		private class ULIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public ULIntersectionRuneResolver() :
-				base('╭','╒','╓','╔','┌')
+		private class ULIntersectionRuneResolver : IntersectionRuneResolver {
+			public ULIntersectionRuneResolver () :
+				base ('╭', '╒', '╓', '╔', '┌')
 			{
-				
+
 			}
 		}
-		private class URIntersectionRuneResolver : IntersectionRuneResolver 
-		{
+		private class URIntersectionRuneResolver : IntersectionRuneResolver {
 
-			public URIntersectionRuneResolver() :
-				base('╮','╕','╖','╗','┐')
+			public URIntersectionRuneResolver () :
+				base ('╮', '╕', '╖', '╗', '┐')
 			{
-				
+
 			}
 		}
-		private class LLIntersectionRuneResolver : IntersectionRuneResolver 
-		{
+		private class LLIntersectionRuneResolver : IntersectionRuneResolver {
 
-			public LLIntersectionRuneResolver() :
-				base('╰','╘','╙','╚','└')
+			public LLIntersectionRuneResolver () :
+				base ('╰', '╘', '╙', '╚', '└')
 			{
-				
+
 			}
 		}
-		private class LRIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public LRIntersectionRuneResolver() :
-				base('╯','╛','╜','╝','┘')
+		private class LRIntersectionRuneResolver : IntersectionRuneResolver {
+			public LRIntersectionRuneResolver () :
+				base ('╯', '╛', '╜', '╝', '┘')
 			{
-				
+
 			}
 		}
 
-		private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public TopTeeIntersectionRuneResolver():
-				base('┬','╤','╥','╦','┬'){
-					
-				}
+		private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver {
+			public TopTeeIntersectionRuneResolver () :
+				base ('┬', '╤', '╥', '╦', '┬')
+			{
+
+			}
 		}
-		private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public LeftTeeIntersectionRuneResolver():
-				base('├','╞','╟','╠','├'){
-					
-				}
+		private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver {
+			public LeftTeeIntersectionRuneResolver () :
+				base ('├', '╞', '╟', '╠', '├')
+			{
+
+			}
 		}
-		private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public RightTeeIntersectionRuneResolver():
-				base('┤','╡','╢','╣','┤'){
-					
-				}
+		private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver {
+			public RightTeeIntersectionRuneResolver () :
+				base ('┤', '╡', '╢', '╣', '┤')
+			{
+
+			}
 		}
-		private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public BottomTeeIntersectionRuneResolver():
-				base('┴','╧','╨','╩','┴'){
-					
-				}
+		private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver {
+			public BottomTeeIntersectionRuneResolver () :
+				base ('┴', '╧', '╨', '╩', '┴')
+			{
+
+			}
 		}
-		private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver 
-		{
-			public CrosshairIntersectionRuneResolver():
-				base('┼','╪','╫','╬','┼'){
-					
-				}
+		private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver {
+			public CrosshairIntersectionRuneResolver () :
+				base ('┼', '╪', '╫', '╬', '┼')
+			{
+
+			}
 		}
 
 		private Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects)
@@ -217,7 +210,7 @@ namespace Terminal.Gui.Graphs {
 
 			var runeType = GetRuneTypeForIntersects (intersects);
 
-			if(runeResolvers.ContainsKey (runeType)) {
+			if (runeResolvers.ContainsKey (runeType)) {
 				return runeResolvers [runeType].GetRuneForIntersects (driver, intersects);
 			}
 
@@ -228,13 +221,13 @@ namespace Terminal.Gui.Graphs {
 			// TODO: maybe make these resolvers to for simplicity?
 			// or for dotted lines later on or that kind of thing?
 			switch (runeType) {
-			case IntersectionRuneType.None: 
+			case IntersectionRuneType.None:
 				return null;
-			case IntersectionRuneType.Dot: 
+			case IntersectionRuneType.Dot:
 				return (Rune)'.';
-			case IntersectionRuneType.HLine: 
+			case IntersectionRuneType.HLine:
 				return useDouble ? driver.HDLine : driver.HLine;
-			case IntersectionRuneType.VLine: 
+			case IntersectionRuneType.VLine:
 				return useDouble ? driver.VDLine : driver.VLine;
 			default: throw new Exception ("Could not find resolver or switch case for " + nameof (runeType) + ":" + runeType);
 			}
@@ -243,7 +236,7 @@ namespace Terminal.Gui.Graphs {
 
 		private IntersectionRuneType GetRuneTypeForIntersects (IntersectionDefinition [] intersects)
 		{
-			if(intersects.All(i=>i.Line.Length == 0)) {
+			if (intersects.All (i => i.Line.Length == 0)) {
 				return IntersectionRuneType.Dot;
 			}
 

+ 22 - 22
UnitTests/Core/LineCanvasTests.cs

@@ -60,7 +60,7 @@ namespace Terminal.Gui.CoreTests {
 		}
 
 		[InlineData (BorderStyle.Single)]
-		[InlineData(BorderStyle.Rounded)]
+		[InlineData (BorderStyle.Rounded)]
 		[Theory, AutoInitShutdown]
 		public void TestLineCanvas_Vertical (BorderStyle style)
 		{
@@ -96,7 +96,7 @@ namespace Terminal.Gui.CoreTests {
 		/// Not when they terminate adjacent to one another.
 		/// </summary>
 		[Fact, AutoInitShutdown]
-		public void TestLineCanvas_Corner_NoOverlap()
+		public void TestLineCanvas_Corner_NoOverlap ()
 		{
 			var v = GetCanvas (out var canvas);
 			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, BorderStyle.Single);
@@ -130,14 +130,14 @@ namespace Terminal.Gui.CoreTests {
 │";
 			TestHelpers.AssertDriverContentsAre (looksLike, output);
-		
+
 		}
 
-		[Fact,AutoInitShutdown]
+		[Fact, AutoInitShutdown]
 		public void TestLineCanvas_Window ()
 		{
 			var v = GetCanvas (out var canvas);
-			
+
 			// outer box
 			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Single);
 			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Single);
@@ -172,10 +172,10 @@ namespace Terminal.Gui.CoreTests {
 
 			// outer box
 			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Rounded);
-			
+
 			// BorderStyle.Single is ignored because corner overlaps with the above line which is Rounded
 			// this results in a rounded corner being used.
-			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Single); 
+			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Single);
 			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, BorderStyle.Rounded);
 			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, BorderStyle.Single);
 
@@ -224,8 +224,8 @@ namespace Terminal.Gui.CoreTests {
 
 
 		[Theory, AutoInitShutdown]
-		[InlineData(BorderStyle.Single)]
-		[InlineData(BorderStyle.Rounded)]
+		[InlineData (BorderStyle.Single)]
+		[InlineData (BorderStyle.Rounded)]
 		public void TestLineCanvas_Window_DoubleTop_SingleSides (BorderStyle thinStyle)
 		{
 			var v = GetCanvas (out var canvas);
@@ -237,7 +237,7 @@ namespace Terminal.Gui.CoreTests {
 			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, thinStyle);
 
 
-			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical,thinStyle);
+			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);
@@ -254,8 +254,8 @@ namespace Terminal.Gui.CoreTests {
 		}
 
 		[Theory, AutoInitShutdown]
-		[InlineData(BorderStyle.Single)]
-		[InlineData(BorderStyle.Rounded)]
+		[InlineData (BorderStyle.Single)]
+		[InlineData (BorderStyle.Rounded)]
 		public void TestLineCanvas_Window_SingleTop_DoubleSides (BorderStyle thinStyle)
 		{
 			var v = GetCanvas (out var canvas);
@@ -263,8 +263,8 @@ namespace Terminal.Gui.CoreTests {
 			// 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 (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);
@@ -286,24 +286,24 @@ namespace Terminal.Gui.CoreTests {
 
 
 		[Theory, AutoInitShutdown]
-		[InlineData(0,0,@"
+		[InlineData (0, 0, @"
 ═══
 ══
 ═══")]
-		[InlineData (1, 0,@"
+		[InlineData (1, 0, @"
 ══
 ══")]
-		[InlineData (2, 0,@"
+		[InlineData (2, 0, @"
 
 ═")]
-		[InlineData (0, 1,@"
+		[InlineData (0, 1, @"
 ══
 ═══")]
-		[InlineData (0, 2,@"
+		[InlineData (0, 2, @"
 ═══")]
-		public void TestLineCanvasRenderOffset_NoOffset (int xOffset,int yOffset, string expect)
+		public void TestLineCanvasRenderOffset_NoOffset (int xOffset, int yOffset, string expect)
 		{
 			var canvas = new LineCanvas ();
 			canvas.AddLine (new Point (0, 0), 2, Orientation.Horizontal, BorderStyle.Double);
@@ -338,8 +338,8 @@ namespace Terminal.Gui.CoreTests {
 				Bounds = new Rect (0, 0, 10, 5)
 			};
 
-			var canvasCopy = canvas =  new LineCanvas ();
-			v.DrawContentComplete += (r)=> canvasCopy.Draw (v, v.Bounds);
+			var canvasCopy = canvas = new LineCanvas ();
+			v.DrawContentComplete += (r) => canvasCopy.Draw (v, v.Bounds);
 
 			return v;
 		}