Files
Progrart/Progrart/Controls/BaseEditor.axaml.cs
Creeper Lv 75b9292c34 Added DialogHost as dialog system.
Implemented create folder and progrart image in menu in file explorer.
2025-12-24 00:55:56 +11:00

37 lines
953 B
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaEdit.TextMate;
using TextMateSharp.Grammars;
namespace Progrart.Controls;
public partial class BaseEditor : UserControl
{
RegistryOptions _registryOptions;
TextMate.Installation _textMateInstallation;
public string Text
{
get => CodeEditBox.Text;
set => CodeEditBox.Text = value;
}
public BaseEditor()
{
InitializeComponent();
{
var _textEditor = CodeEditBox;
_registryOptions = new RegistryOptions(ThemeName.DarkPlus);
_textMateInstallation = _textEditor.InstallTextMate(_registryOptions);
_textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(_registryOptions.GetLanguageByExtension(".js").Id));
}
}
public void SetGrammerByExtension(string extension_name)
{
_textMateInstallation.SetGrammar(
_registryOptions.GetScopeByLanguageId(
_registryOptions.GetLanguageByExtension(extension_name).Id
)
);
}
}