Skip to content

Commit

Permalink
[ApplyGameColors] Fix color and style continuation edge case.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmbook committed Oct 30, 2017
1 parent 40a8136 commit 0ab1beb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions trunk/modUTF8.bas
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ Public Function ApplyGameColors(saElements() As Variant, arr() As Variant) As Bo
TextBefore = Left$(saElements(i + 2), CodePos - 1)
TextAfter = Mid$(saElements(i + 2), CodePos + CodeLength)
If LenB(TextBefore) > 0 And LenB(TextAfter) > 0 Then
' split required, add element to arr
' color code mid string, split required, add element to arr
ReDim Preserve arr(LBound(arr) To UBound(arr) + 3)
arr(j + 2) = TextBefore
If Not IsColor Then
arr(j + 3) = CombineStyle(saElements(i), StyleSpec)
arr(j + 4) = saElements(i + 1) ' continue color
arr(j + 4) = arr(j + 1) ' continue color
Else
arr(j + 3) = vbNullString ' continue font
arr(j + 4) = Color
Expand Down Expand Up @@ -354,8 +354,11 @@ End Function

Private Function CombineStyle(ByVal StyleFont As String, ByVal StyleSpec As String) As String

If InStr(1, StyleFont, ":", vbBinaryCompare) > 0 Then
CombineStyle = StyleSpec & StyleFont
Dim ColPos As Long
ColPos = InStr(1, StyleFont, ":", vbBinaryCompare)

If ColPos > 0 Then
CombineStyle = Left$(StyleFont, ColPos - 1) & StyleSpec & Mid$(StyleFont, ColPos)
Else
CombineStyle = StyleSpec & ":" & StyleFont
End If
Expand Down

0 comments on commit 0ab1beb

Please sign in to comment.