danipen / textmatesharp Goto Github PK
View Code? Open in Web Editor NEWA port of tm4e to bring TextMate grammars to dotnet ecosystem
License: MIT License
A port of tm4e to bring TextMate grammars to dotnet ecosystem
License: MIT License
I'm using AvaloniaEdit and am using it as a replacement for a WPF RichTextBox I was using in a custom control.
Look at the AE docs it says I need to implement IRegistryOptions but I can't find any examples of what any of the requirements are for doing so. This is all pretty complex stuff and I can't find anything to give me a nudge in the right direction.
I found a message saying to look at the implementation for AvaloniaEdit but the link is now a 404 and looking over all the branches it seems to have vanished.
My requirements are really simple.
I just have a handful of key words to be green and a handful of keywords to be Red but I just cannot figure out what to do with the interface. It all seems geared up for a much more complex use case and I'm left struggling a bit to be honest.
Are there any docs I'm missing or examples?
if language doesn't have extensions, NullReferenceException is thrown.
Solution: add
if (language.Extensions == null)
continue;
before foreach loop, as by RegistryOptions.GetLanguageByExtension
I am trying to parse the vue file .
It is found that the embedded language inside cannot be parsed normally. What configuration is needed to achieve this goal?
In your sample code I see that the GetFilePath(string scopeName)
method is automatically called in IRegistryOptions
.
I can see that some embedded languages needed by vue will find its tmlanguage files in this way. Is this related to the problem I mentioned?
Hello,
First, thanks for this project!
I am using TextMateSharp through AvaloniaEdit.TextMate project and I would like to have support for arm and arm64.
I do not have an arm machine to test it, but the onigwrap.dll
seem to be missing when I compile for win-arm64
, although it appears for win-x64
.
I would like support for the following .NET target runtimes:
linux-arm64
osx-x64
osx-arm64
win-arm
win-arm64
Does it work on arm machines?
Calling "grammar.TokenizeLine(line,rulestack)" by two threads at the same time will cause thread safety problems. How do you solve them?
I try to use this tool to parse Json grammar。
When I parse the complete Json text, I can get the correct result, but I want to parse the grammar of a certain line alone and cannot get the correct result.
I guess it should be StackElement in IGrammar.TokenizeLine(string lineText, StackElement prevState)
can be used to contact context analysis.
How to deal with such problems?
Thanks a lot!
Describe the bug
Syntax Highlighting appears to be broken after nested multi line strings
one: |-
this is fine
two:
two: |-
this is fine
shouldnt-be-highlighted:
test:
one: |
this is fine
two:
two: |
this is fine
shouldnt-be-highlighted:
test:
one: >
this is fine
two:
two: >
this is fine
shouldnt-be-highlighted:
test:
one: >-
this is fine
two:
two: >-
this is fine
shouldnt-be-highlighted:
test:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Lines following a nested multi line string should be highlighted correctly
Screenshots
Left is VS Code, right is AvaloniaEdit
Desktop (please complete the following information):
Hi,
Would it be possible to get a new version released that contains #53 ?
Reason for asking: I just tried to build an application of mine that uses AvaloniaEdit / TextMateSharp as .NET 8 using the RC1 release, and it fell over at runtime due to the reflection based serializers being disabled by default - and I think that change should fix it by using the serializer context in more places.
Thanks,
TextMateSharp.Themes.FontStyle is currently a class with int fields representing a bitfield. This sort of bitfield is normally represented in c#/dotnet as an enum with the [Flags]
attribute, so FontStyle should be updated to match.
Unhandled exception rendering component: Operation is not supported on this platform.
System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Threading.Thread.Start()
at TextMateSharp.Model.TMModel.TokenizerThread.Run() in /_/src/TextMateSharp/Model/TMModel.cs:line 63
at TextMateSharp.Model.TMModel.Start() in /_/src/TextMateSharp/Model/TMModel.cs:line 334
at TextMateSharp.Model.TMModel.SetGrammar(IGrammar grammar) in /_/src/TextMateSharp/Model/TMModel.cs:line 282
at AvaloniaEdit.TextMate.TextMateColoringTransformer.SetGrammar(IGrammar grammar)
at AvaloniaEdit.TextMate.TextMate.Installation.SetGrammar(String scopeName)
Found while trying AvaloniaEdit running on the webassembly.
I saw the package TextmateSharp.Wasm.
Is it possible to run with AvaloniaEdit?
For me AvaloniaEdit alone works in Wasm. As soon as I add some highlighting it breaks, with or without the TextMateSharp.Wasm package.
Maybe I am not doing it right, since I didn't see any demo project for this
We use TextMateSharp in our projects; on our tests, projects compiled with AnyCPU platform either do not copy onigwrap.dll to the bin folder (in case of packages.config), or copy x86 version of onigrwrap.dll (in case of sdk-style projects/package references). On the x64 platform, the project cannot load this dll and fails to run.
Please consider providing additional packages like TextMateShar.onigwrap.dll.Native.win-x64/TextMateShar.onigwrap.dll.Native.win-x86,
and implementing run-time binding to the correct version of onigwrap.dll depending on the platform.
Please take a look at ClearScript project which does it this way:
https://www.nuget.org/packages/Microsoft.ClearScript
(different platforms are handled inside V8SplitProxyNative.Generated.cs)
System.Text.Json is compatible still with .NET Standard via NuGet package. Also, they've added source generator support for even better performance and reducing of reflection.
Was wondering if there's any plans/thoughts on migrating to the new infrastructure from Newtonsoft.Json?
Firstly - thank you for this project!
From what I can see thus far, the grammar needs to be the JSON format only, is that right? Do you have any plans to implement support for the XML Plist grammar similar to what exists in tm4e?
I realize there is a workaround to convert those XML grammars to JSON, so this is a good-to-have feature, albeit lower priority.
Once again, thanks!
When a machine has configured to use Turkish culture, the following exception happens trying to load the Ini grammar:
System.IO.FileNotFoundException : The grammar package 'TextMateSharp.Grammars.Resources.Grammars.ıni.package.json' was not
found.
Hi,
We use TextMateSharp in our new generic parser.
There are a few features that we'd like to see in the next version of TextMateSharp
Please consider adding the name of the matched token to the ParsedThemeRule, so it's possible to match the token name from the tokens (right now, we can only get colors from the token). Here's a code snippet
foreach (var themeRule in theme.Match(token.Scopes))
{
name = themeRule.name;
}
We use the name of the matched token for our lexical styles collection.
Please also consider parsing language-configuration.json into C# classes. We use language configuration to get code snippets, code folding, indentation rules, etc.
Another small issue - IStateStack does not uniquely identifies the stack object; please add RuleId (at least) to this interface.
BTW, StateStack.GetHashCode throws exceptions most of the time.
Finally, please consider signing TextMateSharp assemblies with strong names, as we're getting errors when adding the package to our strong-name signed assemblies.
We were able to work around most of these issues (except for the last one), by porting/changing some code from TextMateSharp.
Happy to send you our modifications if needed.
I'm attaching a screenshot for your reference.
Kind regards,
Dmitry
[email protected]
This suddenly popped up when I alt-tabbed back to plastic. I'd changed a source file that I think was visible in the diff view.
I could continue working after forcibly killing plastic. What exactly has been corrupted and should I be concerned?
DEBUG ExceptionHandler - Stack trace: at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
at TextMateSharp.Themes.Theme.Match(IList`1 scopeNames) in /_/src/TextMateSharp/Themes/Theme.cs:line 42
at AvaloniaEdit.TextMate.TextMateColoringTransformer.ProcessTokens(Int32 lineNumber, List`1 tokens)
at AvaloniaEdit.TextMate.TextMateColoringTransformer.TransformLine(DocumentLine line, ITextRunConstructionContext context)
Wen trying to parse the following line using the csharp grammar:
string s = "chars: 安定させる";
The IToken::StartIndex
and IToken::EndIndex
for the string token are not correct.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.