Question: How to set syntax highlighting rules programmatically on the fly
See original GitHub issueI am able to set some syntax highlighting rules with textEditor.SyntaxHighlighting.MainRuleSet.Rules.Add()
Unfortunately, changes to this list are not applied to the editor on the fly and I haven’t found any method to trigger a refresh once the editor is loaded.
I intended to use AvalonEdit to highlight multiple user defined values in log files. Is this possible?
Best regards, Carsten
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Changes to syntax highlighting
We are now moving to a more tag-based syntax highlighting method. There are one of three possible syntax highlighting hints associated with each ......
Read more >Dynamically update syntax highlighting mode rules for the ...
Totally new to ace editor dev, to dynamically add additional rules to a mode file for syntax highlighting I'm doing an ajax call...
Read more >Working with Syntax Highlighting
Syntax Highlighting is what makes the editor automatically display text in different styles/colors, depending on the function of the string in relation to ......
Read more >How to Syntax Highlight Code on Stack Overflow 🖍️
How to add syntax highlighting to your code blocks on Stackoverflow and specify a language. ⭐ Get my full-stack NextJS with Express ...
Read more >Syntax Highlighting | GitLab
GitLab provides syntax highlighting on all files through Highlight.js and the Rouge Ruby gem. ... Configure maximum file size for highlighting.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is, link below. I’ll make a few disclaimers. I’m only handling 24’ish colors and underline/reverse (most multi-user dimension games only support those colors). A little hacky but I strip the rest of the codes out I don’t support before it gets to the terminal. Also, the
DocumentColorizingTransformer
provides you a line to colorize so to make things easier on myself I provided everything I need to format that line in the line (if a color was started on line 24, when 25 comes down from the server I include the last color from the previous line at the start of line 25), that way, no matter what line or what order AvalonEdit gives me lines in I can color/style it correctly.Although on reviewing this code just now I see a bug where if I have a style (underline) and a color it only brings the last ANSI code over to the next line. I’ll need to fix that.
Here’s the link, the AvalonTerminal folder has most of the pieces in it including the
AnsiColorizer
. I welcome any feedback.Repo: https://github.com/blakepell/AvalonMudClient Folder: https://github.com/blakepell/AvalonMudClient/tree/master/src/Avalon.Client/Controls/AvalonTerminal
I’m currently writing / using AvalonEdit to render text that’s colored with ANSI control sequences (think of an SSH window coloring text, that’s exactly it). For this I used a
DocumentColorizingTransformer
which fires for lines rendered to the screen (and the you do the color stuff in code). As an example, I could add more ANSI control sequences on the fly if I wanted to (I already know them all but the variables for the rule could come from a database, a file, user input, etc).Create a class that inherits from “DocumentColorizingTransformer” and then fill in the pieces in the ColorizeLine method you override. The C# route should be flexible enough to implement dynamic rules. Then you just add that class into the
TextArea.TextView.LineTransforms
list.