This project is read-only.

How to implement my own Highlightning

Topics: Developer Forum
Sep 28, 2007 at 7:50 AM
Edited Sep 28, 2007 at 7:52 AM
Hi there,

As you see, I've got a new problem. I try to implement my own highlightning with my own keywords, probably also some special colors and so on. But don't worry about the colors yet, I'm happy if at least the highlighting works with default colors which were already defined somewhere.

I use the latest source code. It's not easy to understand the way how to implement my own XML file with the keywords. I don't really see how these Keywords are in touch with the colors neither. So what I've already got, is the following XML file [1] and some source code which doesn't work, so I don't paste it. It's also because of the lot of trays which all failed and made the code unreadable. What always works, is the AutoComplete and also the Snippets function, but not the Highlighting.
It would be nice if you could explain me how to implement my own Highlighting :-). I see that the C# and HTML Highlighting works fine, so the Highlighting is already implemented (I saw a posting where was written, that the implementation is not finished yet)!?

I tried to create a new Instance of the 'Configuration' class and to load my XML file. This object I'm giving to the ScintillaNet ConfigurationManager with the Method "Configure". As I see, the ConfigurationManager is used to add Snippets and also AutoComplete, but how do I add Highlighting? It has to be something done with the Lexer Class or the ScintillaNet Lexer Property; But what and how can I find out?

I hope you understand my problem and you can help me ;-).
Gregor W.

<?xml version="1.0" encoding="utf-8"?>
<Language Name="test">
<AutoComplete FillUpCharacters=".([" SingleLineAccept="True" IsCaseSensitive="False">
gregor peter

<Indentation TabWidth="4" SmartIndentType="cpp" />

<Lexer LineCommentPrefix="//" StreamCommentPrefix="/* " StreamCommentSuffix=" /*" >
<Keywords List="0" Inherit="False">gregor</Keywords>
<Keywords List="1" Inherit="False">peter</Keywords>
Nov 7, 2007 at 7:20 PM
That's one thing I really need to document: getting new languages added. Also I need to document how the whole builtin/custom/user and default/language layering works. Unfortunately to really understand it you need to know how Scintilla lexers work, which is also poorly documented and very difficult to understand.

For instance adding your own keywords is lexer specific. In this case since you are using XML there really is no "keyword" in the sense that say c# has. XML (which in Scintilla is really the exact same lexer as HTML but case sensitive) recognizes tags, attributes, comments, and strings. It doesn't give a special style to keywords inside of an element. The exception to this of course is script, which is also language specific.

So if you intend to have an element name or attribute name of "gregor" or "peter" you can use <Keywords List="0"> to get the TAG Style or ATTRIBUTE style. However this won't work:
<sometag>This will not be colorized: gregor</sometag>
becuase the XML lexer doesn't look for keywords in that way.
Nov 12, 2007 at 1:20 PM
An example lexer is something I really want to get into the repo. So hopefully I'll get it done here soon. At least a basic example that we can improve over time.