Keywords are not highlighting

Topics: Developer Forum, User Forum
Mar 20, 2012 at 1:32 PM
Edited Mar 20, 2012 at 2:34 PM

Hello, this is my first time using ScintillaNET in one of my projects.

I need to have syntax highlighting, however keywords are not being highlighted. I seem to be doing some things right.

      <Style Name="default" ForeColor="Red"/>
      <Style Name="linenumber" ForeColor="gray"/>
      <Style Name="comment" ForeColor="green"/>
      <Style Name="word" ForeColor ="blue"/>  

The default, line number, and  comment are all working great, but the keywords are not. As far as I understand Name="word" refers to all the keywords in the List="0", right?

<Lexer StreamCommentPrefix="{ " StreamCommentSuffix=" }" LexerName="cpp">
      <Keywords List="0">example1 example2</Keywords>
      <Keywords List="1">example2 example3</Keywords>
      <Keywords List="2">example3 example4</Keywords>    

However the keywords in List 0 are not highlighting in blue, they just stay red. I've tried a bunch of stuff and nothing seems to be working. I am confused right now.

Thanks in advance. 

Mar 20, 2012 at 3:02 PM

Ok, this works...

textBox.Lexing.SetKeywords(0, "private public class void");  

However how do you get it to work with the .xml file? Am I messing up the Lexer tag?

Mar 20, 2012 at 3:15 PM

You may need to get the latest release. There was a recently fixed problem with keywords not highlighting. Also try these changes to your styles:

      <Style Name="DOCUMENT_DEFAULT" ForeColor="Red"/>
      <Style Name="LINENUMBER" ForeColor="gray"/>
      <Style Name="COMMENT" ForeColor="green"/>
      <Style Name="WORD" ForeColor ="blue"/>  

Offhand I don't remember if the Names are case sensitive but all the built in configs specify them in upper case. Also the DEFAULT style has an non-intuitive behavior (again I don't remember the specifics offhand). I don't recommend using it to set a default ForeColor. Instead use DOCUMENT_DEFAULT and IDENTIFIER.

the cpp lexer uses these styles as do most others. This file lists all the styles that the cpp lexer will use:

Mar 21, 2012 at 8:48 PM

I have version 2.4, which seem to be the latest update. I don't think it is case sensitive. I tried both upper/lower case and there is no difference. 

Mar 22, 2012 at 1:53 AM

Actually, the fix that Chris is referring to hasn't made it out in a release yet. See thread 348309 for details. Hopefully that's what your issues it.



Mar 22, 2012 at 3:15 AM
Edited Mar 22, 2012 at 3:16 AM

Ok, thank you very much. I solved it by applying what was suggested.

I set the ConfigurationManager.Language = "lang";  twice. Now it works perfectly. A really weird bug though...