Create HighlightingStyle's which will overwrite the previous ones.

SyntaxEditor for WPF Forum

Posted 3 years ago by Daniel Constantin - ModuleWorks GmbH
Version: 19.1.0687
Avatar

Hi,

How can I create some HighlightingStyle which will overwrite the previous ones ?

I have some HighlightingStyle which do some text Bold and after that I create other HighlightingStyle which do some coloring. The thing is that after the coloring I will still have parts of the text which is bold.

There is some option to overwrite this the behavior of HighlightingStyle, not to combine multiple styles ?

Kind regards,

Daniel

Comments (7)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

It's hard to say what's happening in your particular scenario without having a simple sample project to debug.  Can you put a new simple sample project together that shows this and send it to our support address, mentioning this thread?  Then we can have a look at that.  Be sure to exclude the bin/obj folders from the .zip you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 3 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi,

https://www.actiprosoftware.com/docs/controls/wpf/syntaxeditor/user-interface/styles/highlighting-styles

This is from documentation:

"All the properties in HighlightingStyle are initially set to "default" values. These default values are set up to not change formatting in any way.

In the code example above however, we have assigned a Maroon foreground Color to the style. This means that the style defined above will only change the foreground of text that it is applied against. It will not alter the bold weight, font size, etc."

In my case I want "Maroon" highlighting style to change the font to Regular because it was Bold before. The problem is if Regular is default value, it will not do anything, it will merge the styles.(I do not want merging styles). It will just keep the Bold. I want to be able to make a style overwrite all the previous existing properties of the text even though some of them are default values.

Kind regards,

Daniel

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Can you explain how you have a default value of Bold text in the editor?  Where specifically is that coming from?  Again, a code snippet showing the setup would be helpful in us understanding your scenario. 

IHighlightingStyle.Bold can be set to false to turn off Bold over the text range that the style applies.  The Bold property is a nullable boolean.  Its default is null, which means don't alter the bold setting.  But a True or False value should.


Actipro Software Support

Posted 3 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi,

I have a lexer which implements the ILexer interface. Inside the Parse method I have a tokenizer which creates tokens which are added to the ILexerTarget parseTarget parameter thru OnTokenParsed() method. For me it might happen to have a big token (like a comment one) which contains smallet tokens (like a command). I currently add the smallest tokens first which change the text style (some letters becomes bold, and the colors are changed) and after that I add the largest tokens (a comment which is just green, no bold). After this I get a comment (green foreground) with some bold letters for the command.

I have a workaround now to filter out inner tokens which can be found in larger ones and it works. I was thinking if there is a way when I apply a style for a larger token to overwrite the style currently on that text.

Kind regards,

Daniel

Posted 3 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

I have the bold property false for the comment token and it will still keep the bold letters from the previous tokens.

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Based on what you were describing, it sounds like you might be returning tokens that overlap each other from the ILexer?  As an example with a C# comment, with what I mean, say you have the document text "/*a*/".  Is your lexer returning a token for the "a" text range that is bold and another token for the entire "/*a*/" that is not bold?

If so, that is not a supported scenario and would explain why you are having trouble.  The lexer needs to be returning sequential non-overlapping tokens.  For SyntaxEditor to work properly, you should return three tokens for the above example:  "/*", "a", and "*/".  

I hope that helps.


Actipro Software Support

Posted 3 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

That is exactly what I was doing. Some tokens were overlapped. I was thinking that maybe I can set the styles to overwrite previous styles.

Kind regards,

Daniel

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.