Skip to content

Commit

Permalink
Merge pull request #111 from SkEditorTeam/dev/dev
Browse files Browse the repository at this point in the history
v2.8.0
  • Loading branch information
NotroDev authored Aug 6, 2024
2 parents c4a85ea + 183080b commit a39fc13
Show file tree
Hide file tree
Showing 45 changed files with 390 additions and 158 deletions.
2 changes: 1 addition & 1 deletion Installer/Package.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="SkEditor" Manufacturer="Notro" Version="2.7.1" UpgradeCode="14564974-da58-4917-8a0d-590043f589c2">
<Package Name="SkEditor" Manufacturer="Notro" Version="2.8.0" UpgradeCode="14564974-da58-4917-8a0d-590043f589c2">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
<MediaTemplate EmbedCab="yes" />

Expand Down
5 changes: 5 additions & 0 deletions SkEditor/API/Utilities/IFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public interface IFiles
/// <param name="select">Should the new created tab be selected right after its creation or not.</param>
public void AddCustomTab(object header, Control content, bool select = true, IconSource? icon = null);

/// <summary>
/// Add a new editor tab with the desired content.
///
public Task<OpenedFile> AddEditorTab(string content, string? path);

/// <summary>
/// Select the desired opened file's tab item.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions SkEditor/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<Brush x:Key="TextControlPlaceholderForegroundFocused">#26FFFFFF</Brush>
<Brush x:Key="SearchPanelBackgroundBrush">#161616</Brush>


<Brush x:Key="CurrentLineBackground">#05FFFFFF</Brush>
<Brush x:Key="CurrentLineBorder">#0DFFFFFF</Brush>

<Thickness x:Key="FlyoutContentPadding">10</Thickness>

<FontFamily x:Key="JetBrainsFont">avares://SkEditor/Assets/JetBrainsMono#JetBrains Mono</FontFamily>
Expand Down
30 changes: 30 additions & 0 deletions SkEditor/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using Serilog;
using SkEditor.API;
using SkEditor.Utilities;
using SkEditor.Utilities.InternalAPI;
using SkEditor.Views;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace SkEditor;

Expand All @@ -32,6 +36,32 @@ public override async void OnFrameworkInitializationCompleted()
.WriteTo.Sink(new LogsHandler())
.CreateLogger();

Dispatcher.UIThread.UnhandledException += async (sender, e) =>
{
e.Handled = true;
string? source = e.Exception.Source;
if (AddonLoader.DllNames.Contains(source + ".dll"))
{
Log.Error(e.Exception, $"An error occured in an addon: {source}");
await SkEditorAPI.Windows.ShowMessage("Error", $"An error occured in an addon: {source}\n\n{e.Exception.Message}");
return;
}
string message = "Application crashed!";
Log.Fatal(e.Exception, message);
Console.Error.WriteLine(e);
Console.Error.WriteLine(message);
await SkEditorAPI.Core.SaveData();
AddonLoader.SaveMeta();
var fullException = e.Exception.ToString();
var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(fullException));
await Task.Delay(500);
Process.Start(Environment.ProcessPath, "--crash " + encodedMessage);
Environment.Exit(1);
};

Mutex mutex = new(true, "{217619cc-ff9d-438b-8a0a-348df94de61b}");

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
Expand Down
1 change: 1 addition & 0 deletions SkEditor/Assets/Icons.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<ui:PathIconSource x:Key="DocumentMultipleIcon" Data="M4 4.25A2.25 2.25 0 0 1 6.25 2h4.381a2.25 2.25 0 0 1 1.591.659l4.619 4.619c.422.422.659.994.659 1.59v8.382a2.25 2.25 0 0 1-2.25 2.25h-9A2.25 2.25 0 0 1 4 17.25v-13Zm2.25-.75a.75.75 0 0 0-.75.75v13c0 .414.336.75.75.75h9a.75.75 0 0 0 .75-.75V8.998h-3.246a2.25 2.25 0 0 1-2.25-2.25V3.5H6.25Zm5.754 1.062v2.186c0 .414.336.75.75.75h2.185l-2.935-2.936ZM6.629 20.5A2.25 2.25 0 0 0 8.75 22h6.5A4.75 4.75 0 0 0 20 17.25v-5.881a2.25 2.25 0 0 0-.66-1.591l-.84-.841v8.313a3.25 3.25 0 0 1-3.25 3.25H6.629Z"/>
<ui:PathIconSource x:Key="SessionRestoringIcon" Data="M12 4.5a7.5 7.5 0 1 1-7.419 6.392c.067-.454-.265-.892-.724-.892a.749.749 0 0 0-.752.623A9 9 0 1 0 6 5.292V4.25a.75.75 0 0 0-1.5 0v3c0 .414.336.75.75.75h3a.75.75 0 0 0 0-1.5H6.9a7.473 7.473 0 0 1 5.1-2Z"/>
<ui:PathIconSource x:Key="ConnectionsIcon" Data="M9.25 7a.75.75 0 0 1 .11 1.492l-.11.008H7a3.5 3.5 0 0 0-.206 6.994L7 15.5h2.25a.75.75 0 0 1 .11 1.492L9.25 17H7a5 5 0 0 1-.25-9.994L7 7h2.25ZM17 7a5 5 0 0 1 .25 9.994L17 17h-2.25a.75.75 0 0 1-.11-1.492l.11-.008H17a3.5 3.5 0 0 0 .206-6.994L17 8.5h-2.25a.75.75 0 0 1-.11-1.492L14.75 7H17ZM7 11.25h10a.75.75 0 0 1 .102 1.493L17 12.75H7a.75.75 0 0 1-.102-1.493L7 11.25h10H7Z"/>
<ui:PathIconSource x:Key="HighlightCurrentLineIcon" Data="M20.259 2.004a.75.75 0 0 1 .742.649l.007.102-.004 4.497a2.254 2.254 0 0 1-2.001 2.234v2.26a2.25 2.25 0 0 1-2.096 2.245l-.154.005H16.5v2.792a2.25 2.25 0 0 1-1.14 1.958l-.155.08-6.635 3.106a.75.75 0 0 1-1.061-.579l-.007-.1v-7.257H7.25A2.25 2.25 0 0 1 5.005 11.9L5 11.746v-2.26a2.25 2.25 0 0 1-1.994-2.072L3 7.25V2.754a.75.75 0 0 1 1.493-.102l.007.102V7.25c0 .38.282.694.648.744L5.25 8h13.501c.38 0 .695-.283.746-.649l.007-.101.004-4.497a.75.75 0 0 1 .75-.75ZM15 13.996H9.003v6.077l5.567-2.606a.75.75 0 0 0 .424-.572l.008-.107L15 13.996ZM17.502 9.5H6.5v2.246c0 .38.282.694.648.743l.102.007h9.503a.75.75 0 0 0 .743-.648l.007-.102-.001-2.246Z"/>


<ui:SymbolIconSource x:Key="RefreshIcon" Symbol="Refresh"/>
Expand Down
2 changes: 2 additions & 0 deletions SkEditor/Controls/Docs/DocumentationControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ await SkEditorAPI.Windows.ShowMessage(Translation.Get("Success"),
}
});

Loaded += (sender, args) => QueryBox.Focus();

KeyDown += (sender, args) =>
{
if (args is { Key: Key.Enter, KeyModifiers: KeyModifiers.None } && QueryBox.IsFocused)
Expand Down
2 changes: 1 addition & 1 deletion SkEditor/Controls/MainMenuControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<ui:SymbolIcon Symbol="SaveAs"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{DynamicResource MenuHeaderSaveAll}" Name="MenuItemSaveAll" HotKey="Ctrl+Alt+S" InputGesture="Ctrl+Alt+S">
<MenuItem Header="{DynamicResource MenuHeaderSaveAll}" Name="MenuItemSaveAll" InputGesture="Ctrl+Alt+S">
<MenuItem.Icon>
<ui:SymbolIcon Symbol="SaveAs"/>
</MenuItem.Icon>
Expand Down
18 changes: 18 additions & 0 deletions SkEditor/Controls/MainMenuControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public MainMenuControl()
InitializeComponent();

AssignCommands();
AddMissingHotkeys();
}

private void AssignCommands()
Expand Down Expand Up @@ -72,6 +73,23 @@ private static void ShowDialogIfEditorIsOpen(AppWindow window)
window.ShowDialog(SkEditorAPI.Windows.GetMainWindow());
}

private void AddMissingHotkeys()
{
Loaded += (_, _) =>
{
SkEditorAPI.Windows.GetMainWindow().KeyDown += (sender, e) =>
{
if (e.PhysicalKey == PhysicalKey.S
&& e.KeyModifiers == (KeyModifiers.Control | KeyModifiers.Alt)
&& string.IsNullOrEmpty(e.KeySymbol))
{
MenuItemSaveAll.Command.Execute(null);
e.Handled = true;
}
};
};
}

public static void AddDocsTab()
{
FluentIcons.Avalonia.Fluent.SymbolIconSource icon = new()
Expand Down
3 changes: 3 additions & 0 deletions SkEditor/Languages/English.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
<system:String x:Key="SettingsPersonalizationSyntaxDescription">Set how specific text is displayed with syntax highlightings.</system:String>
<system:String x:Key="SettingsPersonalizationFont">Font</system:String>
<system:String x:Key="SettingsPersonalizationFontDescription">Current font: {0}</system:String>
<system:String x:Key="SettingsPersonalizationHighlightCurrentLine">Highlight current line</system:String>

<!-- Theme Settings -->
<system:String x:Key="SettingsThemeTitle">Theme</system:String>
Expand Down Expand Up @@ -415,6 +416,8 @@
<system:String x:Key="ThemeEditorMenuBackground">Menu background</system:String>
<system:String x:Key="ThemeEditorMenuBorder">Menu border</system:String>
<system:String x:Key="ThemeEditorFocusedTextBoxBackground">Focused text box background</system:String>
<system:String x:Key="ThemeEditorCurrentLineBackground">Current line background</system:String>
<system:String x:Key="ThemeEditorCurrentLineBorder">Current line border</system:String>
<system:String x:Key="ThemeEditorAccentColor">Accent color</system:String>

<!-- Welcome Tab -->
Expand Down
3 changes: 3 additions & 0 deletions SkEditor/Languages/Polish.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
<system:String x:Key="SettingsPersonalizationSyntaxDescription">Ustaw sposób wyświetlania określonego tekstu z podświetlaniem składni.</system:String>
<system:String x:Key="SettingsPersonalizationFont">Czcionka</system:String>
<system:String x:Key="SettingsPersonalizationFontDescription">Aktualnie: {0}</system:String>
<system:String x:Key="SettingsPersonalizationHighlightCurrentLine">Podświetl bieżącą linię</system:String>

<!-- Theme Settings -->
<system:String x:Key="SettingsThemeTitle">Motyw</system:String>
Expand Down Expand Up @@ -415,6 +416,8 @@
<system:String x:Key="ThemeEditorMenuBackground">Tło menu</system:String>
<system:String x:Key="ThemeEditorMenuBorder">Obramowanie menu</system:String>
<system:String x:Key="ThemeEditorFocusedTextBoxBackground">Tło aktywnego pola tekstowego</system:String>
<system:String x:Key="ThemeEditorCurrentLineBackground">Tło aktualnej linii</system:String>
<system:String x:Key="ThemeEditorCurrentLineBorder">Obramowanie aktualnej linii</system:String>
<system:String x:Key="ThemeEditorAccentColor">Kolor wiodący</system:String>

<!-- Welcome Tab -->
Expand Down
38 changes: 7 additions & 31 deletions SkEditor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using Avalonia;
using Avalonia.Data;
using Serilog;
using SkEditor.API;
using SkEditor.Utilities.InternalAPI;
using System;
using System.Diagnostics;

namespace SkEditor.Desktop
{
Expand All @@ -17,13 +13,18 @@ class Program
public static void Main(string[] args)
{
GC.KeepAlive(typeof(RelativeSource));
CheckTest(args);

// Check for the --test argument
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}

private static void CheckTest(string[] args)
{
if (args.Length > 0 && args[0] == "--test")
{
try
{
// Here you can add any initialization code that you want to test
Console.WriteLine("Test passed");
}
catch (Exception e)
Expand All @@ -33,31 +34,6 @@ public static void Main(string[] args)
}
return;
}

try
{
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}
catch (Exception e)
{
string message = "Application crashed!";
string? source = e.Source;
if (AddonLoader.DllNames.Contains(source + ".dll"))
{
message += $" It's fault of {source} addon.";
}
Log.Fatal(e, message);
Console.Error.WriteLine(e);
Console.Error.WriteLine(message);

SkEditorAPI.Core.SaveData();
AddonLoader.SaveMeta();

var fullException = e.ToString();
var encodedMessage = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(fullException));
Process.Start(Environment.ProcessPath, "--crash " + encodedMessage);
}
}

// Avalonia configuration, don't remove; also used by visual designer.
Expand Down
38 changes: 17 additions & 21 deletions SkEditor/SkEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>SkEditor.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<AssemblyVersion>2.7.1</AssemblyVersion>
<FileVersion>2.7.1</FileVersion>
<Version>2.7.1</Version>
<InformationalVersion>2.7.1-prerelease</InformationalVersion>
<AssemblyVersion>2.8.0</AssemblyVersion>
<FileVersion>2.8.0</FileVersion>
<Version>2.8.0</Version>
<InformationalVersion>2.8.0</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>CS8600;CS8604;CS8622;CS8603;CS8602;CA2211;CS8619;CS8629;CS8601;CS8618;CS8620</NoWarn>
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PropertyGroup>
<NoWarn>CS8600;CS8604;CS8622;CS8603;CS8602;CA2211;CS8619;CS8629;CS8601;CS8618;CS8620</NoWarn>
<DebugType>portable</DebugType>
</PropertyGroup>
Expand Down Expand Up @@ -48,28 +44,28 @@

<ItemGroup>
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.2.1" />
<PackageReference Include="Avalonia" Version="11.1.0" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.1.0" />
<PackageReference Include="Avalonia" Version="11.1.1" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.1" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.1.1" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.1" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />

<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0" />
<PackageReference Condition="'$(Configuration)' == 'Release'" Include="Avalonia.Controls.DataGrid" Version="11.1.0" />
<PackageReference Condition="'$(Configuration)' == 'Release'" Include="Avalonia.Controls.ColorPicker" Version="11.1.0" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.1" />
<PackageReference Condition="'$(Configuration)' == 'Release'" Include="Avalonia.Controls.DataGrid" Version="11.1.1" />
<PackageReference Condition="'$(Configuration)' == 'Release'" Include="Avalonia.Controls.ColorPicker" Version="11.1.1" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageReference Include="FluentIcons.Avalonia.Fluent" Version="1.1.249" />
<PackageReference Include="FluentIcons.Avalonia.Fluent" Version="1.1.250" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Protocol" Version="6.11.0-preview.2" />
<PackageReference Include="Octokit" Version="13.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="SkAvaloniaEdit" Version="11.0.6.7" />
<PackageReference Include="SkFluentAvalonia" Version="2.0.5.2" />
<PackageReference Include="SkAvaloniaEdit" Version="11.0.7" />
<PackageReference Include="SkFluentAvalonia" Version="2.0.5.3" />
<PackageReference Include="SpacedGrid-Avalonia" Version="11.0.0" />
<PackageReference Include="Svg.Skia" Version="2.0.0" />
<PackageReference Include="System.Threading.AccessControl" Version="9.0.0-preview.5.24306.7" />
Expand Down
Loading

0 comments on commit a39fc13

Please sign in to comment.