diff --git a/comp/src/gb.highlight/.src/TextHighlighter.class b/comp/src/gb.highlight/.src/TextHighlighter.class index 5cd29626d..6ff337fef 100644 --- a/comp/src/gb.highlight/.src/TextHighlighter.class +++ b/comp/src/gb.highlight/.src/TextHighlighter.class @@ -561,6 +561,69 @@ Public Sub ToHTML(Text As String, Optional Theme As TextHighlighterTheme) As Str End +Public Sub ToRichText(Text As String, Optional Theme As TextHighlighterTheme) As String + + Dim aResult As New String[] + Dim Y As Integer + Dim sHTML As String + Dim aText As String[] + Dim sLineHtml As String + Dim sOldStyle As String + Dim sStyle As String + + HighlightStart(Theme) + + aText = Split(Text, "\n") + For Y = 0 To aText.Max + + HighlightLine(aText[Y]) + + sLineHtml = "" + + While Not HighlightToken() + + sHtml = Replace(Html($sToken), " ", " ") + sHtml = Replace(sHtml, "\t", "  ") + + If $hStyle.Bold Then sHtml = "" & sHtml & "" + If $hStyle.Underline Or If $hStyle.Dotted Then + sHtml = "" & sHtml & "" + Else If $hStyle.Strikeout Then + sHtml = "" & sHtml & "" + Endif + + sStyle = "" + 'If $iBackground <> Color.Default Then sStyle &= "background-color:" & Color.ToHTML($iBackground) & ";" + If $hStyle.Color Then sStyle &= " color=\"" & Color.ToHTML($hStyle.Color) & "\"" + + If sStyle <> sOldStyle Then + If sOldStyle Then sLineHtml &= "" + If sStyle Then sHtml = "" & sHtml + sOldStyle = sStyle + Endif + + sLineHtml &= sHtml + + Wend + + sLineHtml &= Html($sToken) + + ' If Me.Limit Then + ' If Y And If Not Trim(aResult[aResult.Max]) Then + ' aResult.Add("
") + ' Else + ' aResult.Add("
") + ' Endif + ' Endif + + aResult.Add(sLineHtml) + + Next + + Return "" & aResult.Join("
\n") & "
" + +End + Public Sub Paint(Text As String, X As Float, Y As Float, Optional Theme As TextHighlighterTheme, Optional Pos As Integer) Dim aText As String[]