project: reorganize the structure of the project.

* remove dotnet-tool.json because the project does not rely on any dotnet tools.
* remove Directory.Build.props because the solution has only one project.
* move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
leo 2024-04-02 20:00:33 +08:00
parent 96e60da7ad
commit 96d4150d26
319 changed files with 37 additions and 53 deletions

View file

@ -0,0 +1,63 @@
using System;
using System.IO;
using Avalonia.Styling;
using AvaloniaEdit;
using AvaloniaEdit.TextMate;
using TextMateSharp.Grammars;
namespace SourceGit.Models
{
public static class TextMateHelper
{
public static TextMate.Installation CreateForEditor(TextEditor editor)
{
if (App.Current?.ActualThemeVariant == ThemeVariant.Dark)
{
return editor.InstallTextMate(new RegistryOptions(ThemeName.DarkPlus));
}
else
{
return editor.InstallTextMate(new RegistryOptions(ThemeName.LightPlus));
}
}
public static void SetThemeByApp(TextMate.Installation installation)
{
if (installation == null)
return;
var reg = installation.RegistryOptions as RegistryOptions;
if (App.Current?.ActualThemeVariant == ThemeVariant.Dark)
{
installation.SetTheme(reg.LoadTheme(ThemeName.DarkPlus));
}
else
{
installation.SetTheme(reg.LoadTheme(ThemeName.LightPlus));
}
}
public static void SetGrammarByFileName(TextMate.Installation installation, string filePath)
{
if (installation == null)
return;
var ext = Path.GetExtension(filePath);
if (ext == ".h")
{
ext = ".cpp";
}
else if (ext == ".resx" || ext == ".plist")
{
ext = ".xml";
}
var reg = installation.RegistryOptions as RegistryOptions;
installation.SetGrammar(reg.GetScopeByExtension(ext));
GC.Collect();
}
}
}