You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and behaves differently to what's in NuGet. When I am trying to replicate the demo implementation I can't make it work with the NuGet libraries which offer different methods in TextMate and other classes.
Sample
MainView.axaml
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:AvaloniaEditTheme2.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaEditTheme2.Views.MainView"
x:DataType="vm:MainViewModel"
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
>
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<Grid>
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<AvaloniaEdit:TextEditor Name="Editor" Text="Hello AvaloniaEdit!"
ShowLineNumbers="True"
FontFamily="Cascadia Code,Consolas,Menlo,Monospace"/>
</Grid>
</UserControl>
MainView.axaml.cs
...
using Avalonia.Controls;
using AvaloniaEdit;
using AvaloniaEdit.TextMate;
using TextMateSharp.Grammars;
namespace AvaloniaEditTheme2.Views;
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
//First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
var _textEditor = this.FindControl<TextEditor>("Editor");
//Here we initialize RegistryOptions with the theme we want to use.
var _registryOptions = new RegistryOptions(ThemeName.LightPlus);
//Initial setup of TextMate.
var _textMateInstallation = _textEditor.InstallTextMate(_registryOptions);
//Here we are getting the language by the extension and right after that we are initializing grammar with this language.
//And that's all , you are ready to use AvaloniaEdit with syntax highlighting!
_textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(_registryOptions.GetLanguageByExtension(".cs").Id));
// Python Sample
_textEditor.Text = "import subprocess\r\n\r\ndef open_visual_studio(path):\r\n try:\r\n # Use subprocess to run the command\r\n subprocess.run(f'start devenv \"{path}\"', shell=True, check=True)";
}
}
Expected Result
Theme color of ThemeName.LightPlus or any other should render in their colors
Actual result
There are no syntax theme colors applied
The text was updated successfully, but these errors were encountered:
Followed getting started instructions from here multiple times from scratch but I can't seem to apply theme styling (colors) to the AvaloniaEdit.
New Avalonia project with additional steps from https://github.com/AvaloniaUI/AvaloniaEdit to add AvaloniaEdit + apply a theme.
The AvaloniaEdit.Demo project on GitHub seems to have different properties in the TextMate classes for example
AvaloniaEdit/src/AvaloniaEdit.TextMate/TextMate.cs
Line 66 in 318277d
Sample
MainView.axaml
MainView.axaml.cs
...
Expected Result
Theme color of
ThemeName.LightPlus
or any other should render in their colorsActual result
There are no syntax theme colors applied
The text was updated successfully, but these errors were encountered: