Custom Configurations

Topics: Developer Forum, User Forum
May 29, 2009 at 7:32 PM
Edited May 29, 2009 at 7:33 PM

I'm having difficulty using a custom configuration by instructing it to load the configuration manually ala:

XmlReader xmlR = XmlReader.Create(new StringReader(Resources.LuaConfig));
XmlDocument configDoc = new XmlDocument();
configDoc.Load(xmlR);
Configuration luaConfig = new Configuration("LuArch");
luaConfig.Load(configDoc);

this.LuaEditor.ConfigurationManager.LoadOrder = ConfigurationLoadOrder.CustomBuiltInUser;
this.LuaEditor.ConfigurationManager.Language = "LuArch";
this.LuaEditor.ConfigurationManager.Configure(luaConfig);
xmlR.Close();

From the above, I think I have it structured properly; however, I'm honestly not familiar enough with ScintillaNet to be sure, but the issue is: it doesn't highlight anything.  The actual language is a variant of Lua used in a project I'm working on.  The primary difference is I'm just adding a few keywords for internal purposes, which relate more to the code generation side of things, the stuff that's known but not exactly expressly visible in the editor, as it's generated later.

I've uploaded the configuraiton file here.  If you can figure out what might be causing the system to not  highlight properly, please let me know.

Oddly the autocomplete list seems to be loading, but the highlighting aspect seems to be unavailable.  I'm also pretty sure it's not just a color issue, because the system doesn't properly enable collapse of comments using --[[ and --]].

Thanks,

May 29, 2009 at 8:00 PM

After corresponding with an online associate of mine, I've learned the issue lies within Scintilla itself, not ScintillaNET.

I wasn't aware that the system only had a default subset of lexers, I was under the impression that it used some sort of simple DFA architecture that built the lexer from the keyword system you provided and a few special rules that defined common functionality among programs.  After using a few of his suggestions, I think I can get this to work; however, perhaps a bit better idea of what ScintillaNET is and what it is not would be appropriate for the main page, such as expressly stating that if the language isn't set to the default series of values, it won't work unless you build your own version of Scintilla and ScintillaNET to incorporate your custom language's lexer.

So I suppose this could be considered resolved.

Coordinator
May 29, 2009 at 8:37 PM

Look on the home page, link titled "How do I get syntax highlighting to work?". While there is no built in configuration for LuArch I assume this is a dialect of Lua. In your config on the Lexer element set LexerName="lua".

May 29, 2009 at 8:43 PM

Indeed, this is essentially what I have done.  My initial error was ignoring the relation of lexer and language.  I was oversimplifying it when I should have not.  I should know that the lexer is important since I've written a Lexer generator, but that's another matter entirely ;]

 

A question for you, if I may:  Does the usage of the individual keyword repositories happen in an arbitrary manner, as in each lexer uses all keyword slots, or is it more of a lexer specific function?  I tried specifying the second set of keywords for Lua, but it's ignoring them entirely, which probably gives me my answer.

Coordinator
May 29, 2009 at 9:09 PM

It's lexer specific. There really is no standard and each lexer author tends to use whatever they want. There's no Scintilla documentation on these but I went through each of the lexer sources and recorded which ones each lexer used and how the lexer refers to them. I put them in the source tree (Lua is here). Each line maps to the Keyword index. I never got around to allowing the string value though. So you still need to use <Keywords List="2"> for "String, (table) & math functions".

Along the same lines check out the style names for Lua here. I noticed your config has a lot of styles defined that don't apply to the Lua lexer.

 

 

May 29, 2009 at 10:26 PM

I appreciate the insight towards the Scintilla control.  I noticed that specifics information is also embedded in the ScintillaNET control, such as:

ScintillaNet.Configuration.Builtin.LexerKeywordListNames.lua.txt

I'm not sure if it's intentionally embedded into the assembly's resources, but I did notice it.  I wasn't sure exactly what it was until you told me.

As far as the style names, I basically ripped out the default configuration's options and altered them to suit my needs.  I had a feeling some were unused by Lua but at the time I was more interested in making it work.  I'll probably minimize the list with the information you provided.

Thanks again,

Coordinator
May 29, 2009 at 10:32 PM

They're embedded resources becuase at one time I intended to use them in much the same way I use the style names. It just never happened and can safely be set to build action none to reduce the assembly size.