Skip to content

Commit

Permalink
Automated JetBrains cleanup
Browse files Browse the repository at this point in the history
Co-authored-by:  <[email protected]>
  • Loading branch information
github-actions[bot] committed Nov 9, 2024
1 parent 89b24bd commit 66553d4
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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));
}

Expand Down
22 changes: 11 additions & 11 deletions src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@ public readonly struct Pixel
public bool IsCaret { get; }

/// <summary>
/// Make a pixel foreground with transparent background
/// Make a pixel foreground with transparent background
/// </summary>
/// <param name="symbol"></param>
/// <param name="foregroundColor"></param>
/// <param name="style"></param>
/// <param name="weight"></param>
/// <param name="textDecorations"></param>
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))
{
}

/// <summary>
/// Make a pixel with only background color, but no foreground
/// Make a pixel with only background color, but no foreground
/// </summary>
/// <param name="background"></param>
public Pixel(PixelBackground background) :
public Pixel(PixelBackground background) :
this(new PixelForeground(new SimpleSymbol(), Colors.Transparent),
background)
background)
{
}

/// <summary>
/// Make a pixel with foreground and background
/// Make a pixel with foreground and background
/// </summary>
/// <param name="foreground"></param>
/// <param name="background"></param>
/// <param name="isCaret"></param>
public Pixel(PixelForeground foreground,
PixelBackground background,
public Pixel(PixelForeground foreground,
PixelBackground background,
bool isCaret = false)
{
Foreground = foreground;
Expand All @@ -60,7 +60,7 @@ public Pixel(PixelForeground foreground,
}

/// <summary>
/// Blend the pixelAbove with the this pixel.
/// Blend the pixelAbove with the this pixel.
/// </summary>
/// <param name="pixelAbove"></param>
/// <returns></returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Consolonia.NUnit/UnitTestConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/Consolonia.Core.Tests/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ public void OneTimeSetUp()
AvaloniaLocator.Current = new AvaloniaLocator()
.Bind<IConsole>().ToConstant(new UnitTestConsole(new PixelBufferSize(100, 100)));
}

}
}
}
21 changes: 9 additions & 12 deletions src/Tests/Consolonia.Core.Tests/DrawingBoxSymbolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
}
}
16 changes: 8 additions & 8 deletions src/Tests/Consolonia.Core.Tests/GlyphTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public class GlyphTests
[Test]
public void GetGlyphsEmptyStringReturnsEmptyList()
{
var text = string.Empty;
string text = string.Empty;
var glyphs = text.GetGlyphs(true);
Assert.IsEmpty(glyphs);
}

[Test]
public void GetGlyphsSingleCharacterReturnsSingleGlyph()
{
var text = "a";
string text = "a";
Assert.AreEqual(1, text.MeasureText());

var glyphs = text.GetGlyphs(true);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Consolonia.Core.Tests/PixelBackgroundTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
17 changes: 10 additions & 7 deletions src/Tests/Consolonia.Core.Tests/PixelForegroundTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Text;
using Avalonia.Media;
using Consolonia.Core.Drawing.PixelBufferImplementation;
using NUnit.Framework;
Expand Down Expand Up @@ -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"));
Expand All @@ -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));
Expand All @@ -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"));
}
Expand All @@ -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));
Expand All @@ -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("🎶"));
}
Expand Down
20 changes: 11 additions & 9 deletions src/Tests/Consolonia.Core.Tests/PixelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ 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));
}

[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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/Consolonia.Core.Tests/SimpleSymbolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Consolonia.Core.Tests
[TestFixture]
public class SimpleSymbolTests
{

[Test]
public void ConstructorChar()
{
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 66553d4

Please sign in to comment.