|
EControl Ltd. VCL libraries and software support forum
|
View previous topic :: View next topic |
Author |
Message |
Alex
Joined: 12 Jun 2006 Posts: 2
|
Posted: Mon Jun 12, 2006 1:05 am Post subject: Rules and keywords highlighting priority |
|
|
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 |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Fri Jun 16, 2006 10:17 am Post subject: |
|
|
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 |
|
|
Alex
Joined: 12 Jun 2006 Posts: 2
|
Posted: Sat Jun 17, 2006 11:20 am Post subject: |
|
|
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 |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
|
Back to top |
|
|
|
|
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
|