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 

Autoclose creates additional close tag in SyntaxMemo

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



Joined: 03 Dec 2008
Posts: 4
Location: Raleigh, NC, USA

PostPosted: Wed Apr 06, 2011 4:10 am    Post subject: Autoclose creates additional close tag in SyntaxMemo Reply with quote

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.

Code:

#if
 
#endif


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
View user's profile Send private message
Viola



Joined: 03 Dec 2008
Posts: 4
Location: Raleigh, NC, USA

PostPosted: Wed Apr 06, 2011 11:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
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