Multi-line content divider

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Steven Liu
Avatar
Hi,
I am working with file format like this:

SECTION Options1
Option1=Val1
Option2=Val2 !comment1


!comment2
SECTION Options2
Option3=Val3
Option4=Val4
I defined a multi-line content divider:

<RegexPatternGroup Type="EndScope" TokenKey="SectionEndToken" Style="DefaultStyle" PatternValue="(\n[ ]*\n|\n)" LookAhead="([ ]*(!.*)?\n)*[ ]*(SECTION|\z)" CaseSensitivity="Insensitive" IsContentDivider="True" />
I use (\n[ ]*\n|\n) as PatternValue because I want to include the next blank line(if there is one) in the scope, so IntelliPrompt would work properly in that blank line. It seems to work, except that the content divider is displayed twice. It seems that when EndScope token spans multiple lines, SyntaxEditor draws divider for every line. Is there a way to only draw one divider at the last line of the EndScope token?

For you reference, here's the complete xml:

<SyntaxLanguage Key="TEST" LanguageDefinitionVersion="3.0" Secure="True" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">

    <Styles>
        <Style Key="KeywordStyle" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="CommentDelimiterStyle" ForeColor="Green" BackColor="Default" Bold="False" Italic="False" Underline="False" />
        <Style Key="CommentDefaultStyle" ForeColor="Green" BackColor="Default" Bold="False" Italic="False" Underline="False" />
    </Styles>
 
    <States> 
        <State Key="DefaultState">
            <ChildStates>
                <ChildState Key="SectionState" />
                <ChildState Key="CommentState" />
            </ChildStates>
        </State>
        <State Key="SectionState">
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="SectionStartToken" Style="KeywordStyle" PatternValue="SECTION" LookAhead="{NonWordMacro}" CaseSensitivity="AutoCorrect" />
                    <RegexPatternGroup Type="EndScope" TokenKey="SectionEndToken" Style="DefaultStyle" PatternValue="(\n[ ]*\n|\n)" LookAhead="([ ]*(!.*)?\n)*[ ]*(SECTION|\z)" CaseSensitivity="Insensitive" IsContentDivider="True" />
                </Scope>
            </Scopes>
            <ChildStates>
                <ChildState Key="CommentState" />
            </ChildStates>
        </State> 
        <State Key="CommentState" TokenKey="CommentDefaultToken" Style="CommentDefaultStyle">
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="CommentStartToken" Style="CommentDelimiterStyle" PatternValue="!" />
                    <RegexPatternGroup Type="EndScope" TokenKey="CommentEndToken" Style="CommentDelimiterStyle" PatternValue="." LookAhead ="\n" />
                </Scope>
            </Scopes>
        </State>
    </States> 
</SyntaxLanguage>
FYI, the complex EndScope LookAhead pattern for SECTION state is look ahead to find the next SECTION keyword, meanwhile ignore multiple blank lines or comment lines in between. In another words, I don't want to include second and further blank lines in the SECTION state, same for comment lines. It works well.

my semantic parser is very simple:

    Public Overrides Sub GetTokenOutliningAction(ByVal tokenStream As TokenStream, ByRef outliningKey As String, ByRef tokenAction As OutliningNodeAction)
        ' Get the token
        Dim token As token = tokenStream.Peek()

        ' generic parser
        Dim state As String
        If token.Key.EndsWith("StartToken") Then
            state = token.Key.Remove(token.Key.Length - 10, 10)
            If state <> "String" And state <> "Comment" Then
                outliningKey = state & "Block"
                tokenAction = OutliningNodeAction.Start
            End If
        ElseIf token.Key.EndsWith("EndToken") Then
            state = token.Key.Remove(token.Key.Length - 8, 8)
            If state <> "String" And state <> "Comment" Then
                outliningKey = state & "Block"
                tokenAction = OutliningNodeAction.End
            End If
        End If

    End Sub
Thanks.
Steven

Comments (4)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Steven,

Thanks for the post, I'll add this bug to the TODO list.


Actipro Software Support

Posted 18 years ago by Steven Liu
Avatar
Thanks. would you give me some idea when we'll have a release that includes the fix?
Steven
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It's now fixed for the next maintenance release, which should be pretty soon.


[Modified at 08/20/2006 11:41 PM]


Actipro Software Support

Posted 18 years ago by Steven Liu
Avatar
That is great. Thank a lot.
Steven
The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.