-pulizia codice
-aggiunto gestione colore su script
This commit is contained in:
@@ -556,11 +556,14 @@ Public Class ScriptWindowVM
|
||||
Dim textRange As New TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd)
|
||||
Dim text As String = textRange.Text
|
||||
|
||||
Dim keywords As String() = {"local ", "function", "end", " if ", " then ", " else ", "for ", "while", "do", "return"}
|
||||
Dim colorsArray As String() = {"WHITE", "LGRAY", "GRAY", "BLACK", "RED", "MAROON", "YELLOW", "OLIVE", "LIME", "GREEN",
|
||||
"AQUA", "TEAL", "BLUE", "NAVY", "FUCHSIA", "PURPLE", "ORANGE", "BROWN"}
|
||||
Dim keywords As String() = {"local ", "function", "end", " if ", " then ", " else ", "for ", "while", "do", "return", "true", "nil", "_ENV", "_G"}
|
||||
'Dim colorsArray As String() = {"WHITE", "LGRAY", "GRAY", "BLACK", "RED", "MAROON", "YELLOW", "OLIVE", "LIME", "GREEN",
|
||||
' "AQUA", "TEAL", "BLUE", "NAVY", "FUCHSIA", "PURPLE", "ORANGE", "BROWN"}
|
||||
Dim ValueKey As String() = {".CMP_Draw", ".N1", ".V1", ".T1", ".Npar", ".Nome", ".INFO", ".WithInt", ".CMP", ".GLOB", ".ROOT"}
|
||||
Dim keywordColor As Color = Colors.Blue
|
||||
Dim commentColor As Color = Colors.Green
|
||||
Dim valueColor As Color = Colors.MediumSeaGreen
|
||||
Dim egtColor As Color = Colors.LightGoldenrodYellow
|
||||
Dim infoColor As New System.Windows.Media.Color With {
|
||||
.A = 255,
|
||||
.R = 206,
|
||||
@@ -570,31 +573,46 @@ Public Class ScriptWindowVM
|
||||
Dim functionColor As Color = Colors.BlueViolet
|
||||
|
||||
Dim pattern As String = "(?<=function\s)[^(]+"
|
||||
Dim pattern2 As String = "'([^']*)'"
|
||||
Dim pattern3 As String = "(?<!')\bEgt\w*\b(?!')"
|
||||
|
||||
' Instantiate the regular expression object.
|
||||
Dim regex As New Regex(pattern, RegexOptions.IgnoreCase)
|
||||
Dim regex2 As New Regex(pattern2, RegexOptions.IgnoreCase)
|
||||
Dim regex3 As New Regex(pattern3, RegexOptions.IgnoreCase)
|
||||
|
||||
' Ottieni tutte le corrispondenze
|
||||
Dim matches As MatchCollection = regex.Matches(text)
|
||||
Dim matches2 As MatchCollection = regex2.Matches(text)
|
||||
Dim matches3 As MatchCollection = regex3.Matches(text)
|
||||
|
||||
' Itera attraverso tutte le corrispondenze e stampale
|
||||
For Each match As Match In matches
|
||||
HighlightText(rtb, text, " " & match.ToString(), functionColor)
|
||||
Next
|
||||
|
||||
' Evidenzia le info
|
||||
For Each match2 As Match In matches2
|
||||
HighlightText(rtb, text, match2.ToString(), infoColor)
|
||||
Next
|
||||
|
||||
'' Evidenzia le parole che iniziano per Egt
|
||||
'For Each match3 As Match In matches3
|
||||
' HighlightText(rtb, text, match3.ToString(), egtColor)
|
||||
'Next
|
||||
|
||||
' Evidenzia le parole chiave
|
||||
For Each valueItem In ValueKey
|
||||
HighlightText(rtb, text, valueItem, valueColor)
|
||||
Next
|
||||
|
||||
' Evidenzia le value chiave
|
||||
For Each keyword In keywords
|
||||
HighlightText(rtb, text, keyword, keywordColor)
|
||||
Next
|
||||
|
||||
' Evidenzia le info
|
||||
For Each color In colorsArray
|
||||
HighlightText(rtb, text, "'" & color & "'", infoColor)
|
||||
Next
|
||||
|
||||
' Evidenzia i commenti
|
||||
HighlightText(rtb, text, "--", commentColor, True)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub HighlightText(rtb As RichTextBox, text As String, word As String, color As Color, Optional isComment As Boolean = False)
|
||||
|
||||
Reference in New Issue
Block a user