1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
' *********************** ColorizeRTF ************************
' Input:
' r as RichTextBox: RichTextBox where the colorization laws are going to be
applied
'
' This procedure applies the colorization laws to a RichTextBox.
Sub ColorizeRTF(r As RichTextBox)
' Names of step are red
Call ColorizeItemRTF(r, "--Step", vbRed, True)
' Telecommands are blue
Call ColorizeItemRTF("ISSUE", vbBlue, False)
' Calls to procedures are orange
Call ColorizeItemRTF(r, "EXECUTE", RGB(255, 128, 0), False)
' Verifications are green
Call ColorizeItemRTF(r, "CHECK_ITEM", RGB(0, 128, 0), False)
' Beginning and end of FOR and REPEAT loops are bold
Call ColorizeItemRTF(r, "FOR I:=", vbBlack, True)
Call ColorizeItemRTF(r, "END FOR", vbBlack, True)
Call ColorizeItemRTF(r, "REPEAT", vbBlack, True)
Call ColorizeItemRTF(r, "UNTIL(", vbBlack, True)
' Place the selection point at the beginning of the code and clear any
selection
r.SelStart = 0
r.SelLength = 0
End Sub
' ********************** ColorizeItemRTF **********************
' Input:
' r As RichTextBox: RichTextBox where the colorization applies
' s as String: string to look for in the code. The entire line will then be
colorized.
' l as Long: color to be used
' IsBold as Boolean: if IsBold = TRUE, then the line turns bold
'
' This procedure applies a colorization law
' "If a line contains s, then the end of the line, starting at s, will get
the following settings:
' color is l
' if IsBold is TRUE, then it turns bold"
Sub ColorizeItemRTF(r As RichTextBox, s As String, l As Long, IsBold As
Boolean)
Dim index1 As Long, index2 As Long
Do
index1 = r.Find(s, index1 + 1, , modMain.rtfMatchCase Or
modMain.rtfNoHighlight)
If index1 = -1 Then Exit Do
index2 = r.Find(vbCrLf, index1, , modMain.rtfNoHighlight)
r.SelStart = index1
r.SelLength = index2 - index1 + 1
r.SelColor = l
r.SelBold = IsBold
Loop
End Sub |
Partager