Multi Language Support - looking for a decent sample

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Todd Davis - Developer, SeaburyDesign
Avatar
I know SyntaxEditor comes with a sample project, but the sample project confuses me because it demonstrates pretty much every aspect of the editor all at once, and it is hard to pin down those few things that relate specifically to the task you are trying to accomplish. I'd like to know what I need, at a bare minimum, to implement multi-language support. I want a plain vanilla, "Hello World"'ish example of what is needed to load, say, a C# file, and have it properly colored and tokenized. Is there such a sample? (Frankly, I'd like such a basic sample for each major feature of the editor, but I'll start with this one). If not, can anyone kindly post the specifics of what I need to do?

Thanks kindly,
-Todd

-Todd Davis http://www.SeaburyDesign.com

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Todd,

Thanks for the comments... that's something we're attempting to address in v4.0. While we still provide the combined MainForm, we've made a number of quickstart samples that focus on certain feature areas. So that should help reduce the learning curve.

Anyhow for multi-language support, check out the ActiproSoftware.Html.xml language definition file. It shows transitioning to CSS, JScript, and VBScript using both methods of language transitioning.

Also the DynamicallyCreateForm shows how to merge languages programmatically.


Actipro Software Support

Posted 13 years ago by Todd Davis - Developer, SeaburyDesign
Avatar
Thanks for the info. I will look into the resources listed above for more info, however in the meantime, I found the answer I was looking for, so I figured I'd share in case the next person in line was confused as well. The answer was very simple, fortunately. Assuming that you are including the Languages and Parsers folders from the demo project in your own project, then you can load the C# language file something like this:

protected override void OnLoad(EventArgs e)
{
projectPath = Path.GetFullPath(Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\");
languagePath = projectPath + @"Languages\";
editor.Document.LoadLanguageFromXml(languagePath + "ActiproSoftware.CSharp.xml", 0);
base.OnLoad(e);
}

I'm not quite sure where the second parameter of LoadLanguageFromXml() comes into play - I know it has to do with encryption, but I'm confused as to how that works and where I'd use it.

It also seems that it would be quite feasible to include the Language files as an embedded resource, and then access them from a stream. I might try that next, which would help to protect the language files from tampering or deletion.

-Todd Davis http://www.SeaburyDesign.com

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes that is correct. The second parameter is for descrambling the language file since it can be saved with an encryption code. The plain text ones just use 0 for that parameter. The reason to encrypt your language is so you can distribute it in a file and it can't be read by competition then.

Including them in a Stream is feasible too.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.