Skip to content

Commit

Permalink
another linter pass
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Nov 1, 2024
1 parent f0ab57a commit b1a3212
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry)
CurrentClip.ExecuteWithClipping(new Point(px, py), () =>
{
_pixelBuffer.Set(new PixelBufferCoordinate((ushort)px, (ushort)py),
(pixel, bb) => { return pixel.Blend(new Pixel(new PixelBackground(bb.Mode, bb.Color))); },
(pixel, bb) => pixel.Blend(new Pixel(new PixelBackground(bb.Mode, bb.Color))),
backgroundBrush);
});
}
Expand Down Expand Up @@ -289,7 +289,6 @@ private void DrawLineInternal(IPen pen, Line line)

byte pattern = (byte)(line.Vertical ? 0b1010 : 0b0101);
DrawPixelAndMoveHead(ref head, line, lineStyle, pattern, color, line.Length); //line
return;
}

/// <summary>
Expand Down Expand Up @@ -322,7 +321,6 @@ private void DrawRectangleLineInternal(IPen pen, Line line)

pattern = (byte)(line.Vertical ? 0b1000 : 0b0001);
DrawPixelAndMoveHead(ref head, line, lineStyle, pattern, color, 1); //ending
return;
}

/// <summary>
Expand Down
15 changes: 10 additions & 5 deletions src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ public void Print(PixelBufferCoordinate bufferPoint, Color background, Color for
SetCaretPosition(bufferPoint);

StringBuilder sb = new StringBuilder();
if (textDecorations != null && textDecorations.Any(td => td.Location == TextDecorationLocation.Underline))
if (HasTextDecoration(textDecorations, TextDecorationLocation.Underline))
sb.Append(ConsoleUtils.Underline);

if (textDecorations != null && textDecorations.Any(td => td.Location == TextDecorationLocation.Strikethrough))
if (HasTextDecoration(textDecorations, TextDecorationLocation.Strikethrough))
sb.Append(ConsoleUtils.Strikethrough);

if (style == FontStyle.Italic)
sb.Append(ConsoleUtils.Italic);

sb.Append(ConsoleUtils.Background(background));

sb.Append(ConsoleUtils.Foreground(weight switch
{
FontWeight.Medium or FontWeight.SemiBold or FontWeight.Bold or FontWeight.ExtraBold or FontWeight.Black or FontWeight.ExtraBlack
FontWeight.Medium or FontWeight.SemiBold or FontWeight.Bold or FontWeight.ExtraBold or FontWeight.Black or FontWeight.ExtraBlack
=> foreground.Brighten(background),
FontWeight.Thin or FontWeight.ExtraLight or FontWeight.Light
FontWeight.Thin or FontWeight.ExtraLight or FontWeight.Light
=> foreground.Shade(background),
_ => foreground
}));
Expand All @@ -103,6 +103,11 @@ FontWeight.Thin or FontWeight.ExtraLight or FontWeight.Light
else _headBufferPoint = (PixelBufferCoordinate)((ushort)0, (ushort)(_headBufferPoint.Y + 1));
}

private static bool HasTextDecoration(TextDecorationCollection textDecorations, TextDecorationLocation location)
{
return textDecorations?.Any(td => td.Location == location) ?? false;
}

public event Action Resized;
public event Action<Key, char, RawInputModifiers, bool, ulong> KeyEvent;
public event Action<RawPointerEventType, Point, Vector?, RawInputModifiers> MouseEvent;
Expand Down

0 comments on commit b1a3212

Please sign in to comment.