diff --git a/src/Consolonia.Core/Drawing/DrawingContextImpl.cs b/src/Consolonia.Core/Drawing/DrawingContextImpl.cs
index f036906e..6b6f8c10 100644
--- a/src/Consolonia.Core/Drawing/DrawingContextImpl.cs
+++ b/src/Consolonia.Core/Drawing/DrawingContextImpl.cs
@@ -95,7 +95,7 @@ public void DrawBitmap(IBitmapImpl source, double opacity, Rect sourceRect, Rect
Color background = GetBackgroundColorForQuadPixel(quadColors, quadPixel);
var imagePixel = new Pixel(
- new PixelForeground(new SimpleSymbol(quadPixel), color: foreground),
+ new PixelForeground(new SimpleSymbol(quadPixel), foreground),
new PixelBackground(background));
CurrentClip.ExecuteWithClipping(new Point(px, py),
() =>
diff --git a/src/Consolonia.Core/Drawing/PixelBufferImplementation/DrawingBoxSymbol.cs b/src/Consolonia.Core/Drawing/PixelBufferImplementation/DrawingBoxSymbol.cs
index 1cea2396..688a0c64 100644
--- a/src/Consolonia.Core/Drawing/PixelBufferImplementation/DrawingBoxSymbol.cs
+++ b/src/Consolonia.Core/Drawing/PixelBufferImplementation/DrawingBoxSymbol.cs
@@ -34,7 +34,7 @@ private static char GetBoxSymbol(byte upRightDownLeft)
byte leftPart = (byte)(upRightDownLeft & 0b1111_0000);
bool hasLeftPart = leftPart > 0;
- switch (upRightDownLeft & 0b0000_1111)
+ switch (upRightDownLeft & 0b0000_1111)
{
case 0b0000_1000:
case 0b0000_0010:
@@ -107,12 +107,12 @@ public ISymbol Blend(ref ISymbol symbolAbove)
{
if (symbolAbove.IsWhiteSpace()) return this;
- if (symbolAbove is not DrawingBoxSymbol drawingBoxSymbol)
+ if (symbolAbove is not DrawingBoxSymbol drawingBoxSymbol)
return symbolAbove;
-
+
if (drawingBoxSymbol._upRightDownLeft == BoldSymbol || _upRightDownLeft == BoldSymbol)
return new DrawingBoxSymbol(BoldSymbol);
-
+
return new DrawingBoxSymbol((byte)(_upRightDownLeft | drawingBoxSymbol._upRightDownLeft));
}
diff --git a/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs b/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs
index c4c3ae52..8d6e4222 100644
--- a/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs
+++ b/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs
@@ -17,17 +17,17 @@ public readonly struct Pixel
public bool IsCaret { get; }
///
- /// Make a pixel foreground with transparent background
+ /// Make a pixel foreground with transparent background
///
///
///
///
///
///
- public Pixel(ISymbol symbol,
- Color foregroundColor,
+ public Pixel(ISymbol symbol,
+ Color foregroundColor,
FontStyle style = FontStyle.Normal,
- FontWeight weight = FontWeight.Normal,
+ FontWeight weight = FontWeight.Normal,
TextDecorationCollection textDecorations = null) : this(
new PixelForeground(symbol, foregroundColor, weight, style, textDecorations),
new PixelBackground(PixelBackgroundMode.Transparent))
@@ -35,23 +35,23 @@ public Pixel(ISymbol symbol,
}
///
- /// Make a pixel with only background color, but no foreground
+ /// Make a pixel with only background color, but no foreground
///
///
- public Pixel(PixelBackground background) :
+ public Pixel(PixelBackground background) :
this(new PixelForeground(new SimpleSymbol(), Colors.Transparent),
- background)
+ background)
{
}
///
- /// Make a pixel with foreground and background
+ /// Make a pixel with foreground and background
///
///
///
///
- public Pixel(PixelForeground foreground,
- PixelBackground background,
+ public Pixel(PixelForeground foreground,
+ PixelBackground background,
bool isCaret = false)
{
Foreground = foreground;
@@ -60,7 +60,7 @@ public Pixel(PixelForeground foreground,
}
///
- /// Blend the pixelAbove with the this pixel.
+ /// Blend the pixelAbove with the this pixel.
///
///
///
diff --git a/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs b/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs
index f914a812..ba5e52cf 100644
--- a/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs
+++ b/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs
@@ -8,7 +8,8 @@ namespace Consolonia.Core.Drawing.PixelBufferImplementation
public readonly struct PixelForeground
{
public PixelForeground(ISymbol symbol, Color color,
- FontWeight weight = FontWeight.Normal, FontStyle style = FontStyle.Normal, TextDecorationCollection textDecorations = null)
+ FontWeight weight = FontWeight.Normal, FontStyle style = FontStyle.Normal,
+ TextDecorationCollection textDecorations = null)
{
ArgumentNullException.ThrowIfNull(symbol);
Symbol = symbol;
diff --git a/src/Consolonia.Core/Drawing/RenderTarget.cs b/src/Consolonia.Core/Drawing/RenderTarget.cs
index 498e3b4e..aaea2e11 100644
--- a/src/Consolonia.Core/Drawing/RenderTarget.cs
+++ b/src/Consolonia.Core/Drawing/RenderTarget.cs
@@ -130,10 +130,11 @@ private void RenderToDevice()
"All pixels in the buffer must have exact console color before rendering");
- var pixelSpread = (pixel.Background.Color,
- pixel.Foreground.Color,
+ (Color, Color, FontWeight Weight, FontStyle Style, TextDecorationCollection TextDecorations, string Text
+ ) pixelSpread = (pixel.Background.Color,
+ pixel.Foreground.Color,
pixel.Foreground.Weight,
- pixel.Foreground.Style,
+ pixel.Foreground.Style,
pixel.Foreground.TextDecorations,
pixel.Foreground.Symbol.Text);
diff --git a/src/Consolonia.NUnit/UnitTestConsole.cs b/src/Consolonia.NUnit/UnitTestConsole.cs
index 30754759..a74040ac 100644
--- a/src/Consolonia.NUnit/UnitTestConsole.cs
+++ b/src/Consolonia.NUnit/UnitTestConsole.cs
@@ -66,7 +66,7 @@ void IConsole.Print(PixelBufferCoordinate bufferPoint, Color background, Color f
PixelBuffer.Set(new PixelBufferCoordinate((ushort)(x + i), y), _ =>
// ReSharper disable once AccessToModifiedClosure we are sure about inline execution
new Pixel(
- new PixelForeground(new SimpleSymbol(rune), color: foreground, style: style, weight: weight,
+ new PixelForeground(new SimpleSymbol(rune), foreground, style: style, weight: weight,
textDecorations: textDecorations),
new PixelBackground(PixelBackgroundMode.Colored, background)));
i++;
diff --git a/src/Tests/Consolonia.Core.Tests/Assembly.cs b/src/Tests/Consolonia.Core.Tests/Assembly.cs
index 16870199..5d141236 100644
--- a/src/Tests/Consolonia.Core.Tests/Assembly.cs
+++ b/src/Tests/Consolonia.Core.Tests/Assembly.cs
@@ -18,6 +18,5 @@ public void OneTimeSetUp()
AvaloniaLocator.Current = new AvaloniaLocator()
.Bind().ToConstant(new UnitTestConsole(new PixelBufferSize(100, 100)));
}
-
}
-}
+}
\ No newline at end of file
diff --git a/src/Tests/Consolonia.Core.Tests/DrawingBoxSymbolTests.cs b/src/Tests/Consolonia.Core.Tests/DrawingBoxSymbolTests.cs
index 6cf315d5..8ec43a4f 100644
--- a/src/Tests/Consolonia.Core.Tests/DrawingBoxSymbolTests.cs
+++ b/src/Tests/Consolonia.Core.Tests/DrawingBoxSymbolTests.cs
@@ -48,19 +48,16 @@ public void BlendAllSymbols()
(0b0000_1111, "โผ")
};
- foreach (var (code1, _) in symbols)
+ foreach ((byte code1, string _) in symbols)
+ foreach ((byte code2, string _) in symbols)
{
- foreach (var (code2, _) in symbols)
- {
- ISymbol symbol1 = new DrawingBoxSymbol(code1);
- ISymbol symbol2 = new DrawingBoxSymbol(code2);
- ISymbol blendedSymbol = symbol1.Blend(ref symbol2);
- if (symbol1.Text != symbol2.Text)
- Debug.WriteLine($"{symbol1.Text} + {symbol2.Text} => {blendedSymbol.Text}");
- Assert.That(blendedSymbol.Text, Is.Not.Null);
- }
+ ISymbol symbol1 = new DrawingBoxSymbol(code1);
+ ISymbol symbol2 = new DrawingBoxSymbol(code2);
+ ISymbol blendedSymbol = symbol1.Blend(ref symbol2);
+ if (symbol1.Text != symbol2.Text)
+ Debug.WriteLine($"{symbol1.Text} + {symbol2.Text} => {blendedSymbol.Text}");
+ Assert.That(blendedSymbol.Text, Is.Not.Null);
}
}
-
- }
+ }
}
\ No newline at end of file
diff --git a/src/Tests/Consolonia.Core.Tests/GlyphTests.cs b/src/Tests/Consolonia.Core.Tests/GlyphTests.cs
index 87740604..551bfb8e 100644
--- a/src/Tests/Consolonia.Core.Tests/GlyphTests.cs
+++ b/src/Tests/Consolonia.Core.Tests/GlyphTests.cs
@@ -9,7 +9,7 @@ public class GlyphTests
[Test]
public void GetGlyphsEmptyStringReturnsEmptyList()
{
- var text = string.Empty;
+ string text = string.Empty;
var glyphs = text.GetGlyphs(true);
Assert.IsEmpty(glyphs);
}
@@ -17,7 +17,7 @@ public void GetGlyphsEmptyStringReturnsEmptyList()
[Test]
public void GetGlyphsSingleCharacterReturnsSingleGlyph()
{
- var text = "a";
+ string text = "a";
Assert.AreEqual(1, text.MeasureText());
var glyphs = text.GetGlyphs(true);
@@ -28,7 +28,7 @@ public void GetGlyphsSingleCharacterReturnsSingleGlyph()
[Test]
public void GetGlyphsMultipleCharsReturnsMultipleGlyph()
{
- var text = "hello";
+ string text = "hello";
Assert.AreEqual(5, text.MeasureText());
var glyphs = text.GetGlyphs(true);
@@ -43,7 +43,7 @@ public void GetGlyphsMultipleCharsReturnsMultipleGlyph()
[Test]
public void GetGlyphsComplexCharsReturnsSingleGlyph()
{
- var text = "๐๐๐ซ๐ ๐ถ";
+ string text = "๐๐๐ซ๐ ๐ถ";
Assert.AreEqual(5, text.MeasureText());
var glyphs = text.GetGlyphs(true);
@@ -58,7 +58,7 @@ public void GetGlyphsComplexCharsReturnsSingleGlyph()
[Test]
public void GetGlyphsSingleEmojiReturnsSingleGlyph()
{
- var text = "๐";
+ string text = "๐";
Assert.AreEqual(2, text.MeasureText());
var glyphs = text.GetGlyphs(true);
@@ -69,7 +69,7 @@ public void GetGlyphsSingleEmojiReturnsSingleGlyph()
[Test]
public void GetGlyphsWithComplexEmoji()
{
- var text = "๐จโ๐ฉโ๐งโ๐ฆ";
+ string text = "๐จโ๐ฉโ๐งโ๐ฆ";
Assert.AreEqual(2, text.MeasureText());
var glyphs = text.GetGlyphs(true);
@@ -80,7 +80,7 @@ public void GetGlyphsWithComplexEmoji()
[Test]
public void GetGlyphsWithMultipleGlyphs()
{
- var text = "a๐";
+ string text = "a๐";
Assert.AreEqual(3, text.MeasureText());
var glyphs = text.GetGlyphs(true);
@@ -92,7 +92,7 @@ public void GetGlyphsWithMultipleGlyphs()
[Test]
public void GetGlyphsWithOutComplexEmojiSupport()
{
- var text = "๐จโ๐ฉโ๐งโ๐ฆ";
+ string text = "๐จโ๐ฉโ๐งโ๐ฆ";
Assert.AreEqual(2, text.MeasureText());
var glyphs = text.GetGlyphs(false);
diff --git a/src/Tests/Consolonia.Core.Tests/PixelBackgroundTests.cs b/src/Tests/Consolonia.Core.Tests/PixelBackgroundTests.cs
index e7bb7456..414d34d3 100644
--- a/src/Tests/Consolonia.Core.Tests/PixelBackgroundTests.cs
+++ b/src/Tests/Consolonia.Core.Tests/PixelBackgroundTests.cs
@@ -14,7 +14,7 @@ public void Constructor()
Assert.That(pixelBackground.Color, Is.EqualTo(Colors.Red));
Assert.That(pixelBackground.Mode, Is.EqualTo(PixelBackgroundMode.Colored));
}
-
+
[TestCase(PixelBackgroundMode.Transparent)]
[TestCase(PixelBackgroundMode.Colored)]
[TestCase(PixelBackgroundMode.Shaded)]
diff --git a/src/Tests/Consolonia.Core.Tests/PixelForegroundTests.cs b/src/Tests/Consolonia.Core.Tests/PixelForegroundTests.cs
index 19b1746c..7cc87873 100644
--- a/src/Tests/Consolonia.Core.Tests/PixelForegroundTests.cs
+++ b/src/Tests/Consolonia.Core.Tests/PixelForegroundTests.cs
@@ -1,4 +1,5 @@
using System.Linq;
+using System.Text;
using Avalonia.Media;
using Consolonia.Core.Drawing.PixelBufferImplementation;
using NUnit.Framework;
@@ -48,7 +49,7 @@ public void ConstructorWithSymbolAndStyle()
public void ConstructorWithSymbolAndTextDecorations()
{
var symbol = new SimpleSymbol('a');
- var textDecorations = TextDecorations.Underline;
+ TextDecorationCollection textDecorations = TextDecorations.Underline;
var pixelForeground = new PixelForeground(symbol, Colors.Red, textDecorations: textDecorations);
Assert.That(pixelForeground.Color, Is.EqualTo(Colors.Red));
Assert.That(pixelForeground.Symbol.Text, Is.EqualTo("a"));
@@ -60,7 +61,7 @@ public void ConstructorWithSymbolAndTextDecorations()
[Test]
public void ConstructorWithWideCharacter()
{
- var rune = "๐ต".EnumerateRunes().First();
+ Rune rune = "๐ต".EnumerateRunes().First();
var symbol = new SimpleSymbol(rune);
var pixelForeground = new PixelForeground(symbol, Colors.Red);
Assert.That(pixelForeground.Color, Is.EqualTo(Colors.Red));
@@ -77,7 +78,7 @@ public void Blend()
var pixelForeground = new PixelForeground(symbol, Colors.Red);
var symbolAbove = new SimpleSymbol('b');
var pixelForegroundAbove = new PixelForeground(symbolAbove, Colors.Blue);
- var newPixelForeground = pixelForeground.Blend(pixelForegroundAbove);
+ PixelForeground newPixelForeground = pixelForeground.Blend(pixelForegroundAbove);
Assert.That(newPixelForeground.Color, Is.EqualTo(Colors.Blue));
Assert.That(newPixelForeground.Symbol.Text, Is.EqualTo("b"));
}
@@ -86,10 +87,12 @@ public void Blend()
public void BlendComplex()
{
var symbol = new SimpleSymbol('a');
- var pixelForeground = new PixelForeground(symbol, Colors.Red, FontWeight.Light, FontStyle.Normal, TextDecorations.Strikethrough);
+ var pixelForeground = new PixelForeground(symbol, Colors.Red, FontWeight.Light, FontStyle.Normal,
+ TextDecorations.Strikethrough);
var symbolAbove = new SimpleSymbol('b');
- var pixelForegroundAbove = new PixelForeground(symbolAbove, Colors.Blue, FontWeight.Bold, FontStyle.Italic, TextDecorations.Underline);
- var newPixelForeground = pixelForeground.Blend(pixelForegroundAbove);
+ var pixelForegroundAbove = new PixelForeground(symbolAbove, Colors.Blue, FontWeight.Bold, FontStyle.Italic,
+ TextDecorations.Underline);
+ PixelForeground newPixelForeground = pixelForeground.Blend(pixelForegroundAbove);
Assert.That(newPixelForeground.Color, Is.EqualTo(Colors.Blue));
Assert.That(newPixelForeground.Symbol.Text, Is.EqualTo("b"));
Assert.That(newPixelForeground.Weight, Is.EqualTo(FontWeight.Bold));
@@ -104,7 +107,7 @@ public void BlendEmoji()
var pixelForeground = new PixelForeground(symbol, Colors.Red);
var symbolAbove = new SimpleSymbol("๐ถ");
var pixelForegroundAbove = new PixelForeground(symbolAbove, Colors.Blue);
- var newPixelForeground = pixelForeground.Blend(pixelForegroundAbove);
+ PixelForeground newPixelForeground = pixelForeground.Blend(pixelForegroundAbove);
Assert.That(newPixelForeground.Color, Is.EqualTo(Colors.Blue));
Assert.That(newPixelForeground.Symbol.Text, Is.EqualTo("๐ถ"));
}
diff --git a/src/Tests/Consolonia.Core.Tests/PixelTests.cs b/src/Tests/Consolonia.Core.Tests/PixelTests.cs
index 55110c4c..20ecc8e3 100644
--- a/src/Tests/Consolonia.Core.Tests/PixelTests.cs
+++ b/src/Tests/Consolonia.Core.Tests/PixelTests.cs
@@ -7,11 +7,10 @@ namespace Consolonia.Core.Tests
[TestFixture]
public class PixelTests
{
-
[Test]
public void ConstructorColorOnly()
{
- Pixel pixel = new Pixel(new PixelBackground(Colors.Red));
+ var pixel = new Pixel(new PixelBackground(Colors.Red));
Assert.That(pixel.Background.Color, Is.EqualTo(Colors.Red));
Assert.That(pixel.Background.Mode, Is.EqualTo(PixelBackgroundMode.Colored));
}
@@ -19,7 +18,7 @@ public void ConstructorColorOnly()
[Test]
public void ConstructorColorAndSymbol()
{
- Pixel pixel = new Pixel(new SimpleSymbol("a"), Colors.Red);
+ var pixel = new Pixel(new SimpleSymbol("a"), Colors.Red);
Assert.That(pixel.Foreground.Symbol.Text, Is.EqualTo("a"));
Assert.That(pixel.Foreground.Color, Is.EqualTo(Colors.Red));
Assert.That(pixel.Foreground.Style, Is.EqualTo(FontStyle.Normal));
@@ -32,7 +31,7 @@ public void ConstructorColorAndSymbol()
[Test]
public void ConstructorDrawingBoxSymbol()
{
- Pixel pixel = new Pixel(new DrawingBoxSymbol(0b0000_1111), Colors.Red);
+ var pixel = new Pixel(new DrawingBoxSymbol(0b0000_1111), Colors.Red);
Assert.That(pixel.Foreground.Symbol.Text, Is.EqualTo("โผ"));
Assert.That(pixel.Foreground.Color, Is.EqualTo(Colors.Red));
Assert.That(pixel.Foreground.Style, Is.EqualTo(FontStyle.Normal));
@@ -45,7 +44,8 @@ public void ConstructorDrawingBoxSymbol()
[Test]
public void ConstructorDrawingBoxSymbolAndColor()
{
- Pixel pixel = new Pixel(new PixelForeground(new DrawingBoxSymbol(0b0000_1111), color: Colors.Red), new PixelBackground(Colors.Blue));
+ var pixel = new Pixel(new PixelForeground(new DrawingBoxSymbol(0b0000_1111), Colors.Red),
+ new PixelBackground(Colors.Blue));
Assert.That(pixel.Foreground.Symbol.Text, Is.EqualTo("โผ"));
Assert.That(pixel.Foreground.Color, Is.EqualTo(Colors.Red));
Assert.That(pixel.Foreground.Style, Is.EqualTo(FontStyle.Normal));
@@ -58,8 +58,9 @@ public void ConstructorDrawingBoxSymbolAndColor()
[Test]
public void BlendTransparentBackground()
{
- Pixel pixel = new Pixel(new PixelBackground(Colors.Green));
- Pixel pixel2 = new Pixel(new PixelForeground(new SimpleSymbol('a'), Colors.Red), new PixelBackground(Colors.Transparent));
+ var pixel = new Pixel(new PixelBackground(Colors.Green));
+ var pixel2 = new Pixel(new PixelForeground(new SimpleSymbol('a'), Colors.Red),
+ new PixelBackground(Colors.Transparent));
Pixel newPixel = pixel.Blend(pixel2);
Assert.That(newPixel.Foreground.Symbol.Text, Is.EqualTo("a"));
Assert.That(newPixel.Foreground.Color, Is.EqualTo(Colors.Red));
@@ -69,8 +70,9 @@ public void BlendTransparentBackground()
[Test]
public void BlendColoredBackground()
{
- Pixel pixel = new Pixel(new PixelBackground(Colors.Green));
- Pixel pixel2 = new Pixel(new PixelForeground(new SimpleSymbol('a'), Colors.Red), new PixelBackground(Colors.Blue));
+ var pixel = new Pixel(new PixelBackground(Colors.Green));
+ var pixel2 = new Pixel(new PixelForeground(new SimpleSymbol('a'), Colors.Red),
+ new PixelBackground(Colors.Blue));
Pixel newPixel = pixel.Blend(pixel2);
Assert.That(newPixel.Foreground.Symbol.Text, Is.EqualTo("a"));
Assert.That(newPixel.Foreground.Color, Is.EqualTo(Colors.Red));
diff --git a/src/Tests/Consolonia.Core.Tests/SimpleSymbolTests.cs b/src/Tests/Consolonia.Core.Tests/SimpleSymbolTests.cs
index 8b2e9cf0..b967e5d5 100644
--- a/src/Tests/Consolonia.Core.Tests/SimpleSymbolTests.cs
+++ b/src/Tests/Consolonia.Core.Tests/SimpleSymbolTests.cs
@@ -8,7 +8,6 @@ namespace Consolonia.Core.Tests
[TestFixture]
public class SimpleSymbolTests
{
-
[Test]
public void ConstructorChar()
{
@@ -36,7 +35,7 @@ public void ConstructorRune()
[Test]
public void ConstructorRuneEmoji()
{
- var rune = "๐".EnumerateRunes().First();
+ Rune rune = "๐".EnumerateRunes().First();
ISymbol symbol = new SimpleSymbol(rune);
Assert.That(symbol.Text, Is.EqualTo("๐"));
Assert.That(symbol.Width, Is.EqualTo(2));