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 Oct 29, 2024
1 parent 46b6c62 commit d4f7440
Show file tree
Hide file tree
Showing 38 changed files with 172 additions and 167 deletions.
2 changes: 1 addition & 1 deletion Directory.Core.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'RELEASE' ">true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<AvaloniaAccessUnstablePrivateApis>true</AvaloniaAccessUnstablePrivateApis>
<AvaloniaAccessUnstablePrivateApis>true</AvaloniaAccessUnstablePrivateApis>
<Avalonia_I_Want_To_Use_Private_Apis_In_Nuget_Package_And_Promise_To_Pin_The_Exact_Avalonia_Version_In_Package_Dependency>true</Avalonia_I_Want_To_Use_Private_Apis_In_Nuget_Package_And_Promise_To_Pin_The_Exact_Avalonia_Version_In_Package_Dependency>
</PropertyGroup>
</Project>
13 changes: 8 additions & 5 deletions src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ public IWriteableBitmapImpl LoadWriteableBitmap(Stream stream)
throw new NotImplementedException();
}

IBitmapImpl IPlatformRenderInterface.LoadBitmapToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode)
IBitmapImpl IPlatformRenderInterface.LoadBitmapToWidth(Stream stream, int width,
BitmapInterpolationMode interpolationMode)
{
throw new NotImplementedException();
}

IBitmapImpl IPlatformRenderInterface.LoadBitmapToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode)
IBitmapImpl IPlatformRenderInterface.LoadBitmapToHeight(Stream stream, int height,
BitmapInterpolationMode interpolationMode)
{
throw new NotImplementedException();
}
Expand All @@ -105,7 +107,7 @@ IBitmapImpl IPlatformRenderInterface.ResizeBitmap(IBitmapImpl bitmapImpl, PixelS
{
throw new NotImplementedException();
}

public IBitmapImpl LoadBitmap(
PixelFormat format,
AlphaFormat alphaFormat,
Expand All @@ -117,10 +119,11 @@ public IBitmapImpl LoadBitmap(
throw new NotImplementedException();
}

public IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, IReadOnlyList<GlyphInfo> glyphInfos,
public IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize,
IReadOnlyList<GlyphInfo> glyphInfos,
Point baselineOrigin)
{
return new GlyphRunImpl(glyphTypeface,glyphInfos,baselineOrigin);
return new GlyphRunImpl(glyphTypeface, glyphInfos, baselineOrigin);
}

public IPlatformRenderInterfaceContext CreateBackendContext(IPlatformGraphicsContext graphicsApiContext)
Expand Down
25 changes: 13 additions & 12 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public void DrawGlyphRun(IBrush foreground, IGlyphRunImpl glyphRun)
ConsoloniaPlatform.RaiseNotSupported(17, glyphRun);
throw new InvalidProgramException();
}

if (glyphRun.FontRenderingEmSize.IsNearlyEqual(0)) return;
if (!glyphRun.FontRenderingEmSize.IsNearlyEqual(1))
{
Expand All @@ -195,9 +196,9 @@ public void PushClip(Rect clip)

public void PushClip(RoundedRect clip)
{
if(clip.IsRounded)
if (clip.IsRounded)
ConsoloniaPlatform.RaiseNotSupported(2);

PushClip(clip.Rect);
}

Expand Down Expand Up @@ -265,13 +266,13 @@ public Matrix Transform
{
lineStyle = null;
if (pen is not
{
Brush: FourBitColorBrush or LineBrush { Brush: FourBitColorBrush },
Thickness: 1,
DashStyle: null or { Dashes.Count: 0 },
LineCap: PenLineCap.Flat,
LineJoin: PenLineJoin.Miter
})
{
Brush: FourBitColorBrush or LineBrush { Brush: FourBitColorBrush },
Thickness: 1,
DashStyle: null or { Dashes.Count: 0 },
LineCap: PenLineCap.Flat,
LineJoin: PenLineJoin.Miter
})
{
ConsoloniaPlatform.RaiseNotSupported(6);
return null;
Expand Down Expand Up @@ -352,7 +353,7 @@ void DrawPixelAndMoveHead(int count)
}
}
}

private void DrawStringInternal(IBrush foreground, string str, Point origin = new())
{
if (foreground is not FourBitColorBrush { Mode: PixelBackgroundMode.Colored } consoleColorBrush)
Expand Down Expand Up @@ -394,8 +395,8 @@ void DrawPixelAndMoveHead(int count)
case '\n':
{
/* it's not clear if we need to draw anything. Cursor can be placed at the end of the line
var consolePixel = new Pixel(' ', foregroundColor);
var consolePixel = new Pixel(' ', foregroundColor);
_pixelBuffer.Set((PixelBufferCoordinate)characterPoint,
(oldPixel, cp) => oldPixel.Blend(cp), consolePixel);*/
}
Expand Down
20 changes: 8 additions & 12 deletions src/Consolonia.Core/Drawing/FourBitColorBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public ConsoleColor Color
set => SetValue(ColorProperty, value);
}

public double Opacity => 1;
public ITransform Transform => null;
public RelativePoint TransformOrigin => RelativePoint.TopLeft;

// ReSharper disable once UnusedMember.Global used by Avalonia
// ReSharper disable once UnusedParameter.Global
public IBrush ProvideValue(IServiceProvider _)
{
return this;
}

public double Opacity => 1;
public ITransform Transform => null;
public RelativePoint TransformOrigin => RelativePoint.TopLeft;
}

public class FourBitBrushConverter : TypeConverter
public class FourBitBrushConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
Expand All @@ -66,15 +66,11 @@ public override object ConvertFrom(
ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string s)
{
return Enum.TryParse(s, out ConsoleColor result)
? result
return Enum.TryParse(s, out ConsoleColor result)
? result
: null;
}


return null;
}
}


}
2 changes: 1 addition & 1 deletion src/Consolonia.Core/Drawing/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public IGeometryImpl Intersect(IGeometryImpl geometry)
throw new NotImplementedException();
}

public bool StrokeContains([NotNull]IPen pen, Point point)
public bool StrokeContains([NotNull] IPen pen, Point point)
{
if (pen!.Thickness == 0)
return false;
Expand Down
16 changes: 8 additions & 8 deletions src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ void IDrawingContextLayerImpl.Blit(IDrawingContextImpl context)

bool IDrawingContextLayerImpl.CanBlit => true;

public IDrawingContextImpl CreateDrawingContext()
{
return new DrawingContextImpl(_consoleWindow, _bufferBuffer);
}

public bool IsCorrupted => false;


private void OnResized(Size size, WindowResizeReason reason)
{
Expand Down Expand Up @@ -110,7 +117,7 @@ private void RenderToDevice()
throw new InvalidOperationException("Caret is already shown");
caretPosition = new PixelBufferCoordinate(x, y);
}

/* todo: There is not IWindowImpl.Invalidate anymore.
if (!_consoleWindow.InvalidatedRects.Any(rect =>
rect.ContainsExclusive(new Point(x, y)))) continue;*/
Expand Down Expand Up @@ -221,12 +228,5 @@ public void Flush()
_stringBuilder.Clear();
}
}

public IDrawingContextImpl CreateDrawingContext()
{
return new DrawingContextImpl(_consoleWindow, _bufferBuffer);
}

public bool IsCorrupted => false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace Consolonia.Core.Infrastructure
{
public class ArrowsAndKeyboardNavigationHandler : IKeyboardNavigationHandler
{
private readonly IKeyboardNavigationHandler _keyboardNavigationHandler;

//todo: check XTFocus https://github.com/jinek/Consolonia/issues/105#issuecomment-2089015880
private IInputRoot _owner;

private readonly IKeyboardNavigationHandler _keyboardNavigationHandler;

public ArrowsAndKeyboardNavigationHandler(IKeyboardNavigationHandler keyboardNavigationHandler)
{
_keyboardNavigationHandler = keyboardNavigationHandler;
Expand Down
26 changes: 12 additions & 14 deletions src/Consolonia.Core/Infrastructure/ConsoleWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public ConsoleWindow()
Handle = null!;
}

private IMouseDevice MouseDevice { get; }

public void Dispose()
{
Closed?.Invoke();
Expand All @@ -41,7 +43,7 @@ public void Dispose()
Console.FocusEvent -= ConsoleOnFocusEvent;
Console.Dispose();
}

public void SetInputRoot(IInputRoot inputRoot)
{
_inputRoot = inputRoot;
Expand Down Expand Up @@ -77,7 +79,7 @@ public void SetFrameThemeVariant(PlatformThemeVariant themeVariant)
{
//todo:
}

public Size ClientSize
{
get
Expand Down Expand Up @@ -105,7 +107,6 @@ public Size ClientSize
public Compositor Compositor { get; } = new(null);
public Action Closed { get; set; }
public Action LostFocus { get; set; }
private IMouseDevice MouseDevice { get; }

public WindowTransparencyLevel TransparencyLevel => WindowTransparencyLevel.None;

Expand Down Expand Up @@ -241,6 +242,14 @@ public void SetExtendClientAreaTitleBarHeightHint(double titleBarHeight)
// ReSharper disable once UnassignedGetOnlyAutoProperty todo: what is this property
public Thickness OffScreenMargin { get; }

public object TryGetFeature(Type featureType)
{
if (featureType == typeof(ISystemNavigationManagerImpl))
return null;
if (featureType == typeof(ITextInputMethodImpl)) return null;
throw new NotImplementedException("Consider this");
}

private void ConsoleOnMouseEvent(RawPointerEventType type, Point point, Vector? wheelDelta,
RawInputModifiers modifiers)
{
Expand Down Expand Up @@ -334,16 +343,5 @@ await Dispatcher.UIThread.InvokeAsync(() =>
}, DispatcherPriority.Input);
}
}

public object TryGetFeature(Type featureType)
{
if (featureType == typeof(ISystemNavigationManagerImpl))
return null;
if (featureType == typeof(ITextInputMethodImpl))
{
return null;
}
throw new NotImplementedException("Consider this");
}
}
}
2 changes: 1 addition & 1 deletion src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Initialize()
.Bind<IRenderTimer>().ToConstant(new UiThreadRenderTimer(120))
.Bind<IDispatcherImpl>().ToConstant(new ManagedDispatcherImpl(null))
/*.Bind<IRenderTimer>().ToConstant(new SleepLoopRenderTimer(120))*/
/*SleepLoopRenderTimer : IRenderTimer*/
/*SleepLoopRenderTimer : IRenderTimer*/
/*.Bind<IRenderLoop>().ToConstant(new RenderLoop()) todo: is internal now*/
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control))
.Bind<IKeyboardDevice>().ToConstant(new ConsoleKeyboardDevice())
Expand Down
4 changes: 1 addition & 3 deletions src/Consolonia.Core/Infrastructure/ExceptionSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public bool IsEnabled(LogEventLevel level, string area)
public void Log(LogEventLevel level, string area, object source, string messageTemplate)
{
Log(level, area, source, messageTemplate, Array.Empty<object>());
}

// ReSharper disable UnusedMember.Global
} // ReSharper disable UnusedMember.Global
public void Log<T0>(LogEventLevel level, string area, object source, string messageTemplate, T0 propertyValue0)
{
Log(level, area, source, messageTemplate, new object[] { propertyValue0 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ public void Print(PixelBufferCoordinate bufferPoint, ConsoleColor backgroundColo
throw new NotSupportedException("Is not supposed to be rendered");

if (str.Any(
c => ConsoleText.IsWideChar(c) &&
char.IsLetterOrDigit(c) /*todo: https://github.com/SlimeNull/NullLib.ConsoleEx/issues/2*/))
{
c => ConsoleText.IsWideChar(c) &&
char.IsLetterOrDigit(c) /*todo: https://github.com/SlimeNull/NullLib.ConsoleEx/issues/2*/))
throw new NotSupportedException("Is not supposed to be rendered");
}

Console.Write(str);

Expand Down
3 changes: 2 additions & 1 deletion src/Consolonia.Core/InternalHelpers/CommonInternalHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace Consolonia.Core.InternalHelpers
internal static class CommonInternalHelper
{
public static bool IsNearlyEqual(this double value, double compareTo)
{//todo: strange implementation for this name
{
//todo: strange implementation for this name
return value.CompareTo(compareTo) == 0;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Consolonia.Core/Styles/ResourceIncludeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ public IStyle Loaded
return _loaded[0];
}
}

public bool TryGetResource(object key, ThemeVariant theme, out object value)
{
if (!_isLoading && Loaded is IResourceProvider p)
return p.TryGetResource(key, theme, out value);

value = null;
return false;
}
Expand Down
15 changes: 8 additions & 7 deletions src/Consolonia.Core/Text/FontManagerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@ namespace Consolonia.Core.Text
/// </summary>
internal class FontManagerImpl : IFontManagerImpl
{
public static string GetTheOnlyFontFamilyName()
{
return "ConsoleDefault(F7D6533C-AC9D-4C4A-884F-7719A9B5DC0C)";
}

public string GetDefaultFontFamilyName()
{
return GetTheOnlyFontFamilyName();
}

string[] IFontManagerImpl.GetInstalledFontFamilyNames(bool checkForUpdates)
{
return new []{GetTheOnlyFontFamilyName()};
return new[] { GetTheOnlyFontFamilyName() };
}

public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch,
public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight,
FontStretch fontStretch,
CultureInfo culture, out Typeface typeface)
{
throw new NotImplementedException();
Expand All @@ -44,5 +40,10 @@ public bool TryCreateGlyphTypeface(Stream stream, out IGlyphTypeface glyphTypefa
{
throw new NotImplementedException();
}

public static string GetTheOnlyFontFamilyName()
{
return "ConsoleDefault(F7D6533C-AC9D-4C4A-884F-7719A9B5DC0C)";
}
}
}
4 changes: 2 additions & 2 deletions src/Consolonia.Core/Text/GlyphRunImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public GlyphRunImpl(IGlyphTypeface glyphTypeface, IReadOnlyList<GlyphInfo> glyph
new Size(glyphInfos.Sum(info => info.GlyphAdvance), FontRenderingEmSize));
}

public ushort[] GlyphIndices { get; }

public void Dispose()
{

}

public IReadOnlyList<float> GetIntersections(float lowerLimit, float upperLimit)
Expand All @@ -35,6 +36,5 @@ public IReadOnlyList<float> GetIntersections(float lowerLimit, float upperLimit)
public double FontRenderingEmSize { get; }
public Point BaselineOrigin { get; }
public Rect Bounds { get; }
public ushort[] GlyphIndices { get; }
}
}
Loading

0 comments on commit d4f7440

Please sign in to comment.