|
EControl Ltd. VCL libraries and software support forum
|
View previous topic :: View next topic |
Author |
Message |
Viola
Joined: 03 Dec 2008 Posts: 4 Location: Raleigh, NC, USA
|
Posted: Wed Apr 06, 2011 4:10 am Post subject: Autoclose creates additional close tag in SyntaxMemo |
|
|
Hi
My problem is that I want to be able to autoclose code tags, but it doesn't always work as expected. An example of this is a cpp file with the preprocessor tags #if, which is closed with #endif.
First, I'll describe the normal behaviour:
I open the cpp file and type "#if" and hit Enter. This auto-closes the tag with a "#endif" and a line between them, with the cursor on it. i.e.
Hitting enter again adds another blank line between the tags.
Now for the abnormal behaviour:
if I have something (could be a comment, or even just whitespace) after the #endif tag (on the same line), if I place the cursor between the tags and press Enter, a second end tag is added. i.e.
Code: |
#if
#endif
#endif //comment
|
This is my SyntAnalyzer block rules for the cpp #if directive (loaded from a lexer file):
Code: |
item
DisplayName = '#if'
ConditionList = <
item
TagList.Strings = (
'\#if')
CondType = tcMask
TokenTypes = 512
end>
BlockEnd = '#endif'
DisplayInTree = False
HighlightPos = cpBound
CollapseFmt = '%s0'
IgnoreAsParent = True
AutoCloseMode = acmCloseNearest
AutoCloseText = '#endif'
end
item
DisplayName = '#endif'
BlockType = btRangeEnd
ConditionList = <
item
TagList.Strings = (
'#endif')
TokenTypes = 512
end>
HighlightPos = cpBound
IgnoreAsParent = False
end
|
Please can you help me solve this problem? Any insights or thoughts on where I might look?
Thanks. |
|
Back to top |
|
|
Viola
Joined: 03 Dec 2008 Posts: 4 Location: Raleigh, NC, USA
|
Posted: Wed Apr 06, 2011 11:57 pm Post subject: |
|
|
Hi
I managed to figure this out (with some help from a work colleague).
The solution was to edit the lexer file (changed lines are marked with an arrow):
Code: |
item
DisplayName = '#if'
ConditionList = <
item
TagList.Strings = (
'\#if')
CondType = tcMask
TokenTypes = 512
end>
BlockEnd = '#endif'
DisplayInTree = False
HighlightPos = cpBound
CollapseFmt = '%s0'
IgnoreAsParent = True
AutoCloseMode = acmCloseNearest
AutoCloseText = '#endif'
end
item
DisplayName = '#endif'
BlockType = btRangeEnd
ConditionList = <
item
TagList.Strings = (
'\#endif.*') <== previously '#endif')
CondType = tcMask <== new line
TokenTypes = 512
end>
HighlightPos = cpBound
IgnoreAsParent = False
end
|
Hopefully, if anyone else has this problem, this will help them. |
|
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
|