Codejock Forums Homepage
Forum Home Forum Home > General > Articles and Tutorials
  New Posts New Posts RSS Feed - How to load the Lex Syntax from a resource
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to load the Lex Syntax from a resource

 Post Reply Post Reply
elmue View Drop Down

Joined: 05 June 2010
Location: Germany
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote elmue Quote  Post ReplyReply Direct Link To This Post Topic: How to load the Lex Syntax from a resource
    Posted: 13 June 2010 at 10:25pm

The samples MDITextEditor and GUI_VisualStudio demonstrate how to use the SyntaxEdit control.
But both load the Lex Syntax and the color theme from files.
At least 3 files are required in the samples:

I need only one syntax for my project and don't want to fill the disk with unnecessarry files.

As an Xtreme manual does not exist I had to dive deep into the code to find out how to load the syntax from a resource rather than from files.
I will explain this here so others can save the time that I spent in finding out how to do this.

When tracing through the code I found several bugs.
You must first fix these bugs and then recompile the entire library.

Edit the file XTPSyntaxEditLexColorFileReader.cpp:

In the demo GUI_VisualStudio in the constructor CGUI_VisualStudioView() remove the line

GetEditCtrl().SetConfigFile(CXTPSyntaxEditCtrl::GetModulePath() + _T("EditConfig\\SyntaxEdit.ini"));

and replace it with the following code:

CString s_Theme = ";Comment";
CString s_Scheme;

GetEditCtrl().SetSyntaxAndColorScheme(s_Scheme, s_Theme);



The function GetResource() loads the Syntax scheme from the resources into a string.

I tried to set a color theme via s_Theme but it does not work. (There are more bugs still in the code)
But this does not matter because all the colors are already defined in the syntax scheme.
The color theme is only needed if you want to override these colors.

Please note that the "parsing" that is done for the string
is very primitive.
The string must be exactly of the above format.
It MUST end with "\r\n" !

The scheme name "CPP" is completely meaningless.

The string s_Theme must not be empty!

The comment in the code is misleading:
//m_sIniSet = _T("[Schemes]\r\nCPP\r\n[Themes]\r\nDefault\r\nAlternative\r\n");

This comment makes you think that it would be possible to add more than one Theme or more than one Scheme.
But this is not possible. The rest of the code was not designed for that.

The color of the line numbers must be set separately.


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.