BCGSoft Forums
BCGSoft Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 BCGSoft Professional Editor Forums
 BCGPEdit Library-related topics
 Beyond XML definitions
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Daniel Schmid

46 Posts

Posted - 01/14/2004 :  03:24:22 AM  Show Profile  Visit Daniel Schmid's Homepage  Reply with Quote
I am developping an application with a CNC-Machine ISO Editor. Until now, I used CristalEditView classes, but I would like to move on to BCGPEdit.

But: There is a number of things I don't know how to define in XML:

In ISO, most of the code goes like
Gxx Mxx Axx Fxxx #xxxx ...
or GxxMxxAxxFxxx#xxx ...

where xxx are digits.

The definition would be that a word is starts with a letter, and ends only when another letter is used or any word delimitter is found...

Furthermore I would like to define a particular color for numbers....

How can I achieve all that?

Regards
Daniel

Support

4187 Posts

Posted - 01/14/2004 :  12:03:10 PM  Show Profile  Visit Support's Homepage  Reply with Quote
Hello,

It seems that it can't be defined with XML.
So the simpliest way to define a particular color for numbers is to override the CBCGPEditCtrl::OnGetCharColor function and set up the clrText variable:
virtual void OnGetCharColor (TCHAR ch, int nOffset, COLORREF& clrText, COLORREF& clrBk)


Regarding codes
quote:
Gxx Mxx Axx Fxxx #xxxx ...
or GxxMxxAxxFxxx#xxx ...
Whould you like to customize color highlighting or to separate off the words of such sequences for other purposes?

Sincerely yours,

BCGSoft Technical Support
Go to Top of Page

Daniel Schmid

46 Posts

Posted - 01/15/2004 :  03:25:04 AM  Show Profile  Visit Daniel Schmid's Homepage  Reply with Quote
A possible solution to my problem would be the following:

You could modify the control like this:

virtual BOOL OnGetTextColor (int nStart, int& nEnd,
COLORREF& clrText, COLORREF& clrBk, BOOL bColorFound) const


Now I can return the end of the word, and I'm no longer dependent on word delimiters, I can modify if I recognize certain patterns, or I can hand on to XML definitions like before.

What do you think?

Go to Top of Page

Support

4187 Posts

Posted - 01/15/2004 :  08:39:36 AM  Show Profile  Visit Support's Homepage  Reply with Quote
Unfortunately the OnGetCharColor function is virtual and it is discouraged to modify its prototype for reasons of legacy user code and backward compatibility.

Is it absolutely necessary for you to return the end of the word?
Please look through the CBCGPEditCtrl::OnDrawText function. OnGetCharColor is called as follows:
if (OnGetTextColor (i, nNextDelimiter, clrForeground, clrBackground, bColorFound))
{
bColorFound = TRUE;
}


nNextDelimiter is a local variable and has minor importance. Using OnGetTextColor gives to you more flexebility. You can implement your custom word highlighting mechanism and use you own static nNextDelimiter variable. Furthermore if you call OnGetWordColor from your OnGetTextColor function and return TRUE then you can hand on the default coloring for the words.

Best regards,


BCGSoft Technical Support
Go to Top of Page

Daniel Schmid

46 Posts

Posted - 01/15/2004 :  09:23:47 AM  Show Profile  Visit Daniel Schmid's Homepage  Reply with Quote
This is how a colored line in my current editor looks like:
G101X-20Y50F#101(comment)
IF{#1EQ0}GOTO500

Maybe this gives you a clearer idea of the situation.

I have the following items:
- keywords (IF, ELSE, GOTO, ...)
- commands (G100, G101, G200, ...)
- variables (#1, #2, ...)
- parameters (F, X, Y, ...)
- numbers
- comment

each of this items should have its own color. except for commands and variables, everything is feasible by the use of XML and OnGetCharColor.
Variables always start with #, followed by up to 3 digits,
the commands start by ether M or G, followed by up to 3 digits. That's where i'm stuck. They have a well defined starting char, but are variable in word length...

Any suggestions?

Go to Top of Page

Daniel Schmid

46 Posts

Posted - 02/19/2004 :  02:48:43 AM  Show Profile  Visit Daniel Schmid's Homepage  Reply with Quote
Hi... do you have some more news for me regarding this issue?...

Concerning the question if I have to know the end of a word:
It would be of help if I optionally could change the current text buffer position, from where I'm analizing the syntax to color. Like this, I would be compeletely independent of word delimiters, spaces, tabs, etc and I could customize any kind of syntax coloring, especially when code is a stream of characters and letters... (like in the above example)
Do you know what I mean?....

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To:
BCGSoft Forums © Copyright (c) 1998-2022 BCGSoft Co Ltd Go To Top Of Page
Snitz Forums 2000