How do i use the "built in lexers"

Topics: User Forum
Feb 9, 2009 at 2:55 PM
I don't understand anything:

At this page:

It says that i can use the ConfigurationManager.Language to set the language for the syntax highlighting, but it also says that i can use the built in lexers -

1. Why is there both lexers and ConfigurationManager.Language?
2. What is the lexers
3. How do i set the lexers

I need the Batch lexer:
Sorry if i misunderstand it all.

Feb 9, 2009 at 5:06 PM
Hey guys sorry for the long hiatus. I'm probably not going to be actively working on ScintillaNET but I can at least field these kinds of questions.

The ConfigurationManager is a superset of the Lexer Langauge. It's basically just a fancy object that can set almost all ScintillaNET's properties from an XML file.
What the lexer does is designates a language parser to look through the text and set styles on blocks of code.

I like to think of Scintilla styling as kind of like CSS classes. Take this line of code

if (someInt < 5)

What the Lexer does is goes through and marks it up kind of like this
<span class="keyword">if</span> <span class="operator">(</span><span class="identifier">someInt</span> <span class="operator">&lt;</span> <span class="number">5</span><span class="operator">)</span>

(Note that Scintilla and ScintillaNET don't actually use CSS, this is just an analogy)
However similar to HTML just marking up the code like this won't actually put colors on the screen, you also need to define how those classes should be displayed. This is done through the Styles Object. However the Styles object isn't the most intuitive object to use. The ConfigurationManager makes it easy by allowing you to store Style information in XML using named styles. It also can store pretty much any other ScintillaNET property. Each of these groups of configurations are considered a "Language".

Feb 9, 2009 at 10:14 PM
Hi i'm also having trouble understanding how this works although i'm more wondering how to change certain properties. Here's what i want to do:-

  1. make any word begining with # change colour
  2. change the colours of the words already changed by the lexer (e.g. variables start with $ are in purple, i would like them brown just because it's an easier transfer from current editor.)
  3. make keywords go bold when recognised
Feb 10, 2009 at 7:30 AM
I don't understand your post (ChrisRickard) - is i possible to highlight Batch using the "built in lexer"

If it's possible, please give me an example in VB.NET or C#

If it's not possible please say that
Feb 10, 2009 at 7:59 AM
Technically, yes you can. However you aren't going to get the results you expect.

You can do it by setting the ConfigurationManager.Language property
scintillaDocument.ConfigurationManager.Language = "Batch";
Or you can set it via the Windows Forms Designer.

The problem is we don't have a configuration for Batch as of yet. The built in "Batch" lexer will look through the document and styles according to the batch rules, but there are missing pieces still. You need to define things like keywords, what each style will actually look like, and comment strings.

Someone has to create a configuration file and define all these rules that are specific for batch. You can do this yourself by taking one of the languages we have configurations for and modifying it for Batch. mssql.xml and pgsql.xml are good ones to start with.

You can find these files in the source code under ScintillaNET/Configuration/Builtin.
Feb 10, 2009 at 8:08 AM
Thanks, i use it now, and it highlights echo and things...
Thank you very much it is super that i can have a such good free source code editing component, i have used in 3 of my apps now.
Feb 10, 2009 at 8:14 AM
Or!, now i maybe understand

Nearly every thing gets red