Fix 'gambas' highlighting when 'CanRewrite' is FALSE. Fix highlighting recursion when 'CanRewrite' is TRUE.
[GB.HIGHLIGHT] * BUG: Fix 'gambas' highlighting when 'CanRewrite' is FALSE. * BUG: Fix highlighting recursion when 'CanRewrite' is TRUE. * NEW: TextHighlighter: 'ToHTML()', 'ToANSI()' and 'Paint()' now take the 'CanRewrite' property into account. * NEW: Raise an error if we try to load 'gb.highlight' whereas 'gb.eval.highlight' is already loaded.
This commit is contained in:
parent
982f48f0bb
commit
252617baef
5 changed files with 18 additions and 5 deletions
|
@ -22,11 +22,13 @@ Public Sub Main()
|
|||
'File.Save("~/test.html", TextHighlighter["sh"].ToHTML(File.Load("~/gambas/git/master/acinclude.m4")))
|
||||
|
||||
'Print TextHighlighter["javascript"].ToANSI(File.Load("~/asap/omogen/master/src/kernel/guygle.cgi/javascript/selectr.js"))
|
||||
With TextHighlighter["gambas"]
|
||||
With TextHighlighter["webpage"]
|
||||
Print .Colors.Join()
|
||||
.CanRewrite = True
|
||||
'Print .ToANSI(File.Load("~/asap/omogen/master/src/kernel/guygle.cgi/style/style-modern.css"))
|
||||
Print .ToANSI(File.Load("~/gambas/git/master/comp/src/gb.desktop/.src/Desktop.class"))
|
||||
'Print .ToANSI(File.Load("~/gambas/git/master/comp/src/gb.desktop/.src/Desktop.class"))
|
||||
'Print .ToANSI(File.Load("~/asap/omogen/master/src/kernel/guygle.cgi/.src/Site/Dialog.webpage"))
|
||||
File.Save("~/test.html", .ToHTML(File.Load("~/asap/omogen/master/src/kernel/guygle.cgi/.src/Site/Dialog.webpage")))
|
||||
End With
|
||||
|
||||
End
|
||||
|
|
|
@ -65,7 +65,7 @@ Static Public Sub _init()
|
|||
Case "webpage"
|
||||
sName = ("Gambas Web Page")
|
||||
Case Else
|
||||
sName = String.UCaseFirst(sKey)
|
||||
sName = sKey
|
||||
End Select
|
||||
Register(sKey, sName)
|
||||
Next
|
||||
|
@ -431,7 +431,11 @@ Private Sub HighlightLine(sLine As String)
|
|||
'bCanRewrite = Me.CanRewrite
|
||||
'Me.CanRewrite = False
|
||||
$aHighlight = Me.Run(sLine & "\n", $aState)
|
||||
$sLine = sLine
|
||||
If Me.CanRewrite Then
|
||||
$sLine = Me.TextAfter
|
||||
Else
|
||||
$sLine = sLine
|
||||
Endif
|
||||
'Me.CanRewrite = bCanRewrite
|
||||
$aStyles = $hTheme._GetStyles()
|
||||
$iPos = 1
|
||||
|
@ -565,7 +569,7 @@ Public Sub ToHTML(Text As String, Optional Theme As TextHighlighterTheme) As Str
|
|||
|
||||
Next
|
||||
|
||||
Return "<tt><span style=\"color:#000000;\">" & aResult.Join("<br>\n") & "</span></tt>"
|
||||
Return "<span style=\"color:#000000;font-family:monospace;\">" & aResult.Join("<br>\n") & "</span>"
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ Static Public Sub _init()
|
|||
|
||||
Dim sColor As String
|
||||
|
||||
If Component.IsLoaded("gb.eval.highlight") Then
|
||||
Error.Raise("'gb.highlight' component is not compatible with 'gb.eval.highlight'.")
|
||||
Endif
|
||||
|
||||
For Each sColor In ["Background", "Selection", "Current", "Breakpoint", "Highlight", "Normal", "Added", "Removed", "Error", "Comment", "Documentation", "Keyword", "Function", "Operator", "Symbol", "Number", "String", "Datatype", "Preprocessor", "Escape", "Constant"]
|
||||
_RegisterColor(sColor, "*")
|
||||
Next
|
||||
|
|
|
@ -106,6 +106,8 @@ Public Sub _Analyze(Text As String, (State) As Byte[], Optional (MatchLimit) As
|
|||
bNewLine = False
|
||||
bGotLimit = True
|
||||
sTextAfter = Left(sTextAfter, -2)
|
||||
Text = String.Left(Text, iPos)
|
||||
iLenText = iPos
|
||||
Break
|
||||
Endif
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ Private Sub Include(iHighlight As Byte, sHighlight As String, bMatch As Boolean,
|
|||
|
||||
hHighlight = TextHighlighter._Create(sHighlight)
|
||||
hHighlight.TextAfter = ""
|
||||
hHighlight.CanRewrite = Me.CanRewrite
|
||||
iPosBefore = $iPos
|
||||
|
||||
aHighlight = hHighlight._Analyze($sText, aState, bMatch, sLimit, ByRef $iPos)
|
||||
|
|
Loading…
Reference in a new issue