-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.axaml.cs
36 lines (28 loc) · 1.02 KB
/
MainWindow.axaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using Avalonia.Controls;
using AvaloniaEdit;
using AvaloniaEdit.TextMate;
using TextMateSharp.Grammars;
namespace SharpFM;
public partial class MainWindow : Window
{
private RegistryOptions _registryOptions;
private int _currentTheme = (int)ThemeName.DarkPlus;
private readonly TextMate.Installation _textMateInstallation;
private readonly TextEditor _textEditor;
public MainWindow()
{
InitializeComponent();
_textEditor = this.FindControl<TextEditor>("avaloniaEditor") ?? throw new Exception("no control");
_registryOptions = new RegistryOptions(
(ThemeName)_currentTheme);
_textMateInstallation = _textEditor.InstallTextMate(_registryOptions);
Language xmlLang = _registryOptions.GetLanguageByExtension(".xml");
_textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(xmlLang.Id));
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
_textMateInstallation.Dispose();
}
}