EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rules and keywords highlighting priority

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
Alex



Joined: 12 Jun 2006
Posts: 2

PostPosted: Mon Jun 12, 2006 1:05 am    Post subject: Rules and keywords highlighting priority Reply with quote

Quote:
HiMichael,

I have some troubles with implementation of highliting.
I want to create manual higlihting function like in Source Insight. When User press shift+F8 on identifier by cursor, this identifier highlighted everywhere (f.e. by yellow background). When user press shift+F8 on this identifer second time, higlihted is canceling.
I am try do it with keywords. But i have some troubles.

For example I have a rule, which all text in line with "Enter " string is in STYLE 1 (for example all line in bold font):
Enter function name1();

And when I add to keyword name1 it is not worked, because rule for line have more priority(?).

In an ideal variant, I would like that to all line STYLE1 was applied, but for the specific word ( user press shift+F8 ) in this line other style was applied (keyword style?).

Could you please help me if it possible.

Alexander.

Quote:

It is not a good solution.

Use OnGetStyleEntry to perform custom formatting.

Example:

procedure SyntaxMemo1GetStyleEntry(Sender: TObject; CurPos: integer;
StyleList: TList; var NextPos: integer);
var S: string;
begin
S := SyntaxMemo1.Lines.SubString(CurPos + 1, Length(HltWord));
if S = HltWord then
List.Add(TStyleEntry.Create(HltStyle, CurPos, CurPos + Length(HltWord)))
end;

After changing highlited word you should only invalidate editor. This the most effective way to perform custom formatting.


Another solution is to use THyperlinkHighlighter component. It is also contains a list of rules, that are over lexer's highlighting. But first way will have the best performance.


Michael.




Hi Michael,
The first variant, that you have suggested, does not work as it would be desirable.
For example, I have a rule parser with regular expression "\w+\sEnter".
It is highlight line fully:
Enter FuncNameA(a, b); {

For example I want to highlight all "FuncNameA" word in all text.
For example:
Enter FuncNameA(a, b); {

What should I make?
GetStyleEntry calls only at the beginning of the block (substr(curpos)="Enter"), but not for each word or a symbol.

Thanks,
Alex
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Fri Jun 16, 2006 10:17 am    Post subject: Reply with quote

You should not use parser rules for this purpose.
The right way is to use Range rule:
type - "Tag detector"
Conditions:
1. = "" <Identifier>
2. = "Enter" <Identifier>

Michael.
Back to top
View user's profile Send private message Send e-mail
Alex



Joined: 12 Jun 2006
Posts: 2

PostPosted: Sat Jun 17, 2006 11:20 am    Post subject: Reply with quote

Michael,
I am sorry,
but my attempts have failed.

Could you please email me completed lcf file with these rules?

Thanks in advance.
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Mon Jun 19, 2006 8:36 am    Post subject: Reply with quote

Hello,

Try http://www.econtrol.ru/download/kw_test.lcf.
Also it may be required to download latest demo app. (threre are new fields added to lexer config).

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group