Posted 18 years ago by Manel
Avatar
I'm migrating a big IDE from another control to syntaxEditor.

I've been making some tests, and I can't seem to get a keyword hilighted properly.

This is the core I'm using:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim Language As New ActiproSoftware.SyntaxEditor.SyntaxLanguage("BlitzMax", False) '= codigo.Document.Language
        Language.ExampleText = "This is a regular text message.\r\n" & _
        "INFO   : This is a sample info message.\r\n" & _
        "WARNING: This is a sample warning.\r\n" & _
        "ERROR  : This is a sample error.\r\n"
        Dim defaultHighlightingStyle As ActiproSoftware.SyntaxEditor.HighlightingStyle = Language.HighlightingStyles("DefaultStyle")
        Dim HS As New HighlightingStyle("Module Keywords", "Module Keywords", Color.Black, Color.Aqua, False, False, True)
        Language.HighlightingStyles.Add(HS)
        Language.HighlightingStyles.Add(New HighlightingStyle("InfoMessageDelimiterStyle", Nothing, Color.DarkGreen, Color.Empty, True, False, False))

        Language.HighlightingStyles.Add(New HighlightingStyle("InfoMessageDefaultStyle", Nothing, Color.Green, Color.Empty, False, False, False))
        Language.HighlightingStyles.Add(New HighlightingStyle("WarningMessageDelimiterStyle", Nothing, Color.DarkBlue, Color.Empty, True, False, False))
        Language.HighlightingStyles.Add(New HighlightingStyle("WarningMessageDefaultStyle", Nothing, Color.Blue, Color.Empty, False, False, False))
        Language.HighlightingStyles.Add(New HighlightingStyle("ErrorMessageDelimiterStyle", Nothing, Color.DarkRed, Color.Empty, True, False, False))
        Language.HighlightingStyles.Add(New HighlightingStyle("ErrorMessageDefaultStyle", Nothing, Color.Red, Color.Empty, False, False, False))

        '' Create an info message state
        Dim infoMessageLexicalState As LexicalState = New LexicalState("InfoMessageState")
        infoMessageLexicalState.DefaultTokenKey = "InfoMessageDefaultToken"
        infoMessageLexicalState.DefaultHighlightingStyle = Language.HighlightingStyles("InfoMessageDefaultStyle")
        infoMessageLexicalState.LexicalScopes.Add(New LexicalScope())
        infoMessageLexicalState.LexicalScopes(0).StartLexicalPatternGroup = _
            New LexicalPatternGroup(LexicalPatternType.Regex, "InfoMessageStartToken", _
            Language.HighlightingStyles("InfoMessageDelimiterStyle"), "^INFO \s* :")

        Dim LPG As New LexicalPatternGroup(LexicalPatternType.Explicit, "keyowrds2", HS)

        Dim lp As LexicalPattern = New LexicalPattern("Method")
        LPG.Add(New LexicalPattern("Info"))
        LPG.Add(lp)

        'LPG.CaseSensitivity = CaseSensitivity.AutoCorrect       'This makes nothing
        Dim I As Integer = infoMessageLexicalState.LexicalPatternGroups.Add(LPG)
        infoMessageLexicalState.LexicalPatternGroups(I).CaseSensitivity = CaseSensitivity.AutoCorrect

        infoMessageLexicalState.LexicalScopes(0).EndLexicalPatternGroup = _
            New LexicalPatternGroup(LexicalPatternType.Regex, "InfoMessageEndToken", _
            Language.HighlightingStyles("InfoMessageDelimiterStyle"), "{LineTerminatorMacro}")
        Language.LexicalStates.Add(infoMessageLexicalState)

        'Add Lexical States:
        Dim lexicalState As LexicalState = New LexicalState("DefaultState")
        lexicalState.DefaultHighlightingStyle = defaultHighlightingStyle
        lexicalState.ChildLexicalStates.Add(infoMessageLexicalState)
        Language.LexicalStates.Add(lexicalState)
        Language.DefaultLexicalState = lexicalState

        Language.IsUpdating = False

        codigo.Document.Language = Language
        codigo.Document.AutoCaseCorrectEnabled = True
        codigo.Document.AutoCharacterCasing = CharacterCasing.Normal

        codigo.Document.Reparse()

    End Sub
It is a code of a form called Fom1, that has a SyntaxEditor called Codigo.
I can create a Lexical state called infoMessageLexicalState, inside this there's a keyword called Method, Anyword that includes the letters of Method (example DoMethod) hilites the 'Method' part. anyway to solve this?

Comments (1)

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

I just replied to the email you sent on this before the posting appeared.
Yes SyntaxEditor can handle all this fine, you just need to tweak several
things in your language definition. I'll look for your email reply.


Actipro Software Support

The latest build of this product (v24.1.1) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.