Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Syntax Edit
  New Posts New Posts RSS Feed - 13,1 sample and SetSyntaxAndColorScheme
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

13,1 sample and SetSyntaxAndColorScheme

 Post Reply Post Reply
Author
Message
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Topic: 13,1 sample and SetSyntaxAndColorScheme
    Posted: 03 July 2009 at 8:21pm

I'm obviously missing something, but I find the MDI Text Editor sample in 13.1 quite baffling.

In the 13.0 sample, which lacked the SetSyntaxAndColorScheme calls and menu options, loading any of the recognized file types did result in appropriate syntax coloring.
 
In the 13.1 sample there is rather different behaviour. If you load a .cpp file it works fine to apply syntax coloring. But if you load any other file, including ones that it should know about such as .schclass files, then these don't display any syntax coloring at all.


For example, open any of the sample .schclass files. They display in black and white.

Select Reload Syntax... nothing changes.

Select ReloadSyntaxMode... nothing changes.

BUT, if you choose ReloadSyntax2IniMode then.... yes! Coloring is applied!

 
However, I'm still no nearer to understanding how the SetSyntaxAndColorScheme calls work as in the sample they don't seem to do anything unless the file is a CPP file (.cpp or .h). The menu option additions that are new to the 13.1 sample (ReloadSyntaxMode etc) seem designed to illustrate the application of this call, but for anything other than a CPP file they do nothing. I realise that the code is specifically loading just the CPP coloring scheme, but why doesn't this call apply the CPP syntax to whatever file is currently loaded? It seems to "know" that it is not a CPP file--where is this set and how can I override it?

What I want to do is apply my own .schclass schema, loaded and passed via a string variable, and have this apply to any text displayed in the syntax editor. Moreover, I don't want the choice of syntax rules to depend on the file extension. For example, how is it possible to set the syntax coloring style for a new file that has not yet been saved? As the sample currently stands, such files never show syntax coloring and it isn't obvious how I can change this.

Any help appreciated....

 

Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 03 July 2009 at 8:47pm
You can modify sample or use prev version of sample - it should works properly.
SetSyntaxAndColorScheme used for passing Syntax and Color schemes as strings without any files involved.
Sample use CPP for such case because this scheme already stored as a string in app complilation.
IniMode works as previous file-based mode.
If you need to set file extention - there is a function SetPassedIniSet
e.g.

GetEditCtrl().SetPassedIniSet(_T("[Schemes]\r\nSQL\r\n[Themes]\r\nDefault\r\nAlternative\r\n"));

Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2009 at 3:25am
I tried that but it doesn't seem to do anything.
 
I think I'd be able to adjust things for my own uses if you could explain how it is possible to get the syntax editor sample to use the CPP coloring scheme, which it certainly does know about, when editing a fresh unsaved file, to which it currently applies no syntax coloring. In this situation the SetSyntaxAndColorScheme explicitly defaults to the CPP scheme (or uses the SetPassedIniSet values), so using SetPassedIniSet wouldn't help me choose a custom syntax mode.
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2009 at 12:13pm
this is why I use example with SQL syntax passed instead of CPP
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2009 at 4:58pm
If I knew how I could make a blank UNSAVED file display SQL coloring by modifying the sample then I could apply this to my own situation. However, I don't know how to do this. The sample itself does not do any syntax coloring until a file is saved. SetPassedIniSet does not change this as far as I can tell.
 
What I want to do is apply syntax coloring to a set of arbitrary text that I will ultimately store as a string within a data file. The text concerned is NEVER saved as a separate file, so I have to be able to tell the editor to use a particular syntax when displaying it.
 
There must be a way to do this.
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2009 at 5:47pm
Sure - open Issue and I will help you
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2009 at 8:44pm
Thanks Mark, I have done so, and am surprised (and pleased) that you have already responded on this.
 
However, I must say that overall I'm rather saddened by the policy of routing things via private support tickets as I get a lot of help by looking at answers given to other people. If we arrive at an answer I will post it here so that others might benefit.
 
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2009 at 10:08pm
This is a policy
and this is a static app I did to robin:
 
It take syntax and color schemes as a strings
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 05 July 2009 at 4:43am
Mark has been really helpful and I'm very grateful for this.
 
The little application is nice and I hope that we can see a couple of extra small samples put into future builds of the Toolkit as it would make it much easier to use the syntax editor if this was the case.
 
I said that I'd post the solution. It turns out that the trick to enabling syntax coloring when the text has not been loaded from a file is not too difficult:
 
GetEditBuffer()->SetFileExt(_T(".XXX"));
 
where XXX is the extension you which to use, as defined in your syntax definition
 
and don't forget to add

#define _XTP_INCLUDE_SYNTAXEDIT_LEXER

before including the XTToolkitPro.h file
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
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.125 seconds.