Posted 18 years ago
by ernesto

Here is a quick piece of info for any newbi,
This is a code snipit on how to find the location of the keyword that was just typed using the KeyPressTrigger event. Here we create a textstream for the GetTextStream method of the Document name space. Next we capture the last word typed start position in the edit control using SelctedView. Next we capture the stream (in this case only the text typed starting at the keywordstartpoint up to the current carret position, this should only capture the word typed. Next capture the keyword's tokenName, which will let us know if the word captured is actually a defined KeyWord Token from our syntax language xml file. Finally we display in a message box the two string values we found, if it is key word then the message will show the key word and its token name.thanks
Actipro
Updated to use Select Case statement for tokenName in case someone needs to find other KeyWordToken names that are defined in the Syntax Language xml file.
[Modified at 01/25/2007 05:27 PM]
[Modified at 01/25/2007 05:33 PM]
[Modified at 01/25/2007 09:34 PM]
This is a code snipit on how to find the location of the keyword that was just typed using the KeyPressTrigger event. Here we create a textstream for the GetTextStream method of the Document name space. Next we capture the last word typed start position in the edit control using SelctedView. Next we capture the stream (in this case only the text typed starting at the keywordstartpoint up to the current carret position, this should only capture the word typed. Next capture the keyword's tokenName, which will let us know if the word captured is actually a defined KeyWord Token from our syntax language xml file. Finally we display in a message box the two string values we found, if it is key word then the message will show the key word and its token name.
Private Sub SyntaxEditor_TriggerActivated(ByVal sender As Object, ByVal e As ActiproSoftware.SyntaxEditor.TriggerEventArgs) Handles SyntaxEditor.TriggerActivated
Dim stream As TextStream
Dim keywordStartPoint As Integer = SyntaxEditor.SelectedView.FindPreviousWordStart
Dim tokenName As String
stream = SyntaxEditor.Document.GetTextStream(keywordStartPoint)
tokenName = stream.Token.Key
Select Case tokenName
Case "ReservedWordToken"
MessageBox.Show("Key word =" & " " & "(" & stream.TokenText & ")" & " " & "Token name =" & " " & "(" & tokenName & ")")
End Select
End Sub
Actipro
Updated to use Select Case statement for tokenName in case someone needs to find other KeyWordToken names that are defined in the Syntax Language xml file.
[Modified at 01/25/2007 05:27 PM]
[Modified at 01/25/2007 05:33 PM]
[Modified at 01/25/2007 09:34 PM]