Posted 18 years ago
by Manel
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: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?
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
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?